diff options
author | obo <obo@openoffice.org> | 2010-06-21 13:30:01 +0200 |
---|---|---|
committer | obo <obo@openoffice.org> | 2010-06-21 13:30:01 +0200 |
commit | 943661174d0a2c1264d2c35e1ac7426ed3668774 (patch) | |
tree | c8fdfc84115ff1efe4c45b25817c0e235af68fc8 /sc | |
parent | 04702d4ba168df48dcfd3e5693a0346b2f09c78a (diff) | |
parent | 7406378b5b58fb693b9e5e77d7ccf267823d282a (diff) |
CWS-TOOLING: integrate CWS calctabcolor
Diffstat (limited to 'sc')
66 files changed, 1804 insertions, 653 deletions
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/dociter.hxx b/sc/inc/dociter.hxx index dd1d18e49a51..f7216b9cff48 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -206,8 +206,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 +303,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() diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 768dc815a482..044ccc853034 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -616,6 +616,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. 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/sc.hrc b/sc/inc/sc.hrc index c2bf3e96ed5c..aad25ab4d0a4 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -833,8 +833,10 @@ #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_MENU_SET_TAB_BG_COLOR (TAB_POPUP_START + 9) +#define FID_TAB_SET_TAB_BG_COLOR (TAB_POPUP_START + 10) -#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) @@ -1423,7 +1425,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) @@ -1631,8 +1636,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/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/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 aed123bd7a65..e93f4e381f95 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -153,6 +153,7 @@ private: ScRangeList* pScenarioRanges; Color aScenarioColor; + Color aTabBgColor; USHORT nScenarioFlags; BOOL bActiveScenario; @@ -209,6 +210,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; } diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 4cf609d3644f..48ea39d40181 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" 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/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 904ee22d3d8c..07442c7ee259 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -7748,3 +7748,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 4129aaef7d85..a7b493fc2aa7 100644 --- a/sc/sdi/tabvwsh.sdi +++ b/sc/sdi/tabvwsh.sdi @@ -58,6 +58,7 @@ interface Tables 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; ] } // =========================================================================== diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 706783579a24..da1f20433d1f 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -940,11 +940,6 @@ ScDBQueryDataIterator::ScDBQueryDataIterator(ScDocument* pDocument, ScDBQueryPar } } -bool ScDBQueryDataIterator::GetThis(Value& rValue) -{ - return mpData->getCurrent(rValue); -} - bool ScDBQueryDataIterator::GetFirst(Value& rValue) { return mpData->getFirst(rValue); @@ -1259,14 +1254,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(); diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index c5922aa88dcc..2b71231c5210 100755..100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -897,6 +897,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 77f59254e049..4fe49b3728dd 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -285,6 +285,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 { diff --git a/sc/source/core/data/makefile.mk b/sc/source/core/data/makefile.mk index cf51e1e543a4..189e2e568b88 100755..100644 --- a/sc/source/core/data/makefile.mk +++ b/sc/source/core/data/makefile.mk @@ -101,6 +101,7 @@ SLOFILES = \ $(SLO)$/sortparam.obj \ $(SLO)$/stlpool.obj \ $(SLO)$/stlsheet.obj \ + $(SLO)$/tabbgcolor.obj \ $(SLO)$/table1.obj \ $(SLO)$/table2.obj \ $(SLO)$/table3.obj \ @@ -128,6 +129,7 @@ EXCEPTIONSFILES= \ $(SLO)$/dptabres.obj \ $(SLO)$/dptabdat.obj \ $(SLO)$/global2.obj \ + $(SLO)$/tabbgcolor.obj \ $(SLO)$/table1.obj \ $(SLO)$/table2.obj \ $(SLO)$/table3.obj \ 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 a8b819072c21..8b7ca593b2e9 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -151,6 +151,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName, nLockCount( 0 ), pScenarioRanges( NULL ), aScenarioColor( COL_LIGHTGRAY ), + aTabBgColor( COL_AUTO ), nScenarioFlags( 0 ), bActiveScenario( FALSE ) { @@ -271,6 +272,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; 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/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/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index 3aef51d10c54..79026e7b3a48 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -1192,6 +1192,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/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/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 35ad5b41e0cb..97ac2d7459d5 100755 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -4053,6 +4053,12 @@ 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 + { + XclImpPalette& rPal = GetPalette(); + rTabViewSett.ReadTabBgColor( rStrm, rPal); + } + break; } // common records 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/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/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/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/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 5963fd72bad2..8121de6a46e1 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -84,6 +84,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> @@ -124,6 +125,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> @@ -161,6 +163,7 @@ using namespace formula; using namespace com::sun::star; using namespace xmloff::token; using ::std::vector; +using ::com::sun::star::uno::UNO_QUERY; //---------------------------------------------------------------------------- @@ -1705,132 +1708,130 @@ 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(); - 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) + 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()) { - ExportFormatRanges(0, 0, aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable); - aPrevCell = aCell; - bIsFirst = sal_False; + ::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 } - else + 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); } } @@ -2148,505 +2149,506 @@ 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) + { + 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<USHORT>(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) { - 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_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()) { - 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<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); } } - 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() diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 69c7144191d6..58ea9e0e5b17 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -698,12 +698,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/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/scmod.cxx b/sc/source/ui/app/scmod.cxx index 94e18def8a11..8f46b11236ae 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2192,9 +2192,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 +2241,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 +2262,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 +2275,4 @@ Window * ScModule::Find1RefWindow( Window *pWndAncestor ) return NULL; } -//<!--Added by PengYunQuan for Validity Cell Range Picker + 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/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index e08c930301cf..5ca2a01f05c9 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2791,6 +2791,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) ); // Drawing-Layer muss sein Undo selbst in der Hand behalten !!! pDoc->BeginDrawUndo(); // DeleteTab erzeugt ein SdrUndoDelPage @@ -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 !!!!!! 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/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/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/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 abda5c9a0994..ece9a0a8b1aa 100644 --- a/sc/source/ui/src/popup.src +++ b/sc/source/ui/src/popup.src @@ -190,6 +190,15 @@ Menu RID_POPUP_TAB HelpId = FID_TAB_RTL ; Text [ en-US ] = "S~heet Right-To-Left" ; }; + //------------------------------ + 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/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 17f15af54701..b3a7db1148fe 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -59,6 +59,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 +91,7 @@ TYPEINIT1(ScUndoScenarioFlags, SfxUndoAction); TYPEINIT1(ScUndoRenameObject, SfxUndoAction); TYPEINIT1(ScUndoLayoutRTL, SfxUndoAction); //UNUSED2009-05 TYPEINIT1(ScUndoSetGrammar, SfxUndoAction); +TYPEINIT1(ScUndoTabColor, SfxUndoAction); // ----------------------------------------------------------------------- @@ -411,6 +413,7 @@ void ScUndoDeleteTab::Undo() pDoc->SetActiveScenario( nTab, bActive ); } pDoc->SetVisible( nTab, pRefUndoDoc->IsVisible( nTab ) ); + pDoc->SetTabBgColor( nTab, pRefUndoDoc->GetTabBgColor(nTab) ); if ( pRefUndoDoc->IsTabProtected( nTab ) ) pDoc->SetTabProtection(nTab, pRefUndoDoc->GetTabProtection(nTab)); @@ -776,6 +779,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 980a73307797..6233d5f8944e 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -769,6 +769,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} }; @@ -8471,15 +8472,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 } @@ -8618,13 +8628,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); } 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/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/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 68a852c4a3b7..313b15628239 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -55,6 +55,14 @@ #include "scabstdlg.hxx" //CHINA001 +#include "tabbgcolor.hxx" +#include "tabbgcolordlg.hxx" +#include "editeng/colritem.hxx" + +#include <boost/scoped_ptr.hpp> + +using ::boost::scoped_ptr; + #define IS_AVAILABLE(WhichId,ppItem) \ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) @@ -683,6 +691,117 @@ 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; default: DBG_ERROR("Unbekannte Message bei ViewShell"); break; @@ -801,6 +920,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..b0a3635d35c7 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 )); diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 11ecfa5aae8c..ea11ee222770 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -86,6 +86,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 +2202,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) ); if ( pDoc->IsTabProtected( nTab ) ) pUndoDoc->SetTabProtection(nTab, pDoc->GetTabProtection(nTab)); @@ -2291,6 +2293,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/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index da8e6efdad55..855db09ff50c 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -215,6 +215,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 b7b12e07ee6a..d9e23b5f3623 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 \ |