diff options
196 files changed, 6610 insertions, 3552 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index f93a0190116d..edf8ad2b6209 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -160,7 +160,9 @@ enum PROP_DOCUMENT_BASEDIAGRAM, PROP_DOCUMENT_ADDITIONAL_SHAPES, PROP_DOCUMENT_UPDATE_ADDIN, - PROP_DOCUMENT_NULL_DATE + PROP_DOCUMENT_NULL_DATE, + PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, + PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG }; void lcl_AddPropertiesToVector( @@ -232,6 +234,19 @@ void lcl_AddPropertiesToVector( PROP_DOCUMENT_NULL_DATE, ::getCppuType( static_cast< const ::com::sun::star::util::DateTime * >(0)), beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "DisableComplexChartTypes" ), + PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); + rOutProperties.push_back( + Property( C2U( "DisableDataTableDialog" ), + PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); } const uno::Sequence< Property > & lcl_GetPropertySequence() @@ -1583,6 +1598,8 @@ const std::vector< WrappedProperty* > ChartDocumentWrapper::createWrappedPropert aWrappedProperties.push_back( new WrappedAdditionalShapesProperty( *this ) ); aWrappedProperties.push_back( new WrappedRefreshAddInAllowedProperty( *this ) ); aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U("NullDate"),Any() ) ); // i99104 + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "DisableComplexChartTypes" ), uno::makeAny( sal_False ) ) ); + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "DisableDataTableDialog" ), uno::makeAny( sal_False ) ) ); return aWrappedProperties; } diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 75457a5e7cad..8b649072538e 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -37,6 +37,7 @@ #include "RangeSelectionHelper.hxx" // for RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR #include "TabPageNotifiable.hxx" +#include "macros.hxx" #include <rtl/math.hxx> #include <vcl/dialog.hxx> @@ -147,7 +148,8 @@ ErrorBarResources::ErrorBarResources( Window* pParent, Dialog * pParentDialog, m_pParentWindow( pParent ), m_pParentDialog( pParentDialog ), m_pCurrentRangeChoosingField( 0 ), - m_bHasInternalDataProvider( true ) + m_bHasInternalDataProvider( true ), + m_bDisableDataTableDialog( false ) { if( m_bNoneAvailable ) m_aRbNone.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); @@ -197,7 +199,21 @@ void ErrorBarResources::SetChartDocumentForRangeChoosing( const uno::Reference< chart2::XChartDocument > & xChartDocument ) { if( xChartDocument.is()) + { m_bHasInternalDataProvider = xChartDocument->hasInternalDataProvider(); + uno::Reference< beans::XPropertySet > xProps( xChartDocument, uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableDataTableDialog" ) ) >>= m_bDisableDataTableDialog; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } m_apRangeSelectionHelper.reset( new RangeSelectionHelper( xChartDocument )); // has internal data provider => rename "cell range" to "from data" @@ -240,6 +256,7 @@ void ErrorBarResources::UpdateControlStates() m_aLbFunction.Enable( bIsFunction ); // range buttons + m_aRbRange.Enable( !m_bHasInternalDataProvider || !m_bDisableDataTableDialog ); bool bShowRange = ( m_aRbRange.IsChecked()); bool bCanChooseRange = ( bShowRange && diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index 1696fcdc17c2..ec6c1d2a1c10 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -853,15 +853,35 @@ ChartTypeTabPage::ChartTypeTabPage( Window* pParent bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() ); + bool bDisableComplexChartTypes = false; + uno::Reference< beans::XPropertySet > xProps( m_xChartModel, uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableComplexChartTypes" ) ) >>= bDisableComplexChartTypes; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + m_aChartTypeDialogControllerList.push_back(new ColumnChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new BarChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new PieChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new AreaChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new LineChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() ); + if ( !bDisableComplexChartTypes ) + { + m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() ); + } m_aChartTypeDialogControllerList.push_back(new NetChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() ); + if ( !bDisableComplexChartTypes ) + { + m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() ); + } m_aChartTypeDialogControllerList.push_back(new CombiColumnLineChartDialogController() ); ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin(); diff --git a/chart2/source/controller/inc/res_ErrorBar.hxx b/chart2/source/controller/inc/res_ErrorBar.hxx index 36bceaffce9f..0b5f33b5c128 100644 --- a/chart2/source/controller/inc/res_ErrorBar.hxx +++ b/chart2/source/controller/inc/res_ErrorBar.hxx @@ -135,6 +135,7 @@ private: m_apRangeSelectionHelper; Edit * m_pCurrentRangeChoosingField; bool m_bHasInternalDataProvider; + bool m_bDisableDataTableDialog; DECL_LINK( CategoryChosen, void * ); DECL_LINK( SynchronizePosAndNeg, void * ); diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 2652aadfdb32..a01b80bfa22b 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -528,6 +528,23 @@ void ControllerCommandDispatch::updateCommandAvailability() bool bShapeContext = ( m_pChartController ? m_pChartController->isShapeContext() : false ); + bool bDisableDataTableDialog = false; + if ( m_xController.is() ) + { + Reference< beans::XPropertySet > xProps( m_xController->getModel(), uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableDataTableDialog" ) ) >>= bDisableDataTableDialog; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } + // edit commands m_aCommandAvailability[ C2U(".uno:Cut")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected; m_aCommandAvailability[ C2U(".uno:Copy")] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject; @@ -595,7 +612,7 @@ void ControllerCommandDispatch::updateCommandAvailability() // depending on own data m_aCommandAvailability[ C2U(".uno:DataRanges")] = bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData); - m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData; + m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData && !bDisableDataTableDialog; // titles m_aCommandAvailability[ C2U(".uno:MainTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle; @@ -631,9 +648,9 @@ void ControllerCommandDispatch::updateCommandAvailability() // series arrangement m_aCommandAvailability[ C2U(".uno:Forward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Forward" ) ) : - ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward ) ); + ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward && !bDisableDataTableDialog ) ); m_aCommandAvailability[ C2U(".uno:Backward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Backward" ) ) : - ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward ) ); + ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward && !bDisableDataTableDialog ) ); m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable; m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable; diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx index 116ce6f417f9..843aeb261a5f 100644 --- a/chart2/source/tools/WrappedPropertySet.cxx +++ b/chart2/source/tools/WrappedPropertySet.cxx @@ -34,6 +34,8 @@ // header for define DELETEZ #include <tools/solar.h> +#include <tools/debug.hxx> + //............................................................................. namespace chart { @@ -115,7 +117,11 @@ void SAL_CALL WrappedPropertySet::setPropertyValue( const OUString& rPropertyNam else if( xInnerPropertySet.is() ) xInnerPropertySet->setPropertyValue( rPropertyName, rValue ); else - throw beans::UnknownPropertyException(); + { +#if OSL_DEBUG_LEVEL > 1 + DBG_ERROR("found no inner property set to map to"); +#endif + } } catch( beans::UnknownPropertyException& ex ) { @@ -160,7 +166,11 @@ Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName else if( xInnerPropertySet.is() ) aRet = xInnerPropertySet->getPropertyValue( rPropertyName ); else - throw beans::UnknownPropertyException(); + { +#if OSL_DEBUG_LEVEL > 1 + DBG_ERROR("found no inner property set to map to"); +#endif + } } catch( beans::UnknownPropertyException& ex ) { diff --git a/sc/inc/AccessibleFilterTopWindow.hxx b/sc/inc/AccessibleFilterTopWindow.hxx index 7d01317c6b8d..55fcb503f51b 100644 --- a/sc/inc/AccessibleFilterTopWindow.hxx +++ b/sc/inc/AccessibleFilterTopWindow.hxx @@ -58,9 +58,6 @@ public: // Non-UNO Methods - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - getAccessibleChildMenu(); - enum ChildControlType { LISTBOX, TOGGLE_ALL, SINGLE_ON_BTN, SINGLE_OFF_BTN, OK_BTN, CANCEL_BTN }; diff --git a/sc/inc/ViewSettingsSequenceDefines.hxx b/sc/inc/ViewSettingsSequenceDefines.hxx index 9e787ea590fe..f23229d31a43 100644 --- a/sc/inc/ViewSettingsSequenceDefines.hxx +++ b/sc/inc/ViewSettingsSequenceDefines.hxx @@ -61,7 +61,7 @@ // this are the defines for the position of the settings in the // TableViewSettingsSequence -#define SC_TABLE_VIEWSETTINGS_COUNT 14 +#define SC_TABLE_VIEWSETTINGS_COUNT 15 #define SC_CURSOR_X 0 #define SC_CURSOR_Y 1 @@ -77,6 +77,7 @@ #define SC_TABLE_ZOOM_TYPE 11 #define SC_TABLE_ZOOM_VALUE 12 #define SC_TABLE_PAGE_VIEW_ZOOM_VALUE 13 +#define SC_TABLE_TAB_BG_COLOR 14 #define SC_CURSORPOSITIONX "CursorPositionX" #define SC_CURSORPOSITIONY "CursorPositionY" diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index 3eef919e2f1b..c5d49632292e 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -82,9 +82,10 @@ const SCSIZE SCSIZE_MAX = ::std::numeric_limits<SCSIZE>::max(); // A define to handle critical sections we hopefully don't need very often. #define SC_ROWLIMIT_MORE_THAN_32K 1 /* set to 1 if we throw the switch */ -// The maximum values. Defines are needed for preprocessor checks in -// bcaslot.cxx, otherwise type safe constants are preferred. -#define MAXROWCOUNT_DEFINE 65536 +// The maximum values. Defines are needed for preprocessor checks, for example +// in bcaslot.cxx, otherwise type safe constants are preferred. +//#define MAXROWCOUNT_DEFINE 65536 +#define MAXROWCOUNT_DEFINE 1048576 #define MAXCOLCOUNT_DEFINE 1024 // Count values @@ -123,7 +124,11 @@ const SCROW SCROW_REPEAT_NONE = SCROW_MAX; // #if SC_ROWLIMIT_MORE_THAN_64K // #error row limit 64k // #endif -#define SC_ROWLIMIT_MORE_THAN_64K 0 /* set to 1 if we throw the switch */ +#if MAXROWCOUNT_DEFINE > 65536 +#define SC_ROWLIMIT_MORE_THAN_64K 1 +#else +#define SC_ROWLIMIT_MORE_THAN_64K 0 +#endif const SCROW SCROWS64K = 65536; // === old stuff defines ===================================================== diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx index c82d607577bf..11b21bab0162 100644 --- a/sc/inc/attarray.hxx +++ b/sc/inc/attarray.hxx @@ -35,6 +35,7 @@ class ScDocument; class ScMarkArray; class ScPatternAttr; class ScStyleSheet; +class ScFlatBoolRowSegments; class Rectangle; class SfxItemPoolCache; @@ -154,7 +155,7 @@ public: BOOL bRefresh, BOOL bAttrs ); BOOL RemoveAreaMerge( SCROW nStartRow, SCROW nEndRow ); - void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pUsed, BOOL bReset ); + void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset ); BOOL IsStyleSheetUsed( const ScStyleSheet& rStyle, BOOL bGatherAllStyles ) const; void DeleteAreaSafe(SCROW nStartRow, SCROW nEndRow); diff --git a/sc/inc/chartuno.hxx b/sc/inc/chartuno.hxx index 795d655f3d06..fe261f26e517 100644 --- a/sc/inc/chartuno.hxx +++ b/sc/inc/chartuno.hxx @@ -31,6 +31,8 @@ #include "address.hxx" #include <svl/lstner.hxx> #include <tools/string.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> #include <com/sun/star/table/XTableChart.hpp> #include <com/sun/star/table/XTableCharts.hpp> @@ -39,6 +41,7 @@ #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XNamed.hpp> +#include <cppuhelper/compbase4.hxx> #include <cppuhelper/implbase4.hxx> @@ -113,12 +116,20 @@ public: }; -class ScChartObj : public cppu::WeakImplHelper4< - com::sun::star::table::XTableChart, - com::sun::star::document::XEmbeddedObjectSupplier, - com::sun::star::container::XNamed, - com::sun::star::lang::XServiceInfo >, - public SfxListener +typedef ::cppu::WeakComponentImplHelper4< + ::com::sun::star::table::XTableChart, + ::com::sun::star::document::XEmbeddedObjectSupplier, + ::com::sun::star::container::XNamed, + ::com::sun::star::lang::XServiceInfo > ScChartObj_Base; + +typedef ::comphelper::OPropertyContainer ScChartObj_PBase; +typedef ::comphelper::OPropertyArrayUsageHelper< ScChartObj > ScChartObj_PABase; + +class ScChartObj : public ::comphelper::OBaseMutex + ,public ScChartObj_Base + ,public ScChartObj_PBase + ,public ScChartObj_PABase + ,public SfxListener { private: ScDocShell* pDocShell; @@ -128,12 +139,32 @@ private: void Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders ); void GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const; +protected: + // ::comphelper::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::Exception); + using ::cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + + // ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; + public: ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN); virtual ~ScChartObj(); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + virtual void SAL_CALL disposing(); + // XTableChart virtual sal_Bool SAL_CALL getHasColumnHeaders() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHasColumnHeaders( sal_Bool bHasColumnHeaders ) @@ -163,6 +194,10 @@ public: throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); }; #endif diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 503f0975c5c9..af6292bbd830 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -30,7 +30,6 @@ #include "markarr.hxx" #include "global.hxx" -#include "compressedarray.hxx" #include "address.hxx" #include "rangenam.hxx" #include <tools/solar.h> @@ -65,7 +64,7 @@ class ScPostIt; struct ScFunctionData; struct ScLineFlags; struct ScMergePatternState; - +class ScFlatBoolRowSegments; #define COLUMN_DELTA 4 @@ -209,10 +208,10 @@ public: // UpdateSelectionFunction: Mehrfachselektion void UpdateSelectionFunction( const ScMarkData& rMark, ScFunctionData& rData, - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags, + ScFlatBoolRowSegments& rHiddenRows, BOOL bDoExclude, SCROW nExStartRow, SCROW nExEndRow ); void UpdateAreaFunction( ScFunctionData& rData, - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags, + ScFlatBoolRowSegments& rHiddenRows, SCROW nStartRow, SCROW nEndRow ); void CopyToColumn(SCROW nRow1, SCROW nRow2, USHORT nFlags, BOOL bMarked, @@ -329,7 +328,7 @@ public: const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, BOOL& rFound ) const; const ScStyleSheet* GetAreaStyle( BOOL& rFound, SCROW nRow1, SCROW nRow2 ) const; - void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pUsed, BOOL bReset ); + void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset ); BOOL IsStyleSheetUsed( const ScStyleSheet& rStyle, BOOL bGatherAllStyles ) const; /// May return -1 if not found diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx index dd1d18e49a51..d995550a2f1d 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -36,6 +36,8 @@ #include <memory> +#include <set> + class ScDocument; class ScBaseCell; class ScPatternAttr; @@ -206,8 +208,6 @@ private: ::std::auto_ptr<ScDBQueryParamBase> mpParam; ::std::auto_ptr<DataAccess> mpData; - bool GetThis(Value& rValue); - public: ScDBQueryDataIterator(ScDocument* pDocument, ScDBQueryParamBase* pParam); /// Does NOT reset rValue if no value found! @@ -305,7 +305,6 @@ public: ScBaseCell* GetNext(); SCCOL GetCol() { return nCol; } SCROW GetRow() { return nRow; } - ULONG GetNumberFormat(); // setzt alle Entry.nField einen weiter, wenn Spalte // wechselt, fuer ScInterpreter ScHLookup() @@ -514,6 +513,23 @@ public: const ScBaseCell* GetCell() const { return pFoundCell; } }; +// ============================================================================ + +class ScRowBreakIterator +{ +public: + static SCROW NOT_FOUND; + + explicit ScRowBreakIterator(::std::set<SCROW>& rBreaks); + SCROW first(); + SCROW next(); + +private: + ::std::set<SCROW>& mrBreaks; + ::std::set<SCROW>::const_iterator maItr; + ::std::set<SCROW>::const_iterator maEnd; +}; + #endif diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 47d4193accb1..83896f76378d 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -44,6 +44,7 @@ #include <memory> #include <map> +#include <set> // Wang Xu Ming -- 2009-8-17 // DataPilot Migration - Cache&&Performance @@ -144,6 +145,7 @@ class SfxUndoManager; class ScFormulaParserPool; struct ScClipParam; struct ScClipRangeNameData; +class ScRowBreakIterator; namespace com { namespace sun { namespace star { namespace lang { @@ -162,6 +164,9 @@ namespace com { namespace sun { namespace star { namespace script { namespace vba { class XVBAEventProcessor; } } + namespace sheet { + struct TablePageBreakData; + } } } } #include <svl/zforlist.hxx> @@ -388,12 +393,12 @@ private: // kein Broadcast, keine Listener aufbauen waehrend aus einem anderen // Doc (per Filter o.ae.) inserted wird, erst bei CompileAll / CalcAfterLoad BOOL bInsertingFromOtherDoc; - BOOL bImportingXML; // special handling of formula text + bool bLoadingMedium; + bool bImportingXML; // special handling of formula text BOOL bXMLFromWrapper; // distinguish ScXMLImportWrapper from external component BOOL bCalcingAfterLoad; // in CalcAfterLoad TRUE // wenn temporaer keine Listener auf/abgebaut werden sollen BOOL bNoListening; - BOOL bLoadingDone; BOOL bIdleDisabled; BOOL bInLinkUpdate; // TableLink or AreaLink BOOL bChartListenerCollectionNeedsUpdate; @@ -435,8 +440,6 @@ private: sal_Int16 mnNamedRangesLockCount; - inline BOOL RowHidden( SCROW nRow, SCTAB nTab ); // FillInfo - public: SC_DLLPUBLIC ULONG GetCellCount() const; // alle Zellen SCSIZE GetCellCount(SCTAB nTab, SCCOL nCol) const; @@ -623,6 +626,9 @@ public: Color& rColor, USHORT& rFlags ) const; SC_DLLPUBLIC void SetScenarioData( SCTAB nTab, const String& rComment, const Color& rColor, USHORT nFlags ); + SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const; + SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor ); + SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const; void GetScenarioFlags( SCTAB nTab, USHORT& rFlags ) const; SC_DLLPUBLIC BOOL IsActiveScenario( SCTAB nTab ) const; SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, BOOL bActive ); // nur fuer Undo etc. @@ -933,12 +939,17 @@ public: SCROW& rEndRow, BOOL bNotes = TRUE ) const; void InvalidateTableArea(); + SC_DLLPUBLIC BOOL GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const; + /** + * Find the maximum column position that contains printable data for the + * specified row range. The final column position must be equal or less + * than the initial value of rEndCol. + */ void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow ); - SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, ScDirection eDir ); @@ -1262,19 +1273,20 @@ public: void DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark ); void DeleteSelectionTab( SCTAB nTab, USHORT nDelFlag, const ScMarkData& rMark ); - // - SC_DLLPUBLIC void SetColWidth( SCCOL nCol, SCTAB nTab, USHORT nNewWidth ); SC_DLLPUBLIC void SetRowHeight( SCROW nRow, SCTAB nTab, USHORT nNewHeight ); SC_DLLPUBLIC void SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, USHORT nNewHeight ); - void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, BOOL bManual ); + + SC_DLLPUBLIC void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, + USHORT nNewHeight ); + void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, BOOL bManual ); SC_DLLPUBLIC USHORT GetColWidth( SCCOL nCol, SCTAB nTab ) const; - SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const; SC_DLLPUBLIC ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const; - ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const; - SC_DLLPUBLIC const ScSummableCompressedArray< SCROW, USHORT> & GetRowHeightArray( SCTAB nTab ) const; + SCROW GetRowForHeight( SCTAB nTab, ULONG nHeight ) const; + ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const; SC_DLLPUBLIC ULONG GetColOffset( SCCOL nCol, SCTAB nTab ) const; SC_DLLPUBLIC ULONG GetRowOffset( SCROW nRow, SCTAB nTab ) const; @@ -1283,22 +1295,6 @@ public: USHORT GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const; - // All FastGet...() methods have no check for valid nTab! - // They access ScCompressedArray objects, so using the - // single row taking ones in loops to access a sequence of - // single rows is no good idea! Use specialized range - // taking methods instead, or iterators. - SC_DLLPUBLIC ULONG FastGetRowHeight( SCROW nStartRow, SCROW nEndRow, - SCTAB nTab ) const; - inline ULONG FastGetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, - SCTAB nTab, double fScale ) const; - SC_DLLPUBLIC inline USHORT FastGetRowHeight( SCROW nRow, SCTAB nTab ) const; - inline SCROW FastGetRowForHeight( SCTAB nTab, ULONG nHeight ) const; - inline SCROW FastGetFirstNonHiddenRow( SCROW nStartRow, SCTAB nTab ) const; - /** No check for flags whether row is hidden, height value - is returned unconditionally. */ - inline USHORT FastGetOriginalRowHeight( SCROW nRow, SCTAB nTab ) const; - SCROW GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const; USHORT GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev, @@ -1335,6 +1331,44 @@ public: SC_DLLPUBLIC const ScBitMaskCompressedArray< SCROW, BYTE> & GetRowFlagsArray( SCTAB nTab ) const; SC_DLLPUBLIC ScBitMaskCompressedArray< SCROW, BYTE> & GetRowFlagsArrayModifiable( SCTAB nTab ); + SC_DLLPUBLIC void GetAllRowBreaks(::std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const; + SC_DLLPUBLIC void GetAllColBreaks(::std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const; + SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const; + SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const; + SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual); + SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual); + void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual); + void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual); + ::com::sun::star::uno::Sequence< + ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const; + + SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); + SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW& rLastRow); + SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL& rLastCol); + SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); + SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden); + SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden); + SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + + bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + bool ColFiltered(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); + SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered); + SC_DLLPUBLIC void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bFiltered); + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab); + + /** + * Write all column row flags to table's flag data, because not all column + * row attributes are stored in the flag data members. This is necessary + * for ods export. + */ + void SyncColRowFlags(); + /// @return the index of the last row with any set flags (auto-pagebreak is ignored). SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const; @@ -1356,8 +1390,6 @@ public: BOOL GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault); BOOL GetRowDefault( SCTAB nTab, SCROW nRow, SCCOL nLastCol, SCCOL& nDefault); - BOOL IsFiltered( SCROW nRow, SCTAB nTab ) const; - BOOL UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, BOOL bShow ); BOOL UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, BOOL bShow ); @@ -1374,6 +1406,7 @@ public: Size GetPageSize( SCTAB nTab ) const; void SetPageSize( SCTAB nTab, const Size& rSize ); void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow ); + void InvalidatePageBreaks(SCTAB nTab); void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = NULL ); void RemoveManualBreaks( SCTAB nTab ); BOOL HasManualBreaks( SCTAB nTab ) const; @@ -1470,8 +1503,6 @@ public: void DoColResize( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCSIZE nAdd ); - // Idleberechnung der OutputDevice-Zelltextbreite - BOOL IsLoadingDone() const { return bLoadingDone; } void InvalidateTextWidth( const String& rStyleName ); void InvalidateTextWidth( SCTAB nTab ); void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, BOOL bNumFormatChanged ); @@ -1508,8 +1539,9 @@ public: BOOL GetNoSetDirty() const { return bNoSetDirty; } void SetInsertingFromOtherDoc( BOOL bVal ) { bInsertingFromOtherDoc = bVal; } BOOL IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; } - void SetImportingXML( BOOL bVal ); - BOOL IsImportingXML() const { return bImportingXML; } + void SetLoadingMedium( bool bVal ); + void SetImportingXML( bool bVal ); + bool IsImportingXML() const { return bImportingXML; } void SetXMLFromWrapper( BOOL bVal ); BOOL IsXMLFromWrapper() const { return bXMLFromWrapper; } void SetCalcingAfterLoad( BOOL bVal ) { bCalcingAfterLoad = bVal; } @@ -1771,6 +1803,7 @@ public: SfxUndoManager* GetUndoManager(); bool IsInVBAMode() const; + ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const; private: // CLOOK-Impl-Methoden @@ -1833,53 +1866,6 @@ inline void ScDocument::SetSortParam( ScSortParam& rParam, SCTAB nTab ) mSheetSortParams[ nTab ] = rParam; } - -inline ULONG ScDocument::FastGetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, - SCTAB nTab, double fScale ) const -{ - return pTab[nTab]->pRowFlags->SumScaledCoupledArrayForCondition( nStartRow, - nEndRow, CR_HIDDEN, 0, *(pTab[nTab]->pRowHeight), fScale); -} - -inline USHORT ScDocument::FastGetRowHeight( SCROW nRow, SCTAB nTab ) const -{ - return ( pTab[nTab]->pRowFlags->GetValue(nRow) & CR_HIDDEN ) ? 0 : - pTab[nTab]->pRowHeight->GetValue(nRow); -} - -inline SCROW ScDocument::FastGetRowForHeight( SCTAB nTab, ULONG nHeight ) const -{ - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter( - *(pTab[nTab]->pRowFlags), 0, MAXROW, CR_HIDDEN, 0, - *(pTab[nTab]->pRowHeight)); - ULONG nSum = 0; - for ( ; aIter; aIter.NextRange() ) - { - ULONG nNew = *aIter * (aIter.GetRangeEnd() - aIter.GetRangeStart() + 1); - if (nSum + nNew > nHeight) - { - for ( ; aIter && nSum <= nHeight; ++aIter ) - { - nSum += *aIter; - } - return aIter.GetPos(); - } - nSum += nNew; - } - return aIter.GetPos(); -} - -inline SCROW ScDocument::FastGetFirstNonHiddenRow( SCROW nStartRow, SCTAB nTab) const -{ - return pTab[nTab]->pRowFlags->GetFirstForCondition( nStartRow, MAXROW, - CR_HIDDEN, 0); -} - -inline USHORT ScDocument::FastGetOriginalRowHeight( SCROW nRow, SCTAB nTab ) const -{ - return pTab[nTab]->pRowHeight->GetValue(nRow); -} - #endif diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 2c3ecee39e32..14c9515dfacb 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -115,7 +115,6 @@ private: void HandleCalculateEvents(); rtl::OUString maBuildId; - sal_Int32 mnXlsWriteProtPass; protected: const SfxItemPropertySet& GetPropertySet() const { return aPropSet; } diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index 65e89ec75d41..44aa1daa9a92 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -276,6 +276,7 @@ public: virtual ScDataObject* Clone() const; ScDPObject* operator[](USHORT nIndex) const {return (ScDPObject*)At(nIndex);} + ScDPObject* GetByName(const String& rName) const; void DeleteOnTab( SCTAB nTab ); void UpdateReference( UpdateRefMode eUpdateRefMode, diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 23668aa6813d..8178eb4a01d2 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -203,13 +203,16 @@ const SCSIZE PIVOT_MAXPAGEFIELD = 10; // FILTERED und MANUALSIZE nur fuer Zeilen moeglich const BYTE CR_HIDDEN = 1; //const BYTE CR_MARKED = 2; -const BYTE CR_PAGEBREAK = 4; +//const BYTE CR_PAGEBREAK = 4; const BYTE CR_MANUALBREAK = 8; const BYTE CR_FILTERED = 16; const BYTE CR_MANUALSIZE = 32; +const BYTE CR_ALL = (CR_HIDDEN | CR_MANUALBREAK | CR_FILTERED | CR_MANUALSIZE); -// was davon kommt in die Datei: -#define CR_SAVEMASK ( ~CR_PAGEBREAK ) +typedef BYTE ScBreakType; +const ScBreakType BREAK_NONE = 0; +const ScBreakType BREAK_PAGE = 1; +const ScBreakType BREAK_MANUAL = 2; // Insert-/Delete-Flags const USHORT IDF_NONE = 0x0000; diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index a9c1997f74f5..31934067988a 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -571,9 +571,13 @@ #define STR_STYLE_FAMILY_PAGE 434 #define STR_ERR_DATAPILOTSOURCE 435 -#define STR_PIVOT_FIRSTROWEMPTYERR 436 +#define STR_PIVOT_FIRSTROWEMPTYERR 436 #define STR_PIVOT_ONLYONEROWERR 437 -#define STR_COUNT 438 + +#define STR_UNDO_SET_TAB_BG_COLOR 438 +#define STR_UNDO_SET_MULTI_TAB_BG_COLOR 439 + +#define STR_COUNT 440 #endif diff --git a/sc/inc/olinetab.hxx b/sc/inc/olinetab.hxx index 3ffc03f4a249..82a49b3ba025 100644 --- a/sc/inc/olinetab.hxx +++ b/sc/inc/olinetab.hxx @@ -30,24 +30,24 @@ #include "collect.hxx" -#include "compressedarray.hxx" #include "scdllapi.h" #define SC_OL_MAXDEPTH 7 class SvStream; +class ScTable; class ScOutlineEntry : public ScDataObject { SCCOLROW nStart; SCSIZE nSize; - BOOL bHidden; - BOOL bVisible; + bool bHidden; + bool bVisible; public: ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, - BOOL bNewHidden = FALSE ); + bool bNewHidden = FALSE ); ScOutlineEntry( const ScOutlineEntry& rEntry ); virtual ScDataObject* Clone() const; @@ -55,14 +55,14 @@ public: SCCOLROW GetStart() const { return nStart; } SCSIZE GetSize() const { return nSize; } SCCOLROW GetEnd() const { return nStart+nSize-1; } - BOOL IsHidden() const { return bHidden; } // Gruppe versteckt - BOOL IsVisible() const { return bVisible; } // Control sichtbar? + bool IsHidden() const { return bHidden; } // Gruppe versteckt + bool IsVisible() const { return bVisible; } // Control sichtbar? void Move( SCsCOLROW nDelta ); void SetSize( SCSIZE nNewSize ); void SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize ); - void SetHidden( BOOL bNewHidden ); - void SetVisible( BOOL bNewVisible ); + void SetHidden( bool bNewHidden ); + void SetVisible( bool bNewVisible ); }; @@ -123,9 +123,7 @@ public: void InsertSpace( SCCOLROW nStartPos, SCSIZE nSize ); BOOL DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize ); - BOOL ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, - BOOL bShow, - const ScBitMaskCompressedArray< SCCOLROW, BYTE>& rHiddenFlags ); + bool ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol ); void RemoveAll(); }; diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index ad60c62a9c7e..4a697dc57558 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -833,9 +833,11 @@ #define FID_TAB_INDEX (TAB_POPUP_START+6) #define FID_TAB_RTL (TAB_POPUP_START+7) #define FID_TAB_DESELECTALL (TAB_POPUP_START+8) -#define FID_TAB_EVENTS (TAB_POPUP_START+9) +#define FID_TAB_MENU_SET_TAB_BG_COLOR (TAB_POPUP_START + 9) +#define FID_TAB_SET_TAB_BG_COLOR (TAB_POPUP_START + 10) +#define FID_TAB_EVENTS (TAB_POPUP_START+11) -#define TAB_POPUP_END (DATA_MENU_END + 20) +#define TAB_POPUP_END (TAB_POPUP_START + 20) #define OBJBAR_FORMAT_START (TAB_POPUP_END) #define SID_ALIGNLEFT (OBJBAR_FORMAT_START+6) @@ -1424,7 +1426,10 @@ #define RID_SCSTR_ONCLICK (STR_START + 402) -#define STR_END RID_SCSTR_ONCLICK +#define SCSTR_SET_TAB_BG_COLOR (STR_START + 403) +#define SCSTR_NO_TAB_BG_COLOR (STR_START + 404) + +#define STR_END (SCSTR_NO_TAB_BG_COLOR) #define BMP_START (STR_END) @@ -1632,8 +1637,9 @@ #define RID_SCDLG_RETYPEPASS_INPUT (SC_DIALOGS_START + 151) #define RID_SCDLG_TEXT_IMPORT_OPTIONS (SC_DIALOGS_START + 152) #define RID_POPUP_FILTER (SC_DIALOGS_START + 153) +#define RID_SCDLG_TAB_BG_COLOR (SC_DIALOGS_START + 154) -#define SC_DIALOGS_END (SC_DIALOGS_START + 154) +#define SC_DIALOGS_END (SC_DIALOGS_START + 155) #ifndef STD_MASKCOLOR #define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index d3c19bb539d5..442e62bdd9cb 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -286,6 +286,12 @@ public: virtual void GetInputString( String& rString ) const = 0; }; +class AbstractScTabBgColorDlg : public VclAbstractDialog //add for ScTabBgColorDlg +{ +public: + virtual void GetSelectedColor( Color& rColor ) const = 0; +}; + class AbstractScImportOptionsDlg : public VclAbstractDialog //add for ScImportOptionsDlg { public: @@ -435,6 +441,14 @@ public: const String& rDefault, ULONG nHelpId , int nId ) = 0; + + virtual AbstractScTabBgColorDlg * CreateScTabBgColorDlg ( Window* pParent, //add for ScTabBgColorDlg + const String& rTitle, //Dialog Title + const String& rTabBgColorNoColorText, //Label for no tab color + const Color& rDefaultColor, //Currently selected Color + ULONG nHelpId , + int nId ) = 0; + virtual AbstractScImportOptionsDlg * CreateScImportOptionsDlg ( Window* pParent, //add for ScImportOptionsDlg int nId, BOOL bAscii = TRUE, diff --git a/sc/inc/scextopt.hxx b/sc/inc/scextopt.hxx index d4a845040010..ad3fd4b1b51e 100644 --- a/sc/inc/scextopt.hxx +++ b/sc/inc/scextopt.hxx @@ -38,7 +38,6 @@ /** Extended settings for the document, used in import/export filters. */ struct ScExtDocSettings { - ScRange maOleSize; /// Visible range if embedded. String maGlobCodeName; /// Global codename (VBA module name). double mfTabBarWidth; /// Width of the tabbar, relative to frame window width (0.0 ... 1.0). sal_uInt32 mnLinkCnt; /// Recursive counter for loading external documents. diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 984e36bec03e..bd5d40709cd4 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -282,13 +282,11 @@ SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rO void SetInSharedDocSaving( bool bNew ) { mbIsInSharedDocSaving = bNew; } bool IsInSharedDocSaving() const { return mbIsInSharedDocSaving; } - //<!--Added by PengYunQuan for Validity Cell Range Picker SC_DLLPUBLIC BOOL RegisterRefWindow( USHORT nSlotId, Window *pWnd ); SC_DLLPUBLIC BOOL UnregisterRefWindow( USHORT nSlotId, Window *pWnd ); SC_DLLPUBLIC BOOL IsAliveRefDlg( USHORT nSlotId, Window *pWnd ); SC_DLLPUBLIC Window * Find1RefWindow( USHORT nSlotId, Window *pWndAncestor ); SC_DLLPUBLIC Window * Find1RefWindow( Window *pWndAncestor ); - //-->Added by PengYunQuan for Validity Cell Range Picker }; #define SC_MOD() ( *(ScModule**) GetAppData(SHL_CALC) ) diff --git a/sc/inc/segmenttree.hxx b/sc/inc/segmenttree.hxx new file mode 100644 index 000000000000..195331c750ad --- /dev/null +++ b/sc/inc/segmenttree.hxx @@ -0,0 +1,172 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_SEGMENTTREE_HXX +#define SC_SEGMENTTREE_HXX + +#include "address.hxx" + +#include <memory> + +class ScFlatBoolSegmentsImpl; + +class ScFlatBoolRowSegments +{ +public: + struct RangeData + { + SCROW mnRow1; + SCROW mnRow2; + bool mbValue; + }; + + class ForwardIterator + { + public: + explicit ForwardIterator(ScFlatBoolRowSegments& rSegs); + + bool getValue(SCROW nPos, bool& rVal); + SCROW getLastPos() const; + + private: + ScFlatBoolRowSegments& mrSegs; + + SCROW mnCurPos; + SCROW mnLastPos; + bool mbCurValue; + }; + + class RangeIterator + { + public: + explicit RangeIterator(ScFlatBoolRowSegments& rSegs); + bool getFirst(RangeData& rRange); + bool getNext(RangeData& rRange); + private: + ScFlatBoolRowSegments& mrSegs; + }; + + ScFlatBoolRowSegments(); + ScFlatBoolRowSegments(const ScFlatBoolRowSegments& r); + ~ScFlatBoolRowSegments(); + + void setTrue(SCROW nRow1, SCROW nRow2); + void setFalse(SCROW nRow1, SCROW nRow2); + bool getValue(SCROW nRow); + bool getRangeData(SCROW nRow, RangeData& rData); + void removeSegment(SCROW nRow1, SCROW nRow2); + void insertSegment(SCROW nRow, SCROW nSize, bool bSkipStartBoundary); + + SCROW findLastNotOf(bool bValue) const; + + void enableTreeSearch(bool bEnable); + void setInsertFromBack(bool bInsertFromBack); + +private: + ::std::auto_ptr<ScFlatBoolSegmentsImpl> mpImpl; +}; + +// ============================================================================ + +class ScFlatBoolColSegments +{ +public: + struct RangeData + { + SCCOL mnCol1; + SCCOL mnCol2; + bool mbValue; + }; + ScFlatBoolColSegments(); + ScFlatBoolColSegments(const ScFlatBoolColSegments& r); + ~ScFlatBoolColSegments(); + + void setTrue(SCCOL nCol1, SCCOL nCol2); + void setFalse(SCCOL nCol1, SCCOL nCol2); + bool getValue(SCCOL nCol); + bool getRangeData(SCCOL nCol, RangeData& rData); + void removeSegment(SCCOL nCol1, SCCOL nCol2); + void insertSegment(SCCOL nCol, SCCOL nSize, bool bSkipStartBoundary); + + void enableTreeSearch(bool bEnable); + void setInsertFromBack(bool bInsertFromBack); + +private: + ::std::auto_ptr<ScFlatBoolSegmentsImpl> mpImpl; +}; + +// ============================================================================ + +class ScFlatUInt16SegmentsImpl; + +class ScFlatUInt16RowSegments +{ +public: + struct RangeData + { + SCROW mnRow1; + SCROW mnRow2; + sal_uInt16 mnValue; + }; + + class ForwardIterator + { + public: + explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs); + + bool getValue(SCROW nPos, sal_uInt16& rVal); + SCROW getLastPos() const; + + private: + ScFlatUInt16RowSegments& mrSegs; + + SCROW mnCurPos; + SCROW mnLastPos; + sal_uInt16 mnCurValue; + }; + + ScFlatUInt16RowSegments(sal_uInt16 nDefault); + ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r); + ~ScFlatUInt16RowSegments(); + + void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue); + sal_uInt16 getValue(SCROW nRow); + sal_uInt32 getSumValue(SCROW nRow1, SCROW nRow2); + bool getRangeData(SCROW nRow, RangeData& rData); + void removeSegment(SCROW nRow1, SCROW nRow2); + void insertSegment(SCROW nRow, SCROW nSize, bool bSkipStartBoundary); + + SCROW findLastNotOf(sal_uInt16 nValue) const; + + void enableTreeSearch(bool bEnable); + void setInsertFromBack(bool bInsertFromBack); + +private: + ::std::auto_ptr<ScFlatUInt16SegmentsImpl> mpImpl; +}; + +#endif diff --git a/sc/inc/tabbgcolor.hxx b/sc/inc/tabbgcolor.hxx new file mode 100644 index 000000000000..c2b2a63baf65 --- /dev/null +++ b/sc/inc/tabbgcolor.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tabbgcolor.hxx,v $ + * $Revision: 1.00 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_TABBGCOLOR_HXX +#define SC_TABBGCOLOR_HXX + +#include "tools/color.hxx" +#include "address.hxx" + +#include <vector> + +struct ScUndoTabColorInfo +{ + SCTAB mnTabId; + Color maOldTabBgColor; + Color maNewTabBgColor; + + bool IsDefaultOldTabBgColor() const; + bool IsDefaultNewTabBgColor() const; + + explicit ScUndoTabColorInfo(SCTAB nTab); + ScUndoTabColorInfo(const ScUndoTabColorInfo& r); + + typedef ::std::vector<ScUndoTabColorInfo> List; +}; + +#endif diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 850cae4d587b..78e5875b6879 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -39,12 +39,20 @@ #include "compressedarray.hxx" #include <memory> +#include <set> +#include <boost/shared_ptr.hpp> namespace utl { class SearchParam; class TextSearch; } +namespace com { namespace sun { namespace star { + namespace sheet { + struct TablePageBreakData; + } +} } } + class SfxItemSet; class SfxStyleSheetBase; class SvxBoxInfoItem; @@ -73,6 +81,9 @@ struct RowInfo; struct ScFunctionData; struct ScLineFlags; class CollatorWrapper; +class ScFlatUInt16RowSegments; +class ScFlatBoolRowSegments; +class ScFlatBoolColSegments; class ScTable @@ -112,10 +123,19 @@ private: ::std::auto_ptr<ScTableProtection> pTabProtection; USHORT* pColWidth; - ScSummableCompressedArray< SCROW, USHORT>* pRowHeight; + ::boost::shared_ptr<ScFlatUInt16RowSegments> mpRowHeights; BYTE* pColFlags; ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags; + ::boost::shared_ptr<ScFlatBoolColSegments> mpHiddenCols; + ::boost::shared_ptr<ScFlatBoolRowSegments> mpHiddenRows; + ::boost::shared_ptr<ScFlatBoolColSegments> mpFilteredCols; + ::boost::shared_ptr<ScFlatBoolRowSegments> mpFilteredRows; + + ::std::set<SCROW> maRowPageBreaks; + ::std::set<SCROW> maRowManualBreaks; + ::std::set<SCCOL> maColPageBreaks; + ::std::set<SCCOL> maColManualBreaks; ScOutlineTable* pOutlineTable; @@ -157,8 +177,10 @@ private: ScRangeList* pScenarioRanges; Color aScenarioColor; + Color aTabBgColor; USHORT nScenarioFlags; BOOL bActiveScenario; + bool mbPageBreaksValid; friend class ScDocument; // fuer FillInfo friend class ScDocumentIterator; @@ -219,6 +241,8 @@ public: void SetScenarioComment( const String& rComment ) { aComment = rComment; } const Color& GetScenarioColor() const { return aScenarioColor; } void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; } + const Color& GetTabBgColor() const; + void SetTabBgColor(const Color& rColor); USHORT GetScenarioFlags() const { return nScenarioFlags; } void SetScenarioFlags(USHORT nNew) { nScenarioFlags = nNew; } void SetActiveScenario(BOOL bSet) { bActiveScenario = bSet; } @@ -374,7 +398,8 @@ public: void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const; - void InvalidateTableArea() { bTableAreaValid = FALSE; } + void InvalidateTableArea(); + void InvalidatePageBreaks(); BOOL GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = leer BOOL GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const; @@ -473,7 +498,7 @@ public: SCCOL& rCol, SCROW& rRow, ScMarkData& rMark, String& rUndoStr, ScDocument* pUndoDoc); - void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 ) const; + void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 ); void GetBorderLines( SCCOL nCol, SCROW nRow, const SvxBorderLine** ppLeft, const SvxBorderLine** ppTop, @@ -590,29 +615,49 @@ public: void SetRowHeight( SCROW nRow, USHORT nNewHeight ); BOOL SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeight, double nPPTX, double nPPTY ); + + /** + * Set specified row height to specified ranges. Don't check for drawing + * objects etc. Just set the row height. Nothing else. + * + * Note that setting a new row height via this function will not + * invalidate page breaks. + */ + void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeight ); + // nPPT fuer Test auf Veraenderung void SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ); - USHORT GetColWidth( SCCOL nCol ) const; - USHORT GetRowHeight( SCROW nRow ) const; - ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const; - ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const; - ULONG GetColOffset( SCCOL nCol ) const; - ULONG GetRowOffset( SCROW nRow ) const; + USHORT GetColWidth( SCCOL nCol ); + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ); + ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ); + ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ); + ULONG GetColOffset( SCCOL nCol ); + ULONG GetRowOffset( SCROW nRow ); + + /** + * Get the last row such that the height of row 0 to the end row is as + * high as possible without exceeding the specified height value. + * + * @param nHeight maximum desired height + * + * @return SCROW last row of the range within specified height. + */ + SCROW GetRowForHeight(ULONG nHeight); USHORT GetOriginalWidth( SCCOL nCol ) const; USHORT GetOriginalHeight( SCROW nRow ) const; - USHORT GetCommonWidth( SCCOL nEndCol ) const; + USHORT GetCommonWidth( SCCOL nEndCol ); - SCROW GetHiddenRowCount( SCROW nRow ) const; + SCROW GetHiddenRowCount( SCROW nRow ); - void ShowCol(SCCOL nCol, BOOL bShow); - void ShowRow(SCROW nRow, BOOL bShow); - void DBShowRow(SCROW nRow, BOOL bShow); + void ShowCol(SCCOL nCol, bool bShow); + void ShowRow(SCROW nRow, bool bShow); + void DBShowRow(SCROW nRow, bool bShow); - void ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow); - void DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow); + void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow); + void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow); void SetColFlags( SCCOL nCol, BYTE nNewFlags ); void SetRowFlags( SCROW nRow, BYTE nNewFlags ); @@ -626,15 +671,11 @@ public: /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored). SCROW GetLastChangedRow() const; - BOOL IsFiltered(SCROW nRow) const; - BYTE GetColFlags( SCCOL nCol ) const; BYTE GetRowFlags( SCROW nRow ) const; const ScBitMaskCompressedArray< SCROW, BYTE> * GetRowFlagsArray() const { return pRowFlags; } - const ScSummableCompressedArray< SCROW, USHORT> * GetRowHeightArray() const - { return pRowHeight; } BOOL UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, BOOL bShow ); BOOL UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, BOOL bShow ); @@ -643,6 +684,63 @@ public: void RemoveManualBreaks(); BOOL HasManualBreaks() const; + void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const; + void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const; + bool HasRowPageBreak(SCROW nRow) const; + bool HasColPageBreak(SCCOL nCol) const; + bool HasRowManualBreak(SCROW nRow) const; + bool HasColManualBreak(SCCOL nCol) const; + + /** + * Get the row position of the next manual break that occurs at or below + * specified row. When no more manual breaks are present at or below + * the specified row, -1 is returned. + * + * @param nRow row at which the search begins. + * + * @return SCROW next row position with manual page break, or -1 if no + * more manual breaks are present. + */ + SCROW GetNextManualBreak(SCROW nRow) const; + + void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow); + void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual); + void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual); + void SetRowBreak(SCROW nRow, bool bPage, bool bManual); + void SetColBreak(SCCOL nCol, bool bPage, bool bManual); + ::com::sun::star::uno::Sequence< + ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const; + + bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); + bool RowHidden(SCROW nRow, SCROW& rLastRow); + bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow); + bool ColHidden(SCCOL nCol, SCCOL& rLastCol); + bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); + void SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden); + void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden); + void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); + void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); + void CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset); + SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow); + SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow); + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow); + sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow); + + SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol); + + bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); + bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow); + void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); + void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); + void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered); + void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered); + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow); + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow); + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow); + + void SyncColRowFlags(); + void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ); void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ); @@ -760,14 +858,65 @@ private: void StartNeededListeners(); // only for cells where NeedsListening()==TRUE void SetRelNameDirty(); + void SetLoadingMedium(bool bLoading); + SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2, SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY, - const ScPatternAttr* pPattern, const SfxItemSet* pCondSet ) const; + const ScPatternAttr* pPattern, const SfxItemSet* pCondSet ); // idle calculation of OutputDevice text width for cell // also invalidates script type, broadcasts for "calc as shown" void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, BOOL bNumFormatChanged, BOOL bBroadcast ); + + /** + * In case the cell text goes beyond the column width, move the max column + * position to the right. This is called from ExtendPrintArea. + */ + void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY); + + /** + * Use this to iterate through non-empty visible cells in a single column. + */ + class VisibleDataCellIterator + { + public: + static SCROW ROW_NOT_FOUND; + + explicit VisibleDataCellIterator(ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn); + ~VisibleDataCellIterator(); + + /** + * Set the start row position. In case there is not visible data cell + * at the specified row position, it will move to the position of the + * first visible data cell below that point. + * + * @return First visible data cell if found, or NULL otherwise. + */ + ScBaseCell* reset(SCROW nRow); + + /** + * Find the next visible data cell position. + * + * @return Next visible data cell if found, or NULL otherwise. + */ + ScBaseCell* next(); + + /** + * Get the current row position. + * + * @return Current row position, or ROW_NOT_FOUND if the iterator + * doesn't point to a valid data cell position. + */ + SCROW getRow() const; + + private: + ScFlatBoolRowSegments& mrRowSegs; + ScColumn& mrColumn; + ScBaseCell* mpCell; + SCROW mnCurRow; + SCROW mnUBound; + }; }; diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 1e37e812efc1..2d011f425398 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -173,6 +173,7 @@ #define SC_UNONAME_COPYFORM "CopyFormulas" #define SC_UNONAME_TABLAYOUT "TableLayout" #define SC_UNONAME_AUTOPRINT "AutomaticPrintArea" +#define SC_UNONAME_TABCOLOR "TabColor" // LinkTarget #define SC_UNO_LINKDISPBIT "LinkDisplayBitmap" @@ -527,6 +528,7 @@ #define SC_UNO_ZOOMTYPE "ZoomType" #define SC_UNO_ZOOMVALUE "ZoomValue" #define SC_UNO_UPDTEMPL "UpdateFromTemplate" + /*Stampit enable/disable print cancel */ #define SC_UNO_ALLOWPRINTJOBCANCEL "AllowPrintJobCancel" @@ -612,6 +614,7 @@ // --> PB 2004-08-23 #i33095# Security Options #define SC_UNO_LOADREADONLY "LoadReadonly" // <-- +#define SC_UNO_MODIFYPASSWORDINFO "ModifyPasswordInfo" // FormulaParser #define SC_UNO_COMPILEENGLISH "CompileEnglish" diff --git a/sc/inc/unowids.hxx b/sc/inc/unowids.hxx index f58c3248bf81..175022a0ba14 100644 --- a/sc/inc/unowids.hxx +++ b/sc/inc/unowids.hxx @@ -78,7 +78,8 @@ #define SC_WID_UNO_AUTOPRINT ( SC_WID_UNO_START + 38 ) #define SC_WID_UNO_ABSNAME ( SC_WID_UNO_START + 39 ) #define SC_WID_UNO_CODENAME ( SC_WID_UNO_START + 40 ) -#define SC_WID_UNO_END ( SC_WID_UNO_START + 40 ) +#define SC_WID_UNO_TABCOLOR ( SC_WID_UNO_START + 41 ) +#define SC_WID_UNO_END ( SC_WID_UNO_START + 41 ) inline BOOL IsScUnoWid( USHORT nWid ) diff --git a/sc/prj/build.lst b/sc/prj/build.lst index 115e92990f3c..afdd953d2274 100755 --- a/sc/prj/build.lst +++ b/sc/prj/build.lst @@ -1,4 +1,4 @@ -sc sc : filter l10n vbahelper oovbaapi svx uui stoc BOOST:boost formula oox NULL +sc sc : filter l10n vbahelper oovbaapi svx uui stoc BOOST:boost formula MDDS:mdds oox NULL sc sc usr1 - all sc_mkout NULL sc sc\inc nmake - all sc_inc NULL sc sc\prj get - all sc_prj NULL diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 80a330f51890..94cd06d9f699 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -60,6 +60,7 @@ interface TableSelection FID_DELETE_TABLE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] FID_TAB_RENAME [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] FID_TAB_RTL [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + FID_TAB_SET_TAB_BG_COLOR [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] SID_TABLE_ACTIVATE [ ExecMethod = Execute; ] } diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index c1866d022439..1e42ce5fb1dc 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -7773,3 +7773,56 @@ SfxVoidItem ShareDocument SID_SHARE_DOC ToolBoxConfig = FALSE, GroupId = GID_OPTIONS; ] + +//-------------------------------------------------------------------------- +SvxColorItem TabBgColor FID_TAB_SET_TAB_BG_COLOR + +[ + // flags: + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = TRUE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + Readonly = FALSE, + + // config: + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_FORMAT; +] + +//-------------------------------------------------------------------------- +SfxVoidItem SetTabBgColor FID_TAB_MENU_SET_TAB_BG_COLOR +(SvxColorItem TabBgColor FID_TAB_SET_TAB_BG_COLOR) +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = TRUE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_FORMAT; +] + diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi index 578687886287..fac67839e656 100644 --- a/sc/sdi/tabvwsh.sdi +++ b/sc/sdi/tabvwsh.sdi @@ -52,13 +52,14 @@ interface Tables FID_TAB_SELECTALL [ ExecMethod = Execute; StateMethod = GetState; ] FID_TAB_DESELECTALL [ ExecMethod = Execute; StateMethod = GetState; ] FID_TAB_MENU_RENAME [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] - FID_TAB_APPEND [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] - FID_INS_TABLE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + FID_TAB_APPEND [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + FID_INS_TABLE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] FID_INS_TABLE_EXT [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] - FID_TABLE_HIDE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] - FID_TABLE_SHOW [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] - SID_SELECT_TABLES [ ExecMethod = Execute; StateMethod = GetState; ] - FID_TAB_EVENTS [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + FID_TABLE_HIDE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + FID_TABLE_SHOW [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + SID_SELECT_TABLES [ ExecMethod = Execute; StateMethod = GetState; ] + FID_TAB_MENU_SET_TAB_BG_COLOR [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + FID_TAB_EVENTS [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] } // =========================================================================== diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 53df13b4cd62..f3443312bd4e 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -52,7 +52,7 @@ #include "markarr.hxx" #include "rechead.hxx" #include "globstr.hrc" - +#include "segmenttree.hxx" #undef DBG_INVALIDATE #define DBGOUTPUT(s) \ @@ -1727,8 +1727,7 @@ SCsROW ScAttrArray::GetNextUnprotected( SCsROW nRow, BOOL bUp ) const return nRet; } - -void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pUsed, BOOL bReset ) +void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset ) { SCROW nStart = 0; SCSIZE nPos = 0; @@ -1740,7 +1739,7 @@ void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pU // for (SCROW nRow = nStart; nRow <= nEnd; nRow++) // pUsed[nRow] = TRUE; - memset( &pUsed[nStart], TRUE, nEnd-nStart+1 ); + rUsedRows.setTrue(nStart, nEnd); if (bReset) { diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 48a0e8597e1c..95482b1c624b 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -47,8 +47,10 @@ #define BCA_SLOTS_COL ((MAXCOLCOUNT_DEFINE) / 16) #if MAXROWCOUNT_DEFINE == 32000 #define BCA_SLOTS_ROW 256 +#define BCA_SLICE 125 #else -#define BCA_SLOTS_ROW ((MAXROWCOUNT_DEFINE) / 128) +#define BCA_SLICE 128 +#define BCA_SLOTS_ROW ((MAXROWCOUNT_DEFINE) / BCA_SLICE) #endif #define BCA_SLOT_COLS ((MAXCOLCOUNT_DEFINE) / BCA_SLOTS_COL) #define BCA_SLOT_ROWS ((MAXROWCOUNT_DEFINE) / BCA_SLOTS_ROW) @@ -59,7 +61,7 @@ #if (BCA_SLOT_ROWS * BCA_SLOTS_ROW) != (MAXROWCOUNT_DEFINE) #error bad BCA_SLOTS_ROW value! #endif -// size of slot array +// size of slot array if linear #define BCA_SLOTS_DEFINE (BCA_SLOTS_COL * BCA_SLOTS_ROW) // Arbitrary 2**31/8, assuming size_t can hold at least 2^31 values and // sizeof_ptr is at most 8 bytes. You'd probably doom your machine's memory @@ -67,14 +69,60 @@ #if BCA_SLOTS_DEFINE > 268435456 #error BCA_SLOTS_DEFINE DOOMed! #endif -// type safe constant -const SCSIZE BCA_SLOTS = BCA_SLOTS_DEFINE; // STATIC DATA ----------------------------------------------------------- TYPEINIT1( ScHint, SfxSimpleHint ); TYPEINIT1( ScAreaChangedHint, SfxHint ); +struct ScSlotData +{ + SCROW nStartRow; // first row of this segment + SCROW nStopRow; // first row of next segment + SCSIZE nSlice; // slice size in this segment + SCSIZE nCumulated; // cumulated slots of previous segments + + ScSlotData( SCROW r1, SCROW r2, SCSIZE s, SCSIZE c ) : nStartRow(r1), nStopRow(r2), nSlice(s), nCumulated(c) {} +}; +typedef ::std::vector< ScSlotData > ScSlotDistribution; +#if MAXROWCOUNT_DEFINE <= 65536 +// Linear distribution. +static ScSlotDistribution aSlotDistribution( ScSlotData( 0, MAXROWCOUNT, BCA_SLOT_ROWS, 0)); +static SCSIZE nBcaSlotsRow = BCA_SLOTS_ROW; +static SCSIZE nBcaSlots = BCA_SLOTS_DEFINE; +#else +// Logarithmic or any other distribution. +// Upper sheet part usually is more populated and referenced and gets fine +// grained resolution, larger data in larger hunks. +// Could be further enhanced by also applying a different distribution of +// column slots. +static SCSIZE initSlotDistribution( ScSlotDistribution & rSD, SCSIZE & rBSR ) +{ + SCSIZE nSlots = 0; + SCROW nRow1 = 0; + SCROW nRow2 = 32*1024; + SCSIZE nSlice = 128; + // Must be sorted by row1,row2! + while (nRow2 <= MAXROWCOUNT) + { + //fprintf( stderr, "r1,r2,slice,cum: %7zu, %7zu, %7zu, %7zu\n", (size_t)nRow1, (size_t)nRow2, (size_t)nSlice, (size_t)nSlots); + // {0,32k,128,0;32k,64k,256,0+256;64k,128k,512,0+256+128;128k,256k,1024,0+256+128+128;256k,512k,2048,...;512k,1M,4096,...} + rSD.push_back( ScSlotData( nRow1, nRow2, nSlice, nSlots)); + nSlots += (nRow2 - nRow1) / nSlice; + nRow1 = nRow2; + nRow2 *= 2; + nSlice *= 2; + } + //fprintf( stderr, "Slices: %zu, slots per sheet: %zu, memory per referenced sheet: %zu\n", (size_t) nSlots, (size_t) nSlots * BCA_SLOTS_COL, (size_t) nSlots * BCA_SLOTS_COL * sizeof(void*)); + rBSR = nSlots; + return nSlots; +} +static ScSlotDistribution aSlotDistribution; +static SCSIZE nBcaSlotsRow; +static SCSIZE nBcaSlots = initSlotDistribution( aSlotDistribution, nBcaSlotsRow) * BCA_SLOTS_COL; +// Ensure that all static variables are initialized with this one call. +#endif + ScBroadcastAreaSlot::ScBroadcastAreaSlot( ScDocument* pDocument, ScBroadcastAreaSlotMachine* pBASMa ) : @@ -393,14 +441,14 @@ void ScBroadcastAreaSlot::UpdateInsert( ScBroadcastArea* pArea ) ScBroadcastAreaSlotMachine::TableSlots::TableSlots() { - ppSlots = new ScBroadcastAreaSlot* [ BCA_SLOTS ]; - memset( ppSlots, 0 , sizeof( ScBroadcastAreaSlot* ) * BCA_SLOTS ); + ppSlots = new ScBroadcastAreaSlot* [ nBcaSlots ]; + memset( ppSlots, 0 , sizeof( ScBroadcastAreaSlot* ) * nBcaSlots ); } ScBroadcastAreaSlotMachine::TableSlots::~TableSlots() { - for ( ScBroadcastAreaSlot** pp = ppSlots + BCA_SLOTS; --pp >= ppSlots; /* nothing */ ) + for ( ScBroadcastAreaSlot** pp = ppSlots + nBcaSlots; --pp >= ppSlots; /* nothing */ ) { if (*pp) delete *pp; @@ -417,16 +465,16 @@ ScBroadcastAreaSlotMachine::ScBroadcastAreaSlotMachine( pEOUpdateChain( NULL ), nInBulkBroadcast( 0 ) { - for (TableSlotsMap::iterator iTab( aTableSlotsMap.begin()); - iTab != aTableSlotsMap.end(); ++iTab) - { - delete (*iTab).second; - } } ScBroadcastAreaSlotMachine::~ScBroadcastAreaSlotMachine() { + for (TableSlotsMap::iterator iTab( aTableSlotsMap.begin()); + iTab != aTableSlotsMap.end(); ++iTab) + { + delete (*iTab).second; + } delete pBCAlways; } @@ -438,13 +486,21 @@ inline SCSIZE ScBroadcastAreaSlotMachine::ComputeSlotOffset( SCCOL nCol = rAddress.Col(); if ( !ValidRow(nRow) || !ValidCol(nCol) ) { - DBG_ASSERT( FALSE, "Row/Col ungueltig!" ); + DBG_ERRORFILE( "Row/Col invalid, using first slot!" ); return 0; } - else - return - static_cast<SCSIZE>(nRow) / BCA_SLOT_ROWS + - static_cast<SCSIZE>(nCol) / BCA_SLOT_COLS * BCA_SLOTS_ROW; + for (size_t i=0; i < aSlotDistribution.size(); ++i) + { + if (nRow < aSlotDistribution[i].nStopRow) + { + const ScSlotData& rSD = aSlotDistribution[i]; + return rSD.nCumulated + + (static_cast<SCSIZE>(nRow - rSD.nStartRow)) / rSD.nSlice + + static_cast<SCSIZE>(nCol) / BCA_SLOT_COLS * nBcaSlotsRow; + } + } + DBG_ERRORFILE( "No slot found, using last!" ); + return nBcaSlots - 1; } @@ -459,9 +515,28 @@ void ScBroadcastAreaSlotMachine::ComputeAreaPoints( const ScRange& rRange, } +inline void ComputeNextSlot( SCSIZE & nOff, SCSIZE & nBreak, ScBroadcastAreaSlot** & pp, + SCSIZE & nStart, ScBroadcastAreaSlot** const & ppSlots, SCSIZE const & nRowBreak ) +{ + if ( nOff < nBreak ) + { + ++nOff; + ++pp; + } + else + { + nStart += nBcaSlotsRow; + nOff = nStart; + pp = ppSlots + nOff; + nBreak = nOff + nRowBreak; + } +} + + void ScBroadcastAreaSlotMachine::StartListeningArea( const ScRange& rRange, SvtListener* pListener ) { + //fprintf( stderr, "StartListeningArea (c,r,t): %d, %d, %d, %d, %d, %d\n", (int)rRange.aStart.Col(), (int)rRange.aStart.Row(), (int)rRange.aStart.Tab(), (int)rRange.aEnd.Col(), (int)rRange.aEnd.Row(), (int)rRange.aEnd.Tab()); if ( rRange == BCA_LISTEN_ALWAYS ) { if ( !pBCAlways ) @@ -500,18 +575,7 @@ void ScBroadcastAreaSlotMachine::StartListeningArea( const ScRange& rRange, } else (*pp)->InsertListeningArea( pArea); - if ( nOff < nBreak ) - { - ++nOff; - ++pp; - } - else - { - nStart += BCA_SLOTS_ROW; - nOff = nStart; - pp = ppSlots + nOff; - nBreak = nOff + nRowBreak; - } + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak); } } } @@ -521,6 +585,7 @@ void ScBroadcastAreaSlotMachine::StartListeningArea( const ScRange& rRange, void ScBroadcastAreaSlotMachine::EndListeningArea( const ScRange& rRange, SvtListener* pListener ) { + //fprintf( stderr, "EndListeningArea (c,r,t): %d, %d, %d, %d, %d, %d\n", (int)rRange.aStart.Col(), (int)rRange.aStart.Row(), (int)rRange.aStart.Tab(), (int)rRange.aEnd.Col(), (int)rRange.aEnd.Row(), (int)rRange.aEnd.Tab()); if ( rRange == BCA_LISTEN_ALWAYS ) { DBG_ASSERT( pBCAlways, "ScBroadcastAreaSlotMachine::EndListeningArea: BCA_LISTEN_ALWAYS but none established"); @@ -547,7 +612,7 @@ void ScBroadcastAreaSlotMachine::EndListeningArea( const ScRange& rRange, SCSIZE nBreak = nOff + nRowBreak; ScBroadcastAreaSlot** pp = ppSlots + nOff; ScBroadcastArea* pArea = NULL; - if (nOff == 0 && nEnd == BCA_SLOTS-1) + if (nOff == 0 && nEnd == nBcaSlots-1) { // Slightly optimized for 0,0,MAXCOL,MAXROW calls as they // happen for insertion and deletion of sheets. @@ -564,18 +629,7 @@ void ScBroadcastAreaSlotMachine::EndListeningArea( const ScRange& rRange, { if ( *pp ) (*pp)->EndListeningArea( rRange, pListener, pArea ); - if ( nOff < nBreak ) - { - ++nOff; - ++pp; - } - else - { - nStart += BCA_SLOTS_ROW; - nOff = nStart; - pp = ppSlots + nOff; - nBreak = nOff + nRowBreak; - } + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak); } } } @@ -629,18 +683,7 @@ BOOL ScBroadcastAreaSlotMachine::AreaBroadcastInRange( const ScRange& rRange, { if ( *pp ) bBroadcasted |= (*pp)->AreaBroadcastInRange( rRange, rHint ); - if ( nOff < nBreak ) - { - ++nOff; - ++pp; - } - else - { - nStart += BCA_SLOTS_ROW; - nOff = nStart; - pp = ppSlots + nOff; - nBreak = nOff + nRowBreak; - } + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak); } } return bBroadcasted; @@ -660,7 +703,7 @@ void ScBroadcastAreaSlotMachine::DelBroadcastAreasInRange( SCSIZE nOff = nStart; SCSIZE nBreak = nOff + nRowBreak; ScBroadcastAreaSlot** pp = ppSlots + nOff; - if (nOff == 0 && nEnd == BCA_SLOTS-1) + if (nOff == 0 && nEnd == nBcaSlots-1) { // Slightly optimized for 0,0,MAXCOL,MAXROW calls as they // happen for insertion and deletion of sheets. @@ -677,18 +720,7 @@ void ScBroadcastAreaSlotMachine::DelBroadcastAreasInRange( { if ( *pp ) (*pp)->DelBroadcastAreasInRange( rRange ); - if ( nOff < nBreak ) - { - ++nOff; - ++pp; - } - else - { - nStart += BCA_SLOTS_ROW; - nOff = nStart; - pp = ppSlots + nOff; - nBreak = nOff + nRowBreak; - } + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak); } } } @@ -711,7 +743,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas( SCSIZE nOff = nStart; SCSIZE nBreak = nOff + nRowBreak; ScBroadcastAreaSlot** pp = ppSlots + nOff; - if (nOff == 0 && nEnd == BCA_SLOTS-1) + if (nOff == 0 && nEnd == nBcaSlots-1) { // Slightly optimized for 0,0,MAXCOL,MAXROW calls as they // happen for insertion and deletion of sheets. @@ -728,18 +760,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas( { if ( *pp ) (*pp)->UpdateRemove( eUpdateRefMode, rRange, nDx, nDy, nDz ); - if ( nOff < nBreak ) - { - ++nOff; - ++pp; - } - else - { - nStart += BCA_SLOTS_ROW; - nOff = nStart; - pp = ppSlots + nOff; - nBreak = nOff + nRowBreak; - } + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak); } } } @@ -771,18 +792,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas( { if (*pp) (*pp)->UpdateRemoveArea( pArea); - if ( nOff < nBreak ) - { - ++nOff; - ++pp; - } - else - { - nStart += BCA_SLOTS_ROW; - nOff = nStart; - pp = ppSlots + nOff; - nBreak = nOff + nRowBreak; - } + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak); } } @@ -876,18 +886,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas( if (!*pp) *pp = new ScBroadcastAreaSlot( pDoc, this ); (*pp)->UpdateInsert( pArea ); - if ( nOff < nBreak ) - { - ++nOff; - ++pp; - } - else - { - nStart += BCA_SLOTS_ROW; - nOff = nStart; - pp = ppSlots + nOff; - nBreak = nOff + nRowBreak; - } + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak); } } diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index a70a9b86e186..aa492630ab0e 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -277,21 +277,21 @@ void ScBaseCell::StartListeningTo( ScDocument* pDoc ) if ( rRef1.IsColRel() ) { // ColName pDoc->StartListeningArea( ScRange ( - 0, + rRef1.nCol, rRef1.nRow, rRef1.nTab, - MAXCOL, - rRef2.nRow, + rRef2.nCol, + MAXROW, rRef2.nTab ), pFormCell ); } else { // RowName pDoc->StartListeningArea( ScRange ( rRef1.nCol, - 0, + rRef1.nRow, rRef1.nTab, - rRef2.nCol, - MAXROW, + MAXCOL, + rRef2.nRow, rRef2.nTab ), pFormCell ); } } @@ -367,21 +367,21 @@ void ScBaseCell::EndListeningTo( ScDocument* pDoc, ScTokenArray* pArr, if ( rRef1.IsColRel() ) { // ColName pDoc->EndListeningArea( ScRange ( - 0, + rRef1.nCol, rRef1.nRow, rRef1.nTab, - MAXCOL, - rRef2.nRow, + rRef2.nCol, + MAXROW, rRef2.nTab ), pFormCell ); } else { // RowName pDoc->EndListeningArea( ScRange ( rRef1.nCol, - 0, + rRef1.nRow, rRef1.nTab, - rRef2.nCol, - MAXROW, + MAXCOL, + rRef2.nRow, rRef2.nTab ), pFormCell ); } } diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 6a5fe824197b..e9fd26ced939 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -600,13 +600,11 @@ const ScStyleSheet* ScColumn::GetAreaStyle( BOOL& rFound, SCROW nRow1, SCROW nRo return bEqual ? pStyle : NULL; } - -void ScColumn::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pUsed, BOOL bReset ) +void ScColumn::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset ) { - pAttrArray->FindStyleSheet( pStyleSheet, pUsed, bReset ); + pAttrArray->FindStyleSheet( pStyleSheet, rUsedRows, bReset ); } - BOOL ScColumn::IsStyleSheetUsed( const ScStyleSheet& rStyle, BOOL bGatherAllStyles ) const { return pAttrArray->IsStyleSheetUsed( rStyle, bGatherAllStyles ); @@ -893,11 +891,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) SvtBroadcaster* pBC2 = pCell2->ReleaseBroadcaster(); pCell1->TakeBroadcaster( pBC2 ); pCell2->TakeBroadcaster( pBC1 ); - - ScHint aHint1( SC_HINT_DATACHANGED, aPos1, pCell2 ); - pDocument->Broadcast( aHint1 ); - ScHint aHint2( SC_HINT_DATACHANGED, aPos2, pCell1 ); - pDocument->Broadcast( aHint2 ); } else { @@ -918,7 +911,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) // insert ColEntry at new position Insert( nRow2, pCell1 ); - pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, aPos1, pDummyCell ) ); } return; @@ -999,14 +991,6 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) Delete( nRow2 ); // deletes pCell2 else if ( pNew2 ) Insert( nRow2, pNew2 ); // deletes pCell2 (if existing), inserts pNew2 - - // #64122# Bei Formeln hinterher nochmal broadcasten, damit die Formel nicht in irgendwelchen - // FormulaTrack-Listen landet, ohne die Broadcaster beruecksichtigt zu haben - // (erst hier, wenn beide Zellen eingefuegt sind) - if ( pBC1 && pFmlaCell2 ) - pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, aPos1, pNew1 ) ); - if ( pBC2 && pFmlaCell1 ) - pDocument->Broadcast( ScHint( SC_HINT_DATACHANGED, aPos2, pNew2 ) ); } @@ -1402,7 +1386,7 @@ void ScColumn::CopyScenarioFrom( const ScColumn& rSrcCol ) // Dies ist die Szenario-Tabelle, die Daten werden hineinkopiert ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW ); - SCROW nStart, nEnd; + SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) { @@ -1433,7 +1417,7 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const // Dies ist die Szenario-Tabelle, die Daten werden in die andere kopiert ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW ); - SCROW nStart, nEnd; + SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) { @@ -1482,7 +1466,7 @@ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const ScRange aRange( nCol, 0, nTab ); ScAttrIterator aAttrIter( pAttrArray, 0, MAXROW ); - SCROW nStart, nEnd; + SCROW nStart = -1, nEnd = -1; const ScPatternAttr* pPattern = aAttrIter.Next( nStart, nEnd ); while (pPattern) { diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 4c8de67ba271..2adf6d926f0f 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -66,6 +66,7 @@ #include "compiler.hxx" // ScTokenArray GetCodeLen #include "dbcolect.hxx" #include "fillinfo.hxx" +#include "segmenttree.hxx" #include <math.h> @@ -760,8 +761,8 @@ void ScColumn::GetOptimalHeight( SCROW nStartRow, SCROW nEndRow, USHORT* pHeight { ScAttrIterator aIter( pAttrArray, nStartRow, nEndRow ); - SCROW nStart; - SCROW nEnd; + SCROW nStart = -1; + SCROW nEnd = -1; SCROW nEditPos = 0; SCROW nNextEnd = 0; @@ -1407,11 +1408,11 @@ BOOL ScColumn::GetPrevDataPos(SCROW& rRow) const return bFound; } -BOOL ScColumn::GetNextDataPos(SCROW& rRow) const // groesser als rRow +BOOL ScColumn::GetNextDataPos(SCROW& rRow) const // greater than rRow { SCSIZE nIndex; if (Search( rRow, nIndex )) - ++nIndex; // naechste Zelle + ++nIndex; // next cell BOOL bMore = ( nIndex < nCount ); if ( bMore ) @@ -1782,7 +1783,7 @@ void lcl_UpdateSubTotal( ScFunctionData& rData, ScBaseCell* pCell ) // Mehrfachselektion: void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark, ScFunctionData& rData, - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags, + ScFlatBoolRowSegments& rHiddenRows, BOOL bDoExclude, SCROW nExStartRow, SCROW nExEndRow ) { SCSIZE nIndex; @@ -1790,7 +1791,8 @@ void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark, while (aDataIter.Next( nIndex )) { SCROW nRow = pItems[nIndex].nRow; - if ( !pRowFlags || !( pRowFlags->GetValue(nRow) & CR_HIDDEN ) ) + bool bRowHidden = rHiddenRows.getValue(nRow); + if ( !bRowHidden ) if ( !bDoExclude || nRow < nExStartRow || nRow > nExEndRow ) lcl_UpdateSubTotal( rData, pItems[nIndex].pCell ); } @@ -1798,7 +1800,7 @@ void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark, // bei bNoMarked die Mehrfachselektion weglassen void ScColumn::UpdateAreaFunction( ScFunctionData& rData, - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags, + ScFlatBoolRowSegments& rHiddenRows, SCROW nStartRow, SCROW nEndRow ) { SCSIZE nIndex; @@ -1806,7 +1808,8 @@ void ScColumn::UpdateAreaFunction( ScFunctionData& rData, while ( nIndex<nCount && pItems[nIndex].nRow<=nEndRow ) { SCROW nRow = pItems[nIndex].nRow; - if ( !pRowFlags || !( pRowFlags->GetValue(nRow) & CR_HIDDEN ) ) + bool bRowHidden = rHiddenRows.getValue(nRow); + if ( !bRowHidden ) lcl_UpdateSubTotal( rData, pItems[nIndex].pCell ); ++nIndex; } diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index be7211138c1d..65e896c7f2c4 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -1648,8 +1648,8 @@ BOOL ScColumn::GetDataEntries(SCROW nStartRow, TypedScStrCollection& rStrings, B void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow ) { ScAttrIterator aAttrIter( pAttrArray, nStartRow, nEndRow ); - SCROW nTop; - SCROW nBottom; + SCROW nTop = -1; + SCROW nBottom = -1; SCSIZE nIndex; const ScPatternAttr* pPattern = aAttrIter.Next( nTop, nBottom ); while (pPattern) diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 706783579a24..aa5b011da93b 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -49,6 +49,7 @@ using ::rtl::math::approxEqual; using ::std::vector; using ::rtl::OUString; +using ::std::set; // STATIC DATA ----------------------------------------------------------- @@ -345,7 +346,7 @@ BOOL ScValueIterator::GetThis(double& rValue, USHORT& rErr) if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow ) { nRow = pCol->pItems[nColRow].nRow + 1; - if ( !bSubTotal || !pDoc->pTab[nTab]->IsFiltered( nRow-1 ) ) + if ( !bSubTotal || !pDoc->pTab[nTab]->RowFiltered( nRow-1 ) ) { ScBaseCell* pCell = pCol->pItems[nColRow].pCell; ++nColRow; @@ -940,11 +941,6 @@ ScDBQueryDataIterator::ScDBQueryDataIterator(ScDocument* pDocument, ScDBQueryPar } } -bool ScDBQueryDataIterator::GetThis(Value& rValue) -{ - return mpData->getCurrent(rValue); -} - bool ScDBQueryDataIterator::GetFirst(Value& rValue) { return mpData->getFirst(rValue); @@ -1071,7 +1067,7 @@ ScBaseCell* ScCellIterator::GetThis() if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow ) { nRow = pCol->pItems[nColRow].nRow; - if ( !bSubTotal || !pDoc->pTab[nTab]->IsFiltered( nRow ) ) + if ( !bSubTotal || !pDoc->pTab[nTab]->RowFiltered( nRow ) ) { ScBaseCell* pCell = pCol->pItems[nColRow].pCell; @@ -1259,14 +1255,6 @@ ScBaseCell* ScQueryCellIterator::GetNext() return GetThis(); } -ULONG ScQueryCellIterator::GetNumberFormat() -{ - ScColumn* pCol = &(pDoc->pTab[nTab])->aCol[nCol]; - lcl_IterGetNumberFormat( nNumFormat, pAttrArray, - nAttrEndRow, pCol->pAttrArray, nRow, pDoc ); - return nNumFormat; -} - void ScQueryCellIterator::AdvanceQueryParamEntryField() { SCSIZE nEntries = aParam.GetEntryCount(); @@ -2147,3 +2135,24 @@ const ScPatternAttr* ScAttrRectIterator::GetNext( SCCOL& rCol1, SCCOL& rCol2, return NULL; // is nix mehr } +// ============================================================================ + +SCROW ScRowBreakIterator::NOT_FOUND = -1; + +ScRowBreakIterator::ScRowBreakIterator(set<SCROW>& rBreaks) : + mrBreaks(rBreaks), + maItr(rBreaks.begin()), maEnd(rBreaks.end()) +{ +} + +SCROW ScRowBreakIterator::first() +{ + maItr = mrBreaks.begin(); + return maItr == maEnd ? NOT_FOUND : *maItr; +} + +SCROW ScRowBreakIterator::next() +{ + ++maItr; + return maItr == maEnd ? NOT_FOUND : *maItr; +} diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 90220e54fbb3..d2c99c75a95e 100644..100755 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -190,11 +190,11 @@ ScDocument::ScDocument( ScDocumentMode eMode, // bNoSetDirty( TRUE ), bNoSetDirty( FALSE ), bInsertingFromOtherDoc( FALSE ), - bImportingXML( FALSE ), + bLoadingMedium( false ), + bImportingXML( false ), bXMLFromWrapper( FALSE ), bCalcingAfterLoad( FALSE ), bNoListening( FALSE ), - bLoadingDone( TRUE ), bIdleDisabled( FALSE ), bInLinkUpdate( FALSE ), bChartListenerCollectionNeedsUpdate( FALSE ), @@ -899,6 +899,8 @@ BOOL ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM SetNoListening( TRUE ); // noch nicht bei CopyToTable/Insert pTab[nOldPos]->CopyToTable(0, 0, MAXCOL, MAXROW, IDF_ALL, (pOnlyMarked != NULL), pTab[nNewPos], pOnlyMarked ); + pTab[nNewPos]->SetTabBgColor(pTab[nOldPos]->GetTabBgColor()); + SCsTAB nDz; /* if (nNewPos < nOldPos) nDz = ((short)nNewPos) - (short)nOldPos + 1; diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index ef6c7ab74f09..529eac2632a2 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -286,6 +286,26 @@ void ScDocument::SetScenarioData( SCTAB nTab, const String& rComment, } } +Color ScDocument::GetTabBgColor( SCTAB nTab ) const +{ + if (ValidTab(nTab) && pTab[nTab]) + return pTab[nTab]->GetTabBgColor(); + return Color(COL_AUTO); +} + +void ScDocument::SetTabBgColor( SCTAB nTab, const Color& rColor ) +{ + if (ValidTab(nTab) && pTab[nTab]) + pTab[nTab]->SetTabBgColor(rColor); +} + +bool ScDocument::IsDefaultTabBgColor( SCTAB nTab ) const +{ + if (ValidTab(nTab) && pTab[nTab]) + return pTab[nTab]->GetTabBgColor() == COL_AUTO; + return true; +} + void ScDocument::GetScenarioData( SCTAB nTab, String& rComment, Color& rColor, USHORT& rFlags ) const { @@ -1190,15 +1210,6 @@ BOOL ScDocument::SearchAndReplace(const SvxSearchItem& rSearchItem, return bFound; } -BOOL ScDocument::IsFiltered( SCROW nRow, SCTAB nTab ) const -{ - if (VALIDTAB(nTab)) - if (pTab[nTab]) - return pTab[nTab]->IsFiltered( nRow ); - DBG_ERROR("Falsche Tabellennummer"); - return 0; -} - // Outline anpassen BOOL ScDocument::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, BOOL bShow ) @@ -1611,46 +1622,43 @@ ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) nTwips = (long) (aPosRect.Top() / HMM_PER_TWIPS); SCROW nY1 = 0; - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter( - *(pTable->GetRowFlagsArray()), nY1, MAXROW, CR_HIDDEN, 0, - *(pTable->GetRowHeightArray())); bEnd = FALSE; - while (!bEnd && aIter) + for (SCROW i = nY1; i <= MAXROW && !bEnd; ++i) { - nY1 = aIter.GetPos(); - nAdd = (long) *aIter; + if (pTable->RowHidden(i)) + continue; + + nY1 = i; + nAdd = static_cast<long>(pTable->GetRowHeight(i)); if (nSize+nAdd <= nTwips+1 && nY1<MAXROW) { nSize += nAdd; ++nY1; - ++aIter; } else bEnd = TRUE; } - if (!aIter) - nY1 = aIter.GetIterEnd(); // all hidden down to the bottom + if (!bEnd) + nY1 = MAXROW; // all hidden down to the bottom nTwips = (long) (aPosRect.Bottom() / HMM_PER_TWIPS); SCROW nY2 = nY1; - aIter.NewLimits( nY2, MAXROW); bEnd = FALSE; - while (!bEnd && aIter) + for (SCROW i = nY2; i <= MAXROW && !bEnd; ++i) { - nY2 = aIter.GetPos(); - nAdd = (long) *aIter; + nY2 = i; + nAdd = static_cast<long>(pTable->GetRowHeight(i)); if (nSize+nAdd < nTwips && nY2<MAXROW) { nSize += nAdd; ++nY2; - ++aIter; } else bEnd = TRUE; } - if (!aIter) - nY2 = aIter.GetIterEnd(); // all hidden down to the bottom + if (!bEnd) + nY2 = MAXROW; // all hidden down to the bottom return ScRange( nX1,nY1,nTab, nX2,nY2,nTab ); } @@ -1688,24 +1696,33 @@ void lcl_SnapVer( ScTable* pTable, long& rVal, SCROW& rStartRow ) SCROW nRow = 0; long nTwips = (long) (rVal / HMM_PER_TWIPS); long nSnap = 0; - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter( - *(pTable->GetRowFlagsArray()), nRow, MAXROW, CR_HIDDEN, 0, - *(pTable->GetRowHeightArray())); - while ( aIter ) + + bool bFound = false; + for (SCROW i = nRow; i <= MAXROW; ++i) { - nRow = aIter.GetPos(); - long nAdd = *aIter; + SCROW nLastRow; + if (pTable->RowHidden(i, NULL, &nLastRow)) + { + i = nLastRow; + continue; + } + + nRow = i; + long nAdd = pTable->GetRowHeight(i); if ( nSnap + nAdd/2 < nTwips || nRow < rStartRow ) { nSnap += nAdd; ++nRow; - ++aIter; } else + { + bFound = true; break; + } } - if (!aIter) + if (!bFound) nRow = MAXROW; // all hidden down to the bottom + rVal = (long) ( nSnap * HMM_PER_TWIPS ); rStartRow = nRow; } @@ -1863,14 +1880,14 @@ Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow, for (i=0; i<nStartCol; i++) aRect.Left() += GetColWidth(i,nTab); - aRect.Top() += FastGetRowHeight( 0, nStartRow-1, nTab); + aRect.Top() += GetRowHeight( 0, nStartRow-1, nTab); aRect.Right() = aRect.Left(); aRect.Bottom() = aRect.Top(); for (i=nStartCol; i<=nEndCol; i++) aRect.Right() += GetColWidth(i,nTab); - aRect.Bottom() += FastGetRowHeight( nStartRow, nEndRow, nTab); + aRect.Bottom() += GetRowHeight( nStartRow, nEndRow, nTab); aRect.Left() = (long)(aRect.Left() * HMM_PER_TWIPS); aRect.Right() = (long)(aRect.Right() * HMM_PER_TWIPS); diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index 9da788fca01c..abef7d53c2af 100644 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -67,7 +67,7 @@ #include "charthelper.hxx" using namespace ::com::sun::star; - +#include <stdio.h> // ----------------------------------------------------------------------- @@ -722,7 +722,19 @@ void ScDocument::UpdateFontCharSet() } } -void ScDocument::SetImportingXML( BOOL bVal ) +void ScDocument::SetLoadingMedium( bool bVal ) +{ + bLoadingMedium = bVal; + for (SCTAB nTab = 0; nTab <= MAXTAB; ++nTab) + { + if (!pTab[nTab]) + return; + + pTab[nTab]->SetLoadingMedium(bVal); + } +} + +void ScDocument::SetImportingXML( bool bVal ) { bImportingXML = bVal; if (pDrawLayer) @@ -739,6 +751,8 @@ void ScDocument::SetImportingXML( BOOL bVal ) SetLayoutRTL( nTab, TRUE ); // includes mirroring; bImportingXML must be cleared first } } + + SetLoadingMedium(bVal); } void ScDocument::SetXMLFromWrapper( BOOL bVal ) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 3d4df4f330a6..37057b10ca5f 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -52,6 +52,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/sheet/TablePageBreakData.hpp> #include "document.hxx" #include "table.hxx" @@ -94,8 +95,12 @@ #include "clipparam.hxx" #include <map> +#include <limits> namespace WritingMode2 = ::com::sun::star::text::WritingMode2; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::sheet::TablePageBreakData; +using ::std::set; struct ScDefaultAttr { @@ -125,6 +130,7 @@ void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck ) CreateValidTabName( aString ); // keine doppelten pTab[nTab] = new ScTable(this, nTab, aString); + pTab[nTab]->SetLoadingMedium(bLoadingMedium); ++nMaxTableNumber; } } @@ -2009,9 +2015,6 @@ void ScDocument::CopyNonFilteredFromClip( SCCOL nCol1, SCROW nRow1, while ( nFlagTab < MAXTAB && !ppClipTab[nFlagTab] ) ++nFlagTab; - const ScBitMaskCompressedArray< SCROW, BYTE> & rSourceFlags = - pCBFCP->pClipDoc->GetRowFlagsArray( nFlagTab); - SCROW nSourceRow = rClipStartRow; SCROW nSourceEnd = 0; if (pCBFCP->pClipDoc->GetClipParam().maRanges.Count()) @@ -2021,12 +2024,15 @@ void ScDocument::CopyNonFilteredFromClip( SCCOL nCol1, SCROW nRow1, while ( nSourceRow <= nSourceEnd && nDestRow <= nRow2 ) { // skip filtered rows - nSourceRow = rSourceFlags.GetFirstForCondition( nSourceRow, nSourceEnd, CR_FILTERED, 0); + nSourceRow = pCBFCP->pClipDoc->FirstNonFilteredRow(nSourceRow, nSourceEnd, nFlagTab); if ( nSourceRow <= nSourceEnd ) { // look for more non-filtered rows following - SCROW nFollow = rSourceFlags.GetBitStateEnd( nSourceRow, CR_FILTERED, 0) - nSourceRow; + SCROW nLastRow = nSourceRow; + pCBFCP->pClipDoc->RowFiltered(nSourceRow, nFlagTab, NULL, &nLastRow); + SCROW nFollow = nLastRow - nSourceRow; + if (nFollow > nSourceEnd - nSourceRow) nFollow = nSourceEnd - nSourceRow; if (nFollow > nRow2 - nDestRow) @@ -2434,8 +2440,7 @@ void ScDocument::GetClipArea(SCCOL& nClipX, SCROW& nClipY, BOOL bIncludeFiltered while ( nCountTab < MAXTAB && !pTab[nCountTab] ) ++nCountTab; - SCROW nResult = GetRowFlagsArray( nCountTab).CountForCondition( - nStartRow, nEndRow, CR_FILTERED, 0); + SCROW nResult = CountNonFilteredRows(nStartRow, nEndRow, nCountTab); if ( nResult > 0 ) nClipY = nResult - 1; @@ -2474,8 +2479,13 @@ BOOL ScDocument::HasClipFilteredRows() if (!rClipRanges.Count()) return false; - return GetRowFlagsArray( nCountTab).HasCondition( rClipRanges.First()->aStart.Row(), - rClipRanges.First()->aEnd.Row(), CR_FILTERED, CR_FILTERED); + for (ScRange* p = rClipRanges.First(); p; p = rClipRanges.Next()) + { + bool bAnswer = pTab[nCountTab]->HasFilteredRows(p->aStart.Row(), p->aEnd.Row()); + if (bAnswer) + return true; + } + return false; } @@ -3098,6 +3108,11 @@ void ScDocument::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, ( nStartRow, nEndRow, nNewHeight, 1.0, 1.0 ); } +void ScDocument::SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, USHORT nNewHeight ) +{ + if ( ValidTab(nTab) && pTab[nTab] ) + pTab[nTab]->SetRowHeightOnly( nStartRow, nEndRow, nNewHeight ); +} void ScDocument::SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, BOOL bManual ) { @@ -3142,10 +3157,10 @@ USHORT ScDocument::GetOriginalHeight( SCROW nRow, SCTAB nTab ) const } -USHORT ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab ) const +USHORT ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero ) const { if ( ValidTab(nTab) && pTab[nTab] ) - return pTab[nTab]->GetRowHeight( nRow ); + return pTab[nTab]->GetRowHeight( nRow, NULL, NULL, bHiddenAsZero ); DBG_ERROR("Falsche Tabellennummer"); return 0; } @@ -3167,11 +3182,9 @@ ULONG ScDocument::GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) con return 0; } -ULONG ScDocument::FastGetRowHeight( SCROW nStartRow, SCROW nEndRow, - SCTAB nTab ) const +SCROW ScDocument::GetRowForHeight( SCTAB nTab, ULONG nHeight ) const { - return pTab[nTab]->pRowFlags->SumCoupledArrayForCondition( nStartRow, - nEndRow, CR_HIDDEN, 0, *(pTab[nTab]->pRowHeight)); + return pTab[nTab]->GetRowForHeight(nHeight); } ULONG ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, @@ -3192,29 +3205,6 @@ ULONG ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, return 0; } - -const ScSummableCompressedArray< SCROW, USHORT> & ScDocument::GetRowHeightArray( - SCTAB nTab ) const -{ - const ScSummableCompressedArray< SCROW, USHORT> * pHeight; - if ( ValidTab(nTab) && pTab[nTab] ) - pHeight = pTab[nTab]->GetRowHeightArray(); - else - { - DBG_ERROR("wrong sheet number"); - pHeight = 0; - } - if (!pHeight) - { - DBG_ERROR("no row heights at sheet"); - static ScSummableCompressedArray< SCROW, USHORT> aDummy( MAXROW, - ScGlobal::nStdRowHeight); - pHeight = &aDummy; - } - return *pHeight; -} - - SCROW ScDocument::GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const { if ( ValidTab(nTab) && pTab[nTab] ) @@ -3397,6 +3387,259 @@ const ScBitMaskCompressedArray< SCROW, BYTE> & ScDocument::GetRowFlagsArray( return *pFlags; } +void ScDocument::GetAllRowBreaks(set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return; + + pTab[nTab]->GetAllRowBreaks(rBreaks, bPage, bManual); +} + +void ScDocument::GetAllColBreaks(set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return; + + pTab[nTab]->GetAllColBreaks(rBreaks, bPage, bManual); +} + +ScBreakType ScDocument::HasRowBreak(SCROW nRow, SCTAB nTab) const +{ + ScBreakType nType = BREAK_NONE; + if (!ValidTab(nTab) || !pTab[nTab] || !ValidRow(nRow)) + return nType; + + if (pTab[nTab]->HasRowPageBreak(nRow)) + nType |= BREAK_PAGE; + + if (pTab[nTab]->HasRowManualBreak(nRow)) + nType |= BREAK_MANUAL; + + return nType; +} + +ScBreakType ScDocument::HasColBreak(SCCOL nCol, SCTAB nTab) const +{ + ScBreakType nType = BREAK_NONE; + if (!ValidTab(nTab) || !pTab[nTab] || !ValidCol(nCol)) + return nType; + + if (pTab[nTab]->HasColPageBreak(nCol)) + nType |= BREAK_PAGE; + + if (pTab[nTab]->HasColManualBreak(nCol)) + nType |= BREAK_MANUAL; + + return nType; +} + +void ScDocument::SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual) +{ + if (!ValidTab(nTab) || !pTab[nTab] || !ValidRow(nRow)) + return; + + pTab[nTab]->SetRowBreak(nRow, bPage, bManual); +} + +void ScDocument::SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual) +{ + if (!ValidTab(nTab) || !pTab[nTab] || !ValidCol(nCol)) + return; + + pTab[nTab]->SetColBreak(nCol, bPage, bManual); +} + +void ScDocument::RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual) +{ + if (!ValidTab(nTab) || !pTab[nTab] || !ValidRow(nRow)) + return; + + pTab[nTab]->RemoveRowBreak(nRow, bPage, bManual); +} + +void ScDocument::RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual) +{ + if (!ValidTab(nTab) || !pTab[nTab] || !ValidCol(nCol)) + return; + + pTab[nTab]->RemoveColBreak(nCol, bPage, bManual); +} + +Sequence<TablePageBreakData> ScDocument::GetRowBreakData(SCTAB nTab) const +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return Sequence<TablePageBreakData>(); + + return pTab[nTab]->GetRowBreakData(); +} + +bool ScDocument::RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow, SCROW* pLastRow) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return false; + + return pTab[nTab]->RowHidden(nRow, pFirstRow, pLastRow); +} + +bool ScDocument::RowHidden(SCROW nRow, SCTAB nTab, SCROW& rLastRow) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + { + rLastRow = nRow; + return false; + } + + return pTab[nTab]->RowHidden(nRow, rLastRow); +} + + +bool ScDocument::HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return false; + + return pTab[nTab]->HasHiddenRows(nStartRow, nEndRow); +} + +bool ScDocument::ColHidden(SCCOL nCol, SCTAB nTab, SCCOL& rLastCol) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + { + rLastCol = nCol; + return false; + } + + return pTab[nTab]->ColHidden(nCol, rLastCol); +} + +bool ScDocument::ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol, SCCOL* pLastCol) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + { + if (pFirstCol) + *pFirstCol = nCol; + if (pLastCol) + *pLastCol = nCol; + return false; + } + + return pTab[nTab]->ColHidden(nCol, pFirstCol, pLastCol); +} + +void ScDocument::SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return; + + pTab[nTab]->SetRowHidden(nStartRow, nEndRow, bHidden); +} + +void ScDocument::SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return; + + pTab[nTab]->SetColHidden(nStartCol, nEndCol, bHidden); +} + +SCROW ScDocument::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return ::std::numeric_limits<SCROW>::max();; + + return pTab[nTab]->FirstVisibleRow(nStartRow, nEndRow); +} + +SCROW ScDocument::LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return ::std::numeric_limits<SCROW>::max();; + + return pTab[nTab]->LastVisibleRow(nStartRow, nEndRow); +} + +SCROW ScDocument::CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return 0; + + return pTab[nTab]->CountVisibleRows(nStartRow, nEndRow); +} + +bool ScDocument::RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow, SCROW* pLastRow) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return false; + + return pTab[nTab]->RowFiltered(nRow, pFirstRow, pLastRow); +} + +bool ScDocument::HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return false; + + return pTab[nTab]->HasFilteredRows(nStartRow, nEndRow); +} + +bool ScDocument::ColFiltered(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol, SCCOL* pLastCol) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return false; + + return pTab[nTab]->ColFiltered(nCol, pFirstCol, pLastCol); +} + +void ScDocument::SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return; + + pTab[nTab]->SetRowFiltered(nStartRow, nEndRow, bFiltered); +} + +void ScDocument::SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bFiltered) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return; + + pTab[nTab]->SetColFiltered(nStartCol, nEndCol, bFiltered); +} + +SCROW ScDocument::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return ::std::numeric_limits<SCROW>::max();; + + return pTab[nTab]->FirstNonFilteredRow(nStartRow, nEndRow); +} + +SCROW ScDocument::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return ::std::numeric_limits<SCROW>::max();; + + return pTab[nTab]->LastNonFilteredRow(nStartRow, nEndRow); +} + +SCROW ScDocument::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return 0; + + return pTab[nTab]->CountNonFilteredRows(nStartRow, nEndRow); +} + +void ScDocument::SyncColRowFlags() +{ + for (SCTAB i = 0; i <= nMaxTableNumber; ++i) + { + if (!ValidTab(i) || !pTab[i]) + continue; + + pTab[i]->SyncColRowFlags(); + } +} SCROW ScDocument::GetLastFlaggedRow( SCTAB nTab ) const { @@ -3441,7 +3684,7 @@ SCCOL ScDocument::GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const SCROW ScDocument::GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart, bool bCareManualSize) const { - if ( ValidTab(nTab) && pTab[nTab] && pTab[nTab]->GetRowFlagsArray() && pTab[nTab]->GetRowHeightArray() ) + if ( ValidTab(nTab) && pTab[nTab] && pTab[nTab]->GetRowFlagsArray() && pTab[nTab]->mpRowHeights ) { BYTE nStartFlags = pTab[nTab]->GetRowFlags(nStart); USHORT nStartHeight = pTab[nTab]->GetOriginalHeight(nStart); @@ -3451,7 +3694,7 @@ SCROW ScDocument::GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart, bool bCa SCROW nFlagsEndRow; SCROW nHeightEndRow; BYTE nFlags = pTab[nTab]->GetRowFlagsArray()->GetValue( nRow, nIndex, nFlagsEndRow ); - USHORT nHeight = pTab[nTab]->GetRowHeightArray()->GetValue( nRow, nIndex, nHeightEndRow ); + USHORT nHeight = pTab[nTab]->GetRowHeight(nRow, NULL, &nHeightEndRow); if (((nStartFlags & CR_MANUALBREAK) != (nFlags & CR_MANUALBREAK)) || ((nStartFlags & CR_MANUALSIZE) != (nFlags & CR_MANUALSIZE)) || (bCareManualSize && (nStartFlags & CR_MANUALSIZE) && (nStartHeight != nHeight)) || @@ -4781,6 +5024,11 @@ void ScDocument::SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCRO pTab[nTab]->SetRepeatArea( nStartCol, nEndCol, nStartRow, nEndRow ); } +void ScDocument::InvalidatePageBreaks(SCTAB nTab) +{ + if (ValidTab(nTab) && pTab[nTab]) + pTab[nTab]->InvalidatePageBreaks(); +} void ScDocument::UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea ) { @@ -4960,6 +5208,12 @@ SfxUndoManager* ScDocument::GetUndoManager() return mpUndoManager; } +ScRowBreakIterator* ScDocument::GetRowBreakIterator(SCTAB nTab) const +{ + if (ValidTab(nTab) && pTab[nTab]) + return new ScRowBreakIterator(pTab[nTab]->maRowPageBreaks); + return NULL; +} void ScDocument::EnableUndo( bool bVal ) { diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 5394605969d0..a2a10329cf68 100644..100755 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -410,7 +410,7 @@ void ScDPObject::CreateOutput() nNewRow = 0; ScAddress aStart( aOutRange.aStart ); - aStart.SetRow( (USHORT) nNewRow ); + aStart.SetRow(nNewRow); pOutput->SetPosition( aStart ); //! modify aOutRange? @@ -2434,6 +2434,14 @@ void ScDPCollection::WriteRefsTo( ScDPCollection& r ) const } } +ScDPObject* ScDPCollection::GetByName(const String& rName) const +{ + for (USHORT i=0; i<nCount; i++) + if (static_cast<const ScDPObject*>(pItems[i])->GetName() == rName) + return static_cast<ScDPObject*>(pItems[i]); + return NULL; +} + String ScDPCollection::CreateNewName( USHORT nMin ) const { String aBase = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DataPilot")); diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 91688c6c0e2a..bdd6fd555b89 100644..100755 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1185,9 +1185,9 @@ void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionDa Reference<beans::XPropertySet> xPropSet(xSource, UNO_QUERY); if (xPropSet.is()) { - sal_Int32 nDataFieldCount = 0; - Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("DataFieldCount")); - if ((any >>= nDataFieldCount) && nDataFieldCount > 0) + sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet, + rtl::OUString::createFromAscii(SC_UNO_DATAFIELDCOUNT) ); + if (nDataFieldCount > 0) aResData.DataFieldIndex = (nRow - nDataStartRow) % nDataFieldCount; } @@ -1267,9 +1267,9 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>& if (!xPropSet.is()) return false; - sal_Int32 nDataFieldCount = 0; - Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("DataFieldCount")); - if (!(any >>= nDataFieldCount) || nDataFieldCount == 0) + sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet, + rtl::OUString::createFromAscii(SC_UNO_DATAFIELDCOUNT) ); + if (nDataFieldCount == 0) // No data field is present in this datapilot table. return false; diff --git a/sc/source/core/data/dptabresmember.cxx b/sc/source/core/data/dptabresmember.cxx deleted file mode 100644 index 8c3b7b164bc3..000000000000 --- a/sc/source/core/data/dptabresmember.cxx +++ /dev/null @@ -1,831 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright IBM Corporation 2009. - * Copyright 2009 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: dptabresmember.cxx,v $ - * $Revision: 1.0 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "dptabresmember.hxx" -// ----------------------------------------------------------------------- -ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData , - BOOL bForceSub ) : - pResultData( pData ), - aParentDimData( rParentDimData ), - /* pParentDim( pDim ), - pParentLevel( pLev ), - pMemberDesc( pDesc ),*/ - pChildDimension( NULL ), - pDataRoot( NULL ), - bHasElements( FALSE ), - bForceSubTotal( bForceSub ), - bHasHiddenDetails( FALSE ), - bInitialized( FALSE ), - nMemberStep( 1 ), - bAutoHidden( FALSE ) -{ - // pParentLevel/pMemberDesc is 0 for root members -} - -ScDPNormalResultMember::ScDPNormalResultMember( const ScDPResultData* pData, - BOOL bForceSub ) : - pResultData( pData ), - pChildDimension( NULL ), - pDataRoot( NULL ), - bHasElements( FALSE ), - bForceSubTotal( bForceSub ), - bHasHiddenDetails( FALSE ), - bInitialized( FALSE ), - nMemberStep( 1 ), - bAutoHidden( FALSE ) -{ -} - -ScDPNormalResultMember::~ScDPNormalResultMember() -{ - delete pChildDimension; - delete pDataRoot; -} - -String ScDPNormalResultMember::GetName() const -{ -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - const ScDPMember* pMemberDesc = GetDPMember(); - // End Comments - if (pMemberDesc) - return pMemberDesc->GetNameStr(); - else - return ScGlobal::GetRscString(STR_PIVOT_TOTAL); // root member -} - -void ScDPNormalResultMember::FillItemData( ScDPItemData& rData ) const -{ -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - const ScDPMember* pMemberDesc = GetDPMember(); -// End Comments - if (pMemberDesc) - pMemberDesc->FillItemData( rData ); - else - rData.SetString( ScGlobal::GetRscString(STR_PIVOT_TOTAL) ); // root member -} - -BOOL ScDPNormalResultMember::IsNamedItem( /*const ScDPItemData& r */SCROW nIndex ) const -{ - //! store ScDPMember pointer instead of ScDPMember ??? - const ScDPMember* pMemberDesc = GetDPMember(); - if (pMemberDesc) - return ((ScDPMember*)pMemberDesc)->IsNamedItem(/* r*/ nIndex ); - return FALSE; -} - -// Wang Xu Ming -- 2009-5-27 -// DataPilot Migration -bool ScDPNormalResultMember::IsValidEntry( const vector< SCROW >& aMembers ) const -{ - return GetEntryStatus( aMembers ) != ENTRY_INVALID; -} -// End Comments - -ENTRYSTATUS ScDPNormalResultMember::GetEntryStatus( const vector< SCROW >& aMembers ) const -{ - if ( !IsValid() ) - return ENTRY_INVALID; - - const ScDPResultDimension* pChildDim = GetChildDimension(); - if (pChildDim) - { - if (aMembers.size() < 2) - return ENTRY_INVALID; - - vector</*ScDPItemData*/SCROW>::const_iterator itr = aMembers.begin(); - vector</*ScDPItemData*/SCROW> aChildMembers(++itr, aMembers.end()); - return pChildDim->GetEntryStatus(aChildMembers); - } - else if( bHasHiddenDetails ) - return ENTRY_HASHIDDENDETAIL; - else - return ENTRY_VALID; -} - -void ScDPNormalResultMember::InitFrom( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev, - size_t nPos, ScDPInitState& rInitState , - BOOL bInitChild /*= TRUE */) - { - // with LateInit, initialize only those members that have data - if ( pResultData->IsLateInit() ) - return; - - bInitialized = TRUE; - - if (nPos >= ppDim.size() ) - return; - - // skip child dimension if details are not shown - if ( GetDPMember() && !GetDPMember()->getShowDetails() ) - { - // Wang Xu Ming -- 2009-6-16 - // Show DataLayout dimention - nMemberStep = 1; - while ( nPos < ppDim.size() ) - { - if ( ppDim[nPos] ->getIsDataLayoutDimension() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState , FALSE ); - return; - } - else - { //find next dim - nPos ++; - nMemberStep ++; - } - } - // End Comments - bHasHiddenDetails = TRUE; // only if there is a next dimension - return; - } - - if ( bInitChild ) - { - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState, TRUE ); - } -} - -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration -void ScDPNormalResultMember::LateInitFrom( LateInitParams& rParams/*const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev*/, - const vector< SCROW >& pItemData, size_t nPos, - ScDPInitState& rInitState ) -// End Comments -{ - // without LateInit, everything has already been initialized - if ( !pResultData->IsLateInit() ) - return; - - bInitialized = TRUE; - - if ( rParams.IsEnd( nPos ) /*nPos >= ppDim.size()*/) - // No next dimension. Bail out. - return; - - // skip child dimension if details are not shown - if ( GetDPMember() && !GetDPMember()->getShowDetails() ) - { - // Wang Xu Ming -- 2009-6-16 - // DataPilot Migration - // Show DataLayout dimention - nMemberStep = 1; - while ( !rParams.IsEnd( nPos ) ) - { - if ( rParams.GetDim( nPos ) ->getIsDataLayoutDimension() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - rParams.SetInitChild( FALSE ); - pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState ); - return; - } - else - { //find next dim - nPos ++; - nMemberStep ++; - } - } - // End Comments - bHasHiddenDetails = TRUE; // only if there is a next dimension - return; - } - - // LateInitFrom is called several times... - if ( rParams.GetInitChild() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState ); - } -} - -BOOL ScDPNormalResultMember::IsSubTotalInTitle(long nMeasure) const -{ - BOOL bRet = FALSE; - if ( pChildDimension && /*pParentLevel*/GetParentLevel() && - /*pParentLevel*/GetParentLevel()->IsOutlineLayout() && /*pParentLevel*/GetParentLevel()->IsSubtotalsAtTop() ) - { - long nUserSubStart; - long nSubTotals = GetSubTotalCount( &nUserSubStart ); - nSubTotals -= nUserSubStart; // visible count - if ( nSubTotals ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nSubTotals *= pResultData->GetMeasureCount(); // number of subtotals that will be inserted - - // only a single subtotal row will be shown in the outline title row - if ( nSubTotals == 1 ) - bRet = TRUE; - } - } - return bRet; -} - -long ScDPNormalResultMember::GetSize(long nMeasure) const -{ - if ( !IsVisible() ) - return 0; - const ScDPLevel* pParentLevel = GetParentLevel(); - long nExtraSpace = 0; - if ( pParentLevel && pParentLevel->IsAddEmpty() ) - ++nExtraSpace; - - if ( pChildDimension ) - { - // outline layout takes up an extra row for the title only if subtotals aren't shown in that row - if ( pParentLevel && pParentLevel->IsOutlineLayout() && !IsSubTotalInTitle( nMeasure ) ) - ++nExtraSpace; - - long nSize = pChildDimension->GetSize(nMeasure); - long nUserSubStart; - long nUserSubCount = GetSubTotalCount( &nUserSubStart ); - nUserSubCount -= nUserSubStart; // for output size, use visible count - if ( nUserSubCount ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nSize += pResultData->GetMeasureCount() * nUserSubCount; - else - nSize += nUserSubCount; - } - return nSize + nExtraSpace; - } - else - { - if ( nMeasure == SC_DPMEASURE_ALL ) - return pResultData->GetMeasureCount() + nExtraSpace; - else - return 1 + nExtraSpace; - } -} - - -BOOL ScDPNormalResultMember::IsVisible() const -{ - // not initialized -> shouldn't be there at all - // (allocated only to preserve ordering) - const ScDPLevel* pParentLevel = GetParentLevel(); - return ( bHasElements || ( pParentLevel && pParentLevel->getShowEmpty() ) ) && IsValid() && bInitialized; -} - -BOOL ScDPNormalResultMember::IsValid() const -{ - // non-Valid members are left out of calculation - - // was member set no invisible at the DataPilotSource? - const ScDPMember* pMemberDesc =GetDPMember(); - if ( pMemberDesc && !pMemberDesc->getIsVisible() ) - return FALSE; - - if ( bAutoHidden ) - return FALSE; - - return TRUE; -} - -BOOL ScDPNormalResultMember::HasHiddenDetails() const -{ - // bHasHiddenDetails is set only if the "show details" flag is off, - // and there was a child dimension to skip - - return bHasHiddenDetails; -} - -long ScDPNormalResultMember::GetSubTotalCount( long* pUserSubStart ) const -{ - if ( pUserSubStart ) - *pUserSubStart = 0; // default - - const ScDPLevel* pParentLevel = GetParentLevel(); - - if ( bForceSubTotal ) // set if needed for root members - return 1; // grand total is always "automatic" - else if ( pParentLevel ) - { - //! direct access via ScDPLevel - - uno::Sequence<sheet::GeneralFunction> aSeq = pParentLevel->getSubTotals(); - long nSequence = aSeq.getLength(); - if ( nSequence && aSeq[0] != sheet::GeneralFunction_AUTO ) - { - // For manual subtotals, always add "automatic" as first function - // (used for calculation, but not for display, needed for sorting, see lcl_GetForceFunc) - - ++nSequence; - if ( pUserSubStart ) - *pUserSubStart = 1; // visible subtotals start at 1 - } - return nSequence; - } - else - return 0; -} - -void ScDPNormalResultMember::ProcessData( const vector< SCROW >& aChildMembers, const ScDPResultDimension* pDataDim, - const vector< SCROW >& aDataMembers, const vector<ScDPValueData>& aValues ) -{ - SetHasElements(); - - if (pChildDimension) - pChildDimension->ProcessData( aChildMembers, pDataDim, aDataMembers, aValues ); - - if ( !pDataRoot ) - { - pDataRoot = new ScDPDataMember( pResultData, NULL ); - if ( pDataDim ) - pDataRoot->InitFrom( pDataDim ); // recursive - } - - ScDPSubTotalState aSubState; // initial state - - long nUserSubCount = GetSubTotalCount(); - - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !pChildDimension ) - nUserSubCount = 1; - - const ScDPLevel* pParentLevel = GetParentLevel(); - - for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic" - { - // #i68338# if nUserSubCount is 1 (automatic only), don't set nRowSubTotalFunc - if ( pChildDimension && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( pParentLevel, nUserPos ); - } - - pDataRoot->ProcessData( aDataMembers, aValues, aSubState ); - } -} - -void ScDPNormalResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pSequences, - long& rPos, long nMeasure, BOOL bRoot, - const String* pMemberName, - const String* pMemberCaption ) -{ - // IsVisible() test is in ScDPResultDimension::FillMemberResults - // (not on data layout dimension) - - long nSize = GetSize(nMeasure); - sheet::MemberResult* pArray = pSequences->getArray(); - DBG_ASSERT( rPos+nSize <= pSequences->getLength(), "bumm" ); - - BOOL bIsNumeric = FALSE; - String aName; - if ( pMemberName ) // if pMemberName != NULL, use instead of real member name - aName = *pMemberName; - else - { - ScDPItemData aItemData; - FillItemData( aItemData ); - aName = aItemData.GetString(); - bIsNumeric = aItemData.IsValue(); - } - const ScDPDimension* pParentDim = GetParentDim(); - if ( bIsNumeric && pParentDim && pResultData->IsNumOrDateGroup( pParentDim->GetDimension() ) ) - { - // Numeric group dimensions use numeric entries for proper sorting, - // but the group titles must be output as text. - bIsNumeric = FALSE; - } - - String aCaption = aName; - if ( pMemberCaption ) // use pMemberCaption if != NULL - aCaption = *pMemberCaption; - if (!aCaption.Len()) - aCaption = ScGlobal::GetRscString(STR_EMPTYDATA); - - if ( !bIsNumeric ) - { - // add a "'" character so a string isn't parsed as value in the output cell - //! have a separate bit in Flags (MemberResultFlags) instead? - aCaption.Insert( (sal_Unicode) '\'', 0 ); - } - - if ( nSize && !bRoot ) // root is overwritten by first dimension - { - pArray[rPos].Name = rtl::OUString(aName); - pArray[rPos].Caption = rtl::OUString(aCaption); - pArray[rPos].Flags |= sheet::MemberResultFlags::HASMEMBER; - - // set "continue" flag (removed for subtotals later) - for (long i=1; i<nSize; i++) - pArray[rPos+i].Flags |= sheet::MemberResultFlags::CONTINUE; - } - - const ScDPLevel* pParentLevel = GetParentLevel(); - long nExtraSpace = 0; - if ( pParentLevel && pParentLevel->IsAddEmpty() ) - ++nExtraSpace; - - BOOL bTitleLine = FALSE; - if ( pParentLevel && pParentLevel->IsOutlineLayout() ) - bTitleLine = TRUE; - - // if the subtotals are shown at the top (title row) in outline layout, - // no extra row for the subtotals is needed - BOOL bSubTotalInTitle = IsSubTotalInTitle( nMeasure ); - - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - { - if ( bTitleLine ) // in tabular layout the title is on a separate row - ++rPos; // -> fill child dimension one row below - - if (bRoot) // same sequence for root member - pChildDimension->FillMemberResults( pSequences, rPos, nMeasure ); - else - // Wang Xu Ming -- 2009-6-16 - // DataPilot Migration - // for show details - pChildDimension->FillMemberResults( pSequences + nMemberStep/*1*/, rPos, nMeasure ); - // End Comments - - if ( bTitleLine ) // title row is included in GetSize, so the following - --rPos; // positions are calculated with the normal values - } - - rPos += nSize; - - long nUserSubStart; - long nUserSubCount = GetSubTotalCount(&nUserSubStart); - if ( nUserSubCount && pChildDimension && !bSubTotalInTitle ) - { - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - - rPos -= nSubSize * (nUserSubCount - nUserSubStart); // GetSize includes space for SubTotal - rPos -= nExtraSpace; // GetSize includes the empty line - - for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++) - { - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - - ScSubTotalFunc eForce = SUBTOTAL_FUNC_NONE; - if (bHasChild) - eForce = lcl_GetForceFunc( pParentLevel, nUserPos ); - - String aSubStr = aName; //! caption? - aSubStr += ' '; - aSubStr += pResultData->GetMeasureString(nMemberMeasure, FALSE, eForce); - - pArray[rPos].Name = rtl::OUString(aName); - pArray[rPos].Caption = rtl::OUString(aSubStr); - pArray[rPos].Flags = ( pArray[rPos].Flags | - ( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) & - ~sheet::MemberResultFlags::CONTINUE; - - if ( nMeasure == SC_DPMEASURE_ALL ) - { - // data layout dimension is (direct/indirect) child of this. - // data layout dimension must have name for all entries. - - uno::Sequence<sheet::MemberResult>* pLayoutSeq = pSequences; - if (!bRoot) - ++pLayoutSeq; - ScDPResultDimension* pLayoutDim = pChildDimension; - while ( pLayoutDim && !pLayoutDim->IsDataLayout() ) - { - pLayoutDim = pLayoutDim->GetFirstChildDimension(); - ++pLayoutSeq; - } - if ( pLayoutDim ) - { - sheet::MemberResult* pLayoutArray = pLayoutSeq->getArray(); - String aDataName = pResultData->GetMeasureDimensionName(nMemberMeasure); - pLayoutArray[rPos].Name = rtl::OUString(aDataName); - } - } - - rPos += 1; - } - } - - rPos += nExtraSpace; // add again (subtracted above) - } -} - -void ScDPNormalResultMember::FillDataResults( const ScDPResultMember* pRefMember, - uno::Sequence< uno::Sequence<sheet::DataResult> >& rSequence, - long& rRow, long nMeasure ) const -{ - // IsVisible() test is in ScDPResultDimension::FillDataResults - // (not on data layout dimension) - const ScDPLevel* pParentLevel = GetParentLevel(); - long nStartRow = rRow; - - long nExtraSpace = 0; - if ( pParentLevel && pParentLevel->IsAddEmpty() ) - ++nExtraSpace; - - BOOL bTitleLine = FALSE; - if ( pParentLevel && pParentLevel->IsOutlineLayout() ) - bTitleLine = TRUE; - - BOOL bSubTotalInTitle = IsSubTotalInTitle( nMeasure ); - - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - { - if ( bTitleLine ) // in tabular layout the title is on a separate row - ++rRow; // -> fill child dimension one row below - - pChildDimension->FillDataResults( pRefMember, rSequence, rRow, nMeasure ); // doesn't modify rRow - rRow += (USHORT) GetSize( nMeasure ); - - if ( bTitleLine ) // title row is included in GetSize, so the following - --rRow; // positions are calculated with the normal values - } - - long nUserSubStart; - long nUserSubCount = GetSubTotalCount(&nUserSubStart); - if ( nUserSubCount || !bHasChild ) - { - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !bHasChild ) - { - nUserSubCount = 1; - nUserSubStart = 0; - } - - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - if (bHasChild) - { - rRow -= nSubSize * ( nUserSubCount - nUserSubStart ); // GetSize includes space for SubTotal - rRow -= nExtraSpace; // GetSize includes the empty line - } - - long nMoveSubTotal = 0; - if ( bSubTotalInTitle ) - { - nMoveSubTotal = rRow - nStartRow; // force to first (title) row - rRow = nStartRow; - } - - if ( pDataRoot ) - { - ScDPSubTotalState aSubState; // initial state - - for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++) - { - if ( bHasChild && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos ); - } - - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL ) - nMemberMeasure = SC_DPMEASURE_ALL; - - DBG_ASSERT( rRow < rSequence.getLength(), "bumm" ); - uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rRow]; - long nSeqCol = 0; - pDataRoot->FillDataRow( pRefMember, rSubSeq, nSeqCol, nMemberMeasure, bHasChild, aSubState ); - - rRow += 1; - } - } - } - else - rRow += nSubSize * ( nUserSubCount - nUserSubStart ); // empty rows occur when ShowEmpty is true - - // add extra space again if subtracted from GetSize above, - // add to own size if no children - rRow += nExtraSpace; - - rRow += nMoveSubTotal; - } -} - -void ScDPNormalResultMember::UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const -{ - // IsVisible() test is in ScDPResultDimension::FillDataResults - // (not on data layout dimension) - - BOOL bHasChild = ( pChildDimension != NULL ); - - long nUserSubCount = GetSubTotalCount(); - // process subtotals even if not shown -// if ( nUserSubCount || !bHasChild ) - { - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !bHasChild ) - nUserSubCount = 1; - - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - - if ( pDataRoot ) - { - ScDPSubTotalState aSubState; // initial state - - for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic" - { - if ( bHasChild && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos ); - } - - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL ) - nMemberMeasure = SC_DPMEASURE_ALL; - - pDataRoot->UpdateDataRow( pRefMember, nMemberMeasure, bHasChild, aSubState ); - } - } - } - } - - if (bHasChild) // child dimension must be processed last, so the column total is known - { - pChildDimension->UpdateDataResults( pRefMember, nMeasure ); - } -} - -void ScDPNormalResultMember::SortMembers( ScDPResultMember* pRefMember ) -{ - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - pChildDimension->SortMembers( pRefMember ); // sorting is done at the dimension - - if ( IsRoot() && pDataRoot ) - { - // use the row root member to sort columns - // sub total count is always 1 - - pDataRoot->SortMembers( pRefMember ); - } -} - -void ScDPNormalResultMember::DoAutoShow( ScDPResultMember* pRefMember ) -{ - BOOL bHasChild = ( pChildDimension != NULL ); - if (bHasChild) - pChildDimension->DoAutoShow( pRefMember ); // sorting is done at the dimension - - if ( IsRoot()&& pDataRoot ) - { - // use the row root member to sort columns - // sub total count is always 1 - - pDataRoot->DoAutoShow( pRefMember ); - } -} - -void ScDPNormalResultMember::ResetResults( BOOL bRoot ) -{ - if (pDataRoot) - pDataRoot->ResetResults(); - - if (pChildDimension) - pChildDimension->ResetResults(); - -// Wang Xu Ming -- 3/4/2009 -// Dim refresh and filter. SODC_19023 - // if (!bRoot) - // bHasElements = FALSE; -// End Comments -} - -void ScDPNormalResultMember::UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, - ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const -{ - // IsVisible() test is in ScDPResultDimension::FillDataResults - // (not on data layout dimension) - - rTotals.SetInColRoot( IsRoot() ); - - BOOL bHasChild = ( pChildDimension != NULL ); - - long nUserSubCount = GetSubTotalCount(); - if ( nUserSubCount || !bHasChild ) - { - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !bHasChild ) - nUserSubCount = 1; - - long nMemberMeasure = nMeasure; - long nSubSize = pResultData->GetCountForMeasure(nMeasure); - - if ( pDataRoot ) - { - ScDPSubTotalState aSubState; // initial state - - for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic" - { - if ( bHasChild && nUserSubCount > 1 ) - { - aSubState.nRowSubTotalFunc = nUserPos; - aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel(), nUserPos ); - } - - for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nMemberMeasure = nSubCount; - else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL ) - nMemberMeasure = SC_DPMEASURE_ALL; - - pDataRoot->UpdateRunningTotals( pRefMember, nMemberMeasure, - bHasChild, aSubState, rRunning, rTotals, *this ); - } - } - } - } - - if (bHasChild) // child dimension must be processed last, so the column total is known - { - pChildDimension->UpdateRunningTotals( pRefMember, nMeasure, rRunning, rTotals ); - } -} - -void ScDPNormalResultMember::DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const -{ - lcl_DumpRow( String::CreateFromAscii("ScDPResultMember"), GetName(), NULL, pDoc, rPos ); - SCROW nStartRow = rPos.Row(); - - if (pDataRoot) - pDataRoot->DumpState( pRefMember, pDoc, rPos ); - - if (pChildDimension) - pChildDimension->DumpState( pRefMember, pDoc, rPos ); - - lcl_Indent( pDoc, nStartRow, rPos ); -} - -ScDPAggData* ScDPNormalResultMember::GetColTotal( long nMeasure ) const -{ - return lcl_GetChildTotal( const_cast<ScDPAggData*>(&aColTotal), nMeasure ); -} - -void ScDPNormalResultMember::FillVisibilityData(ScDPResultVisibilityData& rData) const -{ - if (pChildDimension) - pChildDimension->FillVisibilityData(rData); -} -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration -SCROW ScDPNormalResultMember::GetDataId( ) const -{ -// TODO: - const ScDPMember* pMemberDesc = GetDPMember(); - if (pMemberDesc) - return pMemberDesc->GetItemDataId(); - return -1; -} - -// ----------------------------------------------------------------------- -ScDPHideDetailsMember:: ScDPHideDetailsMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, - BOOL bForceSub ):ScDPResultMember(pData,rParentDimData, bForceSub) -{ - pOrigMember = new ScDPNormalResultMember(pData,rParentDimData, bForceSub); - -}
\ No newline at end of file diff --git a/sc/source/core/data/dptabresmember.hxx b/sc/source/core/data/dptabresmember.hxx deleted file mode 100644 index 72657167d07d..000000000000 --- a/sc/source/core/data/dptabresmember.hxx +++ /dev/null @@ -1,161 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright IBM Corporation 2009. - * Copyright 2009 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: dptabresmember.hxx,v $ - * $Revision: 1.0 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef DPTABRESMEMBER_HXX -#define DPTABRESMEMBER_HXX - -class ScDPNormalResultMember: public ScDPResultMember -{ -private: - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - ScDPParentDimData aParentDimData; - // End Comments - BOOL bHasElements:1; - BOOL bForceSubTotal:1; - BOOL bHasHiddenDetails:1; - BOOL bInitialized:1; - BOOL bAutoHidden:1; - ScDPAggData aColTotal; // to store column totals - -// Wang Xu Ming -- 2009-6-9 -// DataPilot Migration - USHORT nMemberStep; // step to show details -// End Comments -public: - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - ScDPNormalResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, - BOOL bForceSub ); //! Ref - ScDPNormalResultMember( const ScDPResultData* pData, BOOL bForceSub ); - // End Comments - ~ScDPNormalResultMember(); - - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - // Add parameter: BOOL bInitChild - void InitFrom( const ::std::vector<ScDPDimension*>& ppDim, - const ::std::vector<ScDPLevel*>& ppLev, - size_t nPos, - ScDPInitState& rInitState, - BOOL bInitChild = TRUE ); - // End Comments - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - void LateInitFrom( - LateInitParams& rParams, - const ::std::vector< SCROW >& pItemData, - size_t nPos, - ScDPInitState& rInitState); - // End Comments - - String GetName() const; - void FillItemData( ScDPItemData& rData ) const; - BOOL IsValid() const; - BOOL IsVisible() const; - long GetSize(long nMeasure) const; - BOOL HasHiddenDetails() const; - BOOL IsSubTotalInTitle(long nMeasure) const; - -// BOOL SubTotalEnabled() const; - long GetSubTotalCount( long* pUserSubStart = NULL ) const; - -// Wang Xu Ming -- 2009-6-9 -// DataPilot Migration -// Use item index -// BOOL IsNamedItem( const ScDPItemData& r ) const; - BOOL IsNamedItem( SCROW nIndex ) const; -// End Comments - bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const; - ENTRYSTATUS GetEntryStatus( const ::std::vector<SCROW>& aMembers ) const; - - void SetHasElements() { bHasElements = TRUE; } - void SetAutoHidden() { bAutoHidden = TRUE; } - - void ProcessData( const ::std::vector<SCROW>& aChildMembers, - const ScDPResultDimension* pDataDim, - const ::std::vector<SCROW>& aDataMembers, - const ::std::vector<ScDPValueData>& aValues ); - - void FillMemberResults( com::sun::star::uno::Sequence< - com::sun::star::sheet::MemberResult>* pSequences, - long& rPos, long nMeasure, BOOL bRoot, - const String* pMemberName, - const String* pMemberCaption ); - - void FillDataResults( const ScDPResultMember* pRefMember, - com::sun::star::uno::Sequence< - com::sun::star::uno::Sequence< - com::sun::star::sheet::DataResult> >& rSequence, - long& rRow, long nMeasure ) const; - - void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const; - void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure, - ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const; - - void SortMembers( ScDPResultMember* pRefMember ); - void DoAutoShow( ScDPResultMember* pRefMember ); - - void ResetResults( BOOL bRoot ); - - void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const; - - // Wang Xu Ming -- 2009-6-9 - // DataPilot Migration - const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref - const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref - const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref - inline SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref - inline BOOL IsRoot() const { return GetParentLevel() == NULL; } - // End Comments - - ScDPAggData* GetColTotal( long nMeasure ) const; - - void FillVisibilityData(ScDPResultVisibilityData& rData) const; -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - SCROW GetDataId( ) const ; -// End Comments -}; - -class ScDPHideDetailsMember: public ScDPResultMember -{ -private: - ScDPNormalResultMember * pOrigMember; -public: - ScDPHideDetailsMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData, - BOOL bForceSub ); - - -}; - - -#endif //DPTABRESMEMBER_HXX diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 3d7fc007818b..4df709768279 100755 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -592,12 +592,14 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b { //! nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden) + SCCOL nLastCol; + SCROW nLastRow; if( bValid1 ) { Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) ); - if( (pDoc->GetColFlags( nCol1, nTab1 ) & CR_HIDDEN) == 0 ) + if (!pDoc->ColHidden(nCol1, nTab1, nLastCol)) aPos.X() += pDoc->GetColWidth( nCol1, nTab1 ) / 4; - if( (pDoc->GetRowFlags( nRow1, nTab1 ) & CR_HIDDEN) == 0 ) + if (!pDoc->RowHidden(nRow1, nTab1, nLastRow)) aPos.Y() += pDoc->GetRowHeight( nRow1, nTab1 ) / 2; TwipsToMM( aPos.X() ); TwipsToMM( aPos.Y() ); @@ -629,9 +631,9 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b if( bValid2 ) { Point aPos( pDoc->GetColOffset( nCol2, nTab2 ), pDoc->GetRowOffset( nRow2, nTab2 ) ); - if( (pDoc->GetColFlags( nCol2, nTab2 ) & CR_HIDDEN) == 0 ) + if (!pDoc->ColHidden(nCol2, nTab2, nLastCol)) aPos.X() += pDoc->GetColWidth( nCol2, nTab2 ) / 4; - if( (pDoc->GetRowFlags( nRow2, nTab2 ) & CR_HIDDEN) == 0 ) + if (!pDoc->RowHidden(nRow2, nTab2, nLastRow)) aPos.Y() += pDoc->GetRowHeight( nRow2, nTab2 ) / 2; TwipsToMM( aPos.X() ); TwipsToMM( aPos.Y() ); @@ -735,8 +737,8 @@ BOOL ScDrawLayer::GetPrintArea( ScRange& rRange, BOOL bSetHor, BOOL bSetVer ) co } if (!bSetVer) { - nStartY = pDoc->FastGetRowHeight( 0, rRange.aStart.Row()-1, nTab); - nEndY = nStartY + pDoc->FastGetRowHeight( rRange.aStart.Row(), + nStartY = pDoc->GetRowHeight( 0, rRange.aStart.Row()-1, nTab); + nEndY = nStartY + pDoc->GetRowHeight( rRange.aStart.Row(), rRange.aEnd.Row(), nTab); nStartY = (long)(nStartY * HMM_PER_TWIPS); nEndY = (long)(nEndY * HMM_PER_TWIPS); @@ -817,9 +819,9 @@ BOOL ScDrawLayer::GetPrintArea( ScRange& rRange, BOOL bSetHor, BOOL bSetVer ) co { nStartY = (long) (nStartY / HMM_PER_TWIPS); nEndY = (long) (nEndY / HMM_PER_TWIPS); - SCROW nRow = pDoc->FastGetRowForHeight( nTab, nStartY); + SCROW nRow = pDoc->GetRowForHeight( nTab, nStartY); rRange.aStart.SetRow( nRow>0 ? (nRow-1) : 0); - nRow = pDoc->FastGetRowForHeight( nTab, nEndY); + nRow = pDoc->GetRowForHeight( nTab, nEndY); rRange.aEnd.SetRow( nRow == MAXROW ? MAXROW : (nRow>0 ? (nRow-1) : 0)); } @@ -1041,9 +1043,9 @@ void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCR for (SCsCOL s=-1; s>=nDx; s--) aMove.X() -= pDoc->GetColWidth(s+(SCsCOL)nCol1,nTab); if (nDy > 0) - aMove.Y() += pDoc->FastGetRowHeight( nRow1, nRow1+nDy-1, nTab); + aMove.Y() += pDoc->GetRowHeight( nRow1, nRow1+nDy-1, nTab); else - aMove.Y() -= pDoc->FastGetRowHeight( nRow1+nDy, nRow1-1, nTab); + aMove.Y() -= pDoc->GetRowHeight( nRow1+nDy, nRow1-1, nTab); if ( bNegativePage ) aMove.X() = -aMove.X(); @@ -1115,9 +1117,9 @@ void ScDrawLayer::HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips ) Rectangle aRect; Point aTopLeft; - aRect.Top() += pDoc->FastGetRowHeight( 0, nRow-1, nTab); + aRect.Top() += pDoc->GetRowHeight( 0, nRow-1, nTab); aTopLeft.Y() = aRect.Top(); - aRect.Top() += pDoc->FastGetRowHeight(nRow,nTab); + aRect.Top() += pDoc->GetRowHeight(nRow, nTab); aRect.Bottom() = MAXMM; aRect.Left() = 0; @@ -1143,14 +1145,14 @@ BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow ) Rectangle aTestRect; - aTestRect.Top() += pDoc->FastGetRowHeight( 0, nStartRow-1, nTab); + aTestRect.Top() += pDoc->GetRowHeight( 0, nStartRow-1, nTab); if (nEndRow==MAXROW) aTestRect.Bottom() = MAXMM; else { aTestRect.Bottom() = aTestRect.Top(); - aTestRect.Bottom() += pDoc->FastGetRowHeight( nStartRow, nEndRow, nTab); + aTestRect.Bottom() += pDoc->GetRowHeight( nStartRow, nEndRow, nTab); TwipsToMM( aTestRect.Bottom() ); } @@ -1706,7 +1708,7 @@ Rectangle ScDrawLayer::GetCellRect( ScDocument& rDoc, const ScAddress& rPos, boo for( SCCOL nCol = 0; nCol < rPos.Col(); ++nCol ) aTopLeft.X() += rDoc.GetColWidth( nCol, rPos.Tab() ); if( rPos.Row() > 0 ) - aTopLeft.Y() += rDoc.FastGetRowHeight( 0, rPos.Row() - 1, rPos.Tab() ); + aTopLeft.Y() += rDoc.GetRowHeight( 0, rPos.Row() - 1, rPos.Tab() ); // find bottom-right position of passed cell address ScAddress aEndPos = rPos; @@ -1721,7 +1723,7 @@ Rectangle ScDrawLayer::GetCellRect( ScDocument& rDoc, const ScAddress& rPos, boo Point aBotRight = aTopLeft; for( SCCOL nCol = rPos.Col(); nCol <= aEndPos.Col(); ++nCol ) aBotRight.X() += rDoc.GetColWidth( nCol, rPos.Tab() ); - aBotRight.Y() += rDoc.FastGetRowHeight( rPos.Row(), aEndPos.Row(), rPos.Tab() ); + aBotRight.Y() += rDoc.GetRowHeight( rPos.Row(), aEndPos.Row(), rPos.Tab() ); // twips -> 1/100 mm aTopLeft.X() = static_cast< long >( aTopLeft.X() * HMM_PER_TWIPS ); diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 05e0d98c9719..8418cb3c3a25 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -52,7 +52,6 @@ #include "conditio.hxx" #include "stlpool.hxx" - // ----------------------------------------------------------------------- const USHORT ROWINFO_MAX = 1024; @@ -97,11 +96,13 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY, rStartY = nY; BOOL bHOver = pInfo->bHOverlapped; BOOL bVOver = pInfo->bVOverlapped; + SCCOL nLastCol; + SCROW nLastRow; while (bHOver) // nY konstant { --rStartX; - if (rStartX >= (SCsCOL) nX1 && (pDoc->GetColFlags(rStartX,nTab) & CR_HIDDEN) == 0) + if (rStartX >= (SCsCOL) nX1 && !pDoc->ColHidden(rStartX, nTab, nLastCol)) { bHOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bHOverlapped; bVOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bVOverlapped; @@ -123,8 +124,8 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY, --nArrY; // lokale Kopie ! if (rStartX >= (SCsCOL) nX1 && rStartY >= (SCsROW) nY1 && - (pDoc->GetColFlags(rStartX,nTab) & CR_HIDDEN) == 0 && - (pDoc->GetRowFlags(rStartY,nTab) & CR_HIDDEN) == 0 && + !pDoc->ColHidden(rStartX, nTab, nLastCol) && + !pDoc->RowHidden(rStartY, nTab, nLastRow) && (SCsROW) pRowInfo[nArrY].nRowNo == rStartY) { bHOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bHOverlapped; @@ -141,8 +142,8 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY, const ScMergeAttr* pMerge; if (rStartX >= (SCsCOL) nX1 && rStartY >= (SCsROW) nY1 && - (pDoc->GetColFlags(rStartX,nTab) & CR_HIDDEN) == 0 && - (pDoc->GetRowFlags(rStartY,nTab) & CR_HIDDEN) == 0 && + !pDoc->ColHidden(rStartX, nTab, nLastCol) && + !pDoc->RowHidden(rStartY, nTab, nLastRow) && (SCsROW) pRowInfo[nArrY].nRowNo == rStartY) { pMerge = (const ScMergeAttr*) &pRowInfo[nArrY].pCellInfo[rStartX+1].pPatternAttr-> @@ -155,12 +156,6 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY, rEndY = rStartY + pMerge->GetRowMerge() - 1; } -inline BOOL ScDocument::RowHidden( SCROW nRow, SCTAB nTab ) -{ - return ( pTab[nTab]->pRowFlags->GetValue(nRow) & CR_HIDDEN ) != 0; -} - - #define CELLINFO(x,y) pRowInfo[nArrY+y].pCellInfo[nArrX+x] void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, @@ -356,7 +351,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX nX = nArrX-1; if ( ValidCol(nX) ) { - if ( (GetColFlags(nX,nTab) & CR_HIDDEN) == 0 ) // Spalte nicht versteckt + if (!ColHidden(nX, nTab)) { USHORT nThisWidth = (USHORT) (GetColWidth( nX, nTab ) * nScaleX); if (!nThisWidth) @@ -376,7 +371,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX // #i58049#, #i57939# Hidden columns must be skipped here, or their attributes // will disturb the output - if ( (GetColFlags(nX,nTab) & CR_HIDDEN) == 0 ) // column not hidden + // TODO: Optimize this loop. + if (!ColHidden(nX, nTab)) { USHORT nThisWidth = (USHORT) (GetColWidth( nX, nTab ) * nScaleX); if (!nThisWidth) @@ -481,7 +477,9 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX do { - if ( nArrY==0 || !RowHidden( nCurRow,nTab ) ) + SCROW nLastHiddenRow = -1; + bool bRowHidden = RowHidden(nCurRow, nTab, nLastHiddenRow); + if ( nArrY==0 || !bRowHidden ) { RowInfo* pThisRowInfo = &pRowInfo[nArrY]; if (pBackground != pDefBackground) // Spalten-HG == Standard ? @@ -551,6 +549,12 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX ++nArrY; } + else if (bRowHidden && nLastHiddenRow >= 0) + { + nCurRow = nLastHiddenRow; + if (nCurRow > nThisRow) + nCurRow = nThisRow; + } ++nCurRow; } while (nCurRow <= nThisRow && nCurRow <= nYExtra); diff --git a/sc/source/core/data/makefile.mk b/sc/source/core/data/makefile.mk index f299c09ea622..95ce6bcec179 100755 --- a/sc/source/core/data/makefile.mk +++ b/sc/source/core/data/makefile.mk @@ -99,9 +99,11 @@ SLOFILES = \ $(SLO)$/pivot2.obj \ $(SLO)$/poolhelp.obj \ $(SLO)$/sheetevents.obj \ + $(SLO)$/segmenttree.obj \ $(SLO)$/sortparam.obj \ $(SLO)$/stlpool.obj \ $(SLO)$/stlsheet.obj \ + $(SLO)$/tabbgcolor.obj \ $(SLO)$/table1.obj \ $(SLO)$/table2.obj \ $(SLO)$/table3.obj \ @@ -129,6 +131,7 @@ EXCEPTIONSFILES= \ $(SLO)$/dptabres.obj \ $(SLO)$/dptabdat.obj \ $(SLO)$/global2.obj \ + $(SLO)$/tabbgcolor.obj \ $(SLO)$/table1.obj \ $(SLO)$/table2.obj \ $(SLO)$/table3.obj \ @@ -149,7 +152,8 @@ EXCEPTIONSFILES= \ $(SLO)$/dbdocutl.obj \ $(SLO)$/dptabsrc.obj \ $(SLO)$/drwlayer.obj \ - $(SLO)$/globalx.obj + $(SLO)$/globalx.obj \ + $(SLO)$/segmenttree.obj .IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCSPARC" NOOPTFILES= \ @@ -165,7 +169,8 @@ EXCEPTIONSNOOPTFILES= \ .ELSE EXCEPTIONSFILES+= \ $(SLO)$/cell.obj \ - $(SLO)$/global.obj + $(SLO)$/global.obj \ + $(SLO)$/table5.obj .ENDIF # --- Tagets ------------------------------------------------------- diff --git a/sc/source/core/data/olinetab.cxx b/sc/source/core/data/olinetab.cxx index 55f7ba46b898..af444c4b2123 100644 --- a/sc/source/core/data/olinetab.cxx +++ b/sc/source/core/data/olinetab.cxx @@ -41,10 +41,11 @@ #include "global.hxx" #include "rechead.hxx" #include "address.hxx" +#include "table.hxx" //------------------------------------------------------------------------ -ScOutlineEntry::ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, BOOL bNewHidden ) : +ScOutlineEntry::ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden ) : nStart ( nNewStart ), nSize ( nNewSize ), bHidden ( bNewHidden ), @@ -93,12 +94,12 @@ void ScOutlineEntry::SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize ) SetSize( nNewSize ); } -void ScOutlineEntry::SetHidden( BOOL bNewHidden ) +void ScOutlineEntry::SetHidden( bool bNewHidden ) { bHidden = bNewHidden; } -void ScOutlineEntry::SetVisible( BOOL bNewVisible ) +void ScOutlineEntry::SetVisible( bool bNewVisible ) { bVisible = bNewVisible; } @@ -637,10 +638,9 @@ BOOL ScOutlineArray::DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize ) return bNeedSave; } -BOOL ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, - BOOL bShow, const ScBitMaskCompressedArray< SCCOLROW, BYTE>& rHiddenFlags ) +bool ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol ) { - BOOL bModified = FALSE; + bool bModified = false; ScSubOutlineIterator aIter( this ); ScOutlineEntry* pEntry; while((pEntry=aIter.GetNext())!=NULL) @@ -654,18 +654,16 @@ BOOL ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, { // #i12341# hide if all columns/rows are hidden, show if at least one // is visible - - SCCOLROW nEnd = rHiddenFlags.GetBitStateEnd( nEntryStart, - CR_HIDDEN, CR_HIDDEN); - BOOL bAllHidden = (nEntryEnd <= nEnd && nEnd < + SCCOLROW nEnd = rTable.LastHiddenColRow(nEntryStart, bCol); + bool bAllHidden = (nEntryEnd <= nEnd && nEnd < ::std::numeric_limits<SCCOLROW>::max()); - BOOL bToggle = ( bShow != bAllHidden ); + bool bToggle = ( bShow != bAllHidden ); if ( bToggle ) { pEntry->SetHidden( !bShow ); SetVisibleBelow( aIter.LastLevel(), aIter.LastEntry(), bShow, bShow ); - bModified = TRUE; + bModified = true; } } } diff --git a/sc/source/core/data/segmenttree.cxx b/sc/source/core/data/segmenttree.cxx new file mode 100644 index 000000000000..86b53582d1d4 --- /dev/null +++ b/sc/source/core/data/segmenttree.cxx @@ -0,0 +1,582 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#include "segmenttree.hxx" + +#include <mdds/flat_segment_tree.hpp> + +#include <limits> + +using ::std::numeric_limits; + +// ============================================================================ + +template<typename _ValueType, typename _ExtValueType = _ValueType> +class ScFlatSegmentsImpl +{ +public: + typedef _ValueType ValueType; + typedef _ExtValueType ExtValueType; + + struct RangeData + { + SCCOLROW mnPos1; + SCCOLROW mnPos2; + ValueType mnValue; + }; + + ScFlatSegmentsImpl(SCCOLROW nMax, ValueType nDefault); + ScFlatSegmentsImpl(const ScFlatSegmentsImpl& r); + ~ScFlatSegmentsImpl(); + + void setValue(SCCOLROW nPos1, SCCOLROW nPos2, ValueType nValue); + ValueType getValue(SCCOLROW nPos); + ExtValueType getSumValue(SCCOLROW nPos1, SCCOLROW nPos2); + bool getRangeData(SCCOLROW nPos, RangeData& rData); + void removeSegment(SCCOLROW nPos1, SCCOLROW nPos2); + void insertSegment(SCCOLROW nPos, SCCOLROW nSize, bool bSkipStartBoundary); + + SCROW findLastNotOf(ValueType nValue) const; + + // range iteration + bool getFirst(RangeData& rData); + bool getNext(RangeData& rData); + + void enableTreeSearch(bool b) + { + mbTreeSearchEnabled = b; + } + + void setInsertFromBack(bool b) + { + mbInsertFromBack = b; + } + +private: + typedef ::mdds::flat_segment_tree<SCCOLROW, ValueType> fst_type; + fst_type maSegments; + typename fst_type::const_iterator maItr; + + bool mbTreeSearchEnabled:1; + bool mbInsertFromBack:1; +}; + +template<typename _ValueType, typename _ExtValueType> +ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ScFlatSegmentsImpl(SCCOLROW nMax, ValueType nDefault) : + maSegments(0, nMax+1, nDefault), + mbTreeSearchEnabled(true), + mbInsertFromBack(false) +{ +} + +template<typename _ValueType, typename _ExtValueType> +ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ScFlatSegmentsImpl(const ScFlatSegmentsImpl<_ValueType, _ExtValueType>& r) : + maSegments(r.maSegments), + mbTreeSearchEnabled(r.mbTreeSearchEnabled), + mbInsertFromBack(r.mbInsertFromBack) +{ +} + +template<typename _ValueType, typename _ExtValueType> +ScFlatSegmentsImpl<_ValueType, _ExtValueType>::~ScFlatSegmentsImpl() +{ +} + +template<typename _ValueType, typename _ExtValueType> +void ScFlatSegmentsImpl<_ValueType, _ExtValueType>::setValue(SCCOLROW nPos1, SCCOLROW nPos2, ValueType nValue) +{ + if (mbInsertFromBack) + maSegments.insert_back(nPos1, nPos2+1, nValue); + else + maSegments.insert_front(nPos1, nPos2+1, nValue); +} + +template<typename _ValueType, typename _ExtValueType> +typename ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ValueType ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getValue(SCCOLROW nPos) +{ + ValueType nValue = 0; + if (!mbTreeSearchEnabled) + { + maSegments.search(nPos, nValue); + return nValue; + } + + if (!maSegments.is_tree_valid()) + maSegments.build_tree(); + + maSegments.search_tree(nPos, nValue); + return nValue; +} + +template<typename _ValueType, typename _ExtValueType> +typename ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ExtValueType +ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getSumValue(SCCOLROW nPos1, SCCOLROW nPos2) +{ + RangeData aData; + if (!getRangeData(nPos1, aData)) + return 0; + + sal_uInt32 nValue = 0; + + SCROW nCurPos = nPos1; + SCROW nEndPos = aData.mnPos2; + while (nEndPos <= nPos2) + { + nValue += aData.mnValue * (nEndPos - nCurPos + 1); + nCurPos = nEndPos + 1; + if (!getRangeData(nCurPos, aData)) + break; + + nEndPos = aData.mnPos2; + } + if (nCurPos <= nPos2) + { + nEndPos = ::std::min(nEndPos, nPos2); + nValue += aData.mnValue * (nEndPos - nCurPos + 1); + } + return nValue; +} + +template<typename _ValueType, typename _ExtValueType> +bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getRangeData(SCCOLROW nPos, RangeData& rData) +{ + ValueType nValue; + SCCOLROW nPos1, nPos2; + + if (mbTreeSearchEnabled) + { + if (!maSegments.is_tree_valid()) + maSegments.build_tree(); + + if (!maSegments.search_tree(nPos, nValue, &nPos1, &nPos2)) + return false; + } + else + { + // Conduct leaf-node only search. Faster when searching between range insertion. + if (!maSegments.search(nPos, nValue, &nPos1, &nPos2)) + return false; + } + + rData.mnPos1 = nPos1; + rData.mnPos2 = nPos2-1; // end point is not inclusive. + rData.mnValue = nValue; + return true; +} + +template<typename _ValueType, typename _ExtValueType> +void ScFlatSegmentsImpl<_ValueType, _ExtValueType>::removeSegment(SCCOLROW nPos1, SCCOLROW nPos2) +{ + maSegments.shift_left(nPos1, nPos2); +} + +template<typename _ValueType, typename _ExtValueType> +void ScFlatSegmentsImpl<_ValueType, _ExtValueType>::insertSegment(SCCOLROW nPos, SCCOLROW nSize, bool bSkipStartBoundary) +{ + maSegments.shift_right(nPos, nSize, bSkipStartBoundary); +} + +template<typename _ValueType, typename _ExtValueType> +SCCOLROW ScFlatSegmentsImpl<_ValueType, _ExtValueType>::findLastNotOf(ValueType nValue) const +{ + SCCOLROW nPos = numeric_limits<SCCOLROW>::max(); // position not found. + typename fst_type::const_reverse_iterator itr = maSegments.rbegin(), itrEnd = maSegments.rend(); + // Note that when searching in reverse direction, we need to skip the first + // node, since the right-most leaf node does not store a valid value. + for (++itr; itr != itrEnd; ++itr) + { + if (itr->second != nValue) + { + nPos = (--itr)->first - 1; + break; + } + } + return nPos; +} + +template<typename _ValueType, typename _ExtValueType> +bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getFirst(RangeData& rData) +{ + maItr = maSegments.begin(); + return getNext(rData); +} + +template<typename _ValueType, typename _ExtValueType> +bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getNext(RangeData& rData) +{ + typename fst_type::const_iterator itrEnd = maSegments.end(); + if (maItr == itrEnd) + return false; + + rData.mnPos1 = maItr->first; + rData.mnValue = maItr->second; + + ++maItr; + if (maItr == itrEnd) + return false; + + rData.mnPos2 = maItr->first - 1; + return true; +} + +// ============================================================================ + +class ScFlatUInt16SegmentsImpl : public ScFlatSegmentsImpl<sal_uInt16, sal_uInt32> +{ +public: + explicit ScFlatUInt16SegmentsImpl(SCCOLROW nMax, sal_uInt16 nDefault) : + ScFlatSegmentsImpl<sal_uInt16, sal_uInt32>(nMax, nDefault) + { + } +}; + +// ---------------------------------------------------------------------------- + +class ScFlatBoolSegmentsImpl : public ScFlatSegmentsImpl<bool> +{ +public: + explicit ScFlatBoolSegmentsImpl(SCCOLROW nMax) : + ScFlatSegmentsImpl<bool>(nMax, false) + { + } + + void setTrue(SCCOLROW nPos1, SCCOLROW nPos2); + void setFalse(SCCOLROW nPos1, SCCOLROW nPos2); +}; + +void ScFlatBoolSegmentsImpl::setTrue(SCCOLROW nPos1, SCCOLROW nPos2) +{ + setValue(nPos1, nPos2, true); +} + +void ScFlatBoolSegmentsImpl::setFalse(SCCOLROW nPos1, SCCOLROW nPos2) +{ + setValue(nPos1, nPos2, false); +} + +// ============================================================================ + +ScFlatBoolRowSegments::ForwardIterator::ForwardIterator(ScFlatBoolRowSegments& rSegs) : + mrSegs(rSegs), mnCurPos(0), mnLastPos(-1), mbCurValue(false) +{ +} + +bool ScFlatBoolRowSegments::ForwardIterator::getValue(SCROW nPos, bool& rVal) +{ + if (nPos >= mnCurPos) + // It can only go in a forward direction. + mnCurPos = nPos; + + if (mnCurPos > mnLastPos) + { + // position not in the current segment. Update the current value. + ScFlatBoolRowSegments::RangeData aData; + if (!mrSegs.getRangeData(mnCurPos, aData)) + return false; + + mbCurValue = aData.mbValue; + mnLastPos = aData.mnRow2; + } + + rVal = mbCurValue; + return true; +} + +SCROW ScFlatBoolRowSegments::ForwardIterator::getLastPos() const +{ + return mnLastPos; +} + +// ---------------------------------------------------------------------------- + +ScFlatBoolRowSegments::RangeIterator::RangeIterator(ScFlatBoolRowSegments& rSegs) : + mrSegs(rSegs) +{ +} + +bool ScFlatBoolRowSegments::RangeIterator::getFirst(RangeData& rRange) +{ + ScFlatBoolSegmentsImpl::RangeData aData; + if (!mrSegs.mpImpl->getFirst(aData)) + return false; + + rRange.mnRow1 = static_cast<SCROW>(aData.mnPos1); + rRange.mnRow2 = static_cast<SCROW>(aData.mnPos2); + rRange.mbValue = static_cast<bool>(aData.mnValue); + return true; +} + +bool ScFlatBoolRowSegments::RangeIterator::getNext(RangeData& rRange) +{ + ScFlatBoolSegmentsImpl::RangeData aData; + if (!mrSegs.mpImpl->getNext(aData)) + return false; + + rRange.mnRow1 = static_cast<SCROW>(aData.mnPos1); + rRange.mnRow2 = static_cast<SCROW>(aData.mnPos2); + rRange.mbValue = static_cast<bool>(aData.mnValue); + return true; +} + +// ---------------------------------------------------------------------------- + +ScFlatBoolRowSegments::ScFlatBoolRowSegments() : + mpImpl(new ScFlatBoolSegmentsImpl(static_cast<SCCOLROW>(MAXROW))) +{ +} + +ScFlatBoolRowSegments::ScFlatBoolRowSegments(const ScFlatBoolRowSegments& r) : + mpImpl(new ScFlatBoolSegmentsImpl(*r.mpImpl)) +{ +} + +ScFlatBoolRowSegments::~ScFlatBoolRowSegments() +{ +} + +void ScFlatBoolRowSegments::setTrue(SCROW nRow1, SCROW nRow2) +{ + mpImpl->setTrue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2)); +} + +void ScFlatBoolRowSegments::setFalse(SCROW nRow1, SCROW nRow2) +{ + mpImpl->setFalse(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2)); +} + +bool ScFlatBoolRowSegments::getValue(SCROW nRow) +{ + return mpImpl->getValue(static_cast<SCCOLROW>(nRow)); +} + +bool ScFlatBoolRowSegments::getRangeData(SCROW nRow, RangeData& rData) +{ + ScFlatBoolSegmentsImpl::RangeData aData; + if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nRow), aData)) + return false; + + rData.mbValue = aData.mnValue; + rData.mnRow1 = static_cast<SCROW>(aData.mnPos1); + rData.mnRow2 = static_cast<SCROW>(aData.mnPos2); + return true; +} + +void ScFlatBoolRowSegments::removeSegment(SCROW nRow1, SCROW nRow2) +{ + mpImpl->removeSegment(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2)); +} + +void ScFlatBoolRowSegments::insertSegment(SCROW nRow, SCROW nSize, bool bSkipStartBoundary) +{ + mpImpl->insertSegment(static_cast<SCCOLROW>(nRow), static_cast<SCCOLROW>(nSize), bSkipStartBoundary); +} + +SCROW ScFlatBoolRowSegments::findLastNotOf(bool bValue) const +{ + return static_cast<SCROW>(mpImpl->findLastNotOf(bValue)); +} + +void ScFlatBoolRowSegments::enableTreeSearch(bool bEnable) +{ + mpImpl->enableTreeSearch(bEnable); +} + +void ScFlatBoolRowSegments::setInsertFromBack(bool bInsertFromBack) +{ + mpImpl->setInsertFromBack(bInsertFromBack); +} + +// ============================================================================ + +ScFlatBoolColSegments::ScFlatBoolColSegments() : + mpImpl(new ScFlatBoolSegmentsImpl(static_cast<SCCOLROW>(MAXCOL))) +{ +} + +ScFlatBoolColSegments::ScFlatBoolColSegments(const ScFlatBoolColSegments& r) : + mpImpl(new ScFlatBoolSegmentsImpl(*r.mpImpl)) +{ +} + +ScFlatBoolColSegments::~ScFlatBoolColSegments() +{ +} + +void ScFlatBoolColSegments::setTrue(SCCOL nCol1, SCCOL nCol2) +{ + mpImpl->setTrue(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2)); +} + +void ScFlatBoolColSegments::setFalse(SCCOL nCol1, SCCOL nCol2) +{ + mpImpl->setFalse(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2)); +} + +bool ScFlatBoolColSegments::getValue(SCCOL nCol) +{ + return mpImpl->getValue(static_cast<SCCOLROW>(nCol)); +} + +bool ScFlatBoolColSegments::getRangeData(SCCOL nCol, RangeData& rData) +{ + ScFlatBoolSegmentsImpl::RangeData aData; + if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nCol), aData)) + return false; + + rData.mbValue = aData.mnValue; + rData.mnCol1 = static_cast<SCCOL>(aData.mnPos1); + rData.mnCol2 = static_cast<SCCOL>(aData.mnPos2); + return true; +} + +void ScFlatBoolColSegments::removeSegment(SCCOL nCol1, SCCOL nCol2) +{ + mpImpl->removeSegment(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2)); +} + +void ScFlatBoolColSegments::insertSegment(SCCOL nCol, SCCOL nSize, bool bSkipStartBoundary) +{ + mpImpl->insertSegment(static_cast<SCCOLROW>(nCol), static_cast<SCCOLROW>(nSize), bSkipStartBoundary); +} + +void ScFlatBoolColSegments::enableTreeSearch(bool bEnable) +{ + mpImpl->enableTreeSearch(bEnable); +} + +void ScFlatBoolColSegments::setInsertFromBack(bool bInsertFromBack) +{ + mpImpl->setInsertFromBack(bInsertFromBack); +} + +// ============================================================================ + + +// ============================================================================ + +ScFlatUInt16RowSegments::ForwardIterator::ForwardIterator(ScFlatUInt16RowSegments& rSegs) : + mrSegs(rSegs), mnCurPos(0), mnLastPos(-1), mnCurValue(0) +{ +} + +bool ScFlatUInt16RowSegments::ForwardIterator::getValue(SCROW nPos, sal_uInt16& rVal) +{ + if (nPos >= mnCurPos) + // It can only go in a forward direction. + mnCurPos = nPos; + + if (mnCurPos > mnLastPos) + { + // position not in the current segment. Update the current value. + ScFlatUInt16RowSegments::RangeData aData; + if (!mrSegs.getRangeData(mnCurPos, aData)) + return false; + + mnCurValue = aData.mnValue; + mnLastPos = aData.mnRow2; + } + + rVal = mnCurValue; + return true; +} + +SCROW ScFlatUInt16RowSegments::ForwardIterator::getLastPos() const +{ + return mnLastPos; +} + +// ---------------------------------------------------------------------------- + +ScFlatUInt16RowSegments::ScFlatUInt16RowSegments(sal_uInt16 nDefault) : + mpImpl(new ScFlatUInt16SegmentsImpl(static_cast<SCCOLROW>(MAXROW), nDefault)) +{ +} + +ScFlatUInt16RowSegments::ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r) : + mpImpl(new ScFlatUInt16SegmentsImpl(*r.mpImpl)) +{ +} + +ScFlatUInt16RowSegments::~ScFlatUInt16RowSegments() +{ +} + +void ScFlatUInt16RowSegments::setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue) +{ + mpImpl->setValue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2), nValue); +} + +sal_uInt16 ScFlatUInt16RowSegments::getValue(SCROW nRow) +{ + return mpImpl->getValue(static_cast<SCCOLROW>(nRow)); +} + +sal_uInt32 ScFlatUInt16RowSegments::getSumValue(SCROW nRow1, SCROW nRow2) +{ + return mpImpl->getSumValue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2)); +} + +bool ScFlatUInt16RowSegments::getRangeData(SCROW nRow, RangeData& rData) +{ + ScFlatUInt16SegmentsImpl::RangeData aData; + if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nRow), aData)) + return false; + + rData.mnRow1 = aData.mnPos1; + rData.mnRow2 = aData.mnPos2; + rData.mnValue = aData.mnValue; + return true; +} + +void ScFlatUInt16RowSegments::removeSegment(SCROW nRow1, SCROW nRow2) +{ + mpImpl->removeSegment(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2)); +} + +void ScFlatUInt16RowSegments::insertSegment(SCROW nRow, SCROW nSize, bool bSkipStartBoundary) +{ + mpImpl->insertSegment(static_cast<SCCOLROW>(nRow), static_cast<SCCOLROW>(nSize), bSkipStartBoundary); +} + +SCROW ScFlatUInt16RowSegments::findLastNotOf(sal_uInt16 nValue) const +{ + return static_cast<SCROW>(mpImpl->findLastNotOf(nValue)); +} + +void ScFlatUInt16RowSegments::enableTreeSearch(bool bEnable) +{ + mpImpl->enableTreeSearch(bEnable); +} + +void ScFlatUInt16RowSegments::setInsertFromBack(bool bInsertFromBack) +{ + mpImpl->setInsertFromBack(bInsertFromBack); +} + diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index 4a4210a7925c..a3319eafd3fd 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -171,7 +171,7 @@ SfxItemSet& __EXPORT ScStyleSheet::GetItemSet() // gespeicherte Printer noch nicht geladen ist! ScDocument* pDoc = ((ScStyleSheetPool&)GetPool()).GetDocument(); - if ( pDoc && pDoc->IsLoadingDone() ) + if ( pDoc ) { // Setzen von sinnvollen Default-Werten: SvxPageItem aPageItem( ATTR_PAGE ); diff --git a/sc/source/core/data/tabbgcolor.cxx b/sc/source/core/data/tabbgcolor.cxx new file mode 100644 index 000000000000..a3d9eec16d99 --- /dev/null +++ b/sc/source/core/data/tabbgcolor.cxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tabbgcolor.hxx,v $ + * $Revision: 1.00 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + + + +// INCLUDE --------------------------------------------------------------- + +#include "tabbgcolor.hxx" + +bool ScUndoTabColorInfo::IsDefaultOldTabBgColor() const +{ + return maOldTabBgColor == Color(COL_AUTO); +} + +bool ScUndoTabColorInfo::IsDefaultNewTabBgColor() const +{ + return maOldTabBgColor == Color(COL_AUTO); +} + +ScUndoTabColorInfo::ScUndoTabColorInfo(SCTAB nTab) : + mnTabId(nTab), + maOldTabBgColor(COL_AUTO), + maNewTabBgColor(COL_AUTO) +{ +} + +ScUndoTabColorInfo::ScUndoTabColorInfo(const ScUndoTabColorInfo& r) : + mnTabId(r.mnTabId), + maOldTabBgColor(r.maOldTabBgColor), + maNewTabBgColor(r.maNewTabBgColor) +{ +} diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index af4f82b56898..baaabd3a8c8f 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -28,69 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - -//------------------------------------------------------------------------ - -#ifdef WIN - -// SFX -#define _SFXAPPWIN_HXX -#define _SFX_SAVEOPT_HXX -//#define _SFX_CHILDWIN_HXX *** -#define _SFXCTRLITEM_HXX -#define _SFXPRNMON_HXX -#define _INTRO_HXX -#define _SFXMSGDESCR_HXX -#define _SFXMSGPOOL_HXX -#define _SFXFILEDLG_HXX -#define _PASSWD_HXX -#define _SFXTBXCTRL_HXX -#define _SFXSTBITEM_HXX -#define _SFXMNUITEM_HXX -#define _SFXIMGMGR_HXX -#define _SFXTBXMGR_HXX -#define _SFXSTBMGR_HXX -#define _SFX_MINFITEM_HXX -#define _SFXEVENT_HXX - -//#define _SI_HXX -//#define SI_NODRW -#define _SI_DLL_HXX -#define _SIDLL_HXX -#define _SI_NOITEMS -#define _SI_NOOTHERFORMS -#define _SI_NOSBXCONTROLS -#define _SINOSBXCONTROLS -#define _SI_NODRW // -#define _SI_NOCONTROL -#define _VCBRW_HXX -#define _VCTRLS_HXX -//#define _VCSBX_HXX -#define _VCONT_HXX -#define _VDRWOBJ_HXX -#define _VCATTR_HXX - - -#define _SVX_DAILDLL_HXX -#define _SVX_HYPHEN_HXX -#define _SVX_IMPGRF_HXX -#define _SVX_OPTITEMS_HXX -#define _SVX_OPTGERL_HXX -#define _SVX_OPTSAVE_HXX -#define _SVX_OPTSPELL_HXX -#define _SVX_OPTPATH_HXX -#define _SVX_OPTLINGU_HXX -#define _SVX_RULER_HXX -#define _SVX_RULRITEM_HXX -#define _SVX_SPLWRAP_HXX -#define _SVX_SPLDLG_HXX -#define _SVX_THESDLG_HXX - -#endif //WIN - -// INCLUDE --------------------------------------------------------------- - #include "scitems.hxx" #include <svx/algitem.hxx> #include <unotools/textsearch.hxx> @@ -113,8 +50,7 @@ #include "prnsave.hxx" #include "tabprotection.hxx" #include "sheetevents.hxx" - -// STATIC DATA ----------------------------------------------------------- +#include "segmenttree.hxx" // ----------------------------------------------------------------------- @@ -132,9 +68,13 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName, nRepeatStartY( SCROW_REPEAT_NONE ), pTabProtection( NULL ), pColWidth( NULL ), - pRowHeight( NULL ), + mpRowHeights( static_cast<ScFlatUInt16RowSegments*>(NULL) ), pColFlags( NULL ), pRowFlags( NULL ), + mpHiddenCols(new ScFlatBoolColSegments), + mpHiddenRows(new ScFlatBoolRowSegments), + mpFilteredCols(new ScFlatBoolColSegments), + mpFilteredRows(new ScFlatBoolRowSegments), pOutlineTable( NULL ), pSheetEvents( NULL ), bTableAreaValid( FALSE ), @@ -154,8 +94,10 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName, nLockCount( 0 ), pScenarioRanges( NULL ), aScenarioColor( COL_LIGHTGRAY ), + aTabBgColor( COL_AUTO ), nScenarioFlags( 0 ), - bActiveScenario( FALSE ) + bActiveScenario( FALSE ), + mbPageBreaksValid(false) { if (bColInfo) @@ -172,7 +114,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName, if (bRowInfo) { - pRowHeight = new ScSummableCompressedArray< SCROW, USHORT>( MAXROW, ScGlobal::nStdRowHeight); + mpRowHeights.reset(new ScFlatUInt16RowSegments(ScGlobal::nStdRowHeight)); pRowFlags = new ScBitMaskCompressedArray< SCROW, BYTE>( MAXROW, 0); } @@ -214,7 +156,6 @@ ScTable::~ScTable() delete[] pColWidth; delete[] pColFlags; - delete pRowHeight; delete pRowFlags; delete pSheetEvents; delete pOutlineTable; @@ -275,6 +216,22 @@ void ScTable::SetLoadingRTL( BOOL bSet ) bLoadingRTL = bSet; } +const Color& ScTable::GetTabBgColor() const +{ + return aTabBgColor; +} + +void ScTable::SetTabBgColor(const Color& rColor) +{ + if (aTabBgColor != rColor) + { + // The tab color has changed. Set this table 'modified'. + aTabBgColor = rColor; + if (IsStreamValid()) + SetStreamValid(false); + } +} + void ScTable::SetScenario( BOOL bFlag ) { bScenario = bFlag; @@ -973,9 +930,10 @@ BOOL ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark, // auf der naechsten Zelle landet, auch wenn die geschuetzt/nicht markiert ist. //! per Extra-Parameter steuern, nur fuer Cursor-Bewegung ??? - if ( pRowFlags && ( pRowFlags->GetValue(nRow) & CR_HIDDEN ) ) + if (RowHidden(nRow)) return FALSE; - if ( pColFlags && ( pColFlags[nCol] & CR_HIDDEN ) ) + + if (ColHidden(nCol)) return FALSE; } @@ -1002,8 +960,8 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, { BOOL bUp = ( nMovY < 0 ); nRow = rMark.GetNextMarked( nCol, nRow, bUp ); - while ( VALIDROW(nRow) && ((pRowFlags && (pRowFlags->GetValue(nRow) & CR_HIDDEN)) || - pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) ) + while ( VALIDROW(nRow) && + (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) ) { // #53697# ausgeblendete ueberspringen (s.o.) nRow += nMovY; @@ -1013,7 +971,7 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, while ( nRow < 0 || nRow > MAXROW ) { nCol = sal::static_int_cast<SCsCOL>( nCol + static_cast<SCsCOL>(nMovY) ); - while ( VALIDCOL(nCol) && pColFlags && (pColFlags[nCol] & CR_HIDDEN) ) + while ( VALIDCOL(nCol) && ColHidden(nCol) ) nCol = sal::static_int_cast<SCsCOL>( nCol + static_cast<SCsCOL>(nMovY) ); // #53697# skip hidden rows (see above) if (nCol < 0) { @@ -1032,8 +990,8 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, else if (nRow > MAXROW) nRow = 0; nRow = rMark.GetNextMarked( nCol, nRow, bUp ); - while ( VALIDROW(nRow) && ((pRowFlags && (pRowFlags->GetValue(nRow) & CR_HIDDEN)) || - pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) ) + while ( VALIDROW(nRow) && + (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) ) { // #53697# ausgeblendete ueberspringen (s.o.) nRow += nMovY; @@ -1424,93 +1382,140 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev, double nPPTX = aPix1000.X() / 1000.0; double nPPTY = aPix1000.Y() / 1000.0; - BOOL bEmpty[MAXCOLCOUNT]; - for (SCCOL i=0; i<=MAXCOL; i++) - bEmpty[i] = ( aCol[i].GetCellCount() == 0 ); - - SCSIZE nIndex; - SCCOL nPrintCol = rEndCol; - SCSIZE nRowFlagsIndex; - SCROW nRowFlagsEndRow; - BYTE nRowFlag = pRowFlags->GetValue( nStartRow, nRowFlagsIndex, nRowFlagsEndRow); - for (SCROW nRow = nStartRow; nRow<=nEndRow; nRow++) + // First, mark those columns that we need to skip i.e. hidden and empty columns. + + ScFlatBoolColSegments aSkipCols; + aSkipCols.setInsertFromBack(true); // speed optimazation. + aSkipCols.setFalse(0, MAXCOL); + for (SCCOL i = 0; i <= MAXCOL; ++i) { - if (nRow > nRowFlagsEndRow) - nRowFlag = pRowFlags->GetNextValue( nRowFlagsIndex, nRowFlagsEndRow); - if ( ( nRowFlag & CR_HIDDEN ) == 0 ) + SCCOL nLastCol = i; + if (ColHidden(i, NULL, &nLastCol)) + { + // Columns are hidden in this range. + aSkipCols.setTrue(i, nLastCol); + } + else { - SCCOL nDataCol = rEndCol; - while (nDataCol > 0 && ( bEmpty[nDataCol] || !aCol[nDataCol].Search(nRow,nIndex) ) ) - --nDataCol; - if ( ( pColFlags[nDataCol] & CR_HIDDEN ) == 0 ) + // These columns are visible. Check for empty columns. + for (SCCOL j = i; j <= nLastCol; ++j) { - ScBaseCell* pCell = aCol[nDataCol].GetCell(nRow); - if (pCell) - { - CellType eType = pCell->GetCellType(); - if (eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT - || (eType == CELLTYPE_FORMULA && !((ScFormulaCell*)pCell)->IsValue()) ) - { - BOOL bFormula = FALSE; //! uebergeben - long nPixel = pCell->GetTextWidth(); - - // Breite bereits im Idle-Handler berechnet? - if ( TEXTWIDTH_DIRTY == nPixel ) - { - ScNeededSizeOptions aOptions; - aOptions.bTotalSize = TRUE; - aOptions.bFormula = bFormula; - aOptions.bSkipMerged = FALSE; - - Fraction aZoom(1,1); - nPixel = aCol[nDataCol].GetNeededSize( nRow, - pDev,nPPTX,nPPTY,aZoom,aZoom, - TRUE, aOptions ); - pCell->SetTextWidth( (USHORT)nPixel ); - } + if (aCol[j].GetCellCount() == 0) + // empty + aSkipCols.setTrue(j,j); + } + } + i = nLastCol; + } - long nTwips = (long) (nPixel / nPPTX); - long nDocW = GetColWidth( nDataCol ); + ScFlatBoolColSegments::RangeData aColData; + for (SCCOL nCol = rEndCol; nCol >= 0; --nCol) + { + if (!aSkipCols.getRangeData(nCol, aColData)) + // Failed to get the data. This should never happen! + return; - long nMissing = nTwips - nDocW; - if ( nMissing > 0 ) - { - // look at alignment - - const ScPatternAttr* pPattern = GetPattern( nDataCol, nRow ); - const SfxItemSet* pCondSet = NULL; - if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ) - pCondSet = pDocument->GetCondResult( nDataCol, nRow, nTab ); - - SvxCellHorJustify eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&) - pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue(); - if ( eHorJust == SVX_HOR_JUSTIFY_CENTER ) - nMissing /= 2; // distributed into both directions - else - { - // STANDARD is LEFT (only text is handled here) - BOOL bRight = ( eHorJust == SVX_HOR_JUSTIFY_RIGHT ); - if ( IsLayoutRTL() ) - bRight = !bRight; - if ( bRight ) - nMissing = 0; // extended only to the left (logical) - } - } + if (aColData.mbValue) + { + // Skip these columns. + nCol = aColData.mnCol1; // move toward 0. + continue; + } - SCCOL nCol = nDataCol; - while (nMissing > 0 && nCol < MAXCOL) - { - ++nCol; - nMissing -= GetColWidth( nCol ); - } - if (nCol>nPrintCol) - nPrintCol = nCol; - } - } + // These are visible and non-empty columns. + for (SCCOL nDataCol = nCol; 0 <= nDataCol && nDataCol >= aColData.mnCol1; --nDataCol) + { + SCCOL nPrintCol = nDataCol; + VisibleDataCellIterator aIter(*mpHiddenRows, aCol[nDataCol]); + ScBaseCell* pCell = aIter.reset(nStartRow); + if (!pCell) + // No visible cells found in this column. Skip it. + continue; + + while (pCell) + { + SCCOL nNewCol = nDataCol; + SCROW nRow = aIter.getRow(); + if (nRow > nEndRow) + // Went past the last row position. Bail out. + break; + + MaybeAddExtraColumn(nNewCol, nRow, pDev, nPPTX, nPPTY); + if (nNewCol > nPrintCol) + nPrintCol = nNewCol; + pCell = aIter.next(); } + + if (nPrintCol > rEndCol) + // Make sure we don't shrink the print area. + rEndCol = nPrintCol; + } + nCol = aColData.mnCol1; // move toward 0. + } +} + +void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY) +{ + ScBaseCell* pCell = aCol[rCol].GetCell(nRow); + if (!pCell || !pCell->HasStringData()) + return; + + bool bFormula = false; //! ueberge + long nPixel = pCell->GetTextWidth(); + + // Breite bereits im Idle-Handler berechnet? + if ( TEXTWIDTH_DIRTY == nPixel ) + { + ScNeededSizeOptions aOptions; + aOptions.bTotalSize = TRUE; + aOptions.bFormula = bFormula; + aOptions.bSkipMerged = FALSE; + + Fraction aZoom(1,1); + nPixel = aCol[rCol].GetNeededSize( + nRow, pDev, nPPTX, nPPTY, aZoom, aZoom, true, aOptions ); + pCell->SetTextWidth( (USHORT)nPixel ); + } + + long nTwips = (long) (nPixel / nPPTX); + long nDocW = GetColWidth( rCol ); + + long nMissing = nTwips - nDocW; + if ( nMissing > 0 ) + { + // look at alignment + + const ScPatternAttr* pPattern = GetPattern( rCol, nRow ); + const SfxItemSet* pCondSet = NULL; + if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ) + pCondSet = pDocument->GetCondResult( rCol, nRow, nTab ); + + SvxCellHorJustify eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&) + pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue(); + if ( eHorJust == SVX_HOR_JUSTIFY_CENTER ) + nMissing /= 2; // distributed into both directions + else + { + // STANDARD is LEFT (only text is handled here) + bool bRight = ( eHorJust == SVX_HOR_JUSTIFY_RIGHT ); + if ( IsLayoutRTL() ) + bRight = !bRight; + if ( bRight ) + nMissing = 0; // extended only to the left (logical) } } - rEndCol = nPrintCol; + + SCCOL nNewCol = rCol; + while (nMissing > 0 && nNewCol < MAXCOL) + { + ScBaseCell* pNextCell = aCol[nNewCol+1].GetCell(nRow); + if (pNextCell && pNextCell->GetCellType() != CELLTYPE_NOTE) + // Cell content in a next column ends display of this string. + nMissing = 0; + else + nMissing -= GetColWidth(++nNewCol); + } + rCol = nNewCol; } void ScTable::DoColResize( SCCOL nCol1, SCCOL nCol2, SCSIZE nAdd ) @@ -1601,7 +1606,104 @@ void ScTable::RestorePrintRanges( const ScPrintSaverTab& rSaveTab ) UpdatePageBreaks(NULL); } +SCROW ScTable::VisibleDataCellIterator::ROW_NOT_FOUND = -1; +ScTable::VisibleDataCellIterator::VisibleDataCellIterator(ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn) : + mrRowSegs(rRowSegs), + mrColumn(rColumn), + mpCell(NULL), + mnCurRow(ROW_NOT_FOUND), + mnUBound(ROW_NOT_FOUND) +{ +} +ScTable::VisibleDataCellIterator::~VisibleDataCellIterator() +{ +} + +ScBaseCell* ScTable::VisibleDataCellIterator::reset(SCROW nRow) +{ + if (nRow > MAXROW) + { + mnCurRow = ROW_NOT_FOUND; + return NULL; + } + + ScFlatBoolRowSegments::RangeData aData; + if (!mrRowSegs.getRangeData(nRow, aData)) + { + mnCurRow = ROW_NOT_FOUND; + return NULL; + } + if (!aData.mbValue) + { + // specified row is visible. Take it. + mnCurRow = nRow; + mnUBound = aData.mnRow2; + } + else + { + // specified row is not-visible. The first visible row is the start of + // the next segment. + mnCurRow = aData.mnRow2 + 1; + mnUBound = mnCurRow; // get range data on the next iteration. + if (mnCurRow > MAXROW) + { + // Make sure the row doesn't exceed our current limit. + mnCurRow = ROW_NOT_FOUND; + return NULL; + } + } + + mpCell = mrColumn.GetCell(mnCurRow); + if (mpCell) + // First visible cell found. + return mpCell; + + // Find a first visible cell below this row (if any). + return next(); +} + +ScBaseCell* ScTable::VisibleDataCellIterator::next() +{ + if (mnCurRow == ROW_NOT_FOUND) + return NULL; + + while (mrColumn.GetNextDataPos(mnCurRow)) + { + if (mnCurRow > mnUBound) + { + // We don't know the visibility of this row range. Query it. + ScFlatBoolRowSegments::RangeData aData; + if (!mrRowSegs.getRangeData(mnCurRow, aData)) + { + mnCurRow = ROW_NOT_FOUND; + return NULL; + } + + if (aData.mbValue) + { + // This row is invisible. Skip to the last invisible row and + // try again. + mnCurRow = mnUBound = aData.mnRow2; + continue; + } + + // This row is visible. + mnUBound = aData.mnRow2; + } + + mpCell = mrColumn.GetCell(mnCurRow); + if (mpCell) + return mpCell; + } + mnCurRow = ROW_NOT_FOUND; + return NULL; +} + +SCROW ScTable::VisibleDataCellIterator::getRow() const +{ + return mnCurRow; +} diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 199d972560e3..9bd5b031fde5 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -58,6 +58,7 @@ #include "postit.hxx" #include "sheetevents.hxx" #include "globstr.hrc" +#include "segmenttree.hxx" #include <math.h> @@ -139,22 +140,28 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE InitializeNoteCaptions(); if (nStartCol==0 && nEndCol==MAXCOL) { - if (pRowHeight && pRowFlags) + if (mpRowHeights && pRowFlags) { - pRowHeight->Insert( nStartRow, nSize); + mpRowHeights->insertSegment(nStartRow, nSize, false); BYTE nNewFlags = pRowFlags->Insert( nStartRow, nSize); // only copy manual size flag, clear all others if (nNewFlags && (nNewFlags != CR_MANUALSIZE)) pRowFlags->SetValue( nStartRow, nStartRow + nSize - 1, nNewFlags & CR_MANUALSIZE); } + if (pOutlineTable) pOutlineTable->InsertRow( nStartRow, nSize ); + + mpFilteredRows->insertSegment(nStartRow, nSize, true); + mpHiddenRows->insertSegment(nStartRow, nSize, true); } for (SCCOL j=nStartCol; j<=nEndCol; j++) aCol[j].InsertRow( nStartRow, nSize ); DecRecalcLevel( false ); + + InvalidatePageBreaks(); } @@ -165,15 +172,19 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE InitializeNoteCaptions(); if (nStartCol==0 && nEndCol==MAXCOL) { - if (pRowHeight && pRowFlags) - { - pRowHeight->Remove( nStartRow, nSize); + if (pRowFlags) pRowFlags->Remove( nStartRow, nSize); - } + + if (mpRowHeights) + mpRowHeights->removeSegment(nStartRow, nStartRow+nSize); + if (pOutlineTable) if (pOutlineTable->DeleteRow( nStartRow, nSize )) if (pUndoOutline) *pUndoOutline = TRUE; + + mpFilteredRows->removeSegment(nStartRow, nStartRow+nSize); + mpHiddenRows->removeSegment(nStartRow, nStartRow+nSize); } { // scope for bulk broadcast @@ -182,6 +193,8 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE aCol[j].DeleteRow( nStartRow, nSize ); } DecRecalcLevel(); + + InvalidatePageBreaks(); } @@ -217,6 +230,9 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE } if (pOutlineTable) pOutlineTable->InsertCol( nStartCol, nSize ); + + mpHiddenCols->insertSegment(nStartCol, static_cast<SCCOL>(nSize), true); + mpFilteredCols->insertSegment(nStartCol, static_cast<SCCOL>(nSize), true); } @@ -248,6 +264,8 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE } } DecRecalcLevel(); + + InvalidatePageBreaks(); } @@ -269,6 +287,10 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE if (pOutlineTable->DeleteCol( nStartCol, nSize )) if (pUndoOutline) *pUndoOutline = TRUE; + + SCCOL nRmSize = nStartCol + static_cast<SCCOL>(nSize); + mpHiddenCols->removeSegment(nStartCol, nRmSize); + mpFilteredCols->removeSegment(nStartCol, nRmSize); } @@ -290,6 +312,8 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, aCol[nStartCol + i]); } DecRecalcLevel(); + + InvalidatePageBreaks(); } @@ -361,20 +385,21 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, // copy widths/heights, and only "hidden", "filtered" and "manual" flags // also for all preceding columns/rows, to have valid positions for drawing objects - if (pColFlags && pTable->pColFlags && pColWidth && pTable->pColWidth) + if (pColWidth && pTable->pColWidth) for (i=0; i<=nCol2; i++) - { - pTable->pColFlags[i] = pColFlags[i] & CR_HIDDEN; pTable->pColWidth[i] = pColWidth[i]; - } - if (pRowFlags && pTable->pRowFlags && pRowHeight && pTable->pRowHeight) + pTable->CopyColHidden(*this, 0, nCol2); + pTable->CopyColFiltered(*this, 0, nCol2); + + if (pRowFlags && pTable->pRowFlags && mpRowHeights && pTable->mpRowHeights) { - pTable->pRowFlags->CopyFromAnded( *pRowFlags, 0, nRow2, - (CR_HIDDEN | CR_FILTERED | CR_MANUALSIZE)); - pTable->pRowHeight->CopyFrom( *pRowHeight, 0, nRow2); + pTable->pRowFlags->CopyFromAnded( *pRowFlags, 0, nRow2, CR_MANUALSIZE); + pTable->CopyRowHeight(*this, 0, nRow2, 0); } + pTable->CopyRowHidden(*this, 0, nRow2); + pTable->CopyRowFiltered(*this, 0, nRow2); // ggf. Formeln durch Werte ersetzen @@ -415,10 +440,10 @@ void ScTable::CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, for (i=nCol1; i<=nCol2; i++) pColWidth[i] = pTable->pColWidth[i-nDx]; - if (nCol1==0 && nCol2==MAXCOL && pRowHeight && pTable->pRowHeight && + if (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pTable->mpRowHeights && pRowFlags && pTable->pRowFlags) { - pRowHeight->CopyFrom( *pTable->pRowHeight, nRow1, nRow2, -nDy); + CopyRowHeight(*pTable, nRow1, nRow2, -nDy); // Must copy CR_MANUALSIZE bit too, otherwise pRowHeight doesn't make sense for (SCROW j=nRow1; j<=nRow2; j++) { @@ -653,8 +678,10 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, // Charts muessen beim Ein-/Ausblenden angepasst werden ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection(); + bool bFlagChange = false; + BOOL bWidth = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth); - BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && pRowHeight && pDestTab->pRowHeight); + BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights); if (bWidth||bHeight) { @@ -663,33 +690,77 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if (bWidth) for (SCCOL i=nCol1; i<=nCol2; i++) { - BOOL bChange = pCharts && - ( pDestTab->pColFlags[i] & CR_HIDDEN ) != ( pColFlags[i] & CR_HIDDEN ); + bool bThisHidden = ColHidden(i); + bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden); + bool bChange = bHiddenChange || (pDestTab->pColWidth[i] != pColWidth[i]); pDestTab->pColWidth[i] = pColWidth[i]; pDestTab->pColFlags[i] = pColFlags[i]; + pDestTab->SetColHidden(i, i, bThisHidden); //! Aenderungen zusammenfassen? - if (bChange) + if (bHiddenChange && pCharts) pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab )); + + if (bChange) + bFlagChange = true; } if (bHeight) { - pDestTab->pRowHeight->CopyFrom( *pRowHeight, nRow1, nRow2); - for (SCROW i=nRow1; i<=nRow2; i++) + bool bChange = pDestTab->GetRowHeight(nRow1, nRow2) != GetRowHeight(nRow1, nRow2); + + if (bChange) + bFlagChange = true; + + pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0); + pDestTab->pRowFlags->CopyFrom(*pRowFlags, nRow1, nRow2); + + // Hidden flags. + for (SCROW i = nRow1; i <= nRow2; ++i) { - // TODO: might need some performance improvement, block - // operations instead of single GetValue()/SetValue() calls. - BYTE nThisRowFlags = pRowFlags->GetValue(i); - BOOL bChange = pCharts && - ( pDestTab->pRowFlags->GetValue(i) & CR_HIDDEN ) != ( nThisRowFlags & CR_HIDDEN ); - pDestTab->pRowFlags->SetValue( i, nThisRowFlags ); - //! Aenderungen zusammenfassen? - if (bChange) - pCharts->SetRangeDirty(ScRange( 0, i, nTab, MAXCOL, i, nTab )); + SCROW nThisLastRow, nDestLastRow; + bool bThisHidden = RowHidden(i, NULL, &nThisLastRow); + bool bDestHidden = pDestTab->RowHidden(i, NULL, &nDestLastRow); + + // If the segment sizes differ, we take the shorter segment of the two. + SCROW nLastRow = ::std::min(nThisLastRow, nDestLastRow); + if (nLastRow >= nRow2) + // the last row shouldn't exceed the upper bound the caller specified. + nLastRow = nRow2; + + pDestTab->SetRowHidden(i, nLastRow, bThisHidden); + + bool bThisHiddenChange = (bThisHidden != bDestHidden); + if (bThisHiddenChange && pCharts) + { + // Hidden flags differ. + pCharts->SetRangeDirty(ScRange(0, i, nTab, MAXCOL, nLastRow, nTab)); + } + + if (bThisHiddenChange) + bFlagChange = true; + + // Jump to the last row of the identical flag segment. + i = nLastRow; + } + + // Filtered flags. + for (SCROW i = nRow1; i <= nRow2; ++i) + { + SCROW nLastRow; + bool bFiltered = RowFiltered(i, NULL, &nLastRow); + if (nLastRow >= nRow2) + // the last row shouldn't exceed the upper bound the caller specified. + nLastRow = nRow2; + pDestTab->SetRowFiltered(i, nLastRow, bFiltered); + i = nLastRow; } } pDestTab->DecRecalcLevel(); } + + if (bFlagChange) + pDestTab->InvalidatePageBreaks(); + pDestTab->SetOutlineTable( pOutlineTable ); // auch nur wenn bColRowFlags } } @@ -703,7 +774,7 @@ void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)) { BOOL bWidth = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth); - BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && pRowHeight && pDestTab->pRowHeight); + BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights); if (bWidth||bHeight) IncRecalcLevel(); @@ -723,8 +794,8 @@ void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, for (SCCOL i=nCol1; i<=nCol2; i++) pDestTab->pColWidth[i] = pColWidth[i]; if (bHeight) - pDestTab->pRowHeight->CopyFrom( *pRowHeight, nRow1, nRow2); - DecRecalcLevel(); + pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0); + DecRecalcLevel(); } } } @@ -736,6 +807,16 @@ void ScTable::CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const aCol[i].CopyUpdated( pPosTab->aCol[i], pDestTab->aCol[i] ); } +void ScTable::InvalidateTableArea() +{ + bTableAreaValid = FALSE; +} + +void ScTable::InvalidatePageBreaks() +{ + mbPageBreaksValid = false; +} + void ScTable::CopyScenarioTo( ScTable* pDestTab ) const { DBG_ASSERT( bScenario, "bScenario == FALSE" ); @@ -1115,6 +1196,17 @@ void ScTable::SetRelNameDirty() } +void ScTable::SetLoadingMedium(bool bLoading) +{ + mpRowHeights->enableTreeSearch(!bLoading); + + // When loading a medium, prefer inserting row heights from the back + // position since the row heights are stored and read in ascending order + // during import. + mpRowHeights->setInsertFromBack(bLoading); +} + + void ScTable::CalcAll() { for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CalcAll(); @@ -1262,7 +1354,7 @@ BOOL ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2, SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY, - const ScPatternAttr* pPattern, const SfxItemSet* pCondSet ) const + const ScPatternAttr* pPattern, const SfxItemSet* pCondSet ) { // Rueckgabe = neues nArrY @@ -1295,7 +1387,7 @@ SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCO for ( SCROW nRow = nAttrRow1; nRow <= nAttrRow2; nRow++ ) { - if ( !(pRowFlags->GetValue(nRow) & CR_HIDDEN) ) + if (!RowHidden(nRow)) { BOOL bHitOne = TRUE; if ( nCol > nX2+1 ) @@ -1303,7 +1395,7 @@ SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCO // reicht die gedrehte Zelle bis in den sichtbaren Bereich? SCCOL nTouchedCol = nCol; - long nWidth = (long) ( pRowHeight->GetValue(nRow) * nFactor ); + long nWidth = static_cast<long>(mpRowHeights->getValue(nRow) * nFactor); DBG_ASSERT(nWidth <= 0, "Richtung falsch"); while ( nWidth < 0 && nTouchedCol > 0 ) { @@ -1329,9 +1421,9 @@ SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCO return nArrY; } -void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 ) const +void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 ) { - if ( !pColWidth || !pRowHeight || !pColFlags || !pRowFlags ) + if ( !pColWidth || !mpRowHeights || !pColFlags || !pRowFlags ) { DBG_ERROR( "Spalten-/Zeileninfo fehlt" ); return; @@ -1344,7 +1436,7 @@ void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCC for (SCCOL nCol=0; nCol<=MAXCOL; nCol++) { - if ( !(pColFlags[nCol] & CR_HIDDEN) ) + if (!ColHidden(nCol)) { SCSIZE nArrY = 0; ScDocAttrIterator aIter( pDocument, nTab, nCol, nY1, nCol, nY2 ); @@ -1859,36 +1951,24 @@ void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, BOOL bRem double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY ) { - BOOL* pUsed = new BOOL[MAXROWCOUNT]; - memset( pUsed, 0, sizeof(BOOL) * (MAXROWCOUNT) ); + ScFlatBoolRowSegments aUsedRows; + for (SCCOL i = 0; i <= MAXCOL; ++i) + aCol[i].FindStyleSheet(pStyleSheet, aUsedRows, bRemoved); - SCCOL nCol; - for (nCol=0; nCol<=MAXCOL; nCol++) - aCol[nCol].FindStyleSheet( pStyleSheet, pUsed, bRemoved ); - - BOOL bFound = FALSE; - SCROW nStart = 0, nEnd = 0; - for (SCROW i=0; i<=MAXROW; i++) + SCROW nRow = 0; + while (nRow <= MAXROW) { - if (pUsed[i]) - { - if (!bFound) - { - nStart = i; - bFound = TRUE; - } - nEnd = i; - } - else if (bFound) - { - SetOptimalHeight( nStart, nEnd, 0, pDev, nPPTX, nPPTY, rZoomX, rZoomY, FALSE ); - bFound = FALSE; - } - } - if (bFound) - SetOptimalHeight( nStart, nEnd, 0, pDev, nPPTX, nPPTY, rZoomX, rZoomY, FALSE ); + ScFlatBoolRowSegments::RangeData aData; + if (!aUsedRows.getRangeData(nRow, aData)) + // search failed! + return; - delete[] pUsed; + SCROW nEndRow = aData.mnRow2; + if (aData.mbValue) + SetOptimalHeight(nRow, nEndRow, 0, pDev, nPPTX, nPPTY, rZoomX, rZoomY, FALSE); + + nRow = nEndRow + 1; + } } @@ -1970,6 +2050,8 @@ void ScTable::SetColWidth( SCCOL nCol, USHORT nNewWidth ) pDrawLayer->WidthChanged( nTab, nCol, ((long) nNewWidth) - (long) pColWidth[nCol] ); pColWidth[nCol] = nNewWidth; DecRecalcLevel(); + + InvalidatePageBreaks(); } } else @@ -1981,7 +2063,7 @@ void ScTable::SetColWidth( SCCOL nCol, USHORT nNewWidth ) void ScTable::SetRowHeight( SCROW nRow, USHORT nNewHeight ) { - if (VALIDROW(nRow) && pRowHeight) + if (VALIDROW(nRow) && mpRowHeights) { if (!nNewHeight) { @@ -1989,7 +2071,7 @@ void ScTable::SetRowHeight( SCROW nRow, USHORT nNewHeight ) nNewHeight = ScGlobal::nStdRowHeight; } - USHORT nOldHeight = pRowHeight->GetValue(nRow); + sal_uInt16 nOldHeight = mpRowHeights->getValue(nRow); if ( nNewHeight != nOldHeight ) { IncRecalcLevel(); @@ -1997,8 +2079,10 @@ void ScTable::SetRowHeight( SCROW nRow, USHORT nNewHeight ) ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); if (pDrawLayer) pDrawLayer->HeightChanged( nTab, nRow, ((long) nNewHeight) - (long) nOldHeight ); - pRowHeight->SetValue( nRow, nNewHeight); + mpRowHeights->setValue(nRow, nRow, nNewHeight); DecRecalcLevel(); + + InvalidatePageBreaks(); } } else @@ -2007,12 +2091,45 @@ void ScTable::SetRowHeight( SCROW nRow, USHORT nNewHeight ) } } +namespace { + +/** + * Check if the new pixel size is different from the old size between + * specified ranges. + */ +bool lcl_pixelSizeChanged( + ScFlatUInt16RowSegments& rRowHeights, SCROW nStartRow, SCROW nEndRow, + sal_uInt16 nNewHeight, double nPPTY) +{ + long nNewPix = static_cast<long>(nNewHeight * nPPTY); + + ScFlatUInt16RowSegments::ForwardIterator aFwdIter(rRowHeights); + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow) + { + sal_uInt16 nHeight; + if (!aFwdIter.getValue(nRow, nHeight)) + break; + + if (nHeight != nNewHeight) + { + bool bChanged = (nNewPix != static_cast<long>(nHeight * nPPTY)); + if (bChanged) + return true; + } + + // Skip ahead to the last position of the current range. + nRow = aFwdIter.getLastPos(); + } + return false; +} + +} BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeight, double /* nPPTX */, double nPPTY ) { BOOL bChanged = FALSE; - if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowHeight) + if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && mpRowHeights) { IncRecalcLevel(); InitializeNoteCaptions(); @@ -2022,8 +2139,6 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig nNewHeight = ScGlobal::nStdRowHeight; } - long nNewPix = (long) ( nNewHeight * nPPTY ); - BOOL bSingle = FALSE; // TRUE = process every row for its own ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); if (pDrawLayer) @@ -2032,24 +2147,17 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig if (bSingle) { - size_t nIndex; - SCROW nRegionEndRow; - USHORT nOldHeight = pRowHeight->GetValue( nStartRow, nIndex, nRegionEndRow); - if (nNewHeight == nOldHeight && nEndRow <= nRegionEndRow) + ScFlatUInt16RowSegments::RangeData aData; + mpRowHeights->getRangeData(nStartRow, aData); + if (nNewHeight == aData.mnValue && nEndRow <= aData.mnRow2) bSingle = FALSE; // no difference in this range } if (bSingle) { if (nEndRow-nStartRow < 20) { - // Whether new pixel size will differ from old pixel size in any row. - ScCompressedArrayIterator< SCROW, USHORT> aIter( *pRowHeight, - nStartRow, nEndRow); - do - { - if (*aIter != nNewHeight) - bChanged = (nNewPix != (long) (*aIter * nPPTY)); - } while (!bChanged && aIter.NextRange()); + if (!bChanged) + bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); /* #i94028# #i94991# If drawing objects are involved, each row has to be changed for its own, because each call to @@ -2061,12 +2169,12 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig for( SCROW nRow = nStartRow; nRow <= nEndRow ; ++nRow ) { pDrawLayer->HeightChanged( nTab, nRow, - ((long) nNewHeight) - ((long) pRowHeight->GetValue( nRow ))); - pRowHeight->SetValue( nRow, nNewHeight ); + static_cast<long>(nNewHeight) - static_cast<long>(mpRowHeights->getValue(nRow))); + mpRowHeights->setValue(nRow, nRow, nNewHeight); } } else - pRowHeight->SetValue( nStartRow, nEndRow, nNewHeight); + mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); } else { @@ -2081,23 +2189,22 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig { if (pDrawLayer) { - unsigned long nOldHeights = pRowHeight->SumValues( nStartRow, nEndRow); + unsigned long nOldHeights = GetRowHeight(nStartRow, nEndRow); // FIXME: should we test for overflows? long nHeightDif = (long) (unsigned long) nNewHeight * (nEndRow - nStartRow + 1) - nOldHeights; pDrawLayer->HeightChanged( nTab, nEndRow, nHeightDif ); } - // Whether new pixel size will differ from old pixel size in any row. - ScCompressedArrayIterator< SCROW, USHORT> aIter( *pRowHeight, - nStartRow, nEndRow); - do - { - if (*aIter != nNewHeight) - bChanged = (nNewPix != (long) (*aIter * nPPTY)); - } while (!bChanged && aIter.NextRange()); - pRowHeight->SetValue( nStartRow, nEndRow, nNewHeight); + + if (!bChanged) + bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); + + mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); } DecRecalcLevel(); + + if (bChanged) + InvalidatePageBreaks(); } else { @@ -2107,6 +2214,16 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig return bChanged; } +void ScTable::SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeight ) +{ + if (!ValidRow(nStartRow) || !ValidRow(nEndRow) || !mpRowHeights) + return; + + if (!nNewHeight) + nNewHeight = ScGlobal::nStdRowHeight; + + mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); +} void ScTable::SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ) { @@ -2124,13 +2241,13 @@ void ScTable::SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ) } -USHORT ScTable::GetColWidth( SCCOL nCol ) const +USHORT ScTable::GetColWidth( SCCOL nCol ) { DBG_ASSERT(VALIDCOL(nCol),"Falsche Spaltennummer"); if (VALIDCOL(nCol) && pColFlags && pColWidth) { - if ( pColFlags[nCol] & CR_HIDDEN ) + if (ColHidden(nCol)) return 0; else return pColWidth[nCol]; @@ -2151,7 +2268,7 @@ USHORT ScTable::GetOriginalWidth( SCCOL nCol ) const // immer die eingest } -USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) const +USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) { // get the width that is used in the largest continuous column range (up to nEndCol) @@ -2163,24 +2280,24 @@ USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) const USHORT nMaxWidth = 0; USHORT nMaxCount = 0; - USHORT nRangeStart = 0; + SCCOL nRangeStart = 0; while ( nRangeStart <= nEndCol ) { // skip hidden columns - while ( nRangeStart <= nEndCol && (pColFlags[nRangeStart] & CR_HIDDEN) ) + while ( nRangeStart <= nEndCol && ColHidden(nRangeStart) ) ++nRangeStart; if ( nRangeStart <= nEndCol ) { USHORT nThisCount = 0; USHORT nThisWidth = pColWidth[nRangeStart]; - USHORT nRangeEnd = nRangeStart; + SCCOL nRangeEnd = nRangeStart; while ( nRangeEnd <= nEndCol && pColWidth[nRangeEnd] == nThisWidth ) { ++nThisCount; ++nRangeEnd; // skip hidden columns - while ( nRangeEnd <= nEndCol && (pColFlags[nRangeEnd] & CR_HIDDEN) ) + while ( nRangeEnd <= nEndCol && ColHidden(nRangeEnd) ) ++nRangeEnd; } @@ -2198,44 +2315,80 @@ USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) const } -USHORT ScTable::GetRowHeight( SCROW nRow ) const +USHORT ScTable::GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) { DBG_ASSERT(VALIDROW(nRow),"Falsche Zeilennummer"); - if (VALIDROW(nRow) && pRowFlags && pRowHeight) + if (VALIDROW(nRow) && mpRowHeights) { - if ( pRowFlags->GetValue(nRow) & CR_HIDDEN ) + if (bHiddenAsZero && RowHidden(nRow)) return 0; else - return pRowHeight->GetValue(nRow); + { + ScFlatUInt16RowSegments::RangeData aData; + if (!mpRowHeights->getRangeData(nRow, aData)) + // TODO: What should we return in case the search fails? + return 0; + + if (pStartRow) + *pStartRow = aData.mnRow1; + if (pEndRow) + *pEndRow = aData.mnRow2; + return aData.mnValue; + } } else return (USHORT) ScGlobal::nStdRowHeight; } -ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const +ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) { DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer"); - if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowFlags && pRowHeight) + if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && mpRowHeights) { - return pRowFlags->SumCoupledArrayForCondition( nStartRow, nEndRow, - CR_HIDDEN, 0, *pRowHeight); + ULONG nHeight = 0; + SCROW nRow = nStartRow; + while (nRow <= nEndRow) + { + SCROW nLastRow = -1; + if (!RowHidden(nRow, nLastRow)) + { + if (nLastRow > nEndRow) + nLastRow = nEndRow; + nHeight += mpRowHeights->getSumValue(nRow, nLastRow); + } + nRow = nLastRow + 1; + } + return nHeight; } else return (ULONG) ((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight); } -ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const +ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) { DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer"); - if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowFlags && pRowHeight) + if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && mpRowHeights) { - return pRowFlags->SumScaledCoupledArrayForCondition( nStartRow, - nEndRow, CR_HIDDEN, 0, *pRowHeight, fScale); + ULONG nHeight = 0; + SCROW nRow = nStartRow; + while (nRow <= nEndRow) + { + SCROW nLastRow = -1; + if (!RowHidden(nRow, nLastRow)) + { + if (nLastRow > nEndRow) + nLastRow = nEndRow; + sal_uInt32 nThisHeight = mpRowHeights->getSumValue(nRow, nLastRow); + nHeight += static_cast<ULONG>(nThisHeight * fScale); + } + nRow = nLastRow + 1; + } + return nHeight; } else return (ULONG) ((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight * fScale); @@ -2246,8 +2399,8 @@ USHORT ScTable::GetOriginalHeight( SCROW nRow ) const // non-0 even if hid { DBG_ASSERT(VALIDROW(nRow),"wrong row number"); - if (VALIDROW(nRow) && pRowHeight) - return pRowHeight->GetValue(nRow); + if (VALIDROW(nRow) && mpRowHeights) + return mpRowHeights->getValue(nRow); else return (USHORT) ScGlobal::nStdRowHeight; } @@ -2256,28 +2409,26 @@ USHORT ScTable::GetOriginalHeight( SCROW nRow ) const // non-0 even if hid // Spalten-/Zeilen-Flags -SCROW ScTable::GetHiddenRowCount( SCROW nRow ) const +SCROW ScTable::GetHiddenRowCount( SCROW nRow ) { - SCROW nEndRow = nRow; - if ( pRowFlags ) - { - nEndRow = pRowFlags->GetBitStateEnd( nRow, CR_HIDDEN, CR_HIDDEN); - if (ValidRow(nEndRow)) - ++nEndRow; - else - nEndRow = nRow; - } - return nEndRow - nRow; + if (!ValidRow(nRow)) + return 0; + + SCROW nLastRow = -1; + if (!RowHidden(nRow, nLastRow) || !ValidRow(nLastRow)) + return 0; + + return nLastRow - nRow + 1; } //! ShowRows / DBShowRows zusammenfassen -void ScTable::ShowCol(SCCOL nCol, BOOL bShow) +void ScTable::ShowCol(SCCOL nCol, bool bShow) { - if (VALIDCOL(nCol) && pColFlags) + if (VALIDCOL(nCol)) { - BOOL bWasVis = ( pColFlags[nCol] & CR_HIDDEN ) == 0; + bool bWasVis = !ColHidden(nCol); if (bWasVis != bShow) { IncRecalcLevel(); @@ -2291,11 +2442,8 @@ void ScTable::ShowCol(SCCOL nCol, BOOL bShow) pDrawLayer->WidthChanged( nTab, nCol, -(long) pColWidth[nCol] ); } - if (bShow) - pColFlags[nCol] &= ~CR_HIDDEN; - else - pColFlags[nCol] |= CR_HIDDEN; - DecRecalcLevel(); + SetColHidden(nCol, nCol, !bShow); + DecRecalcLevel(); ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); if ( pCharts ) @@ -2309,12 +2457,11 @@ void ScTable::ShowCol(SCCOL nCol, BOOL bShow) } -void ScTable::ShowRow(SCROW nRow, BOOL bShow) +void ScTable::ShowRow(SCROW nRow, bool bShow) { if (VALIDROW(nRow) && pRowFlags) { - BYTE nFlags = pRowFlags->GetValue(nRow); - BOOL bWasVis = ( nFlags & CR_HIDDEN ) == 0; + bool bWasVis = !RowHidden(nRow); if (bWasVis != bShow) { IncRecalcLevel(); @@ -2323,20 +2470,23 @@ void ScTable::ShowRow(SCROW nRow, BOOL bShow) if (pDrawLayer) { if (bShow) - pDrawLayer->HeightChanged( nTab, nRow, (long) pRowHeight->GetValue(nRow) ); + pDrawLayer->HeightChanged( + nTab, nRow, static_cast<long>(mpRowHeights->getValue(nRow))); else - pDrawLayer->HeightChanged( nTab, nRow, -(long) pRowHeight->GetValue(nRow) ); + pDrawLayer->HeightChanged( + nTab, nRow, -static_cast<long>(mpRowHeights->getValue(nRow))); } + SetRowHidden(nRow, nRow, !bShow); if (bShow) - pRowFlags->SetValue( nRow, nFlags & ~(CR_HIDDEN | CR_FILTERED)); - else - pRowFlags->SetValue( nRow, nFlags | CR_HIDDEN); - DecRecalcLevel(); + SetRowFiltered(nRow, nRow, false); + DecRecalcLevel(); ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); if ( pCharts ) pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, MAXCOL, nRow, nTab )); + + InvalidatePageBreaks(); } } else @@ -2346,12 +2496,11 @@ void ScTable::ShowRow(SCROW nRow, BOOL bShow) } -void ScTable::DBShowRow(SCROW nRow, BOOL bShow) +void ScTable::DBShowRow(SCROW nRow, bool bShow) { if (VALIDROW(nRow) && pRowFlags) { - BYTE nFlags = pRowFlags->GetValue(nRow); - BOOL bWasVis = ( nFlags & CR_HIDDEN ) == 0; + bool bWasVis = !RowHidden(nRow); IncRecalcLevel(); InitializeNoteCaptions(); if (bWasVis != bShow) @@ -2360,18 +2509,18 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow) if (pDrawLayer) { if (bShow) - pDrawLayer->HeightChanged( nTab, nRow, (long) pRowHeight->GetValue(nRow) ); + pDrawLayer->HeightChanged( + nTab, nRow, static_cast<long>(mpRowHeights->getValue(nRow))); else - pDrawLayer->HeightChanged( nTab, nRow, -(long) pRowHeight->GetValue(nRow) ); + pDrawLayer->HeightChanged( + nTab, nRow, -static_cast<long>(mpRowHeights->getValue(nRow))); } } // Filter-Flag immer setzen, auch wenn Hidden unveraendert - if (bShow) - pRowFlags->SetValue( nRow, nFlags & ~(CR_HIDDEN | CR_FILTERED)); - else - pRowFlags->SetValue( nRow, nFlags | (CR_HIDDEN | CR_FILTERED)); - DecRecalcLevel(); + SetRowHidden(nRow, nRow, !bShow); + SetRowFiltered(nRow, nRow, !bShow); + DecRecalcLevel(); if (bWasVis != bShow) { @@ -2381,6 +2530,8 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow) if (pOutlineTable) UpdateOutlineRow( nRow, nRow, bShow ); + + InvalidatePageBreaks(); } } else @@ -2390,26 +2541,25 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow) } -void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow) +void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow) { SCROW nStartRow = nRow1; IncRecalcLevel(); InitializeNoteCaptions(); while (nStartRow <= nRow2) { - BYTE nOldFlag = pRowFlags->GetValue(nStartRow) & CR_HIDDEN; - SCROW nEndRow = pRowFlags->GetBitStateEnd( nStartRow, CR_HIDDEN, nOldFlag); + SCROW nEndRow = -1; + bool bWasVis = !RowHidden(nStartRow, nEndRow); if (nEndRow > nRow2) nEndRow = nRow2; - BOOL bWasVis = ( nOldFlag == 0 ); BOOL bChanged = ( bWasVis != bShow ); if ( bChanged ) { ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); if (pDrawLayer) { - long nHeight = (long) pRowHeight->SumValues( nStartRow, nEndRow); + long nHeight = static_cast<long>(mpRowHeights->getSumValue(nStartRow, nEndRow)); if (bShow) pDrawLayer->HeightChanged( nTab, nStartRow, nHeight ); else @@ -2417,10 +2567,8 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow) } } - if (bShow) - pRowFlags->AndValue( nStartRow, nEndRow, sal::static_int_cast<BYTE>(~(CR_HIDDEN | CR_FILTERED)) ); - else - pRowFlags->OrValue( nStartRow, nEndRow, (CR_HIDDEN | CR_FILTERED)); + SetRowHidden(nStartRow, nEndRow, !bShow); + SetRowFiltered(nStartRow, nEndRow, !bShow); if ( bChanged ) { @@ -2442,26 +2590,25 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow) } -void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow) +void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow) { SCROW nStartRow = nRow1; IncRecalcLevel(); InitializeNoteCaptions(); while (nStartRow <= nRow2) { - BYTE nOldFlag = pRowFlags->GetValue(nStartRow) & CR_HIDDEN; - SCROW nEndRow = pRowFlags->GetBitStateEnd( nStartRow, CR_HIDDEN, nOldFlag); + SCROW nEndRow = -1; + bool bWasVis = !RowHidden(nStartRow, nEndRow); if (nEndRow > nRow2) nEndRow = nRow2; - BOOL bWasVis = ( nOldFlag == 0 ); BOOL bChanged = ( bWasVis != bShow ); if ( bChanged ) { ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer(); if (pDrawLayer) { - long nHeight = (long) pRowHeight->SumValues( nStartRow, nEndRow); + long nHeight = static_cast<long>(mpRowHeights->getSumValue(nStartRow, nEndRow)); if (bShow) pDrawLayer->HeightChanged( nTab, nStartRow, nHeight ); else @@ -2469,16 +2616,17 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow) } } + SetRowHidden(nStartRow, nEndRow, !bShow); if (bShow) - pRowFlags->AndValue( nStartRow, nEndRow, sal::static_int_cast<BYTE>(~(CR_HIDDEN | CR_FILTERED)) ); - else - pRowFlags->OrValue( nStartRow, nEndRow, CR_HIDDEN); + SetRowFiltered(nStartRow, nEndRow, false); if ( bChanged ) { ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection(); if ( pCharts ) pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab )); + + InvalidatePageBreaks(); } nStartRow = nEndRow + 1; @@ -2487,16 +2635,6 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow) } -BOOL ScTable::IsFiltered(SCROW nRow) const -{ - if (VALIDROW(nRow) && pRowFlags) - return ( pRowFlags->GetValue(nRow) & CR_FILTERED ) != 0; - - DBG_ERROR("Falsche Zeilennummer oder keine Flags"); - return FALSE; -} - - void ScTable::SetColFlags( SCCOL nCol, BYTE nNewFlags ) { if (VALIDCOL(nCol) && pColFlags) @@ -2550,11 +2688,32 @@ BYTE ScTable::GetRowFlags( SCROW nRow ) const SCROW ScTable::GetLastFlaggedRow() const { - if ( !pRowFlags ) - return 0; + SCROW nLastFound = 0; + if (pRowFlags) + { + SCROW nRow = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<BYTE>(CR_ALL) ); + if (ValidRow(nRow)) + nLastFound = nRow; + } - SCROW nLastFound = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) ); - return ValidRow(nLastFound) ? nLastFound : 0; + if (!maRowManualBreaks.empty()) + nLastFound = ::std::max(nLastFound, *maRowManualBreaks.rbegin()); + + if (mpHiddenRows) + { + SCROW nRow = mpHiddenRows->findLastNotOf(false); + if (ValidRow(nRow)) + nLastFound = ::std::max(nLastFound, nRow); + } + + if (mpFilteredRows) + { + SCROW nRow = mpFilteredRows->findLastNotOf(false); + if (ValidRow(nRow)) + nLastFound = ::std::max(nLastFound, nRow); + } + + return nLastFound; } @@ -2565,7 +2724,7 @@ SCCOL ScTable::GetLastChangedCol() const SCCOL nLastFound = 0; for (SCCOL nCol = 1; nCol <= MAXCOL; nCol++) - if ((pColFlags[nCol] & ~CR_PAGEBREAK) || (pColWidth[nCol] != STD_COL_WIDTH)) + if ((pColFlags[nCol] & CR_ALL) || (pColWidth[nCol] != STD_COL_WIDTH)) nLastFound = nCol; return nLastFound; @@ -2577,11 +2736,12 @@ SCROW ScTable::GetLastChangedRow() const if ( !pRowFlags ) return 0; - SCROW nLastFlags = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) ); - if (!ValidRow(nLastFlags)) - nLastFlags = 0; + SCROW nLastFlags = GetLastFlaggedRow(); - SCROW nLastHeight = pRowHeight->GetLastUnequalAccess( 0, ScGlobal::nStdRowHeight); + // Find the last row position where the height is NOT the standard row + // height. + // KOHEI: Test this to make sure it does what it's supposed to. + SCROW nLastHeight = mpRowHeights->findLastNotOf(ScGlobal::nStdRowHeight); if (!ValidRow(nLastHeight)) nLastHeight = 0; @@ -2594,7 +2754,7 @@ BOOL ScTable::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, BOOL bShow ) if (pOutlineTable && pColFlags) { ScBitMaskCompressedArray< SCCOLROW, BYTE> aArray( MAXCOL, pColFlags, MAXCOLCOUNT); - return pOutlineTable->GetColArray()->ManualAction( nStartCol, nEndCol, bShow, aArray ); + return pOutlineTable->GetColArray()->ManualAction( nStartCol, nEndCol, bShow, *this, true ); } else return FALSE; @@ -2604,7 +2764,7 @@ BOOL ScTable::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, BOOL bShow ) BOOL ScTable::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, BOOL bShow ) { if (pOutlineTable && pRowFlags) - return pOutlineTable->GetRowArray()->ManualAction( nStartRow, nEndRow, bShow, *pRowFlags ); + return pOutlineTable->GetRowArray()->ManualAction( nStartRow, nEndRow, bShow, *this, false ); else return FALSE; } @@ -2612,54 +2772,58 @@ BOOL ScTable::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, BOOL bShow ) void ScTable::ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ) { - if (pColFlags) - { - while ( rX1>0 ? (pColFlags[rX1-1] & CR_HIDDEN) : FALSE ) - --rX1; - while ( rX2<MAXCOL ? (pColFlags[rX2+1] & CR_HIDDEN) : FALSE ) - ++rX2; - } - if (pRowFlags) + // Column-wise expansion + + while (rX1 > 0 && ColHidden(rX1-1)) + --rX1; + + while (rX2 < MAXCOL && ColHidden(rX2+1)) + ++rX2; + + // Row-wise expansion + + if (rY1 > 0) { - if (rY1 > 0) + ScFlatBoolRowSegments::RangeData aData; + if (mpHiddenRows->getRangeData(rY1-1, aData) && aData.mbValue) { - SCROW nStartRow = pRowFlags->GetBitStateStart( rY1-1, CR_HIDDEN, CR_HIDDEN); + SCROW nStartRow = aData.mnRow1; if (ValidRow(nStartRow)) rY1 = nStartRow; } - if (rY2 < MAXROW) - { - SCROW nEndRow = pRowFlags->GetBitStateEnd( rY2+1, CR_HIDDEN, CR_HIDDEN); - if (ValidRow(nEndRow)) - rY2 = nEndRow; - } + } + if (rY2 < MAXROW) + { + SCROW nEndRow = -1; + if (RowHidden(rY2+1, nEndRow) && ValidRow(nEndRow)) + rY2 = nEndRow; } } void ScTable::StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ) { - if (pColFlags) - { - while ( rX2>rX1 && (pColFlags[rX2] & CR_HIDDEN) ) - --rX2; - while ( rX2>rX1 && (pColFlags[rX1] & CR_HIDDEN) ) - ++rX1; - } - if (pRowFlags) + while ( rX2>rX1 && ColHidden(rX2) ) + --rX2; + while ( rX2>rX1 && ColHidden(rX1) ) + ++rX1; + + if (rY1 < rY2) { - if (rY1 < rY2) + ScFlatBoolRowSegments::RangeData aData; + if (mpHiddenRows->getRangeData(rY2, aData) && aData.mbValue) { - SCROW nStartRow = pRowFlags->GetBitStateStart( rY2, CR_HIDDEN, CR_HIDDEN); + SCROW nStartRow = aData.mnRow1; if (ValidRow(nStartRow) && nStartRow >= rY1) rY2 = nStartRow; } - if (rY1 < rY2) - { - SCROW nEndRow = pRowFlags->GetBitStateEnd( rY1, CR_HIDDEN, CR_HIDDEN); - if (ValidRow(nEndRow) && nEndRow <= rY2) - rY1 = nEndRow; - } + } + + if (rY1 < rY2) + { + SCROW nEndRow = -1; + if (RowHidden(rY1, nEndRow) && ValidRow(nEndRow) && nEndRow <= rY2) + rY1 = nEndRow; } } @@ -2821,16 +2985,16 @@ BOOL ScTable::RefVisible(ScFormulaCell* pCell) if (pCell->HasOneReference(aRef)) { - if (aRef.aStart.Col()==aRef.aEnd.Col() && aRef.aStart.Tab()==aRef.aEnd.Tab() && pRowFlags) + if (aRef.aStart.Col()==aRef.aEnd.Col() && aRef.aStart.Tab()==aRef.aEnd.Tab()) { - // while ((value & CR_FILTERED) == CR_FILTERED) - // most times will be faster than - // while ((value & CR_FILTERED) == 0) - SCROW nEndRow = pRowFlags->GetBitStateEnd( aRef.aStart.Row(), - CR_FILTERED, CR_FILTERED); + SCROW nEndRow; + if (!RowFiltered(aRef.aStart.Row(), NULL, &nEndRow)) + // row not filtered. + nEndRow = ::std::numeric_limits<SCROW>::max(); + if (!ValidRow(nEndRow) || nEndRow < aRef.aEnd.Row()) return TRUE; // at least partly visible - return FALSE; // completely unvisible + return FALSE; // completely invisible } } @@ -2872,18 +3036,17 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos } -ULONG ScTable::GetRowOffset( SCROW nRow ) const +ULONG ScTable::GetRowOffset( SCROW nRow ) { ULONG n = 0; - if ( pRowFlags && pRowHeight ) + if ( mpHiddenRows && mpRowHeights ) { if (nRow == 0) return 0; else if (nRow == 1) return GetRowHeight(0); - n = pRowFlags->SumCoupledArrayForCondition( 0, nRow-1, CR_HIDDEN, 0, - *pRowHeight); + n = GetTotalRowHeight(0, nRow-1); #ifdef DBG_UTIL if (n == ::std::numeric_limits<unsigned long>::max()) DBG_ERRORFILE("ScTable::GetRowOffset: row heights overflow"); @@ -2896,18 +3059,42 @@ ULONG ScTable::GetRowOffset( SCROW nRow ) const return n; } +SCROW ScTable::GetRowForHeight(ULONG nHeight) +{ + sal_uInt32 nSum = 0; + + ScFlatBoolRowSegments::RangeData aData; + for (SCROW nRow = 0; nRow <= MAXROW; ++nRow) + { + if (!mpHiddenRows->getRangeData(nRow, aData)) + break; + + if (aData.mbValue) + { + nRow = aData.mnRow2; + continue; + } + + sal_uInt32 nNew = mpRowHeights->getValue(nRow); + nSum += nNew; + if (nSum > nHeight) + { + return nRow < MAXROW ? nRow + 1 : MAXROW; + } + } + return -1; +} + -ULONG ScTable::GetColOffset( SCCOL nCol ) const +ULONG ScTable::GetColOffset( SCCOL nCol ) { ULONG n = 0; - if ( pColFlags && pColWidth ) + if ( pColWidth ) { SCCOL i; - BYTE* pFlags = pColFlags; - USHORT* pWidth = pColWidth; - for( i = 0; i < nCol; i++, pFlags++, pWidth++ ) - if( !( *pFlags & CR_HIDDEN ) ) - n += *pWidth; + for( i = 0; i < nCol; i++ ) + if (!ColHidden(i)) + n += pColWidth[i]; } else { diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 7d295b6286a8..bd6a2c92c442 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -208,17 +208,14 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress& rProgress ) { BOOL bByRow = aSortParam.bByRow; SCSIZE nCount = pArray->GetCount(); + SCCOLROW nStart = pArray->GetStart(); ScSortInfo** ppInfo = pArray->GetFirstArray(); - // hngngn.. Win16 legacy? Table has ULONG count but can only be initialized using USHORT :-/ - // FIXME: use std::vector instead, would be better anyway (type safe) - USHORT nArghl = (nCount > USHRT_MAX ? USHRT_MAX : static_cast<USHORT>(nCount)); - Table aTable( nArghl ); + ::std::vector<ScSortInfo*> aTable(nCount); SCSIZE nPos; for ( nPos = 0; nPos < nCount; nPos++ ) - { - aTable.Insert( ppInfo[nPos]->nOrg, (void*) ppInfo[nPos] ); - } - SCCOLROW nDest = pArray->GetStart(); + aTable[ppInfo[nPos]->nOrg - nStart] = ppInfo[nPos]; + + SCCOLROW nDest = nStart; for ( nPos = 0; nPos < nCount; nPos++, nDest++ ) { SCCOLROW nOrg = ppInfo[nPos]->nOrg; @@ -231,9 +228,9 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress& rProgress ) // neue Position des weggeswapten eintragen ScSortInfo* p = ppInfo[nPos]; p->nOrg = nDest; - p = (ScSortInfo*) aTable.Replace( nDest, (void*) p ); + ::std::swap(p, aTable[nDest-nStart]); p->nOrg = nOrg; - p = (ScSortInfo*) aTable.Replace( nOrg, (void*) p ); + ::std::swap(p, aTable[nOrg-nStart]); DBG_ASSERT( p == ppInfo[nPos], "SortReorder: nOrg MisMatch" ); } rProgress.SetStateOnPercent( nPos ); @@ -449,14 +446,17 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2) } } } - if (bGlobalKeepQuery && pRowFlags) + if (bGlobalKeepQuery) { - BYTE nRow1Flags = pRowFlags->GetValue(nRow1); - BYTE nRow2Flags = pRowFlags->GetValue(nRow2); - BYTE nFlags1 = nRow1Flags & ( CR_HIDDEN | CR_FILTERED ); - BYTE nFlags2 = nRow2Flags & ( CR_HIDDEN | CR_FILTERED ); - pRowFlags->SetValue( nRow1, (nRow1Flags & ~( CR_HIDDEN | CR_FILTERED )) | nFlags2); - pRowFlags->SetValue( nRow2, (nRow2Flags & ~( CR_HIDDEN | CR_FILTERED )) | nFlags1); + bool bRow1Hidden = RowHidden(nRow1); + bool bRow2Hidden = RowHidden(nRow2); + SetRowHidden(nRow1, nRow1, bRow2Hidden); + SetRowHidden(nRow2, nRow2, bRow1Hidden); + + bool bRow1Filtered = RowFiltered(nRow1); + bool bRow2Filtered = RowFiltered(nRow2); + SetRowFiltered(nRow1, nRow1, bRow2Filtered); + SetRowFiltered(nRow2, nRow2, bRow1Filtered); } } @@ -616,7 +616,7 @@ void ScTable::RemoveSubTotals( ScSubTotalParam& rParam ) if ( pCell->GetCellType() == CELLTYPE_FORMULA ) if (((ScFormulaCell*)pCell)->IsSubTotal()) { - SetRowFlags(nRow+1,GetRowFlags(nRow+1)&(~CR_MANUALBREAK)); + RemoveRowBreak(nRow+1, false, true); pDocument->DeleteRow( 0,nTab, MAXCOL,nTab, nRow, 1 ); --nEndRow; aIter = ScColumnIterator( &aCol[nCol],nRow,nEndRow ); @@ -784,9 +784,7 @@ BOOL ScTable::DoSubTotals( ScSubTotalParam& rParam ) bBlockVis = FALSE; if ( rParam.bPagebreak && nRow < MAXROW && aRowEntry.nSubStartRow != nStartRow && nLevel == 0) - SetRowFlags( aRowEntry.nSubStartRow, - GetRowFlags(aRowEntry.nSubStartRow) | - CR_MANUALBREAK); + SetRowBreak(aRowEntry.nSubStartRow, false, true); if (bSpaceLeft) { @@ -839,13 +837,6 @@ BOOL ScTable::DoSubTotals( ScSubTotalParam& rParam ) SetString( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, nTab, aOutString ); ApplyStyle( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, *pStyle ); -/* if (rParam.bPagebreak && nRow < MAXROW) - { - BYTE nFlags = GetRowFlags( nRow+1 ); - nFlags |= CR_MANUALBREAK; - SetRowFlags( nRow+1, nFlags ); - } -*/ ++nRow; ++nEndRow; aRowEntry.nSubStartRow = nRow; @@ -859,11 +850,7 @@ BOOL ScTable::DoSubTotals( ScSubTotalParam& rParam ) } } } - if (!pRowFlags) - bBlockVis = TRUE; - else - if ( (pRowFlags->GetValue(nRow) & CR_FILTERED) == 0 ) - bBlockVis = TRUE; + bBlockVis = !RowFiltered(nRow); } } else @@ -1935,8 +1922,8 @@ void ScTable::UpdateSelectionFunction( ScFunctionData& rData, SCCOL nCol; if ( rMark.IsMultiMarked() ) for (nCol=0; nCol<=MAXCOL && !rData.bError; nCol++) - if ( !pColFlags || !( pColFlags[nCol] & CR_HIDDEN ) ) - aCol[nCol].UpdateSelectionFunction( rMark, rData, pRowFlags, + if ( !pColFlags || !ColHidden(nCol) ) + aCol[nCol].UpdateSelectionFunction( rMark, rData, *mpHiddenRows, bSingle && ( nCol >= nStartCol && nCol <= nEndCol ), nStartRow, nEndRow ); @@ -1944,8 +1931,8 @@ void ScTable::UpdateSelectionFunction( ScFunctionData& rData, if ( bSingle && !rMark.IsMarkNegative() ) for (nCol=nStartCol; nCol<=nEndCol && !rData.bError; nCol++) - if ( !pColFlags || !( pColFlags[nCol] & CR_HIDDEN ) ) - aCol[nCol].UpdateAreaFunction( rData, pRowFlags, nStartRow, nEndRow ); + if ( !pColFlags || !ColHidden(nCol) ) + aCol[nCol].UpdateAreaFunction( rData, *mpHiddenRows, nStartRow, nEndRow ); } void ScTable::FindConditionalFormat( ULONG nKey, ScRangeList& rList ) diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index a3a0153a4b97..2635b5821e4f 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -50,8 +50,15 @@ #include "brdcst.hxx" #include "tabprotection.hxx" #include "globstr.hrc" +#include "segmenttree.hxx" +#include <com/sun/star/sheet/TablePageBreakData.hpp> + +#include <algorithm> +#include <limits> using ::com::sun::star::uno::Sequence; +using ::com::sun::star::sheet::TablePageBreakData; +using ::std::set; // STATIC DATA ----------------------------------------------------------- @@ -62,8 +69,18 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) { if ( pDocument->IsImportingXML() ) return; - if ( !pUserArea && !bPageSizeValid ) - return; + + // pUserArea != NULL -> print area is specified. We need to force-update + // the page breaks. + + if (!pUserArea) + { + if (!bPageSizeValid) + return; + + if (mbPageBreaksValid) + return; + } SfxStyleSheetBase* pStyle = pDocument->GetStyleSheetPool()-> Find( aPageStyle, SFX_STYLE_FAMILY_PAGE ); @@ -76,7 +93,6 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) const SfxPoolItem* pItem; SCCOL nX; - SCROW nY; SCCOL nStartCol = 0; SCROW nStartRow = 0; SCCOL nEndCol = MAXCOL; @@ -96,8 +112,9 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) // bei mehreren Bereichen nichts anzeigen: for (nX=0; nX<MAXCOL; nX++) - pColFlags[nX] &= ~CR_PAGEBREAK; - pRowFlags->AndValue( 0, MAXROW-1, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) ); + RemoveColBreak(nX, true, false); + + RemoveRowPageBreaks(0, MAXROW-1); return; } @@ -143,13 +160,13 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) // Anfang: Breaks loeschen for (nX=0; nX<nStartCol; nX++) - pColFlags[nX] &= ~CR_PAGEBREAK; - pRowFlags->AndValue( 0, nStartRow-1, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) ); + RemoveColBreak(nX, true, false); + RemoveRowPageBreaks(0, nStartRow-1); if (nStartCol > 0) - pColFlags[nStartCol] |= CR_PAGEBREAK; //! AREABREAK + SetColBreak(nStartCol, true, false); // AREABREAK if (nStartRow > 0) - pRowFlags->OrValue( nStartRow, CR_PAGEBREAK); //! AREABREAK + SetRowBreak(nStartRow, true, false); // AREABREAK // Mittelteil: Breaks verteilen @@ -159,15 +176,16 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) for (nX=nStartCol; nX<=nEndCol; nX++) { BOOL bStartOfPage = FALSE; - long nThisX = ( pColFlags[nX] & CR_HIDDEN ) ? 0 : pColWidth[nX]; - if ( (nSizeX+nThisX > nPageSizeX) || ((pColFlags[nX] & CR_MANUALBREAK) && !bSkipColBreaks) ) + long nThisX = ColHidden(nX) ? 0 : pColWidth[nX]; + bool bManualBreak = HasColManualBreak(nX); + if ( (nSizeX+nThisX > nPageSizeX) || (bManualBreak && !bSkipColBreaks) ) { - pColFlags[nX] |= CR_PAGEBREAK; + SetColBreak(nX, true, false); nSizeX = 0; bStartOfPage = TRUE; } else if (nX != nStartCol) - pColFlags[nX] &= ~CR_PAGEBREAK; + RemoveColBreak(nX, true, false); else bStartOfPage = TRUE; @@ -175,9 +193,9 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) { // subtract size of repeat columns from page size for (SCCOL i=nRepeatStartX; i<=nRepeatEndX; i++) - nPageSizeX -= ( pColFlags[i] & CR_HIDDEN ) ? 0 : pColWidth[i]; + nPageSizeX -= ColHidden(i) ? 0 : pColWidth[i]; while (nX<=nRepeatEndX) - pColFlags[++nX] &= ~CR_PAGEBREAK; + RemoveColBreak(++nX, true, false); bColFound = TRUE; } @@ -185,23 +203,40 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) } // Remove all page breaks in range. - pRowFlags->AndValue( nStartRow+1, nEndRow, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) ); + RemoveRowPageBreaks(nStartRow+1, nEndRow); + // And set new page breaks. BOOL bRepeatRow = ( nRepeatStartY != SCROW_REPEAT_NONE ); BOOL bRowFound = FALSE; long nSizeY = 0; - ScCompressedArrayIterator< SCROW, BYTE> aFlagsIter( *pRowFlags, nStartRow, nEndRow); - ScCompressedArrayIterator< SCROW, USHORT> aHeightIter( *pRowHeight, nStartRow, nEndRow); - for ( ; aFlagsIter; ++aFlagsIter, ++aHeightIter) + ScFlatBoolRowSegments::ForwardIterator aIterHidden(*mpHiddenRows); + ScFlatUInt16RowSegments::ForwardIterator aIterHeights(*mpRowHeights); + SCROW nNextManualBreak = GetNextManualBreak(nStartRow); // -1 => no more manual breaks + for (SCROW nY = nStartRow; nY <= nEndRow; ++nY) { - nY = aFlagsIter.GetPos(); BOOL bStartOfPage = FALSE; - BYTE nFlags = *aFlagsIter; - long nThisY = (nFlags & CR_HIDDEN) ? 0 : *aHeightIter; - if ( (nSizeY+nThisY > nPageSizeY) || ((nFlags & CR_MANUALBREAK) && !bSkipRowBreaks) ) + bool bThisRowHidden = false; + aIterHidden.getValue(nY, bThisRowHidden); + long nThisY = 0; + if (!bThisRowHidden) + { + sal_uInt16 nTmp; + aIterHeights.getValue(nY, nTmp); + nThisY = static_cast<long>(nTmp); + } + + bool bManualBreak = false; + if (nNextManualBreak >= 0) + { + bManualBreak = (nY == nNextManualBreak); + if (nY >= nNextManualBreak) + // Query the next menual break position. + nNextManualBreak = GetNextManualBreak(nY+1); + } + + if ( (nSizeY+nThisY > nPageSizeY) || (bManualBreak && !bSkipRowBreaks) ) { - pRowFlags->SetValue( nY, nFlags | CR_PAGEBREAK); - aFlagsIter.Resync( nY); + SetRowBreak(nY, true, false); nSizeY = 0; bStartOfPage = TRUE; } @@ -213,21 +248,47 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) if ( bStartOfPage && bRepeatRow && nY>nRepeatStartY && !bRowFound ) { // subtract size of repeat rows from page size - unsigned long nHeights = pRowFlags->SumCoupledArrayForCondition( - nRepeatStartY, nRepeatEndY, CR_HIDDEN, 0, *pRowHeight); + unsigned long nHeights = GetTotalRowHeight(nRepeatStartY, nRepeatEndY); #ifdef DBG_UTIL if (nHeights == ::std::numeric_limits<unsigned long>::max()) DBG_ERRORFILE("ScTable::UpdatePageBreaks: row heights overflow"); #endif nPageSizeY -= nHeights; if (nY <= nRepeatEndY) + RemoveRowPageBreaks(nY, nRepeatEndY); + bRowFound = TRUE; + } + + if (bThisRowHidden) + { + // Hidden row range. Skip them unless there is a manual break. + SCROW nLastCommon = aIterHidden.getLastPos(); + if (nNextManualBreak >= 0) + nLastCommon = ::std::min(nLastCommon, nNextManualBreak-1); + nY = nLastCommon; + } + else + { + // Visible row range. + + SCROW nLastHidden = aIterHidden.getLastPos(); + SCROW nLastHeight = aIterHeights.getLastPos(); + SCROW nLastCommon = ::std::min(nLastHidden, nLastHeight); + if (nNextManualBreak >= 0) + nLastCommon = ::std::min(nLastCommon, nNextManualBreak-1); + + if (nLastCommon > nY) { - pRowFlags->AndValue( nY, nRepeatEndY, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) ); - nY = nRepeatEndY + 1; - aFlagsIter.Resync( nY); - aHeightIter.Resync( nY); + long nMaxMultiple = static_cast<long>(nLastCommon - nY); + long nMultiple = (nPageSizeY - nSizeY) / nThisY; + if (nMultiple > nMaxMultiple) + nMultiple = nMaxMultiple; + if (nMultiple > 1) + { + nSizeY += nThisY * (nMultiple - 1); + nY += nMultiple - 1; + } } - bRowFound = TRUE; } nSizeY += nThisY; @@ -237,26 +298,24 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) if (nEndCol < MAXCOL) { - pColFlags[nEndCol+1] |= CR_PAGEBREAK; //! AREABREAK + SetColBreak(nEndCol+1, true, false); // AREABREAK for (nX=nEndCol+2; nX<=MAXCOL; nX++) - pColFlags[nX] &= ~CR_PAGEBREAK; + RemoveColBreak(nX, true, false); } if (nEndRow < MAXROW) { - pRowFlags->OrValue( nEndRow+1, CR_PAGEBREAK); //! AREABREAK + SetRowBreak(nEndRow+1, true, false); // AREABREAK if (nEndRow+2 <= MAXROW) - pRowFlags->AndValue( nEndRow+2, MAXROW, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) ); + RemoveRowPageBreaks(nEndRow+2, MAXROW); } + mbPageBreaksValid = true; } void ScTable::RemoveManualBreaks() { - if (pColFlags) - for (SCCOL nCol = 0; nCol <= MAXCOL; nCol++) - pColFlags[nCol] &= ~CR_MANUALBREAK; - - if (pRowFlags) - pRowFlags->AndValue( 0, MAXROW, sal::static_int_cast<BYTE>(~CR_MANUALBREAK) ); + maRowManualBreaks.clear(); + maColManualBreaks.clear(); + InvalidatePageBreaks(); if (IsStreamValid()) SetStreamValid(FALSE); @@ -264,22 +323,673 @@ void ScTable::RemoveManualBreaks() BOOL ScTable::HasManualBreaks() const { - if (pColFlags) - for (SCCOL nCol = 0; nCol <= MAXCOL; nCol++) - if ( pColFlags[nCol] & CR_MANUALBREAK ) - return TRUE; + return !maRowManualBreaks.empty() || !maColManualBreaks.empty(); +} + +void ScTable::GetAllRowBreaks(set<SCROW>& rBreaks, bool bPage, bool bManual) const +{ + if (bPage) + rBreaks = maRowPageBreaks; + + if (bManual) + { + using namespace std; + copy(maRowManualBreaks.begin(), maRowManualBreaks.end(), inserter(rBreaks, rBreaks.begin())); + } +} + +void ScTable::GetAllColBreaks(set<SCCOL>& rBreaks, bool bPage, bool bManual) const +{ + if (bPage) + rBreaks = maColPageBreaks; - if (pRowFlags) - if (ValidRow( pRowFlags->GetLastAnyBitAccess( 0, CR_MANUALBREAK))) - return TRUE; + if (bManual) + { + using namespace std; + copy(maColManualBreaks.begin(), maColManualBreaks.end(), inserter(rBreaks, rBreaks.begin())); + } +} + +bool ScTable::HasRowPageBreak(SCROW nRow) const +{ + if (!ValidRow(nRow)) + return false; + + return maRowPageBreaks.count(nRow) > 0; +} + +bool ScTable::HasColPageBreak(SCCOL nCol) const +{ + if (!ValidCol(nCol)) + return false; + + return maColPageBreaks.count(nCol) > 0; +} + +bool ScTable::HasRowManualBreak(SCROW nRow) const +{ + if (!ValidRow(nRow)) + return false; + + return maRowManualBreaks.count(nRow) > 0; +} - return FALSE; +bool ScTable::HasColManualBreak(SCCOL nCol) const +{ + if (!ValidCol(nCol)) + return false; + + return (maColManualBreaks.count(nCol) > 0); +} + +SCROW ScTable::GetNextManualBreak(SCROW nRow) const +{ + set<SCROW>::const_iterator itr = maRowManualBreaks.lower_bound(nRow); + return itr == maRowManualBreaks.end() ? -1 : *itr; +} + +void ScTable::RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow) +{ + using namespace std; + + if (!ValidRow(nStartRow) || !ValidRow(nEndRow)) + return; + + set<SCROW>::iterator low = maRowPageBreaks.lower_bound(nStartRow); + set<SCROW>::iterator high = maRowPageBreaks.upper_bound(nEndRow); + maRowPageBreaks.erase(low, high); +} + +void ScTable::RemoveRowBreak(SCROW nRow, bool bPage, bool bManual) +{ + if (!ValidRow(nRow)) + return; + + if (bPage) + maRowPageBreaks.erase(nRow); + + if (bManual) + { + maRowManualBreaks.erase(nRow); + InvalidatePageBreaks(); + } +} + +void ScTable::RemoveColBreak(SCCOL nCol, bool bPage, bool bManual) +{ + if (!ValidCol(nCol)) + return; + + if (bPage) + maColPageBreaks.erase(nCol); + + if (bManual) + { + maColManualBreaks.erase(nCol); + InvalidatePageBreaks(); + } +} + +void ScTable::SetRowBreak(SCROW nRow, bool bPage, bool bManual) +{ + if (!ValidRow(nRow)) + return; + + if (bPage) + maRowPageBreaks.insert(nRow); + + if (bManual) + { + maRowManualBreaks.insert(nRow); + InvalidatePageBreaks(); + } +} + +void ScTable::SetColBreak(SCCOL nCol, bool bPage, bool bManual) +{ + if (!ValidCol(nCol)) + return; + + if (bPage) + maColPageBreaks.insert(nCol); + + if (bManual) + { + maColManualBreaks.insert(nCol); + InvalidatePageBreaks(); + } +} + +Sequence<TablePageBreakData> ScTable::GetRowBreakData() const +{ + using ::std::copy; + using ::std::inserter; + + set<SCROW> aRowBreaks = maRowPageBreaks; + copy(maRowManualBreaks.begin(), maRowManualBreaks.end(), inserter(aRowBreaks, aRowBreaks.begin())); + + set<SCROW>::const_iterator itr = aRowBreaks.begin(), itrEnd = aRowBreaks.end(); + Sequence<TablePageBreakData> aSeq(aRowBreaks.size()); + + for (sal_Int32 i = 0; itr != itrEnd; ++itr, ++i) + { + SCROW nRow = *itr; + TablePageBreakData aData; + aData.Position = nRow; + aData.ManualBreak = HasRowManualBreak(nRow); + aSeq[i] = aData; + } + + return aSeq; +} + +bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) +{ + if (!ValidRow(nRow)) + return true; + + ScFlatBoolRowSegments::RangeData aData; + if (!mpHiddenRows->getRangeData(nRow, aData)) + // search failed. + return true; + + if (pFirstRow) + *pFirstRow = aData.mnRow1; + if (pLastRow) + *pLastRow = aData.mnRow2; + + return aData.mbValue; +} + + +bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow) +{ + rLastRow = nRow; + if (!ValidRow(nRow)) + return true; + + ScFlatBoolRowSegments::RangeData aData; + if (!mpHiddenRows->getRangeData(nRow, aData)) + // search failed. + return true; + + rLastRow = aData.mnRow2; + return aData.mbValue; +} + +bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nStartRow; + while (nRow <= nEndRow) + { + SCROW nLastRow = -1; + bool bHidden = RowHidden(nRow, nLastRow); + if (bHidden) + return true; + + nRow = nLastRow + 1; + } + return false; +} + +bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol) +{ + rLastCol = nCol; + if (!ValidCol(nCol)) + return true; + + ScFlatBoolColSegments::RangeData aData; + if (!mpHiddenCols->getRangeData(nCol, aData)) + return true; + + rLastCol = aData.mnCol2; + return aData.mbValue; +} + +bool ScTable::ColHidden(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) +{ + if (!ValidCol(nCol)) + return true; + + ScFlatBoolColSegments::RangeData aData; + if (!mpHiddenCols->getRangeData(nCol, aData)) + return true; + + if (pFirstCol) + *pFirstCol = aData.mnCol1; + if (pLastCol) + *pLastCol = aData.mnCol2; + + return aData.mbValue; +} + +void ScTable::SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden) +{ + if (bHidden) + mpHiddenRows->setTrue(nStartRow, nEndRow); + else + mpHiddenRows->setFalse(nStartRow, nEndRow); +} + +void ScTable::SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden) +{ + if (bHidden) + mpHiddenCols->setTrue(nStartCol, nEndCol); + else + mpHiddenCols->setFalse(nStartCol, nEndCol); +} + +void ScTable::CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol) +{ + SCCOL nCol = nStartCol; + while (nCol <= nEndCol) + { + SCCOL nLastCol; + bool bHidden = rTable.ColHidden(nCol, NULL, &nLastCol); + if (nLastCol > nEndCol) + nLastCol = nEndCol; + + SetColHidden(nCol, nLastCol, bHidden); + nCol = nLastCol + 1; + } +} + +void ScTable::CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nStartRow; + while (nRow <= nEndRow) + { + SCROW nLastRow = -1; + bool bHidden = rTable.RowHidden(nRow, nLastRow); + if (nLastRow > nEndRow) + nLastRow = nEndRow; + SetRowHidden(nRow, nLastRow, bHidden); + nRow = nLastRow + 1; + } +} + +void ScTable::CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset) +{ + SCROW nRow = nStartRow; + ScFlatUInt16RowSegments::RangeData aSrcData; + while (nRow <= nEndRow) + { + if (!rSrcTable.mpRowHeights->getRangeData(nRow + nSrcOffset, aSrcData)) + // Something is wrong ! + return; + + SCROW nLastRow = aSrcData.mnRow2 - nSrcOffset; + if (nLastRow > nEndRow) + nLastRow = nEndRow; + + mpRowHeights->setValue(nRow, nLastRow, aSrcData.mnValue); + nRow = nLastRow + 1; + } +} + +SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nStartRow; + ScFlatBoolRowSegments::RangeData aData; + while (nRow <= nEndRow) + { + if (!ValidRow(nRow)) + break; + + if (!mpHiddenRows->getRangeData(nRow, aData)) + // failed to get range data. + break; + + if (!aData.mbValue) + // visible row found + return nRow; + + nRow = aData.mnRow2 + 1; + } + + return ::std::numeric_limits<SCROW>::max(); +} + +SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nEndRow; + ScFlatBoolRowSegments::RangeData aData; + while (nRow >= nStartRow) + { + if (!ValidRow(nRow)) + break; + + if (!mpHiddenRows->getRangeData(nRow, aData)) + // failed to get range data. + break; + + if (!aData.mbValue) + // visible row found + return nRow; + + nRow = aData.mnRow1 - 1; + } + + return ::std::numeric_limits<SCROW>::max(); +} + +SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nCount = 0; + SCROW nRow = nStartRow; + ScFlatBoolRowSegments::RangeData aData; + while (nRow <= nEndRow) + { + if (!mpHiddenRows->getRangeData(nRow, aData)) + break; + + if (aData.mnRow2 > nEndRow) + aData.mnRow2 = nEndRow; + + if (!aData.mbValue) + nCount += aData.mnRow2 - nRow + 1; + + nRow = aData.mnRow2 + 1; + } + return nCount; +} + +sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) +{ + sal_uInt32 nHeight = 0; + SCROW nRow = nStartRow; + ScFlatBoolRowSegments::RangeData aData; + while (nRow <= nEndRow) + { + if (!mpHiddenRows->getRangeData(nRow, aData)) + break; + + if (aData.mnRow2 > nEndRow) + aData.mnRow2 = nEndRow; + + if (!aData.mbValue) + // visible row range. + nHeight += mpRowHeights->getSumValue(nRow, aData.mnRow2); + + nRow = aData.mnRow2 + 1; + } + + return nHeight; +} + +SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol) +{ + if (bCol) + { + SCCOL nCol = static_cast<SCCOL>(nPos); + if (ColHidden(nCol)) + { + for (SCCOL i = nCol+1; i <= MAXCOL; ++i) + { + if (!ColHidden(nCol)) + return nCol - 1; + } + } + } + else + { + SCROW nRow = static_cast<SCROW>(nPos); + SCROW nLastRow; + if (RowHidden(nRow, NULL, &nLastRow)) + return static_cast<SCCOLROW>(nLastRow); + } + return ::std::numeric_limits<SCCOLROW>::max(); +} + +bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) +{ + if (!ValidRow(nRow)) + return false; + + ScFlatBoolRowSegments::RangeData aData; + if (!mpFilteredRows->getRangeData(nRow, aData)) + // search failed. + return false; + + if (pFirstRow) + *pFirstRow = aData.mnRow1; + if (pLastRow) + *pLastRow = aData.mnRow2; + + return aData.mbValue; +} + +bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) +{ + if (!ValidCol(nCol)) + return false; + + ScFlatBoolColSegments::RangeData aData; + if (!mpFilteredCols->getRangeData(nCol, aData)) + // search failed. + return false; + + if (pFirstCol) + *pFirstCol = aData.mnCol1; + if (pLastCol) + *pLastCol = aData.mnCol2; + + return aData.mbValue; +} + +bool ScTable::HasFilteredRows(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nStartRow; + while (nRow <= nEndRow) + { + SCROW nLastRow = nRow; + bool bFiltered = RowFiltered(nRow, NULL, &nLastRow); + if (bFiltered) + return true; + + nRow = nLastRow + 1; + } + return false; +} + +void ScTable::CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol) +{ + SCCOL nCol = nStartCol; + while (nCol <= nEndCol) + { + SCCOL nLastCol; + bool bFiltered = rTable.ColFiltered(nCol, NULL, &nLastCol); + if (nLastCol > nEndCol) + nLastCol = nEndCol; + + SetColFiltered(nCol, nLastCol, bFiltered); + nCol = nLastCol + 1; + } +} + +void ScTable::CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nStartRow; + while (nRow <= nEndRow) + { + SCROW nLastRow = -1; + bool bFiltered = rTable.RowFiltered(nRow, NULL, &nLastRow); + if (nLastRow > nEndRow) + nLastRow = nEndRow; + SetRowFiltered(nRow, nLastRow, bFiltered); + nRow = nLastRow + 1; + } +} + +void ScTable::SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered) +{ + if (bFiltered) + mpFilteredRows->setTrue(nStartRow, nEndRow); + else + mpFilteredRows->setFalse(nStartRow, nEndRow); +} + +void ScTable::SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered) +{ + if (bFiltered) + mpFilteredCols->setTrue(nStartCol, nEndCol); + else + mpFilteredCols->setFalse(nStartCol, nEndCol); +} + +SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nStartRow; + ScFlatBoolRowSegments::RangeData aData; + while (nRow <= nEndRow) + { + if (!ValidRow(nRow)) + break; + + if (!mpFilteredRows->getRangeData(nRow, aData)) + // failed to get range data. + break; + + if (!aData.mbValue) + // non-filtered row found + return nRow; + + nRow = aData.mnRow2 + 1; + } + + return ::std::numeric_limits<SCROW>::max(); +} + +SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nRow = nEndRow; + ScFlatBoolRowSegments::RangeData aData; + while (nRow >= nStartRow) + { + if (!ValidRow(nRow)) + break; + + if (!mpFilteredRows->getRangeData(nRow, aData)) + // failed to get range data. + break; + + if (!aData.mbValue) + // non-filtered row found + return nRow; + + nRow = aData.mnRow1 - 1; + } + + return ::std::numeric_limits<SCROW>::max(); +} + +SCROW ScTable::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) +{ + SCROW nCount = 0; + SCROW nRow = nStartRow; + ScFlatBoolRowSegments::RangeData aData; + while (nRow <= nEndRow) + { + if (!mpFilteredRows->getRangeData(nRow, aData)) + break; + + if (aData.mnRow2 > nEndRow) + aData.mnRow2 = nEndRow; + + if (!aData.mbValue) + nCount += aData.mnRow2 - nRow + 1; + + nRow = aData.mnRow2 + 1; + } + return nCount; +} + +namespace { + +void lcl_syncFlags(ScFlatBoolColSegments& rColSegments, ScFlatBoolRowSegments& rRowSegments, + BYTE* pColFlags, ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags, const BYTE nFlagMask) +{ + using ::sal::static_int_cast; + + pRowFlags->AndValue(0, MAXROW, static_int_cast<BYTE>(~nFlagMask)); + for (SCCOL i = 0; i <= MAXCOL; ++i) + pColFlags[i] &= static_int_cast<BYTE>(~nFlagMask); + + { + // row hidden flags. + + SCROW nRow = 0; + ScFlatBoolRowSegments::RangeData aData; + while (nRow <= MAXROW) + { + if (!rRowSegments.getRangeData(nRow, aData)) + break; + + if (aData.mbValue) + pRowFlags->OrValue(nRow, aData.mnRow2, static_int_cast<BYTE>(nFlagMask)); + + nRow = aData.mnRow2 + 1; + } + } + + { + // column hidden flags. + + SCCOL nCol = 0; + ScFlatBoolColSegments::RangeData aData; + while (nCol <= MAXCOL) + { + if (!rColSegments.getRangeData(nCol, aData)) + break; + + if (aData.mbValue) + { + for (SCCOL i = nCol; i <= aData.mnCol2; ++i) + pColFlags[i] |= nFlagMask; + } + + nCol = aData.mnCol2 + 1; + } + } +} + +} + +void ScTable::SyncColRowFlags() +{ + using ::sal::static_int_cast; + + // Manual breaks. + pRowFlags->AndValue(0, MAXROW, static_int_cast<BYTE>(~CR_MANUALBREAK)); + for (SCCOL i = 0; i <= MAXCOL; ++i) + pColFlags[i] &= static_int_cast<BYTE>(~CR_MANUALBREAK); + + if (!maRowManualBreaks.empty()) + { + for (set<SCROW>::const_iterator itr = maRowManualBreaks.begin(), itrEnd = maRowManualBreaks.end(); + itr != itrEnd; ++itr) + pRowFlags->OrValue(*itr, static_int_cast<BYTE>(CR_MANUALBREAK)); + } + + if (!maColManualBreaks.empty()) + { + for (set<SCCOL>::const_iterator itr = maColManualBreaks.begin(), itrEnd = maColManualBreaks.end(); + itr != itrEnd; ++itr) + pColFlags[*itr] |= CR_MANUALBREAK; + } + + // Hidden flags. + lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, pColFlags, pRowFlags, CR_HIDDEN); + lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, pColFlags, pRowFlags, CR_FILTERED); } void ScTable::SetPageSize( const Size& rSize ) { if ( rSize.Width() != 0 && rSize.Height() != 0 ) { + if (aPageSizeTwips != rSize) + InvalidatePageBreaks(); + bPageSizeValid = TRUE; aPageSizeTwips = rSize; } diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx index 5b87fef3151a..2709dd54d1fb 100644 --- a/sc/source/core/data/tabprotection.cxx +++ b/sc/source/core/data/tabprotection.cxx @@ -33,6 +33,7 @@ #include "tabprotection.hxx" #include "tools/debug.hxx" #include "svl/PasswordHelper.hxx" +#include <comphelper/docpasswordhelper.hxx> #include "document.hxx" #define DEBUG_TAB_PROTECTION 0 @@ -75,40 +76,6 @@ ScPassHashProtectable::~ScPassHashProtectable() // ============================================================================ -static sal_uInt16 lcl_getXLHashFromChar(const sal_Char* szPassword) -{ - sal_uInt16 cchPassword = static_cast< sal_uInt16 >( strlen(szPassword) ); - sal_uInt16 wPasswordHash = 0; - if (!cchPassword) - return wPasswordHash; - - const char* pch = &szPassword[cchPassword]; - while (pch-- != szPassword) - { - wPasswordHash = ((wPasswordHash >> 14) & 0x01) | - ((wPasswordHash << 1) & 0x7fff); - wPasswordHash ^= *pch; - } - - wPasswordHash = ((wPasswordHash >> 14) & 0x01) | - ((wPasswordHash << 1) & 0x7fff); - - wPasswordHash ^= (0x8000 | ('N' << 8) | 'K'); - wPasswordHash ^= cchPassword; - - return wPasswordHash; -} - -static Sequence<sal_Int8> lcl_getXLHash(const String& aPassText) -{ - const sal_Char* szBuf = OUStringToOString(OUString(aPassText), RTL_TEXTENCODING_UTF8).getStr(); - sal_uInt16 nHash = lcl_getXLHashFromChar(szBuf); - Sequence<sal_Int8> aHash(2); - aHash[0] = (nHash >> 8) & 0xFF; - aHash[1] = nHash & 0xFF; - return aHash; -} - class ScTableProtectionImpl { public: @@ -146,7 +113,7 @@ Sequence<sal_Int8> ScTableProtectionImpl::hashPassword(const String& aPassText, switch (eHash) { case PASSHASH_XL: - aHash = lcl_getXLHash(aPassText); + aHash = ::comphelper::DocPasswordHelper::GetXLHashAsSequence( aPassText, RTL_TEXTENCODING_UTF8 ); break; case PASSHASH_OOO: default: diff --git a/sc/source/core/inc/bcaslot.hxx b/sc/source/core/inc/bcaslot.hxx index 1ecbefe4a9b1..13384b033628 100644 --- a/sc/source/core/inc/bcaslot.hxx +++ b/sc/source/core/inc/bcaslot.hxx @@ -214,10 +214,6 @@ private: +---+---+ */ - /* TODO: When going for 1M rows this will definitely need some change, or - * with lots of referred sheets even the reservation of NULL pointers would - * be a memory hog. */ - class TableSlots { public: @@ -227,7 +223,8 @@ private: /** Obtain slot pointer, no check on validity! It is assumed that - all calls are made with the result of ComputeSlotOfsset() + all calls are made with the results of ComputeSlotOffset(), + ComputeAreaPoints() and ComputeNextSlot() */ inline ScBroadcastAreaSlot* getAreaSlot( SCSIZE nOff ) { return *(ppSlots + nOff); } diff --git a/sc/source/core/inc/doubleref.hxx b/sc/source/core/inc/doubleref.hxx index e7bd2dfa6ae1..10221d942c9c 100644 --- a/sc/source/core/inc/doubleref.hxx +++ b/sc/source/core/inc/doubleref.hxx @@ -47,11 +47,10 @@ struct ScQueryParamBase; class ScDBRangeBase { public: - enum RefType { INTERNAL, EXTERNAL }; + enum RefType { INTERNAL, EXTERNAL }; // TODO: We may not need this after all... (kohei) virtual ~ScDBRangeBase() = 0; - RefType getType() const; bool fillQueryEntries(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef) const; virtual SCCOL getColSize() const = 0; diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index c0ae60f13841..07b79c11b373 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/sheet/XCompatibilityNames.hpp> +#include <com/sun/star/sheet/NoConvergenceException.hpp> #include "addincol.hxx" #include "addinhelpid.hxx" @@ -1582,9 +1583,13 @@ void ScUnoAddInCall::ExecuteCallWithArgs(uno::Sequence<uno::Any>& rCallArgs) if ( rWrapped.TargetException.getValueType().equals( getCppuType( (lang::IllegalArgumentException*)0 ) ) ) nErrCode = errIllegalArgument; + else if ( rWrapped.TargetException.getValueType().equals( + getCppuType( (sheet::NoConvergenceException*)0 ) ) ) + nErrCode = errNoConvergence; else nErrCode = errNoValue; } + catch(uno::Exception&) { nErrCode = errNoValue; diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index 9e4e77b7c1d4..573763141b18 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -44,6 +44,9 @@ #include "cell.hxx" #include "docoptio.hxx" +#include <vector> + +using ::std::vector; // ----------------------------------------------------------------------- @@ -163,11 +166,17 @@ ScMemChart* ScChartArray::CreateMemChartSingle() SCCOL nStrCol = nCol1; // fuer Beschriftung merken SCROW nStrRow = nRow1; - // Beschriftungen auch nach HiddenCols finden - while ( (pDocument->GetColFlags( nCol1, nTab1) & CR_HIDDEN) != 0 ) - nCol1++; - nRow1 = pDocument->GetRowFlagsArray( nTab1).GetFirstForCondition( nRow1, - nRow2, CR_HIDDEN, 0); + // Skip hidden columns. + // TODO: make use of last column value once implemented. + SCCOL nLastCol = -1; + while (pDocument->ColHidden(nCol1, nTab1, nLastCol)) + ++nCol1; + + // Skip hidden rows. + SCROW nLastRow = -1; + if (pDocument->RowHidden(nRow1, nTab1, nLastRow)) + nRow1 = nLastRow + 1; + // falls alles hidden ist, bleibt die Beschriftung am Anfang if ( nCol1 <= nCol2 ) { @@ -181,17 +190,33 @@ ScMemChart* ScChartArray::CreateMemChartSingle() } SCSIZE nTotalCols = ( nCol1 <= nCol2 ? nCol2 - nCol1 + 1 : 0 ); - SCCOL* pCols = new SCCOL[nTotalCols > 0 ? nTotalCols : 1]; - SCSIZE nColCount = 0; + vector<SCCOL> aCols; + aCols.reserve(nTotalCols); for (SCSIZE i=0; i<nTotalCols; i++) - if ((pDocument->GetColFlags(sal::static_int_cast<SCCOL>(nCol1+i),nTab1)&CR_HIDDEN)==0) - pCols[nColCount++] = sal::static_int_cast<SCCOL>(nCol1+i); + { + SCCOL nThisCol = sal::static_int_cast<SCCOL>(nCol1+i); + if (!pDocument->ColHidden(nThisCol, nTab1, nLastCol)) + aCols.push_back(nThisCol); + } + SCSIZE nColCount = aCols.size(); SCSIZE nTotalRows = ( nRow1 <= nRow2 ? nRow2 - nRow1 + 1 : 0 ); - SCROW* pRows = new SCROW[nTotalRows > 0 ? nTotalRows : 1]; - SCSIZE nRowCount = (nTotalRows ? - pDocument->GetRowFlagsArray( nTab1).FillArrayForCondition( nRow1, - nRow2, CR_HIDDEN, 0, pRows, nTotalRows) : 0); + vector<SCROW> aRows; + aRows.reserve(nTotalRows); + if (nRow1 <= nRow2) + { + // Get all visible rows between nRow1 and nRow2. + SCROW nThisRow = nRow1; + while (nThisRow <= nRow2) + { + if (pDocument->RowHidden(nThisRow, nTab1, nLastRow)) + nThisRow = nLastRow; + else + aRows.push_back(nThisRow); + ++nThisRow; + } + } + SCSIZE nRowCount = aRows.size(); // May happen at least with more than 32k rows. if (nColCount > SHRT_MAX || nRowCount > SHRT_MAX) @@ -205,13 +230,13 @@ ScMemChart* ScChartArray::CreateMemChartSingle() { bValidData = FALSE; nColCount = 1; - pCols[0] = nStrCol; + aCols.push_back(nStrCol); } if ( !nRowCount ) { bValidData = FALSE; nRowCount = 1; - pRows[0] = nStrRow; + aRows.push_back(nStrRow); } // @@ -234,7 +259,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle() { double nVal = DBL_MIN; // Hack fuer Chart, um leere Zellen zu erkennen - pDocument->GetCell( pCols[nCol], pRows[nRow], nTab1, pCell ); + pDocument->GetCell( aCols[nCol], aRows[nRow], nTab1, pCell ); if (pCell) { CellType eType = pCell->GetCellType(); @@ -244,8 +269,8 @@ ScMemChart* ScChartArray::CreateMemChartSingle() if ( bCalcAsShown && nVal != 0.0 ) { sal_uInt32 nFormat; - pDocument->GetNumberFormat( pCols[nCol], - pRows[nRow], nTab1, nFormat ); + pDocument->GetNumberFormat( aCols[nCol], + aRows[nRow], nTab1, nFormat ); nVal = pDocument->RoundValueAsShown( nVal, nFormat ); } } @@ -277,13 +302,13 @@ ScMemChart* ScChartArray::CreateMemChartSingle() { String aString, aColStr; if (HasColHeaders()) - pDocument->GetString( pCols[nCol], nStrRow, nTab1, aString ); + pDocument->GetString( aCols[nCol], nStrRow, nTab1, aString ); if ( !aString.Len() ) { aString = ScGlobal::GetRscString(STR_COLUMN); aString += ' '; // aString += String::CreateFromInt32( pCols[nCol]+1 ); - ScAddress aPos( pCols[ nCol ], 0, 0 ); + ScAddress aPos( aCols[ nCol ], 0, 0 ); aPos.Format( aColStr, SCA_VALID_COL, NULL ); aString += aColStr; } @@ -303,14 +328,14 @@ ScMemChart* ScChartArray::CreateMemChartSingle() String aString; if (HasRowHeaders()) { - ScAddress aAddr( nStrCol, pRows[nRow], nTab1 ); - pDocument->GetString( nStrCol, pRows[nRow], nTab1, aString ); + ScAddress aAddr( nStrCol, aRows[nRow], nTab1 ); + pDocument->GetString( nStrCol, aRows[nRow], nTab1, aString ); } if ( !aString.Len() ) { aString = ScGlobal::GetRscString(STR_ROW); aString += ' '; - aString += String::CreateFromInt32( pRows[nRow]+1 ); + aString += String::CreateFromInt32( aRows[nRow]+1 ); } pMemChart->SetRowText( static_cast<short>(nRow), aString); @@ -346,11 +371,6 @@ ScMemChart* ScChartArray::CreateMemChartSingle() // SetExtraStrings( *pMemChart ); } - // Aufraeumen - - delete[] pRows; - delete[] pCols; - return pMemChart; } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 5f4b86b7cd18..c28d295275ae 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -121,6 +121,24 @@ enum ScanState ssStop }; +// ODFF names that are not written in the current mapping but to be recognized. +// New names will be written in a future relase, then exchange (!) with the +// names in formula/source/core/resource/core_resource.src to be able to still +// read the old names as well. +struct FunctionName +{ + const sal_Char* pName; + OpCode eOp; +}; +static const FunctionName aOdffAliases[] = { + // Renamed old names: + // XXX none yet. + // Renamed new names: + { "BINOM.DIST.RANGE", ocB }, // B -> BINOM.DIST.RANGE + { "LEGACY.TDIST", ocTDist } // TDIST -> LEGACY.TDIST +}; +static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); + static const sal_Char* pInternal[ 1 ] = { "TTT" }; using namespace ::com::sun::star::i18n; @@ -2504,7 +2522,21 @@ BOOL ScCompiler::IsOpCode( const String& rName, bool bInArray ) aToken.SetOpCode(eOp); pRawToken = aToken.Clone(); } - else + else if (mxSymbols->isODFF()) + { + for (size_t i=0; i<nOdffAliases; ++i) + { + if (rName.EqualsIgnoreCaseAscii( aOdffAliases[i].pName)) + { + ScRawToken aToken; + aToken.SetOpCode( aOdffAliases[i].eOp); + pRawToken = aToken.Clone(); + bFound = TRUE; + break; // for + } + } + } + if (!bFound) { String aIntName; if (mxSymbols->hasExternals()) @@ -2887,6 +2919,7 @@ BOOL ScCompiler::IsReference( const String& rName ) BOOL ScCompiler::IsMacro( const String& rName ) { + String aName( rName); StarBASIC* pObj = 0; SfxObjectShell* pDocSh = pDoc->GetDocumentShell(); @@ -2898,7 +2931,14 @@ BOOL ScCompiler::IsMacro( const String& rName ) else pObj = pSfxApp->GetBasic(); - SbxMethod* pMeth = (SbxMethod*) pObj->Find( rName, SbxCLASS_METHOD ); + // ODFF recommends to store user-defined functions prefixed with "USER.", + // use only unprefixed name if encountered. BASIC doesn't allow '.' in a + // function name so a function "USER.FOO" could not exist, and macro check + // is assigned the lowest priority in function name check. + if (FormulaGrammar::isODFF( GetGrammar()) && aName.EqualsIgnoreCaseAscii( "USER.", 0, 5)) + aName.Erase( 0, 5); + + SbxMethod* pMeth = (SbxMethod*) pObj->Find( aName, SbxCLASS_METHOD ); if( !pMeth ) { pSfxApp->LeaveBasicCall(); @@ -2913,7 +2953,7 @@ BOOL ScCompiler::IsMacro( const String& rName ) return FALSE; } ScRawToken aToken; - aToken.SetExternal( rName.GetBuffer() ); + aToken.SetExternal( aName.GetBuffer() ); aToken.eOp = ocMacro; pRawToken = aToken.Clone(); pSfxApp->LeaveBasicCall(); diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 1f257512ae50..e86bb22646c8 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -359,7 +359,7 @@ Point ScDetectiveFunc::GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) c for ( SCCOL i = 0; i < nCol; ++i ) aPos.X() += pDoc->GetColWidth( i, nTab ); - aPos.Y() += pDoc->FastGetRowHeight( 0, nRow - 1, nTab ); + aPos.Y() += pDoc->GetRowHeight( 0, nRow - 1, nTab ); aPos.X() = static_cast< long >( aPos.X() * HMM_PER_TWIPS ); aPos.Y() = static_cast< long >( aPos.Y() * HMM_PER_TWIPS ); diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx index 5c2d3f575654..740413ea8533 100644 --- a/sc/source/core/tool/doubleref.cxx +++ b/sc/source/core/tool/doubleref.cxx @@ -268,11 +268,6 @@ ScDBRangeBase::~ScDBRangeBase() { } -ScDBRangeBase::RefType ScDBRangeBase::getType() const -{ - return meType; -} - bool ScDBRangeBase::fillQueryEntries(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef) const { if (!pDBRef) diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 2bf6a5680613..5c326001ff02 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -537,9 +537,14 @@ BOOL ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, BYTE* pCellArr) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::CreateDoubleArr" ); -#if SC_ROWLIMIT_MORE_THAN_64K -#error row limit 64k + + // Old Add-Ins are hard limited to USHORT values. +#if MAXCOLCOUNT_DEFINE > USHRT_MAX +#error Add check for columns > USHRT_MAX! #endif + if (nRow1 > USHRT_MAX || nRow2 > USHRT_MAX) + return FALSE; + USHORT nCount = 0; USHORT* p = (USHORT*) pCellArr; *p++ = static_cast<USHORT>(nCol1); @@ -618,9 +623,14 @@ BOOL ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, BYTE* pCellArr) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::CreateStringArr" ); -#if SC_ROWLIMIT_MORE_THAN_64K -#error row limit 64k + + // Old Add-Ins are hard limited to USHORT values. +#if MAXCOLCOUNT_DEFINE > USHRT_MAX +#error Add check for columns > USHRT_MAX! #endif + if (nRow1 > USHRT_MAX || nRow2 > USHRT_MAX) + return FALSE; + USHORT nCount = 0; USHORT* p = (USHORT*) pCellArr; *p++ = static_cast<USHORT>(nCol1); @@ -713,9 +723,14 @@ BOOL ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, BYTE* pCellArr) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::CreateCellArr" ); -#if SC_ROWLIMIT_MORE_THAN_64K -#error row limit 64k + + // Old Add-Ins are hard limited to USHORT values. +#if MAXCOLCOUNT_DEFINE > USHRT_MAX +#error Add check for columns > USHRT_MAX! #endif + if (nRow1 > USHRT_MAX || nRow2 > USHRT_MAX) + return FALSE; + USHORT nCount = 0; USHORT* p = (USHORT*) pCellArr; *p++ = static_cast<USHORT>(nCol1); @@ -2125,7 +2140,7 @@ void ScInterpreter::ScExternal() if (ScGlobal::GetFuncCollection()->SearchFunc(aFuncName, nIndex)) { FuncData* pFuncData = (FuncData*)ScGlobal::GetFuncCollection()->At(nIndex); - if (nParamCount == pFuncData->GetParamCount() - 1) + if (nParamCount <= MAXFUNCPARAM && nParamCount == pFuncData->GetParamCount() - 1) { ParamType eParamType[MAXFUNCPARAM]; void* ppParam[MAXFUNCPARAM]; diff --git a/sc/source/filter/excel/colrowst.cxx b/sc/source/filter/excel/colrowst.cxx index 3a48aa6b96ba..01587c036dea 100644 --- a/sc/source/filter/excel/colrowst.cxx +++ b/sc/source/filter/excel/colrowst.cxx @@ -207,7 +207,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab ) // row heights ------------------------------------------------------------ // #i54252# set default row height - rDoc.SetRowHeightRange( 0, MAXROW, nScTab, mnDefHeight ); + rDoc.SetRowHeightOnly( 0, MAXROW, nScTab, mnDefHeight ); if( ::get_flag( mnDefRowFlags, EXC_DEFROW_UNSYNCED ) ) // first access to row flags, do not ask for old flags rDoc.SetRowFlags( 0, MAXROW, nScTab, CR_MANUALSIZE ); @@ -258,7 +258,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab ) { DBG_ASSERT( (nScRow == 0) || (nFirstScRow >= 0), "XclImpColRowSettings::Convert - algorithm error" ); if( nScRow > 0 ) - rDoc.SetRowHeightRange( nFirstScRow, nScRow - 1, nScTab, nLastHeight ); + rDoc.SetRowHeightOnly( nFirstScRow, nScRow - 1, nScTab, nLastHeight ); nFirstScRow = nScRow; nLastHeight = nHeight; @@ -267,7 +267,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab ) // set row height of last portion if( mnLastScRow >= 0 ) - rDoc.SetRowHeightRange( nFirstScRow, mnLastScRow, nScTab, nLastHeight ); + rDoc.SetRowHeightOnly( nFirstScRow, mnLastScRow, nScTab, nLastHeight ); // ------------------------------------------------------------------------ @@ -307,7 +307,7 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab ) rDoc.ShowRow( nScRow, nScTab, FALSE ); // #i38093# rows hidden by filter need extra flag if( (nFirstFilterScRow <= nScRow) && (nScRow <= nLastFilterScRow) ) - rDoc.SetRowFlags( nScRow, nScTab, rDoc.GetRowFlags( nScRow, nScTab ) | CR_FILTERED ); + rDoc.SetRowFiltered(nScRow, nScRow, nScTab, true); } } diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 3523c272291d..458629979172 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -200,17 +200,12 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList ) UINT16 nExcTabCount = rTabInfo.GetXclTabCount(); UINT16 nCodenames = static_cast< UINT16 >( GetExtDocOptions().GetCodeNameCount() ); - sal_uInt16 nWriteProtHash = 0; - if( SfxObjectShell* pDocShell = GetDocShell() ) - { - ScfPropertySet aPropSet( pDocShell->GetModel() ); - sal_Int32 nApiHash = 0; - if( aPropSet.GetProperty( nApiHash, CREATE_OUSTRING( "WriteProtectionPassword" ) ) && (0 < nApiHash) && (nApiHash <= SAL_MAX_UINT16) ) - { - nWriteProtHash = static_cast< sal_uInt16 >( nApiHash ); - Add( new XclExpEmptyRecord( EXC_ID_WRITEPROT ) ); - } - } + SfxObjectShell* pShell = GetDocShell(); + sal_uInt16 nWriteProtHash = pShell ? pShell->GetModifyPasswordHash() : 0; + bool bRecommendReadOnly = pShell && pShell->IsLoadReadonly(); + + if( (nWriteProtHash > 0) || bRecommendReadOnly ) + Add( new XclExpEmptyRecord( EXC_ID_WRITEPROT ) ); // TODO: correct codepage for BIFF5? sal_uInt16 nCodePage = XclTools::GetXclCodePage( (GetBiff() <= EXC_BIFF5) ? RTL_TEXTENCODING_MS_1252 : RTL_TEXTENCODING_UNICODE ); @@ -234,7 +229,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList ) Add( new XclExpWriteAccess ); } - Add( new XclExpFileSharing( GetRoot(), nWriteProtHash ) ); + Add( new XclExpFileSharing( GetRoot(), nWriteProtHash, bRecommendReadOnly ) ); Add( new XclExpUInt16Record( EXC_ID_CODEPAGE, nCodePage ) ); if( GetBiff() == EXC_BIFF8 ) diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index e62f050f2351..209d24ac043d 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -122,7 +122,8 @@ ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ): ImportTyp( &rImpData.mrDoc, rImpData.meTextEnc ), XclImpRoot( rImpData ), maStrm( rStrm, GetRoot() ), - aIn( maStrm ) + aIn( maStrm ), + maScOleSize( ScAddress::INITIALIZE_INVALID ) { mnLastRefIdx = 0; nBdshtTab = 0; @@ -178,15 +179,16 @@ void ImportExcel::ReadFileSharing() maStrm >> nRecommendReadOnly >> nPasswordHash; if( (nRecommendReadOnly != 0) || (nPasswordHash != 0) ) + { if( SfxItemSet* pItemSet = GetMedium().GetItemSet() ) pItemSet->Put( SfxBoolItem( SID_DOC_READONLY, TRUE ) ); - if( nPasswordHash != 0 ) - { - if( SfxObjectShell* pDocShell = GetDocShell() ) + if( SfxObjectShell* pShell = GetDocShell() ) { - ScfPropertySet aPropSet( pDocShell->GetModel() ); - aPropSet.SetProperty( CREATE_OUSTRING( "WriteProtectionPassword" ), static_cast< sal_Int32 >( nPasswordHash ) ); + if( nRecommendReadOnly != 0 ) + pShell->SetLoadReadonly( sal_True ); + if( nPasswordHash != 0 ) + pShell->SetModifyPasswordHash( nPasswordHash ); } } } @@ -919,8 +921,7 @@ void ImportExcel::Olesize( void ) aXclOleSize.Read( maStrm, false ); SCTAB nScTab = GetCurrScTab(); - ScRange& rOleSize = GetExtDocOptions().GetDocSettings().maOleSize; - GetAddressConverter().ConvertRange( rOleSize, aXclOleSize, nScTab, nScTab, false ); + GetAddressConverter().ConvertRange( maScOleSize, aXclOleSize, nScTab, nScTab, false ); } @@ -1204,45 +1205,40 @@ void ImportExcel::PostDocLoad( void ) // process all drawing objects (including OLE, charts, controls; after hiding rows/columns; before visible OLE area) GetObjectManager().ConvertObjects(); - // visible area if embedded OLE - if( ScModelObj* pDocObj = GetDocModelObj() ) + // visible area (used if this document is an embedded OLE object) + if( SfxObjectShell* pDocShell = GetDocShell() ) { - if( SfxObjectShell* pEmbObj = pDocObj->GetEmbeddedObject() ) + // visible area if embedded + const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings(); + SCTAB nDisplScTab = rDocSett.mnDisplTab; + + /* #i44077# If a new OLE object is inserted from file, there is no + OLESIZE record in the Excel file. Calculate used area from file + contents (used cells and drawing objects). */ + if( !maScOleSize.IsValid() ) { - // visible area if embedded - const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings(); - SCTAB nDisplScTab = rDocSett.mnDisplTab; - - // first try if there was an OLESIZE record - ScRange aScOleSize = rDocSett.maOleSize; - - /* #i44077# If a new OLE object is inserted from file, there - is no OLESIZE record in the Excel file. Calculate used area - from file contents (used cells and drawing objects). */ - if( !aScOleSize.IsValid() ) - { - // used area of displayed sheet (cell contents) - if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) ) - aScOleSize = pTabSett->maUsedArea; - // add all valid drawing objects - ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab ); - if( aScObjArea.IsValid() ) - aScOleSize.ExtendTo( aScObjArea ); - } + // used area of displayed sheet (cell contents) + if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) ) + maScOleSize = pTabSett->maUsedArea; + // add all valid drawing objects + ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab ); + if( aScObjArea.IsValid() ) + maScOleSize.ExtendTo( aScObjArea ); + } - // valid size found - set it at the document - if( aScOleSize.IsValid() ) - { - pEmbObj->SetVisArea( GetDoc().GetMMRect( - aScOleSize.aStart.Col(), aScOleSize.aStart.Row(), - aScOleSize.aEnd.Col(), aScOleSize.aEnd.Row(), nDisplScTab ) ); - GetDoc().SetVisibleTab( nDisplScTab ); - } + // valid size found - set it at the document + if( maScOleSize.IsValid() ) + { + pDocShell->SetVisArea( GetDoc().GetMMRect( + maScOleSize.aStart.Col(), maScOleSize.aStart.Row(), + maScOleSize.aEnd.Col(), maScOleSize.aEnd.Row(), nDisplScTab ) ); + GetDoc().SetVisibleTab( nDisplScTab ); } + } - // #111099# open forms in alive mode (has no effect, if no controls in document) + // #111099# open forms in alive mode (has no effect, if no controls in document) + if( ScModelObj* pDocObj = GetDocModelObj() ) pDocObj->setPropertyValue( CREATE_OUSTRING( SC_UNO_APPLYFMDES ), uno::Any( false ) ); - } // enables extended options to be set to the view after import GetExtDocOptions().SetChanged( true ); diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index dda09227a104..cfe5aedb867e 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -1193,6 +1193,7 @@ FltError ImportExcel8::Read( void ) case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break; case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break; case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break; + case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break; case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break; } } diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index a4b5864668b4..0509f2afa5fa 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -146,7 +146,7 @@ void XclExpDffSheetAnchor::ImplSetFlags( const SdrObject& rSdrObj ) void XclExpDffSheetAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit ) { - maAnchor.SetRect( GetDoc(), mnScTab, rRect, eMapUnit ); + maAnchor.SetRect( GetRoot(), mnScTab, rRect, eMapUnit ); } // ---------------------------------------------------------------------------- @@ -175,7 +175,7 @@ void XclExpDffEmbeddedAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUni XclExpDffNoteAnchor::XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect ) : XclExpDffAnchorBase( rRoot, EXC_ESC_ANCHOR_SIZELOCKED ) { - maAnchor.SetRect( GetDoc(), rRoot.GetCurrScTab(), rRect, MAP_100TH_MM ); + maAnchor.SetRect( rRoot, rRoot.GetCurrScTab(), rRect, MAP_100TH_MM ); } // ---------------------------------------------------------------------------- diff --git a/sc/source/filter/excel/xepage.cxx b/sc/source/filter/excel/xepage.cxx index 753d43e8d584..6194a04c27f6 100644 --- a/sc/source/filter/excel/xepage.cxx +++ b/sc/source/filter/excel/xepage.cxx @@ -45,9 +45,14 @@ #include "xehelper.hxx" #include "xeescher.hxx" +#include <set> +#include <limits> + #include <oox/core/tokens.hxx> using ::rtl::OString; +using ::std::set; +using ::std::numeric_limits; // Page settings records ====================================================== @@ -299,17 +304,23 @@ XclExpPageSettings::XclExpPageSettings( const XclExpRoot& rRoot ) : // *** page breaks *** - ScCompressedArrayIterator< SCROW, BYTE> aIter( rDoc.GetRowFlagsArray( nScTab), 1, GetMaxPos().Row()); - do + set<SCROW> aRowBreaks; + rDoc.GetAllRowBreaks(aRowBreaks, nScTab, false, true); + + SCROW nMaxRow = numeric_limits<sal_uInt16>::max(); + for (set<SCROW>::const_iterator itr = aRowBreaks.begin(), itrEnd = aRowBreaks.end(); itr != itrEnd; ++itr) { - if (*aIter & CR_MANUALBREAK) - for (SCROW j=aIter.GetRangeStart(); j<=aIter.GetRangeEnd(); ++j) - maData.maHorPageBreaks.push_back( static_cast< sal_uInt16 >( j ) ); - } while (aIter.NextRange()); - - for( SCCOL nScCol = 1, nScMaxCol = GetMaxPos().Col(); nScCol <= nScMaxCol; ++nScCol ) - if( rDoc.GetColFlags( nScCol, nScTab ) & CR_MANUALBREAK ) - maData.maVerPageBreaks.push_back( static_cast< sal_uInt16 >( nScCol ) ); + SCROW nRow = *itr; + if (nRow > nMaxRow) + break; + + maData.maHorPageBreaks.push_back(nRow); + } + + set<SCCOL> aColBreaks; + rDoc.GetAllColBreaks(aColBreaks, nScTab, false, true); + for (set<SCCOL>::const_iterator itr = aColBreaks.begin(), itrEnd = aColBreaks.end(); itr != itrEnd; ++itr) + maData.maVerPageBreaks.push_back(*itr); } static void lcl_WriteHeaderFooter( XclExpXmlStream& rStrm ) diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx index 834873740d68..50e07ae1f2ed 100644 --- a/sc/source/filter/excel/xeroot.cxx +++ b/sc/source/filter/excel/xeroot.cxx @@ -33,6 +33,7 @@ #include <unotools/saveopt.hxx> #include <svl/itemset.hxx> #include <svl/stritem.hxx> +#include <svl/intitem.hxx> #include <svl/eitem.hxx> #include "xecontent.hxx" #include "xltracer.hxx" @@ -247,24 +248,16 @@ bool XclExpRoot::IsDocumentEncrypted() const return false; } -const String XclExpRoot::GetPassword() const +String XclExpRoot::GetPassword() const { - SfxItemSet* pSet = GetMedium().GetItemSet(); - if (!pSet) - return String(); - - const SfxPoolItem* pItem = NULL; - if (SFX_ITEM_SET == pSet->GetItemState(SID_PASSWORD, sal_True, &pItem)) + if( SfxItemSet* pItemSet = GetMedium().GetItemSet() ) { - const SfxStringItem* pStrItem = dynamic_cast<const SfxStringItem*>(pItem); - if (pStrItem) - { - // Password from the save dialog. - return pStrItem->GetValue(); - } + const SfxPoolItem* pItem = 0; + if( pItemSet->GetItemState( SID_PASSWORD, TRUE, &pItem ) == SFX_ITEM_SET ) + if( const SfxStringItem* pStrItem = dynamic_cast< const SfxStringItem* >( pItem ) ) + return pStrItem->GetValue(); } - - return String(); + return String::EmptyString(); } XclExpRootData::XclExpLinkMgrRef XclExpRoot::GetLocalLinkMgrRef() const diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 315282098cec..ccebe9a4280f 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -74,6 +74,7 @@ sal_uInt32 lclGetWeighting( XclExpColorType eType ) case EXC_COLOR_CELLTEXT: case EXC_COLOR_CHARTTEXT: case EXC_COLOR_CTRLTEXT: return 10; + case EXC_COLOR_TABBG: case EXC_COLOR_CELLAREA: return 20; case EXC_COLOR_GRID: return 50; default: DBG_ERRORFILE( "lclGetWeighting - unknown color type" ); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index e9aaa70bceba..b5ca318a91b4 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1601,8 +1601,7 @@ XclExpColinfo::XclExpColinfo( const XclExpRoot& rRoot, mnWidth = XclTools::GetXclColumnWidth( nScWidth, GetCharWidth() ); // column flags - BYTE nScColFlags = rDoc.GetColFlags( nScCol, nScTab ); - ::set_flag( mnFlags, EXC_COLINFO_HIDDEN, (nScColFlags & CR_HIDDEN) != 0 ); + ::set_flag( mnFlags, EXC_COLINFO_HIDDEN, rDoc.ColHidden(nScCol, nScTab) ); // outline data rOutlineBfr.Update( nScCol ); @@ -1827,23 +1826,17 @@ XclExpRow::XclExpRow( const XclExpRoot& rRoot, sal_uInt16 nXclRow, BYTE nRowFlags = GetDoc().GetRowFlags( nScRow, nScTab ); bool bUserHeight = ::get_flag< BYTE >( nRowFlags, CR_MANUALSIZE ); - bool bHidden = ::get_flag< BYTE >( nRowFlags, CR_HIDDEN ); + bool bHidden = GetDoc().RowHidden(nScRow, nScTab); ::set_flag( mnFlags, EXC_ROW_UNSYNCED, bUserHeight ); ::set_flag( mnFlags, EXC_ROW_HIDDEN, bHidden ); // *** Row height *** ----------------------------------------------------- - USHORT nScHeight = GetDoc().GetRowHeight( nScRow, nScTab ); - if( nScHeight == 0 ) - { - ::set_flag( mnFlags, EXC_ROW_HIDDEN ); - mnHeight = EXC_ROW_DEFAULTHEIGHT; - } + if (bUserHeight) + mnHeight = GetDoc().GetRowHeight(nScRow, nScTab, false); else - { - // Calc and Excel use twips - mnHeight = static_cast< sal_uInt16 >( nScHeight ); - } + mnHeight = EXC_ROW_DEFAULTHEIGHT; + // #76250# not usable in Applix // ::set_flag( mnHeight, EXC_ROW_FLAGDEFHEIGHT, !bUserHeight ); diff --git a/sc/source/filter/excel/xeview.cxx b/sc/source/filter/excel/xeview.cxx index c342b5a40ea1..035afd0a5830 100644 --- a/sc/source/filter/excel/xeview.cxx +++ b/sc/source/filter/excel/xeview.cxx @@ -256,6 +256,35 @@ void XclExpSelection::WriteBody( XclExpStream& rStrm ) maSelData.maXclSelection.Write( rStrm, false ); } +// ---------------------------------------------------------------------------- + +XclExpTabBgColor::XclExpTabBgColor( const XclTabViewData& rTabViewData ) : + XclExpRecord( EXC_ID_SHEETEXT, 18 ), + mrTabViewData( rTabViewData ) +{ +} +//TODO Fix savexml... +/*void XclExpTabBgColor::SaveXml( XclExpXmlStream& rStrm ) +{ +}*/ + +void XclExpTabBgColor::WriteBody( XclExpStream& rStrm ) +{ + if ( mrTabViewData.IsDefaultTabBgColor() ) + return; + sal_uInt16 rt = 0x0862; //rt + sal_uInt16 grbitFrt = 0x0000; //grbit must be set to 0 + sal_uInt32 unused = 0x00000000; //Use twice... + sal_uInt32 cb = 0x00000014; // Record Size, may be larger in future... + sal_uInt16 reserved = 0x0000; //trailing bits are 0 + sal_uInt16 TabBgColorIndex; + XclExpPalette& rPal = rStrm.GetRoot().GetPalette(); + TabBgColorIndex = rPal.GetColorIndex(mrTabViewData.mnTabBgColorId); + if (TabBgColorIndex < 8 || TabBgColorIndex > 63 ) // only numbers 8 - 63 are valid numbers + TabBgColorIndex = 127; //Excel specs: 127 makes excel ignore tab color information. + rStrm << rt << grbitFrt << unused << unused << cb << TabBgColorIndex << reserved; +} + // Sheet view settings ======================================================== namespace { @@ -366,6 +395,14 @@ XclExpTabViewSettings::XclExpTabViewSettings( const XclExpRoot& rRoot, SCTAB nSc maData.mnPageZoom = lclGetXclZoom( rTabSett.mnPageZoom, EXC_WIN2_PAGEZOOM_DEF ); maData.mnCurrentZoom = maData.mbPageMode ? maData.mnPageZoom : maData.mnNormalZoom; } + + // Tab Bg Color + if ( GetBiff() == EXC_BIFF8 && !GetDoc().IsDefaultTabBgColor(nScTab) ) + { + XclExpPalette& rPal = GetPalette(); + maData.maTabBgColor = GetDoc().GetTabBgColor(nScTab); + maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG ); + } } void XclExpTabViewSettings::Save( XclExpStream& rStrm ) @@ -377,6 +414,7 @@ void XclExpTabViewSettings::Save( XclExpStream& rStrm ) WriteSelection( rStrm, EXC_PANE_TOPRIGHT ); WriteSelection( rStrm, EXC_PANE_BOTTOMLEFT ); WriteSelection( rStrm, EXC_PANE_BOTTOMRIGHT ); + WriteTabBgColor( rStrm ); } static void lcl_WriteSelection( XclExpXmlStream& rStrm, const XclTabViewData& rData, sal_uInt8 nPane ) @@ -491,5 +529,10 @@ void XclExpTabViewSettings::WriteSelection( XclExpStream& rStrm, sal_uInt8 nPane XclExpSelection( maData, nPane ).Save( rStrm ); } +void XclExpTabViewSettings::WriteTabBgColor( XclExpStream& rStrm ) const +{ + if ( !maData.IsDefaultTabBgColor() ) + XclExpTabBgColor( maData ).Save( rStrm ); +} // ============================================================================ diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index 5c10a0716028..7cbd74a836d2 100755..100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -4054,6 +4054,14 @@ void XclImpChart::ReadChartSubStream( XclImpStream& rStrm ) case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( rStrm, true );break; case EXC_ID_SCL: rTabViewSett.ReadScl( rStrm ); break; + case EXC_ID_SHEETEXT: //0x0862 + { + // FIXME: do not need to pass palette, XclImpTabVieSettings is derived from root + XclImpPalette& rPal = GetPalette(); + rTabViewSett.ReadTabBgColor( rStrm, rPal); + } + break; + case EXC_ID_CODENAME: ReadCodeName( rStrm, false ); break; } diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 02c5203d356a..dc87bba4c050 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -1696,7 +1696,7 @@ void XclImpChartObj::FinalizeTabChart() // create the object anchor XclObjAnchor aAnchor; - aAnchor.SetRect( GetDoc(), GetCurrScTab(), Rectangle( 1000, 500, nWidth, nHeight ), MAP_100TH_MM ); + aAnchor.SetRect( GetRoot(), GetCurrScTab(), Rectangle( 1000, 500, nWidth, nHeight ), MAP_100TH_MM ); SetAnchor( aAnchor ); } @@ -3926,7 +3926,7 @@ void XclImpSheetDrawing::ConvertObjects( XclImpDffConverter& rDffConv ) Rectangle XclImpSheetDrawing::CalcAnchorRect( const XclObjAnchor& rAnchor, bool /*bDffAnchor*/ ) const { - return rAnchor.GetRect( GetDoc(), maScUsedArea.aStart.Tab(), MAP_100TH_MM ); + return rAnchor.GetRect( GetRoot(), maScUsedArea.aStart.Tab(), MAP_100TH_MM ); } void XclImpSheetDrawing::OnObjectInserted( const XclImpDrawObjBase& rDrawObj ) diff --git a/sc/source/filter/excel/xipage.cxx b/sc/source/filter/excel/xipage.cxx index c689d0eb7feb..38cebc2e6ca8 100644 --- a/sc/source/filter/excel/xipage.cxx +++ b/sc/source/filter/excel/xipage.cxx @@ -375,14 +375,14 @@ void XclImpPageSettings::Finalize() { SCROW nScRow = static_cast< SCROW >( *aIt ); if( nScRow <= MAXROW ) - rDoc.SetRowFlags( nScRow, nScTab, rDoc.GetRowFlags( nScRow, nScTab ) | CR_MANUALBREAK ); + rDoc.SetRowBreak(nScRow, nScTab, false, true); } for( aIt = maData.maVerPageBreaks.begin(), aEnd = maData.maVerPageBreaks.end(); aIt != aEnd; ++aIt ) { SCCOL nScCol = static_cast< SCCOL >( *aIt ); if( nScCol <= MAXCOL ) - rDoc.SetColFlags( nScCol, nScTab, rDoc.GetColFlags( nScCol, nScTab ) | CR_MANUALBREAK ); + rDoc.SetColBreak(nScCol, nScTab, false, true); } } diff --git a/sc/source/filter/excel/xiview.cxx b/sc/source/filter/excel/xiview.cxx index 6eeee8e04839..f75032ff461e 100644 --- a/sc/source/filter/excel/xiview.cxx +++ b/sc/source/filter/excel/xiview.cxx @@ -106,6 +106,24 @@ void XclImpTabViewSettings::Initialize() maData.SetDefaults(); } +void XclImpTabViewSettings::ReadTabBgColor( XclImpStream& rStrm, XclImpPalette& rPal ) +{ + DBG_ASSERT_BIFF( GetBiff() >= EXC_BIFF8 ); + if( GetBiff() < EXC_BIFF8 ) + return; + + sal_uInt8 ColorIndex; + Color TabBgColor; + + rStrm.Ignore( 16 ); + ColorIndex = rStrm.ReaduInt8() & EXC_SHEETEXT_TABCOLOR; //0x7F + if ( ColorIndex >= 8 && ColorIndex <= 63 ) //only accept valid index values + { + TabBgColor = rPal.GetColor( ColorIndex ); + maData.maTabBgColor = TabBgColor; + } +} + void XclImpTabViewSettings::ReadWindow2( XclImpStream& rStrm, bool bChart ) { if( GetBiff() == EXC_BIFF2 ) @@ -276,6 +294,10 @@ void XclImpTabViewSettings::Finalize() aViewOpt.SetOption( VOPT_OUTLINER, maData.mbShowOutline ); rDoc.SetViewOptions( aViewOpt ); } + + // *** set tab bg color + if ( !maData.IsDefaultTabBgColor() ) + rDoc.SetTabBgColor(nScTab, maData.maTabBgColor); } // ============================================================================ diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx index 3b4b8e29ac0b..153a5d5ed3cc 100644 --- a/sc/source/filter/excel/xlescher.cxx +++ b/sc/source/filter/excel/xlescher.cxx @@ -36,6 +36,7 @@ #include "document.hxx" #include "xestream.hxx" #include "xistream.hxx" +#include "xlroot.hxx" #include "xltools.hxx" using ::rtl::OUString; @@ -110,15 +111,15 @@ long lclGetYFromRow( ScDocument& rDoc, SCTAB nScTab, sal_uInt16 nXclRow, sal_uIn /** Calculates an object column position from a drawing layer X position (in twips). */ void lclGetColFromX( ScDocument& rDoc, SCTAB nScTab, sal_uInt16& rnXclCol, - sal_uInt16& rnOffset, sal_uInt16 nXclStartCol, + sal_uInt16& rnOffset, sal_uInt16 nXclStartCol, sal_uInt16 nXclMaxCol, long& rnStartW, long nX, double fScale ) { // rnStartW in conjunction with nXclStartCol is used as buffer for previously calculated width long nTwipsX = static_cast< long >( nX / fScale + 0.5 ); long nColW = 0; - for( rnXclCol = nXclStartCol; rnXclCol <= MAXCOL; ++rnXclCol ) + for( rnXclCol = nXclStartCol; rnXclCol <= nXclMaxCol; ++rnXclCol ) { - nColW = rDoc.GetColWidth( static_cast<SCCOL>(rnXclCol), nScTab ); + nColW = rDoc.GetColWidth( static_cast< SCCOL >( rnXclCol ), nScTab ); if( rnStartW + nColW > nTwipsX ) break; rnStartW += nColW; @@ -128,28 +129,27 @@ void lclGetColFromX( /** Calculates an object row position from a drawing layer Y position (in twips). */ void lclGetRowFromY( - ScDocument& rDoc, SCTAB nScTab, - sal_uInt16& rnXclRow, sal_uInt16& rnOffset, sal_uInt16 nXclStartRow, + ScDocument& rDoc, SCTAB nScTab, sal_uInt16& rnXclRow, + sal_uInt16& rnOffset, sal_uInt16 nXclStartRow, sal_uInt16 nXclMaxRow, long& rnStartH, long nY, double fScale ) { // rnStartH in conjunction with nXclStartRow is used as buffer for previously calculated height long nTwipsY = static_cast< long >( nY / fScale + 0.5 ); long nRowH = 0; - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter( - rDoc.GetRowFlagsArray( nScTab), static_cast<SCROW>(nXclStartRow), - MAXROW, CR_HIDDEN, 0, rDoc.GetRowHeightArray( nScTab)); - for ( ; aIter; ++aIter ) + bool bFound = false; + for( SCROW nRow = static_cast< SCROW >( nXclStartRow ); nRow <= nXclMaxRow; ++nRow ) { - nRowH = *aIter; + nRowH = rDoc.GetRowHeight( nRow, nScTab ); if( rnStartH + nRowH > nTwipsY ) { - rnXclRow = static_cast< sal_uInt16 >( aIter.GetPos() ); + rnXclRow = static_cast< sal_uInt16 >( nRow ); + bFound = true; break; } rnStartH += nRowH; } - if (!aIter) - rnXclRow = static_cast< sal_uInt16 >( aIter.GetIterEnd() ); // down to the bottom.. + if( !bFound ) + rnXclRow = nXclMaxRow; rnOffset = static_cast< sal_uInt16 >( nRowH ? ((nTwipsY - rnStartH) * 256.0 / nRowH + 0.5) : 0 ); } @@ -178,8 +178,9 @@ XclObjAnchor::XclObjAnchor() : { } -Rectangle XclObjAnchor::GetRect( ScDocument& rDoc, SCTAB nScTab, MapUnit eMapUnit ) const +Rectangle XclObjAnchor::GetRect( const XclRoot& rRoot, SCTAB nScTab, MapUnit eMapUnit ) const { + ScDocument& rDoc = rRoot.GetDoc(); double fScale = lclGetTwipsScale( eMapUnit ); Rectangle aRect( lclGetXFromCol( rDoc, nScTab, maFirst.mnCol, mnLX, fScale ), @@ -193,20 +194,24 @@ Rectangle XclObjAnchor::GetRect( ScDocument& rDoc, SCTAB nScTab, MapUnit eMapUni return aRect; } -void XclObjAnchor::SetRect( ScDocument& rDoc, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit ) +void XclObjAnchor::SetRect( const XclRoot& rRoot, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit ) { - Rectangle aRect( rRect ); + ScDocument& rDoc = rRoot.GetDoc(); + sal_uInt16 nXclMaxCol = rRoot.GetXclMaxPos().Col(); + sal_uInt16 nXclMaxRow = static_cast<sal_uInt16>( rRoot.GetXclMaxPos().Row()); + // #106948# adjust coordinates in mirrored sheets + Rectangle aRect( rRect ); if( rDoc.IsLayoutRTL( nScTab ) ) lclMirrorRectangle( aRect ); double fScale = lclGetTwipsScale( eMapUnit ); long nDummy = 0; - lclGetColFromX( rDoc, nScTab, maFirst.mnCol, mnLX, 0, nDummy, aRect.Left(), fScale ); - lclGetColFromX( rDoc, nScTab, maLast.mnCol, mnRX, maFirst.mnCol, nDummy, aRect.Right(), fScale ); + lclGetColFromX( rDoc, nScTab, maFirst.mnCol, mnLX, 0, nXclMaxCol, nDummy, aRect.Left(), fScale ); + lclGetColFromX( rDoc, nScTab, maLast.mnCol, mnRX, maFirst.mnCol, nXclMaxCol, nDummy, aRect.Right(), fScale ); nDummy = 0; - lclGetRowFromY( rDoc, nScTab, maFirst.mnRow, mnTY, 0, nDummy, aRect.Top(), fScale ); - lclGetRowFromY( rDoc, nScTab, maLast.mnRow, mnBY, maFirst.mnRow, nDummy, aRect.Bottom(), fScale ); + lclGetRowFromY( rDoc, nScTab, maFirst.mnRow, mnTY, 0, nXclMaxRow, nDummy, aRect.Top(), fScale ); + lclGetRowFromY( rDoc, nScTab, maLast.mnRow, mnBY, maFirst.mnRow, nXclMaxRow, nDummy, aRect.Bottom(), fScale ); } void XclObjAnchor::SetRect( const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY, diff --git a/sc/source/filter/excel/xlview.cxx b/sc/source/filter/excel/xlview.cxx index d9cbbbb4b7c0..8e9df7e0ac1f 100644 --- a/sc/source/filter/excel/xlview.cxx +++ b/sc/source/filter/excel/xlview.cxx @@ -76,6 +76,7 @@ void XclTabViewData::SetDefaults() mbDefGridColor = true; mbShowFormulas = false; mbShowGrid = mbShowHeadings = mbShowZeros = mbShowOutline = true; + maTabBgColor.SetColor( COL_AUTO ); } bool XclTabViewData::IsSplit() const diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index 0ab97170621e..b4d764dc74a7 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -718,7 +718,7 @@ void ScHTMLExport::WriteTables() SCCOL nCol; for ( nCol=nStartCol; nCol<=nEndCol; nCol++ ) { - if ( !(pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) ) + if ( !pDoc->ColHidden(nCol, nTab) ) ++nColCnt; } (((aByteStrOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_cols) += '=') += ByteString::CreateFromInt32( nColCnt ); @@ -739,7 +739,7 @@ void ScHTMLExport::WriteTables() aByteStr += '='; for ( nCol=nStartCol; nCol<=nEndCol; nCol++ ) { - if ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) + if ( pDoc->ColHidden(nCol, nTab) ) continue; // for aByteStrOut = aByteStr; @@ -754,14 +754,12 @@ void ScHTMLExport::WriteTables() // At least old (3.x, 4.x?) Netscape doesn't follow <TABLE COLS=n> and // <COL WIDTH=x> specified, but needs a width at every column. bTableDataWidth = TRUE; // widths in first row - bool bHasHiddenRows = pDoc->GetRowFlagsArray( nTab).HasCondition( - nStartRow, nEndRow, CR_HIDDEN, CR_HIDDEN); + bool bHasHiddenRows = pDoc->HasHiddenRows(nStartRow, nEndRow, nTab); for ( SCROW nRow=nStartRow; nRow<=nEndRow; nRow++ ) { - if ( bHasHiddenRows && (pDoc->GetRowFlags( nRow, nTab ) & CR_HIDDEN) ) + if ( bHasHiddenRows && pDoc->RowHidden(nRow, nTab) ) { - nRow = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition( - nRow+1, nEndRow, CR_HIDDEN, 0); + nRow = pDoc->FirstVisibleRow(nRow+1, nEndRow, nTab); --nRow; continue; // for } @@ -770,7 +768,7 @@ void ScHTMLExport::WriteTables() bTableDataHeight = TRUE; // height at every first cell of each row for ( SCCOL nCol2=nStartCol; nCol2<=nEndCol; nCol2++ ) { - if ( pDoc->GetColFlags( nCol2, nTab ) & CR_HIDDEN ) + if ( pDoc->ColHidden(nCol2, nTab) ) continue; // for if ( nCol2 == nEndCol ) diff --git a/sc/source/filter/inc/imp_op.hxx b/sc/source/filter/inc/imp_op.hxx index 065678d5c792..2df58173a63a 100644 --- a/sc/source/filter/inc/imp_op.hxx +++ b/sc/source/filter/inc/imp_op.hxx @@ -97,6 +97,7 @@ protected: XclImpStream& aIn; // input stream ScfUInt32Vec maSheetOffsets; + ScRange maScOleSize; /// Visible range if embedded. NameBuffer* pExtNameBuff; // ... externe Namen (Ind.-Basis=1) ExcelToSc* pFormConv; // Formel-Konverter diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx index 7a2a33795520..201562fa752c 100644 --- a/sc/source/filter/inc/xcl97rec.hxx +++ b/sc/source/filter/inc/xcl97rec.hxx @@ -535,7 +535,7 @@ private: class XclExpFileSharing : public XclExpRecord { public: - explicit XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash ); + explicit XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash, bool bRecommendReadOnly ); virtual void Save( XclExpStream& rStrm ); @@ -545,6 +545,7 @@ private: private: XclExpString maUserName; sal_uInt16 mnPasswordHash; + bool mbRecommendReadOnly; }; // ============================================================================ diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx index f9d3a6ab2f95..980590f9d4ff 100644 --- a/sc/source/filter/inc/xeroot.hxx +++ b/sc/source/filter/inc/xeroot.hxx @@ -158,7 +158,7 @@ public: bool IsDocumentEncrypted() const; - const String GetPassword() const; + String GetPassword() const; private: diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx index cb12e03b21ad..fd7303509688 100644 --- a/sc/source/filter/inc/xestyle.hxx +++ b/sc/source/filter/inc/xestyle.hxx @@ -58,7 +58,8 @@ enum XclExpColorType EXC_COLOR_CHARTLINE, /// Line in a chart. EXC_COLOR_CHARTAREA, /// Area in a chart. EXC_COLOR_CTRLTEXT, /// Text color in a form control. - EXC_COLOR_GRID /// Spreadsheet grid color. + EXC_COLOR_GRID, /// Spreadsheet grid color. + EXC_COLOR_TABBG /// Spreadsheet tab bg color. }; // ---------------------------------------------------------------------------- diff --git a/sc/source/filter/inc/xeview.hxx b/sc/source/filter/inc/xeview.hxx index ca94e6eae3f9..61e349ab1e86 100644 --- a/sc/source/filter/inc/xeview.hxx +++ b/sc/source/filter/inc/xeview.hxx @@ -131,6 +131,20 @@ private: sal_uInt8 mnPane; /// Pane identifier of this selection. }; +class XclExpTabBgColor : public XclExpRecord +{ +public: + explicit XclExpTabBgColor( const XclTabViewData& rTabViewData ); + + /* virtual void SaveXml( XclExpXmlStream& rStrm ); TODO Fix XML Saving Stream */ +private: + /** Writes the contents of the SHEETEXT record. */ + virtual void WriteBody( XclExpStream& rStrm ); + +private: + const XclTabViewData& mrTabViewData; /// view settings data of current sheet. +}; + // View settings ============================================================== /** Contains all view settings records for a single sheet. */ @@ -153,6 +167,7 @@ private: void WriteScl( XclExpStream& rStrm ) const; void WritePane( XclExpStream& rStrm ) const; void WriteSelection( XclExpStream& rStrm, sal_uInt8 nPane ) const; + void WriteTabBgColor( XclExpStream& rStrm ) const; private: XclTabViewData maData; /// All view settings for a sheet. diff --git a/sc/source/filter/inc/xiview.hxx b/sc/source/filter/inc/xiview.hxx index 5f6d11c3439d..2451d69ee01c 100644 --- a/sc/source/filter/inc/xiview.hxx +++ b/sc/source/filter/inc/xiview.hxx @@ -80,7 +80,8 @@ public: void ReadPane( XclImpStream& rStrm ); /** Reads a SELECTION record. */ void ReadSelection( XclImpStream& rStrm ); - + /** Reads a SHEETEXT record (Tab Color). */ + void ReadTabBgColor( XclImpStream& rStrm, XclImpPalette& rPal ); /** Sets the view settings at the current sheet or the extended sheet options object. */ void Finalize(); diff --git a/sc/source/filter/inc/xlescher.hxx b/sc/source/filter/inc/xlescher.hxx index 10194ab41bc0..921da6b8741b 100644 --- a/sc/source/filter/inc/xlescher.hxx +++ b/sc/source/filter/inc/xlescher.hxx @@ -321,9 +321,9 @@ struct XclObjAnchor : public XclRange explicit XclObjAnchor(); /** Calculates a rectangle from the contained coordinates. */ - Rectangle GetRect( ScDocument& rDoc, SCTAB nScTab, MapUnit eMapUnit ) const; + Rectangle GetRect( const XclRoot& rRoot, SCTAB nScTab, MapUnit eMapUnit ) const; /** Initializes the anchor coordinates for a sheet. */ - void SetRect( ScDocument& rDoc, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit ); + void SetRect( const XclRoot& rRoot, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit ); /** Initializes the anchor coordinates for an embedded draw page. */ void SetRect( const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY, diff --git a/sc/source/filter/inc/xlview.hxx b/sc/source/filter/inc/xlview.hxx index 1a116c84c08e..c0c9d4b3d6e1 100644 --- a/sc/source/filter/inc/xlview.hxx +++ b/sc/source/filter/inc/xlview.hxx @@ -86,6 +86,11 @@ const sal_uInt8 EXC_PANE_TOPLEFT = 3; /// Single, top, left, o const sal_uInt16 EXC_ID_SCL = 0x00A0; +// (0x0862) SHEETEXT ---------------------------------------------------------- + +const sal_uInt16 EXC_ID_SHEETEXT = 0x0862; /// header id for sheetext +const sal_uInt8 EXC_SHEETEXT_TABCOLOR = 0x7F; /// mask for tab color +const sal_uInt16 EXC_COLOR_NOTABBG = 0x7F; /// Excel ignores Tab color when set to this value... // Structs ==================================================================== /** Contains all view settings for the entire document. */ @@ -146,6 +151,9 @@ struct XclTabViewData bool mbShowHeadings; /// true = Show column/row headings. bool mbShowZeros; /// true = Show zero value zells. bool mbShowOutline; /// true = Show outlines. + Color maTabBgColor; /// Tab Color default = (COL_AUTO ) + bool IsDefaultTabBgColor() const { return maTabBgColor == Color(COL_AUTO) ? TRUE : FALSE; }; + sal_uInt32 mnTabBgColorId; /// pallette color id explicit XclTabViewData(); ~XclTabViewData(); diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx index 5173d5303321..2f6f81b7279c 100644 --- a/sc/source/filter/lotus/lotimpop.cxx +++ b/sc/source/filter/lotus/lotimpop.cxx @@ -180,8 +180,7 @@ void ImportLotus::Hiddencolumn( UINT16 nRecLen ) { Read( nCol ); - pD->SetColFlags( static_cast<SCCOL> (nCol), static_cast<SCTAB> (nLTab), pD->GetColFlags( static_cast<SCCOL> (nCol), static_cast<SCTAB> (nLTab) ) | CR_HIDDEN ); - + pD->SetColHidden(static_cast<SCCOL>(nCol), static_cast<SCCOL>(nCol), static_cast<SCTAB>(nLTab), true); nCnt--; } } diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index 0306bdc6315b..4ab0c8bb3b14 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -226,7 +226,7 @@ void OP_ColumnWidth( SvStream& r, UINT16 /*n*/ ) nBreite = ( UINT16 ) ( TWIPS_PER_CHAR * nWidthSpaces ); else { - pDoc->SetColFlags( static_cast<SCCOL> (nCol), 0, pDoc->GetColFlags( static_cast<SCCOL> (nCol), 0 ) | CR_HIDDEN ); + pDoc->SetColHidden(static_cast<SCCOL>(nCol), static_cast<SCCOL>(nCol), 0, true); nBreite = nDefWidth; } @@ -335,7 +335,7 @@ void OP_HiddenCols( SvStream& r, UINT16 /*n*/ ) { if( nAkt & 0x01 ) // unterstes Bit gesetzt? // -> Hidden Col - pDoc->SetColFlags( nCount, 0, pDoc->GetColFlags( nCount, 0 ) | CR_HIDDEN ); + pDoc->SetColHidden(nCount, nCount, 0, true); nCount++; nAkt = nAkt / 2; // der Naechste bitte... diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 86a347970ff6..7fb3d16c6c8d 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -435,7 +435,7 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNu for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ ) { USHORT nHeight = (USHORT)(ULONG) mpRowHeights->Get( nRow ); - if ( nHeight > mpDoc->FastGetRowHeight( nRow, nTab ) ) + if ( nHeight > mpDoc->GetRowHeight( nRow, nTab ) ) mpDoc->SetRowHeight( nRow, nTab, nHeight ); } } diff --git a/sc/source/filter/rtf/expbase.cxx b/sc/source/filter/rtf/expbase.cxx index 3188b4f920e7..cd3f30ef9c9f 100644 --- a/sc/source/filter/rtf/expbase.cxx +++ b/sc/source/filter/rtf/expbase.cxx @@ -75,16 +75,13 @@ BOOL ScExportBase::GetDataArea( SCTAB nTab, SCCOL& nStartCol, BOOL ScExportBase::TrimDataArea( SCTAB nTab, SCCOL& nStartCol, SCROW& nStartRow, SCCOL& nEndCol, SCROW& nEndRow ) const { - while ( nStartCol <= nEndCol && - pDoc->GetColFlags( nStartCol, nTab ) & CR_HIDDEN ) + SCCOL nLastCol; + while ( nStartCol <= nEndCol && pDoc->ColHidden(nStartCol, nTab, nLastCol)) ++nStartCol; - while ( nStartCol <= nEndCol && - pDoc->GetColFlags( nEndCol, nTab ) & CR_HIDDEN ) + while ( nStartCol <= nEndCol && pDoc->ColHidden(nEndCol, nTab, nLastCol)) --nEndCol; - nStartRow = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition( nStartRow, - nEndRow, CR_HIDDEN, 0); - nEndRow = pDoc->GetRowFlagsArray( nTab).GetLastForCondition( nStartRow, - nEndRow, CR_HIDDEN, 0); + nStartRow = pDoc->FirstVisibleRow(nStartRow, nEndRow, nTab); + nEndRow = pDoc->LastVisibleRow(nStartRow, nEndRow, nTab); return nStartCol <= nEndCol && nStartRow <= nEndRow && nEndRow != ::std::numeric_limits<SCROW>::max(); } diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx index 104d0d7fe192..c9bf2a90a7a5 100644 --- a/sc/source/filter/starcalc/scflt.cxx +++ b/sc/source/filter/starcalc/scflt.cxx @@ -1548,14 +1548,14 @@ void Sc10Import::LoadTables() rStream >> DataValue; if (DataValue != 0) { - BYTE nFlags = 0; - if ((DataValue & crfSoftBreak) == crfSoftBreak) - nFlags |= CR_PAGEBREAK; - if ((DataValue & crfHardBreak) == crfHardBreak) - nFlags |= CR_MANUALBREAK; - if ((DataValue & crfHidden) == crfHidden) - nFlags |= CR_HIDDEN; - for (SCCOL k = static_cast<SCCOL>(DataStart); k <= static_cast<SCCOL>(DataEnd); k++) pDoc->SetColFlags(k, static_cast<SCTAB> (TabNo), nFlags); + bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak); + bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak); + bool bHidden = ((DataValue & crfHidden) == crfHidden); + for (SCCOL k = static_cast<SCCOL>(DataStart); k <= static_cast<SCCOL>(DataEnd); k++) + { + pDoc->SetColHidden(k, k, static_cast<SCTAB>(TabNo), bHidden); + pDoc->SetColBreak(k, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak); + } } DataStart = DataEnd + 1; } @@ -1598,14 +1598,14 @@ void Sc10Import::LoadTables() rStream >> DataValue; if (DataValue != 0) { - BYTE nFlags = 0; - if ((DataValue & crfSoftBreak) == crfSoftBreak) - nFlags |= CR_PAGEBREAK; - if ((DataValue & crfHardBreak) == crfHardBreak) - nFlags |= CR_MANUALBREAK; - if ((DataValue & crfHidden) == crfHidden) - nFlags |= CR_HIDDEN; - for (SCROW l = static_cast<SCROW>(DataStart); l <= static_cast<SCROW>(DataEnd); l++) pDoc->SetRowFlags(l, static_cast<SCTAB> (TabNo), nFlags); + bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak); + bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak); + bool bHidden = ((DataValue & crfHidden) == crfHidden); + for (SCROW l = static_cast<SCROW>(DataStart); l <= static_cast<SCROW>(DataEnd); l++) + { + pDoc->SetRowHidden(l, l, static_cast<SCTAB> (TabNo), bHidden); + pDoc->SetRowBreak(l, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak); + } } DataStart = DataEnd + 1; } @@ -2396,7 +2396,7 @@ void Sc10Import::LoadObjects() nStartX = (long) ( nStartX * HMM_PER_TWIPS ); nStartX += (long) ( GraphHeader.x / nPPTX * HMM_PER_TWIPS ); long nSizeX = (long) ( GraphHeader.w / nPPTX * HMM_PER_TWIPS ); - long nStartY = pDoc->FastGetRowHeight( 0, + long nStartY = pDoc->GetRowHeight( 0, static_cast<SCsROW>(GraphHeader.CarretY) - 1, static_cast<SCTAB>(GraphHeader.CarretZ)); nStartY = (long) ( nStartY * HMM_PER_TWIPS ); diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 67a295ccec8b..df6bdcbbe671 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1354,9 +1354,10 @@ void XclExpWriteAccess::WriteBody( XclExpStream& rStrm ) // ============================================================================ -XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash ) : +XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash, bool bRecommendReadOnly ) : XclExpRecord( EXC_ID_FILESHARING ), - mnPasswordHash( nPasswordHash ) + mnPasswordHash( nPasswordHash ), + mbRecommendReadOnly( bRecommendReadOnly ) { if( rRoot.GetBiff() <= EXC_BIFF5 ) maUserName.AssignByte( rRoot.GetUserName(), rRoot.GetTextEncoding(), EXC_STR_8BITLENGTH ); @@ -1366,13 +1367,13 @@ XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPassw void XclExpFileSharing::Save( XclExpStream& rStrm ) { - if( mnPasswordHash != 0 ) + if( (mnPasswordHash != 0) || mbRecommendReadOnly ) XclExpRecord::Save( rStrm ); } void XclExpFileSharing::WriteBody( XclExpStream& rStrm ) { - rStrm << sal_uInt16( 0 ) << mnPasswordHash << maUserName; + rStrm << sal_uInt16( mbRecommendReadOnly ? 1 : 0 ) << mnPasswordHash << maUserName; } // ============================================================================ diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx index 93e529c4ceca..ba107347b46a 100644 --- a/sc/source/filter/xml/xmldpimp.cxx +++ b/sc/source/filter/xml/xmldpimp.cxx @@ -464,6 +464,11 @@ void ScXMLDataPilotTableContext::EndElement() if (pDoc) { ScDPCollection* pDPCollection = pDoc->GetDPCollection(); + + // #i94570# Names have to be unique, or the tables can't be accessed by API. + if ( pDPCollection->GetByName(pDPObject->GetName()) ) + pDPObject->SetName( String() ); // ignore the invalid name, create a new name in AfterXMLLoading + pDPObject->SetAlive(sal_True); pDPCollection->InsertNewTable(pDPObject); } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index f5a4b3648ebb..a913cb7ac861 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -85,6 +85,7 @@ #include <rtl/ustring.hxx> #include <tools/debug.hxx> +#include "tools/color.hxx" #include <rtl/math.hxx> #include <svl/zforlist.hxx> #include <svx/unoshape.hxx> @@ -125,6 +126,7 @@ #include <com/sun/star/form/XFormsSupplier2.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> @@ -164,6 +166,7 @@ using namespace formula; using namespace com::sun::star; using namespace xmloff::token; using ::std::vector; +using ::com::sun::star::uno::UNO_QUERY; //---------------------------------------------------------------------------- @@ -1708,142 +1711,140 @@ void ScXMLExport::_ExportContent() } else { - //! indent after rebasing to m52 - - uno::Reference<sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); - if (xTable.is()) - { - xCurrentTable.set(xTable); - xCurrentTableCellRange.set(xTable, uno::UNO_QUERY); - uno::Reference<container::XNamed> xName (xTable, uno::UNO_QUERY ); - if ( xName.is() ) + uno::Reference<sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); + if (xTable.is()) { - nCurrentTable = sal::static_int_cast<sal_uInt16>( nTable ); - rtl::OUString sOUTableName(xName->getName()); - AddAttribute(sAttrName, sOUTableName); - AddAttribute(sAttrStyleName, aTableStyles[nTable]); - uno::Reference<util::XProtectable> xProtectable (xTable, uno::UNO_QUERY); - if (xProtectable.is() && xProtectable->isProtected()) + xCurrentTable.set(xTable); + xCurrentTableCellRange.set(xTable, uno::UNO_QUERY); + uno::Reference<container::XNamed> xName (xTable, uno::UNO_QUERY ); + if ( xName.is() ) { - AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE); - rtl::OUStringBuffer aBuffer; - if (pDoc) + nCurrentTable = sal::static_int_cast<sal_uInt16>( nTable ); + rtl::OUString sOUTableName(xName->getName()); + AddAttribute(sAttrName, sOUTableName); + AddAttribute(sAttrStyleName, aTableStyles[nTable]); + + uno::Reference<util::XProtectable> xProtectable (xTable, uno::UNO_QUERY); + if (xProtectable.is() && xProtectable->isProtected()) { - ScTableProtection* pProtect = pDoc->GetTabProtection(static_cast<SCTAB>(nTable)); - if (pProtect) - SvXMLUnitConverter::encodeBase64(aBuffer, pProtect->getPasswordHash(PASSHASH_OOO)); + AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE); + rtl::OUStringBuffer aBuffer; + if (pDoc) + { + ScTableProtection* pProtect = pDoc->GetTabProtection(static_cast<SCTAB>(nTable)); + if (pProtect) + SvXMLUnitConverter::encodeBase64(aBuffer, pProtect->getPasswordHash(PASSHASH_OOO)); + } + if (aBuffer.getLength()) + AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear()); } - if (aBuffer.getLength()) - AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear()); - } - rtl::OUString sPrintRanges; - table::CellRangeAddress aColumnHeaderRange; - sal_Bool bHasColumnHeader; - GetColumnRowHeader(bHasColumnHeader, aColumnHeaderRange, bHasRowHeader, aRowHeaderRange, sPrintRanges); - if( sPrintRanges.getLength() ) - AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT_RANGES, sPrintRanges ); - else if (!pDoc->IsPrintEntireSheet(static_cast<SCTAB>(nTable))) - AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT, XML_FALSE); - SvXMLElementExport aElemT(*this, sElemTab, sal_True, sal_True); - CheckAttrList(); - - if ( pDoc && pDoc->GetSheetEvents( static_cast<SCTAB>(nTable) ) && - getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST ) - { - // store sheet events - uno::Reference<document::XEventsSupplier> xSupplier(xTable, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xEvents(xSupplier->getEvents(), uno::UNO_QUERY); - GetEventExport().ExportExt( xEvents ); - } + rtl::OUString sPrintRanges; + table::CellRangeAddress aColumnHeaderRange; + sal_Bool bHasColumnHeader; + GetColumnRowHeader(bHasColumnHeader, aColumnHeaderRange, bHasRowHeader, aRowHeaderRange, sPrintRanges); + if( sPrintRanges.getLength() ) + AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT_RANGES, sPrintRanges ); + else if (!pDoc->IsPrintEntireSheet(static_cast<SCTAB>(nTable))) + AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT, XML_FALSE); + SvXMLElementExport aElemT(*this, sElemTab, sal_True, sal_True); + CheckAttrList(); - WriteTableSource(); - WriteScenario(); - uno::Reference<drawing::XDrawPage> xDrawPage; - if (pSharedData->HasForm(nTable, xDrawPage) && xDrawPage.is()) - { - ::xmloff::OOfficeFormsExport aForms(*this); - GetFormExport()->exportForms( xDrawPage ); - sal_Bool bRet(GetFormExport()->seekPage( xDrawPage )); - DBG_ASSERT( bRet, "OFormLayerXMLExport::seekPage failed!" ); - (void)bRet; // avoid warning in product version - } - if (pSharedData->HasDrawPage()) - { - GetShapeExport()->seekShapes(uno::Reference<drawing::XShapes>(pSharedData->GetDrawPage(nTable), uno::UNO_QUERY)); - WriteTableShapes(); - } - table::CellRangeAddress aRange(GetEndAddress(xTable, nTable)); - pSharedData->SetLastColumn(nTable, aRange.EndColumn); - pSharedData->SetLastRow(nTable, aRange.EndRow); - pCellsItr->SetCurrentTable(static_cast<SCTAB>(nTable), xCurrentTable); - pGroupColumns->NewTable(); - pGroupRows->NewTable(); - FillColumnRowGroups(); - if (bHasColumnHeader) - pSharedData->SetLastColumn(nTable, aColumnHeaderRange.EndColumn); - bRowHeaderOpen = sal_False; - if (bHasRowHeader) - pSharedData->SetLastRow(nTable, aRowHeaderRange.EndRow); - pDefaults->FillDefaultStyles(nTable, pSharedData->GetLastRow(nTable), - pSharedData->GetLastColumn(nTable), pCellStyles, pDoc); - pRowFormatRanges->SetRowDefaults(pDefaults->GetRowDefaults()); - pRowFormatRanges->SetColDefaults(pDefaults->GetColDefaults()); - pCellStyles->SetRowDefaults(pDefaults->GetRowDefaults()); - pCellStyles->SetColDefaults(pDefaults->GetColDefaults()); - ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader); - sal_Bool bIsFirst(sal_True); - sal_Int32 nEqualCells(0); - ScMyCell aCell; - ScMyCell aPrevCell; - while(pCellsItr->GetNext(aCell, pCellStyles)) - { - if (bIsFirst) + if ( pDoc && pDoc->GetSheetEvents( static_cast<SCTAB>(nTable) ) && + getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST ) { - ExportFormatRanges(0, 0, aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable); - aPrevCell = aCell; - bIsFirst = sal_False; + // store sheet events + uno::Reference<document::XEventsSupplier> xSupplier(xTable, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xEvents(xSupplier->getEvents(), uno::UNO_QUERY); + GetEventExport().ExportExt( xEvents ); } - else + + WriteTableSource(); + WriteScenario(); + uno::Reference<drawing::XDrawPage> xDrawPage; + if (pSharedData->HasForm(nTable, xDrawPage) && xDrawPage.is()) + { + ::xmloff::OOfficeFormsExport aForms(*this); + GetFormExport()->exportForms( xDrawPage ); + sal_Bool bRet(GetFormExport()->seekPage( xDrawPage )); + DBG_ASSERT( bRet, "OFormLayerXMLExport::seekPage failed!" ); + (void)bRet; // avoid warning in product version + } + if (pSharedData->HasDrawPage()) { - if ((aPrevCell.aCellAddress.Row == aCell.aCellAddress.Row) && - (aPrevCell.aCellAddress.Column + nEqualCells + 1 == aCell.aCellAddress.Column)) + GetShapeExport()->seekShapes(uno::Reference<drawing::XShapes>(pSharedData->GetDrawPage(nTable), uno::UNO_QUERY)); + WriteTableShapes(); + } + table::CellRangeAddress aRange(GetEndAddress(xTable, nTable)); + pSharedData->SetLastColumn(nTable, aRange.EndColumn); + pSharedData->SetLastRow(nTable, aRange.EndRow); + pCellsItr->SetCurrentTable(static_cast<SCTAB>(nTable), xCurrentTable); + pGroupColumns->NewTable(); + pGroupRows->NewTable(); + FillColumnRowGroups(); + if (bHasColumnHeader) + pSharedData->SetLastColumn(nTable, aColumnHeaderRange.EndColumn); + bRowHeaderOpen = sal_False; + if (bHasRowHeader) + pSharedData->SetLastRow(nTable, aRowHeaderRange.EndRow); + pDefaults->FillDefaultStyles(nTable, pSharedData->GetLastRow(nTable), + pSharedData->GetLastColumn(nTable), pCellStyles, pDoc); + pRowFormatRanges->SetRowDefaults(pDefaults->GetRowDefaults()); + pRowFormatRanges->SetColDefaults(pDefaults->GetColDefaults()); + pCellStyles->SetRowDefaults(pDefaults->GetRowDefaults()); + pCellStyles->SetColDefaults(pDefaults->GetColDefaults()); + ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader); + sal_Bool bIsFirst(sal_True); + sal_Int32 nEqualCells(0); + ScMyCell aCell; + ScMyCell aPrevCell; + while(pCellsItr->GetNext(aCell, pCellStyles)) + { + if (bIsFirst) + { + ExportFormatRanges(0, 0, aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable); + aPrevCell = aCell; + bIsFirst = sal_False; + } + else { - if(IsCellEqual(aPrevCell, aCell)) - ++nEqualCells; + if ((aPrevCell.aCellAddress.Row == aCell.aCellAddress.Row) && + (aPrevCell.aCellAddress.Column + nEqualCells + 1 == aCell.aCellAddress.Column)) + { + if(IsCellEqual(aPrevCell, aCell)) + ++nEqualCells; + else + { + SetRepeatAttribute(nEqualCells); + WriteCell(aPrevCell); + nEqualCells = 0; + aPrevCell = aCell; + } + } else { SetRepeatAttribute(nEqualCells); WriteCell(aPrevCell); + ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row, + aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable); nEqualCells = 0; aPrevCell = aCell; } } - else - { - SetRepeatAttribute(nEqualCells); - WriteCell(aPrevCell); - ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row, - aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable); - nEqualCells = 0; - aPrevCell = aCell; - } } + if (!bIsFirst) + { + SetRepeatAttribute(nEqualCells); + WriteCell(aPrevCell); + ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row, + pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable); + } + else + ExportFormatRanges(0, 0, pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable); + CloseRow(pSharedData->GetLastRow(nTable)); + nEqualCells = 0; } - if (!bIsFirst) - { - SetRepeatAttribute(nEqualCells); - WriteCell(aPrevCell); - ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row, - pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable); - } - else - ExportFormatRanges(0, 0, pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable); - CloseRow(pSharedData->GetLastRow(nTable)); - nEqualCells = 0; } } - - } IncrementProgressBar(sal_False); } } @@ -2161,505 +2162,507 @@ uno::Any lcl_GetEnumerated( uno::Reference<container::XEnumerationAccess> xEnumA void ScXMLExport::_ExportAutoStyles() { - if (GetModel().is()) + if (!GetModel().is()) + return; + + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY ); + if (!xSpreadDoc.is()) + return; + + uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY ); + if (!xIndex.is()) + return; + + if (getExportFlags() & EXPORT_CONTENT) { - uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY ); - if ( xSpreadDoc.is() ) + // re-create automatic styles with old names from stored data + ScSheetSaveData* pSheetData = ScModelObj::getImplementation(xSpreadDoc)->GetSheetSaveData(); + if (pSheetData && pDoc) { - uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY ); - if ( xIndex.is() ) - { - if (getExportFlags() & EXPORT_CONTENT) + // formulas have to be calculated now, to detect changed results + // (during normal save, they will be calculated anyway) + SCTAB nTabCount = pDoc->GetTableCount(); + for (SCTAB nTab=0; nTab<nTabCount; ++nTab) + if (pDoc->IsStreamValid(nTab)) { - // re-create automatic styles with old names from stored data - ScSheetSaveData* pSheetData = ScModelObj::getImplementation(xSpreadDoc)->GetSheetSaveData(); - if (pSheetData && pDoc) + ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab ); + ScBaseCell* pCell = aIter.GetFirst(); + while (pCell) { - // formulas have to be calculated now, to detect changed results - // (during normal save, they will be calculated anyway) - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab=0; nTab<nTabCount; ++nTab) - if (pDoc->IsStreamValid(nTab)) - { - ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab ); - ScBaseCell* pCell = aIter.GetFirst(); - while (pCell) - { - if (pCell->GetCellType() == CELLTYPE_FORMULA) - static_cast<ScFormulaCell*>(pCell)->IsValue(); // interpret if dirty - pCell = aIter.GetNext(); - } - } + if (pCell->GetCellType() == CELLTYPE_FORMULA) + static_cast<ScFormulaCell*>(pCell)->IsValue(); // interpret if dirty + pCell = aIter.GetNext(); + } + } - // stored cell styles - const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles(); - std::vector<ScCellStyleEntry>::const_iterator aCellIter = rCellEntries.begin(); - std::vector<ScCellStyleEntry>::const_iterator aCellEnd = rCellEntries.end(); - while (aCellIter != aCellEnd) - { - ScAddress aPos = aCellIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) - { - uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference <beans::XPropertySet> xProperties( - xTable->getCellByPosition( aPos.Col(), aPos.Row() ), uno::UNO_QUERY ); + // stored cell styles + const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles(); + std::vector<ScCellStyleEntry>::const_iterator aCellIter = rCellEntries.begin(); + std::vector<ScCellStyleEntry>::const_iterator aCellEnd = rCellEntries.end(); + while (aCellIter != aCellEnd) + { + ScAddress aPos = aCellIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference <beans::XPropertySet> xProperties( + xTable->getCellByPosition( aPos.Col(), aPos.Row() ), uno::UNO_QUERY ); - AddStyleFromCells(xProperties, xTable, nTable, &aCellIter->maName); - } - ++aCellIter; - } + AddStyleFromCells(xProperties, xTable, nTable, &aCellIter->maName); + } + ++aCellIter; + } - // stored column styles - const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->GetColumnStyles(); - std::vector<ScCellStyleEntry>::const_iterator aColumnIter = rColumnEntries.begin(); - std::vector<ScCellStyleEntry>::const_iterator aColumnEnd = rColumnEntries.end(); - while (aColumnIter != aColumnEnd) - { - ScAddress aPos = aColumnIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) - { - uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns()); - uno::Reference<beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex( aPos.Col() ), uno::UNO_QUERY); + // stored column styles + const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->GetColumnStyles(); + std::vector<ScCellStyleEntry>::const_iterator aColumnIter = rColumnEntries.begin(); + std::vector<ScCellStyleEntry>::const_iterator aColumnEnd = rColumnEntries.end(); + while (aColumnIter != aColumnEnd) + { + ScAddress aPos = aColumnIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns()); + uno::Reference<beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex( aPos.Col() ), uno::UNO_QUERY); - sal_Int32 nIndex(-1); - sal_Bool bIsVisible(sal_True); - AddStyleFromColumn( xColumnProperties, &aColumnIter->maName, nIndex, bIsVisible ); - } - ++aColumnIter; - } + sal_Int32 nIndex(-1); + sal_Bool bIsVisible(sal_True); + AddStyleFromColumn( xColumnProperties, &aColumnIter->maName, nIndex, bIsVisible ); + } + ++aColumnIter; + } - // stored row styles - const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->GetRowStyles(); - std::vector<ScCellStyleEntry>::const_iterator aRowIter = rRowEntries.begin(); - std::vector<ScCellStyleEntry>::const_iterator aRowEnd = rRowEntries.end(); - while (aRowIter != aRowEnd) - { - ScAddress aPos = aRowIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) - { - uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows()); - uno::Reference<beans::XPropertySet> xRowProperties(xTableRows->getByIndex( aPos.Row() ), uno::UNO_QUERY); + // stored row styles + const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->GetRowStyles(); + std::vector<ScCellStyleEntry>::const_iterator aRowIter = rRowEntries.begin(); + std::vector<ScCellStyleEntry>::const_iterator aRowEnd = rRowEntries.end(); + while (aRowIter != aRowEnd) + { + ScAddress aPos = aRowIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows()); + uno::Reference<beans::XPropertySet> xRowProperties(xTableRows->getByIndex( aPos.Row() ), uno::UNO_QUERY); - sal_Int32 nIndex(-1); - AddStyleFromRow( xRowProperties, &aRowIter->maName, nIndex ); - } - ++aRowIter; - } + sal_Int32 nIndex(-1); + AddStyleFromRow( xRowProperties, &aRowIter->maName, nIndex ); + } + ++aRowIter; + } - // stored table styles - const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->GetTableStyles(); - std::vector<ScCellStyleEntry>::const_iterator aTableIter = rTableEntries.begin(); - std::vector<ScCellStyleEntry>::const_iterator aTableEnd = rTableEntries.end(); - while (aTableIter != aTableEnd) - { - ScAddress aPos = aTableIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) - { - //! separate method AddStyleFromTable needed? - uno::Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY); - if (xTableProperties.is()) - { - std::vector<XMLPropertyState> xPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties)); - rtl::OUString sParent; - rtl::OUString sName( aTableIter->maName ); - GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TABLE_TABLE, sParent, xPropStates); - GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_TABLE, sName); - } - } - ++aTableIter; - } + // stored table styles + const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->GetTableStyles(); + std::vector<ScCellStyleEntry>::const_iterator aTableIter = rTableEntries.begin(); + std::vector<ScCellStyleEntry>::const_iterator aTableEnd = rTableEntries.end(); + while (aTableIter != aTableEnd) + { + ScAddress aPos = aTableIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + //! separate method AddStyleFromTable needed? + uno::Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY); + if (xTableProperties.is()) + { + std::vector<XMLPropertyState> xPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties)); + rtl::OUString sParent; + rtl::OUString sName( aTableIter->maName ); + GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TABLE_TABLE, sParent, xPropStates); + GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_TABLE, sName); + } + } + ++aTableIter; + } - // stored styles for notes + // stored styles for notes - UniReference<SvXMLExportPropertyMapper> xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this ); - GetShapeExport(); // make sure the graphics styles family is added + UniReference<SvXMLExportPropertyMapper> xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this ); + GetShapeExport(); // make sure the graphics styles family is added - const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles(); - std::vector<ScNoteStyleEntry>::const_iterator aNoteIter = rNoteEntries.begin(); - std::vector<ScNoteStyleEntry>::const_iterator aNoteEnd = rNoteEntries.end(); - while (aNoteIter != aNoteEnd) + const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles(); + std::vector<ScNoteStyleEntry>::const_iterator aNoteIter = rNoteEntries.begin(); + std::vector<ScNoteStyleEntry>::const_iterator aNoteEnd = rNoteEntries.end(); + while (aNoteIter != aNoteEnd) + { + ScAddress aPos = aNoteIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + //! separate method AddStyleFromNote needed? + + ScPostIt* pNote = pDoc->GetNote( aPos ); + DBG_ASSERT( pNote, "note not found" ); + if (pNote) + { + SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); + // all uno shapes are created anyway in CollectSharedData + uno::Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY ); + if (xShapeProperties.is()) { - ScAddress aPos = aNoteIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) + if ( aNoteIter->maStyleName.getLength() ) { - //! separate method AddStyleFromNote needed? - - ScPostIt* pNote = pDoc->GetNote( aPos ); - DBG_ASSERT( pNote, "note not found" ); - if (pNote) - { - SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); - // all uno shapes are created anyway in CollectSharedData - uno::Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY ); - if (xShapeProperties.is()) - { - if ( aNoteIter->maStyleName.getLength() ) - { - std::vector<XMLPropertyState> xPropStates(xShapeMapper->Filter(xShapeProperties)); - rtl::OUString sParent; - rtl::OUString sName( aNoteIter->maStyleName ); - GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sParent, xPropStates); - GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_SD_GRAPHICS_ID, sName); - } - if ( aNoteIter->maTextStyle.getLength() ) - { - std::vector<XMLPropertyState> xPropStates( - GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(xShapeProperties)); - rtl::OUString sParent; - rtl::OUString sName( aNoteIter->maTextStyle ); - GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates); - GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName); - } - } - } + std::vector<XMLPropertyState> xPropStates(xShapeMapper->Filter(xShapeProperties)); + rtl::OUString sParent; + rtl::OUString sName( aNoteIter->maStyleName ); + GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sParent, xPropStates); + GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_SD_GRAPHICS_ID, sName); + } + if ( aNoteIter->maTextStyle.getLength() ) + { + std::vector<XMLPropertyState> xPropStates( + GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(xShapeProperties)); + rtl::OUString sParent; + rtl::OUString sName( aNoteIter->maTextStyle ); + GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates); + GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName); } - ++aNoteIter; } + } + } + ++aNoteIter; + } - // note paragraph styles + // note paragraph styles - //UniReference<SvXMLExportPropertyMapper> xParaPropMapper = XMLTextParagraphExport::CreateParaExtPropMapper( *this ); - UniReference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper(); + //UniReference<SvXMLExportPropertyMapper> xParaPropMapper = XMLTextParagraphExport::CreateParaExtPropMapper( *this ); + UniReference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper(); - const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles(); - std::vector<ScTextStyleEntry>::const_iterator aNoteParaIter = rNoteParaEntries.begin(); - std::vector<ScTextStyleEntry>::const_iterator aNoteParaEnd = rNoteParaEntries.end(); - while (aNoteParaIter != aNoteParaEnd) + const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles(); + std::vector<ScTextStyleEntry>::const_iterator aNoteParaIter = rNoteParaEntries.begin(); + std::vector<ScTextStyleEntry>::const_iterator aNoteParaEnd = rNoteParaEntries.end(); + while (aNoteParaIter != aNoteParaEnd) + { + ScAddress aPos = aNoteParaIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + ScPostIt* pNote = pDoc->GetNote( aPos ); + DBG_ASSERT( pNote, "note not found" ); + if (pNote) + { + SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); + uno::Reference<container::XEnumerationAccess> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xParaProp( + lcl_GetEnumerated( xCellText, aNoteParaIter->maSelection.nStartPara ), uno::UNO_QUERY ); + if ( xParaProp.is() ) { - ScAddress aPos = aNoteParaIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) - { - ScPostIt* pNote = pDoc->GetNote( aPos ); - DBG_ASSERT( pNote, "note not found" ); - if (pNote) - { - SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); - uno::Reference<container::XEnumerationAccess> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xParaProp( - lcl_GetEnumerated( xCellText, aNoteParaIter->maSelection.nStartPara ), uno::UNO_QUERY ); - if ( xParaProp.is() ) - { - std::vector<XMLPropertyState> xPropStates(xParaPropMapper->Filter(xParaProp)); - rtl::OUString sParent; - rtl::OUString sName( aNoteParaIter->maName ); - GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates); - GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName); - } - } - } - ++aNoteParaIter; + std::vector<XMLPropertyState> xPropStates(xParaPropMapper->Filter(xParaProp)); + rtl::OUString sParent; + rtl::OUString sName( aNoteParaIter->maName ); + GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates); + GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName); } + } + } + ++aNoteParaIter; + } - // note text styles + // note text styles - UniReference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); + UniReference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); - const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles(); - std::vector<ScTextStyleEntry>::const_iterator aNoteTextIter = rNoteTextEntries.begin(); - std::vector<ScTextStyleEntry>::const_iterator aNoteTextEnd = rNoteTextEntries.end(); - while (aNoteTextIter != aNoteTextEnd) + const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles(); + std::vector<ScTextStyleEntry>::const_iterator aNoteTextIter = rNoteTextEntries.begin(); + std::vector<ScTextStyleEntry>::const_iterator aNoteTextEnd = rNoteTextEntries.end(); + while (aNoteTextIter != aNoteTextEnd) + { + ScAddress aPos = aNoteTextIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + ScPostIt* pNote = pDoc->GetNote( aPos ); + DBG_ASSERT( pNote, "note not found" ); + if (pNote) + { + SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); + uno::Reference<text::XSimpleText> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY); + ScDrawTextCursor* pCursor = ScDrawTextCursor::getImplementation( xCursorProp ); + if (pCursor) { - ScAddress aPos = aNoteTextIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) - { - ScPostIt* pNote = pDoc->GetNote( aPos ); - DBG_ASSERT( pNote, "note not found" ); - if (pNote) - { - SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); - uno::Reference<text::XSimpleText> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY); - ScDrawTextCursor* pCursor = ScDrawTextCursor::getImplementation( xCursorProp ); - if (pCursor) - { - pCursor->SetSelection( aNoteTextIter->maSelection ); + pCursor->SetSelection( aNoteTextIter->maSelection ); - std::vector<XMLPropertyState> xPropStates(xTextPropMapper->Filter(xCursorProp)); - rtl::OUString sParent; - rtl::OUString sName( aNoteTextIter->maName ); - GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates); - GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName); - } - } - } - ++aNoteTextIter; + std::vector<XMLPropertyState> xPropStates(xTextPropMapper->Filter(xCursorProp)); + rtl::OUString sParent; + rtl::OUString sName( aNoteTextIter->maName ); + GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates); + GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName); } + } + } + ++aNoteTextIter; + } - // stored text styles + // stored text styles - //UniReference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); + //UniReference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); - const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles(); - std::vector<ScTextStyleEntry>::const_iterator aTextIter = rTextEntries.begin(); - std::vector<ScTextStyleEntry>::const_iterator aTextEnd = rTextEntries.end(); - while (aTextIter != aTextEnd) - { - ScAddress aPos = aTextIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); - if (bCopySheet) - { - //! separate method AddStyleFromText needed? - //! cache sheet object - - uno::Reference<table::XCellRange> xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference<text::XSimpleText> xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY); - ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp ); - if (pCursor) - { - pCursor->SetSelection( aTextIter->maSelection ); + const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles(); + std::vector<ScTextStyleEntry>::const_iterator aTextIter = rTextEntries.begin(); + std::vector<ScTextStyleEntry>::const_iterator aTextEnd = rTextEntries.end(); + while (aTextIter != aTextEnd) + { + ScAddress aPos = aTextIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) ); + if (bCopySheet) + { + //! separate method AddStyleFromText needed? + //! cache sheet object + + uno::Reference<table::XCellRange> xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference<text::XSimpleText> xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY); + ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp ); + if (pCursor) + { + pCursor->SetSelection( aTextIter->maSelection ); - std::vector<XMLPropertyState> xPropStates(xTextPropMapper->Filter(xCursorProp)); - rtl::OUString sParent; - rtl::OUString sName( aTextIter->maName ); - GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates); - GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName); - } - } - ++aTextIter; - } + std::vector<XMLPropertyState> xPropStates(xTextPropMapper->Filter(xCursorProp)); + rtl::OUString sParent; + rtl::OUString sName( aTextIter->maName ); + GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates); + GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName); } + } + ++aTextIter; + } + } - ExportExternalRefCacheStyles(); + ExportExternalRefCacheStyles(); - if (!pSharedData) + if (!pSharedData) + { + sal_Int32 nTableCount(0); + sal_Int32 nShapesCount(0); + sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0); + CollectSharedData(nTableCount, nShapesCount, nCellCount); + //DBG_ERROR("no shared data setted"); + } + sal_Int32 nTableCount(xIndex->getCount()); + pCellStyles->AddNewTable(nTableCount - 1); + CollectShapesAutoStyles(nTableCount); + for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable) + { + bool bUseStream = pSheetData && pDoc && pDoc->IsStreamValid((SCTAB)nTable) && + pSheetData->HasStreamPos(nTable) && xSourceStream.is(); + + uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); + if (xTable.is()) + { + // table styles array must be complete, including copied tables - Add should find the stored style + uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY); + if (xTableProperties.is()) + { + std::vector<XMLPropertyState> xPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties)); + if(xPropStates.size()) { - sal_Int32 nTableCount(0); - sal_Int32 nShapesCount(0); - sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0); - CollectSharedData(nTableCount, nShapesCount, nCellCount); - //DBG_ERROR("no shared data setted"); + rtl::OUString sParent; + rtl::OUString sName; + GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_TABLE, sParent, xPropStates); + aTableStyles.push_back(sName); } - sal_Int32 nTableCount(xIndex->getCount()); - pCellStyles->AddNewTable(nTableCount - 1); - CollectShapesAutoStyles(nTableCount); - for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable) + } + } + // collect other auto-styles only for non-copied sheets + if (xTable.is() && !bUseStream) + { + uno::Reference<sheet::XUniqueCellFormatRangesSupplier> xCellFormatRanges ( xTable, uno::UNO_QUERY ); + if ( xCellFormatRanges.is() ) + { + uno::Reference<container::XIndexAccess> xFormatRangesIndex(xCellFormatRanges->getUniqueCellFormatRanges()); + if (xFormatRangesIndex.is()) { - bool bUseStream = pSheetData && pDoc && pDoc->IsStreamValid((SCTAB)nTable) && - pSheetData->HasStreamPos(nTable) && xSourceStream.is(); - - uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); - if (xTable.is()) + sal_Int32 nFormatRangesCount(xFormatRangesIndex->getCount()); + GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nFormatRangesCount); + for (sal_Int32 nFormatRange = 0; nFormatRange < nFormatRangesCount; ++nFormatRange) { - // table styles array must be complete, including copied tables - Add should find the stored style - uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY); - if (xTableProperties.is()) + uno::Reference< sheet::XSheetCellRanges> xCellRanges(xFormatRangesIndex->getByIndex(nFormatRange), uno::UNO_QUERY); + if (xCellRanges.is()) { - std::vector<XMLPropertyState> xPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties)); - if(xPropStates.size()) + uno::Reference <beans::XPropertySet> xProperties (xCellRanges, uno::UNO_QUERY); + if (xProperties.is()) { - rtl::OUString sParent; - rtl::OUString sName; - GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_TABLE, sParent, xPropStates); - aTableStyles.push_back(sName); + AddStyleFromCells(xProperties, xTable, nTable, NULL); + IncrementProgressBar(sal_False); } } } - // collect other auto-styles only for non-copied sheets - if (xTable.is() && !bUseStream) + } + } + uno::Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY); + if (xColumnRowRange.is()) + { + if (pDoc) + { + pDoc->SyncColRowFlags(); + uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns()); + if (xTableColumns.is()) { - uno::Reference<sheet::XUniqueCellFormatRangesSupplier> xCellFormatRanges ( xTable, uno::UNO_QUERY ); - if ( xCellFormatRanges.is() ) + sal_Int32 nColumns(pDoc->GetLastChangedCol(sal::static_int_cast<SCTAB>(nTable))); + pSharedData->SetLastColumn(nTable, nColumns); + table::CellRangeAddress aCellAddress(GetEndAddress(xTable, nTable)); + if (aCellAddress.EndColumn > nColumns) { - uno::Reference<container::XIndexAccess> xFormatRangesIndex(xCellFormatRanges->getUniqueCellFormatRanges()); - if (xFormatRangesIndex.is()) - { - sal_Int32 nFormatRangesCount(xFormatRangesIndex->getCount()); - GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nFormatRangesCount); - for (sal_Int32 nFormatRange = 0; nFormatRange < nFormatRangesCount; ++nFormatRange) - { - uno::Reference< sheet::XSheetCellRanges> xCellRanges(xFormatRangesIndex->getByIndex(nFormatRange), uno::UNO_QUERY); - if (xCellRanges.is()) - { - uno::Reference <beans::XPropertySet> xProperties (xCellRanges, uno::UNO_QUERY); - if (xProperties.is()) - { - AddStyleFromCells(xProperties, xTable, nTable, NULL); - IncrementProgressBar(sal_False); - } - } - } - } + ++nColumns; + pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn); } - uno::Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY); - if (xColumnRowRange.is()) +// else if (nColumns < MAXCOL) +// pColumnStyles->AddNewTable(nTable, ++nColumns); + else + pColumnStyles->AddNewTable(nTable, nColumns); + sal_Int32 nColumn = 0; + while (/*nColumn <= nColumns && */nColumn <= MAXCOL) { - if (pDoc) + sal_Int32 nIndex(-1); + sal_Bool bIsVisible(sal_True); + uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY); + if (xColumnProperties.is()) { - uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns()); - if (xTableColumns.is()) - { - sal_Int32 nColumns(pDoc->GetLastChangedCol(sal::static_int_cast<SCTAB>(nTable))); - pSharedData->SetLastColumn(nTable, nColumns); - table::CellRangeAddress aCellAddress(GetEndAddress(xTable, nTable)); - if (aCellAddress.EndColumn > nColumns) - { - ++nColumns; - pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn); - } - // else if (nColumns < MAXCOL) - // pColumnStyles->AddNewTable(nTable, ++nColumns); - else - pColumnStyles->AddNewTable(nTable, nColumns); - sal_Int32 nColumn = 0; - while (/*nColumn <= nColumns && */nColumn <= MAXCOL) - { - sal_Int32 nIndex(-1); - sal_Bool bIsVisible(sal_True); - uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY); - if (xColumnProperties.is()) - { - AddStyleFromColumn( xColumnProperties, NULL, nIndex, bIsVisible ); - //if(xPropStates.size()) - pColumnStyles->AddFieldStyleName(nTable, nColumn, nIndex, bIsVisible); - } - sal_Int32 nOld(nColumn); - nColumn = pDoc->GetNextDifferentChangedCol(sal::static_int_cast<SCTAB>(nTable), static_cast<USHORT>(nColumn)); - for (sal_Int32 i = nOld + 1; i < nColumn; ++i) - pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible); - } - if (aCellAddress.EndColumn > nColumns) - { - sal_Bool bIsVisible(sal_True); - sal_Int32 nIndex(pColumnStyles->GetStyleNameIndex(nTable, nColumns, bIsVisible)); - for (sal_Int32 i = nColumns + 1; i <= aCellAddress.EndColumn; ++i) - pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible); - } - } - uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows()); - if (xTableRows.is()) - { - sal_Int32 nRows(pDoc->GetLastChangedRow(sal::static_int_cast<SCTAB>(nTable))); - pSharedData->SetLastRow(nTable, nRows); - table::CellRangeAddress aCellAddress(GetEndAddress(xTable, nTable)); - if (aCellAddress.EndRow > nRows) - { - ++nRows; - pRowStyles->AddNewTable(nTable, aCellAddress.EndRow); - } - // else if (nRows < MAXROW) - // pRowStyles->AddNewTable(nTable, ++nRows); - else - pRowStyles->AddNewTable(nTable, nRows); - sal_Int32 nRow = 0; - while ( /*nRow <= nRows && */nRow <= MAXROW) - { - sal_Int32 nIndex = 0; - uno::Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY); - if(xRowProperties.is()) - { - AddStyleFromRow( xRowProperties, NULL, nIndex ); - //if(xPropStates.size()) - pRowStyles->AddFieldStyleName(nTable, nRow, nIndex); - } - sal_Int32 nOld(nRow); - nRow = pDoc->GetNextDifferentChangedRow(sal::static_int_cast<SCTAB>(nTable), static_cast<USHORT>(nRow), false); - for (sal_Int32 i = nOld + 1; i < nRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); - } - if (aCellAddress.EndRow > nRows) - { - sal_Int32 nIndex(pRowStyles->GetStyleNameIndex(nTable, nRows)); - for (sal_Int32 i = nRows + 1; i <= aCellAddress.EndRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); - } - } + AddStyleFromColumn( xColumnProperties, NULL, nIndex, bIsVisible ); + //if(xPropStates.size()) + pColumnStyles->AddFieldStyleName(nTable, nColumn, nIndex, bIsVisible); } + sal_Int32 nOld(nColumn); + nColumn = pDoc->GetNextDifferentChangedCol(sal::static_int_cast<SCTAB>(nTable), static_cast<SCCOL>(nColumn)); + for (sal_Int32 i = nOld + 1; i < nColumn; ++i) + pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible); } - uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery (xTable, uno::UNO_QUERY); - if (xCellRangesQuery.is()) + if (aCellAddress.EndColumn > nColumns) + { + sal_Bool bIsVisible(sal_True); + sal_Int32 nIndex(pColumnStyles->GetStyleNameIndex(nTable, nColumns, bIsVisible)); + for (sal_Int32 i = nColumns + 1; i <= aCellAddress.EndColumn; ++i) + pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible); + } + } + uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows()); + if (xTableRows.is()) + { + sal_Int32 nRows(pDoc->GetLastChangedRow(sal::static_int_cast<SCTAB>(nTable))); + pSharedData->SetLastRow(nTable, nRows); + table::CellRangeAddress aCellAddress(GetEndAddress(xTable, nTable)); + if (aCellAddress.EndRow > nRows) + { + ++nRows; + pRowStyles->AddNewTable(nTable, aCellAddress.EndRow); + } +// else if (nRows < MAXROW) +// pRowStyles->AddNewTable(nTable, ++nRows); + else + pRowStyles->AddNewTable(nTable, nRows); + sal_Int32 nRow = 0; + while (nRow <= nRows && nRow <= MAXROW) { - uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(xCellRangesQuery->queryContentCells(sheet::CellFlags::FORMATTED)); - uno::Reference<sheet::XSheetOperation> xSheetOperation(xSheetCellRanges, uno::UNO_QUERY); - if (xSheetCellRanges.is() && xSheetOperation.is()) + sal_Int32 nIndex = 0; + uno::Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY); + if(xRowProperties.is()) { - sal_uInt32 nCount(sal_uInt32(xSheetOperation->computeFunction(sheet::GeneralFunction_COUNT))); - uno::Reference<container::XEnumerationAccess> xCellsAccess(xSheetCellRanges->getCells()); - if (xCellsAccess.is()) - { - GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCount); - uno::Reference<container::XEnumeration> xCells(xCellsAccess->createEnumeration()); - if (xCells.is()) - { - sal_uInt32 nCount2(0); - while (xCells->hasMoreElements()) - { - uno::Reference<text::XText> xText(xCells->nextElement(), uno::UNO_QUERY); - if (xText.is()) - GetTextParagraphExport()->collectTextAutoStyles(xText, sal_False, sal_False); - ++nCount2; - IncrementProgressBar(sal_False); - } - if(nCount2 > nCount) - GetProgressBarHelper()->SetReference(GetProgressBarHelper()->GetReference() + nCount2 - nCount); - } - } + AddStyleFromRow( xRowProperties, NULL, nIndex ); + //if(xPropStates.size()) + pRowStyles->AddFieldStyleName(nTable, nRow, nIndex); } + sal_Int32 nOld(nRow); + nRow = pDoc->GetNextDifferentChangedRow(sal::static_int_cast<SCTAB>(nTable), static_cast<SCROW>(nRow), false); + for (sal_Int32 i = nOld + 1; i < nRow; ++i) + pRowStyles->AddFieldStyleName(nTable, i, nIndex); + } + if (aCellAddress.EndRow > nRows) + { + sal_Int32 nIndex(pRowStyles->GetStyleNameIndex(nTable, nRows)); + for (sal_Int32 i = nRows + 1; i <= aCellAddress.EndRow; ++i) + pRowStyles->AddFieldStyleName(nTable, i, nIndex); } } - IncrementProgressBar(sal_False); } - pChangeTrackingExportHelper->CollectAutoStyles(); - - GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN, - GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); - GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW, - GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); - GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE, - GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); - exportAutoDataStyles(); - GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL, - GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); - - GetShapeExport()->exportAutoStyles(); - GetFormExport()->exportAutoStyles( ); - - if (pDoc) + } + uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery (xTable, uno::UNO_QUERY); + if (xCellRangesQuery.is()) + { + uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(xCellRangesQuery->queryContentCells(sheet::CellFlags::FORMATTED)); + uno::Reference<sheet::XSheetOperation> xSheetOperation(xSheetCellRanges, uno::UNO_QUERY); + if (xSheetCellRanges.is() && xSheetOperation.is()) { - ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager(); - // #i100879# write the table style for cached tables only if there are cached tables - // (same logic as in ExportExternalRefCacheStyles) - if (pRefMgr->hasExternalData()) + sal_uInt32 nCount(sal_uInt32(xSheetOperation->computeFunction(sheet::GeneralFunction_COUNT))); + uno::Reference<container::XEnumerationAccess> xCellsAccess(xSheetCellRanges->getCells()); + if (xCellsAccess.is()) { - // Special table style for the external ref cache tables. - AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, sExternalRefTabStyleName); - AddAttribute(XML_NAMESPACE_STYLE, XML_FAMILY, XML_TABLE); - SvXMLElementExport aElemStyle(*this, XML_NAMESPACE_STYLE, XML_STYLE, sal_True, sal_True); - AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE); - SvXMLElementExport aElemStyleTabProps(*this, XML_NAMESPACE_STYLE, XML_TABLE_PROPERTIES, sal_True, sal_True); + GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCount); + uno::Reference<container::XEnumeration> xCells(xCellsAccess->createEnumeration()); + if (xCells.is()) + { + sal_uInt32 nCount2(0); + while (xCells->hasMoreElements()) + { + uno::Reference<text::XText> xText(xCells->nextElement(), uno::UNO_QUERY); + if (xText.is()) + GetTextParagraphExport()->collectTextAutoStyles(xText, sal_False, sal_False); + ++nCount2; + IncrementProgressBar(sal_False); + } + if(nCount2 > nCount) + GetProgressBarHelper()->SetReference(GetProgressBarHelper()->GetReference() + nCount2 - nCount); + } } } } - if (getExportFlags() & EXPORT_MASTERSTYLES) - { - GetPageExport()->collectAutoStyles(sal_True); - GetPageExport()->exportAutoStyles(); - } + } + IncrementProgressBar(sal_False); + } + pChangeTrackingExportHelper->CollectAutoStyles(); - // #i30251#; only write Text Styles once + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); + exportAutoDataStyles(); + GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL, + GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap()); - if ((getExportFlags() & EXPORT_CONTENT) || (getExportFlags() & EXPORT_MASTERSTYLES)) - GetTextParagraphExport()->exportTextAutoStyles(); + GetShapeExport()->exportAutoStyles(); + GetFormExport()->exportAutoStyles( ); + + if (pDoc) + { + ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager(); + // #i100879# write the table style for cached tables only if there are cached tables + // (same logic as in ExportExternalRefCacheStyles) + if (pRefMgr->hasExternalData()) + { + // Special table style for the external ref cache tables. + AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, sExternalRefTabStyleName); + AddAttribute(XML_NAMESPACE_STYLE, XML_FAMILY, XML_TABLE); + SvXMLElementExport aElemStyle(*this, XML_NAMESPACE_STYLE, XML_STYLE, sal_True, sal_True); + AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE); + SvXMLElementExport aElemStyleTabProps(*this, XML_NAMESPACE_STYLE, XML_TABLE_PROPERTIES, sal_True, sal_True); } } } + + if (getExportFlags() & EXPORT_MASTERSTYLES) + { + GetPageExport()->collectAutoStyles(sal_True); + GetPageExport()->exportAutoStyles(); + } + + // #i30251#; only write Text Styles once + + if ((getExportFlags() & EXPORT_CONTENT) || (getExportFlags() & EXPORT_MASTERSTYLES)) + GetTextParagraphExport()->exportTextAutoStyles(); } void ScXMLExport::_ExportMasterStyles() @@ -3077,32 +3080,69 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, if ( sCLSID.equalsIgnoreAsciiCase(GetChartExport()->getChartCLSID()) ) { // we have a chart - uno::Reference< frame::XModel > xChartModel; - if( ( xShapeProps->getPropertyValue( sPropModel ) >>= xChartModel ) && - xChartModel.is()) + ::rtl::OUString sRanges; + if ( pDoc ) + { + ::rtl::OUString aChartName; + xShapeProps->getPropertyValue( sPersistName ) >>= aChartName; + ScRange aEmptyRange; + ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); + USHORT nIndex = 0; + ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); + if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) + { + ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); + if ( pListener ) + { + const ScRangeListRef& rRangeList = pListener->GetRangeList(); + if ( rRangeList.Is() ) + { + ScRangeStringConverter::GetStringFromRangeList( sRanges, rRangeList, pDoc, FormulaGrammar::CONV_OOO ); + if ( sRanges.getLength() > 0 ) + { + bIsChart = true; + SvXMLAttributeList* pAttrList = new SvXMLAttributeList(); + if ( pAttrList ) + { + pAttrList->AddAttribute( + GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges ); + } + GetShapeExport()->exportShape( xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList ); + } + } + } + } + } + + if ( sRanges.getLength() == 0 ) { - uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); - uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY ); - if( xChartDoc.is() && xReceiver.is() && - ! xChartDoc->hasInternalDataProvider()) + uno::Reference< frame::XModel > xChartModel; + if( ( xShapeProps->getPropertyValue( sPropModel ) >>= xChartModel ) && + xChartModel.is()) { - // we have a chart that gets its data from Calc - bIsChart = true; - uno::Sequence< ::rtl::OUString > aRepresentations( - xReceiver->getUsedRangeRepresentations()); - SvXMLAttributeList* pAttrList = 0; - if(aRepresentations.getLength()) + uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is() && xReceiver.is() && + ! xChartDoc->hasInternalDataProvider()) { - // add the ranges used by the chart to the shape - // element to be able to start listening after - // load (when the chart is not yet loaded) - uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - ::rtl::OUString sRanges( lcl_RangeSequenceToString( aRepresentations, xRangeConverter )); - pAttrList = new SvXMLAttributeList(); - pAttrList->AddAttribute( - GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + // we have a chart that gets its data from Calc + bIsChart = true; + uno::Sequence< ::rtl::OUString > aRepresentations( + xReceiver->getUsedRangeRepresentations()); + SvXMLAttributeList* pAttrList = 0; + if(aRepresentations.getLength()) + { + // add the ranges used by the chart to the shape + // element to be able to start listening after + // load (when the chart is not yet loaded) + uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter ); + pAttrList = new SvXMLAttributeList(); + pAttrList->AddAttribute( + GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + } + GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList); } - GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList); } } diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index b9e5238508d8..269e1dd9a7e4 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -700,12 +700,12 @@ const SvXMLTokenMap& ScXMLImport::GetTableAttrTokenMap() { static __FAR_DATA SvXMLTokenMapEntry aTableAttrTokenMap[] = { - { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_NAME }, - { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, - { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_PROTECTION }, - { XML_NAMESPACE_TABLE, XML_PRINT_RANGES, XML_TOK_TABLE_PRINT_RANGES }, - { XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, XML_TOK_TABLE_PASSWORD }, - { XML_NAMESPACE_TABLE, XML_PRINT, XML_TOK_TABLE_PRINT }, + { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_TABLE_NAME }, + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_PROTECTION }, + { XML_NAMESPACE_TABLE, XML_PRINT_RANGES, XML_TOK_TABLE_PRINT_RANGES }, + { XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, XML_TOK_TABLE_PASSWORD }, + { XML_NAMESPACE_TABLE, XML_PRINT, XML_TOK_TABLE_PRINT }, XML_TOKEN_MAP_END }; diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx index 733a11c9a1da..4127f5246428 100644 --- a/sc/source/filter/xml/xmlstyle.cxx +++ b/sc/source/filter/xml/xmlstyle.cxx @@ -66,6 +66,7 @@ using namespace ::formula; using ::rtl::OUString; #define MAP(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_010 } +#define MAP_EXT(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_LATEST } #define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0, 0, SvtSaveOptions::ODFVER_010 } const XMLPropertyMapEntry aXMLScCellStylesProperties[] = @@ -161,6 +162,8 @@ const XMLPropertyMapEntry aXMLScTableStylesImportProperties[] = MAP( "IsVisible", XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TYPE_PROP_TABLE|XML_TYPE_BOOL, 0 ), MAP( "PageStyle", XML_NAMESPACE_STYLE, XML_MASTER_PAGE_NAME, XML_TYPE_PROP_TABLE|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_MASTERPAGENAME ), MAP( "TableLayout", XML_NAMESPACE_STYLE, XML_WRITING_MODE, XML_TYPE_PROP_TABLE|XML_TYPE_TEXT_WRITING_MODE, 0 ), + MAP( "TabColor", XML_NAMESPACE_TABLE, XML_TAB_COLOR, XML_TYPE_PROP_TABLE|XML_TYPE_COLORAUTO, 0 ), + MAP_EXT( "TabColor", XML_NAMESPACE_TABLE_EXT, XML_TAB_COLOR, XML_TYPE_PROP_TABLE|XML_TYPE_COLORAUTO, 0 ), MAP_END() }; @@ -169,6 +172,7 @@ const XMLPropertyMapEntry aXMLScTableStylesProperties[] = MAP( "IsVisible", XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TYPE_PROP_TABLE|XML_TYPE_BOOL, 0 ), MAP( "PageStyle", XML_NAMESPACE_STYLE, XML_MASTER_PAGE_NAME, XML_TYPE_PROP_TABLE|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_MASTERPAGENAME ), MAP( "TableLayout", XML_NAMESPACE_STYLE, XML_WRITING_MODE, XML_TYPE_PROP_TABLE|XML_TYPE_TEXT_WRITING_MODE, 0 ), + MAP_EXT( "TabColor", XML_NAMESPACE_TABLE_EXT, XML_TAB_COLOR, XML_TYPE_PROP_TABLE|XML_TYPE_COLORAUTO, 0 ), MAP_END() }; diff --git a/sc/source/ui/Accessibility/AccessibleCellBase.cxx b/sc/source/ui/Accessibility/AccessibleCellBase.cxx index 92ff551f2724..cc93d0a93350 100644 --- a/sc/source/ui/Accessibility/AccessibleCellBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleCellBase.cxx @@ -92,10 +92,12 @@ sal_Bool SAL_CALL ScAccessibleCellBase::isVisible( ) sal_Bool bVisible(sal_True); if (mpDoc) { - BYTE nColFlags = mpDoc->GetColFlags(maCellAddress.Col(), maCellAddress.Tab()); - BYTE nRowFlags = mpDoc->GetRowFlags(maCellAddress.Row(), maCellAddress.Tab()); - if (((nColFlags & CR_HIDDEN) == CR_HIDDEN) || ((nColFlags & CR_FILTERED) == CR_FILTERED) || - ((nRowFlags & CR_HIDDEN) == CR_HIDDEN) || ((nRowFlags & CR_FILTERED) == CR_FILTERED)) + bool bColHidden = mpDoc->ColHidden(maCellAddress.Col(), maCellAddress.Tab()); + bool bRowHidden = mpDoc->RowHidden(maCellAddress.Row(), maCellAddress.Tab()); + bool bColFiltered = mpDoc->ColFiltered(maCellAddress.Col(), maCellAddress.Tab()); + bool bRowFiltered = mpDoc->RowFiltered(maCellAddress.Row(), maCellAddress.Tab()); + + if (bColHidden || bColFiltered || bRowHidden || bRowFiltered) bVisible = sal_False; } return bVisible; diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx b/sc/source/ui/Accessibility/AccessibleContextBase.cxx index e438224ecfb6..0f1fcfa337a5 100644 --- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx @@ -626,7 +626,3 @@ void ScAccessibleContextBase::IsObjectValid() const throw lang::DisposedException(); } -void ScAccessibleContextBase::SetRole(sal_Int16 nRole) -{ - maRole = nRole; -} diff --git a/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx b/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx index f536b8b9a8f7..2af69faa33c8 100644 --- a/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx +++ b/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx @@ -99,13 +99,6 @@ OUString ScAccessibleFilterTopWindow::getImplementationName() throw (RuntimeExce return OUString::createFromAscii("ScAccessibleFilterTopWindow"); } -Reference<XAccessible> ScAccessibleFilterTopWindow::getAccessibleChildMenu() -{ - if (!mxAccMenu.is()) - mxAccMenu.set(new ScAccessibleFilterMenu(this, mpWindow, getAccessibleName(), ScMenuFloatingWindow::MENU_NOT_SELECTED, mpDoc)); - return mxAccMenu; -} - void ScAccessibleFilterTopWindow::setAccessibleChild( const Reference<XAccessible>& rAccessible, ChildControlType eType) { diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index f6fc2cb27b71..2cabe7f9f2d6 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -289,7 +289,7 @@ sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const SCROW nRow(pRange->aStart.Row()); while (!bSubTotal && nRow <= nRowEnd) { - if (pDoc->IsFiltered(nRow, nTab)) + if (pDoc->RowFiltered(nRow, nTab)) bSubTotal = sal_True; else ++nRow; diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 94e18def8a11..272852efcf71 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -1908,21 +1908,19 @@ IMPL_LINK( ScModule, IdleHandler, Timer*, EMPTYARG ) if ( pDocSh ) { ScDocument* pDoc = pDocSh->GetDocument(); - if ( pDoc->IsLoadingDone() ) - { - BOOL bLinks = pDoc->IdleCheckLinks(); - BOOL bWidth = pDoc->IdleCalcTextWidth(); - BOOL bSpell = pDoc->ContinueOnlineSpelling(); - if ( bSpell ) - aSpellTimer.Start(); // da ist noch was - - bMore = bLinks || bWidth || bSpell; // ueberhaupt noch was? - - // While calculating a Basic formula, a paint event may have occured, - // so check the bNeedsRepaint flags for this document's views - if (bWidth) - lcl_CheckNeedsRepaint( pDocSh ); - } + + BOOL bLinks = pDoc->IdleCheckLinks(); + BOOL bWidth = pDoc->IdleCalcTextWidth(); + BOOL bSpell = pDoc->ContinueOnlineSpelling(); + if ( bSpell ) + aSpellTimer.Start(); // da ist noch was + + bMore = bLinks || bWidth || bSpell; // ueberhaupt noch was? + + // While calculating a Basic formula, a paint event may have occured, + // so check the bNeedsRepaint flags for this document's views + if (bWidth) + lcl_CheckNeedsRepaint( pDocSh ); } ULONG nOldTime = aIdleTimer.GetTimeout(); @@ -2192,9 +2190,6 @@ IMPL_LINK( ScModule, CalcFieldValueHdl, EditFieldInfo*, pInfo ) return 0; } - - -//<!--Added by PengYunQuan for Validity Cell Range Picker BOOL ScModule::RegisterRefWindow( USHORT nSlotId, Window *pWnd ) { std::list<Window*> & rlRefWindow = m_mapRefWindow[nSlotId]; @@ -2244,10 +2239,13 @@ BOOL ScModule::IsAliveRefDlg( USHORT nSlotId, Window *pWnd ) Window * ScModule::Find1RefWindow( USHORT nSlotId, Window *pWndAncestor ) { + if (!pWndAncestor) + return NULL; + std::map<USHORT, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId ); if( iSlot == m_mapRefWindow.end() ) - return FALSE; + return NULL; std::list<Window*> & rlRefWindow = iSlot->second; @@ -2262,6 +2260,9 @@ Window * ScModule::Find1RefWindow( USHORT nSlotId, Window *pWndAncestor ) Window * ScModule::Find1RefWindow( Window *pWndAncestor ) { + if (!pWndAncestor) + return NULL; + while( Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent; for( std::map<USHORT, std::list<Window*> >::iterator i = m_mapRefWindow.begin(); @@ -2272,4 +2273,4 @@ Window * ScModule::Find1RefWindow( Window *pWndAncestor ) return NULL; } -//<!--Added by PengYunQuan for Validity Cell Range Picker + diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index a5b286e8a9ea..4b268b9da791 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -602,25 +602,23 @@ void ScTransferObj::InitDocShell() // widths / heights // (must be copied before CopyFromClip, for drawing objects) - SCCOL nCol; - SCROW nRow; + SCCOL nCol, nLastCol; SCTAB nSrcTab = aBlock.aStart.Tab(); pDestDoc->SetLayoutRTL(0, pDoc->IsLayoutRTL(nSrcTab)); for (nCol=nStartX; nCol<=nEndX; nCol++) - if ( pDoc->GetColFlags( nCol, nSrcTab ) & CR_HIDDEN ) + if ( pDoc->ColHidden(nCol, nSrcTab, nLastCol) ) pDestDoc->ShowCol( nCol, 0, FALSE ); else pDestDoc->SetColWidth( nCol, 0, pDoc->GetColWidth( nCol, nSrcTab ) ); ScBitMaskCompressedArray< SCROW, BYTE> & rDestRowFlags = pDestDoc->GetRowFlagsArrayModifiable(0); - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray( - nSrcTab), nStartY, nEndY); - for ( ; aIter; ++aIter ) + + for (SCROW nRow = nStartY; nRow <= nEndY; ++nRow) { - nRow = aIter.GetPos(); - BYTE nSourceFlags = *aIter; - if ( nSourceFlags & CR_HIDDEN ) + BYTE nSourceFlags = pDoc->GetRowFlags(nRow, nSrcTab); + SCROW nLastRow = -1; + if ( pDoc->RowHidden(nRow, nSrcTab, nLastRow) ) pDestDoc->ShowRow( nRow, 0, FALSE ); else { @@ -684,7 +682,7 @@ void ScTransferObj::InitDocShell() for (nCol=0; nCol<nStartX; nCol++) nPosX += pDestDoc->GetColWidth( nCol, 0 ); - nPosY += pDestDoc->FastGetRowHeight( 0, nStartY-1, 0 ); + nPosY += pDestDoc->GetRowHeight( 0, nStartY-1, 0 ); nPosX = (long) ( nPosX * HMM_PER_TWIPS ); nPosY = (long) ( nPosY * HMM_PER_TWIPS ); @@ -701,9 +699,9 @@ void ScTransferObj::InitDocShell() break; nSizeX += nAdd; } - for (nRow=nStartY; nRow<=nEndY; nRow++) + for (SCROW nRow=nStartY; nRow<=nEndY; nRow++) { - long nAdd = pDestDoc->FastGetRowHeight( nRow, 0 ); + long nAdd = pDestDoc->GetRowHeight( nRow, 0 ); if ( nSizeY+nAdd > aPaperSize.Height() && nSizeY ) // above limit? break; nSizeY += nAdd; diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 0af2c30d628f..73a5f1a1c4ee 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -62,6 +62,7 @@ #include "scendlg.hxx" //add for ScNewScenarioDlg #include "shtabdlg.hxx" //add for ScShowTabDlg #include "strindlg.hxx" //add for ScStringInputDlg +#include "tabbgcolordlg.hxx"//add for ScTabBgColorDlg #include "scuiimoptdlg.hxx" //add for ScImportOptionsDlg #include "attrdlg.hxx" //add for ScAttrDlg #include "hfedtdlg.hxx" //add for ScHFEditDlg @@ -112,6 +113,7 @@ IMPL_ABSTDLG_BASE(AbstractScDPShowDetailDlg_Impl); //add for ScDPShowDetailDlg IMPL_ABSTDLG_BASE(AbstractScNewScenarioDlg_Impl); //add for ScNewScenarioDlg IMPL_ABSTDLG_BASE(AbstractScShowTabDlg_Impl); //add for ScShowTabDlg IMPL_ABSTDLG_BASE(AbstractScStringInputDlg_Impl); //add for ScStringInputDlg +IMPL_ABSTDLG_BASE(AbstractScTabBgColorDlg_Impl); //add for ScTabBgColorDlg IMPL_ABSTDLG_BASE(AbstractScImportOptionsDlg_Impl); //add for ScImportOptionsDlg IMPL_ABSTDLG_BASE(AbstractScTextImportOptionsDlg_Impl); IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); //add for ScAttrDlg, ScHFEditDlg, ScStyleDlg, ScSubTotalDlg,ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg @@ -618,6 +620,14 @@ void AbstractScStringInputDlg_Impl::GetInputString( String& rString ) const //a } //add for AbstractScStringInputDlg_Impl end +//add for AbstractScTabBgColorDlg_Impl begin +void AbstractScTabBgColorDlg_Impl::GetSelectedColor( Color& rColor ) const //add for ScTabBgColorDlg +{ + pDlg->GetSelectedColor( rColor ); +} +//add for AbstractScTabBgColorDlg_Impl end + + //add for AbstractScImportOptionsDlg_Impl begin void AbstractScImportOptionsDlg_Impl::GetImportOptions( ScImportOptions& rOptions ) const //add for ScImportOptionsDlg { @@ -1293,6 +1303,31 @@ AbstractScShowTabDlg * ScAbstractDialogFactory_Impl::CreateScShowTabDlg ( Window } //add for ScStringInputDlg end +//add for ScTabBgColorDlg begin +AbstractScTabBgColorDlg * ScAbstractDialogFactory_Impl::CreateScTabBgColorDlg ( + Window* pParent, + const String& rTitle, + const String& rTabBgColorNoColorText, + const Color& rDefaultColor, + ULONG nHelpId , + int nId ) +{ +ScTabBgColorDlg * pDlg=NULL; +switch ( nId ) +{ + case RID_SCDLG_TAB_BG_COLOR : + pDlg = new ScTabBgColorDlg( pParent, rTitle, rTabBgColorNoColorText, rDefaultColor, nHelpId ); + break; + default: + break; +} + +if ( pDlg ) + return new AbstractScTabBgColorDlg_Impl( pDlg ); +return 0; +} +//add for ScTabBgColorDlg end + //add for ScImportOptionsDlg begin AbstractScImportOptionsDlg * ScAbstractDialogFactory_Impl::CreateScImportOptionsDlg ( Window* pParent, int nId, diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index d9752c83da9a..cd0f79dd1598 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -58,6 +58,7 @@ class ScDPShowDetailDlg; class ScNewScenarioDlg; class ScShowTabDlg; class ScStringInputDlg; +class ScTabBgColorDlg; class ScImportOptionsDlg; class SfxTabDialog; class ScSortWarningDlg; @@ -336,6 +337,12 @@ class AbstractScStringInputDlg_Impl : public AbstractScStringInputDlg //add fo virtual void GetInputString( String& rString ) const; }; +class AbstractScTabBgColorDlg_Impl : public AbstractScTabBgColorDlg //add for ScTabBgColorDlg +{ + DECL_ABSTDLG_BASE( AbstractScTabBgColorDlg_Impl, ScTabBgColorDlg ) + virtual void GetSelectedColor( Color& rColor ) const; +}; + class AbstractScImportOptionsDlg_Impl : public AbstractScImportOptionsDlg //add for ScImportOptionsDlg { DECL_ABSTDLG_BASE( AbstractScImportOptionsDlg_Impl, ScImportOptionsDlg) @@ -519,6 +526,14 @@ public: const String& rDefault, ULONG nHelpId , int nId ); + + virtual AbstractScTabBgColorDlg * CreateScTabBgColorDlg ( Window* pParent, //add for ScStringInputDlg + const String& rTitle, //Dialog Title + const String& rTabBgColorNoColorText, //Label for no tab color + const Color& rDefaultColor, //Currently selected Color + ULONG nHelpId , + int nId ); + virtual AbstractScImportOptionsDlg * CreateScImportOptionsDlg ( Window* pParent, //add for ScImportOptionsDlg int nId, BOOL bAscii = TRUE, diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index fa14a5497826..52aae575b7d7 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -169,11 +169,6 @@ void ScDPFieldButton::getPopupBoundingBox(Point& rPos, Size& rSize) const rSize.setHeight(nH); } -bool ScDPFieldButton::isPopupButton() const -{ - return mbPopupButton; -} - void ScDPFieldButton::drawPopupButton() { Point aPos; @@ -732,27 +727,6 @@ ScMenuFloatingWindow* ScMenuFloatingWindow::getSubMenuWindow(size_t nPos) const return maMenuItems[nPos].mpSubMenuWin.get(); } -size_t ScMenuFloatingWindow::getMenuItemCount() const -{ - return maMenuItems.size(); -} - -OUString ScMenuFloatingWindow::getMenuItemName(size_t nPos) const -{ - if (maMenuItems.size() <= nPos) - return ScGlobal::GetEmptyString(); - - return maMenuItems[nPos].maText; -} - -bool ScMenuFloatingWindow::isMenuItemEnabled(size_t nPos) const -{ - if (maMenuItems.size() <= nPos) - return false; - - return maMenuItems[nPos].mbEnabled; -} - bool ScMenuFloatingWindow::isMenuItemSelected(size_t nPos) const { return nPos == mnSelectedMenu; diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index cd1f85fb99cc..a22953ade25b 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -253,20 +253,13 @@ void ScAsciiOptions::ReadFromString( const String& rString ) eCharSet = ScGlobal::GetCharsetValue( aToken ); } - // Language - if (nCount >= 4) - { - aToken = rString.GetToken(3, ','); - eLang = static_cast<LanguageType>(aToken.ToInt32()); - } - // // Startzeile // - if ( nCount >= 5 ) + if ( nCount >= 4 ) { - aToken = rString.GetToken(4,','); + aToken = rString.GetToken(3,','); nStartRow = aToken.ToInt32(); } @@ -274,12 +267,12 @@ void ScAsciiOptions::ReadFromString( const String& rString ) // Spalten-Infos // - if ( nCount >= 6 ) + if ( nCount >= 5 ) { delete[] pColStart; delete[] pColFormat; - aToken = rString.GetToken(5,','); + aToken = rString.GetToken(4,','); nSub = aToken.GetTokenCount('/'); nInfoCount = nSub / 2; if (nInfoCount) @@ -299,6 +292,13 @@ void ScAsciiOptions::ReadFromString( const String& rString ) } } + // Language + if (nCount >= 6) + { + aToken = rString.GetToken(5, ','); + eLang = static_cast<LanguageType>(aToken.ToInt32()); + } + // Import quoted field as text. if (nCount >= 7) { @@ -362,10 +362,6 @@ String ScAsciiOptions::WriteToString() const aOutStr += ScGlobal::GetCharsetString( eCharSet ); aOutStr += ','; // Token-Ende - // Language - aOutStr += String::CreateFromInt32(eLang); - aOutStr += ','; - // // Startzeile // @@ -387,6 +383,13 @@ String ScAsciiOptions::WriteToString() const aOutStr += String::CreateFromInt32(pColFormat[nInfo]); } + // #i112025# the options string is used in macros and linked sheets, + // so new options must be added at the end, to remain compatible + + aOutStr += ','; + + // Language + aOutStr += String::CreateFromInt32(eLang); aOutStr += ','; // Import quoted field as text. diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 9895f0f43610..cf149d258062 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -937,7 +937,10 @@ BOOL ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam, } if (!bCopy) + { + pDoc->InvalidatePageBreaks(nTab); pDoc->UpdatePageBreaks( nTab ); + } // #i23299# because of Subtotal functions, the whole rows must be set dirty ScRange aDirtyRange( 0 , aLocalParam.nRow1, nDestTab, @@ -1275,6 +1278,13 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb // output range must be set at pNewObj pDestObj = new ScDPObject( *pNewObj ); + + // #i94570# When changing the output position in the dialog, a new table is created + // with the settings from the old table, including the name. + // So we have to check for duplicate names here (before inserting). + if ( pDoc->GetDPCollection()->GetByName(pDestObj->GetName()) ) + pDestObj->SetName( String() ); // ignore the invalid name, create a new name below + pDestObj->SetAlive(TRUE); if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) ) { diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index b79f047562b1..36b6641d94a6 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2790,6 +2790,7 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ ) pUndoDoc->SetActiveScenario( nTab, bActive ); } pUndoDoc->SetVisible( nTab, pDoc->IsVisible( nTab ) ); + pUndoDoc->SetTabBgColor( nTab, pDoc->GetTabBgColor(nTab) ); pUndoDoc->SetSheetEvents( nTab, pDoc->GetSheetEvents( nTab ) ); // Drawing-Layer muss sein Undo selbst in der Hand behalten !!! @@ -2995,6 +2996,104 @@ BOOL ScDocFunc::RenameTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL return bSuccess; } +bool ScDocFunc::SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi ) +{ + + ScDocument* pDoc = rDocShell.GetDocument(); + if (bRecord && !pDoc->IsUndoEnabled()) + bRecord = false; + if ( !pDoc->IsDocEditable() || pDoc->IsTabProtected(nTab) ) + { + if (!bApi) + rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Check to see what this string is... + return false; + } + + Color aOldTabBgColor; + aOldTabBgColor = pDoc->GetTabBgColor(nTab); + + bool bSuccess = false; + pDoc->SetTabBgColor(nTab, rColor); + if ( pDoc->GetTabBgColor(nTab) == rColor) + bSuccess = true; + if (bSuccess) + { + if (bRecord) + { + rDocShell.GetUndoManager()->AddUndoAction( + new ScUndoTabColor( &rDocShell, nTab, aOldTabBgColor, rColor)); + } + rDocShell.PostPaintExtras(); + ScDocShellModificator aModificator( rDocShell ); + aModificator.SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + + bSuccess = true; + } + return bSuccess; +} + +bool ScDocFunc::SetTabBgColor( + ScUndoTabColorInfo::List& rUndoTabColorList, bool bRecord, bool bApi ) +{ + ScDocument* pDoc = rDocShell.GetDocument(); + if (bRecord && !pDoc->IsUndoEnabled()) + bRecord = false; + + if ( !pDoc->IsDocEditable() ) + { + if (!bApi) + rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error... + return false; + } + + USHORT nTab; + Color aNewTabBgColor; + bool bSuccess = true; + size_t nTabProtectCount = 0; + size_t nTabListCount = rUndoTabColorList.size(); + for ( size_t i = 0; i < nTabListCount; ++i ) + { + ScUndoTabColorInfo& rInfo = rUndoTabColorList[i]; + nTab = rInfo.mnTabId; + if ( !pDoc->IsTabProtected(nTab) ) + { + aNewTabBgColor = rInfo.maNewTabBgColor; + rInfo.maOldTabBgColor = pDoc->GetTabBgColor(nTab); + pDoc->SetTabBgColor(nTab, aNewTabBgColor); + if ( pDoc->GetTabBgColor(nTab) != aNewTabBgColor) + { + bSuccess = false; + break; + } + } + else + { + nTabProtectCount++; + } + } + + if ( nTabProtectCount == nTabListCount ) + { + if (!bApi) + rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error... + return false; + } + + if (bSuccess) + { + if (bRecord) + { + rDocShell.GetUndoManager()->AddUndoAction( + new ScUndoTabColor( &rDocShell, rUndoTabColorList)); + } + rDocShell.PostPaintExtras(); + ScDocShellModificator aModificator( rDocShell ); + aModificator.SetDocumentModified(); + } + return bSuccess; +} + //------------------------------------------------------------------------ //! SetWidthOrHeight - noch doppelt zu ViewFunc !!!!!! @@ -3097,7 +3196,9 @@ BOOL ScDocFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa for (SCROW nRow=nStartNo; nRow<=nEndNo; nRow++) { BYTE nOld = pDoc->GetRowFlags(nRow,nTab); - if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) ) + SCROW nLastRow = -1; + bool bHidden = pDoc->RowHidden(nRow, nTab, nLastRow); + if ( !bHidden && ( nOld & CR_MANUALSIZE ) ) pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE ); } } @@ -3132,8 +3233,8 @@ BOOL ScDocFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa { for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++) { - if ( eMode != SC_SIZE_VISOPT || - (pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0 ) + SCCOL nLastCol = -1; + if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab, nLastCol) ) { USHORT nThisSize = nSizeTwips; @@ -3203,20 +3304,22 @@ BOOL ScDocFunc::InsertPageBreak( BOOL bColumn, const ScAddress& rPos, if (nPos == 0) return FALSE; // erste Spalte / Zeile - BYTE nFlags = bColumn ? pDoc->GetColFlags( static_cast<SCCOL>(nPos), nTab ) - : pDoc->GetRowFlags( static_cast<SCROW>(nPos), nTab ); - if (nFlags & CR_MANUALBREAK) - return TRUE; // Umbruch schon gesetzt + ScBreakType nBreak = bColumn ? + pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab) : + pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab); + if (nBreak & BREAK_MANUAL) + return true; if (bRecord) rDocShell.GetUndoManager()->AddUndoAction( new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, TRUE ) ); - nFlags |= CR_MANUALBREAK; if (bColumn) - pDoc->SetColFlags( static_cast<SCCOL>(nPos), nTab, nFlags ); + pDoc->SetColBreak(static_cast<SCCOL>(nPos), nTab, false, true); else - pDoc->SetRowFlags( static_cast<SCROW>(nPos), nTab, nFlags ); + pDoc->SetRowBreak(static_cast<SCROW>(nPos), nTab, false, true); + + pDoc->InvalidatePageBreaks(nTab); pDoc->UpdatePageBreaks( nTab ); if (pDoc->IsStreamValid(nTab)) @@ -3262,20 +3365,25 @@ BOOL ScDocFunc::RemovePageBreak( BOOL bColumn, const ScAddress& rPos, SCCOLROW nPos = bColumn ? static_cast<SCCOLROW>(rPos.Col()) : static_cast<SCCOLROW>(rPos.Row()); - BYTE nFlags = bColumn ? pDoc->GetColFlags( static_cast<SCCOL>(nPos), nTab ) - : pDoc->GetRowFlags( static_cast<SCROW>(nPos), nTab ); - if ((nFlags & CR_MANUALBREAK)==0) - return FALSE; // kein Umbruch gesetzt + + ScBreakType nBreak; + if (bColumn) + nBreak = pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab); + else + nBreak = pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab); + if ((nBreak & BREAK_MANUAL) == 0) + // There is no manual break. + return false; if (bRecord) rDocShell.GetUndoManager()->AddUndoAction( new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, FALSE ) ); - nFlags &= ~CR_MANUALBREAK; if (bColumn) - pDoc->SetColFlags( static_cast<SCCOL>(nPos), nTab, nFlags ); + pDoc->RemoveColBreak(static_cast<SCCOL>(nPos), nTab, false, true); else - pDoc->SetRowFlags( static_cast<SCROW>(nPos), nTab, nFlags ); + pDoc->RemoveRowBreak(static_cast<SCROW>(nPos), nTab, false, true); + pDoc->UpdatePageBreaks( nTab ); if (pDoc->IsStreamValid(nTab)) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 5668dcfc72b9..335ee53e8c73 100644..100755 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -45,6 +45,7 @@ #include <svtools/ctrltool.hxx> #include <svtools/sfxecode.hxx> #include <svl/zforlist.hxx> +#include <svl/PasswordHelper.hxx> #include <sfx2/app.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dinfdlg.hxx> @@ -63,9 +64,12 @@ #include "chgtrack.hxx" #include "chgviset.hxx" #include <sfx2/request.hxx> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/script/vba/VBAEventId.hpp> #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/sheet/XSpreadsheetView.hpp> +#include <com/sun/star/task/XJob.hpp> #include <basic/sbstar.hxx> #include <basic/basmgr.hxx> #include <vbahelper/vbaaccesshelper.hxx> @@ -352,6 +356,20 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) // else; nothing has to happen, because it is a user given name } } + + // #i94570# DataPilot table names have to be unique, or the tables can't be accessed by API. + // If no name (or an invalid name, skipped in ScXMLDataPilotTableContext::EndElement) was set, create a new name. + ScDPCollection* pDPCollection = aDocument.GetDPCollection(); + if ( pDPCollection ) + { + USHORT nDPCount = pDPCollection->GetCount(); + for (USHORT nDP=0; nDP<nDPCount; nDP++) + { + ScDPObject* pDPObj = (*pDPCollection)[nDP]; + if ( !pDPObj->GetName().Len() ) + pDPObj->SetName( pDPCollection->CreateNewName() ); + } + } } ScColumn::bDoubleAlloc = sal_False; } @@ -437,7 +455,7 @@ BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium ) // only the latin script language is loaded // -> initialize the others from options (before loading) - InitOptions(); + InitOptions(true); GetUndoManager()->Clear(); @@ -667,6 +685,46 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) } } } + + try + { + uno::Reference< uno::XComponentContext > xContext; + uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); + uno::Reference< beans::XPropertySet > xProp( xServiceManager, uno::UNO_QUERY_THROW ); + xProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext; + if ( xContext.is() ) + { + uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW ); + uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocumentJob" ) ) ); + if ( xEnum.is() ) + { + while ( xEnum->hasMoreElements() ) + { + uno::Any aAny = xEnum->nextElement(); + uno::Reference< lang::XSingleComponentFactory > xFactory; + aAny >>= xFactory; + if ( xFactory.is() ) + { + uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW ); + uno::Sequence< beans::NamedValue > aArgsForJob(1); + ScViewData* pViewData = GetViewData(); + SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : NULL ); + SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : NULL ); + SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : NULL ); + uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : 0 ); + uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW ); + aArgsForJob[0] = beans::NamedValue( ::rtl::OUString::createFromAscii( "SpreadsheetView" ), + uno::makeAny( xSpreadsheetView ) ); + xJob->execute( aArgsForJob ); + } + } + } + } + } + catch ( uno::Exception & ) + { + } } break; case SFX_EVENT_SAVEDOC: @@ -953,10 +1011,33 @@ static void lcl_parseHtmlFilterOption(const OUString& rOption, LanguageType& rLa rDateConvert = static_cast<bool>(aTokens[1].toInt32()); } +namespace { + +class LoadMediumGuard +{ +public: + explicit LoadMediumGuard(ScDocument* pDoc) : + mpDoc(pDoc) + { + mpDoc->SetLoadingMedium(true); + } + + ~LoadMediumGuard() + { + mpDoc->SetLoadingMedium(false); + } +private: + ScDocument* mpDoc; +}; + +} + BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium ) { RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertFrom" ); + LoadMediumGuard aLoadGuard(&aDocument); + BOOL bRet = FALSE; // FALSE heisst Benutzerabbruch !! // bei Fehler: Fehler am Stream setzen!! @@ -2023,7 +2104,7 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed ) /* #115980# #i104990# If the imported document contains a medium password, determine if we can save it, otherwise ask the users whether they want to save without it. */ - if( !::sfx2::CheckMSPasswordCapabilityForExport( aFltName ) ) + if( (rMed.GetFilter()->GetFilterFlags() & SFX_FILTER_ENCRYPTION) == 0 ) { SfxItemSet* pItemSet = rMed.GetItemSet(); const SfxPoolItem* pItem = 0; @@ -2797,3 +2878,97 @@ sal_Bool ScDocShell::AcceptStateUpdate() const return sal_False; } //-->Added by PengYunQuan for Validity Cell Range Picker + + +bool ScDocShell::IsChangeRecording() const +{ + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + return pChangeTrack != NULL; +} + + +bool ScDocShell::HasChangeRecordProtection() const +{ + bool bRes = false; + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + if (pChangeTrack) + bRes = pChangeTrack->IsProtected(); + return bRes; +} + + +void ScDocShell::SetChangeRecording( bool bActivate ) +{ + bool bOldChangeRecording = IsChangeRecording(); + + if (bActivate) + { + aDocument.StartChangeTracking(); + ScChangeViewSettings aChangeViewSet; + aChangeViewSet.SetShowChanges(TRUE); + aDocument.SetChangeViewSettings(aChangeViewSet); + } + else + { + aDocument.EndChangeTracking(); + PostPaintGridAll(); + } + + if (bOldChangeRecording != IsChangeRecording()) + { + UpdateAcceptChangesDialog(); + // Slots invalidieren + SfxBindings* pBindings = GetViewBindings(); + if (pBindings) + pBindings->InvalidateAll(FALSE); + } +} + + +bool ScDocShell::SetProtectionPassword( const String &rNewPassword ) +{ + bool bRes = false; + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + if (pChangeTrack) + { + sal_Bool bProtected = pChangeTrack->IsProtected(); + + if (rNewPassword.Len()) + { + // when password protection is applied change tracking must always be active + SetChangeRecording( true ); + + ::com::sun::star::uno::Sequence< sal_Int8 > aProtectionHash; + SvPasswordHelper::GetHashPassword( aProtectionHash, rNewPassword ); + pChangeTrack->SetProtection( aProtectionHash ); + } + else + { + pChangeTrack->SetProtection( ::com::sun::star::uno::Sequence< sal_Int8 >() ); + } + bRes = true; + + if ( bProtected != pChangeTrack->IsProtected() ) + { + UpdateAcceptChangesDialog(); + SetDocumentModified(); + } + } + + return bRes; +} + + +bool ScDocShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ) +{ + bool bRes = false; + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + if (pChangeTrack && pChangeTrack->IsProtected()) + { + rPasswordHash = pChangeTrack->GetProtection(); + bRes = true; + } + return bRes; +} + + diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 9e3ed217382f..14ff7622818c 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -93,7 +93,7 @@ BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xSt aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew // InitOptions sets the document languages, must be called before CreateStandardStyles - InitOptions(); + InitOptions(false); aDocument.GetStyleSheetPool()->CreateStandardStyles(); aDocument.UpdStlShtPtrsFrmNms(); diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 4709a065792f..233843935bbd 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -424,7 +424,7 @@ double ScDocShell::GetOutputFactor() const //--------------------------------------------------------------------- -void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs) +void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and Load { // Einstellungen aus dem SpellCheckCfg kommen in Doc- und ViewOptions @@ -440,6 +440,14 @@ void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs) // zweistellige Jahreszahleneingabe aus Extras->Optionen->Allgemein->Sonstiges aDocOpt.SetYear2000( sal::static_int_cast<USHORT>( ::utl::MiscCfg().GetYear2000() ) ); + if (bForLoading) + { + // #i112123# No style:decimal-places attribute means automatic decimals, not the configured default, + // so it must not be taken from the global options. + // Calculation settings are handled separately in ScXMLBodyContext::EndElement. + aDocOpt.SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION ); + } + aDocument.SetDocOptions( aDocOpt ); aDocument.SetViewOptions( aViewOpt ); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index a9c92a4b8dbd..d50ce6f21c9c 100644..100755 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -66,6 +66,7 @@ using namespace ::com::sun::star; #include <svx/svditer.hxx> #include <svx/svdpage.hxx> #include <svx/fmshell.hxx> +#include <svtools/xwindowitem.hxx> #include <sfx2/passwd.hxx> #include <sfx2/filedlghelper.hxx> #include <sfx2/docinsert.hxx> @@ -623,8 +624,8 @@ void ScDocShell::Execute( SfxRequest& rReq ) // getting real parent window when called from Security-Options TP Window* pParent = NULL; const SfxPoolItem* pParentItem; - if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_PARENTWINDOW, FALSE, &pParentItem ) ) - pParent = ( Window* ) ( ( const OfaPtrItem* ) pParentItem )->GetValue(); + if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) ) + pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); // desired state ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); @@ -664,17 +665,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) if ( bDo ) { - // update "accept changes" dialog - //! notify all views - SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if ( pViewFrm && pViewFrm->HasChildWindow(FID_CHG_ACCEPT) ) - { - SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT); - if (pChild) - { - ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); - } - } + UpdateAcceptChangesDialog(); // Slots invalidieren if (pBindings) @@ -693,8 +684,8 @@ void ScDocShell::Execute( SfxRequest& rReq ) { Window* pParent = NULL; const SfxPoolItem* pParentItem; - if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_PARENTWINDOW, FALSE, &pParentItem ) ) - pParent = ( Window* ) ( ( const OfaPtrItem* ) pParentItem )->GetValue(); + if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) ) + pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); if ( ExecuteChangeProtectionDialog( pParent ) ) { rReq.Done(); @@ -1164,6 +1155,21 @@ void ScDocShell::Execute( SfxRequest& rReq ) //------------------------------------------------------------------ +void UpdateAcceptChangesDialog() +{ + // update "accept changes" dialog + //! notify all views + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) ) + { + SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT ); + if ( pChild ) + ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); + } +} + +//------------------------------------------------------------------ + BOOL ScDocShell::ExecuteChangeProtectionDialog( Window* _pParent, BOOL bJustQueryIfProtected ) { BOOL bDone = FALSE; @@ -1217,15 +1223,7 @@ BOOL ScDocShell::ExecuteChangeProtectionDialog( Window* _pParent, BOOL bJustQuer } if ( bProtected != pChangeTrack->IsProtected() ) { - // update "accept changes" dialog - //! notify all views - SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) ) - { - SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT ); - if ( pChild ) - ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); - } + UpdateAcceptChangesDialog(); bDone = TRUE; } } @@ -1491,12 +1489,12 @@ BOOL ScDocShell::AdjustPrintZoom( const ScRange& rRange ) SCROW nEndRow = rRange.aEnd.Row(); if ( pRepeatRow && nStartRow >= pRepeatRow->aStart.Row() ) { - nBlkTwipsY += aDocument.FastGetRowHeight( pRepeatRow->aStart.Row(), + nBlkTwipsY += aDocument.GetRowHeight( pRepeatRow->aStart.Row(), pRepeatRow->aEnd.Row(), nTab ); if ( nStartRow <= pRepeatRow->aEnd.Row() ) nStartRow = pRepeatRow->aEnd.Row() + 1; } - nBlkTwipsY += aDocument.FastGetRowHeight( nStartRow, nEndRow, nTab ); + nBlkTwipsY += aDocument.GetRowHeight( nStartRow, nEndRow, nTab ); Size aPhysPage; long nHdr, nFtr; diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 46b6b7af3a63..a17279f409a9 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1441,7 +1441,7 @@ BOOL ScImportExport::Doc2Text( SvStream& rStrm ) for (nRow = nStartRow; nRow <= nEndRow; nRow++) { - if (bIncludeFiltered || !pDoc->IsFiltered( nRow, aRange.aStart.Tab() )) + if (bIncludeFiltered || !pDoc->RowFiltered( nRow, aRange.aStart.Tab() )) { for (nCol = nStartCol; nCol <= nEndCol; nCol++) { diff --git a/sc/source/ui/docshell/olinefun.cxx b/sc/source/ui/docshell/olinefun.cxx index 2f42c77ed5f4..822c74800ab2 100644 --- a/sc/source/ui/docshell/olinefun.cxx +++ b/sc/source/ui/docshell/olinefun.cxx @@ -420,7 +420,7 @@ BOOL ScOutlineDocFunc::SelectLevel( SCTAB nTab, BOOL bColumns, USHORT nLevel, if ( bColumns ) pDoc->ShowCol( static_cast<SCCOL>(i), nTab, bShow ); else - if ( !bShow || !pDoc->IsFiltered( i,nTab ) ) + if ( !bShow || !pDoc->RowFiltered( i,nTab ) ) pDoc->ShowRow( i, nTab, bShow ); } } @@ -518,7 +518,7 @@ BOOL ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, BOOL bRecord, } } for ( i=nMin; i<=nMax; i++ ) - if ( !pDoc->IsFiltered( i,nTab ) ) // weggefilterte nicht einblenden + if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden pDoc->ShowRow( i, nTab, TRUE ); pDoc->UpdatePageBreaks( nTab ); @@ -678,7 +678,7 @@ BOOL ScOutlineDocFunc::ShowOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, US if ( bColumns ) pDoc->ShowCol( static_cast<SCCOL>(i), nTab, TRUE ); else - if ( !pDoc->IsFiltered( i,nTab ) ) // weggefilterte nicht einblenden + if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden pDoc->ShowRow( i, nTab, TRUE ); } @@ -701,6 +701,7 @@ BOOL ScOutlineDocFunc::ShowOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, US pArray->SetVisibleBelow( nLevel, nEntry, TRUE, TRUE ); + pDoc->InvalidatePageBreaks(nTab); pDoc->UpdatePageBreaks( nTab ); if (bPaint) @@ -766,6 +767,7 @@ BOOL ScOutlineDocFunc::HideOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, US pArray->SetVisibleBelow( nLevel, nEntry, FALSE ); + pDoc->InvalidatePageBreaks(nTab); pDoc->UpdatePageBreaks( nTab ); if (bPaint) diff --git a/sc/source/ui/inc/AccessibleContextBase.hxx b/sc/source/ui/inc/AccessibleContextBase.hxx index 191f56c22d3d..ecfeff96af39 100644 --- a/sc/source/ui/inc/AccessibleContextBase.hxx +++ b/sc/source/ui/inc/AccessibleContextBase.hxx @@ -316,8 +316,6 @@ protected: /// Use this method to set initial Description without notification void SetDescription(const rtl::OUString& rDesc) { msDescription = rDesc; } - void SetRole(sal_Int16 nRole); - /// Reference to the parent object. ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> mxParent; diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index df4ff685816f..c92cc082986d 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -31,6 +31,7 @@ #include <tools/link.hxx> #include "global.hxx" #include "formula/grammar.hxx" +#include "tabbgcolor.hxx" class ScEditEngineDefaulter; class SdrUndoAction; @@ -117,6 +118,9 @@ public: BOOL RenameTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi ); BOOL DeleteTable( SCTAB nTab, BOOL bRecord, BOOL bApi ); + bool SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi ); + bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoTabColorList, bool bRecord, bool bApi ); + BOOL SetTableVisible( SCTAB nTab, BOOL bVisible, BOOL bApi ); BOOL SetLayoutRTL( SCTAB nTab, BOOL bRTL, BOOL bApi ); diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 6c65772c4969..19147cfaf61f 100644..100755 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -125,7 +125,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener SC_DLLPRIVATE void InitItems(); SC_DLLPRIVATE void DoEnterHandler(); - SC_DLLPRIVATE void InitOptions(); + SC_DLLPRIVATE void InitOptions(bool bForLoading); SC_DLLPRIVATE void ResetDrawObjectShell(); // SUNWS needs a forward declared friend, otherwise types and members @@ -419,8 +419,20 @@ public: sal_Bool AcceptStateUpdate() const; //-->Added by PengYunQuan for Validity Cell Range Picker ScSheetSaveData* GetSheetSaveData(); + + // passwword protection for Calc (derived from SfxObjectShell) + // see also: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const; + virtual bool HasChangeRecordProtection() const; + virtual void SetChangeRecording( bool bActivate ); + virtual bool SetProtectionPassword( const String &rPassword ); + virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); }; + +void UpdateAcceptChangesDialog(); + + SO2_DECL_REF(ScDocShell) SO2_IMPL_REF(ScDocShell) diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx index 40e6167aee48..15f0c9174cc8 100644 --- a/sc/source/ui/inc/dpcontrol.hxx +++ b/sc/source/ui/inc/dpcontrol.hxx @@ -76,7 +76,6 @@ public: void draw(); void getPopupBoundingBox(Point& rPos, Size& rSize) const; - bool isPopupButton() const; private: void drawPopupButton(); @@ -127,9 +126,6 @@ public: void selectMenuItem(size_t nPos, bool bSelected, bool bSubMenuTimer); void clearSelectedMenuItem(); ScMenuFloatingWindow* getSubMenuWindow(size_t nPos) const; - size_t getMenuItemCount() const; - ::rtl::OUString getMenuItemName(size_t nPos) const; - bool isMenuItemEnabled(size_t nPos) const; bool isMenuItemSelected(size_t nPos) const; size_t getSelectedMenuItem() const; diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 4d6ef782aed6..a2283bf2b7de 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -39,6 +39,7 @@ #include <vector> #include <memory> +#include <boost/shared_ptr.hpp> // --------------------------------------------------------------------------- @@ -112,6 +113,25 @@ private: ::sdr::overlay::OverlayObjectList* mpOOHeader; ::sdr::overlay::OverlayObjectList* mpOOShrink; + ::boost::shared_ptr<Rectangle> mpAutoFillRect; + + /** + * Stores current visible column and row ranges, used to avoid expensive + * operations on objects that are outside visible area. + */ + struct VisibleRange + { + SCCOL mnCol1; + SCCOL mnCol2; + SCROW mnRow1; + SCROW mnRow2; + + VisibleRange(); + + bool isInside(SCCOL nCol, SCROW nRow) const; + }; + VisibleRange maVisibleRange; + private: ScViewData* pViewData; ScSplitPos eWhich; diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc index 908a6bd2221c..becd05165a4e 100644 --- a/sc/source/ui/inc/miscdlgs.hrc +++ b/sc/source/ui/inc/miscdlgs.hrc @@ -181,3 +181,9 @@ #define BTN_GROUP_ROWS 3 #define STR_GROUP 1 #define STR_UNGROUP 2 + +// Tab Bg Color +#define TAB_BG_COLOR_CT_BORDER 1 +#define TAB_BG_COLOR_SET_BGDCOLOR 2 +#define TAB_BG_COLOR_GB_BGDCOLOR 3 + diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx new file mode 100644 index 000000000000..241fc806022d --- /dev/null +++ b/sc/source/ui/inc/tabbgcolordlg.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tabbgcolordlg.hxx,v $ + * $Revision: 1.0 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_TABBGCOLORDLG_HXX +#define SC_TABBGCOLORDLG_HXX + +#include <vcl/dialog.hxx> +#include <vcl/fixed.hxx> +#include <vcl/imagebtn.hxx> +#include <svtools/valueset.hxx> + +//------------------------------------------------------------------------ + +class ScTabBgColorDlg : public ModalDialog +{ +public: + ScTabBgColorDlg( Window* pParent, + const String& rTitle, + const String& rTabBgColorNoColorText, + const Color& rDefaultColor, + ULONG nHelpId ); + ~ScTabBgColorDlg(); + + void GetSelectedColor( Color& rColor ) const; + +private: + class ScTabBgColorValueSet : public ValueSet + { + public: + ScTabBgColorValueSet(Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg); + + virtual void KeyInput( const KeyEvent& rKEvt ); + private: + ScTabBgColorDlg* aTabBgColorDlg; + }; + + Control aBorderWin; + ScTabBgColorValueSet aTabBgColorSet; + FixedLine aTabBgColorBox; + OKButton aBtnOk; + CancelButton aBtnCancel; + HelpButton aBtnHelp; + Color aTabBgColor; + const String aTabBgColorNoColorText; + ULONG mnHelpId; + + void FillColorValueSets_Impl(); + + DECL_LINK( TabBgColorDblClickHdl_Impl, ValueSet* ); + DECL_LINK( TabBgColorOKHdl_Impl, OKButton* pBtn ); +}; + +#endif // SC_TABBGCOLORDLG_HXX diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx index 276ea3d7e204..c8d135070ab1 100644 --- a/sc/source/ui/inc/undotab.hxx +++ b/sc/source/ui/inc/undotab.hxx @@ -32,6 +32,7 @@ #include "markdata.hxx" #include "formula/grammar.hxx" #include <tools/color.hxx> +#include "tabbgcolor.hxx" #ifndef _SVSTDARR_SHORTS @@ -223,6 +224,33 @@ private: void DoChange() const; }; +class ScUndoTabColor: public ScSimpleUndo +{ +public: + TYPEINFO(); + ScUndoTabColor( + ScDocShell* pNewDocShell, + SCTAB nT, + const Color& aOTabBgColor, + const Color& aNTabBgColor); + ScUndoTabColor( + ScDocShell* pNewDocShell, + const ScUndoTabColorInfo::List& rUndoTabColorList); + virtual ~ScUndoTabColor(); + + virtual void Undo(); + virtual void Redo(); + virtual void Repeat(SfxRepeatTarget& rTarget); + virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const; + +virtual String GetComment() const; + +private: + ScUndoTabColorInfo::List aTabColorList; + bool bIsMultipleUndo; + + void DoChange(bool bUndoType) const; +}; class ScUndoMakeScenario: public ScSimpleUndo { diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 21feb272c339..59da2966cc60 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -29,6 +29,8 @@ #include "tabview.hxx" +#include "tabbgcolor.hxx" + #ifndef _SVSTDARR_SHORTS #define _SVSTDARR_SHORTS #include <svl/svstdarr.hxx> @@ -273,6 +275,9 @@ public: SCTAB nCount, const SCTAB* pSrcTabs, BOOL bLink,SCTAB nTab); + bool SetTabBgColor( const Color& rColor, SCTAB nTabNr ); + bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList ); + void InsertTableLink( const String& rFile, const String& rFilter, const String& rOptions, const String& rTabName ); diff --git a/sc/source/ui/inc/viewutil.hxx b/sc/source/ui/inc/viewutil.hxx index 8b103d3761d8..eb1c6df2f902 100644 --- a/sc/source/ui/inc/viewutil.hxx +++ b/sc/source/ui/inc/viewutil.hxx @@ -68,10 +68,10 @@ public: static sal_Int32 GetTransliterationType( USHORT nSlotID ); - static bool HasFiltered( const ScRange& rRange, const ScDocument* pDoc ); + static bool HasFiltered( const ScRange& rRange, ScDocument* pDoc ); /** Fit a range to cover nRows number of unfiltered rows. @return <TRUE/> if the resulting range covers nRows unfiltered rows. */ - static bool FitToUnfilteredRows( ScRange & rRange, const ScDocument * pDoc, size_t nRows ); + static bool FitToUnfilteredRows( ScRange & rRange, ScDocument * pDoc, size_t nRows ); static void UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc ); static void HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, USHORT nSlotId ); diff --git a/sc/source/ui/miscdlgs/acredlin.src b/sc/source/ui/miscdlgs/acredlin.src index cad4747acb63..4baa9f3d388c 100644 --- a/sc/source/ui/miscdlgs/acredlin.src +++ b/sc/source/ui/miscdlgs/acredlin.src @@ -170,7 +170,6 @@ Menu RID_POPUP_CHANGES MenuItem { Identifier = SC_SUB_SORT ; - RadioCheck = TRUE ; SubMenu = Menu { ItemList = diff --git a/sc/source/ui/miscdlgs/makefile.mk b/sc/source/ui/miscdlgs/makefile.mk index ac210bcfaa83..d34994341ade 100644 --- a/sc/source/ui/miscdlgs/makefile.mk +++ b/sc/source/ui/miscdlgs/makefile.mk @@ -46,6 +46,7 @@ SLOFILES = \ $(SLO)$/delcodlg.obj \ $(SLO)$/inscodlg.obj \ $(SLO)$/strindlg.obj \ + $(SLO)$/tabbgcolordlg.obj \ $(SLO)$/mtrindlg.obj \ $(SLO)$/lbseldlg.obj \ $(SLO)$/filldlg.obj \ diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx new file mode 100644 index 000000000000..fdc4c9fd34bf --- /dev/null +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tabbgcolordlg.cxx,v $ + * $Revision: 1.0 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + +//------------------------------------------------------------------ + +#include "tabbgcolordlg.hxx" +#include "scresid.hxx" +#include "miscdlgs.hrc" + +#include "tools/debug.hxx" +#include "tools/color.hxx" +#include "sfx2/objsh.hxx" +#include "svx/xtable.hxx" +#include "svx/drawitem.hxx" +#include "unotools/pathoptions.hxx" +#include "tools/resid.hxx" +#include "editeng/editrids.hrc" + +#include <boost/scoped_ptr.hpp> + +//================================================================== + +#define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl) + +ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, + const String& rTitle, + const String& rTabBgColorNoColorText, + const Color& rDefaultColor, + ULONG nHelpId ) : + ModalDialog ( pParent, ScResId( RID_SCDLG_TAB_BG_COLOR ) ), + aBorderWin ( this, ScResId( TAB_BG_COLOR_CT_BORDER ) ), + aTabBgColorSet ( &aBorderWin, ScResId( TAB_BG_COLOR_SET_BGDCOLOR ), this ), + aTabBgColorBox ( this, ScResId( TAB_BG_COLOR_GB_BGDCOLOR ) ), + aBtnOk ( this, ScResId( BTN_OK ) ), + aBtnCancel ( this, ScResId( BTN_CANCEL ) ), + aBtnHelp ( this, ScResId( BTN_HELP ) ), + aTabBgColor ( rDefaultColor ), + aTabBgColorNoColorText ( rTabBgColorNoColorText ), + mnHelpId ( nHelpId ) + +{ + SetHelpId( nHelpId ); + this->SetText( rTitle ); + this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE); + + aTabBgColorBox.SetText(rTitle); + FillColorValueSets_Impl(); + aTabBgColorSet.SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) ); + aBtnOk.SetClickHdl( HDL(TabBgColorOKHdl_Impl) ); + FreeResource(); +} + +//------------------------------------------------------------------------ + +void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const +{ + rColor = this->aTabBgColor; +} + +ScTabBgColorDlg::~ScTabBgColorDlg() +{ +} + +void ScTabBgColorDlg::FillColorValueSets_Impl() +{ + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem = NULL; + XColorTable* pColorTable = NULL; + ::boost::scoped_ptr<XColorTable> pOwnColorTable; // locally instantiated in case the doc shell doesn't have one. + + const Size aSize15x15 = Size( 15, 15 ); + const Size aSize10x10 = Size( 10, 10 ); + const Size aSize5x5 = Size( 5, 5 ); + USHORT nSelectedItem = 0; + + DBG_ASSERT( pDocSh, "DocShell not found!" ); + + if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) ) + pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); + if ( !pColorTable ) + { + pOwnColorTable.reset(new XColorTable(SvtPathOptions().GetPalettePath())); + pColorTable = pOwnColorTable.get(); + } + if ( pColorTable ) + { + sal_uInt16 i = 0; + long nCount = pColorTable->Count(); + XColorEntry* pEntry = NULL; + Color aColWhite( COL_WHITE ); + String aStrWhite( ScResId( RID_SVXITEMS_COLOR_WHITE ) ); + WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS); + aTabBgColorSet.SetText( aTabBgColorNoColorText ); + aTabBgColorSet.SetStyle( nBits ); + for ( i = 0; i < nCount; i++ ) + { + pEntry = pColorTable->GetColor(i); + aTabBgColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() ); + if (pEntry->GetColor() == aTabBgColor) + nSelectedItem = (i + 1); + } + + while ( i < 80 ) + { + aTabBgColorSet.InsertItem( i + 1, aColWhite, aStrWhite ); + i++; + } + + if ( nCount > 80 ) + { + aTabBgColorSet.SetStyle( nBits | WB_VSCROLL ); + } + } + aTabBgColorSet.SetColCount( 10 ); + aTabBgColorSet.SetLineCount( 10 ); + aTabBgColorSet.CalcWindowSizePixel( aSize15x15 ); + aTabBgColorSet.Format(); + aTabBgColorSet.SelectItem(nSelectedItem); + aTabBgColorSet.Resize(); +} + +IMPL_LINK( ScTabBgColorDlg, TabBgColorDblClickHdl_Impl, ValueSet*, EMPTYARG ) +/* + Handler, called when color selection is changed +*/ +{ + USHORT nItemId = aTabBgColorSet.GetSelectItemId(); + Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO ); + aTabBgColor = aColor; + EndDialog( TRUE ); + return 0; +} + +IMPL_LINK( ScTabBgColorDlg, TabBgColorOKHdl_Impl, OKButton*, EMPTYARG ) +{ + +// Handler, called when the OK button is pushed + + USHORT nItemId = aTabBgColorSet.GetSelectItemId(); + Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO ); + aTabBgColor = aColor; + EndDialog( TRUE ); + return 0; +} + +ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet( Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg ) : + ValueSet(pParent, rResId) +{ + aTabBgColorDlg = pTabBgColorDlg; +} + +void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt ) +{ + switch ( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_SPACE: + case KEY_RETURN: + { + USHORT nItemId = GetSelectItemId(); + const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO ); + aTabBgColorDlg->aTabBgColor = aColor; + aTabBgColorDlg->EndDialog(TRUE); + } + break; + } + ValueSet::KeyInput(rKEvt); +} diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src index bbf20c436065..6c15762bda6a 100644 --- a/sc/source/ui/src/globstr.src +++ b/sc/source/ui/src/globstr.src @@ -1123,6 +1123,14 @@ Resource RID_GLOBSTR { Text [ en-US ] = "Rename Sheet" ; }; + String STR_UNDO_SET_TAB_BG_COLOR + { + Text [ en-US ] = "Color Tab" ; + }; + String STR_UNDO_SET_MULTI_TAB_BG_COLOR + { + Text [ en-US ] = "Color Tabs" ; + }; String STR_UNDO_MOVE_TAB { Text [ en-US ] = "Move Sheets" ; diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src index 06a19af7a8a7..6d4761c8589c 100644 --- a/sc/source/ui/src/miscdlgs.src +++ b/sc/source/ui/src/miscdlgs.src @@ -538,6 +538,96 @@ ModalDialog RID_SCDLG_STRINPUT Size = MAP_APPFONT ( 110 , 8 ) ; }; }; +ModalDialog RID_SCDLG_TAB_BG_COLOR +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 118 , 167 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + Control TAB_BG_COLOR_CT_BORDER + { + Border = TRUE ; + Pos = MAP_APPFONT ( 1 , 1 ) ; //12, 32 + Size = MAP_APPFONT ( 116+2 , 145+2 ) ; + DialogControl = TRUE; + }; + Control TAB_BG_COLOR_SET_BGDCOLOR + { + // * HelpId = HID_BACKGROUND_CTL_BGDCOLORSET ; + Hide = FALSE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 116 , 145 ) ; + TabStop = TRUE ; + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( 82 , 151 ) ; + Size = MAP_APPFONT ( 35 , 14 ) ; + TabStop = TRUE ; + DefButton = FALSE ; + }; + OKButton BTN_OK + { + Pos = MAP_APPFONT ( 45 , 151 ) ; + Size = MAP_APPFONT ( 35 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( 2 , 151 ) ; + Size = MAP_APPFONT ( 35 , 14 ) ; + TabStop = TRUE ; + DefButton = FALSE ; + }; +}; +/* +ModalDialog RID_SCDLG_TAB_BG_COLOR +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 180 , 150 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + Control TAB_BG_COLOR_CT_BORDER + { + Border = TRUE ; + Pos = MAP_APPFONT ( 1 , 1 ) ; //12, 32 + Size = MAP_APPFONT ( 116+2 , 145+2 ) ; + DialogControl = TRUE; + }; + Control TAB_BG_COLOR_SET_BGDCOLOR + { + // * HelpId = HID_BACKGROUND_CTL_BGDCOLORSET ; + Hide = FALSE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 116 , 145 ) ; + TabStop = TRUE ; + }; + OKButton BTN_OK + { + Pos = MAP_APPFONT ( 125 , 50 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( 125 , 67 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = FALSE ; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( 125 , 84 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = FALSE ; + }; +}; +*/ /* ModalDialog RID_SCDLG_MTRINPUT { diff --git a/sc/source/ui/src/popup.src b/sc/source/ui/src/popup.src index e3f721adaa1a..9753aa1590e3 100644 --- a/sc/source/ui/src/popup.src +++ b/sc/source/ui/src/popup.src @@ -196,6 +196,15 @@ Menu RID_POPUP_TAB HelpId = FID_TAB_EVENTS ; Text [ en-US ] = "Sheet E~vents..." ; }; + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MenuItem + { + Identifier = FID_TAB_MENU_SET_TAB_BG_COLOR ; + HelpId = FID_TAB_MENU_SET_TAB_BG_COLOR ; + Text [ en-US ] = "~Tab Color..." ; + }; }; }; diff --git a/sc/source/ui/src/scstring.src b/sc/source/ui/src/scstring.src index 7f5337e11b89..9c47a42239cc 100644 --- a/sc/source/ui/src/scstring.src +++ b/sc/source/ui/src/scstring.src @@ -280,6 +280,14 @@ String SCSTR_RENAMETAB { Text [ en-US ] = "Rename Sheet" ; }; +String SCSTR_SET_TAB_BG_COLOR +{ + Text [ en-US ] = "Tab Color" ; +}; +String SCSTR_NO_TAB_BG_COLOR +{ + Text [ en-US ] = "Default" ; +}; String SCSTR_RENAMEOBJECT { Text [ en-US ] = "Name Object"; diff --git a/sc/source/ui/undo/makefile.mk b/sc/source/ui/undo/makefile.mk index 01edd92f8553..50fab82972ca 100644 --- a/sc/source/ui/undo/makefile.mk +++ b/sc/source/ui/undo/makefile.mk @@ -76,7 +76,8 @@ SLOFILES = \ EXCEPTIONSFILES= \ $(SLO)$/undoblk3.obj \ $(SLO)$/undocell.obj \ - $(SLO)$/undostyl.obj + $(SLO)$/undostyl.obj \ + $(SLO)$/undotab.obj # --- Tagets ------------------------------------------------------- diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index a35ba96112e3..c284045c5b11 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1148,10 +1148,10 @@ ScUndoDragDrop::ScUndoDragDrop( ScDocShell* pNewDocShell, BOOL bIncludeFiltered = bCut; if ( !bIncludeFiltered ) { - // manually find number of non-filtered rows - SCROW nPastedCount = pDocShell->GetDocument()->GetRowFlagsArray( - aSrcRange.aStart.Tab()).CountForCondition( - aSrcRange.aStart.Row(), aSrcRange.aEnd.Row(), CR_FILTERED, 0); + // find number of non-filtered rows + SCROW nPastedCount = pDocShell->GetDocument()->CountNonFilteredRows( + aSrcRange.aStart.Row(), aSrcRange.aEnd.Row(), aSrcRange.aStart.Tab()); + if ( nPastedCount == 0 ) nPastedCount = 1; aDestEnd.SetRow( aNewDestPos.Row() + nPastedCount - 1 ); diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 4011d4755ab1..506afeac138e 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -1028,17 +1028,20 @@ void __EXPORT ScUndoAutoFormat::Redo() aDestMark.MarkToMulti(); // wie SC_SIZE_VISOPT + SCROW nLastRow = -1; for (SCROW nRow=nStartY; nRow<=nEndY; nRow++) { BYTE nOld = pDoc->GetRowFlags(nRow,nTab); - if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) ) + bool bHidden = pDoc->RowHidden(nRow, nTab, nLastRow); + if ( !bHidden && ( nOld & CR_MANUALSIZE ) ) pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE ); } pDoc->SetOptimalHeight( nStartY, nEndY, nTab, 0, &aVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, FALSE ); + SCCOL nLastCol = -1; for (SCCOL nCol=nStartX; nCol<=nEndX; nCol++) - if ((pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0) + if (!pDoc->ColHidden(nCol, nTab, nLastCol)) { USHORT nThisSize = STD_EXTRA_WIDTH + pDoc->GetOptimalColWidth( nCol, nTab, &aVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, bFormula, diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 77142bb13799..cc13ce9f1412 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -568,6 +568,8 @@ void ScUndoPageBreak::DoChange( BOOL bInsertP ) const pViewShell->InsertPageBreak(bColumn, FALSE); else pViewShell->DeletePageBreak(bColumn, FALSE); + + pDocShell->GetDocument()->InvalidatePageBreaks(nTab); } } diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index d550d54f1aea..0f7834b2a8df 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -1027,7 +1027,10 @@ void __EXPORT ScUndoQuery::Undo() pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), TRUE ); if (!bCopy) + { + pDoc->InvalidatePageBreaks(nTab); pDoc->UpdatePageBreaks( nTab ); + } ScRange aDirtyRange( 0 , aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab ); diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index dc299dae8921..70845f6c0bc9 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -28,18 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - -//------------------------------------------------------------------ - -// ?#define _MACRODLG_HXX -// ? #define _BIGINT_HXX -// ? #define _SVDXOUT_HXX -// ? #define _SVDATTR_HXX -// ? #define _SVDSURO_HXX - -// INCLUDE --------------------------------------------------------------- - #include <sfx2/app.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> @@ -59,6 +47,7 @@ #include "printfun.hxx" #include "chgtrack.hxx" #include "tabprotection.hxx" +#include "viewdata.hxx" // for ScUndoRenameObject - might me moved to another file later #include <svx/svditer.hxx> @@ -90,6 +79,7 @@ TYPEINIT1(ScUndoScenarioFlags, SfxUndoAction); TYPEINIT1(ScUndoRenameObject, SfxUndoAction); TYPEINIT1(ScUndoLayoutRTL, SfxUndoAction); //UNUSED2009-05 TYPEINIT1(ScUndoSetGrammar, SfxUndoAction); +TYPEINIT1(ScUndoTabColor, SfxUndoAction); // ----------------------------------------------------------------------- @@ -411,6 +401,7 @@ void ScUndoDeleteTab::Undo() pDoc->SetActiveScenario( nTab, bActive ); } pDoc->SetVisible( nTab, pRefUndoDoc->IsVisible( nTab ) ); + pDoc->SetTabBgColor( nTab, pRefUndoDoc->GetTabBgColor(nTab) ); pDoc->SetSheetEvents( nTab, pRefUndoDoc->GetSheetEvents( nTab ) ); if ( pRefUndoDoc->IsTabProtected( nTab ) ) @@ -777,6 +768,78 @@ BOOL ScUndoCopyTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const return FALSE; } +//--------------------------------------------------------------------------------- +// +// Tab Bg Color +// + +ScUndoTabColor::ScUndoTabColor( + ScDocShell* pNewDocShell, SCTAB nT, const Color& aOTabBgColor, const Color& aNTabBgColor) : + ScSimpleUndo( pNewDocShell ) +{ + ScUndoTabColorInfo aInfo(nT); + aInfo.maOldTabBgColor = aOTabBgColor; + aInfo.maNewTabBgColor = aNTabBgColor; + aTabColorList.push_back(aInfo); +} + +ScUndoTabColor::ScUndoTabColor( + ScDocShell* pNewDocShell, + const ScUndoTabColorInfo::List& rUndoTabColorList) : + ScSimpleUndo(pNewDocShell), + aTabColorList(rUndoTabColorList) +{ +} + +ScUndoTabColor::~ScUndoTabColor() +{ +} + +String ScUndoTabColor::GetComment() const +{ + if (aTabColorList.size() > 1) + return ScGlobal::GetRscString(STR_UNDO_SET_MULTI_TAB_BG_COLOR); + return ScGlobal::GetRscString(STR_UNDO_SET_TAB_BG_COLOR); +} + +void ScUndoTabColor::DoChange(bool bUndoType) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + if (!pDoc) + return; + + size_t nTabColorCount = aTabColorList.size(); + for (size_t i = 0; i < nTabColorCount; ++i) + { + const ScUndoTabColorInfo& rTabColor = aTabColorList[i]; + pDoc->SetTabBgColor(rTabColor.mnTabId, + bUndoType ? rTabColor.maOldTabBgColor : rTabColor.maNewTabBgColor); + } + + pDocShell->PostPaintExtras(); + ScDocShellModificator aModificator( *pDocShell ); + aModificator.SetDocumentModified(); +} + +void ScUndoTabColor::Undo() +{ + DoChange(true); +} + +void ScUndoTabColor::Redo() +{ + DoChange(false); +} + +void ScUndoTabColor::Repeat(SfxRepeatTarget& /* rTarget */) +{ + // No Repeat +} + +BOOL ScUndoTabColor::CanRepeat(SfxRepeatTarget& /* rTarget */) const +{ + return FALSE; +} // ----------------------------------------------------------------------- // diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index cfbad8a7e65c..dea7cc056756 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -770,6 +770,7 @@ const SfxItemPropertySet* lcl_GetSheetPropertySet() {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, &getCppuType((sal_Int32*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, {0,0,0,0,0,0} }; @@ -3376,18 +3377,25 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleC ScMarkData aMarkData(*GetMarkData()); ScDocument* pDoc = pDocShell->GetDocument(); - for (SCCOL nCol=0; nCol<=MAXCOL; nCol++) - if (pDoc->GetColFlags(nCol,nTab) & CR_HIDDEN) - aMarkData.SetMultiMarkArea( ScRange( nCol,0,nTab, nCol,MAXROW,nTab ), FALSE ); + SCCOL nCol = 0, nLastCol; + while (nCol <= MAXCOL) + { + if (pDoc->ColHidden(nCol, nTab, nLastCol)) + // hidden columns. Unselect them. + aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false); - //! nur bis zur letzten selektierten Zeile testen? - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray( nTab), 0, MAXROW); - do + nCol = nLastCol + 1; + } + + SCROW nRow = 0, nLastRow; + while (nRow <= MAXROW) { - if (*aIter & CR_HIDDEN) - aMarkData.SetMultiMarkArea( ScRange( 0, aIter.GetRangeStart(), - nTab, MAXCOL, aIter.GetRangeEnd(), nTab ), FALSE ); - } while (aIter.NextRange()); + if (pDoc->RowHidden(nRow, nTab, nLastRow)) + // These rows are hidden. Unselect them. + aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false); + + nRow = nLastRow + 1; + } ScRangeList aNewRanges; aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE ); @@ -7053,7 +7061,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPage SCCOL nCount = 0; SCCOL nCol; for (nCol=0; nCol<=MAXCOL; nCol++) - if (pDoc->GetColFlags( nCol, nTab ) & ( CR_PAGEBREAK | CR_MANUALBREAK )) + if (pDoc->HasColBreak(nCol, nTab)) ++nCount; sheet::TablePageBreakData aData; @@ -7062,11 +7070,11 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPage USHORT nPos = 0; for (nCol=0; nCol<=MAXCOL; nCol++) { - BYTE nFlags = pDoc->GetColFlags( nCol, nTab ); - if (nFlags & ( CR_PAGEBREAK | CR_MANUALBREAK )) + ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab); + if (nBreak) { aData.Position = nCol; - aData.ManualBreak = ( nFlags & CR_MANUALBREAK ) != 0; + aData.ManualBreak = (nBreak & BREAK_MANUAL); pAry[nPos] = aData; ++nPos; } @@ -7095,33 +7103,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBre ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ); aPrintFunc.UpdatePages(); } - - SCROW nCount = pDoc->GetRowFlagsArray( nTab).CountForAnyBitCondition( - 0, MAXROW, (CR_PAGEBREAK | CR_MANUALBREAK)); - - uno::Sequence<sheet::TablePageBreakData> aSeq(nCount); - if (nCount) - { - sheet::TablePageBreakData aData; - sheet::TablePageBreakData* pAry = aSeq.getArray(); - size_t nPos = 0; - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray( nTab), 0, MAXROW); - do - { - BYTE nFlags = *aIter; - if (nFlags & ( CR_PAGEBREAK | CR_MANUALBREAK )) - { - for (SCROW nRow = aIter.GetRangeStart(); nRow <= aIter.GetRangeEnd(); ++nRow) - { - aData.Position = nRow; - aData.ManualBreak = ( nFlags & CR_MANUALBREAK ) != 0; - pAry[nPos] = aData; - ++nPos; - } - } - } while (aIter.NextRange()); - } - return aSeq; + return pDoc->GetRowBreakData(nTab); } return uno::Sequence<sheet::TablePageBreakData>(0); } @@ -8486,15 +8468,24 @@ void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEn pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag. } } - else if ( pEntry->nWID == SC_WID_UNO_CODENAME ) + else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR ) { - rtl::OUString aCodeName; - if ( pDocSh && ( aValue >>= aCodeName ) ) + sal_Int32 nColor = COL_AUTO; + if (aValue >>= nColor) + { + if (static_cast<ColorData>(nColor) != COL_AUTO) + pDoc->SetTabBgColor(nTab, Color(static_cast<ColorData>(nColor))); + } + } + else if ( pEntry->nWID == SC_WID_UNO_CODENAME ) { - String sNewName( aCodeName ); - pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), sNewName ); + rtl::OUString aCodeName; + if ( pDocSh && ( aValue >>= aCodeName ) ) + { + String sNewName( aCodeName ); + pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), sNewName ); + } } - } else ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID } @@ -8633,13 +8624,17 @@ void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEn BOOL bAutoPrint = pDoc->IsPrintEntireSheet( nTab ); ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint ); } + else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR ) + { + rAny <<= sal_Int32(pDoc->GetTabBgColor(nTab).GetColor()); + } else if ( pEntry->nWID == SC_WID_UNO_CODENAME ) { - String aCodeName; - if ( pDocSh ) - pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName ); - rAny <<= rtl::OUString( aCodeName ); - } + String aCodeName; + if ( pDocSh ) + pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName ); + rAny <<= rtl::OUString( aCodeName ); + } else ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); } @@ -8908,8 +8903,9 @@ void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) { - BOOL bVis = !(pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN); - ScUnoHelpFunctions::SetBoolInAny( rAny, bVis ); + SCCOL nDummy; + bool bHidden = pDoc->ColHidden(nCol, nTab, nDummy); + ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden ); } else if ( pEntry->nWID == SC_WID_UNO_OWIDTH ) { @@ -8919,13 +8915,13 @@ void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE } else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE ) { - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nCol, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak ); + ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab); + ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak ); } else if ( pEntry->nWID == SC_WID_UNO_MANPAGE ) { - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nCol, nTab ) & (CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak ); + ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab); + ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL)); } else ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); @@ -9011,12 +9007,7 @@ void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr // ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT; // aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, eMode, 0, TRUE, TRUE ); // SC_SIZE_DIRECT mit Groesse 0 blendet aus - BYTE nFlags = pDoc->GetRowFlags(nRow, nTab); - if (bFil) - nFlags |= CR_FILTERED; - else - nFlags &= ~CR_FILTERED; - pDoc->SetRowFlags(nRow, nTab, nFlags); + pDoc->SetRowFiltered(nRow, nRow, nTab, bFil); } else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT ) { @@ -9068,12 +9059,13 @@ void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) { - BOOL bVis = !(pDoc->GetRowFlags( nRow, nTab ) & CR_HIDDEN); - ScUnoHelpFunctions::SetBoolInAny( rAny, bVis ); + SCROW nDummy; + bool bHidden = pDoc->RowHidden(nRow, nTab, nDummy); + ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden ); } else if ( pEntry->nWID == SC_WID_UNO_CELLFILT ) { - BOOL bVis = ((pDoc->GetRowFlags( nRow, nTab ) & CR_FILTERED) != 0); + bool bVis = pDoc->RowFiltered(nRow, nTab); ScUnoHelpFunctions::SetBoolInAny( rAny, bVis ); } else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT ) @@ -9083,13 +9075,13 @@ void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr } else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE ) { - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nRow, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak ); + ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab); + ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak ); } else if ( pEntry->nWID == SC_WID_UNO_MANPAGE ) { - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nRow, nTab ) & (CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak ); + ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL); + ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak ); } else ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 8654de8a429e..8a8081e412d3 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2569,14 +2569,17 @@ void ScChart2DataSequence::BuildDataCache() if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr)) continue; + SCCOL nLastCol = -1; + SCROW nLastRow = -1; for (SCTAB nTab = aRange.aStart.Tab(); nTab <= aRange.aEnd.Tab(); ++nTab) { for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol) { for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow) { - bool bColHidden = (m_pDocument->GetColFlags(nCol, nTab) & CR_HIDDEN); - bool bRowHidden = (m_pDocument->GetRowFlags(nRow, nTab) & CR_HIDDEN); + bool bColHidden = m_pDocument->ColHidden(nCol, nTab, nLastCol); + bool bRowHidden = m_pDocument->RowHidden(nRow, nTab, nLastRow); + if (bColHidden || bRowHidden) { // hidden cell diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 201c411ea45c..86f59d66a7a4 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -31,10 +31,12 @@ #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> #include <svx/svditer.hxx> #include <svx/svdoole2.hxx> @@ -54,9 +56,12 @@ #include "chartlis.hxx" #include "unoguard.hxx" #include "chart2uno.hxx" +#include "convuno.hxx" using namespace com::sun::star; +#define PROP_HANDLE_RELATED_CELLRANGES 1 + //------------------------------------------------------------------------ SC_SIMPLE_SERVICE_INFO( ScChartObj, "ScChartObj", "com.sun.star.table.TableChart" ) @@ -222,7 +227,7 @@ void SAL_CALL ScChartsObj::addNewByName( const rtl::OUString& aName, xObj = pDocShell->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aTmp ); if ( xObj.is() ) { - String aObjName = aNameString; // wirklich eingefuegter Name... + String aObjName = aTmp; // wirklich eingefuegter Name... // Rechteck anpassen //! Fehler/Exception, wenn leer/ungueltig ??? @@ -451,12 +456,19 @@ sal_Bool SAL_CALL ScChartsObj::hasByName( const rtl::OUString& aName ) //------------------------------------------------------------------------ -ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) : - pDocShell( pDocSh ), - nTab( nT ), - aChartName( rN ) +ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) + :ScChartObj_Base( m_aMutex ) + ,ScChartObj_PBase( ScChartObj_Base::rBHelper ) + ,pDocShell( pDocSh ) + ,nTab( nT ) + ,aChartName( rN ) { pDocShell->GetDocument()->AddUnoObject(*this); + + uno::Sequence< table::CellRangeAddress > aInitialPropValue; + registerPropertyNoMember( ::rtl::OUString::createFromAscii( "RelatedCellRanges" ), + PROP_HANDLE_RELATED_CELLRANGES, beans::PropertyAttribute::MAYBEVOID, + ::getCppuType( &aInitialPropValue ), &aInitialPropValue ); } ScChartObj::~ScChartObj() @@ -552,6 +564,117 @@ void ScChartObj::Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, b } } +// ::comphelper::OPropertySetHelper + +::cppu::IPropertyArrayHelper& ScChartObj::getInfoHelper() +{ + return *ScChartObj_PABase::getArrayHelper(); +} + +void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) +{ + switch ( nHandle ) + { + case PROP_HANDLE_RELATED_CELLRANGES: + { + uno::Sequence< table::CellRangeAddress > aCellRanges; + if ( rValue >>= aCellRanges ) + { + ScRangeListRef rRangeList = new ScRangeList(); + const table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); + sal_Int32 nCount = aCellRanges.getLength(); + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + table::CellRangeAddress aCellRange = pCellRanges[ i ]; + ScRange aRange; + ScUnoConversion::FillScRange( aRange, aCellRange ); + rRangeList->Append( aRange ); + } + ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); + ScChartListenerCollection* pCollection = ( pDoc ? pDoc->GetChartListenerCollection() : NULL ); + if ( pCollection ) + { + pCollection->ChangeListening( aChartName, rRangeList ); + } + } + } + break; + default: + { + } + break; + } +} + +void ScChartObj::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const +{ + switch ( nHandle ) + { + case PROP_HANDLE_RELATED_CELLRANGES: + { + ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); + if ( pDoc ) + { + ScRange aEmptyRange; + USHORT nIndex = 0; + ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); + ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); + if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) + { + ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); + if ( pListener ) + { + const ScRangeListRef& rRangeList = pListener->GetRangeList(); + if ( rRangeList.Is() ) + { + ULONG nCount = rRangeList->Count(); + uno::Sequence< table::CellRangeAddress > aCellRanges( nCount ); + table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); + for ( USHORT i = 0; i < nCount; ++i ) + { + ScRange aRange( *rRangeList->GetObject( i ) ); + table::CellRangeAddress aCellRange; + ScUnoConversion::FillApiRange( aCellRange, aRange ); + pCellRanges[ i ] = aCellRange; + } + rValue <<= aCellRanges; + } + } + } + } + } + break; + default: + { + } + break; + } +} + +// ::comphelper::OPropertyArrayUsageHelper + +::cppu::IPropertyArrayHelper* ScChartObj::createArrayHelper() const +{ + uno::Sequence< beans::Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); +} + +// XInterface + +IMPLEMENT_FORWARD_XINTERFACE2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) + +// XTypeProvider + +IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) + +// XComponent + +void ScChartObj::disposing() +{ + ScChartObj_Base::disposing(); +} + // XTableChart sal_Bool SAL_CALL ScChartObj::getHasColumnHeaders() throw(uno::RuntimeException) @@ -681,6 +804,13 @@ void SAL_CALL ScChartObj::setName( const rtl::OUString& /* aName */ ) throw(uno: throw uno::RuntimeException(); // name cannot be changed } +// XPropertySet + +uno::Reference< beans::XPropertySetInfo > ScChartObj::getPropertySetInfo() throw (uno::RuntimeException) +{ + return createPropertySetInfo( getInfoHelper() ) ; +} + //------------------------------------------------------------------------ diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx index dd8f15359559..75e415b8f018 100644 --- a/sc/source/ui/unoobj/confuno.cxx +++ b/sc/source/ui/unoobj/confuno.cxx @@ -88,6 +88,7 @@ const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap() {MAP_CHAR_LEN(SC_UNO_LOADREADONLY), 0, &getBooleanCppuType(), 0, 0}, // <-- {MAP_CHAR_LEN(SC_UNO_SHAREDOC), 0, &getBooleanCppuType(), 0, 0}, + {MAP_CHAR_LEN(SC_UNO_MODIFYPASSWORDINFO), 0, &getCppuType((uno::Sequence< beans::PropertyValue >*)0), 0, 0}, {0,0,0,0,0,0} }; return aConfigPropertyMap_Impl; @@ -274,6 +275,20 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue( pDocShell->SetSharedXMLFlag( bDocShared ); } } + else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 ) + { + uno::Sequence< beans::PropertyValue > aInfo; + if ( !( aValue >>= aInfo ) ) + throw lang::IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type Sequence<PropertyValue> expected!" ) ), + uno::Reference< uno::XInterface >(), + 2 ); + + if ( !pDocShell->SetModifyPasswordInfo( aInfo ) ) + throw beans::PropertyVetoException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ), + uno::Reference< uno::XInterface >() ); + } else { ScGridOptions aGridOpt(aViewOpt.GetGridOptions()); @@ -407,6 +422,8 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const rtl::OUString { ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasSharedXMLFlagSet() ); } + else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 ) + aRet <<= pDocShell->GetModifyPasswordInfo(); else { const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 28d2a0520f74..3d3f0f479601 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -365,8 +365,7 @@ ScModelObj::ScModelObj( ScDocShell* pDocSh ) : pDocShell( pDocSh ), pPrintFuncCache( NULL ), pPrinterOptions( NULL ), - maChangesListeners( m_aMutex ), - mnXlsWriteProtPass( 0 ) + maChangesListeners( m_aMutex ) { // pDocShell may be NULL if this is the base of a ScDocOptionsObj if ( pDocShell ) @@ -1748,14 +1747,6 @@ void SAL_CALL ScModelObj::setPropertyValue( if ( aObjName.getLength() ) pDoc->RestoreChartListener( aObjName ); } - else if ( aString.EqualsAscii( "WriteProtectionPassword" ) ) - { - /* This is a hack for #160550# to preserve the write-protection - password in an XLS roundtrip. This property MUST NOT be used - for any other purpose. This property will be deleted when the - feature "Write Protection With Password" will be implemented. */ - aValue >>= mnXlsWriteProtPass; - } if ( aNewOpt != rOldOpt ) { @@ -1924,14 +1915,6 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa { ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL) ); } - else if ( aString.EqualsAscii( "WriteProtectionPassword" ) ) - { - /* This is a hack for #160550# to preserve the write-protection - password in an XLS roundtrip. This property MUST NOT be used - for any other purpose. This property will be deleted when the - feature "Write Protection With Password" will be implemented. */ - aRet <<= mnXlsWriteProtPass; - } } return aRet; @@ -3068,7 +3051,8 @@ uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const rtl::OUString& aPro } else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) ) { - BOOL bVis = !(pDoc->GetColFlags( nStartCol, nTab ) & CR_HIDDEN); + SCCOL nLastCol; + bool bVis = !pDoc->ColHidden(nStartCol, nTab, nLastCol); ScUnoHelpFunctions::SetBoolInAny( aAny, bVis ); } else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) ) @@ -3078,13 +3062,13 @@ uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const rtl::OUString& aPro } else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) ) { - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nStartCol, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak ); + ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab); + ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak ); } else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) ) { - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nStartCol, nTab ) & (CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak ); + ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab); + ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) ); } return aAny; @@ -3244,8 +3228,11 @@ void SAL_CALL ScTableRowsObj::setPropertyValue( sal_Int32 nNewHeight = 0; if ( pDoc->IsImportingXML() && ( aValue >>= nNewHeight ) ) { - // used to set the stored row height for rows with optimal height when loading - pDoc->SetRowHeightRange( nStartRow, nEndRow, nTab, (USHORT)HMMToTwips(nNewHeight) ); + // used to set the stored row height for rows with optimal height when loading. + + // TODO: It's probably cleaner to use a different property name + // for this. + pDoc->SetRowHeightOnly( nStartRow, nEndRow, nTab, (USHORT)HMMToTwips(nNewHeight) ); } else { @@ -3276,9 +3263,9 @@ void SAL_CALL ScTableRowsObj::setPropertyValue( { //! undo etc. if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) - pDoc->GetRowFlagsArrayModifiable( nTab).OrValue( nStartRow, nEndRow, CR_FILTERED); + pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, true); else - pDoc->GetRowFlagsArrayModifiable( nTab).AndValue( nStartRow, nEndRow, sal::static_int_cast<BYTE>(~CR_FILTERED) ); + pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, false); } else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE) ) { @@ -3326,12 +3313,13 @@ uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const rtl::OUString& aProper } else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) ) { - BOOL bVis = !(pDoc->GetRowFlags( nStartRow, nTab ) & CR_HIDDEN); + SCROW nLastRow; + bool bVis = !pDoc->RowHidden(nStartRow, nTab, nLastRow); ScUnoHelpFunctions::SetBoolInAny( aAny, bVis ); } else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) ) { - BOOL bVis = ((pDoc->GetRowFlags( nStartRow, nTab ) & CR_FILTERED) != 0); + bool bVis = pDoc->RowFiltered(nStartRow, nTab); ScUnoHelpFunctions::SetBoolInAny( aAny, bVis ); } else if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) ) @@ -3341,13 +3329,13 @@ uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const rtl::OUString& aProper } else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) ) { - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nStartRow, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak ); + ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab); + ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak ); } else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) ) { - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nStartRow, nTab ) & (CR_MANUALBREAK)) ); - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak ); + ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab); + ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) ); } else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) ) { diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index 80cb88595b11..03d6d14a3ac7 100644..100755 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -298,7 +298,7 @@ static BOOL lcl_IsAnyXMLFilter( const SfxFilter* pFilter ) } else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")) ) lDescriptor[nProperty].Value >>= xInteraction; - else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("RapairPackage")) ) + else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("RepairPackage")) ) lDescriptor[nProperty].Value >>= bRepairPackage; else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle")) ) nIndexOfDocumentTitle = nProperty; diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index b82de19b783f..fd1e655b8ffb 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -1848,6 +1848,7 @@ void ScTabViewObj::SelectionChanged() /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); } } + // execute VBA event handler try { diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 8006292331b6..8f5aba5c4acb 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -24,14 +24,14 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <stdio.h> +#include <stdio.h> -#include<com/sun/star/sheet/XSpreadsheetView.hpp> +#include <com/sun/star/sheet/XSpreadsheetView.hpp> #include <com/sun/star/sheet/XSpreadsheets.hpp> -#include<com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include<ooo/vba/excel/XlCalculation.hpp> +#include <ooo/vba/excel/XlCalculation.hpp> #include <com/sun/star/sheet/XCellRangeReferrer.hpp> #include <com/sun/star/sheet/XCalculatable.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index ff391b9187b8..a7be5feb1d27 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -44,7 +44,7 @@ class ScVbaApplication : public ScVbaApplication_BASE private: sal_Int32 m_xCalculation; sal_Bool m_bDisplayAlerts; - sal_Bool m_bEnableEvents; + sal_Bool m_bEnableEvents; rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); diff --git a/sc/source/ui/vba/vbacomments.cxx b/sc/source/ui/vba/vbacomments.cxx index 93ba4ae84293..7a6d3d774937 100644 --- a/sc/source/ui/vba/vbacomments.cxx +++ b/sc/source/ui/vba/vbacomments.cxx @@ -81,7 +81,6 @@ uno::Reference< container::XEnumeration > ScVbaComments::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new CommentEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration(), mxModel ); } diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index a973e28b76b0..e3a76d17789b 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -355,7 +355,6 @@ ScVbaRangeAreas::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); return new RangesEnumerationImpl( mxParent, mxContext, xEnumAccess->createEnumeration(), mbIsRows, mbIsColumns ); - } uno::Any @@ -1177,7 +1176,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S ScVbaRange* -getRangeForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) +getRangeForName( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) { ScRangeList aCellRanges; ScRange refRange; @@ -1291,7 +1290,7 @@ ScVbaRange::getRangeObjectForName( ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv ) throw ( uno::RuntimeException ) { table::CellRangeAddress refAddr; - return getRangeForName( xContext, sRangeName, pDocSh, refAddr, eConv ); + return getRangeForName( xParent, xContext, sRangeName, pDocSh, refAddr, eConv ); } @@ -2581,7 +2580,7 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI Cell1 >>= sName; RangeHelper referRange( xReferrer ); table::CellRangeAddress referAddress = referRange.getCellRangeAddressable()->getRangeAddress(); - return getRangeForName( mxContext, sName, getScDocShell(), referAddress ); + return getRangeForName( getParent(), mxContext, sName, getScDocShell(), referAddress ); } else @@ -3907,16 +3906,16 @@ ScVbaRange::getPageBreak() throw (uno::RuntimeException) { ScDocument* pDoc = getDocumentFromRange( mxRange ); - BYTE nFlag = 0; + ScBreakType nBreak = BREAK_NONE; if ( !bColumn ) - nFlag = pDoc -> GetRowFlags(thisAddress.StartRow, thisAddress.Sheet); + nBreak = pDoc->HasRowBreak(thisAddress.StartRow, thisAddress.Sheet); else - nFlag = pDoc -> GetColFlags(static_cast<SCCOL>(thisAddress.StartColumn), thisAddress.Sheet); + nBreak = pDoc->HasColBreak(thisAddress.StartColumn, thisAddress.Sheet); - if ( nFlag & CR_PAGEBREAK) + if (nBreak & BREAK_PAGE) nPageBreak = excel::XlPageBreak::xlPageBreakAutomatic; - if ( nFlag & CR_MANUALBREAK) + if (nBreak & BREAK_MANUAL) nPageBreak = excel::XlPageBreak::xlPageBreakManual; } } diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index a461c54f255e..c880a29f8067 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -715,22 +715,22 @@ void ScCellShell::GetState(SfxItemSet &rSet) break; case FID_INS_ROWBRK: - if ( nPosY==0 || (pDoc->GetRowFlags(nPosY,nTab) & CR_MANUALBREAK) ) + if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) ) rSet.DisableItem( nWhich ); break; case FID_INS_COLBRK: - if ( nPosX==0 || (pDoc->GetColFlags(nPosX,nTab) & CR_MANUALBREAK) ) + if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) ) rSet.DisableItem( nWhich ); break; case FID_DEL_ROWBRK: - if ( nPosY==0 || (pDoc->GetRowFlags(nPosY,nTab) & CR_MANUALBREAK)==0 ) + if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) == 0 ) rSet.DisableItem( nWhich ); break; case FID_DEL_COLBRK: - if ( nPosX==0 || (pDoc->GetColFlags(nPosX,nTab) & CR_MANUALBREAK)==0 ) + if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) == 0 ) rSet.DisableItem( nWhich ); break; diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx index 8916624fdb52..d802c08f642f 100644 --- a/sc/source/ui/view/colrowba.cxx +++ b/sc/source/ui/view/colrowba.cxx @@ -98,7 +98,8 @@ USHORT ScColBar::GetEntrySize( SCCOLROW nEntryNo ) { ScDocument* pDoc = pViewData->GetDocument(); SCTAB nTab = pViewData->GetTabNo(); - if ( pDoc->GetColFlags( static_cast<SCCOL>(nEntryNo), nTab ) & CR_HIDDEN ) + SCCOL nLastCol = -1; + if (pDoc->ColHidden(static_cast<SCCOL>(nEntryNo), nTab, nLastCol)) return 0; else return (USHORT) ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab ), pViewData->GetPPTX() ); @@ -265,7 +266,8 @@ USHORT ScRowBar::GetEntrySize( SCCOLROW nEntryNo ) { ScDocument* pDoc = pViewData->GetDocument(); SCTAB nTab = pViewData->GetTabNo(); - if ( pDoc->GetRowFlags( nEntryNo, nTab ) & CR_HIDDEN ) + SCROW nLastRow = -1; + if (pDoc->RowHidden(nEntryNo, nTab, nLastRow)) return 0; else return (USHORT) ScViewData::ToPixel( pDoc->GetOriginalHeight( nEntryNo, diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 35befa8f7a36..dbdeae1ae0b1 100755 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -694,6 +694,9 @@ ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, if( !pDPObj ) return STR_PIVOT_NOTFOUND; + if ( pDocSh && !pDoc ) + pDoc = pDocSh->GetDocument(); + if( !pDoc ) return static_cast<ULONG>(-1); diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx index 3885b0adc752..ba250767c169 100644 --- a/sc/source/ui/view/drawutil.cxx +++ b/sc/source/ui/view/drawutil.cxx @@ -66,14 +66,19 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab, nTwipsX += (long) nWidth; nPixelX += ScViewData::ToPixel( nWidth, nPPTX ); } - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter( - pDoc->GetRowFlagsArray( nTab), nStartRow, nEndRow-1, CR_HIDDEN, 0, - pDoc->GetRowHeightArray( nTab)); - for ( ; aIter; ++aIter ) + + for (SCROW nRow = nStartRow; nRow <= nEndRow-1; ++nRow) { - USHORT nHeight = *aIter; - nTwipsY += (long) nHeight; - nPixelY += ScViewData::ToPixel( nHeight, nPPTY ); + SCROW nLastRow = nRow; + if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow)) + { + nRow = nLastRow; + continue; + } + + USHORT nHeight = pDoc->GetRowHeight(nRow, nTab); + nTwipsY += static_cast<long>(nHeight); + nPixelY += ScViewData::ToPixel(nHeight, nPPTY); } MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY ); @@ -100,10 +105,10 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab, else rScaleY = Fraction( 1, 1 ); - // 17 bits of accuracy are needed to always hit the right part of - // cells in the last rows - rScaleX.ReduceInaccurate( 17 ); - rScaleY.ReduceInaccurate( 17 ); + // 25 bits of accuracy are needed to always hit the right part of + // cells in the last rows (was 17 before 1M rows). + rScaleX.ReduceInaccurate( 25 ); + rScaleY.ReduceInaccurate( 25 ); } diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index 8b9debdabfae..3a28096d2853 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -282,8 +282,8 @@ void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const pDoc->GetTableArea( nTab, nEndCol, nEndRow ); if (nEndCol<20) nEndCol = 20; - if (nEndRow<20) - nEndRow = 20; + if (nEndRow<1000) + nEndRow = 1000; Fraction aZoom(1,1); ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev, aZoom,aZoom, diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index cc09722530ad..1d2b797b3a9b 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -187,7 +187,7 @@ void ScDrawView::AddCustomHdl() if(nCol > 0) --nCol; - SCROW nRow = nPosY <= 0 ? 0 : pDoc->FastGetRowForHeight( nTab, + SCROW nRow = nPosY <= 0 ? 0 : pDoc->GetRowForHeight( nTab, (ULONG) nPosY); if(nRow > 0) --nRow; @@ -376,8 +376,8 @@ void ScDrawView::RecalcScale() pDoc->GetTableArea( nTab, nEndCol, nEndRow ); if (nEndCol<20) nEndCol = 20; - if (nEndRow<20) - nEndRow = 20; + if (nEndRow<1000) + nEndRow = 1000; ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY, aScaleX,aScaleY ); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index a7d2203197d4..0f07b8772254 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -156,7 +156,19 @@ extern USHORT nScFillModeMouseModifier; // global.cxx #define SC_FILTERLISTBOX_LINES 12 -//================================================================== +// ============================================================================ + +ScGridWindow::VisibleRange::VisibleRange() : + mnCol1(0), mnCol2(MAXCOL), mnRow1(0), mnRow2(MAXROW) +{ +} + +bool ScGridWindow::VisibleRange::isInside(SCCOL nCol, SCROW nRow) const +{ + return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2; +} + +// ============================================================================ class ScFilterListBox : public ListBox { @@ -395,6 +407,7 @@ ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhic mpOODragRect( NULL ), mpOOHeader( NULL ), mpOOShrink( NULL ), + mpAutoFillRect(static_cast<Rectangle*>(NULL)), pViewData( pData ), eWhich( eWhichPos ), pNoteMarker( NULL ), @@ -1352,37 +1365,23 @@ BOOL ScGridWindow::TestMouse( const MouseEvent& rMEvt, BOOL bAction ) ScDocument* pDoc = pViewData->GetDocument(); SCTAB nTab = pViewData->GetTabNo(); BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab ); - long nLayoutSign = bLayoutRTL ? -1 : 1; // Auto-Fill ScRange aMarkRange; if (pViewData->GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE) { - if ( aMarkRange.aStart.Tab() == pViewData->GetTabNo() ) + if (aMarkRange.aStart.Tab() == pViewData->GetTabNo() && mpAutoFillRect) { - // Block-Ende wie in DrawAutoFillMark - SCCOL nX = aMarkRange.aEnd.Col(); - SCROW nY = aMarkRange.aEnd.Row(); - - Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE ); - long nSizeXPix; - long nSizeYPix; - pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); - aFillPos.X() += nSizeXPix * nLayoutSign; - aFillPos.Y() += nSizeYPix; - if ( bLayoutRTL ) - aFillPos.X() -= 1; - Point aMousePos = rMEvt.GetPosPixel(); - // Abfrage hier passend zu DrawAutoFillMark - // (ein Pixel mehr als markiert) - if ( aMousePos.X() >= aFillPos.X()-3 && aMousePos.X() <= aFillPos.X()+4 && - aMousePos.Y() >= aFillPos.Y()-3 && aMousePos.Y() <= aFillPos.Y()+4 ) + if (mpAutoFillRect->IsInside(aMousePos)) { SetPointer( Pointer( POINTER_CROSS ) ); //! dickeres Kreuz ? if (bAction) { + SCCOL nX = aMarkRange.aEnd.Col(); + SCROW nY = aMarkRange.aEnd.Row(); + if ( lcl_IsEditableMatrix( pViewData->GetDocument(), aMarkRange ) ) pViewData->SetDragMode( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY, SC_FILL_MATRIX ); @@ -3006,7 +3005,7 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, // clicked on selected object -> don't change anything bHitSelected = TRUE; } - else if ( pViewData->GetMarkData().IsCellMarked( (USHORT) nCellX, (USHORT) nCellY ) ) + else if ( pViewData->GetMarkData().IsCellMarked(nCellX, nCellY) ) { // clicked on selected cell -> don't change anything bHitSelected = TRUE; @@ -3030,7 +3029,7 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, if ( !bHitDraw ) { pView->Unmark(); - pView->SetCursor( (USHORT) nCellX, (USHORT) nCellY ); + pView->SetCursor(nCellX, nCellY); if ( bWasDraw ) pViewData->GetViewShell()->SetDrawShell( FALSE ); // switch shells } @@ -4605,18 +4604,17 @@ void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, USHORT nEdges SCROW nTmp; ScDocument* pDoc = pDocSh->GetDocument(); - while ( nCol1 > 0 && ( pDoc->GetColFlags( nCol1, nTab1 ) & CR_HIDDEN ) ) + while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab1) ) { --nCol1; bHiddenEdge = TRUE; } - while ( nCol2 < MAXCOL && ( pDoc->GetColFlags( nCol2, nTab1 ) & CR_HIDDEN ) ) + while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab1) ) { ++nCol2; bHiddenEdge = TRUE; } - nTmp = pDoc->GetRowFlagsArray( nTab1).GetLastForCondition( 0, nRow1, - CR_HIDDEN, 0); + nTmp = pDoc->FirstVisibleRow(0, nRow1, nTab1); if (!ValidRow(nTmp)) nTmp = 0; if (nTmp < nRow1) @@ -4624,8 +4622,7 @@ void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, USHORT nEdges nRow1 = nTmp; bHiddenEdge = TRUE; } - nTmp = pDoc->GetRowFlagsArray( nTab1).GetFirstForCondition( nRow2, MAXROW, - CR_HIDDEN, 0); + nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab1); if (!ValidRow(nTmp)) nTmp = MAXROW; if (nTmp > nRow2) @@ -5178,6 +5175,9 @@ void ScGridWindow::UpdateCursorOverlay() SCCOL nX = pViewData->GetCurX(); SCROW nY = pViewData->GetCurY(); + if (!maVisibleRange.isInside(nX, nY)) + return; + // don't show the cursor in overlapped cells ScDocument* pDoc = pViewData->GetDocument(); @@ -5353,6 +5353,7 @@ void ScGridWindow::UpdateSelectionOverlay() void ScGridWindow::DeleteAutoFillOverlay() { DELETEZ( mpOOAutoFill ); + mpAutoFillRect.reset(); } void ScGridWindow::UpdateAutoFillOverlay() @@ -5373,6 +5374,11 @@ void ScGridWindow::UpdateAutoFillOverlay() { SCCOL nX = aAutoMarkPos.Col(); SCROW nY = aAutoMarkPos.Row(); + + if (!maVisibleRange.isInside(nX, nY)) + // Autofill mark is not visible. Bail out. + return; + SCTAB nTab = pViewData->GetTabNo(); ScDocument* pDoc = pViewData->GetDocument(); BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab ); @@ -5388,7 +5394,7 @@ void ScGridWindow::UpdateAutoFillOverlay() aFillPos.Y() += nSizeYPix; aFillPos.Y() -= 2; - Rectangle aFillRect( aFillPos, Size(6,6) ); + mpAutoFillRect.reset(new Rectangle(aFillPos, Size(6, 6))); // #i70788# get the OverlayManager safely ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); @@ -5398,7 +5404,7 @@ void ScGridWindow::UpdateAutoFillOverlay() const Color aHandleColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); std::vector< basegfx::B2DRange > aRanges; const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); - basegfx::B2DRange aRB(aFillRect.Left(), aFillRect.Top(), aFillRect.Right() + 1, aFillRect.Bottom() + 1); + basegfx::B2DRange aRB(mpAutoFillRect->Left(), mpAutoFillRect->Top(), mpAutoFillRect->Right() + 1, mpAutoFillRect->Bottom() + 1); aRB.transform(aTransform); aRanges.push_back(aRB); @@ -5413,10 +5419,10 @@ void ScGridWindow::UpdateAutoFillOverlay() mpOOAutoFill = new ::sdr::overlay::OverlayObjectList; mpOOAutoFill->append(*pOverlay); } - } - if ( aOldMode != aDrawMode ) - SetMapMode( aOldMode ); + if ( aOldMode != aDrawMode ) + SetMapMode( aOldMode ); + } } void ScGridWindow::DeleteDragRectOverlay() diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index 6d9bb94eb76b..f8b5c25c4a70 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -933,7 +933,7 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp ) BOOL bGrow = !bHide && nNew > nPagebreakBreak; if ( bColumn ) { - if ( pDoc->GetColFlags( static_cast<SCCOL>(nPagebreakBreak), nTab ) & CR_MANUALBREAK ) + if (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakBreak), nTab) & BREAK_MANUAL) { ScAddress aOldAddr( static_cast<SCCOL>(nPagebreakBreak), nPosY, nTab ); pViewFunc->DeletePageBreak( TRUE, TRUE, &aOldAddr, FALSE ); @@ -946,8 +946,8 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp ) if ( bGrow ) { // vorigen Break auf hart, und Skalierung aendern - if ( static_cast<SCCOL>(nPagebreakPrev) > aPagebreakSource.aStart.Col() && - !(pDoc->GetColFlags( static_cast<SCCOL>(nPagebreakPrev), nTab ) & CR_MANUALBREAK) ) + bool bManualBreak = (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakPrev), nTab) & BREAK_MANUAL); + if ( static_cast<SCCOL>(nPagebreakPrev) > aPagebreakSource.aStart.Col() && !bManualBreak ) { ScAddress aPrev( static_cast<SCCOL>(nPagebreakPrev), nPosY, nTab ); pViewFunc->InsertPageBreak( TRUE, TRUE, &aPrev, FALSE ); @@ -960,7 +960,7 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp ) } else { - if ( pDoc->GetRowFlags( nPagebreakBreak, nTab ) & CR_MANUALBREAK ) + if (pDoc->HasRowBreak(nPagebreakBreak, nTab) & BREAK_MANUAL) { ScAddress aOldAddr( nPosX, nPagebreakBreak, nTab ); pViewFunc->DeletePageBreak( FALSE, TRUE, &aOldAddr, FALSE ); @@ -973,8 +973,8 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp ) if ( bGrow ) { // vorigen Break auf hart, und Skalierung aendern - if ( nPagebreakPrev > aPagebreakSource.aStart.Row() && - !(pDoc->GetRowFlags( nPagebreakPrev, nTab ) & CR_MANUALBREAK) ) + bool bManualBreak = (pDoc->HasRowBreak(nPagebreakPrev, nTab) & BREAK_MANUAL); + if ( nPagebreakPrev > aPagebreakSource.aStart.Row() && !bManualBreak ) { ScAddress aPrev( nPosX, nPagebreakPrev, nTab ); pViewFunc->InsertPageBreak( FALSE, TRUE, &aPrev, FALSE ); diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx index 5bfc0483b553..f16c2fe1ada7 100644..100755 --- a/sc/source/ui/view/gridwin3.cxx +++ b/sc/source/ui/view/gridwin3.cxx @@ -265,7 +265,7 @@ MapMode ScGridWindow::GetDrawMapMode( BOOL bForce ) SCROW nEndRow = 0; pDoc->GetTableArea( nTab, nEndCol, nEndRow ); if (nEndCol<20) nEndCol = 20; - if (nEndRow<20) nEndRow = 20; + if (nEndRow<1000) nEndRow = 1000; ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, this, pViewData->GetZoomX(),pViewData->GetZoomY(), pViewData->GetPPTX(),pViewData->GetPPTY(), diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index f698913ea758..d8024e439173 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -449,6 +449,12 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich); if (nYBottom > MAXROW) nYBottom = MAXROW; + // Store the current visible range. + maVisibleRange.mnCol1 = nPosX; + maVisibleRange.mnCol2 = nXRight; + maVisibleRange.mnRow1 = nPosY; + maVisibleRange.mnRow2 = nYBottom; + if (nX1 > nXRight || nY1 > nYBottom) return; // unsichtbar if (nX2 > nXRight) nX2 = nXRight; @@ -1086,7 +1092,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, if ( nBreak >= nX1 && nBreak <= nX2+1 ) { //! hidden suchen - if ( pDoc->GetColFlags( nBreak, nTab ) & CR_MANUALBREAK ) + if (pDoc->HasColBreak(nBreak, nTab) & BREAK_MANUAL) pContentDev->SetFillColor( aManual ); else pContentDev->SetFillColor( aAutomatic ); @@ -1105,7 +1111,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, if ( nBreak >= nY1 && nBreak <= nY2+1 ) { //! hidden suchen - if ( pDoc->GetRowFlags( nBreak, nTab ) & CR_MANUALBREAK ) + if (pDoc->HasRowBreak(nBreak, nTab) & BREAK_MANUAL) pContentDev->SetFillColor( aManual ); else pContentDev->SetFillColor( aAutomatic ); @@ -1374,7 +1380,7 @@ Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos ) const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(pDoc->GetAttr( nCol,nRow,nTab, ATTR_MERGE )); if ( pMerge->GetColMerge() > 1 ) nNextCol = nCol + pMerge->GetColMerge(); // next cell after the merged area - while ( nNextCol <= MAXCOL && (pDoc->GetColFlags( nNextCol, nTab ) & CR_HIDDEN) ) + while ( nNextCol <= MAXCOL && pDoc->ColHidden(nNextCol, nTab) ) ++nNextCol; BOOL bNextCell = ( nNextCol <= MAXCOL ); if ( bNextCell ) @@ -1577,7 +1583,7 @@ void ScGridWindow::InvertSimple( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) ) { while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 && - ( (pDoc->GetRowFlags( nThisY-1, nTab ) & CR_HIDDEN) || bFirstRow ) ) + (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) ) { --nThisY; pPattern = pDoc->GetPattern( nX, nThisY, nTab ); @@ -1764,7 +1770,7 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects ) if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) ) { while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 && - ( (pDoc->GetRowFlags( nThisY-1, nTab ) & CR_HIDDEN) || bFirstRow ) ) + (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) ) { --nThisY; pPattern = pDoc->GetPattern( nX, nThisY, nTab ); diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx index 6c389d496b73..25f3c1c8f10a 100644 --- a/sc/source/ui/view/hdrcont.cxx +++ b/sc/source/ui/view/hdrcont.cxx @@ -102,7 +102,7 @@ ScHeaderControl::ScHeaderControl( Window* pParent, SelectionEngine* pSelectionEn nWidth = nSmallWidth = aSize.Width(); nBigWidth = LogicToPixel( Size( GetTextWidth( - String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("88888")) ), 0 ) ).Width() + 4; + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("8888888")) ), 0 ) ).Width() + 5; SetBackground(); // sonst Probleme auf OS/2 !?!?! } diff --git a/sc/source/ui/view/makefile.mk b/sc/source/ui/view/makefile.mk index feeacc865fba..1b2fef913fc2 100644 --- a/sc/source/ui/view/makefile.mk +++ b/sc/source/ui/view/makefile.mk @@ -155,6 +155,7 @@ EXCEPTIONSFILES= \ $(SLO)$/gridwin2.obj \ $(SLO)$/scextopt.obj \ $(SLO)$/tabvwshb.obj \ + $(SLO)$/tabvwshf.obj \ $(SLO)$/viewdata.obj \ $(SLO)$/viewfunc.obj \ $(SLO)$/viewfun2.obj \ diff --git a/sc/source/ui/view/olinewin.cxx b/sc/source/ui/view/olinewin.cxx index bec88920f989..b1e82fd9217f 100644 --- a/sc/source/ui/view/olinewin.cxx +++ b/sc/source/ui/view/olinewin.cxx @@ -183,16 +183,15 @@ const ScOutlineEntry* ScOutlineWindow::GetOutlineEntry( size_t nLevel, size_t nE bool ScOutlineWindow::IsHidden( SCCOLROW nColRowIndex ) const { - sal_uInt8 nFlags = mbHoriz ? - GetDoc().GetColFlags( static_cast<SCCOL>(nColRowIndex), GetTab() ) : - GetDoc().GetRowFlags( static_cast<SCROW>(nColRowIndex), GetTab() ); - return (nFlags & CR_HIDDEN) != 0; + return mbHoriz ? + GetDoc().ColHidden(static_cast<SCCOL>(nColRowIndex), GetTab()) : + GetDoc().RowHidden(static_cast<SCROW>(nColRowIndex), GetTab()); } bool ScOutlineWindow::IsFiltered( SCCOLROW nColRowIndex ) const { // columns cannot be filtered - return !mbHoriz && GetDoc().IsFiltered( static_cast<SCROW>(nColRowIndex), GetTab() ); + return !mbHoriz && GetDoc().RowFiltered( static_cast<SCROW>(nColRowIndex), GetTab() ); } bool ScOutlineWindow::IsFirstVisible( SCCOLROW nColRowIndex ) const diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 265e54fe0e12..961572fc0185 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -322,8 +322,9 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) long nPosX; long nPosY; SCSIZE nArrY; - BYTE nOldFlags = 0; - BYTE nFlags; + ScBreakType nBreak = BREAK_NONE; + ScBreakType nBreakOld = BREAK_NONE; + BOOL bSingle; Color aPageColor; Color aManualColor; @@ -378,27 +379,27 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) if ( bPage ) { // Seitenumbrueche auch in ausgeblendeten suchen - nFlags = 0; SCCOL nCol = nXplus1; while (nCol <= MAXCOL) { - BYTE nDocFl = pDoc->GetColFlags( nCol, nTab ); - nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); - if ( nFlags || !(nDocFl & CR_HIDDEN) ) + nBreak = pDoc->HasColBreak(nCol, nTab); + bool bHidden = pDoc->ColHidden(nCol, nTab); + + if ( nBreak || !bHidden ) break; ++nCol; } - if (nFlags != nOldFlags) + if (nBreak != nBreakOld) { aGrid.Flush(); - pDev->SetLineColor( (nFlags & CR_MANUALBREAK) ? aManualColor : - (nFlags) ? aPageColor : aGridColor ); - nOldFlags = nFlags; + pDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor : + nBreak ? aPageColor : aGridColor ); + nBreakOld = nBreak; } } - BOOL bDraw = bGrid || nOldFlags; // einfaches Gitter nur wenn eingestellt + BOOL bDraw = bGrid || nBreakOld; // einfaches Gitter nur wenn eingestellt //! Mit dieser Abfrage wird zuviel weggelassen, wenn ein automatischer //! Umbruch mitten in den Wiederholungsspalten liegt. @@ -409,7 +410,7 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) { if ( nX == MAXCOL ) bDraw = FALSE; - else if (pDoc->GetColFlags(nXplus1,nTab) & ( CR_PAGEBREAK | CR_MANUALBREAK )) + else if (pDoc->HasColBreak(nXplus1, nTab)) bDraw = FALSE; } #endif @@ -500,28 +501,24 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) { if ( bPage ) { - // Seitenumbrueche auch in ausgeblendeten suchen - nFlags = 0; - ScCompressedArrayIterator< SCROW, BYTE > aIter( - pDoc->GetRowFlagsArray( nTab), nYplus1, MAXROW); - do + for (SCROW i = nYplus1; i <= MAXROW; ++i) { - BYTE nDocFl = *aIter; - nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); - if ( nFlags || !(nDocFl & CR_HIDDEN) ) + nBreak = pDoc->HasRowBreak(i, nTab); + bool bHidden = pDoc->RowHidden(i, nTab); + if (nBreak || !bHidden) break; - } while (aIter.NextRange()); + } - if (nFlags != nOldFlags) + if (nBreakOld != nBreak) { aGrid.Flush(); - pDev->SetLineColor( (nFlags & CR_MANUALBREAK) ? aManualColor : - (nFlags) ? aPageColor : aGridColor ); - nOldFlags = nFlags; + pDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor : + (nBreak) ? aPageColor : aGridColor ); + nBreakOld = nBreak; } } - BOOL bDraw = bGrid || nOldFlags; // einfaches Gitter nur wenn eingestellt + BOOL bDraw = bGrid || nBreakOld; // einfaches Gitter nur wenn eingestellt //! Mit dieser Abfrage wird zuviel weggelassen, wenn ein automatischer //! Umbruch mitten in den Wiederholungszeilen liegt. @@ -532,7 +529,7 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) { if ( nY == MAXROW ) bDraw = FALSE; - else if (pDoc->GetRowFlags(nYplus1,nTab) & ( CR_PAGEBREAK | CR_MANUALBREAK )) + else if (pDoc->HasRowBreak(nYplus1, nTab)) bDraw = FALSE; } #endif @@ -654,7 +651,7 @@ void ScOutputData::FindRotated() const ScPatternAttr* pPattern = pInfo->pPatternAttr; const SfxItemSet* pCondSet = pInfo->pConditionSet; - if ( !pPattern && (pDoc->GetColFlags(nX,nTab) & CR_HIDDEN) == 0 ) + if ( !pPattern && !pDoc->ColHidden(nX, nTab) ) { pPattern = pDoc->GetPattern( nX, nY, nTab ); pCondSet = pDoc->GetCondResult( nX, nY, nTab ); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 37bc941c0f16..b0b040f9b5e0 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -114,6 +114,7 @@ class ScDrawStringsVars long nMaxDigitWidth; long nSignWidth; long nDotWidth; + long nExpWidth; ScBaseCell* pLastCell; ULONG nValueFormat; @@ -173,6 +174,7 @@ private: long GetMaxDigitWidth(); long GetSignWidth(); long GetDotWidth(); + long GetExpWidth(); void TextChanged(); long ConvertWidthLogicToPixel( long nWidth ) const; }; @@ -193,6 +195,7 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, BOOL bPTL) : nMaxDigitWidth( 0 ), nSignWidth( 0 ), nDotWidth( 0 ), + nExpWidth( 0 ), pLastCell ( NULL ), nValueFormat( 0 ), bLineBreak ( FALSE ), @@ -262,6 +265,7 @@ void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* nMaxDigitWidth = 0; nSignWidth = 0; nDotWidth = 0; + nExpWidth = 0; pPattern = pNew; pCondSet = pSet; @@ -417,6 +421,7 @@ void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxIt nMaxDigitWidth = 0; nSignWidth = 0; nDotWidth = 0; + nExpWidth = 0; // wird gerufen, wenn sich die Font-Variablen nicht aendern (!StringDiffer) pPattern = pNew; @@ -547,7 +552,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) // Failed to get output string. Bail out. return; - sal_uInt8 nSignCount = 0, nDecimalCount = 0; + sal_uInt8 nSignCount = 0, nDecimalCount = 0, nExpCount = 0; xub_StrLen nLen = aString.Len(); sal_Unicode cDecSep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator.getStr()[0]; for (xub_StrLen i = 0; i < nLen; ++i) @@ -557,13 +562,17 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) ++nSignCount; else if (c == cDecSep) ++nDecimalCount; + else if (c == sal_Unicode('E')) + ++nExpCount; } if (nDecimalCount) nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount; if (nSignCount) nWidth += (nMaxDigit - GetSignWidth()) * nSignCount; + if (nExpCount) + nWidth += (nMaxDigit - GetExpWidth()) * nExpCount; - if (nDecimalCount || nSignCount) + if (nDecimalCount || nSignCount || nExpCount) { // Re-calculate. nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit); @@ -658,6 +667,17 @@ long ScDrawStringsVars::GetDotWidth() return nDotWidth; } +long ScDrawStringsVars::GetExpWidth() +{ + if (nExpWidth > 0) + return nExpWidth; + + nExpWidth = pOutput->pFmtDevice->GetTextWidth(String('E')); + if (bPixelToLogic) + nExpWidth = ConvertWidthLogicToPixel(nExpWidth); + return nExpWidth; +} + void ScDrawStringsVars::TextChanged() { OutputDevice* pRefDevice = pOutput->pRefDevice; @@ -844,7 +864,7 @@ BOOL ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY, while (bHOver) // nY konstant { --rOverX; - bHidden = ( (pDoc->GetColFlags(rOverX,nTab) & CR_HIDDEN) != 0 ); + bHidden = pDoc->ColHidden(rOverX, nTab); if ( !bDoMerge && !bHidden ) return FALSE; @@ -868,7 +888,7 @@ BOOL ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY, while (bVOver) { --rOverY; - bHidden = ( (pDoc->GetRowFlags(rOverY,nTab) & CR_HIDDEN) != 0 ); + bHidden = pDoc->RowHidden(rOverY, nTab); if ( !bDoMerge && !bHidden ) return FALSE; @@ -876,8 +896,8 @@ BOOL ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY, --nArrY; // lokale Kopie ! if (rOverX >= nX1 && rOverY >= nY1 && - (pDoc->GetColFlags(rOverX,nTab) & CR_HIDDEN) == 0 && - (pDoc->GetRowFlags(rOverY,nTab) & CR_HIDDEN) == 0 && + !pDoc->ColHidden(rOverX, nTab) && + !pDoc->RowHidden(rOverY, nTab) && pRowInfo[nArrY].nRowNo == rOverY) { // rVirtPosY -= pRowInfo[nArrY].nHeight; @@ -2176,7 +2196,7 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) if (bDoCell) { if ( nCellY == nY && nCellX >= nX1 && nCellX <= nX2 && - (pDoc->GetColFlags(nCellX,nTab) & CR_HIDDEN) == 0 ) + !pDoc->ColHidden(nCellX, nTab) ) { CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nCellX+1]; pPattern = rCellInfo.pPatternAttr; diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx index 67e1aa86553a..fd36a1b2c1d0 100644 --- a/sc/source/ui/view/prevloc.cxx +++ b/sc/source/ui/view/prevloc.cxx @@ -350,9 +350,9 @@ Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPos, cons long nSizeX = (long) ( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX ); SCROW nEndRow = rCellPos.Row(); - long nPosY = (long) pDoc->FastGetScaledRowHeight( rRange.aStart.Row(), + long nPosY = (long) pDoc->GetScaledRowHeight( rRange.aStart.Row(), nEndRow, nTab, nScaleY); - long nSizeY = (long) ( pDoc->FastGetRowHeight( nEndRow, nTab ) * nScaleY ); + long nSizeY = (long) ( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY ); Size aOffsetLogic( nPosX, nPosY ); Size aSizeLogic( nSizeX, nSizeY ); @@ -599,11 +599,11 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev ++nColCount; if ( bHasRepCols ) for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ ) - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 ) + if (!pDoc->ColHidden(nCol, nTab)) ++nColCount; if ( bHasMainCols ) for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ ) - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 ) + if (!pDoc->ColHidden(nCol, nTab)) ++nColCount; if ( nColCount > 0 ) @@ -620,7 +620,7 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev { long nPosX = 0; for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ ) - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 ) + if (!pDoc->ColHidden(nCol, nTab)) { USHORT nDocW = pDoc->GetColWidth( nCol, nTab ); long nNextX = nPosX + (long) (nDocW * nScaleX); @@ -639,7 +639,7 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev { long nPosX = 0; for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ ) - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 ) + if (!pDoc->ColHidden(nCol, nTab)) { USHORT nDocW = pDoc->GetColWidth( nCol, nTab ); long nNextX = nPosX + (long) (nDocW * nScaleX); @@ -667,11 +667,9 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev if ( bHasHeaderRow ) ++nRowCount; if ( bHasRepRows ) - nRowCount += pDoc->GetRowFlagsArray( nTab).CountForCondition( - nRepeatRowStart, nRepeatRowEnd, CR_HIDDEN, 0); + nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab); if ( bHasMainRows ) - nRowCount += pDoc->GetRowFlagsArray( nTab).CountForCondition( - nMainRowStart, nMainRowEnd, CR_HIDDEN, 0); + nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab); if ( nRowCount > 0 ) { @@ -686,58 +684,44 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev if ( bHasRepRows ) { long nPosY = 0; - ScCompressedArrayIterator< SCROW, BYTE> aIter( - pDoc->GetRowFlagsArray( nTab), nRepeatRowStart, - nRepeatRowEnd); - do + for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow) { - if ((*aIter & CR_HIDDEN) == 0) - { - SCROW nRangeEnd = aIter.GetRangeEnd(); - for (SCROW nRow=aIter.GetRangeStart(); nRow<=nRangeEnd; ++nRow) - { - USHORT nDocH = pDoc->FastGetOriginalRowHeight( nRow, nTab ); - long nNextY = nPosY + (long) (nDocH * nScaleY); - - long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height(); - long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1; - pRowInfo[nRowPos].Set( FALSE, nRow, - aRepeatRect.Top() + nPixelStart, - aRepeatRect.Top() + nPixelEnd ); - - nPosY = nNextY; - ++nRowPos; - } - } - } while (aIter.NextRange()); + if (pDoc->RowHidden(nRow, nTab)) + continue; + + USHORT nDocH = pDoc->GetOriginalHeight( nRow, nTab ); + long nNextY = nPosY + (long) (nDocH * nScaleY); + + long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height(); + long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1; + pRowInfo[nRowPos].Set( FALSE, nRow, + aRepeatRect.Top() + nPixelStart, + aRepeatRect.Top() + nPixelEnd ); + + nPosY = nNextY; + ++nRowPos; + } } if ( bHasMainRows ) { long nPosY = 0; - ScCompressedArrayIterator< SCROW, BYTE> aIter( - pDoc->GetRowFlagsArray( nTab), nMainRowStart, - nMainRowEnd); - do + for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow) { - if ((*aIter & CR_HIDDEN) == 0) - { - SCROW nRangeEnd = aIter.GetRangeEnd(); - for (SCROW nRow=aIter.GetRangeStart(); nRow<=nRangeEnd; ++nRow) - { - USHORT nDocH = pDoc->FastGetOriginalRowHeight( nRow, nTab ); - long nNextY = nPosY + (long) (nDocH * nScaleY); - - long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height(); - long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1; - pRowInfo[nRowPos].Set( FALSE, nRow, - aMainRect.Top() + nPixelStart, - aMainRect.Top() + nPixelEnd ); - - nPosY = nNextY; - ++nRowPos; - } - } - } while (aIter.NextRange()); + if (pDoc->RowHidden(nRow, nTab)) + continue; + + USHORT nDocH = pDoc->GetOriginalHeight( nRow, nTab ); + long nNextY = nPosY + (long) (nDocH * nScaleY); + + long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height(); + long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1; + pRowInfo[nRowPos].Set( FALSE, nRow, + aMainRect.Top() + nPixelStart, + aMainRect.Top() + nPixelEnd ); + + nPosY = nNextY; + ++nRowPos; + } } rInfo.SetRowInfo( nRowCount, pRowInfo ); } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index afe23892e786..378ea1233cf9 100644..100755 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -85,6 +85,8 @@ #include <vcl/lineinfo.hxx> #include <tools/pstm.hxx> +#include <boost/scoped_ptr.hpp> + #define ZOOM_MIN 10 #define GET_BOOL(set,which) ((const SfxBoolItem&)(set)->Get((which))).GetValue() @@ -1501,7 +1503,7 @@ void ScPrintFunc::PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY ) for (SCROW nRow=nY1; nRow<=nY2; nRow++) { - USHORT nDocH = pDoc->FastGetRowHeight( nRow, nPrintTab ); + USHORT nDocH = pDoc->GetRowHeight( nRow, nPrintTab ); if (nDocH) { long nHeight = (long) (nDocH * nScaleY); @@ -1557,7 +1559,7 @@ void ScPrintFunc::LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY, nEndX -= nOneX; long nPosY = nScrY - nOneY; - nPosY += pDoc->FastGetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY); + nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY); Rectangle aCellRect( nScrX, nScrY, nEndX, nPosY ); rLocationData.AddRowHeaders( aCellRect, nY1, nY2, bRepRow ); } @@ -1599,7 +1601,7 @@ void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, } long nPosY = nScrY - nOneY; - nPosY += pDoc->FastGetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY); + nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY); Rectangle aCellRect( nScrX, nScrY, nPosX, nPosY ); rLocationData.AddCellRange( aCellRect, ScRange( nX1,nY1,nPrintTab, nX2,nY2,nPrintTab ), bRepCol, bRepRow, aDrawMapMode ); @@ -2181,9 +2183,9 @@ void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCRO } if ( bCenterVer ) { - long nDataHeight = pDoc->FastGetRowHeight( nY1, nY2, nPrintTab); + long nDataHeight = pDoc->GetRowHeight( nY1, nY2, nPrintTab); if (bDoRepRow) - nDataHeight += pDoc->FastGetRowHeight( nRepeatStartRow, + nDataHeight += pDoc->GetRowHeight( nRepeatStartRow, nRepeatEndRow, nPrintTab); if (aTableParam.bHeaders) nDataHeight += (long) PRINT_HEADER_HEIGHT; @@ -2216,11 +2218,11 @@ void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCRO for (SCCOL i=nRepeatStartCol; i<=nRepeatEndCol; i++) nRepeatWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX); if (bDoRepRow) - nRepeatHeight += pDoc->FastGetScaledRowHeight( nRepeatStartRow, + nRepeatHeight += pDoc->GetScaledRowHeight( nRepeatStartRow, nRepeatEndRow, nPrintTab, nScaleY); for (SCCOL i=nX1; i<=nX2; i++) nContentWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX); - nContentHeight += pDoc->FastGetScaledRowHeight( nY1, nY2, nPrintTab, + nContentHeight += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY); // partition the page @@ -2886,30 +2888,84 @@ void ScPrintFunc::CalcZoom( USHORT nRangeNo ) // Zoom bere if (aTableParam.bScalePageNum) { nZoom = 100; - BOOL bFound = FALSE; USHORT nPagesToFit = aTableParam.nScalePageNum; - while (!bFound) + + sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0; + while (true) { + if (nZoom <= ZOOM_MIN) + break; + CalcPages(); - if ( nPagesX * nPagesY <= nPagesToFit || nZoom <= ZOOM_MIN ) - bFound = TRUE; + bool bFitsPage = (nPagesX * nPagesY <= nPagesToFit); + + if (bFitsPage) + { + if (nZoom == 100) + // If it fits at 100 %, it's good enough for me. + break; + + nLastFitZoom = nZoom; + nZoom = (nLastNonFitZoom + nZoom) / 2; + + if (nLastFitZoom == nZoom) + // It converged. Use this zoom level. + break; + } else - --nZoom; + { + if (nZoom - nLastFitZoom <= 1) + { + nZoom = nLastFitZoom; + CalcPages(); + break; + } + + nLastNonFitZoom = nZoom; + nZoom = (nLastFitZoom + nZoom) / 2; + } } } else if (aTableParam.bScaleTo) { nZoom = 100; - BOOL bFound = FALSE; USHORT nW = aTableParam.nScaleWidth; USHORT nH = aTableParam.nScaleHeight; - while (!bFound) + + sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0; + while (true) { + if (nZoom <= ZOOM_MIN) + break; + CalcPages(); - if ( ((!nW || (nPagesX <= nW)) && (!nH || (nPagesY <= nH))) || (nZoom <= ZOOM_MIN) ) - bFound = TRUE; + bool bFitsPage = ((!nW || (nPagesX <= nW)) && (!nH || (nPagesY <= nH))); + + if (bFitsPage) + { + if (nZoom == 100) + // If it fits at 100 %, it's good enough for me. + break; + + nLastFitZoom = nZoom; + nZoom = (nLastNonFitZoom + nZoom) / 2; + + if (nLastFitZoom == nZoom) + // It converged. Use this zoom level. + break; + } else - --nZoom; + { + if (nZoom - nLastFitZoom <= 1) + { + nZoom = nLastFitZoom; + CalcPages(); + break; + } + + nLastNonFitZoom = nZoom; + nZoom = (nLastFitZoom + nZoom) / 2; + } } } else if (aTableParam.bScaleAll) @@ -3029,18 +3085,20 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten au nPagesY = 0; nTotalY = 0; - BOOL bVisCol = FALSE; + bool bVisCol = false; + SCCOL nLastCol = -1; for (SCCOL i=nStartCol; i<=nEndCol; i++) { - BYTE nFlags = pDoc->GetColFlags(i,nPrintTab); - if ( i>nStartCol && bVisCol && (nFlags & CR_PAGEBREAK) ) + bool bHidden = pDoc->ColHidden(i, nPrintTab, nLastCol); + bool bPageBreak = (pDoc->HasColBreak(i, nPrintTab) & BREAK_PAGE); + if ( i>nStartCol && bVisCol && bPageBreak ) { pPageEndX[nPagesX] = i-1; ++nPagesX; - bVisCol = FALSE; + bVisCol = false; } - if (!(nFlags & CR_HIDDEN)) - bVisCol = TRUE; + if (!bHidden) + bVisCol = true; } if (bVisCol) // auch am Ende keine leeren Seiten { @@ -3048,39 +3106,60 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten au ++nPagesX; } - BOOL bVisRow = FALSE; + bool bVisRow = false; SCROW nPageStartRow = nStartRow; - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray( - nPrintTab), nStartRow, nEndRow); - do + SCROW nLastVisibleRow = -1; + + ::boost::scoped_ptr<ScRowBreakIterator> pRowBreakIter(pDoc->GetRowBreakIterator(nPrintTab)); + SCROW nNextPageBreak = pRowBreakIter->first(); + while (nNextPageBreak != ScRowBreakIterator::NOT_FOUND && nNextPageBreak < nStartRow) + // Skip until the page break position is at the start row or greater. + nNextPageBreak = pRowBreakIter->next(); + + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow) { - BYTE nFlags = *aIter; - SCROW nRangeEnd = aIter.GetRangeEnd(); - for (SCROW j=aIter.GetRangeStart(); j<=nRangeEnd; ++j) + bool bPageBreak = (nNextPageBreak == nRow); + if (bPageBreak) + nNextPageBreak = pRowBreakIter->next(); + + if (nRow > nStartRow && bVisRow && bPageBreak ) { - if ( j>nStartRow && bVisRow && (nFlags & CR_PAGEBREAK) ) + pPageEndY[nTotalY] = nRow-1; + ++nTotalY; + + if ( !aTableParam.bSkipEmpty || + !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1 ) ) { - pPageEndY[nTotalY] = j-1; - ++nTotalY; + pPageRows[nPagesY].SetStartRow( nPageStartRow ); + pPageRows[nPagesY].SetEndRow( nRow-1 ); + pPageRows[nPagesY].SetPagesX( nPagesX ); + if (aTableParam.bSkipEmpty) + lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX ); + ++nPagesY; + } - if ( !aTableParam.bSkipEmpty || - !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, j-1 ) ) - { - pPageRows[nPagesY].SetStartRow( nPageStartRow ); - pPageRows[nPagesY].SetEndRow( j-1 ); - pPageRows[nPagesY].SetPagesX( nPagesX ); - if (aTableParam.bSkipEmpty) - lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX ); - ++nPagesY; - } + nPageStartRow = nRow; + bVisRow = false; + } - nPageStartRow = j; - bVisRow = FALSE; - } - if (!(nFlags & CR_HIDDEN)) - bVisRow = TRUE; + if (nRow <= nLastVisibleRow) + { + // This row is still visible. Don't bother calling RowHidden() to + // find out, for speed optimization. + bVisRow = true; + continue; + } + + SCROW nLastRow = -1; + if (!pDoc->RowHidden(nRow, nPrintTab, NULL, &nLastRow)) + { + bVisRow = true; + nLastVisibleRow = nLastRow; } - } while (aIter.NextRange()); + else + // skip all hidden rows. + nRow = nLastRow; + } if (bVisRow) { diff --git a/sc/source/ui/view/scextopt.cxx b/sc/source/ui/view/scextopt.cxx index 53852a127937..d5816ecdd289 100644 --- a/sc/source/ui/view/scextopt.cxx +++ b/sc/source/ui/view/scextopt.cxx @@ -36,7 +36,6 @@ // ============================================================================ ScExtDocSettings::ScExtDocSettings() : - maOleSize( ScAddress::INITIALIZE_INVALID ), mfTabBarWidth( -1.0 ), mnLinkCnt( 0 ), mnDisplTab( 0 ) diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx index 4887895c8e6b..b2c9ffdc1395 100644 --- a/sc/source/ui/view/select.cxx +++ b/sc/source/ui/view/select.cxx @@ -275,12 +275,12 @@ BOOL __EXPORT ScViewFunctionSet::SetCursorAtPoint( const Point& rPointPixel, BOO ScDocument* pDoc = pViewData->GetDocument(); SCTAB nTab = pViewData->GetTabNo(); if ( bLeft && !bRightScroll ) - do --nPosX; while ( nPosX>=0 && ( pDoc->GetColFlags( nPosX, nTab ) & CR_HIDDEN ) ); + do --nPosX; while ( nPosX>=0 && pDoc->ColHidden( nPosX, nTab ) ); if ( bTop && !bBottomScroll ) { if (--nPosY >= 0) { - pDoc->GetRowFlagsArray( nTab).GetLastForCondition( 0, nPosY, CR_HIDDEN, 0); + nPosY = pDoc->LastVisibleRow(0, nPosY, nTab); if (!ValidRow(nPosY)) nPosY = -1; } @@ -476,7 +476,7 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol { // #94321# in SetCursorAtPoint hidden columns are skipped. // They must be skipped here too, or the result will always be the first hidden column. - do ++nPosX; while ( nPosX<nStartX && ( pDoc->GetColFlags( nPosX, nTab ) & CR_HIDDEN ) ); + do ++nPosX; while ( nPosX<nStartX && pDoc->ColHidden(nPosX, nTab) ); for (SCCOL i=nPosX; i<nStartX; i++) nSizeX += pDoc->GetColWidth( i, nTab ); } @@ -491,8 +491,7 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol // They must be skipped here too, or the result will always be the first hidden row. if (++nPosY < nStartY) { - nPosY = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition( - nPosY, nStartY-1, CR_HIDDEN, 0); + nPosY = pDoc->FirstVisibleRow(nPosY, nStartY-1, nTab); if (!ValidRow(nPosY)) nPosY = nStartY; } diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index c5572fb9844a..6014ded96e1e 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -59,13 +59,14 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) : DropTargetHelper( this ), DragSourceHelper( this ), pViewData( pData ), - nMouseClickPageId( TABBAR_PAGE_NOTFOUND ), - nSelPageIdByMouse( TABBAR_PAGE_NOTFOUND ), + nMouseClickPageId( TabBar::PAGE_NOT_FOUND ), + nSelPageIdByMouse( TabBar::PAGE_NOT_FOUND ), bErrorShown( FALSE ) { ScDocument* pDoc = pViewData->GetDocument(); String aString; + Color aTabBgColor; SCTAB nCount = pDoc->GetTableCount(); for (SCTAB i=0; i<nCount; i++) { @@ -77,6 +78,11 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) : InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL ); else InsertPage( static_cast<sal_uInt16>(i)+1, aString ); + if ( !pDoc->IsDefaultTabBgColor(i) ) + { + aTabBgColor = pDoc->GetTabBgColor(i); + SetTabBgColor( static_cast<sal_uInt16>(i)+1, aTabBgColor ); + } } } } @@ -157,7 +163,7 @@ void ScTabControl::MouseButtonDown( const MouseEvent& rMEvt ) if( rMEvt.IsLeft() && (rMEvt.GetModifier() == 0) ) nMouseClickPageId = GetPageId( rMEvt.GetPosPixel() ); else - nMouseClickPageId = TABBAR_PAGE_NOTFOUND; + nMouseClickPageId = TabBar::PAGE_NOT_FOUND; TabBar::MouseButtonDown( rMEvt ); } @@ -168,7 +174,7 @@ void ScTabControl::MouseButtonUp( const MouseEvent& rMEvt ) // mouse button down and up on same page? if( nMouseClickPageId != GetPageId( aPos ) ) - nMouseClickPageId = TABBAR_PAGE_NOTFOUND; + nMouseClickPageId = TabBar::PAGE_NOT_FOUND; if ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && nMouseClickPageId != 0 && nMouseClickPageId != TAB_PAGE_NOTFOUND ) { @@ -185,7 +191,7 @@ void ScTabControl::MouseButtonUp( const MouseEvent& rMEvt ) SfxDispatcher* pDispatcher = pViewData->GetViewShell()->GetViewFrame()->GetDispatcher(); pDispatcher->Execute( nSlot, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD ); // forget page ID, to be really sure that the dialog is not called twice - nMouseClickPageId = TABBAR_PAGE_NOTFOUND; + nMouseClickPageId = TabBar::PAGE_NOT_FOUND; } TabBar::MouseButtonUp( rMEvt ); @@ -197,7 +203,7 @@ void ScTabControl::Select() nSelPageIdByMouse = nMouseClickPageId; /* Reset nMouseClickPageId, so that next Select() call may invalidate nSelPageIdByMouse (i.e. if called from keyboard). */ - nMouseClickPageId = TABBAR_PAGE_NOTFOUND; + nMouseClickPageId = TabBar::PAGE_NOT_FOUND; ScModule* pScMod = SC_MOD(); ScDocument* pDoc = pViewData->GetDocument(); @@ -262,6 +268,7 @@ void ScTabControl::Select() rBind.Invalidate( FID_DELETE_TABLE ); rBind.Invalidate( FID_TABLE_SHOW ); rBind.Invalidate( FID_TABLE_HIDE ); + rBind.Invalidate( FID_TAB_SET_TAB_BG_COLOR ); // SetReference nur wenn der Konsolidieren-Dialog offen ist // (fuer Referenzen ueber mehrere Tabellen) @@ -288,16 +295,22 @@ void ScTabControl::UpdateStatus() SCTAB i; String aString; SCTAB nMaxCnt = Max( nCount, static_cast<SCTAB>(GetMaxId()) ); + Color aTabBgColor; BOOL bModified = FALSE; // Tabellen-Namen for (i=0; i<nMaxCnt && !bModified; i++) { if (pDoc->IsVisible(i)) + { pDoc->GetName(i,aString); + aTabBgColor = pDoc->GetTabBgColor(i); + } else + { aString.Erase(); + } - if (GetPageText(static_cast<sal_uInt16>(i)+1) != aString) + if ( (GetPageText(static_cast<sal_uInt16>(i)+1) != aString) || (GetTabBgColor(static_cast<sal_uInt16>(i)+1) != aTabBgColor) ) bModified = TRUE; } @@ -314,6 +327,11 @@ void ScTabControl::UpdateStatus() InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL ); else InsertPage( static_cast<sal_uInt16>(i)+1, aString ); + if ( !pDoc->IsDefaultTabBgColor(i) ) + { + aTabBgColor = pDoc->GetTabBgColor(i); + SetTabBgColor( static_cast<sal_uInt16>(i)+1, aTabBgColor ); + } } } } @@ -371,7 +389,7 @@ void ScTabControl::ActivateView(BOOL bActivate) void ScTabControl::SetSheetLayoutRTL( BOOL bSheetRTL ) { SetEffectiveRTL( bSheetRTL ); - nSelPageIdByMouse = TABBAR_PAGE_NOTFOUND; + nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND; } @@ -607,12 +625,12 @@ void ScTabControl::EndRenaming() void ScTabControl::Mirror() { TabBar::Mirror(); - if( nSelPageIdByMouse != TABBAR_PAGE_NOTFOUND ) + if( nSelPageIdByMouse != TabBar::PAGE_NOT_FOUND ) { Rectangle aRect( GetPageRect( GetCurPageId() ) ); if( !aRect.IsEmpty() ) SetPointerPosPixel( aRect.Center() ); - nSelPageIdByMouse = TABBAR_PAGE_NOTFOUND; // only once after a Select() + nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND; // only once after a Select() } } diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 4938defa437d..0bc4617a9af4 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -1439,7 +1439,7 @@ void ScTabView::ScrollX( long nDeltaX, ScHSplitPos eWhich, BOOL bUpdBars ) SCsCOL nDir = ( nDeltaX > 0 ) ? 1 : -1; ScDocument* pDoc = aViewData.GetDocument(); SCTAB nTab = aViewData.GetTabNo(); - while ( ( pDoc->GetColFlags( nNewX, nTab ) & CR_HIDDEN ) && + while ( pDoc->ColHidden(nNewX, nTab) && nNewX+nDir >= 0 && nNewX+nDir <= MAXCOL ) nNewX = sal::static_int_cast<SCsCOL>( nNewX + nDir ); @@ -1528,7 +1528,7 @@ void ScTabView::ScrollY( long nDeltaY, ScVSplitPos eWhich, BOOL bUpdBars ) SCsROW nDir = ( nDeltaY > 0 ) ? 1 : -1; ScDocument* pDoc = aViewData.GetDocument(); SCTAB nTab = aViewData.GetTabNo(); - while ( ( pDoc->GetRowFlags( nNewY, nTab ) & CR_HIDDEN ) && + while ( pDoc->RowHidden(nNewY, nTab) && nNewY+nDir >= 0 && nNewY+nDir <= MAXROW ) nNewY += nDir; @@ -1615,7 +1615,7 @@ SCROW lcl_LastVisible( ScViewData& rViewData ) SCTAB nTab = rViewData.GetTabNo(); SCROW nVis = MAXROW; - while ( nVis > 0 && pDoc->FastGetRowHeight( nVis, nTab ) == 0 ) + while ( nVis > 0 && pDoc->GetRowHeight( nVis, nTab ) == 0 ) --nVis; return nVis; } diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index b7a773ab2abd..674f6f8ae0ff 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -640,13 +640,13 @@ BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom, } long nBlockY = 0; - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter( - pDoc->GetRowFlagsArray( nTab), 0, nFixPosY-1, CR_HIDDEN, 0, - pDoc->GetRowHeightArray( nTab)); - for ( ; aIter; ++aIter) + for (SCROW nRow = 0; nRow <= nFixPosY-1; ++nRow) { + if (pDoc->RowHidden(nRow, nTab)) + continue; + // for frozen panes, add both parts - USHORT nRowTwips = *aIter; + USHORT nRowTwips = pDoc->GetRowHeight(nRow, nTab); if (nRowTwips) { nBlockY += (long)(nRowTwips * fScaleY); @@ -654,10 +654,9 @@ BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom, return FALSE; } } - aIter.NewLimits( nStartRow, nEndRow); - for ( ; aIter; ++aIter) + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow) { - USHORT nRowTwips = *aIter; + USHORT nRowTwips = pDoc->GetRowHeight(nRow, nTab); if (nRowTwips) { nBlockY += (long)(nRowTwips * fScaleY); diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 9fa23bb4a4b6..90bfe0c24e5c 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -968,8 +968,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bHFlip = FALSE; do { - BYTE nColFlags = pDoc->GetColFlags( nCurX, nTab ); - bSkipCell = (nColFlags & CR_HIDDEN) || pDoc->IsHorOverlapped( nCurX, nCurY, nTab ); + SCCOL nLastCol = -1; + bSkipCell = pDoc->ColHidden(nCurX, nTab, nLastCol) || pDoc->IsHorOverlapped( nCurX, nCurY, nTab ); if (bSkipProtected && !bSkipCell) bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED); if (bSkipUnprotected && !bSkipCell) @@ -1010,8 +1010,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bVFlip = FALSE; do { - BYTE nRowFlags = pDoc->GetRowFlags( nCurY, nTab ); - bSkipCell = (nRowFlags & CR_HIDDEN) || pDoc->IsVerOverlapped( nCurX, nCurY, nTab ); + SCROW nLastRow = -1; + bSkipCell = pDoc->RowHidden(nCurY, nTab, nLastRow) || pDoc->IsVerOverlapped( nCurX, nCurY, nTab ); if (bSkipProtected && !bSkipCell) bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED); if (bSkipUnprotected && !bSkipCell) @@ -2094,17 +2094,18 @@ void ScTabView::PaintRangeFinder( long nNumber ) BOOL bHiddenEdge = FALSE; SCROW nTmp; ScDocument* pDoc = aViewData.GetDocument(); - while ( nCol1 > 0 && ( pDoc->GetColFlags( nCol1, nTab ) & CR_HIDDEN ) ) + SCCOL nLastCol = -1; + while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab, nLastCol) ) { --nCol1; bHiddenEdge = TRUE; } - while ( nCol2 < MAXCOL && ( pDoc->GetColFlags( nCol2, nTab ) & CR_HIDDEN ) ) + while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab, nLastCol) ) { ++nCol2; bHiddenEdge = TRUE; } - nTmp = pDoc->GetRowFlagsArray( nTab).GetLastForCondition( 0, nRow1, CR_HIDDEN, 0); + nTmp = pDoc->LastVisibleRow(0, nRow1, nTab); if (!ValidRow(nTmp)) nTmp = 0; if (nTmp < nRow1) @@ -2112,7 +2113,7 @@ void ScTabView::PaintRangeFinder( long nNumber ) nRow1 = nTmp; bHiddenEdge = TRUE; } - nTmp = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition( nRow2, MAXROW, CR_HIDDEN, 0); + nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab); if (!ValidRow(nTmp)) nTmp = MAXROW; if (nTmp > nRow2) diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index bc5c94c271e2..f0ac3fc42869 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -666,7 +666,7 @@ void ScTabView::MakeVisible( const Rectangle& rHMMRect ) if (nScrollY > 0) while (nScrollY > 0 && nPosY < MAXROW) { - nScrollY -= (long) ( pDoc->FastGetRowHeight(nPosY, nTab) * nPPTY ); + nScrollY -= (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); ++nPosY; ++nLinesY; } @@ -674,7 +674,7 @@ void ScTabView::MakeVisible( const Rectangle& rHMMRect ) while (nScrollY < 0 && nPosY > 0) { --nPosY; - nScrollY += (long) ( pDoc->FastGetRowHeight(nPosY, nTab) * nPPTY ); + nScrollY += (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); --nLinesY; } diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx index a94d73a4b022..c0af39226c3f 100644 --- a/sc/source/ui/view/tabvwshe.cxx +++ b/sc/source/ui/view/tabvwshe.cxx @@ -52,6 +52,7 @@ #include "editsh.hxx" #include "dociter.hxx" #include "inputhdl.hxx" +#include "document.hxx" //================================================================== @@ -88,6 +89,22 @@ String __EXPORT ScTabViewShell::GetSelectionText( BOOL bWholeWord ) else aRange.aEnd = aRange.aStart; } + else + { + // #i111531# with 1M rows it was necessary to limit the range + // to the actually used data area. + SCCOL nCol1, nCol2; + SCROW nRow1, nRow2; + SCTAB nTab1, nTab2; + aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); + if (pDoc->ShrinkToUsedDataArea( nTab1, nCol1, nRow1, nCol2, nRow2, false)) + { + aRange.aStart.SetCol( nCol1 ); + aRange.aStart.SetRow( nRow1 ); + aRange.aEnd.SetCol( nCol2 ); + aRange.aEnd.SetRow( nRow2 ); + } + } ScImportExport aObj( pDoc, aRange ); aObj.SetFormulas( GetViewData()->GetOptions().GetOption( VOPT_FORMULAS ) ); diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 82da92820ab1..20a10f149a3a 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -28,9 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - -// INCLUDE --------------------------------------------------------------- +#include <boost/scoped_ptr.hpp> #include "scitems.hxx" #include <sfx2/request.hxx> @@ -42,6 +40,7 @@ #include <svl/whiter.hxx> #include <vcl/msgbox.hxx> #include <svx/svxdlg.hxx> +#include <editeng/colritem.hxx> #include "tabvwsh.hxx" #include "sc.hrc" @@ -58,6 +57,10 @@ #include "scabstdlg.hxx" //CHINA001 +#include "tabbgcolor.hxx" +#include "tabbgcolordlg.hxx" + +using ::boost::scoped_ptr; using namespace com::sun::star; #define IS_AVAILABLE(WhichId,ppItem) \ @@ -688,13 +691,121 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) } break; + case FID_TAB_SET_TAB_BG_COLOR: + case FID_TAB_MENU_SET_TAB_BG_COLOR: + { + if ( nSlot == FID_TAB_MENU_SET_TAB_BG_COLOR ) + nSlot = FID_TAB_SET_TAB_BG_COLOR; + SCTAB nTabNr = pViewData->GetTabNo(); + ScMarkData& rMark = pViewData->GetMarkData(); + SCTAB nTabSelCount = rMark.GetSelectCount(); + if ( !pDoc->IsDocEditable() ) + break; + + if ( pDoc->IsTabProtected( nTabNr ) ) // ||nTabSelCount > 1 + break; + + if( pReqArgs != NULL ) + { + BOOL bDone = FALSE; + const SfxPoolItem* pItem; + Color aColor; + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + nTabNr = ((const SfxUInt16Item*)pItem)->GetValue(); + + if( IS_AVAILABLE( nSlot, &pItem ) ) + aColor = ((const SvxColorItem*)pItem)->GetValue(); + + if ( nTabSelCount > 1 ) + { + scoped_ptr<ScUndoTabColorInfo::List> + pTabColorList(new ScUndoTabColorInfo::List); + for (SCTAB nTab=0; nTab<nTabCount; nTab++) + { + if ( rMark.GetTableSelect(nTab) && !pDoc->IsTabProtected(nTab) ) + { + ScUndoTabColorInfo aTabColorInfo(nTab); + aTabColorInfo.maNewTabBgColor = aColor; + pTabColorList->push_back(aTabColorInfo); + } + } + bDone = SetTabBgColor( *pTabColorList ); + } + else + { + bDone = SetTabBgColor( aColor, nCurrentTab ); //ScViewFunc.SetTabBgColor + } + if( bDone ) + { + rReq.Done( *pReqArgs ); + } + } + else + { + USHORT nRet = RET_OK; /// temp + BOOL bDone = FALSE; /// temp + Color aTabBgColor; + Color aNewTabBgColor; + + aTabBgColor = pDoc->GetTabBgColor( nCurrentTab ); + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "ScAbstractFactory create fail!"); + AbstractScTabBgColorDlg* pDlg = pFact->CreateScTabBgColorDlg( + GetDialogParent(), + String(ScResId(SCSTR_SET_TAB_BG_COLOR)), + String(ScResId(SCSTR_NO_TAB_BG_COLOR)), + aTabBgColor, + nSlot,RID_SCDLG_TAB_BG_COLOR); + while ( !bDone && nRet == RET_OK ) + { + nRet = pDlg->Execute(); + if( nRet == RET_OK ) + { + Color aSelectedColor; + pDlg->GetSelectedColor(aSelectedColor); + scoped_ptr<ScUndoTabColorInfo::List> + pTabColorList(new ScUndoTabColorInfo::List); + if ( nTabSelCount > 1 ) + { + for (SCTAB nTab=0; nTab<nTabCount; nTab++) + { + if ( rMark.GetTableSelect(nTab) && !pDoc->IsTabProtected(nTab) ) + { + ScUndoTabColorInfo aTabColorInfo(nTab); + aTabColorInfo.maNewTabBgColor = aSelectedColor; + pTabColorList->push_back(aTabColorInfo); + } + } + bDone = SetTabBgColor( *pTabColorList ); + } + else + { + bDone = SetTabBgColor( aSelectedColor, nCurrentTab ); //ScViewFunc.SetTabBgColor + } + if ( bDone ) + { + rReq.AppendItem( SvxColorItem( aTabBgColor, nSlot ) ); + rReq.Done(); + } + else + { + if( rReq.IsAPI() ) + { + StarBASIC::Error( SbERR_SETPROP_FAILED ); + } + } + } + } + delete( pDlg ); + } + } + break; + case FID_TAB_EVENTS: { ScDocShell* pDocSh = pViewData->GetDocShell(); uno::Reference<container::XNameReplace> xEvents( new ScSheetEventsObj( pDocSh, nCurrentTab ) ); - uno::Reference<frame::XFrame> xFrame = GetViewFrame()->GetFrame().GetFrameInterface(); - SvxAbstractDialogFactory* pDlgFactory = SvxAbstractDialogFactory::Create(); if (pDlgFactory) { @@ -826,6 +937,23 @@ void ScTabViewShell::GetStateTable( SfxItemSet& rSet ) rSet.Put( SfxBoolItem( nWhich, pDoc->IsLayoutRTL( nTab ) ) ); } break; + + case FID_TAB_MENU_SET_TAB_BG_COLOR: + { + if ( !pDoc->IsDocEditable() + || ( pDocShell && pDocShell->IsDocShared() ) + || pDoc->IsTabProtected(nTab) ) + rSet.DisableItem( nWhich ); + } + break; + + case FID_TAB_SET_TAB_BG_COLOR: + { + Color aColor; + aColor = pDoc->GetTabBgColor( nTab ); + rSet.Put( SvxColorItem( aColor, nWhich ) ); + } + break; } nWhich = aIter.NextWhich(); } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 6b13c1bedcbf..c034836d4d4a 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -160,9 +160,6 @@ void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue> pSettings[SC_TABLE_ZOOM_VALUE].Value <<= nZoomValue; pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE)); pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue; - -// pSettings[SC_TABLE_SELECTED].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLESELECTED)); -// pSettings[SC_TABLE_SELECTED].Value <<= bool(rViewData.GetMarkData().GetTableSelect( nTab )); } } @@ -273,6 +270,17 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV aSettings[i].Value >>= bSelected; rViewData.GetMarkData().SelectTable( nTab, bSelected ); } + else if (sName.compareToAscii(SC_UNONAME_TABCOLOR) == 0) + { + // There are documents out there that have their tab color defined as a view setting. + sal_Int32 nColor = COL_AUTO; + aSettings[i].Value >>= nColor; + if (static_cast<ColorData>(nColor) != COL_AUTO) + { + ScDocument* pDoc = rViewData.GetDocument(); + pDoc->SetTabBgColor(nTab, Color(static_cast<ColorData>(nColor))); + } + } } if (eHSplitMode == SC_SPLIT_FIX) nFixPosX = SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH )); @@ -1595,7 +1603,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, nScrPosY = 65535; else { - nTSize = pDoc->FastGetRowHeight( nY, nTabNo ); + nTSize = pDoc->GetRowHeight( nY, nTabNo ); if (nTSize) { long nSizeYPix = ToPixel( nTSize, nPPTY ); @@ -1604,7 +1612,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, else if ( nY < MAXROW ) { // skip multiple hidden rows (forward only for now) - SCROW nNext = pDoc->FastGetFirstNonHiddenRow( nY + 1, nTabNo ); + SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTabNo); if ( nNext > MAXROW ) nY = MAXROW; else @@ -1616,7 +1624,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, for (nY=nPosY; nY>nWhereY;) { --nY; - nTSize = pDoc->FastGetRowHeight( nY, nTabNo ); + nTSize = pDoc->GetRowHeight( nY, nTabNo ); if (nTSize) { long nSizeYPix = ToPixel( nTSize, nPPTY ); @@ -1706,8 +1714,7 @@ SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, USHO bOut = TRUE; else { -// USHORT nTSize = pDoc->GetRowHeight( nRowNo, nTabNo ); - USHORT nTSize = pDoc->FastGetRowHeight( nRowNo, nTabNo ); + USHORT nTSize = pDoc->GetRowHeight( nRowNo, nTabNo ); if (nTSize) { long nSizeYPix = ToPixel( nTSize, nPPTY ); @@ -1716,7 +1723,7 @@ SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, USHO else if ( nDir == 1 && nRowNo < MAXROW ) { // skip multiple hidden rows (forward only for now) - SCROW nNext = pDoc->FastGetFirstNonHiddenRow( nRowNo + 1, nTabNo ); + SCROW nNext = pDoc->FirstVisibleRow(nRowNo + 1, MAXROW, nTabNo); if ( nNext > MAXROW ) { // same behavior as without the optimization: set bOut with nY=MAXROW+1 @@ -1779,11 +1786,19 @@ BOOL ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& r for (SCCOL i=0; i<nCountX; i++) nOutWidth += ToPixel( pDoc->GetColWidth(nX+i,nTabNo), nPPTX ); SCROW nCountY = pMerge->GetRowMerge(); - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter( - pDoc->GetRowFlagsArray( nTabNo), nY, nY+nCountY-1, CR_HIDDEN, - 0, pDoc->GetRowHeightArray( nTabNo)); - for ( ; aIter; ++aIter ) - nOutHeight += ToPixel( *aIter, nPPTY ); + + for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow) + { + SCROW nLastRow = nRow; + if (pDoc->RowHidden(nRow, nTabNo, NULL, &nLastRow)) + { + nRow = nLastRow; + continue; + } + + USHORT nHeight = pDoc->GetRowHeight(nRow, nTabNo); + nOutHeight += ToPixel(nHeight, nPPTY); + } rSizeXPix = nOutWidth; rSizeYPix = nOutHeight; @@ -1843,7 +1858,7 @@ BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, { while ( rPosY<=MAXROW && nClickY >= nScrY ) { - nScrY += ToPixel( pDoc->FastGetRowHeight( rPosY, nTabNo ), nPPTY ); + nScrY += ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY ); ++rPosY; } --rPosY; @@ -1853,7 +1868,7 @@ BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, while ( rPosY>0 && nClickY < nScrY ) { --rPosY; - nScrY -= ToPixel( pDoc->FastGetRowHeight( rPosY, nTabNo ), nPPTY ); + nScrY -= ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY ); } } @@ -1973,14 +1988,14 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ) if ( nNewPosY > nOldPosY ) for ( i=nOldPosY; i<nNewPosY; i++ ) { - long nThis = pDoc->FastGetRowHeight( i,nTabNo ); + long nThis = pDoc->GetRowHeight( i,nTabNo ); nTPosY -= nThis; nPixPosY -= ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY); } else for ( i=nNewPosY; i<nOldPosY; i++ ) { - long nThis = pDoc->FastGetRowHeight( i,nTabNo ); + long nThis = pDoc->GetRowHeight( i,nTabNo ); nTPosY += nThis; nPixPosY += ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY); } @@ -2010,7 +2025,7 @@ void ScViewData::RecalcPixPos() // nach Zoom-Aenderungen long nPixPosY = 0; SCROW nPosY = pThisTab->nPosY[eWhich]; for (SCROW j=0; j<nPosY; j++) - nPixPosY -= ToPixel(pDoc->FastGetRowHeight(j,nTabNo), nPPTY); + nPixPosY -= ToPixel(pDoc->GetRowHeight(j,nTabNo), nPPTY); pThisTab->nPixPosY[eWhich] = nPixPosY; } } @@ -2053,7 +2068,7 @@ void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) for (nRow=nRow1; nRow<=nRow2; nRow++) { - nTSize = pDoc->FastGetRowHeight( nRow, nTabNo ); + nTSize = pDoc->GetRowHeight( nRow, nTabNo ); if (nTSize) { nSizePix = ToPixel( nTSize, nPPTY ); @@ -2095,7 +2110,7 @@ void ScViewData::SetScreenPos( const Point& rVisAreaStart ) bEnd = FALSE; while (!bEnd) { - nAdd = (long) pDoc->FastGetRowHeight(nY1,nTabNo); + nAdd = (long) pDoc->GetRowHeight(nY1,nTabNo); if (nSize+nAdd <= nTwips+1 && nY1<MAXROW) { nSize += nAdd; @@ -3047,7 +3062,7 @@ BOOL ScViewData::UpdateFixY( SCTAB nTab ) // TRUE = Wert geaendert long nNewPos = 0; for (SCROW nY=pTabData[nTab]->nPosY[SC_SPLIT_TOP]; nY<nFix; nY++) { - USHORT nTSize = pLocalDoc->FastGetRowHeight( nY, nTab ); + USHORT nTSize = pLocalDoc->GetRowHeight( nY, nTab ); if (nTSize) { long nPix = ToPixel( nTSize, nPPTY ); diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 8ac03829127e..a125cbea6f50 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -28,8 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - // INCLUDE --------------------------------------------------------------- #include "scitems.hxx" @@ -86,6 +84,7 @@ #include "funcdesc.hxx" #include "docuno.hxx" #include "charthelper.hxx" +#include "tabbgcolor.hxx" #include <basic/sbstar.hxx> #include <com/sun/star/container/XNameContainer.hpp> @@ -2201,6 +2200,7 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord ) pUndoDoc->SetActiveScenario( nTab, bActive ); } pUndoDoc->SetVisible( nTab, pDoc->IsVisible( nTab ) ); + pUndoDoc->SetTabBgColor( nTab, pDoc->GetTabBgColor(nTab) ); pUndoDoc->SetSheetEvents( nTab, pDoc->GetSheetEvents( nTab ) ); if ( pDoc->IsTabProtected( nTab ) ) @@ -2292,6 +2292,28 @@ BOOL ScViewFunc::RenameTable( const String& rName, SCTAB nTab ) //---------------------------------------------------------------------------- +bool ScViewFunc::SetTabBgColor( const Color& rColor, SCTAB nTab ) +{ + bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( nTab, rColor, TRUE, FALSE ); + if (bSuccess) + { + GetViewData()->GetViewShell()->UpdateInputHandler(); + } + return bSuccess; +} + +bool ScViewFunc::SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList ) +{ + bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( rUndoSetTabBgColorInfoList, TRUE, FALSE ); + if (bSuccess) + { + GetViewData()->GetViewShell()->UpdateInputHandler(); + } + return bSuccess; +} + +//---------------------------------------------------------------------------- + void ScViewFunc::InsertAreaLink( const String& rFile, const String& rFilter, const String& rOptions, const String& rSource, ULONG nRefresh ) diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index dacb41cd1aea..24fab9ac2eba 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -1723,10 +1723,10 @@ BOOL ScViewFunc::MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos, BOOL bIncludeFiltered = bCut; if ( !bIncludeFiltered ) { - // manually find number of non-filtered rows - SCROW nPastedCount = pDocSh->GetDocument()->GetRowFlagsArray( - rSource.aStart.Tab()).CountForCondition( - rSource.aStart.Row(), rSource.aEnd.Row(), CR_FILTERED, 0); + // find number of non-filtered rows + SCROW nPastedCount = pDocSh->GetDocument()->CountNonFilteredRows( + rSource.aStart.Row(), rSource.aEnd.Row(), rSource.aStart.Tab()); + if ( nPastedCount == 0 ) nPastedCount = 1; aDestEnd.SetRow( rDestPos.Row() + nPastedCount - 1 ); diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index 9697cae3a57e..dc4e96bbbf34 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -110,7 +110,7 @@ BOOL ScViewFunc::PasteDataFormat( ULONG nFormatId, nXT += pDoc->GetColWidth(i,nTab); if (pDoc->IsNegativePage(nTab)) nXT = -nXT; - ULONG nYT = pDoc->FastGetRowHeight( 0, nPosY-1, nTab); + ULONG nYT = pDoc->GetRowHeight( 0, nPosY-1, nTab); aPos = Point( (long)(nXT * HMM_PER_TWIPS), (long)(nYT * HMM_PER_TWIPS) ); } } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 5d3bf97aa29c..231eb4e67562 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2195,28 +2195,19 @@ void ScViewFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR { // fuer alle eingeblendeten CR_MANUALSIZE loeschen, // dann SetOptimalHeight mit bShrink = FALSE - ScCompressedArrayIterator< SCROW, BYTE> aIter( - pDoc->GetRowFlagsArray( nTab), nStartNo, - nEndNo); - do + for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow) { - BYTE nOld = *aIter; - if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) ) + SCROW nLastRow = nRow; + if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow)) { - SCROW nRangeEnd = aIter.GetRangeEnd(); - pDoc->SetRowFlags( aIter.GetRangeStart(), - nRangeEnd, nTab, - nOld & ~CR_MANUALSIZE); - aIter.Resync( nRangeEnd); - // Range may be extended due to merges and - // now aIter.GetRangeEnd() may point behind - // the previous row, but all flags of this - // range have the CR_MANUALSIZE bit - // removed, so it is safe to continue with - // the next range, not necessary to catch - // up with the remaining rows. + nRow = nLastRow; + continue; } - } while (aIter.NextRange()); + + BYTE nOld = pDoc->GetRowFlags(nRow, nTab); + if (nOld & CR_MANUALSIZE) + pDoc->SetRowFlags(nRow, nTab, nOld & ~CR_MANUALSIZE); + } } double nPPTX = GetViewData()->GetPPTX(); @@ -2258,8 +2249,7 @@ void ScViewFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR { for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++) { - if ( eMode != SC_SIZE_VISOPT || - (pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0 ) + if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab) ) { USHORT nThisSize = nSizeTwips; diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx index d887aec8bc5b..a6b4e320d3ab 100644 --- a/sc/source/ui/view/viewutil.cxx +++ b/sc/source/ui/view/viewutil.cxx @@ -271,20 +271,19 @@ void ScViewUtil::UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc ) for (SCTAB nTab=0; nTab<nTabCount; nTab++) if ( rMark.GetTableSelect(nTab ) ) { - ScCompressedArrayIterator<SCROW, BYTE> aIter(pDoc->GetRowFlagsArray(nTab), nStartRow, nEndRow); - do + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow) { - if (*aIter & CR_FILTERED) + SCROW nLastRow = nRow; + if (pDoc->RowFiltered(nRow, nTab, NULL, &nLastRow)) { // use nStartCol/nEndCol, so the multi mark area isn't extended to all columns // (visible in repaint for indentation) - - rMark.SetMultiMarkArea( ScRange( nStartCol, aIter.GetRangeStart(), nTab, - nEndCol, aIter.GetRangeEnd(), nTab ), FALSE ); + rMark.SetMultiMarkArea( + ScRange(nStartCol, nRow, nTab, nEndCol, nLastRow, nTab), false); bChanged = true; + nRow = nLastRow; } } - while (aIter.NextRange()); } if ( bChanged && !rMark.HasAnyMultiMarks() ) @@ -295,34 +294,29 @@ void ScViewUtil::UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc ) // static -bool ScViewUtil::FitToUnfilteredRows( ScRange & rRange, const ScDocument * pDoc, size_t nRows ) +bool ScViewUtil::FitToUnfilteredRows( ScRange & rRange, ScDocument * pDoc, size_t nRows ) { SCTAB nTab = rRange.aStart.Tab(); bool bOneTabOnly = (nTab == rRange.aEnd.Tab()); // Always fit the range on its first sheet. DBG_ASSERT( bOneTabOnly, "ScViewUtil::ExtendToUnfilteredRows: works only on one sheet"); SCROW nStartRow = rRange.aStart.Row(); - // FillArrayForCondition() usually is the fastest to determine such a set - // in one pass, even if the array isn't used but the last element. - SCROW* pArr = new SCROW[nRows]; - size_t nCount = pDoc->GetRowFlagsArray( nTab).FillArrayForCondition( - nStartRow, MAXROW, CR_FILTERED, 0, pArr, nRows); - if (nCount) - rRange.aEnd.SetRow( pArr[nCount-1]); - delete [] pArr; - return nCount == nRows && bOneTabOnly; + SCROW nLastRow = pDoc->LastNonFilteredRow(nStartRow, MAXROW, nTab); + if (ValidRow(nLastRow)) + rRange.aEnd.SetRow(nLastRow); + SCROW nCount = pDoc->CountNonFilteredRows(nStartRow, MAXROW, nTab); + return static_cast<size_t>(nCount) == nRows && bOneTabOnly; } // static -bool ScViewUtil::HasFiltered( const ScRange& rRange, const ScDocument* pDoc ) +bool ScViewUtil::HasFiltered( const ScRange& rRange, ScDocument* pDoc ) { SCROW nStartRow = rRange.aStart.Row(); SCROW nEndRow = rRange.aEnd.Row(); for (SCTAB nTab=rRange.aStart.Tab(); nTab<=rRange.aEnd.Tab(); nTab++) { - if ( pDoc->GetRowFlagsArray( nTab).HasCondition( nStartRow, nEndRow, - CR_FILTERED, CR_FILTERED ) ) + if (pDoc->HasFilteredRows(nStartRow, nEndRow, nTab)) return true; } diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index dbdba59e8a82..a6b772cca012 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -216,6 +216,8 @@ <menu:menuitem menu:id=".uno:Hide"/> <menu:menuitem menu:id=".uno:Show"/> <menu:menuitem menu:id=".uno:SheetRightToLeft"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:SetTabBgColor"/> </menu:menupopup> </menu:menu> <menu:menuitem menu:id=".uno:ToggleMergeCells"/> diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index 722f04542551..980d271ae7c0 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -255,6 +255,7 @@ LIB8OBJFILES = \ $(SLO)$/attrdlg.obj \ $(SLO)$/scuiimoptdlg.obj \ $(SLO)$/strindlg.obj \ + $(SLO)$/tabbgcolordlg.obj \ $(SLO)$/shtabdlg.obj \ $(SLO)$/scendlg.obj \ $(SLO)$/pvfundlg.obj \ diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx index bbc58ed27c9c..0d206d0286dd 100644 --- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -915,21 +915,21 @@ double SAL_CALL AnalysisAddIn::getLcm( constREFXPS& xOpt, const SEQSEQ( double ) } -double SAL_CALL AnalysisAddIn::getBesseli( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE +double SAL_CALL AnalysisAddIn::getBesseli( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE { double fRet = sca::analysis::BesselI( fNum, nOrder ); RETURN_FINITE( fRet ); } -double SAL_CALL AnalysisAddIn::getBesselj( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE +double SAL_CALL AnalysisAddIn::getBesselj( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE { double fRet = sca::analysis::BesselJ( fNum, nOrder ); RETURN_FINITE( fRet ); } -double SAL_CALL AnalysisAddIn::getBesselk( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE +double SAL_CALL AnalysisAddIn::getBesselk( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE { if( nOrder < 0 || fNum <= 0.0 ) THROW_IAE; @@ -939,7 +939,7 @@ double SAL_CALL AnalysisAddIn::getBesselk( double fNum, sal_Int32 nOrder ) THROW } -double SAL_CALL AnalysisAddIn::getBessely( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE +double SAL_CALL AnalysisAddIn::getBessely( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE { if( nOrder < 0 || fNum <= 0.0 ) THROW_IAE; diff --git a/scaddins/source/analysis/analysis.hxx b/scaddins/source/analysis/analysis.hxx index fbf7dd012050..ff789838b299 100644 --- a/scaddins/source/analysis/analysis.hxx +++ b/scaddins/source/analysis/analysis.hxx @@ -36,6 +36,7 @@ #include <com/sun/star/sheet/addin/XAnalysis.hpp> #include <com/sun/star/sheet/LocalizedName.hpp> #include <com/sun/star/sheet/XCompatibilityNames.hpp> +#include <com/sun/star/sheet/NoConvergenceException.hpp> #include <cppuhelper/implbase5.hxx> // helper for implementations @@ -143,10 +144,10 @@ public: virtual double SAL_CALL getGcd( constREFXPS& xOpt, const SEQSEQ( double )& aVLst, const SEQ( ANY )& aOptVLst ) THROWDEF_RTE_IAE; virtual double SAL_CALL getLcm( constREFXPS& xOpt, const SEQSEQ( double )& aVLst, const SEQ( ANY )& aOptVLst ) THROWDEF_RTE_IAE; - virtual double SAL_CALL getBesseli( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE; - virtual double SAL_CALL getBesselj( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE; - virtual double SAL_CALL getBesselk( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE; - virtual double SAL_CALL getBessely( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE; + virtual double SAL_CALL getBesseli( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE; + virtual double SAL_CALL getBesselj( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE; + virtual double SAL_CALL getBesselk( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE; + virtual double SAL_CALL getBessely( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE_NCE; virtual STRING SAL_CALL getBin2Oct( constREFXPS& xOpt, const STRING& aNum, const ANY& rPlaces ) THROWDEF_RTE_IAE; virtual double SAL_CALL getBin2Dec( const STRING& aNum ) THROWDEF_RTE_IAE; diff --git a/scaddins/source/analysis/analysisadd.idl b/scaddins/source/analysis/analysisadd.idl index 14b47ac256fc..6245bff9ad5a 100644 --- a/scaddins/source/analysis/analysisadd.idl +++ b/scaddins/source/analysis/analysisadd.idl @@ -25,6 +25,9 @@ * ************************************************************************/ +#ifndef __com_sun_star_sheet_NoConvergenceException_idl__ +#include <com/sun/star/sheet/NoConvergenceException.idl> +#endif #include <com/sun/star/uno/XInterface.idl> #include <com/sun/star/beans/XPropertySet.idl> @@ -145,19 +148,23 @@ module addin /// besseli. double getBesseli( [in] double Num, [in] long Order ) - raises( com::sun::star::lang::IllegalArgumentException ); + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::sheet::NoConvergenceException ); /// besselj. double getBesselj( [in] double Num, [in] long Order ) - raises( com::sun::star::lang::IllegalArgumentException ); + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::sheet::NoConvergenceException ); /// besselk. double getBesselk( [in] double Num, [in] long Order ) - raises( com::sun::star::lang::IllegalArgumentException ); + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::sheet::NoConvergenceException ); /// bessely. double getBessely( [in] double Num, [in] long Order ) - raises( com::sun::star::lang::IllegalArgumentException ); + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::sheet::NoConvergenceException ); /// bin2oct. string getBin2Oct( diff --git a/scaddins/source/analysis/analysisdefs.hxx b/scaddins/source/analysis/analysisdefs.hxx index 81f7435abc19..dae4205e2d84 100644 --- a/scaddins/source/analysis/analysisdefs.hxx +++ b/scaddins/source/analysis/analysisdefs.hxx @@ -44,6 +44,8 @@ #define THROW_RTE throw CSS::uno::RuntimeException() #define THROWDEF_RTE_IAE throw(CSS::uno::RuntimeException,CSS::lang::IllegalArgumentException) #define THROW_IAE throw CSS::lang::IllegalArgumentException() +#define THROWDEF_RTE_IAE_NCE throw(CSS::uno::RuntimeException,CSS::lang::IllegalArgumentException,CSS::sheet::NoConvergenceException) +#define THROW_NCE throw CSS::sheet::NoConvergenceException() #define CHK_Freq ( nFreq != 1 && nFreq != 2 && nFreq != 4 ) #define CHK_FINITE(d) if( !::rtl::math::isFinite( d ) ) THROW_IAE diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index 417d30c24d9b..d47c02a4e961 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -2530,8 +2530,8 @@ ConvertDataList::ConvertDataList( void ) NEWD( "ly3", 1.1810108125623799E-51, CDC_Volume ); // *** Cubic light-year NEWD( "MTON", 1.4125866688595436E00, CDC_Volume ); // *** Measurement ton NEWD( "tspm", 5.0000000000000000E02, CDC_Volume ); // *** Modern teaspoon - NEWD( "uk_gal", 2.6411458333333333E-01, CDC_Volume ); // U.K. / Imperial gallon ?? - NEWD( "uk_qt", 1.0564583333333333E00, CDC_Volume ); // U.K. / Imperial quart ?? + NEWD( "uk_gal", 2.199694619402070E-01, CDC_Volume ); // U.K. / Imperial gallon + NEWD( "uk_qt", 8.798778477608300E-01, CDC_Volume ); // U.K. / Imperial quart // 1 Square Meter is... NEWDP( "m2", 1.0000000000000000E00, CDC_Area ); // *** Square Meter diff --git a/scaddins/source/analysis/bessel.cxx b/scaddins/source/analysis/bessel.cxx index 9b1f79b6d405..f853b49eb443 100644 --- a/scaddins/source/analysis/bessel.cxx +++ b/scaddins/source/analysis/bessel.cxx @@ -31,6 +31,7 @@ #include <rtl/math.hxx> using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::sheet::NoConvergenceException; namespace sca { namespace analysis { @@ -47,93 +48,129 @@ const double THRESHOLD = 30.0; // Threshold for usage of approximation form const double MAXEPSILON = 1e-10; // Maximum epsilon for end of iteration. const sal_Int32 MAXITER = 100; // Maximum number of iterations. - // ============================================================================ // BESSEL J // ============================================================================ /* The BESSEL function, first kind, unmodified: - - inf (-1)^k (x/2)^(n+2k) - J_n(x) = SUM TERM(n,k) with TERM(n,k) := --------------------- - k=0 k! (n+k)! - - Approximation for the BESSEL function, first kind, unmodified, for great x: - - J_n(x) ~ sqrt( 2 / (PI x) ) cos( x - n PI/2 - PI/4 ) for x>=0. - */ + The algorithm follows + http://www.reference-global.com/isbn/978-3-11-020354-7 + Numerical Mathematics 1 / Numerische Mathematik 1, + An algorithm-based introduction / Eine algorithmisch orientierte Einführung + Deuflhard, Peter; Hohmann, Andreas + Berlin, New York (Walter de Gruyter) 2008 + 4. überarb. u. erw. Aufl. 2008 + eBook ISBN: 978-3-11-020355-4 + Chapter 6.3.2 , algorithm 6.24 + The source is in German. + The BesselJ-function is a special case of the adjoint summation with + a_k = 2*(k-1)/x for k=1,... + b_k = -1, for all k, directly substituted + m_0=1, m_k=2 for k even, and m_k=0 for k odd, calculated on the fly + alpha_k=1 for k=N and alpha_k=0 otherwise +*/ // ---------------------------------------------------------------------------- -double BesselJ( double x, sal_Int32 n ) throw( IllegalArgumentException ) +double BesselJ( double x, sal_Int32 N ) throw (IllegalArgumentException, NoConvergenceException) + { - if( n < 0 ) + if( N < 0 ) throw IllegalArgumentException(); - - double fResult = 0.0; - if( fabs( x ) <= THRESHOLD ) + if (x==0.0) + return (N==0) ? 1.0 : 0.0; + + /* The algorithm works only for x>0, therefore remember sign. BesselJ + with integer order N is an even function for even N (means J(-x)=J(x)) + and an odd function for odd N (means J(-x)=-J(x)).*/ + double fSign = (N % 2 == 1 && x < 0) ? -1.0 : 1.0; + double fX = fabs(x); + + const double fMaxIteration = 9000000.0; //experimental, for to return in < 3 seconds + double fEstimateIteration = fX * 1.5 + N; + bool bAsymptoticPossible = pow(fX,0.4) > N; + if (fEstimateIteration > fMaxIteration) { - /* Start the iteration without TERM(n,0), which is set here. - - TERM(n,0) = (x/2)^n / n! - */ - double fTerm = pow( x / 2.0, (double)n ) / Fak( n ); - sal_Int32 nK = 1; // Start the iteration with k=1. - fResult = fTerm; // Start result with TERM(n,0). - - const double fSqrX = x * x / -4.0; + if (bAsymptoticPossible) + return fSign * sqrt(f_2_DIV_PI/fX)* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4); + else + throw NoConvergenceException(); + } - do + double epsilon = 1.0e-15; // relative error + bool bHasfound = false; + double k= 0.0; + // e_{-1} = 0; e_0 = alpha_0 / b_2 + double u ; // u_0 = e_0/f_0 = alpha_0/m_0 = alpha_0 + + // first used with k=1 + double m_bar; // m_bar_k = m_k * f_bar_{k-1} + double g_bar; // g_bar_k = m_bar_k - a_{k+1} + g_{k-1} + double g_bar_delta_u; // g_bar_delta_u_k = f_bar_{k-1} * alpha_k + // - g_{k-1} * delta_u_{k-1} - m_bar_k * u_{k-1} + // f_{-1} = 0.0; f_0 = m_0 / b_2 = 1/(-1) = -1 + double g = 0.0; // g_0= f_{-1} / f_0 = 0/(-1) = 0 + double delta_u = 0.0; // dummy initialize, first used with * 0 + double f_bar = -1.0; // f_bar_k = 1/f_k, but only used for k=0 + + if (N==0) + { + //k=0; alpha_0 = 1.0 + u = 1.0; // u_0 = alpha_0 + // k = 1.0; at least one step is necessary + // m_bar_k = m_k * f_bar_{k-1} ==> m_bar_1 = 0.0 + g_bar_delta_u = 0.0; // alpha_k = 0.0, m_bar = 0.0; g= 0.0 + g_bar = - 2.0/fX; // k = 1.0, g = 0.0 + delta_u = g_bar_delta_u / g_bar; + u = u + delta_u ; // u_k = u_{k-1} + delta_u_k + g = -1.0 / g_bar; // g_k=b_{k+2}/g_bar_k + f_bar = f_bar * g; // f_bar_k = f_bar_{k-1}* g_k + k = 2.0; + // From now on all alpha_k = 0.0 and k > N+1 + } + else + { // N >= 1 and alpha_k = 0.0 for k<N + u=0.0; // u_0 = alpha_0 + for (k =1.0; k<= N-1; k = k + 1.0) { - /* Calculation of TERM(n,k) from TERM(n,k-1): - - (-1)^k (x/2)^(n+2k) - TERM(n,k) = --------------------- - k! (n+k)! - - (-1)(-1)^(k-1) (x/2)^2 (x/2)^(n+2(k-1)) - = ----------------------------------------- - k (k-1)! (n+k) (n+k-1)! - - -(x/2)^2 (-1)^(k-1) (x/2)^(n+2(k-1)) - = ---------- * ----------------------------- - k(n+k) (k-1)! (n+k-1)! - - -(x^2/4) - = ---------- TERM(n,k-1) - k(n+k) - */ - fTerm *= fSqrX; // defined above as -(x^2/4) - fTerm /= (nK * (nK + n)); - fResult += fTerm; + m_bar=2.0 * fmod(k-1.0, 2.0) * f_bar; + g_bar_delta_u = - g * delta_u - m_bar * u; // alpha_k = 0.0 + g_bar = m_bar - 2.0*k/fX + g; + delta_u = g_bar_delta_u / g_bar; + u = u + delta_u; + g = -1.0/g_bar; + f_bar=f_bar * g; } - while( (fabs( fTerm ) > MAXEPSILON) && (++nK < MAXITER) ); + // Step alpha_N = 1.0 + m_bar=2.0 * fmod(k-1.0, 2.0) * f_bar; + g_bar_delta_u = f_bar - g * delta_u - m_bar * u; // alpha_k = 1.0 + g_bar = m_bar - 2.0*k/fX + g; + delta_u = g_bar_delta_u / g_bar; + u = u + delta_u; + g = -1.0/g_bar; + f_bar = f_bar * g; + k = k + 1.0; } - else + // Loop until desired accuracy, always alpha_k = 0.0 + do { - /* Approximation for the BESSEL function, first kind, unmodified: - - J_n(x) ~ sqrt( 2 / (PI x) ) cos( x - n PI/2 - PI/4 ) for x>=0. - - The BESSEL function J_n with n IN {0,2,4,...} is axially symmetric at - x=0, means J_n(x) = J_n(-x). Therefore the approximation for x<0 is: - - J_n(x) = J_n(|x|) for x<0 and n IN {0,2,4,...}. - - The BESSEL function J_n with n IN {1,3,5,...} is point-symmetric at - x=0, means J_n(x) = -J_n(-x). Therefore the approximation for x<0 is: - - J_n(x) = -J_n(|x|) for x<0 and n IN {1,3,5,...}. - */ - double fXAbs = fabs( x ); - fResult = sqrt( f_2_DIV_PI / fXAbs ) * cos( fXAbs - n * f_PI_DIV_2 - f_PI_DIV_4 ); - if( (n & 1) && (x < 0.0) ) - fResult = -fResult; + m_bar = 2.0 * fmod(k-1.0, 2.0) * f_bar; + g_bar_delta_u = - g * delta_u - m_bar * u; + g_bar = m_bar - 2.0*k/fX + g; + delta_u = g_bar_delta_u / g_bar; + u = u + delta_u; + g = -1.0/g_bar; + f_bar = f_bar * g; + bHasfound = (fabs(delta_u)<=fabs(u)*epsilon); + k = k + 1.0; } - return fResult; + while (!bHasfound && k <= fMaxIteration); + if (bHasfound) + return u * fSign; + else + throw NoConvergenceException(); // unlikely to happen } - // ============================================================================ // BESSEL I // ============================================================================ @@ -151,7 +188,7 @@ double BesselJ( double x, sal_Int32 n ) throw( IllegalArgumentException ) // ---------------------------------------------------------------------------- -double BesselI( double x, sal_Int32 n ) throw( IllegalArgumentException ) +double BesselI( double x, sal_Int32 n ) throw( IllegalArgumentException, NoConvergenceException ) { if( n < 0 ) throw IllegalArgumentException(); @@ -222,7 +259,7 @@ double BesselI( double x, sal_Int32 n ) throw( IllegalArgumentException ) // ============================================================================ -double Besselk0( double fNum ) throw( IllegalArgumentException ) +double Besselk0( double fNum ) throw( IllegalArgumentException, NoConvergenceException ) { double fRet; @@ -248,7 +285,7 @@ double Besselk0( double fNum ) throw( IllegalArgumentException ) } -double Besselk1( double fNum ) throw( IllegalArgumentException ) +double Besselk1( double fNum ) throw( IllegalArgumentException, NoConvergenceException ) { double fRet; @@ -275,7 +312,7 @@ double Besselk1( double fNum ) throw( IllegalArgumentException ) } -double BesselK( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException ) +double BesselK( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException, NoConvergenceException ) { switch( nOrder ) { @@ -301,87 +338,136 @@ double BesselK( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException } } +// ============================================================================ +// BESSEL Y +// ============================================================================ -double Bessely0( double fNum ) throw( IllegalArgumentException ) +/* The BESSEL function, second kind, unmodified: + The algorithm for order 0 and for order 1 follows + http://www.reference-global.com/isbn/978-3-11-020354-7 + Numerical Mathematics 1 / Numerische Mathematik 1, + An algorithm-based introduction / Eine algorithmisch orientierte Einführung + Deuflhard, Peter; Hohmann, Andreas + Berlin, New York (Walter de Gruyter) 2008 + 4. überarb. u. erw. Aufl. 2008 + eBook ISBN: 978-3-11-020355-4 + Chapter 6.3.2 , algorithm 6.24 + The source is in German. + See #i31656# for a commented version of the implementation, attachment #desc6 + http://www.openoffice.org/nonav/issues/showattachment.cgi/63609/Comments%20to%20the%20implementation%20of%20the%20Bessel%20functions.odt +*/ + +double Bessely0( double fX ) throw( IllegalArgumentException, NoConvergenceException ) { - double fRet; - - if( fNum < 8.0 ) + if (fX <= 0) + throw IllegalArgumentException(); + const double fMaxIteration = 9000000.0; // should not be reached + if (fX > 5.0e+6) // iteration is not considerable better then approximation + return sqrt(1/f_PI/fX) + *(rtl::math::sin(fX)-rtl::math::cos(fX)); + const double epsilon = 1.0e-15; + const double EulerGamma = 0.57721566490153286060; + double alpha = log(fX/2.0)+EulerGamma; + double u = alpha; + + double k = 1.0; + double m_bar = 0.0; + double g_bar_delta_u = 0.0; + double g_bar = -2.0 / fX; + double delta_u = g_bar_delta_u / g_bar; + double g = -1.0/g_bar; + double f_bar = -1 * g; + + double sign_alpha = 1.0; + double km1mod2; + bool bHasFound = false; + k = k + 1; + do { - double y = fNum * fNum; - - double f1 = -2957821389.0 + y * ( 7062834065.0 + y * ( -512359803.6 + - y * ( 10879881.29 + y * ( -86327.92757 + y * 228.4622733 ) ) ) ); - - double f2 = 40076544269.0 + y * ( 745249964.8 + y * ( 7189466.438 + - y * ( 47447.26470 + y * ( 226.1030244 + y ) ) ) ); - - fRet = f1 / f2 + 0.636619772 * BesselJ( fNum, 0 ) * log( fNum ); + km1mod2 = fmod(k-1.0,2.0); + m_bar=(2.0*km1mod2) * f_bar; + if (km1mod2 == 0.0) + alpha = 0.0; + else + { + alpha = sign_alpha * (4.0/k); + sign_alpha = -sign_alpha; + } + g_bar_delta_u = f_bar * alpha - g * delta_u - m_bar * u; + g_bar = m_bar - (2.0*k)/fX + g; + delta_u = g_bar_delta_u / g_bar; + u = u+delta_u; + g = -1.0 / g_bar; + f_bar = f_bar*g; + bHasFound = (fabs(delta_u)<=fabs(u)*epsilon); + k=k+1; } + while (!bHasFound && k<fMaxIteration); + if (bHasFound) + return u*f_2_DIV_PI; else - { - double z = 8.0 / fNum; - double y = z * z; - double xx = fNum - 0.785398164; - - double f1 = 1.0 + y * ( -0.1098628627e-2 + y * ( 0.2734510407e-4 + - y * ( -0.2073370639e-5 + y * 0.2093887211e-6 ) ) ); - - double f2 = -0.1562499995e-1 + y * ( 0.1430488765e-3 + - y * ( -0.6911147651e-5 + y * ( 0.7621095161e-6 + - y * ( -0.934945152e-7 ) ) ) ); - - fRet = sqrt( 0.636619772 / fNum ) * ( sin( xx ) * f1 + z * cos( xx ) * f2 ); - } - - return fRet; + throw NoConvergenceException(); // not likely to happen } - -double Bessely1( double fNum ) throw( IllegalArgumentException ) +// See #i31656# for a commented version of this implementation, attachment #desc6 +// http://www.openoffice.org/nonav/issues/showattachment.cgi/63609/Comments%20to%20the%20implementation%20of%20the%20Bessel%20functions.odt +double Bessely1( double fX ) throw( IllegalArgumentException, NoConvergenceException ) { - double fRet; - - if( fNum < 8.0 ) + if (fX <= 0) + throw IllegalArgumentException(); + const double fMaxIteration = 9000000.0; // should not be reached + if (fX > 5.0e+6) // iteration is not considerable better then approximation + return - sqrt(1/f_PI/fX) + *(rtl::math::sin(fX)+rtl::math::cos(fX)); + const double epsilon = 1.0e-15; + const double EulerGamma = 0.57721566490153286060; + double alpha = 1.0/fX; + double f_bar = -1.0; + double g = 0.0; + double u = alpha; + double k = 1.0; + double m_bar = 0.0; + alpha = 1.0 - EulerGamma - log(fX/2.0); + double g_bar_delta_u = -alpha; + double g_bar = -2.0 / fX; + double delta_u = g_bar_delta_u / g_bar; + u = u + delta_u; + g = -1.0/g_bar; + f_bar = f_bar * g; + double sign_alpha = -1.0; + double km1mod2; //will be (k-1) mod 2 + double q; // will be (k-1) div 2 + bool bHasFound = false; + k = k + 1.0; + do { - double y = fNum * fNum; - - double f1 = fNum * ( -0.4900604943e13 + y * ( 0.1275274390e13 + - y * ( -0.5153438139e11 + y * ( 0.7349264551e9 + - y * ( -0.4237922726e7 + y * 0.8511937935e4 ) ) ) ) ); - - double f2 = 0.2499580570e14 + y * ( 0.4244419664e12 + - y * ( 0.3733650367e10 + y * ( 0.2245904002e8 + - y * ( 0.1020426050e6 + y * ( 0.3549632885e3 + y ) ) ) ) ); - - fRet = f1 / f2 + 0.636619772 * ( BesselJ( fNum, 1 ) * log( fNum ) - 1.0 / fNum ); + km1mod2 = fmod(k-1.0,2.0); + m_bar=(2.0*km1mod2) * f_bar; + q = (k-1.0)/2.0; + if (km1mod2 == 0.0) // k is odd + { + alpha = sign_alpha * (1.0/q + 1.0/(q+1.0)); + sign_alpha = -sign_alpha; + } + else + alpha = 0.0; + g_bar_delta_u = f_bar * alpha - g * delta_u - m_bar * u; + g_bar = m_bar - (2.0*k)/fX + g; + delta_u = g_bar_delta_u / g_bar; + u = u+delta_u; + g = -1.0 / g_bar; + f_bar = f_bar*g; + bHasFound = (fabs(delta_u)<=fabs(u)*epsilon); + k=k+1; } + while (!bHasFound && k<fMaxIteration); + if (bHasFound) + return -u*2.0/f_PI; else - { -#if 0 - // #i12430# don't know the intention of this piece of code... - double z = 8.0 / fNum; - double y = z * z; - double xx = fNum - 2.356194491; - - double f1 = 1.0 + y * ( 0.183105e-2 + y * ( -0.3516396496e-4 + - y * ( 0.2457520174e-5 + y * ( -0.240337019e6 ) ) ) ); - - double f2 = 0.04687499995 + y * ( -0.2002690873e-3 + - y * ( 0.8449199096e-5 + y * ( -0.88228987e-6 + - y * 0.105787412e-6 ) ) ); - - fRet = sqrt( 0.636619772 / fNum ) * ( sin( xx ) * f1 + z * cos( xx ) * f2 ); -#endif - // #i12430# ...but this seems to work much better. - fRet = sqrt( 0.636619772 / fNum ) * sin( fNum - 2.356194491 ); - } - - return fRet; + throw NoConvergenceException(); } - -double BesselY( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException ) +double BesselY( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException, NoConvergenceException ) { switch( nOrder ) { @@ -407,7 +493,6 @@ double BesselY( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException } } - // ============================================================================ } // namespace analysis diff --git a/scaddins/source/analysis/bessel.hxx b/scaddins/source/analysis/bessel.hxx index 24e8217537d5..c94b4f1a9b77 100644 --- a/scaddins/source/analysis/bessel.hxx +++ b/scaddins/source/analysis/bessel.hxx @@ -29,6 +29,7 @@ #define SCA_BESSEL_HXX #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/sheet/NoConvergenceException.hpp> #include <sal/types.h> namespace sca { @@ -39,16 +40,16 @@ namespace analysis { // ============================================================================ /** Returns the result for the unmodified BESSEL function of first kind (J), n-th order, at point x. */ -double BesselJ( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException ); +double BesselJ( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::sheet::NoConvergenceException ); /** Returns the result for the modified BESSEL function of first kind (I), n-th order, at point x. */ -double BesselI( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException ); +double BesselI( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::sheet::NoConvergenceException ); /** Returns the result for the unmodified BESSEL function of second kind (Y), n-th order, at point x. */ -double BesselY( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException ); +double BesselY( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::sheet::NoConvergenceException ); /** Returns the result for the modified BESSEL function of second kind (K), n-th order, at point x. */ -double BesselK( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException ); +double BesselK( double x, sal_Int32 n ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::sheet::NoConvergenceException ); // ============================================================================ diff --git a/scaddins/source/analysis/makefile.mk b/scaddins/source/analysis/makefile.mk index d837d644dc21..a23f9886b9b1 100644 --- a/scaddins/source/analysis/makefile.mk +++ b/scaddins/source/analysis/makefile.mk @@ -73,7 +73,8 @@ UNOTYPES=\ com.sun.star.uno.XComponentContext \ com.sun.star.util.Date \ com.sun.star.util.XNumberFormatter \ - com.sun.star.util.XNumberFormatTypes + com.sun.star.util.XNumberFormatTypes \ + com.sun.star.sheet.NoConvergenceException # --- Files ------------------------------------- |