From 8599da1e97948cfe7f5730c175b9dc67691a0752 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 17 Sep 2009 15:48:04 -0400 Subject: #i5560# Applied & adjusted for the latest codebase the patches from go-oo. The original patches were contributed by Daniel Watson. --- sc/inc/ViewSettingsSequenceDefines.hxx | 3 +- sc/inc/globstr.hrc | 5 +- sc/inc/sc.hrc | 9 +++ sc/inc/scabstdlg.hxx | 14 ++++ sc/inc/scextopt.hxx | 2 + sc/inc/tabbgcolor.hxx | 46 +++++++++++ sc/inc/unonames.hxx | 2 + sc/sdi/docsh.sdi | 1 + sc/sdi/scalc.sdi | 53 +++++++++++++ sc/sdi/tabvwsh.sdi | 1 + sc/source/filter/excel/read.cxx | 3 + sc/source/filter/excel/xestyle.cxx | 1 + sc/source/filter/excel/xeview.cxx | 43 +++++++++++ sc/source/filter/excel/xichart.cxx | 6 ++ sc/source/filter/excel/xiview.cxx | 22 ++++++ sc/source/filter/excel/xlview.cxx | 1 + sc/source/filter/inc/xestyle.hxx | 3 +- sc/source/filter/inc/xeview.hxx | 15 ++++ sc/source/filter/inc/xiview.hxx | 3 +- sc/source/filter/inc/xlview.hxx | 8 ++ sc/source/ui/attrdlg/scdlgfact.cxx | 35 +++++++++ sc/source/ui/attrdlg/scdlgfact.hxx | 15 ++++ sc/source/ui/docshell/docfunc.cxx | 98 ++++++++++++++++++++++++ sc/source/ui/inc/docfunc.hxx | 5 ++ sc/source/ui/inc/miscdlgs.hrc | 6 ++ sc/source/ui/inc/undotab.hxx | 32 ++++++++ sc/source/ui/inc/viewdata.hxx | 7 ++ sc/source/ui/inc/viewfunc.hxx | 5 ++ sc/source/ui/miscdlgs/makefile.mk | 1 + sc/source/ui/src/globstr.src | 8 ++ sc/source/ui/src/miscdlgs.src | 90 ++++++++++++++++++++++ sc/source/ui/src/popup.src | 9 +++ sc/source/ui/src/scstring.src | 8 ++ sc/source/ui/undo/undotab.cxx | 111 +++++++++++++++++++++++++++ sc/source/ui/view/scextopt.cxx | 3 +- sc/source/ui/view/tabcont.cxx | 21 ++++- sc/source/ui/view/tabvwshf.cxx | 135 +++++++++++++++++++++++++++++++++ sc/source/ui/view/viewdata.cxx | 52 ++++++++++++- sc/source/ui/view/viewfun2.cxx | 23 ++++++ sc/uiconfig/scalc/menubar/menubar.xml | 2 + sc/util/makefile.mk | 1 + 41 files changed, 901 insertions(+), 7 deletions(-) create mode 100644 sc/inc/tabbgcolor.hxx diff --git a/sc/inc/ViewSettingsSequenceDefines.hxx b/sc/inc/ViewSettingsSequenceDefines.hxx index 38443e69fc07..ae8340076d06 100644 --- a/sc/inc/ViewSettingsSequenceDefines.hxx +++ b/sc/inc/ViewSettingsSequenceDefines.hxx @@ -64,7 +64,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 @@ -80,6 +80,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/globstr.hrc b/sc/inc/globstr.hrc index 97d77dc06fc5..2728256e1f2b 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -573,7 +573,10 @@ #define STR_STYLE_FAMILY_CELL 433 #define STR_STYLE_FAMILY_PAGE 434 -#define STR_COUNT 435 +#define STR_UNDO_SET_TAB_BG_COLOR 435 +#define STR_UNDO_SET_MULTI_TAB_BG_COLOR 436 + +#define STR_COUNT 437 #endif diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 8fb6b929337b..2fa8fb459bc3 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -1650,6 +1650,15 @@ #define MID_3 3 #define MID_4 4 +// Sheet tab color +#define FID_TAB_MENU_SET_TAB_BG_COLOR (SC_OOO_BUILD_START + 7) +#define FID_TAB_SET_TAB_BG_COLOR (SC_OOO_BUILD_START + 8) + +#define SCSTR_SET_TAB_BG_COLOR (SC_OOO_BUILD_START + 9) +#define SCSTR_NO_TAB_BG_COLOR (SC_OOO_BUILD_START + 10) + +#define RID_SCDLG_TAB_BG_COLOR (SC_OOO_BUILD_START + 11) + #endif diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index f9895ff15ebb..fb8416e52239 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -284,6 +284,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: @@ -423,6 +429,14 @@ public: const String& rDefault, ULONG nHelpId , int nId ) = 0; + + virtual AbstractScTabBgColorDlg * CreateScTabBgColorDlg ( Window* pParent, //add for ScTabBgColorDlg + const String& rTitle, //Dialog Title + const String& rTabBgColorNoColorText, //Label for no tab color + const Color& rDefaultColor, //Currently selected Color + ULONG nHelpId , + int nId ) = 0; + virtual AbstractScImportOptionsDlg * CreateScImportOptionsDlg ( Window* pParent, //add for ScImportOptionsDlg int nId, BOOL bAscii = TRUE, diff --git a/sc/inc/scextopt.hxx b/sc/inc/scextopt.hxx index fdf05430cc69..be774ab69c66 100644 --- a/sc/inc/scextopt.hxx +++ b/sc/inc/scextopt.hxx @@ -80,6 +80,8 @@ struct ScExtTabSettings bool mbSelected; /// true = Sheet is selected. bool mbFrozenPanes; /// true = Frozen panes; false = Normal splits. bool mbPageMode; /// true = Pagebreak mode; false = Normal view mode. + Color maTabBgColor; /// Tab Bg Color + bool IsDefaultTabBgColor() const { return maTabBgColor == Color(COL_AUTO) ? TRUE : FALSE; }; explicit ScExtTabSettings(); }; diff --git a/sc/inc/tabbgcolor.hxx b/sc/inc/tabbgcolor.hxx new file mode 100644 index 000000000000..83b694af6219 --- /dev/null +++ b/sc/inc/tabbgcolor.hxx @@ -0,0 +1,46 @@ +/************************************************************************* + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SC_TABBGCOLOR_HXX +#define SC_TABBGCOLOR_HXX + +#include +#include + +struct ScUndoSetTabBgColorInfo +{ +public: + SCTAB nTabId; + Color aOldTabBgColor; + Color aNewTabBgColor; + BOOL IsDefaultOldTabBgColor() const {return aOldTabBgColor == Color( COL_AUTO ) ? TRUE : FALSE ;}; + BOOL IsDefaultNewTabBgColor() const {return aOldTabBgColor == Color( COL_AUTO ) ? TRUE : FALSE ;}; +}; +DECLARE_LIST( ScUndoSetTabBgColorInfoList, ScUndoSetTabBgColorInfo* ) +#endif diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 010e420feb42..73fc9cdea301 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -529,6 +529,8 @@ #define SC_UNO_ZOOMTYPE "ZoomType" #define SC_UNO_ZOOMVALUE "ZoomValue" #define SC_UNO_UPDTEMPL "UpdateFromTemplate" +#define SC_UNO_TABCOLOR "TabColor" + /*Stampit enable/disable print cancel */ #define SC_UNO_ALLOWPRINTJOBCANCEL "AllowPrintJobCancel" diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 5d8c1de7612d..ad6dfbf31e42 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -63,6 +63,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 0be7ed5df204..84ff69d38cff 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -7824,3 +7824,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 227d91b47998..cfada86a8ece 100644 --- a/sc/sdi/tabvwsh.sdi +++ b/sc/sdi/tabvwsh.sdi @@ -61,6 +61,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/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index a4a286d27171..50c173d076a1 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -1151,6 +1151,9 @@ 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; + + // 0x0862 (SHEETEXT) + case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break; } } break; diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 2172a7678763..0412dacabb15 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -77,6 +77,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 649bc0de32e6..7e06ff9cf412 100644 --- a/sc/source/filter/excel/xeview.cxx +++ b/sc/source/filter/excel/xeview.cxx @@ -259,6 +259,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 { @@ -368,6 +397,14 @@ XclExpTabViewSettings::XclExpTabViewSettings( const XclExpRoot& rRoot, SCTAB nSc maData.mnNormalZoom = lclGetXclZoom( rTabSett.mnNormalZoom, EXC_WIN2_NORMALZOOM_DEF ); maData.mnPageZoom = lclGetXclZoom( rTabSett.mnPageZoom, EXC_WIN2_PAGEZOOM_DEF ); maData.mnCurrentZoom = maData.mbPageMode ? maData.mnPageZoom : maData.mnNormalZoom; + + // Tab Bg Color + if ( GetBiff() == EXC_BIFF8 && !rTabSett.IsDefaultTabBgColor() ) + { + XclExpPalette& rPal = GetPalette(); + maData.maTabBgColor = rTabSett.maTabBgColor; + maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG ); + } } } @@ -380,6 +417,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 ) @@ -494,5 +532,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 2d920b0a0bd4..bc81ff6ae235 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -3714,6 +3714,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; } switch( rStrm.GetRecId() ) diff --git a/sc/source/filter/excel/xiview.cxx b/sc/source/filter/excel/xiview.cxx index a871bdd0c1d7..fbd72d02e9f8 100644 --- a/sc/source/filter/excel/xiview.cxx +++ b/sc/source/filter/excel/xiview.cxx @@ -109,6 +109,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 ) @@ -279,6 +297,10 @@ void XclImpTabViewSettings::Finalize() aViewOpt.SetOption( VOPT_OUTLINER, maData.mbShowOutline ); rDoc.SetViewOptions( aViewOpt ); } + + // *** set tab bg color + if ( !maData.IsDefaultTabBgColor() ) + rTabSett.maTabBgColor = maData.maTabBgColor; } // ============================================================================ diff --git a/sc/source/filter/excel/xlview.cxx b/sc/source/filter/excel/xlview.cxx index e3290e844bd5..32e4c4db5392 100644 --- a/sc/source/filter/excel/xlview.cxx +++ b/sc/source/filter/excel/xlview.cxx @@ -79,6 +79,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 fb2ea876c279..05e73a316174 100644 --- a/sc/source/filter/inc/xestyle.hxx +++ b/sc/source/filter/inc/xestyle.hxx @@ -61,7 +61,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 149cdad4d85b..ed25cc07bea4 100644 --- a/sc/source/filter/inc/xeview.hxx +++ b/sc/source/filter/inc/xeview.hxx @@ -134,6 +134,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. */ @@ -156,6 +170,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 432bd394b70c..004476a47d01 100644 --- a/sc/source/filter/inc/xiview.hxx +++ b/sc/source/filter/inc/xiview.hxx @@ -83,7 +83,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 91b4866cccf9..c475a9e38701 100644 --- a/sc/source/filter/inc/xlview.hxx +++ b/sc/source/filter/inc/xlview.hxx @@ -89,6 +89,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. */ @@ -149,6 +154,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/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 60b101d482c0..b4264c67a505 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -65,6 +65,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 @@ -114,6 +115,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(AbstractTabDialog_Impl); //add for ScAttrDlg, ScHFEditDlg, ScStyleDlg, ScSubTotalDlg,ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg @@ -614,6 +616,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 { @@ -1260,6 +1270,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 40f6d3bee976..2dc0f2039275 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -61,6 +61,7 @@ class ScDPShowDetailDlg; class ScNewScenarioDlg; class ScShowTabDlg; class ScStringInputDlg; +class ScTabBgColorDlg; class ScImportOptionsDlg; class SfxTabDialog; class ScSortWarningDlg; @@ -337,6 +338,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) @@ -511,6 +518,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/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 608c1c688ea9..59c21498afc6 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2855,6 +2855,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; + } + + ScViewData* pViewData = rDocShell.GetViewData(); + + Color aOldTabBgColor; + aOldTabBgColor = pViewData->GetTabBgColor(nTab); + + BOOL bSuccess = FALSE; + pViewData->SetTabBgColor(rColor, nTab); + if ( pViewData->GetTabBgColor( nTab ) == rColor) + bSuccess = TRUE; + if (bSuccess) + { + if (bRecord) + { + rDocShell.GetUndoManager()->AddUndoAction( + new ScUndoSetTabBgColor( &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( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorInfoList, 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; + } + + ScViewData* pViewData = rDocShell.GetViewData(); + USHORT nTab; + Color aNewTabBgColor; + ScUndoSetTabBgColorInfo* rUndoSetTabBgColorInfo; + BOOL bSuccess = TRUE; + USHORT nTabProtectCount = 0; + for ( USHORT i=0; i < rUndoSetTabBgColorInfoList->Count(); i++ ) + { + rUndoSetTabBgColorInfo = rUndoSetTabBgColorInfoList->GetObject(i); + nTab = rUndoSetTabBgColorInfo->nTabId; + if ( !pDoc->IsTabProtected(nTab) ) + { + aNewTabBgColor = rUndoSetTabBgColorInfo->aNewTabBgColor; + rUndoSetTabBgColorInfo->aOldTabBgColor = pViewData->GetTabBgColor(nTab); + pViewData->SetTabBgColor(aNewTabBgColor, nTab); + if ( pViewData->GetTabBgColor( nTab ) != aNewTabBgColor) + { + bSuccess = FALSE; + break; + } + } + else + { + nTabProtectCount++; + } + } + if ( nTabProtectCount == rUndoSetTabBgColorInfoList->Count() ) + { + if (!bApi) + rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error... + return FALSE; + } + if (bSuccess) + { + if (bRecord) + { + rDocShell.GetUndoManager()->AddUndoAction( + new ScUndoSetTabBgColor( &rDocShell, rUndoSetTabBgColorInfoList)); + } + rDocShell.PostPaintExtras(); + ScDocShellModificator aModificator( rDocShell ); + aModificator.SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + } + return bSuccess; +} + //------------------------------------------------------------------------ //! SetWidthOrHeight - noch doppelt zu ViewFunc !!!!!! diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index 3e9ff5258682..de849fb06cbf 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -34,6 +34,7 @@ #include #include "global.hxx" #include "formula/grammar.hxx" +#include "tabbgcolor.hxx" class ScEditEngineDefaulter; class SdrUndoAction; @@ -120,6 +121,10 @@ 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( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorInfoList, + 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/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc index fc04f2b5ed1f..cb8d7c3f44b0 100644 --- a/sc/source/ui/inc/miscdlgs.hrc +++ b/sc/source/ui/inc/miscdlgs.hrc @@ -184,3 +184,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/undotab.hxx b/sc/source/ui/inc/undotab.hxx index a7cf0d094d6b..40a7499208ee 100644 --- a/sc/source/ui/inc/undotab.hxx +++ b/sc/source/ui/inc/undotab.hxx @@ -35,6 +35,7 @@ #include "markdata.hxx" #include "formula/grammar.hxx" #include +#include "tabbgcolor.hxx" #ifndef _SVSTDARR_SHORTS @@ -226,6 +227,37 @@ private: void DoChange() const; }; +class ScUndoSetTabBgColor: public ScSimpleUndo +{ +public: + TYPEINFO(); + ScUndoSetTabBgColor( + ScDocShell* pNewDocShell, + SCTAB nT, + const Color& aOTabBgColor, + const Color& aNTabBgColor); + ScUndoSetTabBgColor( + ScDocShell* pNewDocShell, + ScUndoSetTabBgColorInfoList* pUndoSetTabBgColorInfoList); + virtual ~ScUndoSetTabBgColor(); + + virtual void Undo(); + virtual void Redo(); + virtual void Repeat(SfxRepeatTarget& rTarget); + virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const; + +virtual String GetComment() const; + +private: + SCTAB nTab; + Color aOldTabBgColor; + Color aNewTabBgColor; + ScUndoSetTabBgColorInfoList* aUndoSetTabBgColorInfoList; + BOOL bIsMultipleUndo; + + void DoChange( SCTAB nTab, const Color& rTabBgColor ) const; + void DoChange( BOOL bUndoType ) const; +}; class ScUndoMakeScenario: public ScSimpleUndo { diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 709bd7898e22..cc5ffc650a9d 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -144,6 +144,9 @@ private: BOOL bOldCurValid; // "virtuelle" Cursorpos. bei zusammengefassten + Color aTabBgColor; + BOOL IsDefaultTabBgColor() const {return aTabBgColor == Color( COL_AUTO ) ? TRUE : FALSE ;}; + ScViewDataTable(); ~ScViewDataTable(); @@ -276,6 +279,10 @@ public: void CopyTab( SCTAB nSrcTab, SCTAB nDestTab ); void MoveTab( SCTAB nSrcTab, SCTAB nDestTab ); + void SetTabBgColor( Color rTabBgColor, SCTAB nTab ); + BOOL IsDefaultTabBgColor( SCTAB nTab ) const; + Color GetTabBgColor( SCTAB nTab ) const; + SCTAB GetRefTabNo() const { return nRefTabNo; } void SetRefTabNo( SCTAB nNewTab ) { nRefTabNo = nNewTab; } diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 066aadca817a..fbc6f1ca917f 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -32,6 +32,8 @@ #include "tabview.hxx" +#include "tabbgcolor.hxx" + #ifndef _SVSTDARR_SHORTS #define _SVSTDARR_SHORTS #include @@ -276,6 +278,9 @@ public: SCTAB nCount, const SCTAB* pSrcTabs, BOOL bLink,SCTAB nTab); + BOOL SetTabBgColor( const Color& rColor, SCTAB nTabNr ); + BOOL SetTabBgColor( ScUndoSetTabBgColorInfoList* 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 66e1f33618e2..a1ad21220e58 100644 --- a/sc/source/ui/miscdlgs/makefile.mk +++ b/sc/source/ui/miscdlgs/makefile.mk @@ -50,6 +50,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/src/globstr.src b/sc/source/ui/src/globstr.src index c5b8cfd1a9e8..2ae00cac3f49 100644 --- a/sc/source/ui/src/globstr.src +++ b/sc/source/ui/src/globstr.src @@ -1130,6 +1130,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 d9ce050f1cd0..12bb512e149b 100644 --- a/sc/source/ui/src/miscdlgs.src +++ b/sc/source/ui/src/miscdlgs.src @@ -546,6 +546,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 05d10b9813bd..5f1929933623 100644 --- a/sc/source/ui/src/popup.src +++ b/sc/source/ui/src/popup.src @@ -193,6 +193,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 efe9a0312b02..bd5d8ec87a64 100644 --- a/sc/source/ui/src/scstring.src +++ b/sc/source/ui/src/scstring.src @@ -283,6 +283,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/undotab.cxx b/sc/source/ui/undo/undotab.cxx index ce428311d3f8..22808d95ac01 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -70,6 +70,9 @@ #include "drwlayer.hxx" #include "scresid.hxx" +// for set tab bg color +#include "viewdata.hxx" + extern BOOL bDrawIsInUndo; //! irgendwo als Member !!! using namespace com::sun::star; @@ -93,6 +96,7 @@ TYPEINIT1(ScUndoScenarioFlags, SfxUndoAction); TYPEINIT1(ScUndoRenameObject, SfxUndoAction); TYPEINIT1(ScUndoLayoutRTL, SfxUndoAction); //UNUSED2009-05 TYPEINIT1(ScUndoSetGrammar, SfxUndoAction); +TYPEINIT1(ScUndoSetTabBgColor, SfxUndoAction); // ----------------------------------------------------------------------- @@ -779,6 +783,113 @@ BOOL ScUndoCopyTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const return FALSE; } +//--------------------------------------------------------------------------------- +// +// Tab Bg Color +// + +ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell* pNewDocShell, + SCTAB nT, + const Color& aOTabBgColor, + const Color& aNTabBgColor) : + ScSimpleUndo( pNewDocShell ), + nTab ( nT ), + bIsMultipleUndo ( FALSE ), + aUndoSetTabBgColorInfoList ( NULL ) +{ + aOldTabBgColor = aOTabBgColor; + aNewTabBgColor = aNTabBgColor; +} + +ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell* pNewDocShell, + ScUndoSetTabBgColorInfoList* pUndoSetTabBgColorInfoList) : + ScSimpleUndo( pNewDocShell ), + bIsMultipleUndo ( TRUE ) +{ + aUndoSetTabBgColorInfoList = pUndoSetTabBgColorInfoList; +} + +__EXPORT ScUndoSetTabBgColor::~ScUndoSetTabBgColor() +{ +} + +String __EXPORT ScUndoSetTabBgColor::GetComment() const +{ + if (bIsMultipleUndo && aUndoSetTabBgColorInfoList && aUndoSetTabBgColorInfoList->Count() > 1) + return ScGlobal::GetRscString( STR_UNDO_SET_MULTI_TAB_BG_COLOR ); + return ScGlobal::GetRscString( STR_UNDO_SET_TAB_BG_COLOR ); +} + +void ScUndoSetTabBgColor::DoChange( SCTAB nTabP, const Color& rTabBgColor ) const +{ + if (bIsMultipleUndo) + return; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + ScViewData* pViewData = pViewShell->GetViewData(); + if (pViewData) + { + pViewData->SetTabBgColor( rTabBgColor, nTabP ); + pDocShell->PostPaintExtras(); + pDocShell->PostDataChanged(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pViewShell->UpdateInputHandler(); + } + } +} + +void ScUndoSetTabBgColor::DoChange(BOOL bUndoType) const +{ + if (!bIsMultipleUndo) + return; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + ScViewData* pViewData = pViewShell->GetViewData(); + if (pViewData) + { + ScUndoSetTabBgColorInfo* aUndoSetTabBgColorInfo=NULL; + for (USHORT i=0; i < aUndoSetTabBgColorInfoList->Count(); i++) + { + aUndoSetTabBgColorInfo = aUndoSetTabBgColorInfoList->GetObject(i); + pViewData->SetTabBgColor( + bUndoType ? aUndoSetTabBgColorInfo->aOldTabBgColor : aUndoSetTabBgColorInfo->aNewTabBgColor, + aUndoSetTabBgColorInfo->nTabId); + } + pDocShell->PostPaintExtras(); + pDocShell->PostDataChanged(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pViewShell->UpdateInputHandler(); + } + } +} + +void __EXPORT ScUndoSetTabBgColor::Undo() +{ + if ( bIsMultipleUndo ) + DoChange(TRUE); + else + DoChange(nTab, aOldTabBgColor); +} + +void __EXPORT ScUndoSetTabBgColor::Redo() +{ + if ( bIsMultipleUndo ) + DoChange(FALSE); + else + DoChange(nTab, aNewTabBgColor); +} + +void __EXPORT ScUndoSetTabBgColor::Repeat(SfxRepeatTarget& /* rTarget */) +{ + // No Repeat +} + +BOOL __EXPORT ScUndoSetTabBgColor::CanRepeat(SfxRepeatTarget& /* rTarget */) const +{ + return FALSE; +} // ----------------------------------------------------------------------- // diff --git a/sc/source/ui/view/scextopt.cxx b/sc/source/ui/view/scextopt.cxx index e6b4a3d0c20e..bac31b006258 100644 --- a/sc/source/ui/view/scextopt.cxx +++ b/sc/source/ui/view/scextopt.cxx @@ -61,7 +61,8 @@ ScExtTabSettings::ScExtTabSettings() : mnPageZoom( 0 ), mbSelected( false ), mbFrozenPanes( false ), - mbPageMode( false ) + mbPageMode( false ), + maTabBgColor( COL_AUTO) { } diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index db1a8952aeef..6b61c21788de 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -69,6 +69,7 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) : ScDocument* pDoc = pViewData->GetDocument(); String aString; + Color aTabBgColor; SCTAB nCount = pDoc->GetTableCount(); for (SCTAB i=0; i(i)+1, aString, TPB_SPECIAL ); else InsertPage( static_cast(i)+1, aString ); + if ( !pViewData->IsDefaultTabBgColor(i) ) + { + aTabBgColor = pViewData->GetTabBgColor(i); + /*SetTabBgColor(static_cast(i)+1, aTabBgColor, pViewData->IsDefaultTabBgColor(i) );*/ + SetTabBgColor( static_cast(i)+1, aTabBgColor ); + } } } } @@ -265,6 +272,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) @@ -291,16 +299,22 @@ void ScTabControl::UpdateStatus() SCTAB i; String aString; SCTAB nMaxCnt = Max( nCount, static_cast(GetMaxId()) ); + Color aTabBgColor; BOOL bModified = FALSE; // Tabellen-Namen for (i=0; iIsVisible(i)) + { pDoc->GetName(i,aString); + aTabBgColor = pViewData->GetTabBgColor(i); + } else + { aString.Erase(); + } - if (GetPageText(static_cast(i)+1) != aString) + if ( (GetPageText(static_cast(i)+1) != aString) || (GetTabBgColor(static_cast(i)+1) != aTabBgColor) ) bModified = TRUE; } @@ -317,6 +331,11 @@ void ScTabControl::UpdateStatus() InsertPage( static_cast(i)+1, aString, TPB_SPECIAL ); else InsertPage( static_cast(i)+1, aString ); + if ( !pViewData->IsDefaultTabBgColor(i) ) + { + aTabBgColor = pViewData->GetTabBgColor(i); + SetTabBgColor( static_cast(i)+1, aTabBgColor ); + } } } } diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 744481c4441c..5a2471c8fc05 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -58,6 +58,10 @@ #include "scabstdlg.hxx" //CHINA001 +#include "tabbgcolor.hxx" //DBW +#include "tabbgcolordlg.hxx" //DBW +#include //DBW + #define IS_AVAILABLE(WhichId,ppItem) \ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) @@ -686,6 +690,120 @@ 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(); + + ScUndoSetTabBgColorInfo* aTabBgColorUndoInfo=NULL; + ScUndoSetTabBgColorInfoList* aTabBgColorUndoInfoList =NULL; + + 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 ) + { + aTabBgColorUndoInfoList = new ScUndoSetTabBgColorInfoList(); + for (SCTAB nTab=0; nTabIsTabProtected(nTab) ) + { + aTabBgColorUndoInfo = new ScUndoSetTabBgColorInfo(); + aTabBgColorUndoInfo->nTabId = nTab; + aTabBgColorUndoInfo->aNewTabBgColor = aColor; + aTabBgColorUndoInfoList->Insert(aTabBgColorUndoInfo); + } + } + bDone = SetTabBgColor( aTabBgColorUndoInfoList ); + } + 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 = pViewData->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); + aTabBgColorUndoInfoList = new ScUndoSetTabBgColorInfoList(); + if ( nTabSelCount > 1 ) + { + for (SCTAB nTab=0; nTabIsTabProtected(nTab) ) + { + aTabBgColorUndoInfo = new ScUndoSetTabBgColorInfo(); + aTabBgColorUndoInfo->nTabId = nTab; + aTabBgColorUndoInfo->aNewTabBgColor = aSelectedColor; + aTabBgColorUndoInfoList->Insert(aTabBgColorUndoInfo); + } + } + bDone = SetTabBgColor( aTabBgColorUndoInfoList ); + } + 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; @@ -804,6 +922,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 = pViewData->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 c3848b76b92b..288e52fa7668 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -104,7 +104,8 @@ ScViewDataTable::ScViewDataTable() : nFixPosY( 0 ), nCurX( 0 ), nCurY( 0 ), - bOldCurValid( FALSE ) + bOldCurValid( FALSE ), + aTabBgColor( Color(COL_AUTO) ) { nPosX[0]=nPosX[1]=0; nPosY[0]=nPosY[1]=0; @@ -164,6 +165,11 @@ void ScViewDataTable::WriteUserDataSequence(uno::Sequence pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE)); pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue; + if ( !IsDefaultTabBgColor() ) + { + pSettings[SC_TABLE_TAB_BG_COLOR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_TABCOLOR)); + pSettings[SC_TABLE_TAB_BG_COLOR].Value <<= static_cast(aTabBgColor.GetColor()); + } // pSettings[SC_TABLE_SELECTED].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLESELECTED)); // pSettings[SC_TABLE_SELECTED].Value <<= bool(rViewData.GetMarkData().GetTableSelect( nTab )); } @@ -276,6 +282,13 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence >= bSelected; rViewData.GetMarkData().SelectTable( nTab, bSelected ); } + else if (sName.compareToAscii(SC_UNO_TABCOLOR) == 0) + { + sal_Int32 nColor = COL_AUTO; + aSettings[i].Value >>= nColor; + if (nColor != COL_AUTO) + aTabBgColor.SetColor(static_cast(nColor)); + } } if (eHSplitMode == SC_SPLIT_FIX) nFixPosX = SanitizeCol( static_cast( bHasHSplitInTwips ? nTempPosHTw : nTempPosH )); @@ -579,6 +592,36 @@ void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab ) aMarkData.InsertTab( nInsTab ); // ggf. angepasst } +void ScViewData::SetTabBgColor( Color rTabBgColor, SCTAB nTab ) +{ + if ( rTabBgColor != Color(COL_AUTO) ) + { + if ( !pTabData[nTab] ) + CreateTabData( nTab ); + pTabData[nTab]->aTabBgColor = rTabBgColor; + } + else + { + if ( pTabData[nTab] ) + pTabData[nTab]->aTabBgColor = Color( COL_AUTO ); + } +} + +Color ScViewData::GetTabBgColor( SCTAB nTab ) const +{ + if ( !pTabData[nTab] ) + return Color(COL_AUTO); + return pTabData[nTab]->aTabBgColor; +} + +BOOL ScViewData::IsDefaultTabBgColor( SCTAB nTab ) const +{ + if ( !pTabData[nTab] ) + return true; + BOOL bResult = pTabData[nTab]->aTabBgColor==Color( COL_AUTO ) ? TRUE : FALSE; + return bResult; +} + //UNUSED2008-05 void ScViewData::UpdateOle( ScSplitPos /* eWhich */ ) //UNUSED2008-05 { //UNUSED2008-05 GetDocShell()->UpdateOle(this); @@ -2444,6 +2487,9 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const rTabSett.mbPageMode = bPagebreak; rTabSett.mnNormalZoom = static_cast< long >( pViewTab->aZoomY * Fraction( 100.0 ) ); rTabSett.mnPageZoom = static_cast< long >( pViewTab->aPageZoomY * Fraction( 100.0 ) ); + + // Tab Bg Color + rTabSett.maTabBgColor = pViewTab->aTabBgColor; } } } @@ -2598,6 +2644,10 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) update map modes that are needed to draw text correctly. */ SetPagebreakMode( rTabSett.mbPageMode ); } + + // Tab Bg Color + if( !rTabSett.IsDefaultTabBgColor() ) + rViewTab.aTabBgColor = rTabSett.maTabBgColor; } } diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 50ede74ab06b..db6023c86f47 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -89,6 +89,7 @@ #include "funcdesc.hxx" #include "docuno.hxx" +#include "tabbgcolor.hxx" //DBW // STATIC DATA --------------------------------------------------------------- @@ -2274,6 +2275,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( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorInfoList ) +{ + BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( rUndoSetTabBgColorInfoList, TRUE, FALSE ); + if (bSuccess) + { + GetViewData()->GetViewShell()->UpdateInputHandler(); + } + return bSuccess; +} + //---------------------------------------------------------------------------- void ScViewFunc::InsertAreaLink( const String& rFile, diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index ab3f121809fa..eed3a975b7f4 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -214,6 +214,8 @@ + + diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index c06071ff6324..b3b438b8f345 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -259,6 +259,7 @@ LIB8OBJFILES = \ $(SLO)$/attrdlg.obj \ $(SLO)$/scuiimoptdlg.obj \ $(SLO)$/strindlg.obj \ + $(SLO)$/tabbgcolordlg.obj \ $(SLO)$/shtabdlg.obj \ $(SLO)$/scendlg.obj \ $(SLO)$/pvfundlg.obj \ -- cgit From 1520eb90b5077da6d40d892feebd70790d359f25 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 17 Sep 2009 21:50:01 -0400 Subject: Fixed build breakages. Now the whole thing builds. --- sc/inc/sc.hrc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 2fa8fb459bc3..db555a5cc127 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) @@ -1430,7 +1432,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) @@ -1635,8 +1640,9 @@ #define RID_SCDLG_DOCPROTECTION (SC_DIALOGS_START + 149) #define RID_SCDLG_RETYPEPASS (SC_DIALOGS_START + 150) #define RID_SCDLG_RETYPEPASS_INPUT (SC_DIALOGS_START + 151) +#define RID_SCDLG_TAB_BG_COLOR (SC_DIALOGS_START + 152) -#define SC_DIALOGS_END (SC_DIALOGS_START + 152) +#define SC_DIALOGS_END (SC_DIALOGS_START + 153) #ifndef STD_MASKCOLOR #define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } @@ -1650,15 +1656,6 @@ #define MID_3 3 #define MID_4 4 -// Sheet tab color -#define FID_TAB_MENU_SET_TAB_BG_COLOR (SC_OOO_BUILD_START + 7) -#define FID_TAB_SET_TAB_BG_COLOR (SC_OOO_BUILD_START + 8) - -#define SCSTR_SET_TAB_BG_COLOR (SC_OOO_BUILD_START + 9) -#define SCSTR_NO_TAB_BG_COLOR (SC_OOO_BUILD_START + 10) - -#define RID_SCDLG_TAB_BG_COLOR (SC_OOO_BUILD_START + 11) - #endif -- cgit From 788b4151c79c72db8b18f65f90bbb04fbf5f7b4c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 17 Sep 2009 21:51:53 -0400 Subject: forgot to add two more new files. --- sc/source/ui/inc/tabbgcolordlg.hxx | 80 +++++++++++++ sc/source/ui/miscdlgs/tabbgcolordlg.cxx | 197 ++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+) create mode 100644 sc/source/ui/inc/tabbgcolordlg.hxx create mode 100644 sc/source/ui/miscdlgs/tabbgcolordlg.cxx diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx new file mode 100644 index 000000000000..6beff970431c --- /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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_TABBGCOLORDLG_HXX +#define SC_TABBGCOLORDLG_HXX + +#include +#include +#include +#include + +//------------------------------------------------------------------------ + +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; + //void SelectColor( const Color& rColor2 ) 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 aHelpId; + + void FillColorValueSets_Impl(); + + DECL_LINK( TabBgColorDblClickHdl_Impl, ValueSet* ); + DECL_LINK( TabBgColorOKHdl_Impl, OKButton* pBtn ); +}; + +#endif // SC_TABBGCOLORDLG_HXX diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx new file mode 100644 index 000000000000..01c9c2a5cf1a --- /dev/null +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include "tabbgcolordlg.hxx" +#include "scresid.hxx" +#include "miscdlgs.hrc" +#include + +//================================================================== + +#define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl) + +__EXPORT 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 ) ), + aTabBgColorNoColorText ( rTabBgColorNoColorText ), + aTabBgColor ( rDefaultColor ), + aHelpId ( nHelpId ) + +{ + SetHelpId( nHelpId ); + this->SetText( rTitle ); + this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE); + //TODO: Assign Help ID's to all controls... + 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; +} + +__EXPORT ScTabBgColorDlg::~ScTabBgColorDlg() +{ +} + +void ScTabBgColorDlg::FillColorValueSets_Impl() +{ + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem = NULL; + XColorTable* pColorTable = NULL; + const Size aSize15x15 = Size( 15, 15 ); + const Size aSize10x10 = Size( 10, 10 ); + const Size aSize5x5 = Size( 5, 5 ); + USHORT nSelectedItem = 0; + FASTBOOL bOwn = FALSE; + + DBG_ASSERT( pDocSh, "DocShell not found!" ); + + if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) ) + pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); + if ( !pColorTable ) + { + bOwn = TRUE; + pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() ); + } + if ( pColorTable ) + { + short 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(); + if ( bOwn ) + delete pColorTable; +} + +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; +} + +__EXPORT 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); +} -- cgit From c08d97576a8e0e4578073cc28da7ffe93a8b44b1 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 16 Nov 2009 11:52:53 -0500 Subject: Removed a compiler warning wrt initialization ordering of data members. --- sc/source/ui/miscdlgs/tabbgcolordlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx index 01c9c2a5cf1a..bac8dd7a78e1 100644 --- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -63,8 +63,8 @@ __EXPORT ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, aBtnOk ( this, ScResId( BTN_OK ) ), aBtnCancel ( this, ScResId( BTN_CANCEL ) ), aBtnHelp ( this, ScResId( BTN_HELP ) ), - aTabBgColorNoColorText ( rTabBgColorNoColorText ), aTabBgColor ( rDefaultColor ), + aTabBgColorNoColorText ( rTabBgColorNoColorText ), aHelpId ( nHelpId ) { -- cgit From 58f94f9afcaea325ad087c19ffb825dfb83448df Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 20 Jan 2010 16:28:02 -0500 Subject: calctabcolor: pathoptions.hxx moved from svtools to unotools. --- sc/source/ui/miscdlgs/tabbgcolordlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx index bac8dd7a78e1..000d64955598 100644 --- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include "tabbgcolordlg.hxx" #include "scresid.hxx" -- cgit From d8c9ce99b4ab513775ef566f4498a66246ffb11b Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 20 Jan 2010 17:05:34 -0500 Subject: calctabcolor: removed compiler warnings. --- sc/source/ui/dbgui/validate.cxx | 2 +- sc/source/ui/inc/undotab.hxx | 2 +- sc/source/ui/undo/undotab.cxx | 20 ++++++++++---------- sc/source/ui/view/viewdata.cxx | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 81e8ff35195d..2d286355db6c 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -584,7 +584,7 @@ void ScTPValidationValue::TidyListBoxes() pWnd = GetChild(0); - while( std::find( alstOrder.begin(), alstOrder.end(), pWnd ) != alstOrder.end() && NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT) ) ); + while( std::find( alstOrder.begin(), alstOrder.end(), pWnd ) != alstOrder.end() && NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT) ) ) ; if ( pWnd ) { diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx index e4e4911d606d..c158c9747da7 100644 --- a/sc/source/ui/inc/undotab.hxx +++ b/sc/source/ui/inc/undotab.hxx @@ -249,10 +249,10 @@ public: virtual String GetComment() const; private: + ScUndoSetTabBgColorInfoList* aUndoSetTabBgColorInfoList; SCTAB nTab; Color aOldTabBgColor; Color aNewTabBgColor; - ScUndoSetTabBgColorInfoList* aUndoSetTabBgColorInfoList; BOOL bIsMultipleUndo; void DoChange( SCTAB nTab, const Color& rTabBgColor ) const; diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 41c56cadb3be..fdadd74f5cba 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -793,12 +793,12 @@ ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell* pNewDocShell, const Color& aOTabBgColor, const Color& aNTabBgColor) : ScSimpleUndo( pNewDocShell ), + aUndoSetTabBgColorInfoList ( NULL ), nTab ( nT ), - bIsMultipleUndo ( FALSE ), - aUndoSetTabBgColorInfoList ( NULL ) + aOldTabBgColor( aOTabBgColor ), + aNewTabBgColor( aNTabBgColor ), + bIsMultipleUndo ( FALSE ) { - aOldTabBgColor = aOTabBgColor; - aNewTabBgColor = aNTabBgColor; } ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell* pNewDocShell, @@ -809,11 +809,11 @@ ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell* pNewDocShell, aUndoSetTabBgColorInfoList = pUndoSetTabBgColorInfoList; } -__EXPORT ScUndoSetTabBgColor::~ScUndoSetTabBgColor() +ScUndoSetTabBgColor::~ScUndoSetTabBgColor() { } -String __EXPORT ScUndoSetTabBgColor::GetComment() const +String ScUndoSetTabBgColor::GetComment() const { if (bIsMultipleUndo && aUndoSetTabBgColorInfoList && aUndoSetTabBgColorInfoList->Count() > 1) return ScGlobal::GetRscString( STR_UNDO_SET_MULTI_TAB_BG_COLOR ); @@ -865,7 +865,7 @@ void ScUndoSetTabBgColor::DoChange(BOOL bUndoType) const } } -void __EXPORT ScUndoSetTabBgColor::Undo() +void ScUndoSetTabBgColor::Undo() { if ( bIsMultipleUndo ) DoChange(TRUE); @@ -873,7 +873,7 @@ void __EXPORT ScUndoSetTabBgColor::Undo() DoChange(nTab, aOldTabBgColor); } -void __EXPORT ScUndoSetTabBgColor::Redo() +void ScUndoSetTabBgColor::Redo() { if ( bIsMultipleUndo ) DoChange(FALSE); @@ -881,12 +881,12 @@ void __EXPORT ScUndoSetTabBgColor::Redo() DoChange(nTab, aNewTabBgColor); } -void __EXPORT ScUndoSetTabBgColor::Repeat(SfxRepeatTarget& /* rTarget */) +void ScUndoSetTabBgColor::Repeat(SfxRepeatTarget& /* rTarget */) { // No Repeat } -BOOL __EXPORT ScUndoSetTabBgColor::CanRepeat(SfxRepeatTarget& /* rTarget */) const +BOOL ScUndoSetTabBgColor::CanRepeat(SfxRepeatTarget& /* rTarget */) const { return FALSE; } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c59aabab3796..f43fcdde2ef8 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -286,7 +286,7 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence >= nColor; - if (nColor != COL_AUTO) + if (static_cast(nColor) != COL_AUTO) aTabBgColor.SetColor(static_cast(nColor)); } } -- cgit From cc0d82f6a35cf377214df4ab10f06ce64188948e Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 11:48:02 -0500 Subject: calctabcolor: Added data member to ScTable to store tab color. --- sc/inc/document.hxx | 2 ++ sc/inc/table.hxx | 3 +++ sc/source/core/data/documen3.cxx | 13 +++++++++++++ sc/source/core/data/table1.cxx | 11 +++++++++++ 4 files changed, 29 insertions(+) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index cc575b529d73..2c21d35861ae 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -588,6 +588,8 @@ public: Color& rColor, USHORT& rFlags ) const; SC_DLLPUBLIC void SetScenarioData( SCTAB nTab, const String& rComment, const Color& rColor, USHORT nFlags ); + Color GetTabColor( SCTAB nTab ) const; + void SetTabColor( SCTAB nTab, const Color& rColor ); 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/table.hxx b/sc/inc/table.hxx index f400054d00b7..3b5a161328f2 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -155,6 +155,7 @@ private: ScRangeList* pScenarioRanges; Color aScenarioColor; + Color aTabColor; USHORT nScenarioFlags; BOOL bActiveScenario; @@ -210,6 +211,8 @@ public: void SetScenarioComment( const String& rComment ) { aComment = rComment; } const Color& GetScenarioColor() const { return aScenarioColor; } void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; } + const Color& GetTabColor() const; + void SetTabColor(const Color& rColor); USHORT GetScenarioFlags() const { return nScenarioFlags; } void SetScenarioFlags(USHORT nNew) { nScenarioFlags = nNew; } void SetActiveScenario(BOOL bSet) { bActiveScenario = bSet; } diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 2529d0ad7f1d..15fd27e76dc7 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -283,6 +283,19 @@ void ScDocument::SetScenarioData( SCTAB nTab, const String& rComment, } } +Color ScDocument::GetTabColor( SCTAB nTab ) const +{ + if (ValidTab(nTab) && pTab[nTab]) + return pTab[nTab]->GetTabColor(); + return Color(COL_AUTO); +} + +void ScDocument::SetTabColor( SCTAB nTab, const Color& rColor ) +{ + if (ValidTab(nTab) && pTab[nTab]) + pTab[nTab]->SetTabColor(rColor); +} + void ScDocument::GetScenarioData( SCTAB nTab, String& rComment, Color& rColor, USHORT& rFlags ) const { diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 403377342661..f61445b62d5e 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -155,6 +155,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName, nLockCount( 0 ), pScenarioRanges( NULL ), aScenarioColor( COL_LIGHTGRAY ), + aTabColor( COL_AUTO ), nScenarioFlags( 0 ), bActiveScenario( FALSE ) { @@ -278,6 +279,16 @@ void ScTable::SetLoadingRTL( BOOL bSet ) bLoadingRTL = bSet; } +const Color& ScTable::GetTabColor() const +{ + return aTabColor; +} + +void ScTable::SetTabColor(const Color& rColor) +{ + aTabColor = rColor; +} + void ScTable::SetScenario( BOOL bFlag ) { bScenario = bFlag; -- cgit From d5daccbdb1ab66b03ef50c7105b483312be94dfa Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 13:22:54 -0500 Subject: calctabcolor: BOOL to bool. --- sc/source/ui/docshell/docfunc.cxx | 22 +++++++++++----------- sc/source/ui/inc/docfunc.hxx | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index acc9f16e7730..2f6469a3032f 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2855,17 +2855,17 @@ 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 ) +bool ScDocFunc::SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi ) { ScDocument* pDoc = rDocShell.GetDocument(); if (bRecord && !pDoc->IsUndoEnabled()) - bRecord = FALSE; + bRecord = false; if ( !pDoc->IsDocEditable() || pDoc->IsTabProtected(nTab) ) { if (!bApi) rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Check to see what this string is... - return FALSE; + return false; } ScViewData* pViewData = rDocShell.GetViewData(); @@ -2873,10 +2873,10 @@ BOOL ScDocFunc::SetTabBgColor( SCTAB nTab, const Color& rColor, BOOL bRecord, BO Color aOldTabBgColor; aOldTabBgColor = pViewData->GetTabBgColor(nTab); - BOOL bSuccess = FALSE; + bool bSuccess = false; pViewData->SetTabBgColor(rColor, nTab); if ( pViewData->GetTabBgColor( nTab ) == rColor) - bSuccess = TRUE; + bSuccess = true; if (bSuccess) { if (bRecord) @@ -2889,28 +2889,28 @@ BOOL ScDocFunc::SetTabBgColor( SCTAB nTab, const Color& rColor, BOOL bRecord, BO aModificator.SetDocumentModified(); SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); - bSuccess = TRUE; + bSuccess = true; } return bSuccess; } -BOOL ScDocFunc::SetTabBgColor( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorInfoList, BOOL bRecord, BOOL bApi ) +bool ScDocFunc::SetTabBgColor( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorInfoList, bool bRecord, bool bApi ) { ScDocument* pDoc = rDocShell.GetDocument(); if (bRecord && !pDoc->IsUndoEnabled()) - bRecord = FALSE; + bRecord = false; if ( !pDoc->IsDocEditable() ) { if (!bApi) rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error... - return FALSE; + return false; } ScViewData* pViewData = rDocShell.GetViewData(); USHORT nTab; Color aNewTabBgColor; ScUndoSetTabBgColorInfo* rUndoSetTabBgColorInfo; - BOOL bSuccess = TRUE; + bool bSuccess = true; USHORT nTabProtectCount = 0; for ( USHORT i=0; i < rUndoSetTabBgColorInfoList->Count(); i++ ) { @@ -2923,7 +2923,7 @@ BOOL ScDocFunc::SetTabBgColor( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorIn pViewData->SetTabBgColor(aNewTabBgColor, nTab); if ( pViewData->GetTabBgColor( nTab ) != aNewTabBgColor) { - bSuccess = FALSE; + bSuccess = false; break; } } diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index de849fb06cbf..11e8914dd14e 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -121,9 +121,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( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorInfoList, - BOOL bRecord, BOOL bApi ); + bool SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi ); + bool SetTabBgColor( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorInfoList, + bool bRecord, bool bApi ); BOOL SetTableVisible( SCTAB nTab, BOOL bVisible, BOOL bApi ); -- cgit From e91ccd784a2155f62195d3e80900741f3e6e970f Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 14:25:56 -0500 Subject: calctabcolor: Entirely removed storage of tabcolor from ScViewDataTable. --- sc/inc/document.hxx | 5 ++-- sc/inc/table.hxx | 6 ++--- sc/source/core/data/documen3.cxx | 15 ++++++++--- sc/source/core/data/table1.cxx | 10 ++++---- sc/source/ui/docshell/docfunc.cxx | 14 +++++----- sc/source/ui/inc/viewdata.hxx | 7 ----- sc/source/ui/undo/undotab.cxx | 54 ++++++++++++++++++--------------------- sc/source/ui/view/tabcont.cxx | 11 ++++---- sc/source/ui/view/tabvwshf.cxx | 4 +-- sc/source/ui/view/viewdata.cxx | 50 ++++++------------------------------ 10 files changed, 68 insertions(+), 108 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 2c21d35861ae..b3591e9ac03f 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -588,8 +588,9 @@ public: Color& rColor, USHORT& rFlags ) const; SC_DLLPUBLIC void SetScenarioData( SCTAB nTab, const String& rComment, const Color& rColor, USHORT nFlags ); - Color GetTabColor( SCTAB nTab ) const; - void SetTabColor( SCTAB nTab, const Color& rColor ); + Color GetTabBgColor( SCTAB nTab ) const; + void SetTabBgColor( SCTAB nTab, const Color& rColor ); + 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/table.hxx b/sc/inc/table.hxx index 3b5a161328f2..9f3dcdbff5e2 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -155,7 +155,7 @@ private: ScRangeList* pScenarioRanges; Color aScenarioColor; - Color aTabColor; + Color aTabBgColor; USHORT nScenarioFlags; BOOL bActiveScenario; @@ -211,8 +211,8 @@ public: void SetScenarioComment( const String& rComment ) { aComment = rComment; } const Color& GetScenarioColor() const { return aScenarioColor; } void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; } - const Color& GetTabColor() const; - void SetTabColor(const Color& rColor); + 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/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 15fd27e76dc7..373691dd2775 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -283,17 +283,24 @@ void ScDocument::SetScenarioData( SCTAB nTab, const String& rComment, } } -Color ScDocument::GetTabColor( SCTAB nTab ) const +Color ScDocument::GetTabBgColor( SCTAB nTab ) const { if (ValidTab(nTab) && pTab[nTab]) - return pTab[nTab]->GetTabColor(); + return pTab[nTab]->GetTabBgColor(); return Color(COL_AUTO); } -void ScDocument::SetTabColor( SCTAB nTab, const Color& rColor ) +void ScDocument::SetTabBgColor( SCTAB nTab, const Color& rColor ) { if (ValidTab(nTab) && pTab[nTab]) - pTab[nTab]->SetTabColor(rColor); + 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, diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index f61445b62d5e..eca154bb2632 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -155,7 +155,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName, nLockCount( 0 ), pScenarioRanges( NULL ), aScenarioColor( COL_LIGHTGRAY ), - aTabColor( COL_AUTO ), + aTabBgColor( COL_AUTO ), nScenarioFlags( 0 ), bActiveScenario( FALSE ) { @@ -279,14 +279,14 @@ void ScTable::SetLoadingRTL( BOOL bSet ) bLoadingRTL = bSet; } -const Color& ScTable::GetTabColor() const +const Color& ScTable::GetTabBgColor() const { - return aTabColor; + return aTabBgColor; } -void ScTable::SetTabColor(const Color& rColor) +void ScTable::SetTabBgColor(const Color& rColor) { - aTabColor = rColor; + aTabBgColor = rColor; } void ScTable::SetScenario( BOOL bFlag ) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 2f6469a3032f..f54e4c17bcdf 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2868,14 +2868,12 @@ bool ScDocFunc::SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bo return false; } - ScViewData* pViewData = rDocShell.GetViewData(); - Color aOldTabBgColor; - aOldTabBgColor = pViewData->GetTabBgColor(nTab); + aOldTabBgColor = pDoc->GetTabBgColor(nTab); bool bSuccess = false; - pViewData->SetTabBgColor(rColor, nTab); - if ( pViewData->GetTabBgColor( nTab ) == rColor) + pDoc->SetTabBgColor(nTab, rColor); + if ( pDoc->GetTabBgColor(nTab) == rColor) bSuccess = true; if (bSuccess) { @@ -2919,9 +2917,9 @@ bool ScDocFunc::SetTabBgColor( ScUndoSetTabBgColorInfoList* rUndoSetTabBgColorIn if ( !pDoc->IsTabProtected(nTab) ) { aNewTabBgColor = rUndoSetTabBgColorInfo->aNewTabBgColor; - rUndoSetTabBgColorInfo->aOldTabBgColor = pViewData->GetTabBgColor(nTab); - pViewData->SetTabBgColor(aNewTabBgColor, nTab); - if ( pViewData->GetTabBgColor( nTab ) != aNewTabBgColor) + rUndoSetTabBgColorInfo->aOldTabBgColor = pDoc->GetTabBgColor(nTab); + pDoc->SetTabBgColor(nTab, aNewTabBgColor); + if ( pDoc->GetTabBgColor(nTab) != aNewTabBgColor) { bSuccess = false; break; diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 1bfab3a7b46e..dc2fe4522ecd 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -144,9 +144,6 @@ private: BOOL bOldCurValid; // "virtuelle" Cursorpos. bei zusammengefassten - Color aTabBgColor; - BOOL IsDefaultTabBgColor() const {return aTabBgColor == Color( COL_AUTO ) ? TRUE : FALSE ;}; - ScViewDataTable(); ~ScViewDataTable(); @@ -280,10 +277,6 @@ public: void CopyTab( SCTAB nSrcTab, SCTAB nDestTab ); void MoveTab( SCTAB nSrcTab, SCTAB nDestTab ); - void SetTabBgColor( Color rTabBgColor, SCTAB nTab ); - BOOL IsDefaultTabBgColor( SCTAB nTab ) const; - Color GetTabBgColor( SCTAB nTab ) const; - SCTAB GetRefTabNo() const { return nRefTabNo; } void SetRefTabNo( SCTAB nNewTab ) { nRefTabNo = nNewTab; } diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index fdadd74f5cba..0793607fc728 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -824,45 +824,41 @@ void ScUndoSetTabBgColor::DoChange( SCTAB nTabP, const Color& rTabBgColor ) cons { if (bIsMultipleUndo) return; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - { - ScViewData* pViewData = pViewShell->GetViewData(); - if (pViewData) - { - pViewData->SetTabBgColor( rTabBgColor, nTabP ); - pDocShell->PostPaintExtras(); - pDocShell->PostDataChanged(); - SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); - pViewShell->UpdateInputHandler(); - } - } + ScDocument* pDoc = pDocShell->GetDocument(); + if (!pDoc) + return; + + pDoc->SetTabBgColor(nTabP, rTabBgColor); + pDocShell->PostPaintExtras(); + pDocShell->PostDataChanged(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pViewShell->UpdateInputHandler(); } void ScUndoSetTabBgColor::DoChange(BOOL bUndoType) const { if (!bIsMultipleUndo) return; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) + ScDocument* pDoc = pDocShell->GetDocument(); + if (!pDoc) + return; + + ScUndoSetTabBgColorInfo* aUndoSetTabBgColorInfo = NULL; + for (USHORT i=0; i < aUndoSetTabBgColorInfoList->Count(); ++i) { - ScViewData* pViewData = pViewShell->GetViewData(); - if (pViewData) - { - ScUndoSetTabBgColorInfo* aUndoSetTabBgColorInfo=NULL; - for (USHORT i=0; i < aUndoSetTabBgColorInfoList->Count(); i++) - { - aUndoSetTabBgColorInfo = aUndoSetTabBgColorInfoList->GetObject(i); - pViewData->SetTabBgColor( - bUndoType ? aUndoSetTabBgColorInfo->aOldTabBgColor : aUndoSetTabBgColorInfo->aNewTabBgColor, - aUndoSetTabBgColorInfo->nTabId); - } - pDocShell->PostPaintExtras(); - pDocShell->PostDataChanged(); - SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); - pViewShell->UpdateInputHandler(); - } + aUndoSetTabBgColorInfo = aUndoSetTabBgColorInfoList->GetObject(i); + pDoc->SetTabBgColor( + aUndoSetTabBgColorInfo->nTabId, + bUndoType ? aUndoSetTabBgColorInfo->aOldTabBgColor : aUndoSetTabBgColorInfo->aNewTabBgColor); } + pDocShell->PostPaintExtras(); + pDocShell->PostDataChanged(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pViewShell->UpdateInputHandler(); } void ScUndoSetTabBgColor::Undo() diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index 6b61c21788de..39f2937a3e59 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -81,10 +81,9 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) : InsertPage( static_cast(i)+1, aString, TPB_SPECIAL ); else InsertPage( static_cast(i)+1, aString ); - if ( !pViewData->IsDefaultTabBgColor(i) ) + if ( !pDoc->IsDefaultTabBgColor(i) ) { - aTabBgColor = pViewData->GetTabBgColor(i); - /*SetTabBgColor(static_cast(i)+1, aTabBgColor, pViewData->IsDefaultTabBgColor(i) );*/ + aTabBgColor = pDoc->GetTabBgColor(i); SetTabBgColor( static_cast(i)+1, aTabBgColor ); } } @@ -307,7 +306,7 @@ void ScTabControl::UpdateStatus() if (pDoc->IsVisible(i)) { pDoc->GetName(i,aString); - aTabBgColor = pViewData->GetTabBgColor(i); + aTabBgColor = pDoc->GetTabBgColor(i); } else { @@ -331,9 +330,9 @@ void ScTabControl::UpdateStatus() InsertPage( static_cast(i)+1, aString, TPB_SPECIAL ); else InsertPage( static_cast(i)+1, aString ); - if ( !pViewData->IsDefaultTabBgColor(i) ) + if ( !pDoc->IsDefaultTabBgColor(i) ) { - aTabBgColor = pViewData->GetTabBgColor(i); + aTabBgColor = pDoc->GetTabBgColor(i); SetTabBgColor( static_cast(i)+1, aTabBgColor ); } } diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 4d877178fe0b..54f9cab2f693 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -751,7 +751,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) Color aTabBgColor; Color aNewTabBgColor; - aTabBgColor = pViewData->GetTabBgColor( nCurrentTab ); + aTabBgColor = pDoc->GetTabBgColor( nCurrentTab ); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); DBG_ASSERT(pFact, "ScAbstractFactory create fail!"); AbstractScTabBgColorDlg* pDlg = pFact->CreateScTabBgColorDlg( @@ -935,7 +935,7 @@ void ScTabViewShell::GetStateTable( SfxItemSet& rSet ) case FID_TAB_SET_TAB_BG_COLOR: { Color aColor; - aColor = pViewData->GetTabBgColor( nTab ); + aColor = pDoc->GetTabBgColor( nTab ); rSet.Put( SvxColorItem( aColor, nWhich ) ); } break; diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index f43fcdde2ef8..03ad6aa85fc2 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -104,8 +104,7 @@ ScViewDataTable::ScViewDataTable() : nFixPosY( 0 ), nCurX( 0 ), nCurY( 0 ), - bOldCurValid( FALSE ), - aTabBgColor( Color(COL_AUTO) ) + bOldCurValid( FALSE ) { nPosX[0]=nPosX[1]=0; nPosY[0]=nPosY[1]=0; @@ -164,14 +163,6 @@ void ScViewDataTable::WriteUserDataSequence(uno::Sequence 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; - - if ( !IsDefaultTabBgColor() ) - { - pSettings[SC_TABLE_TAB_BG_COLOR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_TABCOLOR)); - pSettings[SC_TABLE_TAB_BG_COLOR].Value <<= static_cast(aTabBgColor.GetColor()); - } -// pSettings[SC_TABLE_SELECTED].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLESELECTED)); -// pSettings[SC_TABLE_SELECTED].Value <<= bool(rViewData.GetMarkData().GetTableSelect( nTab )); } } @@ -284,10 +275,13 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence >= nColor; if (static_cast(nColor) != COL_AUTO) aTabBgColor.SetColor(static_cast(nColor)); +#endif } } if (eHSplitMode == SC_SPLIT_FIX) @@ -592,36 +586,6 @@ void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab ) aMarkData.InsertTab( nInsTab ); // ggf. angepasst } -void ScViewData::SetTabBgColor( Color rTabBgColor, SCTAB nTab ) -{ - if ( rTabBgColor != Color(COL_AUTO) ) - { - if ( !pTabData[nTab] ) - CreateTabData( nTab ); - pTabData[nTab]->aTabBgColor = rTabBgColor; - } - else - { - if ( pTabData[nTab] ) - pTabData[nTab]->aTabBgColor = Color( COL_AUTO ); - } -} - -Color ScViewData::GetTabBgColor( SCTAB nTab ) const -{ - if ( !pTabData[nTab] ) - return Color(COL_AUTO); - return pTabData[nTab]->aTabBgColor; -} - -BOOL ScViewData::IsDefaultTabBgColor( SCTAB nTab ) const -{ - if ( !pTabData[nTab] ) - return true; - BOOL bResult = pTabData[nTab]->aTabBgColor==Color( COL_AUTO ) ? TRUE : FALSE; - return bResult; -} - //UNUSED2008-05 void ScViewData::UpdateOle( ScSplitPos /* eWhich */ ) //UNUSED2008-05 { //UNUSED2008-05 GetDocShell()->UpdateOle(this); @@ -2568,7 +2532,7 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const rTabSett.mnPageZoom = static_cast< long >( pViewTab->aPageZoomY * Fraction( 100.0 ) ); // Tab Bg Color - rTabSett.maTabBgColor = pViewTab->aTabBgColor; +// rTabSett.maTabBgColor = pViewTab->aTabBgColor; } } } @@ -2726,7 +2690,9 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) // Tab Bg Color if( !rTabSett.IsDefaultTabBgColor() ) - rViewTab.aTabBgColor = rTabSett.maTabBgColor; + { +// rViewTab.aTabBgColor = rTabSett.maTabBgColor; + } } } -- cgit From a9233bd6bb2dd1f9ad9c816d7ad24f3de60001b1 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 15:52:41 -0500 Subject: calctabcolor: Import tab colors from view settings in case the documents store tab colors as view settings. --- sc/source/ui/view/viewdata.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 03ad6aa85fc2..2ee2e8771805 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -275,13 +275,13 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence >= nColor; if (static_cast(nColor) != COL_AUTO) - aTabBgColor.SetColor(static_cast(nColor)); -#endif + { + ScDocument* pDoc = rViewData.GetDocument(); + pDoc->SetTabBgColor(nTab, Color(static_cast(nColor))); + } } } if (eHSplitMode == SC_SPLIT_FIX) -- cgit From a29b7cdc581f338473d08079216a06f346e7e6d6 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 19:11:55 -0500 Subject: calctabcolor: Export tab colors to ods via UNO's property. --- sc/inc/unowids.hxx | 3 +- sc/source/filter/xml/xmlexprt.cxx | 228 ++++++++++++++++++++------------------ sc/source/filter/xml/xmlexprt.hxx | 1 + sc/source/ui/unoobj/cellsuno.cxx | 5 + 4 files changed, 130 insertions(+), 107 deletions(-) diff --git a/sc/inc/unowids.hxx b/sc/inc/unowids.hxx index aa75f9cc8404..9b05df2aee52 100644 --- a/sc/inc/unowids.hxx +++ b/sc/inc/unowids.hxx @@ -80,7 +80,8 @@ #define SC_WID_UNO_TABLAYOUT ( SC_WID_UNO_START + 37 ) #define SC_WID_UNO_AUTOPRINT ( SC_WID_UNO_START + 38 ) #define SC_WID_UNO_ABSNAME ( SC_WID_UNO_START + 39 ) -#define SC_WID_UNO_END ( SC_WID_UNO_START + 39 ) +#define SC_WID_UNO_TABCOLOR ( SC_WID_UNO_START + 40 ) +#define SC_WID_UNO_END ( SC_WID_UNO_START + 40 ) inline BOOL IsScUnoWid( USHORT nWid ) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index c2fd53acb736..6bb252bc546d 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -87,6 +87,7 @@ #include #include +#include "tools/color.hxx" #include #include #include @@ -127,6 +128,7 @@ #include #include #include +#include #include #include @@ -164,6 +166,7 @@ using namespace formula; using namespace com::sun::star; using namespace xmloff::token; using ::std::vector; +using ::com::sun::star::uno::UNO_QUERY; //---------------------------------------------------------------------------- @@ -529,6 +532,7 @@ ScXMLExport::ScXMLExport( sAttrName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NAME)); sAttrStyleName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME)); + sAttrTabColor = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TAB_COLOR)); sAttrColumnsRepeated = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NUMBER_COLUMNS_REPEATED)); sAttrFormula = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_FORMULA)); sAttrStringValue = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_STRING_VALUE)); @@ -1708,132 +1712,144 @@ void ScXMLExport::_ExportContent() } else { - //! indent after rebasing to m52 - - uno::Reference xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); - if (xTable.is()) - { - xCurrentTable.set(xTable); - xCurrentTableCellRange.set(xTable, uno::UNO_QUERY); - uno::Reference xName (xTable, uno::UNO_QUERY ); - if ( xName.is() ) + uno::Reference xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); + if (xTable.is()) { - nCurrentTable = sal::static_int_cast( nTable ); - rtl::OUString sOUTableName(xName->getName()); - AddAttribute(sAttrName, sOUTableName); - AddAttribute(sAttrStyleName, aTableStyles[nTable]); - uno::Reference xProtectable (xTable, uno::UNO_QUERY); - if (xProtectable.is() && xProtectable->isProtected()) + xCurrentTable.set(xTable); + xCurrentTableCellRange.set(xTable, uno::UNO_QUERY); + uno::Reference 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( nTable ); + rtl::OUString sOUTableName(xName->getName()); + AddAttribute(sAttrName, sOUTableName); + AddAttribute(sAttrStyleName, aTableStyles[nTable]); + + uno::Reference xPropSet(xTable, UNO_QUERY); + if (xPropSet.is()) { - ScTableProtection* pProtect = pDoc->GetTabProtection(static_cast(nTable)); - if (pProtect) - SvXMLUnitConverter::encodeBase64(aBuffer, pProtect->getPasswordHash(PASSHASH_OOO)); + // Tab color for this table, if exists. + uno::Any any; + any = xPropSet->getPropertyValue(OUString::createFromAscii(SC_UNO_TABCOLOR)); + sal_Int32 nColor; + if (any >>= nColor) + { + if (static_cast(nColor) != COL_AUTO) + AddAttribute(sAttrTabColor, OUString::valueOf(nColor)); + } } - 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(nTable))) - AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT, XML_FALSE); - SvXMLElementExport aElemT(*this, sElemTab, sal_True, sal_True); - CheckAttrList(); - WriteTableSource(); - WriteScenario(); - uno::Reference 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(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(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) + + uno::Reference xProtectable (xTable, uno::UNO_QUERY); + if (xProtectable.is() && xProtectable->isProtected()) + { + AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE); + rtl::OUStringBuffer aBuffer; + if (pDoc) + { + ScTableProtection* pProtect = pDoc->GetTabProtection(static_cast(nTable)); + if (pProtect) + SvXMLUnitConverter::encodeBase64(aBuffer, pProtect->getPasswordHash(PASSHASH_OOO)); + } + 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(nTable))) + AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT, XML_FALSE); + SvXMLElementExport aElemT(*this, sElemTab, sal_True, sal_True); + CheckAttrList(); + WriteTableSource(); + WriteScenario(); + uno::Reference 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()) + { + GetShapeExport()->seekShapes(uno::Reference(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(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 ((aPrevCell.aCellAddress.Row == aCell.aCellAddress.Row) && - (aPrevCell.aCellAddress.Column + nEqualCells + 1 == aCell.aCellAddress.Column)) + 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); } } diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx index b71886c1871e..cefc245871b7 100644 --- a/sc/source/filter/xml/xmlexprt.hxx +++ b/sc/source/filter/xml/xmlexprt.hxx @@ -113,6 +113,7 @@ class ScXMLExport : public SvXMLExport rtl::OUString sExternalRefTabStyleName; rtl::OUString sAttrName; rtl::OUString sAttrStyleName; + rtl::OUString sAttrTabColor; rtl::OUString sAttrColumnsRepeated; rtl::OUString sAttrFormula; rtl::OUString sAttrValueType; diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index babccf9a7053..4678d6d246bc 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -772,6 +772,7 @@ const SfxItemPropertySet* lcl_GetSheetPropertySet() {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference*)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_UNO_TABCOLOR), SC_WID_UNO_TABCOLOR, &getCppuType((sal_Int32*)0), 0, 0 }, {0,0,0,0,0,0} }; static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl ); @@ -8608,6 +8609,10 @@ 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 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); } -- cgit From 2ccb52ccae23433c543a9df24e04fae962151229 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 19:44:34 -0500 Subject: calctabcolor: Import tab colors from ods. --- sc/source/filter/xml/xmlimprt.cxx | 1 + sc/source/filter/xml/xmlimprt.hxx | 3 ++- sc/source/filter/xml/xmlsubti.cxx | 37 +++++++++++++++++++++++++------------ sc/source/filter/xml/xmlsubti.hxx | 2 +- sc/source/filter/xml/xmltabi.cxx | 8 +++++++- sc/source/ui/unoobj/cellsuno.cxx | 9 +++++++++ 6 files changed, 45 insertions(+), 15 deletions(-) diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index f2fe367a2c64..96adfab4cf29 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -707,6 +707,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableAttrTokenMap() { 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_TAB_COLOR, XML_TOK_TABLE_TAB_COLOR }, XML_TOKEN_MAP_END }; diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index c110c70f72e2..13b4894503cb 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -203,7 +203,8 @@ enum ScXMLTableAttrTokens XML_TOK_TABLE_PROTECTION, XML_TOK_TABLE_PRINT_RANGES, XML_TOK_TABLE_PASSWORD, - XML_TOK_TABLE_PRINT + XML_TOK_TABLE_PRINT, + XML_TOK_TABLE_TAB_COLOR }; enum ScXMLTableScenarioAttrTokens diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx index 0f980c4a9608..93b35d10e8aa 100644 --- a/sc/source/filter/xml/xmlsubti.cxx +++ b/sc/source/filter/xml/xmlsubti.cxx @@ -40,6 +40,7 @@ #include "document.hxx" #include "markdata.hxx" #include "XMLConverter.hxx" +#include "unonames.hxx" #include "docuno.hxx" #include "cellsuno.hxx" #include "XMLStylesImportHelper.hxx" @@ -64,6 +65,10 @@ #include +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; using ::std::auto_ptr; //------------------------------------------------------------------ @@ -176,7 +181,7 @@ ScMyTables::~ScMyTables() } void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& sStyleName, - const sal_Bool bTempProtection, const rtl::OUString& sTempPassword) + const sal_Bool bTempProtection, const rtl::OUString& sTempPassword, sal_Int32 nTabColor) { if (rImport.GetModel().is()) { @@ -251,19 +256,19 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& } rImport.SetTableStyle(sStyleName); - if ( sStyleName.getLength() ) + Reference xProperties(xCurrentSheet, UNO_QUERY); + if (xProperties.is()) { - // #i57869# All table style properties for all sheets are now applied here, - // before importing the contents. - // This is needed for the background color. - // Sheet visibility has special handling in ScDocFunc::SetTableVisible to - // allow hiding the first sheet. - // RTL layout is only remembered, not actually applied, so the shapes can - // be loaded before mirroring. - - uno::Reference xProperties(xCurrentSheet, uno::UNO_QUERY); - if (xProperties.is()) + if ( sStyleName.getLength() ) { + // #i57869# All table style properties for all sheets are now applied here, + // before importing the contents. + // This is needed for the background color. + // Sheet visibility has special handling in ScDocFunc::SetTableVisible to + // allow hiding the first sheet. + // RTL layout is only remembered, not actually applied, so the shapes can + // be loaded before mirroring. + XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rImport.GetAutoStyles(); if (pStyles) { @@ -278,6 +283,14 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& } } } + + if (static_cast(nTabColor) != COL_AUTO) + { + // Set tab color. + Any any; + any <<= nTabColor; + xProperties->setPropertyValue(OUString::createFromAscii(SC_UNO_TABCOLOR), any); + } } } diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx index c5a16e2c3ef4..a4800e2977db 100644 --- a/sc/source/filter/xml/xmlsubti.hxx +++ b/sc/source/filter/xml/xmlsubti.hxx @@ -147,7 +147,7 @@ public: ScMyTables(ScXMLImport& rImport); ~ScMyTables(); void NewSheet(const rtl::OUString& sTableName, const rtl::OUString& sStyleName, - const sal_Bool bProtection, const rtl::OUString& sPassword); + const sal_Bool bProtection, const rtl::OUString& sPassword, sal_Int32 nTabColor); void AddRow(); void SetRowStyle(const rtl::OUString& rCellStyleName); void AddColumn(sal_Bool bIsCovered); diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx index 8ea9701ecd32..48c3b5175f88 100644 --- a/sc/source/filter/xml/xmltabi.cxx +++ b/sc/source/filter/xml/xmltabi.cxx @@ -52,6 +52,8 @@ #include "externalrefmgr.hxx" #include "sheetdata.hxx" +#include "tools/color.hxx" + #include #include #include @@ -161,6 +163,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, rtl::OUString sName; rtl::OUString sStyleName; rtl::OUString sPassword; + sal_Int32 nTabColor = static_cast(COL_AUTO); sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAttrTokenMap(); for( sal_Int16 i=0; i < nAttrCount; ++i ) @@ -194,6 +197,9 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, bPrintEntireSheet = sal_False; } break; + case XML_TOK_TABLE_TAB_COLOR: + nTabColor = sValue.toInt32(); + break; } } @@ -214,7 +220,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, else { // This is a regular table. - GetScImport().GetTables().NewSheet(sName, sStyleName, bProtection, sPassword); + GetScImport().GetTables().NewSheet(sName, sStyleName, bProtection, sPassword, nTabColor); } } else diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 4678d6d246bc..ed20d3e33a79 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -8471,6 +8471,15 @@ 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_TABCOLOR ) + { + sal_Int32 nColor; + if (aValue >>= nColor) + { + if (static_cast(nColor) != COL_AUTO) + pDoc->SetTabBgColor(nTab, Color(static_cast(nColor))); + } + } else ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID } -- cgit From 92d0c12c4a0bfdf06d98eae121b69a82802b43e3 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 20:31:40 -0500 Subject: calctabcolor: Changing a tab color should set the stream invalid, in order to save the tab color attribute to the sheet during export. --- sc/source/core/data/table1.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index eca154bb2632..b0c09dbafd38 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -286,7 +286,13 @@ const Color& ScTable::GetTabBgColor() const void ScTable::SetTabBgColor(const Color& rColor) { - aTabBgColor = rColor; + if (aTabBgColor != rColor) + { + // The tab color has changed. Set this table 'modified'. + aTabBgColor = rColor; + if (IsStreamValid()) + SetStreamValid(false); + } } void ScTable::SetScenario( BOOL bFlag ) -- cgit From 4919363903eff9c4dedca22a2c087a7808b3c027 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 21:59:44 -0500 Subject: calctabcolor: Tab color is an attribute for extended ODF 1.2. Treat it as such. --- sc/source/filter/xml/xmlexprt.cxx | 24 ++++++++++++++---------- sc/source/filter/xml/xmlimprt.cxx | 15 ++++++++------- sc/source/filter/xml/xmlimprt.hxx | 3 ++- sc/source/filter/xml/xmltabi.cxx | 1 + 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 6bb252bc546d..349520ef7380 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -532,7 +532,7 @@ ScXMLExport::ScXMLExport( sAttrName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NAME)); sAttrStyleName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME)); - sAttrTabColor = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TAB_COLOR)); + sAttrTabColor = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE_EXT, GetXMLToken(XML_TAB_COLOR)); sAttrColumnsRepeated = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NUMBER_COLUMNS_REPEATED)); sAttrFormula = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_FORMULA)); sAttrStringValue = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_STRING_VALUE)); @@ -1725,17 +1725,21 @@ void ScXMLExport::_ExportContent() AddAttribute(sAttrName, sOUTableName); AddAttribute(sAttrStyleName, aTableStyles[nTable]); - uno::Reference xPropSet(xTable, UNO_QUERY); - if (xPropSet.is()) + if (getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST) { - // Tab color for this table, if exists. - uno::Any any; - any = xPropSet->getPropertyValue(OUString::createFromAscii(SC_UNO_TABCOLOR)); - sal_Int32 nColor; - if (any >>= nColor) + // Save only for the extended ODF 1.2 and beyond. + uno::Reference xPropSet(xTable, UNO_QUERY); + if (xPropSet.is()) { - if (static_cast(nColor) != COL_AUTO) - AddAttribute(sAttrTabColor, OUString::valueOf(nColor)); + // Tab color for this table, if exists. + uno::Any any; + any = xPropSet->getPropertyValue(OUString::createFromAscii(SC_UNO_TABCOLOR)); + sal_Int32 nColor; + if (any >>= nColor) + { + if (static_cast(nColor) != COL_AUTO) + AddAttribute(sAttrTabColor, OUString::valueOf(nColor)); + } } } diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 96adfab4cf29..7a436ec58446 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -701,13 +701,14 @@ 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_TAB_COLOR, XML_TOK_TABLE_TAB_COLOR }, + { 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_TAB_COLOR, XML_TOK_TABLE_TAB_COLOR }, + { XML_NAMESPACE_TABLE_EXT, XML_TAB_COLOR, XML_TOK_TABLE_TAB_COLOR_EXT }, XML_TOKEN_MAP_END }; diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 13b4894503cb..229c6cd2d37c 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -204,7 +204,8 @@ enum ScXMLTableAttrTokens XML_TOK_TABLE_PRINT_RANGES, XML_TOK_TABLE_PASSWORD, XML_TOK_TABLE_PRINT, - XML_TOK_TABLE_TAB_COLOR + XML_TOK_TABLE_TAB_COLOR, + XML_TOK_TABLE_TAB_COLOR_EXT, }; enum ScXMLTableScenarioAttrTokens diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx index 48c3b5175f88..d2af3ee3288e 100644 --- a/sc/source/filter/xml/xmltabi.cxx +++ b/sc/source/filter/xml/xmltabi.cxx @@ -198,6 +198,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, } break; case XML_TOK_TABLE_TAB_COLOR: + case XML_TOK_TABLE_TAB_COLOR_EXT: nTabColor = sValue.toInt32(); break; } -- cgit From 6db6969532e2e4761d7ec1c1486983d6ed23192d Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 22:45:22 -0500 Subject: calctabcolor: Reworked Excel import/export to get them to work. --- sc/inc/document.hxx | 6 +++--- sc/inc/scextopt.hxx | 2 -- sc/source/filter/excel/xeview.cxx | 14 +++++++------- sc/source/filter/excel/xiview.cxx | 2 +- sc/source/ui/view/scextopt.cxx | 3 +-- sc/source/ui/view/viewdata.cxx | 6 ------ 6 files changed, 12 insertions(+), 21 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index b3591e9ac03f..39fe74b30669 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -588,9 +588,9 @@ public: Color& rColor, USHORT& rFlags ) const; SC_DLLPUBLIC void SetScenarioData( SCTAB nTab, const String& rComment, const Color& rColor, USHORT nFlags ); - Color GetTabBgColor( SCTAB nTab ) const; - void SetTabBgColor( SCTAB nTab, const Color& rColor ); - bool IsDefaultTabBgColor( SCTAB nTab ) const; + 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/scextopt.hxx b/sc/inc/scextopt.hxx index be774ab69c66..fdf05430cc69 100644 --- a/sc/inc/scextopt.hxx +++ b/sc/inc/scextopt.hxx @@ -80,8 +80,6 @@ struct ScExtTabSettings bool mbSelected; /// true = Sheet is selected. bool mbFrozenPanes; /// true = Frozen panes; false = Normal splits. bool mbPageMode; /// true = Pagebreak mode; false = Normal view mode. - Color maTabBgColor; /// Tab Bg Color - bool IsDefaultTabBgColor() const { return maTabBgColor == Color(COL_AUTO) ? TRUE : FALSE; }; explicit ScExtTabSettings(); }; diff --git a/sc/source/filter/excel/xeview.cxx b/sc/source/filter/excel/xeview.cxx index 7e06ff9cf412..4426a9f54590 100644 --- a/sc/source/filter/excel/xeview.cxx +++ b/sc/source/filter/excel/xeview.cxx @@ -397,14 +397,14 @@ XclExpTabViewSettings::XclExpTabViewSettings( const XclExpRoot& rRoot, SCTAB nSc maData.mnNormalZoom = lclGetXclZoom( rTabSett.mnNormalZoom, EXC_WIN2_NORMALZOOM_DEF ); maData.mnPageZoom = lclGetXclZoom( rTabSett.mnPageZoom, EXC_WIN2_PAGEZOOM_DEF ); maData.mnCurrentZoom = maData.mbPageMode ? maData.mnPageZoom : maData.mnNormalZoom; + } - // Tab Bg Color - if ( GetBiff() == EXC_BIFF8 && !rTabSett.IsDefaultTabBgColor() ) - { - XclExpPalette& rPal = GetPalette(); - maData.maTabBgColor = rTabSett.maTabBgColor; - maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG ); - } + // 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 ); } } diff --git a/sc/source/filter/excel/xiview.cxx b/sc/source/filter/excel/xiview.cxx index fbd72d02e9f8..dd005b8c5567 100644 --- a/sc/source/filter/excel/xiview.cxx +++ b/sc/source/filter/excel/xiview.cxx @@ -300,7 +300,7 @@ void XclImpTabViewSettings::Finalize() // *** set tab bg color if ( !maData.IsDefaultTabBgColor() ) - rTabSett.maTabBgColor = maData.maTabBgColor; + rDoc.SetTabBgColor(nScTab, maData.maTabBgColor); } // ============================================================================ diff --git a/sc/source/ui/view/scextopt.cxx b/sc/source/ui/view/scextopt.cxx index bac31b006258..e6b4a3d0c20e 100644 --- a/sc/source/ui/view/scextopt.cxx +++ b/sc/source/ui/view/scextopt.cxx @@ -61,8 +61,7 @@ ScExtTabSettings::ScExtTabSettings() : mnPageZoom( 0 ), mbSelected( false ), mbFrozenPanes( false ), - mbPageMode( false ), - maTabBgColor( COL_AUTO) + mbPageMode( false ) { } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 2ee2e8771805..28812cc635d9 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2687,12 +2687,6 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) update map modes that are needed to draw text correctly. */ SetPagebreakMode( rTabSett.mbPageMode ); } - - // Tab Bg Color - if( !rTabSett.IsDefaultTabBgColor() ) - { -// rViewTab.aTabBgColor = rTabSett.maTabBgColor; - } } } -- cgit From 3aeb34649fb15f829095496ae22f3167cb10b093 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 23 Feb 2010 12:16:23 -0500 Subject: calctabcolor: Switch to using style:table-properties to store the tab color, as discussed on the ODF TC's mailing list. --- sc/source/filter/xml/xmlexprt.cxx | 19 ------------------- sc/source/filter/xml/xmlexprt.hxx | 1 - sc/source/filter/xml/xmlimprt.cxx | 2 -- sc/source/filter/xml/xmlimprt.hxx | 4 +--- sc/source/filter/xml/xmlstyle.cxx | 3 +++ sc/source/filter/xml/xmlsubti.cxx | 37 ++++++++++++------------------------- sc/source/filter/xml/xmlsubti.hxx | 2 +- sc/source/filter/xml/xmltabi.cxx | 9 +-------- 8 files changed, 18 insertions(+), 59 deletions(-) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 349520ef7380..ca286a980f96 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -532,7 +532,6 @@ ScXMLExport::ScXMLExport( sAttrName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NAME)); sAttrStyleName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME)); - sAttrTabColor = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE_EXT, GetXMLToken(XML_TAB_COLOR)); sAttrColumnsRepeated = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NUMBER_COLUMNS_REPEATED)); sAttrFormula = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_FORMULA)); sAttrStringValue = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_STRING_VALUE)); @@ -1725,24 +1724,6 @@ void ScXMLExport::_ExportContent() AddAttribute(sAttrName, sOUTableName); AddAttribute(sAttrStyleName, aTableStyles[nTable]); - if (getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST) - { - // Save only for the extended ODF 1.2 and beyond. - uno::Reference xPropSet(xTable, UNO_QUERY); - if (xPropSet.is()) - { - // Tab color for this table, if exists. - uno::Any any; - any = xPropSet->getPropertyValue(OUString::createFromAscii(SC_UNO_TABCOLOR)); - sal_Int32 nColor; - if (any >>= nColor) - { - if (static_cast(nColor) != COL_AUTO) - AddAttribute(sAttrTabColor, OUString::valueOf(nColor)); - } - } - } - uno::Reference xProtectable (xTable, uno::UNO_QUERY); if (xProtectable.is() && xProtectable->isProtected()) { diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx index cefc245871b7..b71886c1871e 100644 --- a/sc/source/filter/xml/xmlexprt.hxx +++ b/sc/source/filter/xml/xmlexprt.hxx @@ -113,7 +113,6 @@ class ScXMLExport : public SvXMLExport rtl::OUString sExternalRefTabStyleName; rtl::OUString sAttrName; rtl::OUString sAttrStyleName; - rtl::OUString sAttrTabColor; rtl::OUString sAttrColumnsRepeated; rtl::OUString sAttrFormula; rtl::OUString sAttrValueType; diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 7a436ec58446..b7c4a8f395d4 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -707,8 +707,6 @@ const SvXMLTokenMap& ScXMLImport::GetTableAttrTokenMap() { 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_TAB_COLOR, XML_TOK_TABLE_TAB_COLOR }, - { XML_NAMESPACE_TABLE_EXT, XML_TAB_COLOR, XML_TOK_TABLE_TAB_COLOR_EXT }, XML_TOKEN_MAP_END }; diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 229c6cd2d37c..c110c70f72e2 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -203,9 +203,7 @@ enum ScXMLTableAttrTokens XML_TOK_TABLE_PROTECTION, XML_TOK_TABLE_PRINT_RANGES, XML_TOK_TABLE_PASSWORD, - XML_TOK_TABLE_PRINT, - XML_TOK_TABLE_TAB_COLOR, - XML_TOK_TABLE_TAB_COLOR_EXT, + XML_TOK_TABLE_PRINT }; enum ScXMLTableScenarioAttrTokens diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx index 365d57a53571..43ba5c168577 100644 --- a/sc/source/filter/xml/xmlstyle.cxx +++ b/sc/source/filter/xml/xmlstyle.cxx @@ -69,6 +69,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[] = @@ -164,6 +165,7 @@ 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_EXT( "TabColor", XML_NAMESPACE_TABLE_EXT, XML_TAB_COLOR, XML_TYPE_PROP_TABLE|XML_TYPE_COLORAUTO, 0 ), MAP_END() }; @@ -172,6 +174,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/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx index 93b35d10e8aa..0f980c4a9608 100644 --- a/sc/source/filter/xml/xmlsubti.cxx +++ b/sc/source/filter/xml/xmlsubti.cxx @@ -40,7 +40,6 @@ #include "document.hxx" #include "markdata.hxx" #include "XMLConverter.hxx" -#include "unonames.hxx" #include "docuno.hxx" #include "cellsuno.hxx" #include "XMLStylesImportHelper.hxx" @@ -65,10 +64,6 @@ #include -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Any; -using ::rtl::OUString; using ::std::auto_ptr; //------------------------------------------------------------------ @@ -181,7 +176,7 @@ ScMyTables::~ScMyTables() } void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& sStyleName, - const sal_Bool bTempProtection, const rtl::OUString& sTempPassword, sal_Int32 nTabColor) + const sal_Bool bTempProtection, const rtl::OUString& sTempPassword) { if (rImport.GetModel().is()) { @@ -256,19 +251,19 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& } rImport.SetTableStyle(sStyleName); - Reference xProperties(xCurrentSheet, UNO_QUERY); - if (xProperties.is()) + if ( sStyleName.getLength() ) { - if ( sStyleName.getLength() ) + // #i57869# All table style properties for all sheets are now applied here, + // before importing the contents. + // This is needed for the background color. + // Sheet visibility has special handling in ScDocFunc::SetTableVisible to + // allow hiding the first sheet. + // RTL layout is only remembered, not actually applied, so the shapes can + // be loaded before mirroring. + + uno::Reference xProperties(xCurrentSheet, uno::UNO_QUERY); + if (xProperties.is()) { - // #i57869# All table style properties for all sheets are now applied here, - // before importing the contents. - // This is needed for the background color. - // Sheet visibility has special handling in ScDocFunc::SetTableVisible to - // allow hiding the first sheet. - // RTL layout is only remembered, not actually applied, so the shapes can - // be loaded before mirroring. - XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rImport.GetAutoStyles(); if (pStyles) { @@ -283,14 +278,6 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& } } } - - if (static_cast(nTabColor) != COL_AUTO) - { - // Set tab color. - Any any; - any <<= nTabColor; - xProperties->setPropertyValue(OUString::createFromAscii(SC_UNO_TABCOLOR), any); - } } } diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx index a4800e2977db..c5a16e2c3ef4 100644 --- a/sc/source/filter/xml/xmlsubti.hxx +++ b/sc/source/filter/xml/xmlsubti.hxx @@ -147,7 +147,7 @@ public: ScMyTables(ScXMLImport& rImport); ~ScMyTables(); void NewSheet(const rtl::OUString& sTableName, const rtl::OUString& sStyleName, - const sal_Bool bProtection, const rtl::OUString& sPassword, sal_Int32 nTabColor); + const sal_Bool bProtection, const rtl::OUString& sPassword); void AddRow(); void SetRowStyle(const rtl::OUString& rCellStyleName); void AddColumn(sal_Bool bIsCovered); diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx index d2af3ee3288e..8ea9701ecd32 100644 --- a/sc/source/filter/xml/xmltabi.cxx +++ b/sc/source/filter/xml/xmltabi.cxx @@ -52,8 +52,6 @@ #include "externalrefmgr.hxx" #include "sheetdata.hxx" -#include "tools/color.hxx" - #include #include #include @@ -163,7 +161,6 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, rtl::OUString sName; rtl::OUString sStyleName; rtl::OUString sPassword; - sal_Int32 nTabColor = static_cast(COL_AUTO); sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAttrTokenMap(); for( sal_Int16 i=0; i < nAttrCount; ++i ) @@ -197,10 +194,6 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, bPrintEntireSheet = sal_False; } break; - case XML_TOK_TABLE_TAB_COLOR: - case XML_TOK_TABLE_TAB_COLOR_EXT: - nTabColor = sValue.toInt32(); - break; } } @@ -221,7 +214,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport, else { // This is a regular table. - GetScImport().GetTables().NewSheet(sName, sStyleName, bProtection, sPassword, nTabColor); + GetScImport().GetTables().NewSheet(sName, sStyleName, bProtection, sPassword); } } else -- cgit From e1f75279ee368b62d528b63ce0085453ca65768a Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 23 Feb 2010 15:33:07 -0500 Subject: calctabcolor: Reduce indent levels by early bailout. --- sc/source/filter/xml/xmlexprt.cxx | 857 +++++++++++++++++++------------------- 1 file changed, 430 insertions(+), 427 deletions(-) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index ca286a980f96..6c969e36a46a 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2152,498 +2152,501 @@ uno::Any lcl_GetEnumerated( uno::Reference xEnumA void ScXMLExport::_ExportAutoStyles() { - if (GetModel().is()) + if (!GetModel().is()) + // no model to export. + return; + + uno::Reference xSpreadDoc( GetModel(), uno::UNO_QUERY ); + if (!xSpreadDoc.is()) + // no spreadsheet document to export. + return; + + uno::Reference xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY ); + if (!xIndex.is()) + // no sheets to export. + return; + + if (getExportFlags() & EXPORT_CONTENT) { - uno::Reference 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 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; nTabIsStreamValid(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; nTabIsStreamValid(nTab)) - { - ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab ); - ScBaseCell* pCell = aIter.GetFirst(); - while (pCell) - { - if (pCell->GetCellType() == CELLTYPE_FORMULA) - static_cast(pCell)->IsValue(); // interpret if dirty - pCell = aIter.GetNext(); - } - } + if (pCell->GetCellType() == CELLTYPE_FORMULA) + static_cast(pCell)->IsValue(); // interpret if dirty + pCell = aIter.GetNext(); + } + } - // stored cell styles - const std::vector& rCellEntries = pSheetData->GetCellStyles(); - std::vector::const_iterator aCellIter = rCellEntries.begin(); - std::vector::const_iterator aCellEnd = rCellEntries.end(); - while (aCellIter != aCellEnd) - { - ScAddress aPos = aCellIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); - if (bCopySheet) - { - uno::Reference xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference xProperties( - xTable->getCellByPosition( aPos.Col(), aPos.Row() ), uno::UNO_QUERY ); + // stored cell styles + const std::vector& rCellEntries = pSheetData->GetCellStyles(); + std::vector::const_iterator aCellIter = rCellEntries.begin(); + std::vector::const_iterator aCellEnd = rCellEntries.end(); + while (aCellIter != aCellEnd) + { + ScAddress aPos = aCellIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + uno::Reference xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference 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& rColumnEntries = pSheetData->GetColumnStyles(); - std::vector::const_iterator aColumnIter = rColumnEntries.begin(); - std::vector::const_iterator aColumnEnd = rColumnEntries.end(); - while (aColumnIter != aColumnEnd) - { - ScAddress aPos = aColumnIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); - if (bCopySheet) - { - uno::Reference xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference xTableColumns(xColumnRowRange->getColumns()); - uno::Reference xColumnProperties(xTableColumns->getByIndex( aPos.Col() ), uno::UNO_QUERY); + // stored column styles + const std::vector& rColumnEntries = pSheetData->GetColumnStyles(); + std::vector::const_iterator aColumnIter = rColumnEntries.begin(); + std::vector::const_iterator aColumnEnd = rColumnEntries.end(); + while (aColumnIter != aColumnEnd) + { + ScAddress aPos = aColumnIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + uno::Reference xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference xTableColumns(xColumnRowRange->getColumns()); + uno::Reference 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& rRowEntries = pSheetData->GetRowStyles(); - std::vector::const_iterator aRowIter = rRowEntries.begin(); - std::vector::const_iterator aRowEnd = rRowEntries.end(); - while (aRowIter != aRowEnd) - { - ScAddress aPos = aRowIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); - if (bCopySheet) - { - uno::Reference xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference xTableRows(xColumnRowRange->getRows()); - uno::Reference xRowProperties(xTableRows->getByIndex( aPos.Row() ), uno::UNO_QUERY); + // stored row styles + const std::vector& rRowEntries = pSheetData->GetRowStyles(); + std::vector::const_iterator aRowIter = rRowEntries.begin(); + std::vector::const_iterator aRowEnd = rRowEntries.end(); + while (aRowIter != aRowEnd) + { + ScAddress aPos = aRowIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + uno::Reference xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference xTableRows(xColumnRowRange->getRows()); + uno::Reference 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& rTableEntries = pSheetData->GetTableStyles(); - std::vector::const_iterator aTableIter = rTableEntries.begin(); - std::vector::const_iterator aTableEnd = rTableEntries.end(); - while (aTableIter != aTableEnd) - { - ScAddress aPos = aTableIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); - if (bCopySheet) - { - //! separate method AddStyleFromTable needed? - uno::Reference xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY); - if (xTableProperties.is()) - { - std::vector 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& rTableEntries = pSheetData->GetTableStyles(); + std::vector::const_iterator aTableIter = rTableEntries.begin(); + std::vector::const_iterator aTableEnd = rTableEntries.end(); + while (aTableIter != aTableEnd) + { + ScAddress aPos = aTableIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + //! separate method AddStyleFromTable needed? + uno::Reference xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY); + if (xTableProperties.is()) + { + std::vector 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 xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this ); + GetShapeExport(); // make sure the graphics styles family is added - UniReference xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this ); - GetShapeExport(); // make sure the graphics styles family is added + const std::vector& rNoteEntries = pSheetData->GetNoteStyles(); + std::vector::const_iterator aNoteIter = rNoteEntries.begin(); + std::vector::const_iterator aNoteEnd = rNoteEntries.end(); + while (aNoteIter != aNoteEnd) + { + ScAddress aPos = aNoteIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + //! separate method AddStyleFromNote needed? - const std::vector& rNoteEntries = pSheetData->GetNoteStyles(); - std::vector::const_iterator aNoteIter = rNoteEntries.begin(); - std::vector::const_iterator aNoteEnd = rNoteEntries.end(); - while (aNoteIter != aNoteEnd) + 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 xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY ); + if (xShapeProperties.is()) { - ScAddress aPos = aNoteIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast(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 xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY ); - if (xShapeProperties.is()) - { - if ( aNoteIter->maStyleName.getLength() ) - { - std::vector 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 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 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 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 xParaPropMapper = XMLTextParagraphExport::CreateParaExtPropMapper( *this ); - UniReference xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper(); + //UniReference xParaPropMapper = XMLTextParagraphExport::CreateParaExtPropMapper( *this ); + UniReference xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper(); - const std::vector& rNoteParaEntries = pSheetData->GetNoteParaStyles(); - std::vector::const_iterator aNoteParaIter = rNoteParaEntries.begin(); - std::vector::const_iterator aNoteParaEnd = rNoteParaEntries.end(); - while (aNoteParaIter != aNoteParaEnd) + const std::vector& rNoteParaEntries = pSheetData->GetNoteParaStyles(); + std::vector::const_iterator aNoteParaIter = rNoteParaEntries.begin(); + std::vector::const_iterator aNoteParaEnd = rNoteParaEntries.end(); + while (aNoteParaIter != aNoteParaEnd) + { + ScAddress aPos = aNoteParaIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + ScPostIt* pNote = pDoc->GetNote( aPos ); + DBG_ASSERT( pNote, "note not found" ); + if (pNote) + { + SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); + uno::Reference xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); + uno::Reference 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(nTable) ); - if (bCopySheet) - { - ScPostIt* pNote = pDoc->GetNote( aPos ); - DBG_ASSERT( pNote, "note not found" ); - if (pNote) - { - SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); - uno::Reference xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); - uno::Reference xParaProp( - lcl_GetEnumerated( xCellText, aNoteParaIter->maSelection.nStartPara ), uno::UNO_QUERY ); - if ( xParaProp.is() ) - { - std::vector 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 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 xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); + UniReference xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); - const std::vector& rNoteTextEntries = pSheetData->GetNoteTextStyles(); - std::vector::const_iterator aNoteTextIter = rNoteTextEntries.begin(); - std::vector::const_iterator aNoteTextEnd = rNoteTextEntries.end(); - while (aNoteTextIter != aNoteTextEnd) + const std::vector& rNoteTextEntries = pSheetData->GetNoteTextStyles(); + std::vector::const_iterator aNoteTextIter = rNoteTextEntries.begin(); + std::vector::const_iterator aNoteTextEnd = rNoteTextEntries.end(); + while (aNoteTextIter != aNoteTextEnd) + { + ScAddress aPos = aNoteTextIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + ScPostIt* pNote = pDoc->GetNote( aPos ); + DBG_ASSERT( pNote, "note not found" ); + if (pNote) + { + SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); + uno::Reference xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); + uno::Reference 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(nTable) ); - if (bCopySheet) - { - ScPostIt* pNote = pDoc->GetNote( aPos ); - DBG_ASSERT( pNote, "note not found" ); - if (pNote) - { - SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos ); - uno::Reference xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY); - uno::Reference xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY); - ScDrawTextCursor* pCursor = ScDrawTextCursor::getImplementation( xCursorProp ); - if (pCursor) - { - pCursor->SetSelection( aNoteTextIter->maSelection ); + pCursor->SetSelection( aNoteTextIter->maSelection ); - std::vector 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 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 xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); + //UniReference xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this ); - const std::vector& rTextEntries = pSheetData->GetTextStyles(); - std::vector::const_iterator aTextIter = rTextEntries.begin(); - std::vector::const_iterator aTextEnd = rTextEntries.end(); - while (aTextIter != aTextEnd) - { - ScAddress aPos = aTextIter->maCellPos; - sal_Int32 nTable = aPos.Tab(); - bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); - if (bCopySheet) - { - //! separate method AddStyleFromText needed? - //! cache sheet object - - uno::Reference xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); - uno::Reference xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY); - uno::Reference xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY); - ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp ); - if (pCursor) - { - pCursor->SetSelection( aTextIter->maSelection ); + const std::vector& rTextEntries = pSheetData->GetTextStyles(); + std::vector::const_iterator aTextIter = rTextEntries.begin(); + std::vector::const_iterator aTextEnd = rTextEntries.end(); + while (aTextIter != aTextEnd) + { + ScAddress aPos = aTextIter->maCellPos; + sal_Int32 nTable = aPos.Tab(); + bool bCopySheet = pDoc->IsStreamValid( static_cast(nTable) ); + if (bCopySheet) + { + //! separate method AddStyleFromText needed? + //! cache sheet object + + uno::Reference xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY); + uno::Reference xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY); + uno::Reference xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY); + ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp ); + if (pCursor) + { + pCursor->SetSelection( aTextIter->maSelection ); - std::vector 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 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 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 xTableProperties(xTable, uno::UNO_QUERY); + if (xTableProperties.is()) + { + std::vector 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 xCellFormatRanges ( xTable, uno::UNO_QUERY ); + if ( xCellFormatRanges.is() ) + { + uno::Reference xFormatRangesIndex(xCellFormatRanges->getUniqueCellFormatRanges()); + if (xFormatRangesIndex.is()) { - bool bUseStream = pSheetData && pDoc && pDoc->IsStreamValid((SCTAB)nTable) && - pSheetData->HasStreamPos(nTable) && xSourceStream.is(); - - uno::Reference 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 xTableProperties(xTable, uno::UNO_QUERY); - if (xTableProperties.is()) + uno::Reference< sheet::XSheetCellRanges> xCellRanges(xFormatRangesIndex->getByIndex(nFormatRange), uno::UNO_QUERY); + if (xCellRanges.is()) { - std::vector xPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties)); - if(xPropStates.size()) + uno::Reference 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 xColumnRowRange (xTable, uno::UNO_QUERY); + if (xColumnRowRange.is()) + { + if (pDoc) + { + uno::Reference xTableColumns(xColumnRowRange->getColumns()); + if (xTableColumns.is()) { - uno::Reference xCellFormatRanges ( xTable, uno::UNO_QUERY ); - if ( xCellFormatRanges.is() ) + sal_Int32 nColumns(pDoc->GetLastChangedCol(sal::static_int_cast(nTable))); + pSharedData->SetLastColumn(nTable, nColumns); + table::CellRangeAddress aCellAddress(GetEndAddress(xTable, nTable)); + if (aCellAddress.EndColumn > nColumns) { - uno::Reference 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 xProperties (xCellRanges, uno::UNO_QUERY); - if (xProperties.is()) - { - AddStyleFromCells(xProperties, xTable, nTable, NULL); - IncrementProgressBar(sal_False); - } - } - } - } + ++nColumns; + pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn); } - uno::Reference 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 xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY); + if (xColumnProperties.is()) { - uno::Reference xTableColumns(xColumnRowRange->getColumns()); - if (xTableColumns.is()) - { - sal_Int32 nColumns(pDoc->GetLastChangedCol(sal::static_int_cast(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 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(nTable), static_cast(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 xTableRows(xColumnRowRange->getRows()); - if (xTableRows.is()) - { - sal_Int32 nRows(pDoc->GetLastChangedRow(sal::static_int_cast(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 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(nTable), static_cast(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(nTable), static_cast(nColumn)); + for (sal_Int32 i = nOld + 1; i < nColumn; ++i) + pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible); } - uno::Reference xCellRangesQuery (xTable, uno::UNO_QUERY); - if (xCellRangesQuery.is()) + if (aCellAddress.EndColumn > nColumns) { - uno::Reference xSheetCellRanges(xCellRangesQuery->queryContentCells(sheet::CellFlags::FORMATTED)); - uno::Reference 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 xTableRows(xColumnRowRange->getRows()); + if (xTableRows.is()) + { + sal_Int32 nRows(pDoc->GetLastChangedRow(sal::static_int_cast(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 xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY); + if(xRowProperties.is()) { - sal_uInt32 nCount(sal_uInt32(xSheetOperation->computeFunction(sheet::GeneralFunction_COUNT))); - uno::Reference xCellsAccess(xSheetCellRanges->getCells()); - if (xCellsAccess.is()) - { - GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCount); - uno::Reference xCells(xCellsAccess->createEnumeration()); - if (xCells.is()) - { - sal_uInt32 nCount2(0); - while (xCells->hasMoreElements()) - { - uno::Reference 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(nTable), static_cast(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( ); - - { - // 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) + uno::Reference xCellRangesQuery (xTable, uno::UNO_QUERY); + if (xCellRangesQuery.is()) { - GetPageExport()->collectAutoStyles(sal_True); - GetPageExport()->exportAutoStyles(); + uno::Reference xSheetCellRanges(xCellRangesQuery->queryContentCells(sheet::CellFlags::FORMATTED)); + uno::Reference xSheetOperation(xSheetCellRanges, uno::UNO_QUERY); + if (xSheetCellRanges.is() && xSheetOperation.is()) + { + sal_uInt32 nCount(sal_uInt32(xSheetOperation->computeFunction(sheet::GeneralFunction_COUNT))); + uno::Reference xCellsAccess(xSheetCellRanges->getCells()); + if (xCellsAccess.is()) + { + GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCount); + uno::Reference xCells(xCellsAccess->createEnumeration()); + if (xCells.is()) + { + sal_uInt32 nCount2(0); + while (xCells->hasMoreElements()) + { + uno::Reference 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); + } + } + } } + } + 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( ); + + { + // 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() -- cgit From c5066e9c3d1cef4e5a27ad6511e2cbb2154f7bc9 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 23 Feb 2010 15:34:57 -0500 Subject: calctabcolor: A blank line. --- sc/source/filter/xml/xmlexprt.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 6c969e36a46a..bdae38ce878b 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2637,6 +2637,7 @@ void ScXMLExport::_ExportAutoStyles() SvXMLElementExport aElemStyleTabProps(*this, XML_NAMESPACE_STYLE, XML_TABLE_PROPERTIES, sal_True, sal_True); } } + if (getExportFlags() & EXPORT_MASTERSTYLES) { GetPageExport()->collectAutoStyles(sal_True); -- cgit From 7bd2bb8838c4c4c2f268a289276d351503869664 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 23 Feb 2010 16:13:04 -0500 Subject: calctabcolor: Use static constant values instead of macro define for more type safety. --- sc/source/ui/view/tabcont.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index 39f2937a3e59..2dbdf9802d50 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -62,8 +62,8 @@ 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(); @@ -166,7 +166,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 ); } @@ -177,7 +177,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 ) { @@ -194,7 +194,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 ); @@ -206,7 +206,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(); @@ -392,7 +392,7 @@ void ScTabControl::ActivateView(BOOL bActivate) void ScTabControl::SetSheetLayoutRTL( BOOL bSheetRTL ) { SetEffectiveRTL( bSheetRTL ); - nSelPageIdByMouse = TABBAR_PAGE_NOTFOUND; + nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND; } @@ -628,12 +628,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() } } -- cgit -- cgit From 7e01d0af7f0192370d288d9333dac5f7d6210bb2 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 23 Feb 2010 16:50:03 -0500 Subject: calctabcolor: Fix a crasher; don't forget to check for NULL pointers. The Tab color would crash when you clicked on the Help button to launch the help window, then closed. --- sc/source/ui/app/scmod.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index b9d8682c412b..02bd491df522 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2287,6 +2287,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 >::iterator i = m_mapRefWindow.begin(); -- cgit From 55b416fdb7283c54c6d89ef1d750cca494940ef7 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 23 Feb 2010 17:21:02 -0500 Subject: calctabcolor: More tab to whitespace conversions & removed those ugly "Added by ..." markers. --- sc/inc/scmod.hxx | 2 -- sc/source/ui/app/scmod.cxx | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index bf7f8810fec3..5403d086f80f 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -290,13 +290,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 }; #define SC_MOD() ( *(ScModule**) GetAppData(SHL_CALC) ) diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 02bd491df522..8bcb84a13777 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2217,9 +2217,6 @@ IMPL_LINK( ScModule, CalcFieldValueHdl, EditFieldInfo*, pInfo ) return 0; } - - -// PB 2004-08-23 #i33095# Security Options #define SC_UNO_LOADREADONLY "LoadReadonly" // <-- +#define SC_UNO_MODIFYPASSWORDHASH "ModifyPasswordHash" // FormulaParser #define SC_UNO_COMPILEENGLISH "CompileEnglish" diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx index dd8f15359559..90f3b1ce2781 100644 --- a/sc/source/ui/unoobj/confuno.cxx +++ b/sc/source/ui/unoobj/confuno.cxx @@ -88,6 +88,7 @@ const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap() {MAP_CHAR_LEN(SC_UNO_LOADREADONLY), 0, &getBooleanCppuType(), 0, 0}, // <-- {MAP_CHAR_LEN(SC_UNO_SHAREDOC), 0, &getBooleanCppuType(), 0, 0}, + {MAP_CHAR_LEN(SC_UNO_MODIFYPASSWORDHASH), 0, &getCppuType((sal_Int32*)0), 0, 0}, {0,0,0,0,0,0} }; return aConfigPropertyMap_Impl; @@ -274,6 +275,20 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue( pDocShell->SetSharedXMLFlag( bDocShared ); } } + else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDHASH ) == 0 ) + { + sal_Int32 nHash = 0; + if ( !( aValue >>= nHash ) || nHash < 0 || nHash > SAL_MAX_UINT16 ) + throw lang::IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type INT32, representing UINT16 expected!" ) ), + uno::Reference< uno::XInterface >(), + 2 ); + + if ( !pDocShell->SetModifyPasswordHash( static_cast< sal_uInt16 >( nHash ) ) ) + throw beans::PropertyVetoException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ), + uno::Reference< uno::XInterface >() ); + } else { ScGridOptions aGridOpt(aViewOpt.GetGridOptions()); @@ -407,6 +422,8 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const rtl::OUString { ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasSharedXMLFlagSet() ); } + else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDHASH ) == 0 ) + aRet <<= static_cast< sal_Int32 >( pDocShell->GetModifyPasswordHash() ); else { const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions(); -- cgit From 897974e77d86cf351b1a24788a67fdcefd79ac0e Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 8 Apr 2010 12:17:20 +0200 Subject: tl78: #i109779# import/export password-to-modify --- sc/source/filter/excel/excdoc.cxx | 9 ++++++--- sc/source/filter/excel/impop.cxx | 8 ++++++-- sc/source/filter/excel/xeroot.cxx | 12 ------------ sc/source/filter/inc/xcl97rec.hxx | 3 ++- sc/source/filter/inc/xeroot.hxx | 1 - sc/source/filter/xcl97/xcl97rec.cxx | 9 +++++---- sc/source/ui/docshell/docsh.cxx | 2 +- 7 files changed, 20 insertions(+), 24 deletions(-) diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index a858ca093fd6..f48e9890bac8 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -200,8 +200,11 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList ) UINT16 nExcTabCount = rTabInfo.GetXclTabCount(); UINT16 nCodenames = static_cast< UINT16 >( GetExtDocOptions().GetCodeNameCount() ); - sal_uInt16 nWriteProtHash = GetWriteProtPassword(); - if( nWriteProtHash > 0 ) + SfxObjectShell* pShell = GetDocShell(); + sal_uInt16 nWriteProtHash = pShell ? pShell->GetModifyPasswordHash() : 0; + bool bRecommendReadOnly = pShell && pShell->IsLoadReadonly(); + + if( (nWriteProtHash > 0) || bRecommendReadOnly ) Add( new XclExpEmptyRecord( EXC_ID_WRITEPROT ) ); // TODO: correct codepage for BIFF5? @@ -226,7 +229,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList ) Add( new XclExpWriteAccess ); } - Add( new XclExpFileSharing( GetRoot(), nWriteProtHash ) ); + Add( new XclExpFileSharing( GetRoot(), nWriteProtHash, bRecommendReadOnly ) ); Add( new XclExpUInt16Record( EXC_ID_CODEPAGE, nCodePage ) ); if( GetBiff() == EXC_BIFF8 ) diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index 8cae8a1c3f27..01b62f72d455 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -180,10 +180,14 @@ void ImportExcel::ReadFileSharing() if( (nRecommendReadOnly != 0) || (nPasswordHash != 0) ) { if( SfxItemSet* pItemSet = GetMedium().GetItemSet() ) - { pItemSet->Put( SfxBoolItem( SID_DOC_READONLY, TRUE ) ); + + if( SfxObjectShell* pShell = GetDocShell() ) + { + if( nRecommendReadOnly != 0 ) + pShell->SetLoadReadonly( sal_True ); if( nPasswordHash != 0 ) - pItemSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, nPasswordHash ) ); + pShell->SetModifyPasswordHash( nPasswordHash ); } } } diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx index 6d5424d88971..50e07ae1f2ed 100644 --- a/sc/source/filter/excel/xeroot.cxx +++ b/sc/source/filter/excel/xeroot.cxx @@ -260,18 +260,6 @@ String XclExpRoot::GetPassword() const return String::EmptyString(); } -sal_uInt16 XclExpRoot::GetWriteProtPassword() const -{ - if( SfxItemSet* pItemSet = GetMedium().GetItemSet() ) - { - const SfxPoolItem* pItem = 0; - if( pItemSet->GetItemState( SID_MODIFYPASSWORDHASH, TRUE, &pItem ) == SFX_ITEM_SET ) - if( const SfxInt32Item* pIntItem = dynamic_cast< const SfxInt32Item* >( pItem ) ) - return static_cast< sal_uInt16 >( pIntItem->GetValue() ); - } - return 0; -} - XclExpRootData::XclExpLinkMgrRef XclExpRoot::GetLocalLinkMgrRef() const { return IsInGlobals() ? mrExpData.mxGlobLinkMgr : mrExpData.mxLocLinkMgr; diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx index 7a2a33795520..201562fa752c 100644 --- a/sc/source/filter/inc/xcl97rec.hxx +++ b/sc/source/filter/inc/xcl97rec.hxx @@ -535,7 +535,7 @@ private: class XclExpFileSharing : public XclExpRecord { public: - explicit XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash ); + explicit XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash, bool bRecommendReadOnly ); virtual void Save( XclExpStream& rStrm ); @@ -545,6 +545,7 @@ private: private: XclExpString maUserName; sal_uInt16 mnPasswordHash; + bool mbRecommendReadOnly; }; // ============================================================================ diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx index 08df490986c0..980590f9d4ff 100644 --- a/sc/source/filter/inc/xeroot.hxx +++ b/sc/source/filter/inc/xeroot.hxx @@ -159,7 +159,6 @@ public: bool IsDocumentEncrypted() const; String GetPassword() const; - sal_uInt16 GetWriteProtPassword() const; private: diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 67a295ccec8b..df6bdcbbe671 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1354,9 +1354,10 @@ void XclExpWriteAccess::WriteBody( XclExpStream& rStrm ) // ============================================================================ -XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash ) : +XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash, bool bRecommendReadOnly ) : XclExpRecord( EXC_ID_FILESHARING ), - mnPasswordHash( nPasswordHash ) + mnPasswordHash( nPasswordHash ), + mbRecommendReadOnly( bRecommendReadOnly ) { if( rRoot.GetBiff() <= EXC_BIFF5 ) maUserName.AssignByte( rRoot.GetUserName(), rRoot.GetTextEncoding(), EXC_STR_8BITLENGTH ); @@ -1366,13 +1367,13 @@ XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPassw void XclExpFileSharing::Save( XclExpStream& rStrm ) { - if( mnPasswordHash != 0 ) + if( (mnPasswordHash != 0) || mbRecommendReadOnly ) XclExpRecord::Save( rStrm ); } void XclExpFileSharing::WriteBody( XclExpStream& rStrm ) { - rStrm << sal_uInt16( 0 ) << mnPasswordHash << maUserName; + rStrm << sal_uInt16( mbRecommendReadOnly ? 1 : 0 ) << mnPasswordHash << maUserName; } // ============================================================================ diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 1b4f9b677f81..edbbc3ffdd1f 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1876,7 +1876,7 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed ) /* #115980# #i104990# If the imported document contains a medium password, determine if we can save it, otherwise ask the users whether they want to save without it. */ - if( !::sfx2::CheckMSPasswordCapabilityForExport( aFltName ) ) + if( (rMed.GetFilter()->GetFilterFlags() & SFX_FILTER_ENCRYPTION) == 0 ) { SfxItemSet* pItemSet = rMed.GetItemSet(); const SfxPoolItem* pItem = 0; -- cgit From b71e7bee59426fa5fe73f6ec85afbe6c0db7964d Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 7 May 2010 10:40:12 +0200 Subject: cws tl78: fixing windows specific build problems after merging with DEV300_m77 --- sc/source/ui/unoobj/scdetect.cxx | 0 sc/source/ui/unoobj/warnpassword.cxx | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 sc/source/ui/unoobj/scdetect.cxx mode change 100644 => 100755 sc/source/ui/unoobj/warnpassword.cxx diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx old mode 100644 new mode 100755 diff --git a/sc/source/ui/unoobj/warnpassword.cxx b/sc/source/ui/unoobj/warnpassword.cxx old mode 100644 new mode 100755 -- cgit From e767d294ce8d998c07b1b942d3460a2271f56e65 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 13 May 2010 10:12:41 -0400 Subject: calctabcolor: Removed code that was not intended. --- sc/source/ui/docshell/docsh.cxx | 42 ----------------------------------------- sc/source/ui/undo/undotab.cxx | 4 +--- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 26d534416500..821b2a6ad880 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -129,47 +129,6 @@ using namespace com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; -#include -#include -#include - -namespace { - -class StackPrinter -{ -public: - explicit StackPrinter(const char* msg) : - msMsg(msg) - { - fprintf(stdout, "%s: --begin\n", msMsg.c_str()); - mfStartTime = getTime(); - } - - ~StackPrinter() - { - double fEndTime = getTime(); - fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime-mfStartTime)); - } - - void printTime(int line) const - { - double fEndTime = getTime(); - fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime-mfStartTime)); - } - -private: - double getTime() const - { - timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec + tv.tv_usec / 1000000.0; - } - - ::std::string msMsg; - double mfStartTime; -}; - -} // STATIC DATA ----------------------------------------------------------- // Stream-Namen im Storage @@ -438,7 +397,6 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) BOOL ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor ) { - StackPrinter __stack_printer__("ScDocShell::LoadXML"); RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScDocShell::LoadXML" ); // MacroCallMode is no longer needed, state is kept in SfxObjectShell now diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index fbc39ad62da5..953af0fe0695 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 @@ -67,9 +68,6 @@ #include "drwlayer.hxx" #include "scresid.hxx" -// for set tab bg color -#include "viewdata.hxx" - extern BOOL bDrawIsInUndo; //! irgendwo als Member !!! using namespace com::sun::star; -- cgit From 6c9861ba9afd7039fb4fdbc780b4240dd850ade6 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:08:01 +0200 Subject: CWS mba33issues01: #i83367#: pass object name correctly --- sc/source/ui/unoobj/chartuno.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 201c411ea45c..3b396d508238 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -222,7 +222,7 @@ void SAL_CALL ScChartsObj::addNewByName( const rtl::OUString& aName, xObj = pDocShell->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aTmp ); if ( xObj.is() ) { - String aObjName = aNameString; // wirklich eingefuegter Name... + String aObjName = aTmp; // wirklich eingefuegter Name... // Rechteck anpassen //! Fehler/Exception, wenn leer/ungueltig ??? -- cgit From 83e811244a6dc0902137df91cf3125a67c69b1b5 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:08:55 +0200 Subject: CWS mba33issues01: #i99402#: typo RapairPackage --- sc/source/ui/unoobj/scdetect.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index cded62efa3a8..00390b081ccc 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -297,7 +297,7 @@ static BOOL lcl_IsAnyXMLFilter( const SfxFilter* pFilter ) } else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")) ) lDescriptor[nProperty].Value >>= xInteraction; - else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("RapairPackage")) ) + else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("RepairPackage")) ) lDescriptor[nProperty].Value >>= bRepairPackage; else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle")) ) nIndexOfDocumentTitle = nProperty; -- cgit From f4385ed8bf1da56c716bd4e48c5f5d739127c0d9 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 19 May 2010 14:28:33 +0200 Subject: cws tl79: #i110254# new security tap page in 'File/Properties' --- sc/source/ui/docshell/docsh.cxx | 56 +++++++++++++++++++++++++++++++++++++++++ sc/source/ui/inc/docsh.hxx | 6 +++++ 2 files changed, 62 insertions(+) mode change 100644 => 100755 sc/source/ui/docshell/docsh.cxx mode change 100644 => 100755 sc/source/ui/inc/docsh.hxx diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx old mode 100644 new mode 100755 index 821b2a6ad880..4c808764b349 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -2632,3 +2633,58 @@ sal_Bool ScDocShell::AcceptStateUpdate() const return sal_False; } //-->Added by PengYunQuan for Validity Cell Range Picker + + +void ScDocShell::SetChangeRecording( bool bActivate ) +{ + ScDocument * pDoc = GetDocument(); + DBG_ASSERT( pDoc, "ScDocument missing" ); + if (pDoc) + { + if (bActivate) + pDoc->StartChangeTracking(); + else + pDoc->EndChangeTracking(); + } +} + + +bool ScDocShell::SetProtectionPassword( const String &rNewPassword ) +{ + bool bRes = false; + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + if (pChangeTrack) + { + if (rNewPassword.Len()) + { + // when password protection is applied change tracking must always be active + SetChangeRecording( true ); + + ::com::sun::star::uno::Sequence< sal_Int8 > aProtectionHash; + SvPasswordHelper::GetHashPassword( aProtectionHash, rNewPassword ); + pChangeTrack->SetProtection( aProtectionHash ); + } + else + { + pChangeTrack->SetProtection( ::com::sun::star::uno::Sequence< sal_Int8 >() ); + } + bRes = true; + } + + return bRes; +} + + +bool ScDocShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ) +{ + bool bRes = false; + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + if (pChangeTrack && pChangeTrack->IsProtected()) + { + rPasswordHash = pChangeTrack->GetProtection(); + bRes = true; + } + return bRes; +} + + diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx old mode 100644 new mode 100755 index 09d34c661995..2c28663d107d --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -418,6 +418,12 @@ public: sal_Bool AcceptStateUpdate() const; //-->Added by PengYunQuan for Validity Cell Range Picker ScSheetSaveData* GetSheetSaveData(); + + // passwword protection for Calc (derived from SfxObjectShell) + // see also: FID_CHG_RECORD, SID_CHG_PROTECT + virtual void SetChangeRecording( bool bActivate ); + virtual bool SetProtectionPassword( const String &rPassword ); + virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); }; SO2_DECL_REF(ScDocShell) -- cgit From cbedc2f760a642cfb2c19bea504fdea940edb48a Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 21 May 2010 16:46:32 +0200 Subject: dr76: #i103453# import visual area for embedded documents --- sc/inc/scextopt.hxx | 1 - sc/source/filter/excel/impop.cxx | 67 +++++++++++++++++++--------------------- sc/source/filter/inc/imp_op.hxx | 1 + sc/source/ui/view/scextopt.cxx | 1 - 4 files changed, 32 insertions(+), 38 deletions(-) diff --git a/sc/inc/scextopt.hxx b/sc/inc/scextopt.hxx index b02df9816ef4..d7586fb8df95 100644 --- a/sc/inc/scextopt.hxx +++ b/sc/inc/scextopt.hxx @@ -38,7 +38,6 @@ /** Extended settings for the document, used in import/export filters. */ struct ScExtDocSettings { - ScRange maOleSize; /// Visible range if embedded. String maGlobCodeName; /// Global codename (VBA module name). double mfTabBarWidth; /// Width of the tabbar, relative to frame window width (0.0 ... 1.0). sal_uInt32 mnLinkCnt; /// Recursive counter for loading external documents. diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index e62f050f2351..bddd99984ada 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -122,7 +122,8 @@ ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ): ImportTyp( &rImpData.mrDoc, rImpData.meTextEnc ), XclImpRoot( rImpData ), maStrm( rStrm, GetRoot() ), - aIn( maStrm ) + aIn( maStrm ), + maScOleSize( ScAddress::INITIALIZE_INVALID ) { mnLastRefIdx = 0; nBdshtTab = 0; @@ -919,8 +920,7 @@ void ImportExcel::Olesize( void ) aXclOleSize.Read( maStrm, false ); SCTAB nScTab = GetCurrScTab(); - ScRange& rOleSize = GetExtDocOptions().GetDocSettings().maOleSize; - GetAddressConverter().ConvertRange( rOleSize, aXclOleSize, nScTab, nScTab, false ); + GetAddressConverter().ConvertRange( maScOleSize, aXclOleSize, nScTab, nScTab, false ); } @@ -1204,45 +1204,40 @@ void ImportExcel::PostDocLoad( void ) // process all drawing objects (including OLE, charts, controls; after hiding rows/columns; before visible OLE area) GetObjectManager().ConvertObjects(); - // visible area if embedded OLE - if( ScModelObj* pDocObj = GetDocModelObj() ) + // visible area (used if this document is an embedded OLE object) + if( SfxObjectShell* pDocShell = GetDocShell() ) { - if( SfxObjectShell* pEmbObj = pDocObj->GetEmbeddedObject() ) + // visible area if embedded + const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings(); + SCTAB nDisplScTab = rDocSett.mnDisplTab; + + /* #i44077# If a new OLE object is inserted from file, there is no + OLESIZE record in the Excel file. Calculate used area from file + contents (used cells and drawing objects). */ + if( !maScOleSize.IsValid() ) { - // visible area if embedded - const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings(); - SCTAB nDisplScTab = rDocSett.mnDisplTab; - - // first try if there was an OLESIZE record - ScRange aScOleSize = rDocSett.maOleSize; - - /* #i44077# If a new OLE object is inserted from file, there - is no OLESIZE record in the Excel file. Calculate used area - from file contents (used cells and drawing objects). */ - if( !aScOleSize.IsValid() ) - { - // used area of displayed sheet (cell contents) - if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) ) - aScOleSize = pTabSett->maUsedArea; - // add all valid drawing objects - ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab ); - if( aScObjArea.IsValid() ) - aScOleSize.ExtendTo( aScObjArea ); - } + // used area of displayed sheet (cell contents) + if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) ) + maScOleSize = pTabSett->maUsedArea; + // add all valid drawing objects + ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab ); + if( aScObjArea.IsValid() ) + maScOleSize.ExtendTo( aScObjArea ); + } - // valid size found - set it at the document - if( aScOleSize.IsValid() ) - { - pEmbObj->SetVisArea( GetDoc().GetMMRect( - aScOleSize.aStart.Col(), aScOleSize.aStart.Row(), - aScOleSize.aEnd.Col(), aScOleSize.aEnd.Row(), nDisplScTab ) ); - GetDoc().SetVisibleTab( nDisplScTab ); - } + // valid size found - set it at the document + if( maScOleSize.IsValid() ) + { + pDocShell->SetVisArea( GetDoc().GetMMRect( + maScOleSize.aStart.Col(), maScOleSize.aStart.Row(), + maScOleSize.aEnd.Col(), maScOleSize.aEnd.Row(), nDisplScTab ) ); + GetDoc().SetVisibleTab( nDisplScTab ); } + } - // #111099# open forms in alive mode (has no effect, if no controls in document) + // #111099# open forms in alive mode (has no effect, if no controls in document) + if( ScModelObj* pDocObj = GetDocModelObj() ) pDocObj->setPropertyValue( CREATE_OUSTRING( SC_UNO_APPLYFMDES ), uno::Any( false ) ); - } // enables extended options to be set to the view after import GetExtDocOptions().SetChanged( true ); diff --git a/sc/source/filter/inc/imp_op.hxx b/sc/source/filter/inc/imp_op.hxx index 065678d5c792..2df58173a63a 100644 --- a/sc/source/filter/inc/imp_op.hxx +++ b/sc/source/filter/inc/imp_op.hxx @@ -97,6 +97,7 @@ protected: XclImpStream& aIn; // input stream ScfUInt32Vec maSheetOffsets; + ScRange maScOleSize; /// Visible range if embedded. NameBuffer* pExtNameBuff; // ... externe Namen (Ind.-Basis=1) ExcelToSc* pFormConv; // Formel-Konverter diff --git a/sc/source/ui/view/scextopt.cxx b/sc/source/ui/view/scextopt.cxx index bead62419bb3..1faa105d2bd7 100644 --- a/sc/source/ui/view/scextopt.cxx +++ b/sc/source/ui/view/scextopt.cxx @@ -36,7 +36,6 @@ // ============================================================================ ScExtDocSettings::ScExtDocSettings() : - maOleSize( ScAddress::INITIALIZE_INVALID ), mfTabBarWidth( -1.0 ), mnLinkCnt( 0 ), mnDisplTab( 0 ) -- cgit From 584157c19d5cac970b305645e6a478c6a2af3bef Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 25 May 2010 11:45:06 +0200 Subject: cws tl79: #i110254# security tab page in 'File/Properties' --- sc/source/ui/docshell/docsh.cxx | 53 ++++++++++++++++++++++++++++++++++------ sc/source/ui/docshell/docsh4.cxx | 37 +++++++++++++--------------- sc/source/ui/inc/docsh.hxx | 6 +++++ 3 files changed, 69 insertions(+), 27 deletions(-) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 4c808764b349..ca9771904fda 100755 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2635,16 +2635,47 @@ sal_Bool ScDocShell::AcceptStateUpdate() const //-->Added by PengYunQuan for Validity Cell Range Picker +bool ScDocShell::IsChangeRecording() const +{ + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + return pChangeTrack != NULL; +} + + +bool ScDocShell::HasChangeRecordProtection() const +{ + bool bRes = false; + ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); + if (pChangeTrack) + bRes = pChangeTrack->IsProtected(); + return bRes; +} + + void ScDocShell::SetChangeRecording( bool bActivate ) { - ScDocument * pDoc = GetDocument(); - DBG_ASSERT( pDoc, "ScDocument missing" ); - if (pDoc) + bool bOldChangeRecording = IsChangeRecording(); + + if (bActivate) { - if (bActivate) - pDoc->StartChangeTracking(); - else - pDoc->EndChangeTracking(); + aDocument.StartChangeTracking(); + ScChangeViewSettings aChangeViewSet; + aChangeViewSet.SetShowChanges(TRUE); + aDocument.SetChangeViewSettings(aChangeViewSet); + } + else + { + aDocument.EndChangeTracking(); + PostPaintGridAll(); + } + + if (bOldChangeRecording != IsChangeRecording()) + { + UpdateAcceptChangesDialog(); + // Slots invalidieren + SfxBindings* pBindings = GetViewBindings(); + if (pBindings) + pBindings->InvalidateAll(FALSE); } } @@ -2655,6 +2686,8 @@ bool ScDocShell::SetProtectionPassword( const String &rNewPassword ) ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); if (pChangeTrack) { + sal_Bool bProtected = pChangeTrack->IsProtected(); + if (rNewPassword.Len()) { // when password protection is applied change tracking must always be active @@ -2669,6 +2702,12 @@ bool ScDocShell::SetProtectionPassword( const String &rNewPassword ) pChangeTrack->SetProtection( ::com::sun::star::uno::Sequence< sal_Int8 >() ); } bRes = true; + + if ( bProtected != pChangeTrack->IsProtected() ) + { + UpdateAcceptChangesDialog(); + SetDocumentModified(); + } } return bRes; diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index eb308b67271e..1fe5cc7a74ba 100755 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -665,17 +665,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) if ( bDo ) { - // update "accept changes" dialog - //! notify all views - SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if ( pViewFrm && pViewFrm->HasChildWindow(FID_CHG_ACCEPT) ) - { - SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT); - if (pChild) - { - ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); - } - } + UpdateAcceptChangesDialog(); // Slots invalidieren if (pBindings) @@ -1163,6 +1153,21 @@ void ScDocShell::Execute( SfxRequest& rReq ) } +//------------------------------------------------------------------ + +void UpdateAcceptChangesDialog() +{ + // update "accept changes" dialog + //! notify all views + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) ) + { + SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT ); + if ( pChild ) + ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); + } +} + //------------------------------------------------------------------ BOOL ScDocShell::ExecuteChangeProtectionDialog( Window* _pParent, BOOL bJustQueryIfProtected ) @@ -1218,15 +1223,7 @@ BOOL ScDocShell::ExecuteChangeProtectionDialog( Window* _pParent, BOOL bJustQuer } if ( bProtected != pChangeTrack->IsProtected() ) { - // update "accept changes" dialog - //! notify all views - SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) ) - { - SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT ); - if ( pChild ) - ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); - } + UpdateAcceptChangesDialog(); bDone = TRUE; } } diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 2c28663d107d..e4c02458ec6e 100755 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -421,11 +421,17 @@ public: // passwword protection for Calc (derived from SfxObjectShell) // see also: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const; + virtual bool HasChangeRecordProtection() const; virtual void SetChangeRecording( bool bActivate ); virtual bool SetProtectionPassword( const String &rPassword ); virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); }; + +void UpdateAcceptChangesDialog(); + + SO2_DECL_REF(ScDocShell) SO2_IMPL_REF(ScDocShell) -- cgit From 1170fd37d8fc8aac76a4440d642c90a42cf5f5e6 Mon Sep 17 00:00:00 2001 From: tono Date: Mon, 31 May 2010 21:51:32 +0900 Subject: i#111956: MinGW port fix: dependency to shared library --- sc/util/makefile.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index b7b12e07ee6a..c465a66500ad 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -174,7 +174,11 @@ SHL6LIBS= \ SHL6VERSIONMAP= scfilt.map SHL6DEF=$(MISC)$/$(SHL6TARGET).def DEF6NAME= $(SHL6TARGET) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL6DEPN=$(SHL1TARGETN) +.ELSE +SHL6DEPN=$(SHL1IMPLIBN) +.ENDIF SHL6STDLIBS= \ $(ISCLIB) \ $(BASICLIB) \ @@ -206,7 +210,11 @@ SHL8TARGET= scui$(DLLPOSTFIX) SHL8IMPLIB= scuiimp SHL8VERSIONMAP= scui.map SHL8DEF=$(MISC)$/$(SHL8TARGET).def +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL8DEPN=$(SHL1TARGETN) +.ELSE +SHL8DEPN=$(SHL1IMPLIBN) +.ENDIF DEF8NAME=$(SHL8TARGET) SHL8STDLIBS= \ @@ -317,7 +325,11 @@ SHL9STDLIBS= \ $(SVXMSFILTERLIB) \ $(FORLIB) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL9DEPN=$(SHL1TARGETN) $(SHL8TARGETN) +.ELSE +SHL9DEPN=$(SHL1IMPLIBN) $(SHL8IMPLIBN) +.ENDIF SHL9LIBS=$(SLB)$/$(TARGET_VBA).lib .IF "$(GUI)"=="UNX" || "$(GUI)"=="MAC" -- cgit From c4124e4f726cce06d98e43885fbafd8c579947b5 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 2 Jun 2010 16:27:29 +0200 Subject: calc55: #i112025# new csv import options must be at the end of the options string --- sc/source/ui/dbgui/asciiopt.cxx | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index cd1f85fb99cc..a22953ade25b 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -253,20 +253,13 @@ void ScAsciiOptions::ReadFromString( const String& rString ) eCharSet = ScGlobal::GetCharsetValue( aToken ); } - // Language - if (nCount >= 4) - { - aToken = rString.GetToken(3, ','); - eLang = static_cast(aToken.ToInt32()); - } - // // Startzeile // - if ( nCount >= 5 ) + if ( nCount >= 4 ) { - aToken = rString.GetToken(4,','); + aToken = rString.GetToken(3,','); nStartRow = aToken.ToInt32(); } @@ -274,12 +267,12 @@ void ScAsciiOptions::ReadFromString( const String& rString ) // Spalten-Infos // - if ( nCount >= 6 ) + if ( nCount >= 5 ) { delete[] pColStart; delete[] pColFormat; - aToken = rString.GetToken(5,','); + aToken = rString.GetToken(4,','); nSub = aToken.GetTokenCount('/'); nInfoCount = nSub / 2; if (nInfoCount) @@ -299,6 +292,13 @@ void ScAsciiOptions::ReadFromString( const String& rString ) } } + // Language + if (nCount >= 6) + { + aToken = rString.GetToken(5, ','); + eLang = static_cast(aToken.ToInt32()); + } + // Import quoted field as text. if (nCount >= 7) { @@ -362,10 +362,6 @@ String ScAsciiOptions::WriteToString() const aOutStr += ScGlobal::GetCharsetString( eCharSet ); aOutStr += ','; // Token-Ende - // Language - aOutStr += String::CreateFromInt32(eLang); - aOutStr += ','; - // // Startzeile // @@ -387,6 +383,13 @@ String ScAsciiOptions::WriteToString() const aOutStr += String::CreateFromInt32(pColFormat[nInfo]); } + // #i112025# the options string is used in macros and linked sheets, + // so new options must be added at the end, to remain compatible + + aOutStr += ','; + + // Language + aOutStr += String::CreateFromInt32(eLang); aOutStr += ','; // Import quoted field as text. -- cgit From b6e1fdef1f74ddc7355db66b089c56ed61aee1c4 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 3 Jun 2010 00:10:45 +0200 Subject: tl78: #i110383# password to modify support for binary types only --- sc/inc/unonames.hxx | 1 - sc/source/ui/unoobj/confuno.cxx | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 1656299c3efb..f5de35c9d033 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -610,7 +610,6 @@ // --> PB 2004-08-23 #i33095# Security Options #define SC_UNO_LOADREADONLY "LoadReadonly" // <-- -#define SC_UNO_MODIFYPASSWORDHASH "ModifyPasswordHash" // FormulaParser #define SC_UNO_COMPILEENGLISH "CompileEnglish" diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx index 90f3b1ce2781..dd8f15359559 100644 --- a/sc/source/ui/unoobj/confuno.cxx +++ b/sc/source/ui/unoobj/confuno.cxx @@ -88,7 +88,6 @@ const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap() {MAP_CHAR_LEN(SC_UNO_LOADREADONLY), 0, &getBooleanCppuType(), 0, 0}, // <-- {MAP_CHAR_LEN(SC_UNO_SHAREDOC), 0, &getBooleanCppuType(), 0, 0}, - {MAP_CHAR_LEN(SC_UNO_MODIFYPASSWORDHASH), 0, &getCppuType((sal_Int32*)0), 0, 0}, {0,0,0,0,0,0} }; return aConfigPropertyMap_Impl; @@ -275,20 +274,6 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue( pDocShell->SetSharedXMLFlag( bDocShared ); } } - else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDHASH ) == 0 ) - { - sal_Int32 nHash = 0; - if ( !( aValue >>= nHash ) || nHash < 0 || nHash > SAL_MAX_UINT16 ) - throw lang::IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type INT32, representing UINT16 expected!" ) ), - uno::Reference< uno::XInterface >(), - 2 ); - - if ( !pDocShell->SetModifyPasswordHash( static_cast< sal_uInt16 >( nHash ) ) ) - throw beans::PropertyVetoException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ), - uno::Reference< uno::XInterface >() ); - } else { ScGridOptions aGridOpt(aViewOpt.GetGridOptions()); @@ -422,8 +407,6 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const rtl::OUString { ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasSharedXMLFlagSet() ); } - else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDHASH ) == 0 ) - aRet <<= static_cast< sal_Int32 >( pDocShell->GetModifyPasswordHash() ); else { const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions(); -- cgit From 2de3371e3105daaaa457aef275dc30942beb16b4 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 3 Jun 2010 20:06:50 +0200 Subject: calc55: #i112071# property DataFieldCount is optional --- sc/source/core/data/dpoutput.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index ec384874aa69..5bbcdc5ab991 100755 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1119,9 +1119,9 @@ void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionDa Reference xPropSet(xSource, UNO_QUERY); if (xPropSet.is()) { - sal_Int32 nDataFieldCount = 0; - Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("DataFieldCount")); - if ((any >>= nDataFieldCount) && nDataFieldCount > 0) + sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet, + rtl::OUString::createFromAscii(SC_UNO_DATAFIELDCOUNT) ); + if (nDataFieldCount > 0) aResData.DataFieldIndex = (nRow - nDataStartRow) % nDataFieldCount; } @@ -1201,14 +1201,14 @@ bool ScDPOutput::GetDataResultPositionData(vector& if (!xPropSet.is()) return false; - sal_Int32 nDataFieldCount = 0; - Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("DataFieldCount")); - if (!(any >>= nDataFieldCount) || nDataFieldCount == 0) + sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet, + rtl::OUString::createFromAscii(SC_UNO_DATAFIELDCOUNT) ); + if (nDataFieldCount == 0) // No data field is present in this datapilot table. return false; bool bColGrand = bool(); - any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii(SC_UNO_COLGRAND)); + Any any = xPropSet->getPropertyValue(rtl::OUString::createFromAscii(SC_UNO_COLGRAND)); if (!(any >>= bColGrand)) return false; -- cgit From 20fd52e66f2a42c26a5b1153c1412336ecb22b61 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 4 Jun 2010 14:00:08 +0200 Subject: calc55: #i112116# width of 'E' can be different from digits --- sc/source/ui/view/output2.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 5a48d0d310d5..b69f787a19b5 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -114,6 +114,7 @@ class ScDrawStringsVars long nMaxDigitWidth; long nSignWidth; long nDotWidth; + long nExpWidth; ScBaseCell* pLastCell; ULONG nValueFormat; @@ -173,6 +174,7 @@ private: long GetMaxDigitWidth(); long GetSignWidth(); long GetDotWidth(); + long GetExpWidth(); void TextChanged(); long ConvertWidthLogicToPixel( long nWidth ) const; }; @@ -193,6 +195,7 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, BOOL bPTL) : nMaxDigitWidth( 0 ), nSignWidth( 0 ), nDotWidth( 0 ), + nExpWidth( 0 ), pLastCell ( NULL ), nValueFormat( 0 ), bLineBreak ( FALSE ), @@ -262,6 +265,7 @@ void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* nMaxDigitWidth = 0; nSignWidth = 0; nDotWidth = 0; + nExpWidth = 0; pPattern = pNew; pCondSet = pSet; @@ -417,6 +421,7 @@ void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxIt nMaxDigitWidth = 0; nSignWidth = 0; nDotWidth = 0; + nExpWidth = 0; // wird gerufen, wenn sich die Font-Variablen nicht aendern (!StringDiffer) pPattern = pNew; @@ -547,7 +552,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) // Failed to get output string. Bail out. return; - sal_uInt8 nSignCount = 0, nDecimalCount = 0; + sal_uInt8 nSignCount = 0, nDecimalCount = 0, nExpCount = 0; xub_StrLen nLen = aString.Len(); sal_Unicode cDecSep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator.getStr()[0]; for (xub_StrLen i = 0; i < nLen; ++i) @@ -557,13 +562,17 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) ++nSignCount; else if (c == cDecSep) ++nDecimalCount; + else if (c == sal_Unicode('E')) + ++nExpCount; } if (nDecimalCount) nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount; if (nSignCount) nWidth += (nMaxDigit - GetSignWidth()) * nSignCount; + if (nExpCount) + nWidth += (nMaxDigit - GetExpWidth()) * nExpCount; - if (nDecimalCount || nSignCount) + if (nDecimalCount || nSignCount || nExpCount) { // Re-calculate. nNumDigits = static_cast(nWidth / nMaxDigit); @@ -658,6 +667,17 @@ long ScDrawStringsVars::GetDotWidth() return nDotWidth; } +long ScDrawStringsVars::GetExpWidth() +{ + if (nExpWidth > 0) + return nExpWidth; + + nExpWidth = pOutput->pFmtDevice->GetTextWidth(String('E')); + if (bPixelToLogic) + nExpWidth = ConvertWidthLogicToPixel(nExpWidth); + return nExpWidth; +} + void ScDrawStringsVars::TextChanged() { OutputDevice* pRefDevice = pOutput->pRefDevice; -- cgit From d77d2195dd240df9c28b9c50a667db1e2a8d0e1b Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 4 Jun 2010 18:22:13 +0200 Subject: calc55: #i112035# loading some old chart document fails --- chart2/source/tools/WrappedPropertySet.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx index 116ce6f417f9..843aeb261a5f 100644 --- a/chart2/source/tools/WrappedPropertySet.cxx +++ b/chart2/source/tools/WrappedPropertySet.cxx @@ -34,6 +34,8 @@ // header for define DELETEZ #include +#include + //............................................................................. namespace chart { @@ -115,7 +117,11 @@ void SAL_CALL WrappedPropertySet::setPropertyValue( const OUString& rPropertyNam else if( xInnerPropertySet.is() ) xInnerPropertySet->setPropertyValue( rPropertyName, rValue ); else - throw beans::UnknownPropertyException(); + { +#if OSL_DEBUG_LEVEL > 1 + DBG_ERROR("found no inner property set to map to"); +#endif + } } catch( beans::UnknownPropertyException& ex ) { @@ -160,7 +166,11 @@ Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName else if( xInnerPropertySet.is() ) aRet = xInnerPropertySet->getPropertyValue( rPropertyName ); else - throw beans::UnknownPropertyException(); + { +#if OSL_DEBUG_LEVEL > 1 + DBG_ERROR("found no inner property set to map to"); +#endif + } } catch( beans::UnknownPropertyException& ex ) { -- cgit From 004a866033b8050c816fdea36bab011a15db8536 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:43:36 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- .../chartapiwrapper/ChartDocumentWrapper.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 14a20e133ff1..37c41730523b 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -160,7 +160,9 @@ enum PROP_DOCUMENT_BASEDIAGRAM, PROP_DOCUMENT_ADDITIONAL_SHAPES, PROP_DOCUMENT_UPDATE_ADDIN, - PROP_DOCUMENT_NULL_DATE + PROP_DOCUMENT_NULL_DATE, + PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, + PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG }; void lcl_AddPropertiesToVector( @@ -231,6 +233,19 @@ void lcl_AddPropertiesToVector( PROP_DOCUMENT_NULL_DATE, ::getCppuType( static_cast< const ::com::sun::star::util::DateTime * >(0)), beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "DisableComplexChartTypes" ), + PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); + rOutProperties.push_back( + Property( C2U( "DisableDataTableDialog" ), + PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); } const uno::Sequence< Property > & lcl_GetPropertySequence() @@ -1570,6 +1585,8 @@ const std::vector< WrappedProperty* > ChartDocumentWrapper::createWrappedPropert aWrappedProperties.push_back( new WrappedAdditionalShapesProperty( *this ) ); aWrappedProperties.push_back( new WrappedRefreshAddInAllowedProperty( *this ) ); aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U("NullDate"),Any() ) ); // i99104 + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "DisableComplexChartTypes" ), uno::makeAny( sal_False ) ) ); + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "DisableDataTableDialog" ), uno::makeAny( sal_False ) ) ); return aWrappedProperties; } -- cgit From f84216c511b8d3f3228f012d49e3a9503fddee74 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:44:00 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- chart2/source/controller/dialogs/res_ErrorBar.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 75457a5e7cad..8b649072538e 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -37,6 +37,7 @@ #include "RangeSelectionHelper.hxx" // for RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR #include "TabPageNotifiable.hxx" +#include "macros.hxx" #include #include @@ -147,7 +148,8 @@ ErrorBarResources::ErrorBarResources( Window* pParent, Dialog * pParentDialog, m_pParentWindow( pParent ), m_pParentDialog( pParentDialog ), m_pCurrentRangeChoosingField( 0 ), - m_bHasInternalDataProvider( true ) + m_bHasInternalDataProvider( true ), + m_bDisableDataTableDialog( false ) { if( m_bNoneAvailable ) m_aRbNone.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); @@ -197,7 +199,21 @@ void ErrorBarResources::SetChartDocumentForRangeChoosing( const uno::Reference< chart2::XChartDocument > & xChartDocument ) { if( xChartDocument.is()) + { m_bHasInternalDataProvider = xChartDocument->hasInternalDataProvider(); + uno::Reference< beans::XPropertySet > xProps( xChartDocument, uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableDataTableDialog" ) ) >>= m_bDisableDataTableDialog; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } m_apRangeSelectionHelper.reset( new RangeSelectionHelper( xChartDocument )); // has internal data provider => rename "cell range" to "from data" @@ -240,6 +256,7 @@ void ErrorBarResources::UpdateControlStates() m_aLbFunction.Enable( bIsFunction ); // range buttons + m_aRbRange.Enable( !m_bHasInternalDataProvider || !m_bDisableDataTableDialog ); bool bShowRange = ( m_aRbRange.IsChecked()); bool bCanChooseRange = ( bShowRange && -- cgit From 841d9ebb1d45dff97f1dc765aae8427fab4d17a4 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:44:19 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- chart2/source/controller/dialogs/tp_ChartType.cxx | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index 244d23ed8eff..6460ba7ebb99 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -853,15 +853,35 @@ ChartTypeTabPage::ChartTypeTabPage( Window* pParent bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() ); + bool bDisableComplexChartTypes = false; + uno::Reference< beans::XPropertySet > xProps( m_xChartModel, uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableComplexChartTypes" ) ) >>= bDisableComplexChartTypes; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + m_aChartTypeDialogControllerList.push_back(new ColumnChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new BarChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new PieChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new AreaChartDialogController() ); m_aChartTypeDialogControllerList.push_back(new LineChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() ); + if ( !bDisableComplexChartTypes ) + { + m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() ); + } m_aChartTypeDialogControllerList.push_back(new NetChartDialogController() ); - m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() ); + if ( !bDisableComplexChartTypes ) + { + m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() ); + } m_aChartTypeDialogControllerList.push_back(new CombiColumnLineChartDialogController() ); ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin(); -- cgit From bc78afd4e42319c43edb69b5857997b8356c0d3b Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:44:46 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- chart2/source/controller/inc/res_ErrorBar.hxx | 1 + 1 file changed, 1 insertion(+) diff --git a/chart2/source/controller/inc/res_ErrorBar.hxx b/chart2/source/controller/inc/res_ErrorBar.hxx index 36bceaffce9f..0b5f33b5c128 100644 --- a/chart2/source/controller/inc/res_ErrorBar.hxx +++ b/chart2/source/controller/inc/res_ErrorBar.hxx @@ -135,6 +135,7 @@ private: m_apRangeSelectionHelper; Edit * m_pCurrentRangeChoosingField; bool m_bHasInternalDataProvider; + bool m_bDisableDataTableDialog; DECL_LINK( CategoryChosen, void * ); DECL_LINK( SynchronizePosAndNeg, void * ); -- cgit From f50884d2c099d7dafa20524e60e2fac83faea5ca Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 18:45:09 +0200 Subject: calc55: #i112094# chart data table dialog cannot be disabled via UNO API --- .../controller/main/ControllerCommandDispatch.cxx | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 2652aadfdb32..a01b80bfa22b 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -528,6 +528,23 @@ void ControllerCommandDispatch::updateCommandAvailability() bool bShapeContext = ( m_pChartController ? m_pChartController->isShapeContext() : false ); + bool bDisableDataTableDialog = false; + if ( m_xController.is() ) + { + Reference< beans::XPropertySet > xProps( m_xController->getModel(), uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + xProps->getPropertyValue( C2U( "DisableDataTableDialog" ) ) >>= bDisableDataTableDialog; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } + // edit commands m_aCommandAvailability[ C2U(".uno:Cut")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected; m_aCommandAvailability[ C2U(".uno:Copy")] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject; @@ -595,7 +612,7 @@ void ControllerCommandDispatch::updateCommandAvailability() // depending on own data m_aCommandAvailability[ C2U(".uno:DataRanges")] = bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData); - m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData; + m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData && !bDisableDataTableDialog; // titles m_aCommandAvailability[ C2U(".uno:MainTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle; @@ -631,9 +648,9 @@ void ControllerCommandDispatch::updateCommandAvailability() // series arrangement m_aCommandAvailability[ C2U(".uno:Forward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Forward" ) ) : - ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward ) ); + ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward && !bDisableDataTableDialog ) ); m_aCommandAvailability[ C2U(".uno:Backward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Backward" ) ) : - ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward ) ); + ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward && !bDisableDataTableDialog ) ); m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable; m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable; -- cgit From 8f2045046c1c27395c7afb1168eac5baeb423aa1 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 4 Jun 2010 18:59:28 +0200 Subject: calc55: #i112123# when loading, don't initialize StdPrecision in DocOptions from configuration --- sc/source/ui/docshell/docsh.cxx | 2 +- sc/source/ui/docshell/docsh2.cxx | 2 +- sc/source/ui/docshell/docsh3.cxx | 10 +++++++++- sc/source/ui/inc/docsh.hxx | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 135bbcdace49..d1084036d163 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -457,7 +457,7 @@ BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium ) // only the latin script language is loaded // -> initialize the others from options (before loading) - InitOptions(); + InitOptions(true); GetUndoManager()->Clear(); diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 9e3ed217382f..14ff7622818c 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -93,7 +93,7 @@ BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xSt aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew // InitOptions sets the document languages, must be called before CreateStandardStyles - InitOptions(); + InitOptions(false); aDocument.GetStyleSheetPool()->CreateStandardStyles(); aDocument.UpdStlShtPtrsFrmNms(); diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 4709a065792f..233843935bbd 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -424,7 +424,7 @@ double ScDocShell::GetOutputFactor() const //--------------------------------------------------------------------- -void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs) +void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and Load { // Einstellungen aus dem SpellCheckCfg kommen in Doc- und ViewOptions @@ -440,6 +440,14 @@ void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs) // zweistellige Jahreszahleneingabe aus Extras->Optionen->Allgemein->Sonstiges aDocOpt.SetYear2000( sal::static_int_cast( ::utl::MiscCfg().GetYear2000() ) ); + if (bForLoading) + { + // #i112123# No style:decimal-places attribute means automatic decimals, not the configured default, + // so it must not be taken from the global options. + // Calculation settings are handled separately in ScXMLBodyContext::EndElement. + aDocOpt.SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION ); + } + aDocument.SetDocOptions( aDocOpt ); aDocument.SetViewOptions( aViewOpt ); diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 09d34c661995..0ef96bffc386 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -125,7 +125,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener SC_DLLPRIVATE void InitItems(); SC_DLLPRIVATE void DoEnterHandler(); - SC_DLLPRIVATE void InitOptions(); + SC_DLLPRIVATE void InitOptions(bool bForLoading); SC_DLLPRIVATE void ResetDrawObjectShell(); // SUNWS needs a forward declared friend, otherwise types and members -- cgit From 9e19a15a040e7bfabdf051b63f9a28383381741a Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 20:08:33 +0200 Subject: calc55: #i112084# All charts in a Calc document are loaded when saving the document --- sc/inc/chartuno.hxx | 47 +++++++++++-- sc/source/filter/xml/xmlexprt.cxx | 81 ++++++++++++++++------ sc/source/ui/docshell/docsh.cxx | 43 ++++++++++++ sc/source/ui/unoobj/chartuno.cxx | 138 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 277 insertions(+), 32 deletions(-) diff --git a/sc/inc/chartuno.hxx b/sc/inc/chartuno.hxx index 795d655f3d06..fe261f26e517 100644 --- a/sc/inc/chartuno.hxx +++ b/sc/inc/chartuno.hxx @@ -31,6 +31,8 @@ #include "address.hxx" #include #include +#include +#include #include #include @@ -39,6 +41,7 @@ #include #include #include +#include #include @@ -113,12 +116,20 @@ public: }; -class ScChartObj : public cppu::WeakImplHelper4< - com::sun::star::table::XTableChart, - com::sun::star::document::XEmbeddedObjectSupplier, - com::sun::star::container::XNamed, - com::sun::star::lang::XServiceInfo >, - public SfxListener +typedef ::cppu::WeakComponentImplHelper4< + ::com::sun::star::table::XTableChart, + ::com::sun::star::document::XEmbeddedObjectSupplier, + ::com::sun::star::container::XNamed, + ::com::sun::star::lang::XServiceInfo > ScChartObj_Base; + +typedef ::comphelper::OPropertyContainer ScChartObj_PBase; +typedef ::comphelper::OPropertyArrayUsageHelper< ScChartObj > ScChartObj_PABase; + +class ScChartObj : public ::comphelper::OBaseMutex + ,public ScChartObj_Base + ,public ScChartObj_PBase + ,public ScChartObj_PABase + ,public SfxListener { private: ScDocShell* pDocShell; @@ -128,12 +139,32 @@ private: void Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders ); void GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const; +protected: + // ::comphelper::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::Exception); + using ::cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + + // ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; + public: ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN); virtual ~ScChartObj(); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + virtual void SAL_CALL disposing(); + // XTableChart virtual sal_Bool SAL_CALL getHasColumnHeaders() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHasColumnHeaders( sal_Bool bHasColumnHeaders ) @@ -163,6 +194,10 @@ public: throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); }; #endif diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 0b620e1d47d8..d38fd7aed7b6 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3064,32 +3064,69 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, if ( sCLSID.equalsIgnoreAsciiCase(GetChartExport()->getChartCLSID()) ) { // we have a chart - uno::Reference< frame::XModel > xChartModel; - if( ( xShapeProps->getPropertyValue( sPropModel ) >>= xChartModel ) && - xChartModel.is()) + ::rtl::OUString sRanges; + if ( pDoc ) { - uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); - uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY ); - if( xChartDoc.is() && xReceiver.is() && - ! xChartDoc->hasInternalDataProvider()) + ::rtl::OUString aChartName; + xShapeProps->getPropertyValue( sPersistName ) >>= aChartName; + ScRange aEmptyRange; + ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); + USHORT nIndex = 0; + ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); + if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) { - // we have a chart that gets its data from Calc - bIsChart = true; - uno::Sequence< ::rtl::OUString > aRepresentations( - xReceiver->getUsedRangeRepresentations()); - SvXMLAttributeList* pAttrList = 0; - if(aRepresentations.getLength()) + ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); + if ( pListener ) { - // add the ranges used by the chart to the shape - // element to be able to start listening after - // load (when the chart is not yet loaded) - uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - ::rtl::OUString sRanges( lcl_RangeSequenceToString( aRepresentations, xRangeConverter )); - pAttrList = new SvXMLAttributeList(); - pAttrList->AddAttribute( - GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + const ScRangeListRef& rRangeList = pListener->GetRangeList(); + if ( rRangeList.Is() ) + { + ScRangeStringConverter::GetStringFromRangeList( sRanges, rRangeList, pDoc, FormulaGrammar::CONV_OOO ); + if ( sRanges.getLength() > 0 ) + { + bIsChart = true; + SvXMLAttributeList* pAttrList = new SvXMLAttributeList(); + if ( pAttrList ) + { + pAttrList->AddAttribute( + GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges ); + } + GetShapeExport()->exportShape( xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList ); + } + } + } + } + } + + if ( sRanges.getLength() == 0 ) + { + uno::Reference< frame::XModel > xChartModel; + if( ( xShapeProps->getPropertyValue( sPropModel ) >>= xChartModel ) && + xChartModel.is()) + { + uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is() && xReceiver.is() && + ! xChartDoc->hasInternalDataProvider()) + { + // we have a chart that gets its data from Calc + bIsChart = true; + uno::Sequence< ::rtl::OUString > aRepresentations( + xReceiver->getUsedRangeRepresentations()); + SvXMLAttributeList* pAttrList = 0; + if(aRepresentations.getLength()) + { + // add the ranges used by the chart to the shape + // element to be able to start listening after + // load (when the chart is not yet loaded) + uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter ); + pAttrList = new SvXMLAttributeList(); + pAttrList->AddAttribute( + GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); + } + GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList); } - GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList); } } diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index d1084036d163..9d37d417ec06 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -68,6 +68,9 @@ #include "chgviset.hxx" #include #include +#include +#include +#include #include "scabstdlg.hxx" //CHINA001 @@ -581,6 +584,46 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) } } } + + try + { + uno::Reference< uno::XComponentContext > xContext; + uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); + uno::Reference< beans::XPropertySet > xProp( xServiceManager, uno::UNO_QUERY_THROW ); + xProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext; + if ( xContext.is() ) + { + uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW ); + uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocumentJob" ) ) ); + if ( xEnum.is() ) + { + while ( xEnum->hasMoreElements() ) + { + uno::Any aAny = xEnum->nextElement(); + uno::Reference< lang::XSingleComponentFactory > xFactory; + aAny >>= xFactory; + if ( xFactory.is() ) + { + uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW ); + uno::Sequence< beans::NamedValue > aArgsForJob(1); + ScViewData* pViewData = GetViewData(); + SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : NULL ); + SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : NULL ); + SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : NULL ); + uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : 0 ); + uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW ); + aArgsForJob[0] = beans::NamedValue( ::rtl::OUString::createFromAscii( "SpreadsheetView" ), + uno::makeAny( xSpreadsheetView ) ); + xJob->execute( aArgsForJob ); + } + } + } + } + } + catch ( uno::Exception & ) + { + } } break; case SFX_EVENT_SAVEDOC: diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 201c411ea45c..0150ecdc6d41 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -31,10 +31,12 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -54,9 +56,12 @@ #include "chartlis.hxx" #include "unoguard.hxx" #include "chart2uno.hxx" +#include "convuno.hxx" using namespace com::sun::star; +#define PROP_HANDLE_RELATED_CELLRANGES 1 + //------------------------------------------------------------------------ SC_SIMPLE_SERVICE_INFO( ScChartObj, "ScChartObj", "com.sun.star.table.TableChart" ) @@ -451,12 +456,19 @@ sal_Bool SAL_CALL ScChartsObj::hasByName( const rtl::OUString& aName ) //------------------------------------------------------------------------ -ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) : - pDocShell( pDocSh ), - nTab( nT ), - aChartName( rN ) +ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) + :ScChartObj_Base( m_aMutex ) + ,ScChartObj_PBase( ScChartObj_Base::rBHelper ) + ,pDocShell( pDocSh ) + ,nTab( nT ) + ,aChartName( rN ) { pDocShell->GetDocument()->AddUnoObject(*this); + + uno::Sequence< table::CellRangeAddress > aInitialPropValue; + registerPropertyNoMember( ::rtl::OUString::createFromAscii( "RelatedCellRanges" ), + PROP_HANDLE_RELATED_CELLRANGES, beans::PropertyAttribute::MAYBEVOID, + ::getCppuType( &aInitialPropValue ), &aInitialPropValue ); } ScChartObj::~ScChartObj() @@ -552,6 +564,117 @@ void ScChartObj::Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, b } } +// ::comphelper::OPropertySetHelper + +::cppu::IPropertyArrayHelper& ScChartObj::getInfoHelper() +{ + return *ScChartObj_PABase::getArrayHelper(); +} + +void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) +{ + switch ( nHandle ) + { + case PROP_HANDLE_RELATED_CELLRANGES: + { + uno::Sequence< table::CellRangeAddress > aCellRanges; + if ( rValue >>= aCellRanges ) + { + ScRangeListRef rRangeList = new ScRangeList(); + const table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); + sal_Int32 nCount = aCellRanges.getLength(); + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + table::CellRangeAddress aCellRange = pCellRanges[ i ]; + ScRange aRange; + ScUnoConversion::FillScRange( aRange, aCellRange ); + rRangeList->Append( aRange ); + } + ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); + ScChartListenerCollection* pCollection = ( pDoc ? pDoc->GetChartListenerCollection() : NULL ); + if ( pCollection ) + { + pCollection->ChangeListening( aChartName, rRangeList ); + } + } + } + break; + default: + { + } + break; + } +} + +void ScChartObj::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const +{ + switch ( nHandle ) + { + case PROP_HANDLE_RELATED_CELLRANGES: + { + ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); + if ( pDoc ) + { + ScRange aEmptyRange; + USHORT nIndex = 0; + ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); + ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); + if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) + { + ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); + if ( pListener ) + { + const ScRangeListRef& rRangeList = pListener->GetRangeList(); + if ( rRangeList.Is() ) + { + ULONG nCount = rRangeList->Count(); + uno::Sequence< table::CellRangeAddress > aCellRanges( nCount ); + table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); + for ( USHORT i = 0; i < nCount; ++i ) + { + ScRange aRange( *rRangeList->GetObject( i ) ); + table::CellRangeAddress aCellRange; + ScUnoConversion::FillApiRange( aCellRange, aRange ); + pCellRanges[ i ] = aCellRange; + } + rValue <<= aCellRanges; + } + } + } + } + } + break; + default: + { + } + break; + } +} + +// ::comphelper::OPropertyArrayUsageHelper + +::cppu::IPropertyArrayHelper* ScChartObj::createArrayHelper() const +{ + uno::Sequence< beans::Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); +} + +// XInterface + +IMPLEMENT_FORWARD_XINTERFACE2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) + +// XTypeProvider + +IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) + +// XComponent + +void ScChartObj::disposing() +{ + ScChartObj_Base::disposing(); +} + // XTableChart sal_Bool SAL_CALL ScChartObj::getHasColumnHeaders() throw(uno::RuntimeException) @@ -681,6 +804,13 @@ void SAL_CALL ScChartObj::setName( const rtl::OUString& /* aName */ ) throw(uno: throw uno::RuntimeException(); // name cannot be changed } +// XPropertySet + +uno::Reference< beans::XPropertySetInfo > ScChartObj::getPropertySetInfo() throw (uno::RuntimeException) +{ + return createPropertySetInfo( getInfoHelper() ) ; +} + //------------------------------------------------------------------------ -- cgit From 2022245614171200dd2f34921223edc79abc49ec Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Mon, 7 Jun 2010 13:42:16 +0200 Subject: calc55: #i112185# remove unreferenced files (implementation is in ScDPResultMember) --- sc/source/core/data/dptabresmember.cxx | 831 --------------------------------- sc/source/core/data/dptabresmember.hxx | 161 ------- 2 files changed, 992 deletions(-) delete mode 100644 sc/source/core/data/dptabresmember.cxx delete mode 100644 sc/source/core/data/dptabresmember.hxx diff --git a/sc/source/core/data/dptabresmember.cxx b/sc/source/core/data/dptabresmember.cxx deleted file mode 100644 index 8c3b7b164bc3..000000000000 --- a/sc/source/core/data/dptabresmember.cxx +++ /dev/null @@ -1,831 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright IBM Corporation 2009. - * Copyright 2009 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: dptabresmember.cxx,v $ - * $Revision: 1.0 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "dptabresmember.hxx" -// ----------------------------------------------------------------------- -ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData , - BOOL bForceSub ) : - pResultData( pData ), - aParentDimData( rParentDimData ), - /* pParentDim( pDim ), - pParentLevel( pLev ), - pMemberDesc( pDesc ),*/ - pChildDimension( NULL ), - pDataRoot( NULL ), - bHasElements( FALSE ), - bForceSubTotal( bForceSub ), - bHasHiddenDetails( FALSE ), - bInitialized( FALSE ), - nMemberStep( 1 ), - bAutoHidden( FALSE ) -{ - // pParentLevel/pMemberDesc is 0 for root members -} - -ScDPNormalResultMember::ScDPNormalResultMember( const ScDPResultData* pData, - BOOL bForceSub ) : - pResultData( pData ), - pChildDimension( NULL ), - pDataRoot( NULL ), - bHasElements( FALSE ), - bForceSubTotal( bForceSub ), - bHasHiddenDetails( FALSE ), - bInitialized( FALSE ), - nMemberStep( 1 ), - bAutoHidden( FALSE ) -{ -} - -ScDPNormalResultMember::~ScDPNormalResultMember() -{ - delete pChildDimension; - delete pDataRoot; -} - -String ScDPNormalResultMember::GetName() const -{ -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - const ScDPMember* pMemberDesc = GetDPMember(); - // End Comments - if (pMemberDesc) - return pMemberDesc->GetNameStr(); - else - return ScGlobal::GetRscString(STR_PIVOT_TOTAL); // root member -} - -void ScDPNormalResultMember::FillItemData( ScDPItemData& rData ) const -{ -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration - const ScDPMember* pMemberDesc = GetDPMember(); -// End Comments - if (pMemberDesc) - pMemberDesc->FillItemData( rData ); - else - rData.SetString( ScGlobal::GetRscString(STR_PIVOT_TOTAL) ); // root member -} - -BOOL ScDPNormalResultMember::IsNamedItem( /*const ScDPItemData& r */SCROW nIndex ) const -{ - //! store ScDPMember pointer instead of ScDPMember ??? - const ScDPMember* pMemberDesc = GetDPMember(); - if (pMemberDesc) - return ((ScDPMember*)pMemberDesc)->IsNamedItem(/* r*/ nIndex ); - return FALSE; -} - -// Wang Xu Ming -- 2009-5-27 -// DataPilot Migration -bool ScDPNormalResultMember::IsValidEntry( const vector< SCROW >& aMembers ) const -{ - return GetEntryStatus( aMembers ) != ENTRY_INVALID; -} -// End Comments - -ENTRYSTATUS ScDPNormalResultMember::GetEntryStatus( const vector< SCROW >& aMembers ) const -{ - if ( !IsValid() ) - return ENTRY_INVALID; - - const ScDPResultDimension* pChildDim = GetChildDimension(); - if (pChildDim) - { - if (aMembers.size() < 2) - return ENTRY_INVALID; - - vector::const_iterator itr = aMembers.begin(); - vector aChildMembers(++itr, aMembers.end()); - return pChildDim->GetEntryStatus(aChildMembers); - } - else if( bHasHiddenDetails ) - return ENTRY_HASHIDDENDETAIL; - else - return ENTRY_VALID; -} - -void ScDPNormalResultMember::InitFrom( const vector& ppDim, const vector& ppLev, - size_t nPos, ScDPInitState& rInitState , - BOOL bInitChild /*= TRUE */) - { - // with LateInit, initialize only those members that have data - if ( pResultData->IsLateInit() ) - return; - - bInitialized = TRUE; - - if (nPos >= ppDim.size() ) - return; - - // skip child dimension if details are not shown - if ( GetDPMember() && !GetDPMember()->getShowDetails() ) - { - // Wang Xu Ming -- 2009-6-16 - // Show DataLayout dimention - nMemberStep = 1; - while ( nPos < ppDim.size() ) - { - if ( ppDim[nPos] ->getIsDataLayoutDimension() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState , FALSE ); - return; - } - else - { //find next dim - nPos ++; - nMemberStep ++; - } - } - // End Comments - bHasHiddenDetails = TRUE; // only if there is a next dimension - return; - } - - if ( bInitChild ) - { - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState, TRUE ); - } -} - -// Wang Xu Ming -- 2009-6-10 -// DataPilot Migration -void ScDPNormalResultMember::LateInitFrom( LateInitParams& rParams/*const vector& ppDim, const vector& ppLev*/, - const vector< SCROW >& pItemData, size_t nPos, - ScDPInitState& rInitState ) -// End Comments -{ - // without LateInit, everything has already been initialized - if ( !pResultData->IsLateInit() ) - return; - - bInitialized = TRUE; - - if ( rParams.IsEnd( nPos ) /*nPos >= ppDim.size()*/) - // No next dimension. Bail out. - return; - - // skip child dimension if details are not shown - if ( GetDPMember() && !GetDPMember()->getShowDetails() ) - { - // Wang Xu Ming -- 2009-6-16 - // DataPilot Migration - // Show DataLayout dimention - nMemberStep = 1; - while ( !rParams.IsEnd( nPos ) ) - { - if ( rParams.GetDim( nPos ) ->getIsDataLayoutDimension() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - rParams.SetInitChild( FALSE ); - pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState ); - return; - } - else - { //find next dim - nPos ++; - nMemberStep ++; - } - } - // End Comments - bHasHiddenDetails = TRUE; // only if there is a next dimension - return; - } - - // LateInitFrom is called several times... - if ( rParams.GetInitChild() ) - { - if ( !pChildDimension ) - pChildDimension = new ScDPResultDimension( pResultData ); - pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState ); - } -} - -BOOL ScDPNormalResultMember::IsSubTotalInTitle(long nMeasure) const -{ - BOOL bRet = FALSE; - if ( pChildDimension && /*pParentLevel*/GetParentLevel() && - /*pParentLevel*/GetParentLevel()->IsOutlineLayout() && /*pParentLevel*/GetParentLevel()->IsSubtotalsAtTop() ) - { - long nUserSubStart; - long nSubTotals = GetSubTotalCount( &nUserSubStart ); - nSubTotals -= nUserSubStart; // visible count - if ( nSubTotals ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nSubTotals *= pResultData->GetMeasureCount(); // number of subtotals that will be inserted - - // only a single subtotal row will be shown in the outline title row - if ( nSubTotals == 1 ) - bRet = TRUE; - } - } - return bRet; -} - -long ScDPNormalResultMember::GetSize(long nMeasure) const -{ - if ( !IsVisible() ) - return 0; - const ScDPLevel* pParentLevel = GetParentLevel(); - long nExtraSpace = 0; - if ( pParentLevel && pParentLevel->IsAddEmpty() ) - ++nExtraSpace; - - if ( pChildDimension ) - { - // outline layout takes up an extra row for the title only if subtotals aren't shown in that row - if ( pParentLevel && pParentLevel->IsOutlineLayout() && !IsSubTotalInTitle( nMeasure ) ) - ++nExtraSpace; - - long nSize = pChildDimension->GetSize(nMeasure); - long nUserSubStart; - long nUserSubCount = GetSubTotalCount( &nUserSubStart ); - nUserSubCount -= nUserSubStart; // for output size, use visible count - if ( nUserSubCount ) - { - if ( nMeasure == SC_DPMEASURE_ALL ) - nSize += pResultData->GetMeasureCount() * nUserSubCount; - else - nSize += nUserSubCount; - } - return nSize + nExtraSpace; - } - else - { - if ( nMeasure == SC_DPMEASURE_ALL ) - return pResultData->GetMeasureCount() + nExtraSpace; - else - return 1 + nExtraSpace; - } -} - - -BOOL ScDPNormalResultMember::IsVisible() const -{ - // not initialized -> shouldn't be there at all - // (allocated only to preserve ordering) - const ScDPLevel* pParentLevel = GetParentLevel(); - return ( bHasElements || ( pParentLevel && pParentLevel->getShowEmpty() ) ) && IsValid() && bInitialized; -} - -BOOL ScDPNormalResultMember::IsValid() const -{ - // non-Valid members are left out of calculation - - // was member set no invisible at the DataPilotSource? - const ScDPMember* pMemberDesc =GetDPMember(); - if ( pMemberDesc && !pMemberDesc->getIsVisible() ) - return FALSE; - - if ( bAutoHidden ) - return FALSE; - - return TRUE; -} - -BOOL ScDPNormalResultMember::HasHiddenDetails() const -{ - // bHasHiddenDetails is set only if the "show details" flag is off, - // and there was a child dimension to skip - - return bHasHiddenDetails; -} - -long ScDPNormalResultMember::GetSubTotalCount( long* pUserSubStart ) const -{ - if ( pUserSubStart ) - *pUserSubStart = 0; // default - - const ScDPLevel* pParentLevel = GetParentLevel(); - - if ( bForceSubTotal ) // set if needed for root members - return 1; // grand total is always "automatic" - else if ( pParentLevel ) - { - //! direct access via ScDPLevel - - uno::Sequence aSeq = pParentLevel->getSubTotals(); - long nSequence = aSeq.getLength(); - if ( nSequence && aSeq[0] != sheet::GeneralFunction_AUTO ) - { - // For manual subtotals, always add "automatic" as first function - // (used for calculation, but not for display, needed for sorting, see lcl_GetForceFunc) - - ++nSequence; - if ( pUserSubStart ) - *pUserSubStart = 1; // visible subtotals start at 1 - } - return nSequence; - } - else - return 0; -} - -void ScDPNormalResultMember::ProcessData( const vector< SCROW >& aChildMembers, const ScDPResultDimension* pDataDim, - const vector< SCROW >& aDataMembers, const vector& aValues ) -{ - SetHasElements(); - - if (pChildDimension) - pChildDimension->ProcessData( aChildMembers, pDataDim, aDataMembers, aValues ); - - if ( !pDataRoot ) - { - pDataRoot = new ScDPDataMember( pResultData, NULL ); - if ( pDataDim ) - pDataRoot->InitFrom( pDataDim ); // recursive - } - - ScDPSubTotalState aSubState; // initial state - - long nUserSubCount = GetSubTotalCount(); - - // Calculate at least automatic if no subtotals are selected, - // show only own values if there's no child dimension (innermost). - if ( !nUserSubCount || !pChildDimension ) - nUserSubCount = 1; - - const ScDPLevel* pParentLevel = GetParentLevel(); - - for (long nUserPos=0; nUserPos