ooo-build r15261 - in trunk: . patches/dev300



Author: kyoshida
Date: Fri Jan 30 21:42:36 2009
New Revision: 15261
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15261&view=rev

Log:
2009-01-30  Daniel Watson  <daniel watsonbros gmail com>

	* patches/dev300/calc-sheet-tab-color-officecfg.diff:
	* patches/dev300/calc-sheet-tab-color-sc.diff:
	* patches/dev300/calc-sheet-tab-color-svtools.diff: updated patches.
	Undo & redo are now working & store the tab color info with 
	ScViewDataTable instead of ScTable.  ODF import/export is also working.


Modified:
   trunk/ChangeLog
   trunk/patches/dev300/calc-sheet-tab-color-officecfg.diff
   trunk/patches/dev300/calc-sheet-tab-color-sc.diff
   trunk/patches/dev300/calc-sheet-tab-color-svtools.diff

Modified: trunk/patches/dev300/calc-sheet-tab-color-officecfg.diff
==============================================================================
--- trunk/patches/dev300/calc-sheet-tab-color-officecfg.diff	(original)
+++ trunk/patches/dev300/calc-sheet-tab-color-officecfg.diff	Fri Jan 30 21:42:36 2009
@@ -1,24 +1,24 @@
 diff --git officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
-index 4536277..bdc133d 100644
+index d32c182..e7116ba 100644
 --- officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
 +++ officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
 @@ -1252,6 +1252,19 @@
  					<value xml:lang="en-US">Rename Sheet</value>
  				</prop>
  			</node>
-+			<node oor:name=".uno:SetTabBgColor" oor:op="replace">
-+				<prop oor:name="Label" oor:type="xs:string">
-+					<value xml:lang="en-US">Set ~Tab Color...</value>
-+				</prop>
-+				<prop oor:name="ContextLabel" oor:type="xs:string">
-+					<value xml:lang="en-US">~Tab Color...</value>
-+				</prop>
-+			</node>
-+			<node oor:name=".uno:TabBgColor" oor:op="replace">
-+				<prop oor:name="Label" oor:type="xs:string">
-+					<value xml:lang="en-US">Set Tab Color</value>
-+				</prop>
-+			</node>
++            <node oor:name=".uno:SetTabBgColor" oor:op="replace">
++                <prop oor:name="Label" oor:type="xs:string">
++                    <value xml:lang="en-US">Set ~Tab Color...</value>
++                </prop>
++                <prop oor:name="ContextLabel" oor:type="xs:string">
++                    <value xml:lang="en-US">~Tab Color...</value>
++                </prop>
++            </node>
++            <node oor:name=".uno:TabBgColor" oor:op="replace">
++                <prop oor:name="Label" oor:type="xs:string">
++                    <value xml:lang="en-US">Set Tab Color</value>
++                </prop>
++            </node>
  			<node oor:name=".uno:Move" oor:op="replace">
  				<prop oor:name="Label" oor:type="xs:string">
  					<value xml:lang="en-US">~Move/Copy Sheet...</value>

Modified: trunk/patches/dev300/calc-sheet-tab-color-sc.diff
==============================================================================
--- trunk/patches/dev300/calc-sheet-tab-color-sc.diff	(original)
+++ trunk/patches/dev300/calc-sheet-tab-color-sc.diff	Fri Jan 30 21:42:36 2009
@@ -1,89 +1,100 @@
-diff --git sc/inc/document.hxx sc/inc/document.hxx
-index 7c531e8..d827d27 100644
---- sc/inc/document.hxx
-+++ sc/inc/document.hxx
-@@ -583,6 +583,13 @@ SC_DLLPUBLIC	ScDBCollection*	GetDBCollection() const;
- 	BOOL			RenameTab( SCTAB nTab, const String& rName,
- 								BOOL bUpdateRef = TRUE,
- 								BOOL bExternalDocument = FALSE );
-+// TabBgColor -----------------------------------------------------------------
-+    SC_DLLPUBLIC BOOL           SetTabBgColor( SCTAB nTab, const Color& rColor,
-+                                BOOL bUpdateRef = TRUE,             /*TODO Make sure this parameter is actually needed...*/
-+                                BOOL bExternalDocument = FALSE );   /*TODO Make sure this parameter is actually needed...*/
-+    SC_DLLPUBLIC Color          GetTabBgColor( SCTAB nTab ) const;
-+    SC_DLLPUBLIC BOOL           IsDefaultTabBgColor( SCTAB nTab ) const;
-+// TabBgColor -----------------------------------------------------------------
- 	BOOL			MoveTab( SCTAB nOldPos, SCTAB nNewPos );
- 	BOOL			CopyTab( SCTAB nOldPos, SCTAB nNewPos,
- 								const ScMarkData* pOnlyMarked = NULL );
+diff --git sc/inc/ViewSettingsSequenceDefines.hxx sc/inc/ViewSettingsSequenceDefines.hxx
+index 4561e51..822f4d3 100644
+--- sc/inc/ViewSettingsSequenceDefines.hxx
++++ 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         15
++#define SC_TABLE_VIEWSETTINGS_COUNT         16
+ 
+ #define SC_CURSOR_X							0
+ #define SC_CURSOR_Y							1
+@@ -81,6 +81,7 @@
+ #define SC_TABLE_ZOOM_VALUE                 12
+ #define SC_TABLE_PAGE_VIEW_ZOOM_VALUE       13
+ #define SC_TABLE_SHOWGRID                   14
++#define SC_TABLE_TAB_BG_COLOR               15
+ 
+ #define SC_CURSORPOSITIONX					"CursorPositionX"
+ #define SC_CURSORPOSITIONY					"CursorPositionY"
+diff --git sc/inc/globstr.hrc sc/inc/globstr.hrc
+index fbf7540..d0a0e4a 100644
+--- sc/inc/globstr.hrc
++++ sc/inc/globstr.hrc
+@@ -590,7 +590,9 @@
+ #define STR_FORM_SPINNER            447
+ #define STR_FORM_SCROLLBAR          448
+                                        
+-#define STR_COUNT                   449
++#define STR_UNDO_SET_TAB_BG_COLOR   449
++  
++#define STR_COUNT                   450
+ 
+ #endif
+ 
 diff --git sc/inc/sc.hrc sc/inc/sc.hrc
-index 9fdc0ac..cf9c139 100644
+index 2eba0d8..f646b4a 100644
 --- sc/inc/sc.hrc
 +++ sc/inc/sc.hrc
-@@ -1663,6 +1663,10 @@
+@@ -1664,6 +1664,11 @@
  #define RID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 5)
  #define HID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 6)
  
++// 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_SET_TAB_BG_COLOR          (SC_OOO_BUILD_START + 9)
 +
  #endif
  
  
-diff --git sc/inc/table.hxx sc/inc/table.hxx
-index c4b7c0b..71a277d 100644
---- sc/inc/table.hxx
-+++ sc/inc/table.hxx
-@@ -151,6 +151,11 @@ private:
- 	USHORT			nScenarioFlags;
- 	BOOL			bActiveScenario;
- 
-+// TabBgColor -----------------------------------------------------------------
-+    Color           aTabBgColor;
-+    BOOL            bIsDefaultTabBgColor;
-+// TabBgColor -----------------------------------------------------------------
-+
- friend class ScDocument;					// fuer FillInfo
- friend class ScDocumentIterator;
- friend class ScValueIterator;
-@@ -219,6 +224,12 @@ public:
- 	void		GetCodeName( String& rName ) const {  rName = aCodeName; }
- 	void		SetCodeName( const String& rNewName ) { aCodeName = rNewName; }
+diff --git sc/inc/scextopt.hxx sc/inc/scextopt.hxx
+index 3464fbb..37c6cb0 100644
+--- sc/inc/scextopt.hxx
++++ sc/inc/scextopt.hxx
+@@ -81,6 +81,8 @@ struct ScExtTabSettings
+     bool                mbFrozenPanes;      /// true = Frozen panes; false = Normal splits.
+     bool                mbPageMode;         /// true = Pagebreak mode; false = Normal view mode.
+     bool                mbShowGrid;         /// Whether or not to display gridlines.
++    bool                mbIsDefaultTabBgColor;  /// true = draw default tab color
++    Color               maTabBgColor;           /// Tab Bg Color
  
-+// TabBgColor -----------------------------------------------------------------
-+    void        GetTabBgColor( Color& rColor ) const;
-+    void        SetTabBgColor( const Color& rNewColor );
-+    BOOL        IsDefaultTabBgColor() const                 { return bIsDefaultTabBgColor; };
-+// TabBgColor -----------------------------------------------------------------
-+
-     const String&   GetUpperName() const;
+     explicit            ScExtTabSettings();
+ };
+diff --git sc/inc/unonames.hxx sc/inc/unonames.hxx
+index 253c197..a348e69 100644
+--- sc/inc/unonames.hxx
++++ sc/inc/unonames.hxx
+@@ -529,6 +529,7 @@
+ #define SC_UNO_ZOOMVALUE            "ZoomValue"
+ #define SC_UNO_UPDTEMPL             "UpdateFromTemplate"
+ #define SC_UNO_FILTERED_RANGE_SELECTION       "FilteredRangeSelection"
++#define SC_UNO_TABCOLOR             "TabColor"
+ /*Stampit enable/disable print cancel */
+ #define SC_UNO_ALLOWPRINTJOBCANCEL  "AllowPrintJobCancel"
  
- 	const String&	GetPageStyle() const					{ return aPageStyle; }
 diff --git sc/sdi/docsh.sdi sc/sdi/docsh.sdi
-index 16dff9a..a5ff00c 100644
+index 16dff9a..4ee3d4c 100644
 --- sc/sdi/docsh.sdi
 +++ sc/sdi/docsh.sdi
-@@ -62,6 +62,9 @@ interface TableSelection
+@@ -62,6 +62,7 @@ interface TableSelection
  	FID_TAB_MOVE		[ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
  	FID_DELETE_TABLE	[ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
  	FID_TAB_RENAME		[ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
-+// TabBgColor -----------------------------------------------------------------
-+	FID_TAB_SET_TAB_BG_COLOR		[ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
-+// TabBgColor -----------------------------------------------------------------
++    FID_TAB_SET_TAB_BG_COLOR    [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
  	FID_TAB_RTL			[ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
      FID_TAB_TOGGLE_GRID [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
  
 diff --git sc/sdi/scalc.sdi sc/sdi/scalc.sdi
-index 254442f..9dba779 100644
+index 254442f..2e1ec8c 100644
 --- sc/sdi/scalc.sdi
 +++ sc/sdi/scalc.sdi
-@@ -7875,4 +7875,56 @@ SfxBoolItem ToggleSheetGrid FID_TAB_TOGGLE_GRID
-     GroupId = GID_FORMAT;
+@@ -7851,6 +7851,58 @@ SfxVoidItem ShareDocument SID_SHARE_DOC
  ]
  
-+// TabBgColor -----------------------------------------------------------------
-+//--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
 +SvxColorItem TabBgColor FID_TAB_SET_TAB_BG_COLOR
 +
 +[
@@ -109,7 +120,7 @@
 +    ToolBoxConfig = FALSE,
 +    GroupId = GID_FORMAT;
 +]
- 
++
 +//--------------------------------------------------------------------------
 +SfxVoidItem SetTabBgColor FID_TAB_MENU_SET_TAB_BG_COLOR
 +(SvxColorItem TabBgColor FID_TAB_SET_TAB_BG_COLOR)
@@ -134,177 +145,73 @@
 +    ToolBoxConfig = FALSE,
 +    GroupId = GID_FORMAT;
 +]
-+// TabBgColor -----------------------------------------------------------------
++
++//--------------------------------------------------------------------------
+ SfxBoolItem ToggleSheetGrid FID_TAB_TOGGLE_GRID
+ 
+ [
 diff --git sc/sdi/tabvwsh.sdi sc/sdi/tabvwsh.sdi
-index bd51c83..a2c68dd 100644
+index bd51c83..8cc0ac4 100644
 --- sc/sdi/tabvwsh.sdi
 +++ sc/sdi/tabvwsh.sdi
-@@ -60,6 +60,9 @@ interface Tables
+@@ -60,6 +60,7 @@ interface Tables
  	FID_TABLE_HIDE	[ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
  	FID_TABLE_SHOW	[ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
          SID_SELECT_TABLES       [ ExecMethod = Execute; StateMethod = GetState; ]
-+// TabBgColor -----------------------------------------------------------------
 +    FID_TAB_MENU_SET_TAB_BG_COLOR   [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ]
-+// TabBgColor -----------------------------------------------------------------
  }
  
   // ===========================================================================
-diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
-index 0bba4fc..7058b4e 100644
---- sc/source/core/data/document.cxx
-+++ sc/source/core/data/document.cxx
-@@ -516,6 +516,69 @@ BOOL ScDocument::RenameTab( SCTAB nTab, const String& rName, BOOL /* bUpdateRef
- 	return bValid;
- }
- 
-+// TabBgColor -----------------------------------------------------------------
-+BOOL ScDocument::SetTabBgColor( SCTAB nTab, const Color& rColor, BOOL /* bUpdateRef*/, 
-+                               BOOL /*bExternalDocument*/ ) //TODO Fix parameters while setting up undo
-+{
-+    BOOL    bValid = FALSE;
-+    if (VALIDTAB(nTab))
-+        if (pTab[nTab])
-+        {
-+            bValid = TRUE;
-+/* TODO Fix this
-+            if ( bExternalDocument )
-+                bValid = TRUE;      // zusammengesetzter Name
-+            else
-+                bValid = ValidTabName(rName);
-+            for (i=0; (i<=MAXTAB) && bValid; i++)
-+                if (pTab[i] && (i != nTab))
-+                {
-+                    String aOldName;
-+                    pTab[i]->GetName(aOldName);
-+                    bValid = !ScGlobal::pTransliteration->isEqual( rName, aOldName );
-+                }
-+*/
-+            if (bValid)
-+            {
-+                pTab[nTab]->SetTabBgColor(rColor);
-+            }
-+        }
-+    return bValid;
-+}
-+
-+Color ScDocument::GetTabBgColor( SCTAB nTab ) const
-+{
-+    Color rColor;
-+    if (VALIDTAB(nTab))
-+    {
-+        if (pTab[nTab])
-+        {
-+            pTab[nTab]->GetTabBgColor(rColor);
-+            return rColor;
-+        } else {
-+            return FALSE;
-+        }
-+    } else {
-+        return FALSE;
-+    }
-+}
-+
-+BOOL ScDocument::IsDefaultTabBgColor( SCTAB nTab ) const
-+{
-+    Color rColor;
-+    if (VALIDTAB(nTab))
-+    {
-+        if (pTab[nTab])
-+        {
-+            return pTab[nTab]->IsDefaultTabBgColor();
-+        } else {
-+            return TRUE;
-+        }
-+    } else {
-+        return TRUE;
-+    }
-+}
-+// TabBgColor -----------------------------------------------------------------
- 
- void ScDocument::SetVisible( SCTAB nTab, BOOL bVisible )
- {
-diff --git sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
-index d32c1d0..7f61128 100644
---- sc/source/core/data/table1.cxx
-+++ sc/source/core/data/table1.cxx
-@@ -155,7 +155,11 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
- 	pScenarioRanges( NULL ),
- 	aScenarioColor( COL_LIGHTGRAY ),
- 	nScenarioFlags( 0 ),
--	bActiveScenario( FALSE )
-+	bActiveScenario( FALSE ),
-+// TabBgColor -----------------------------------------------------------------
-+    aTabBgColor( COL_LIGHTGRAY ),
-+    bIsDefaultTabBgColor( TRUE )
-+// TabBgColor -----------------------------------------------------------------
- {
- 
- 	if (bColInfo)
-@@ -246,6 +250,23 @@ const String& ScTable::GetUpperName() const
-     return aUpperName;
- }
- 
-+// TabBgColor -----------------------------------------------------------------
-+void ScTable::GetTabBgColor( Color& rColor ) const
-+{
-+    rColor = aTabBgColor;
-+}
-+
-+void ScTable::SetTabBgColor( const Color& rNewColor )
-+{
-+    aTabBgColor = rNewColor;
-+    //TODO: Take this hard coded color out and reference the style settings...
-+    if ( aTabBgColor != Color( COL_LIGHTGRAY) )
-+        bIsDefaultTabBgColor = FALSE;
-+    else
-+        bIsDefaultTabBgColor = TRUE;
-+}
-+// TabBgColor -----------------------------------------------------------------
-+
- void ScTable::SetVisible( BOOL bVis )
- {
- 	bVisible = bVis;
 diff --git sc/source/filter/excel/read.cxx sc/source/filter/excel/read.cxx
-index 5e747ca..49a2826 100644
+index 5e747ca..aa2b377 100644
 --- sc/source/filter/excel/read.cxx
 +++ sc/source/filter/excel/read.cxx
-@@ -1157,6 +1157,14 @@ FltError ImportExcel8::Read( void )
+@@ -1157,6 +1157,9 @@ FltError ImportExcel8::Read( void )
                      case EXC_ID_SXVDEX:         rPTableMgr.ReadSxvdex( maStrm );    break;
                      case EXC_ID_SXEX:           rPTableMgr.ReadSxex( maStrm );      break;
                      case EXC_ID_SXVIEWEX9:      rPTableMgr.ReadSxViewEx9( maStrm ); break;
-+// TabBgColor -----------------------------------------------------------------
-+                        //TODO: GET REAL ID
-+                    case 0x0862:
-+                        {
-+                            rPageSett.ReadTabBgColor( maStrm, rPal );
-+                        }
-+                    break;
-+// TabBgColor -----------------------------------------------------------------
++
++                    // 0x0862 (SHEETEXT)
++                    case EXC_ID_SHEETEXT:       rTabViewSett.ReadTabBgColor( maStrm, rPal );    break;
                  }
  			}
              break;
-diff --git sc/source/filter/excel/xepage.cxx sc/source/filter/excel/xepage.cxx
-index c43fc15..bee7daa 100644
---- sc/source/filter/excel/xepage.cxx
-+++ sc/source/filter/excel/xepage.cxx
-@@ -108,6 +108,35 @@ void XclExpSetup::WriteBody( XclExpStream& rStrm )
-     }
+diff --git sc/source/filter/excel/xestyle.cxx sc/source/filter/excel/xestyle.cxx
+index d93eec3..de32a64 100644
+--- sc/source/filter/excel/xestyle.cxx
++++ 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 sc/source/filter/excel/xeview.cxx sc/source/filter/excel/xeview.cxx
+index 1ee104c..9f6daae 100644
+--- sc/source/filter/excel/xeview.cxx
++++ sc/source/filter/excel/xeview.cxx
+@@ -259,6 +259,36 @@ void XclExpSelection::WriteBody( XclExpStream& rStrm )
+     maSelData.maXclSelection.Write( rStrm, false );
  }
  
-+// TabBgColor -----------------------------------------------------------------
-+XclExpTabColor::XclExpTabColor( const XclPageData& rPageData ) :
-+    XclExpRecord( 0x0862, 18 ), //TODO Use Real ID!
-+    mrData( rPageData )
++// ----------------------------------------------------------------------------
++
++XclExpTabBgColor::XclExpTabBgColor( const XclTabViewData& rTabViewData ) :
++//    XclExpRecord( 0x0862, 18 ), //TODO Use Real ID!
++    XclExpRecord( EXC_ID_SHEETEXT, 18 ), //TODO Use Real ID!
++    mrTabViewData( rTabViewData )
 +{
 +}
 +//TODO Fix savexml...
-+/*void XclExpTabColor::SaveXml( XclExpXmlStream& rStrm )
++/*void XclExpTabBgColor::SaveXml( XclExpXmlStream& rStrm )
 +{
 +}*/
 +
-+void XclExpTabColor::WriteBody( XclExpStream& rStrm )
++void XclExpTabBgColor::WriteBody( XclExpStream& rStrm )
 +{
-+    if ( mrData.mbIsDefaultTabBgColor )
++    if ( mrTabViewData.mbIsDefaultTabBgColor )
 +        return;
 +    sal_uInt16 rt = 0x0862; //rt
 +    sal_uInt16 grbitFrt = 0x0000; //grbit must be set to 0
@@ -313,96 +220,76 @@
 +    sal_uInt16 reserved = 0x0000; //trailing bits are 0
 +    sal_uInt16 TabBgColorIndex;
 +    XclExpPalette& rPal = rStrm.GetRoot().GetPalette();
-+    TabBgColorIndex = rPal.GetColorIndex(mrData.mnTabBgColorId);
++    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;
 +}
-+// TabBgColor -----------------------------------------------------------------
 +
- // Manual page breaks ---------------------------------------------------------
+ // Sheet view settings ========================================================
  
- XclExpPageBreaks::XclExpPageBreaks( sal_uInt16 nRecId, const ScfUInt16Vec& rPageBreaks, sal_uInt16 nMaxPos ) :
-@@ -197,6 +226,16 @@ XclExpPageSettings::XclExpPageSettings( const XclExpRoot& rRoot ) :
-             maData.mnScaling = nScale;
-             maData.mbFitToPages = false;
-         }
-+		
-+// TabBgColor -----------------------------------------------------------------
-+        if ( GetBiff() == EXC_BIFF8 && !rDoc.IsDefaultTabBgColor(nScTab) )
+ namespace {
+@@ -368,6 +398,15 @@ 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.mbIsDefaultTabBgColor )
 +        {
 +            XclExpPalette& rPal = GetPalette();
 +            maData.mbIsDefaultTabBgColor = false;
-+            maData.maTabBgColor = rDoc.GetTabBgColor(nScTab);
++            maData.maTabBgColor = rTabSett.maTabBgColor;
 +            maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG );
 +        }
-+// TabBgColor -----------------------------------------------------------------
+     }
+ }
  
-         maData.mxBrushItem.reset( new SvxBrushItem( GETITEM( rItemSet, SvxBrushItem, ATTR_BACKGROUND ) ) );
+@@ -380,6 +419,7 @@ void XclExpTabViewSettings::Save( XclExpStream& rStrm )
+     WriteSelection( rStrm, EXC_PANE_TOPRIGHT );
+     WriteSelection( rStrm, EXC_PANE_BOTTOMLEFT );
+     WriteSelection( rStrm, EXC_PANE_BOTTOMRIGHT );
++    WriteTabBgColor( rStrm );
+ }
  
-@@ -271,6 +310,12 @@ void XclExpPageSettings::Save( XclExpStream& rStrm )
-     XclExpDoubleRecord( EXC_ID_BOTTOMMARGIN, maData.mfBottomMargin ).Save( rStrm );
-     XclExpSetup( maData ).Save( rStrm );
+ static void lcl_WriteSelection( XclExpXmlStream& rStrm, const XclTabViewData& rData, sal_uInt8 nPane )
+@@ -494,5 +534,10 @@ void XclExpTabViewSettings::WriteSelection( XclExpStream& rStrm, sal_uInt8 nPane
+         XclExpSelection( maData, nPane ).Save( rStrm );
+ }
  
-+// TabBgColor -----------------------------------------------------------------
-+//  TODO I think this is where I need to inject bits for tab colors
++void XclExpTabViewSettings::WriteTabBgColor( XclExpStream& rStrm ) const
++{
 +    if ( !maData.mbIsDefaultTabBgColor )
-+        XclExpTabColor( maData ).Save( rStrm );
-+// TabBgColor -----------------------------------------------------------------
-+
-     if( (GetBiff() == EXC_BIFF8) && maData.mxBrushItem.get() )
-         if( const Graphic* pGraphic = maData.mxBrushItem->GetGraphic() )
-             XclExpImgData( *pGraphic, EXC_ID8_IMGDATA ).Save( rStrm );
-diff --git sc/source/filter/excel/xestyle.cxx sc/source/filter/excel/xestyle.cxx
-index 115f1e8..651473b 100644
---- sc/source/filter/excel/xestyle.cxx
-+++ sc/source/filter/excel/xestyle.cxx
-@@ -70,6 +70,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" );
++        XclExpTabBgColor( maData ).Save( rStrm );
++}
+ // ============================================================================
+ 
 diff --git sc/source/filter/excel/xichart.cxx sc/source/filter/excel/xichart.cxx
-index 255c7e7..31acf41 100644
+index 99613dc..530aeca 100644
 --- sc/source/filter/excel/xichart.cxx
 +++ sc/source/filter/excel/xichart.cxx
-@@ -3566,6 +3566,15 @@ void XclImpChart::ReadChartSubStream( XclImpStream& rStrm )
+@@ -3566,6 +3566,12 @@ void XclImpChart::ReadChartSubStream( XclImpStream& rStrm )
  
              case EXC_ID_WINDOW2:        rTabViewSett.ReadWindow2( rStrm, true );break;
              case EXC_ID_SCL:            rTabViewSett.ReadScl( rStrm );          break;
-+// TabBgColor -----------------------------------------------------------------
-+            //TODO use a real id!!
-+            case 0x0862:
++            case EXC_ID_SHEETEXT: //0x0862
 +            {
 +                XclImpPalette& rPal = GetPalette();
-+                rPageSett.ReadTabBgColor( rStrm,  rPal);
-+                break;
++                rTabViewSett.ReadTabBgColor( rStrm,  rPal);
 +            }
-+// TabBgColor -----------------------------------------------------------------
++            break;
          }
  
          switch( rStrm.GetRecId() )
-diff --git sc/source/filter/excel/xipage.cxx sc/source/filter/excel/xipage.cxx
-index 2a52521..b0ee137 100644
---- sc/source/filter/excel/xipage.cxx
-+++ sc/source/filter/excel/xipage.cxx
-@@ -47,6 +47,7 @@
- #include "xistream.hxx"
- #include "xihelper.hxx"
- #include "xiescher.hxx"
-+#include "xistyle.hxx"
- 
- // Page settings ==============================================================
- 
-@@ -91,6 +92,27 @@ void XclImpPageSettings::ReadSetup( XclImpStream& rStrm )
-     }
+diff --git sc/source/filter/excel/xiview.cxx sc/source/filter/excel/xiview.cxx
+index 55525ad..3d62836 100644
+--- sc/source/filter/excel/xiview.cxx
++++ sc/source/filter/excel/xiview.cxx
+@@ -109,6 +109,25 @@ void XclImpTabViewSettings::Initialize()
+     maData.SetDefaults();
  }
  
-+// TabBgColor -----------------------------------------------------------------
-+void XclImpPageSettings::ReadTabBgColor( XclImpStream& rStrm, XclImpPalette& rPal )
++void XclImpTabViewSettings::ReadTabBgColor( XclImpStream& rStrm, XclImpPalette& rPal )
 +{
 +    DBG_ASSERT_BIFF( GetBiff() >= EXC_BIFF8 );
 +    if( GetBiff() < EXC_BIFF8 )
@@ -410,9 +297,9 @@
 +
 +    sal_uInt8 ColorIndex;
 +    Color TabBgColor;
-+    
++
 +    rStrm.Ignore( 16 );
-+    ColorIndex = rStrm.ReaduInt8() & 0x7F;
++    ColorIndex = rStrm.ReaduInt8() & EXC_SHEETEXT_TABCOLOR; //0x7F
 +    if ( ColorIndex >= 8 && ColorIndex <= 63 ) //only accept valid index values
 +    {
 +        TabBgColor = rPal.GetColor( ColorIndex );
@@ -420,87 +307,39 @@
 +        maData.mbIsDefaultTabBgColor = false;
 +    }
 +}
-+// TabBgColor -----------------------------------------------------------------
 +
- void XclImpPageSettings::ReadMargin( XclImpStream& rStrm )
+ void XclImpTabViewSettings::ReadWindow2( XclImpStream& rStrm, bool bChart )
  {
-     switch( rStrm.GetRecId() )
-@@ -387,6 +409,22 @@ void XclImpPageSettings::Finalize()
-         if( nScCol <= MAXCOL )
-             rDoc.SetColFlags( nScCol, nScTab, rDoc.GetColFlags( nScCol, nScTab ) | CR_MANUALBREAK );
+     if( GetBiff() == EXC_BIFF2 )
+@@ -281,6 +300,13 @@ void XclImpTabViewSettings::Finalize()
+         aViewOpt.SetOption( VOPT_OUTLINER, maData.mbShowOutline );
+         rDoc.SetViewOptions( aViewOpt );
      }
-+// TabBgColor -----------------------------------------------------------------
++
 +    // *** set tab bg color
 +    if (!maData.mbIsDefaultTabBgColor)
 +    {
-+//      TODO: Fix this wile setting up Undo
-+        /* rDoc.SetTabBgColor (SCTAB        , 
-+                               const Color& rColor, 
-+                               BOOL bUpdateRef, ???< Should be for setting up undo...
-+                               BOOL bExternalDocument, ???< does being an external 
-+                                                            document affect colored tabs? 
-+                                                            if not, then this function 
-+                                                            needs to be reworked,thought through)
-+         */
-+        BOOL bSuccess = rDoc.SetTabBgColor( nScTab, maData.maTabBgColor );
++        rTabSett.mbIsDefaultTabBgColor = maData.mbIsDefaultTabBgColor;
++        rTabSett.maTabBgColor = maData.maTabBgColor;
 +    }
-+// TabBgColor -----------------------------------------------------------------
  }
  
  // ============================================================================
-diff --git sc/source/filter/excel/xlpage.cxx sc/source/filter/excel/xlpage.cxx
-index e9a8142..7933204 100644
---- sc/source/filter/excel/xlpage.cxx
-+++ sc/source/filter/excel/xlpage.cxx
-@@ -184,6 +184,9 @@ void XclPageData::SetDefaults()
-     mbPortrait = true;
-     mbPrintInRows = mbBlackWhite = mbDraftQuality = mbPrintNotes = mbManualStart = mbFitToPages = false;
-     mbHorCenter = mbVerCenter = mbPrintHeadings = mbPrintGrid = false;
-+// TabBgColor -----------------------------------------------------------------
+diff --git sc/source/filter/excel/xlview.cxx sc/source/filter/excel/xlview.cxx
+index 080075b..2b8c50d 100644
+--- sc/source/filter/excel/xlview.cxx
++++ sc/source/filter/excel/xlview.cxx
+@@ -79,6 +79,8 @@ void XclTabViewData::SetDefaults()
+     mbDefGridColor = true;
+     mbShowFormulas = false;
+     mbShowGrid = mbShowHeadings = mbShowZeros = mbShowOutline = true;
 +    mbIsDefaultTabBgColor = true;
-+// TabBgColor -----------------------------------------------------------------
++    maTabBgColor.SetColor( COL_AUTO );
  }
  
- Size XclPageData::GetScPaperSize() const
-diff --git sc/source/filter/inc/xepage.hxx sc/source/filter/inc/xepage.hxx
-index 7653cf3..0936b45 100644
---- sc/source/filter/inc/xepage.hxx
-+++ sc/source/filter/inc/xepage.hxx
-@@ -34,6 +34,9 @@
- #include "xlpage.hxx"
- #include "xeroot.hxx"
- #include "xerecord.hxx"
-+// TabBgColor -----------------------------------------------------------------
-+#include "xestyle.hxx"
-+// TabBgColor -----------------------------------------------------------------
- 
- // Page settings records ======================================================
- 
-@@ -69,6 +72,22 @@ private:
-     const XclPageData&  mrData;             /// Page settings data of current sheet.
- };
- 
-+// TabBgColor -----------------------------------------------------------------
-+class XclExpTabColor : public XclExpRecord
-+{
-+public:
-+    explicit            XclExpTabColor( const XclPageData& rPageData );
-+
-+    /* virtual void        SaveXml( XclExpXmlStream& rStrm ); */
-+private:
-+    /** Writes the contents of the SHEETEXT record. */
-+    virtual void        WriteBody( XclExpStream& rStrm );
-+
-+private:
-+    const XclPageData&  mrData;             /// Page settings data of current sheet.
-+};
-+// TabBgColor -----------------------------------------------------------------
-+
- // Manual page breaks ---------------------------------------------------------
- 
- /** Stores an array of manual page breaks for columns or rows. */
+ bool XclTabViewData::IsSplit() const
 diff --git sc/source/filter/inc/xestyle.hxx sc/source/filter/inc/xestyle.hxx
-index 8a17a74..77394a2 100644
+index 8485bb1..9508c8b 100644
 --- sc/source/filter/inc/xestyle.hxx
 +++ sc/source/filter/inc/xestyle.hxx
 @@ -61,7 +61,8 @@ enum XclExpColorType
@@ -513,96 +352,118 @@
  };
  
  // ----------------------------------------------------------------------------
-diff --git sc/source/filter/inc/xipage.hxx sc/source/filter/inc/xipage.hxx
-index 3b05241..bf2b5cb 100644
---- sc/source/filter/inc/xipage.hxx
-+++ sc/source/filter/inc/xipage.hxx
-@@ -51,6 +51,10 @@ public:
+diff --git sc/source/filter/inc/xeview.hxx sc/source/filter/inc/xeview.hxx
+index 4d8b10d..5c54ecd 100644
+--- sc/source/filter/inc/xeview.hxx
++++ sc/source/filter/inc/xeview.hxx
+@@ -134,6 +134,20 @@ private:
+     sal_uInt8           mnPane;             /// Pane identifier of this selection.
+ };
  
-     /** Reads a SETUP record and inserts contained data. */
-     void                ReadSetup( XclImpStream& rStrm );
-+// TabBgColor -----------------------------------------------------------------
-+    /** Reads a 0x0862 record (Tab Bg Color). */
-+    void                ReadTabBgColor( XclImpStream& rStrm, XclImpPalette& rPal );
-+// TabBgColor -----------------------------------------------------------------
-     /** Reads a ***MARGIN record (reads all 4 margin records). */
-     void                ReadMargin( XclImpStream& rStrm );
-     /** Reads a HCENTER or VCENTER record. */
-diff --git sc/source/filter/inc/xlpage.hxx sc/source/filter/inc/xlpage.hxx
-index 5933997..07a1634 100644
---- sc/source/filter/inc/xlpage.hxx
-+++ sc/source/filter/inc/xlpage.hxx
-@@ -33,6 +33,9 @@
++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 ==============================================================
  
- #include <tools/gen.hxx>
- #include "xltools.hxx"
-+// TabBgColor -----------------------------------------------------------------
-+#include <tools/color.hxx>
-+// TabBgColor -----------------------------------------------------------------
+ /** 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 sc/source/filter/inc/xiview.hxx sc/source/filter/inc/xiview.hxx
+index f0b393e..a54c67b 100644
+--- sc/source/filter/inc/xiview.hxx
++++ 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();
  
- // Constants and Enumerations =================================================
+diff --git sc/source/filter/inc/xlview.hxx sc/source/filter/inc/xlview.hxx
+index 4a3798e..c78979b 100644
+--- sc/source/filter/inc/xlview.hxx
++++ sc/source/filter/inc/xlview.hxx
+@@ -89,6 +89,11 @@ const sal_uInt8 EXC_PANE_TOPLEFT            = 3;        /// Single, top, left, o
  
-@@ -141,6 +144,12 @@ struct XclPageData : ScfNoCopy
-     bool                mbPrintHeadings;    /// true = print column and row headings.
-     bool                mbPrintGrid;        /// true = print grid lines.
+ const sal_uInt16 EXC_ID_SCL                 = 0x00A0;
  
-+// TabBgColor -----------------------------------------------------------------
-+    bool                mbIsDefaultTabBgColor;  /// true = don't set tab color; false = set tab color; 
-+    Color               maTabBgColor;           /// Tab Color default = (COL_LIGHTGRAY )
-+    sal_uInt32          mnTabBgColorId;         /// pallette color id
-+// TabBgColor -----------------------------------------------------------------
++// (0x0862) SHEETEXT ----------------------------------------------------------
 +
-     explicit            XclPageData();
-                         ~XclPageData();
- 
-diff --git sc/source/filter/inc/xlstyle.hxx sc/source/filter/inc/xlstyle.hxx
-index 8973da7..8bc83cc 100644
---- sc/source/filter/inc/xlstyle.hxx
-+++ sc/source/filter/inc/xlstyle.hxx
-@@ -219,6 +219,7 @@ const sal_uInt16 EXC_COLOR_CHBORDERAUTO     = 79;       /// Automatic frame bord
- const sal_uInt16 EXC_COLOR_NOTEBACK         = 80;       /// Note background color.
- const sal_uInt16 EXC_COLOR_NOTETEXT         = 81;       /// Note text color.
- const sal_uInt16 EXC_COLOR_FONTAUTO         = 0x7FFF;   /// Font auto color (system window text color).
++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 ====================================================================
  
- // (0x0293) STYLE -------------------------------------------------------------
+ /** 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.
++    bool                mbIsDefaultTabBgColor;	/// true = don't set tab color; false = set tab color;
++    Color               maTabBgColor;           /// Tab Color default = (COL_AUTO )
++    sal_uInt32          mnTabBgColorId;         /// pallette color id
  
+     explicit            XclTabViewData();
+                         ~XclTabViewData();
 diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
-index a4f0cc6..b7fd459 100644
+index 5da446b..2e704fe 100644
 --- sc/source/ui/docshell/docfunc.cxx
 +++ sc/source/ui/docshell/docfunc.cxx
-@@ -2611,6 +2611,43 @@ BOOL ScDocFunc::RenameTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL
+@@ -2612,6 +2612,45 @@ BOOL ScDocFunc::RenameTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL
  	return bSuccess;
  }
  
-+// TabBgColor -----------------------------------------------------------------
-+// TODO Fix Undo
 +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() )
 +    {
 +        if (!bApi)
-+            rDocShell.ErrorMessage(STR_PROTECTIONERR);
++            rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Check to see what this string is...
 +        return FALSE;
 +    }
 +
-+    ScDocShellModificator aModificator( rDocShell );
++    ScViewData* pViewData = rDocShell.GetViewData();
++
++    Color aOldTabBgColor;
++    aOldTabBgColor = pViewData->GetTabBgColor(nTab);
 +
 +    BOOL bSuccess = FALSE;
-+    if (pDoc->SetTabBgColor( nTab, rColor ))
++    pViewData->SetTabBgColor(rColor, nTab);
++    if ( pViewData->GetTabBgColor( nTab ) == rColor)
++        bSuccess = TRUE;
++    if (bSuccess)
 +    {
 +        if (bRecord)
 +        {
-+            //TODO Add undo action! this is how renametab does it...
-+            /*
 +            rDocShell.GetUndoManager()->AddUndoAction(
-+                            new ScUndoRenameTab( &rDocShell, nTab, sOldName, rName));
-+            */
++                            new ScUndoSetTabBgColor( &rDocShell, nTab, aOldTabBgColor, rColor));
 +        }
 +        rDocShell.PostPaintExtras();
++        ScDocShellModificator aModificator( rDocShell );
 +        aModificator.SetDocumentModified();
 +        SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
 +
@@ -610,184 +471,334 @@
 +    }
 +    return bSuccess;
 +}
-+// TabBgColor -----------------------------------------------------------------
 +
  //------------------------------------------------------------------------
  
  //!	SetWidthOrHeight - noch doppelt zu ViewFunc !!!!!!
 diff --git sc/source/ui/inc/docfunc.hxx sc/source/ui/inc/docfunc.hxx
-index 8196546..8ce7845 100644
+index d2bbeaf..21d770d 100644
 --- sc/source/ui/inc/docfunc.hxx
 +++ sc/source/ui/inc/docfunc.hxx
-@@ -116,6 +116,10 @@ public:
+@@ -116,6 +116,8 @@ public:
  	BOOL			RenameTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi );
  	BOOL			DeleteTable( SCTAB nTab, BOOL bRecord, BOOL bApi );
  
-+// TabBgColor -----------------------------------------------------------------
 +    BOOL            SetTabBgColor( SCTAB nTab, const Color& rColor, BOOL bRecord, BOOL bApi );
-+// TabBgColor -----------------------------------------------------------------
 +
  	BOOL			SetTableVisible( SCTAB nTab, BOOL bVisible, BOOL bApi );
  
  	BOOL			SetLayoutRTL( SCTAB nTab, BOOL bRTL, BOOL bApi );
+diff --git sc/source/ui/inc/undotab.hxx sc/source/ui/inc/undotab.hxx
+index c2d4eb9..af05ade 100644
+--- sc/source/ui/inc/undotab.hxx
++++ sc/source/ui/inc/undotab.hxx
+@@ -226,6 +226,31 @@ private:
+ 	void DoChange() const;
+ };
+ 
++class ScUndoSetTabBgColor: public ScSimpleUndo
++{
++public:
++                    TYPEINFO();
++                    ScUndoSetTabBgColor(
++                            ScDocShell* pNewDocShell,
++                            SCTAB nT,
++                            const Color& aOTabBgColor,
++                            const Color& aNTabBgColor);
++    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;
++
++    void DoChange( SCTAB nTab, const Color& rTabBgColor ) const;
++};
+ 
+ class ScUndoMakeScenario: public ScSimpleUndo
+ {
+diff --git sc/source/ui/inc/viewdata.hxx sc/source/ui/inc/viewdata.hxx
+index afc4b75..17e3148 100644
+--- sc/source/ui/inc/viewdata.hxx
++++ sc/source/ui/inc/viewdata.hxx
+@@ -153,6 +153,9 @@ private:
+ 
+ 	BOOL			bOldCurValid;				// "virtuelle" Cursorpos. bei zusammengefassten
+ 
++    BOOL            bIsDefaultTabBgColor;
++    Color           aTabBgColor;
++
+ 					ScViewDataTable();
+ 					~ScViewDataTable();
+ 
+@@ -287,6 +290,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 sc/source/ui/inc/viewfunc.hxx sc/source/ui/inc/viewfunc.hxx
-index 72e2d96..a6a0599 100644
+index 72e2d96..e886dac 100644
 --- sc/source/ui/inc/viewfunc.hxx
 +++ sc/source/ui/inc/viewfunc.hxx
-@@ -276,6 +276,10 @@ public:
+@@ -276,6 +276,8 @@ public:
  									SCTAB nCount, const SCTAB* pSrcTabs,
  									BOOL bLink,SCTAB nTab);
  
-+// TabBgColor -----------------------------------------------------------------
 +    BOOL            SetTabBgColor( const Color& rColor, SCTAB nTabNr );
-+// TabBgColor -----------------------------------------------------------------
 +
  	void			InsertTableLink( const String& rFile,
  										const String& rFilter, const String& rOptions,
  										const String& rTabName );
 diff --git sc/source/ui/src/globstr.src sc/source/ui/src/globstr.src
-index 5d94238..9d6a513 100644
+index 6912e7a..77793d8 100644
 --- sc/source/ui/src/globstr.src
 +++ sc/source/ui/src/globstr.src
-@@ -1134,6 +1134,13 @@ Resource RID_GLOBSTR
+@@ -1134,6 +1134,10 @@ Resource RID_GLOBSTR
  	{
  		Text [ en-US ] = "Rename Sheet" ;
  	};
-+/* // TabBgColor --------------------------------------------------------------
-+// TODO: Fix this while setting up Undo
-+	String STR_UNDO_SET_TAB_BG_COLOR
-+	{
-+		Text [ en-US ] = "Set Tab Color" ;
-+	};
-+// TabBgColor -------------------------------------------------------------- */
++    String STR_UNDO_SET_TAB_BG_COLOR
++    {
++        Text [ en-US ] = "Set Tab Color" ;
++    };
  	String STR_UNDO_MOVE_TAB
  	{
  		Text [ en-US ] = "Move Sheets" ;
 diff --git sc/source/ui/src/popup.src sc/source/ui/src/popup.src
-index fddf2b5..88c8281 100644
+index 25cd641..9e6fd0c 100644
 --- sc/source/ui/src/popup.src
 +++ sc/source/ui/src/popup.src
-@@ -169,6 +169,14 @@ Menu RID_POPUP_TAB
+@@ -169,6 +169,12 @@ Menu RID_POPUP_TAB
  			HelpId = FID_TAB_MENU_RENAME ;
  			Text [ en-US ] = "~Rename Sheet..." ;
  		};
-+// TabBgColor -----------------------------------------------------------------
-+		MenuItem
-+		{
-+			Identifier = FID_TAB_MENU_SET_TAB_BG_COLOR ;
-+			HelpId = FID_TAB_MENU_SET_TAB_BG_COLOR ;
-+			Text [ en-US ] = "Set Tab ~Color..." ;
-+		};
-+// TabBgColor -----------------------------------------------------------------
++        MenuItem
++        {
++            Identifier = FID_TAB_MENU_SET_TAB_BG_COLOR ;
++            HelpId = FID_TAB_MENU_SET_TAB_BG_COLOR ;
++            Text [ en-US ] = "Set Tab ~Color..." ;
++        };
  		MenuItem
  		{
  			Identifier = FID_TAB_MOVE ;
 diff --git sc/source/ui/src/scstring.src sc/source/ui/src/scstring.src
-index ed03d74..9851aa6 100644
+index ed03d74..19f9087 100644
 --- sc/source/ui/src/scstring.src
 +++ sc/source/ui/src/scstring.src
-@@ -283,6 +283,12 @@ String SCSTR_RENAMETAB
+@@ -283,6 +283,10 @@ String SCSTR_RENAMETAB
  {
  	Text [ en-US ] = "Rename Sheet" ;
  };
-+// TabBgColor -----------------------------------------------------------------
 +String SCSTR_SET_TAB_BG_COLOR
 +{
-+	Text [ en-US ] = "Set Tab Color" ;
++    Text [ en-US ] = "Set Tab Color" ;
 +};
-+// TabBgColor -----------------------------------------------------------------
  String SCSTR_RENAMEOBJECT
  {
  	Text [ en-US ] = "Name Object";
+diff --git sc/source/ui/undo/undotab.cxx sc/source/ui/undo/undotab.cxx
+index df3ab6f..b185d9a 100644
+--- sc/source/ui/undo/undotab.cxx
++++ 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);
+ TYPEINIT1(ScUndoSetGrammar,		SfxUndoAction);
++TYPEINIT1(ScUndoSetTabBgColor,  SfxUndoAction);
+ 
+ 
+ // -----------------------------------------------------------------------
+@@ -779,6 +783,73 @@ BOOL ScUndoCopyTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+ 	return FALSE;
+ }
+ 
++//---------------------------------------------------------------------------------
++//
++//      Tab Bg Color
++//
++
++ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell* pNewDocShell,
++                                    SCTAB nT,
++//                                      const BOOL& bOIsDefaultTabBgColor, 
++//                                      const BOOL& bNIsDefaultTabBgColor,
++                                        const Color& aOTabBgColor, 
++                                        const Color& aNTabBgColor) :
++    ScSimpleUndo( pNewDocShell ),
++    nTab 	 ( nT )
++{
++//  bOldIsDefaultTabBgColor = bOIsDefaultTabBgColor;
++//  bNewIsDefaultTabBgColor = bNIsDefaultTabBgColor;
++    aOldTabBgColor = aOTabBgColor;
++    aNewTabBgColor = aNTabBgColor;
++}
++
++__EXPORT ScUndoSetTabBgColor::~ScUndoSetTabBgColor()
++{
++}
++
++String __EXPORT ScUndoSetTabBgColor::GetComment() const
++{
++    return ScGlobal::GetRscString( STR_UNDO_SET_TAB_BG_COLOR );
++}
++
++void ScUndoSetTabBgColor::DoChange( SCTAB nTabP, const Color& rTabBgColor ) const
++{
++    ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
++    if (pViewShell)
++    {
++        ScViewData* pViewData = pViewShell->GetViewData();
++        if (pViewData)
++        {
++            pViewData->SetTabNo(nTabP);
++            pViewData->SetTabBgColor( rTabBgColor, nTabP );
++            SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );	// Navigator
++            pDocShell->PostPaintGridAll();
++            pDocShell->PostPaintExtras();
++            pDocShell->PostDataChanged();
++            pViewShell->UpdateInputHandler();
++        }
++    }
++}
++
++void __EXPORT ScUndoSetTabBgColor::Undo()
++{
++    DoChange(nTab, aOldTabBgColor);
++}
++
++void __EXPORT ScUndoSetTabBgColor::Redo()
++{
++    DoChange(nTab, aNewTabBgColor);
++}
++
++void __EXPORT ScUndoSetTabBgColor::Repeat(SfxRepeatTarget& /* rTarget */)
++{
++	//	No Repeat
++}
++
++BOOL __EXPORT ScUndoSetTabBgColor::CanRepeat(SfxRepeatTarget& /* rTarget */) const
++{
++    return FALSE;
++}
+ 
+ // -----------------------------------------------------------------------
+ //
+diff --git sc/source/ui/view/scextopt.cxx sc/source/ui/view/scextopt.cxx
+index 3ab9e7b..fb7162f 100644
+--- sc/source/ui/view/scextopt.cxx
++++ sc/source/ui/view/scextopt.cxx
+@@ -62,7 +62,9 @@ ScExtTabSettings::ScExtTabSettings() :
+     mbSelected( false ),
+     mbFrozenPanes( false ),
+     mbPageMode( false ),
+-    mbShowGrid( true )
++    mbShowGrid( true ),
++    mbIsDefaultTabBgColor( true ),
++    maTabBgColor( COL_AUTO)
+ {
+ }
+ 
 diff --git sc/source/ui/view/tabcont.cxx sc/source/ui/view/tabcont.cxx
-index 5117f2b..9b59119 100644
+index 5117f2b..30c7dcb 100644
 --- sc/source/ui/view/tabcont.cxx
 +++ sc/source/ui/view/tabcont.cxx
-@@ -68,6 +68,9 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) :
+@@ -68,6 +68,7 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) :
  	ScDocument* pDoc = pViewData->GetDocument();
  
  	String aString;
-+// TabBgColor -----------------------------------------------------------------
 +    Color aTabBgColor;
-+// TabBgColor -----------------------------------------------------------------
  	SCTAB nCount = pDoc->GetTableCount();
  	for (SCTAB i=0; i<nCount; i++)
  	{
-@@ -79,6 +82,13 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) :
+@@ -79,6 +80,12 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) :
  					InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL );
  				else
  					InsertPage( static_cast<sal_uInt16>(i)+1, aString );
-+// TabBgColor -----------------------------------------------------------------
-+                if ( !pDoc->IsDefaultTabBgColor(i) )
++
++                if ( !pViewData->IsDefaultTabBgColor(i) )
 +                {
-+                    aTabBgColor = pDoc->GetTabBgColor(i);
-+                    SetTabBgColor(static_cast<sal_uInt16>(i)+1, aTabBgColor, pDoc->IsDefaultTabBgColor(i) );
++                    aTabBgColor = pViewData->GetTabBgColor(i);
++                    SetTabBgColor(static_cast<sal_uInt16>(i)+1, aTabBgColor, pViewData->IsDefaultTabBgColor(i) );
 +                }
-+// TabBgColor -----------------------------------------------------------------
  			}
  		}
  	}
-@@ -259,6 +269,9 @@ void ScTabControl::Select()
+@@ -259,6 +266,7 @@ void ScTabControl::Select()
  	rBind.Invalidate( FID_DELETE_TABLE );
  	rBind.Invalidate( FID_TABLE_SHOW );
  	rBind.Invalidate( FID_TABLE_HIDE );
-+// TabBgColor -----------------------------------------------------------------
 +    rBind.Invalidate( FID_TAB_SET_TAB_BG_COLOR );
-+// TabBgColor -----------------------------------------------------------------
  
  		//	SetReference nur wenn der Konsolidieren-Dialog offen ist
  		//	(fuer Referenzen ueber mehrere Tabellen)
-@@ -285,16 +298,26 @@ void ScTabControl::UpdateStatus()
+@@ -285,16 +293,22 @@ void ScTabControl::UpdateStatus()
  	SCTAB i;
  	String aString;
  	SCTAB nMaxCnt = Max( nCount, static_cast<SCTAB>(GetMaxId()) );
-+// TabBgColor -----------------------------------------------------------------
-+	Color aTabBgColor;
-+// TabBgColor -----------------------------------------------------------------
++    Color aTabBgColor;
  
  	BOOL bModified = FALSE;										// Tabellen-Namen
  	for (i=0; i<nMaxCnt && !bModified; i++)
  	{
  		if (pDoc->IsVisible(i))
-+		{
++        {
  			pDoc->GetName(i,aString);
-+// TabBgColor -----------------------------------------------------------------
-+			aTabBgColor = pDoc->GetTabBgColor(i);
-+// TabBgColor -----------------------------------------------------------------
-+		}
++            aTabBgColor = pViewData->GetTabBgColor(i);
++        }
  		else
-+		{
++        {
  			aString.Erase();
-+		}
++        }
  
 -		if (GetPageText(static_cast<sal_uInt16>(i)+1) != aString)
-+		if ( (GetPageText(static_cast<sal_uInt16>(i)+1) != aString) || (GetTabBgColor(static_cast<sal_uInt16>(i)+1) != aTabBgColor) )
++        if ( (GetPageText(static_cast<sal_uInt16>(i)+1) != aString) || (GetTabBgColor(static_cast<sal_uInt16>(i)+1) != aTabBgColor) )
  			bModified = TRUE;
  	}
  
-@@ -311,6 +334,13 @@ void ScTabControl::UpdateStatus()
+@@ -311,6 +325,11 @@ void ScTabControl::UpdateStatus()
  						InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL );
  					else
  						InsertPage( static_cast<sal_uInt16>(i)+1, aString );
-+// TabBgColor -----------------------------------------------------------------
-+					if ( !pDoc->IsDefaultTabBgColor(i) )
-+					{
-+						aTabBgColor = pDoc->GetTabBgColor(i);
-+						SetTabBgColor(static_cast<sal_uInt16>(i)+1, aTabBgColor, pDoc->IsDefaultTabBgColor(i));
-+					}
-+// TabBgColor -----------------------------------------------------------------
++                    if ( !pViewData->IsDefaultTabBgColor(i) )
++                    {
++                        aTabBgColor = pViewData->GetTabBgColor(i);
++                        SetTabBgColor(static_cast<sal_uInt16>(i)+1, aTabBgColor, pViewData->IsDefaultTabBgColor(i));
++                    }
  				}
  			}
  		}
 diff --git sc/source/ui/view/tabvwshf.cxx sc/source/ui/view/tabvwshf.cxx
-index 6987883..dc17fc2 100644
+index 6987883..9f2f15b 100644
 --- sc/source/ui/view/tabvwshf.cxx
 +++ sc/source/ui/view/tabvwshf.cxx
-@@ -60,6 +60,12 @@
+@@ -60,6 +60,13 @@
  
  #include "scabstdlg.hxx" //CHINA001
  
 +// TabBgColor -----------------------------------------------------------------
++//TODO Clean up includes...
 +#include <svtools/colrdlg.hxx>
 +#include <svx/svxdlg.hxx>
 +#include <svx/colritem.hxx>
@@ -796,13 +807,16 @@
  #define IS_AVAILABLE(WhichId,ppItem) \
      (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
  
-@@ -698,6 +704,107 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
-                 rReq.Done();
+@@ -699,10 +706,111 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
              }
              break;
-+// TabBgColor -----------------------------------------------------------------
+ 
+-		default:
+-			DBG_ERROR("Unbekannte Message bei ViewShell");
+-			break;
+-	}
 +        case FID_TAB_SET_TAB_BG_COLOR:
-+        case FID_TAB_MENU_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;
@@ -810,27 +824,27 @@
 +                SCTAB nTabNr = pViewData->GetTabNo();
 +                ScMarkData& rMark = pViewData->GetMarkData();
 +                SCTAB nTabSelCount = rMark.GetSelectCount();
-+                
++
 +                if ( !pDoc->IsDocEditable() )
 +                    break;
-+                
++
 +                if ( pDoc->IsTabProtected( nTabNr ) || nTabSelCount > 1 )
 +                    break;
 +
 +                if( pReqArgs != NULL )
 +                {
-+                    BOOL        bDone   = FALSE;
-+                    const SfxPoolItem* pItem;
-+                    Color       aColor;
-+ 
++                    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();
 +
-+                    bDone = SetTabBgColor( aColor, nTabNr );
-+ 
++                    bDone = SetTabBgColor( aColor, nTabNr ); //ScViewFunc.SetTabBgColor
++
 +                    if( bDone )
 +                    {
 +                        rReq.Done( *pReqArgs );
@@ -840,17 +854,18 @@
 +                {
 +                    USHORT      nRet    = RET_OK;
 +                    BOOL        bDone   = FALSE;
++                    //TODO Use real dialog, but use this one in the meantime...
 +                    //TODO Create Resource...
-+                    String      aErrMsg = String::CreateFromAscii("Error selecting the color...");
-+                    Color       aTabBgColor;
-+                    String      aDlgTitle;
-+                    
++                    String        aErrMsg = String::CreateFromAscii("Error selecting the color...");
++                    Color        aTabBgColor;
++                    String        aDlgTitle;
++
 +                    aDlgTitle = String(ScResId(SCSTR_SET_TAB_BG_COLOR));
-+                    aTabBgColor = pDoc->GetTabBgColor( pViewData->GetTabNo() );
++                    aTabBgColor = pViewData->GetTabBgColor( pViewData->GetTabNo() );
 +
 +                    SvColorDialog* pColorDlg = new SvColorDialog( GetDialogParent() );
 +                            pColorDlg->SetColor( aTabBgColor );
-+                    
++
 +                    while ( !bDone && nRet == RET_OK )
 +                    {
 +                        nRet = pColorDlg->Execute();
@@ -872,9 +887,9 @@
 +                                else
 +                                {
 +                                    nRet = ErrorBox( GetDialogParent(),
-+                                                     WinBits( WB_OK | WB_DEF_OK ),
-+                                                     aErrMsg
-+                                                   ).Execute();
++                                                        WinBits( WB_OK | WB_DEF_OK ),
++                                                        aErrMsg
++                                                    ).Execute();
 +                                }
 +                            }
 +                        }
@@ -884,7 +899,7 @@
 +                /*DBW
 +                SvColorDialog* pColorDlg = new SvColorDialog( GetDialogParent() );
 +                            pColorDlg->SetColor( aTabBgColor );
-+                    
++
 +                            while ( !bDone && nRet == RET_OK )
 +                            {
 +                                nRet = pColorDlg->Execute();
@@ -897,67 +912,176 @@
 +                            }
 +                            delete( pColorDlg );
 +                */
-+                
++
 +            }
 +            break;
-+// TabBgColor -----------------------------------------------------------------
++
++        default:
++            DBG_ERROR("Unbekannte Message bei ViewShell");
++            break;
++    }
+ }
  
- 		default:
- 			DBG_ERROR("Unbekannte Message bei ViewShell");
-@@ -821,6 +928,23 @@ void ScTabViewShell::GetStateTable( SfxItemSet& rSet )
+ //------------------------------------------------------------------
+@@ -821,6 +929,22 @@ void ScTabViewShell::GetStateTable( SfxItemSet& rSet )
              case FID_TAB_TOGGLE_GRID:
                  rSet.Put( SfxBoolItem(nWhich, pViewData->GetShowGrid()) );
                  break;
-+// TabBgColor -----------------------------------------------------------------
++
 +            case FID_TAB_MENU_SET_TAB_BG_COLOR:
 +                {
 +                    if ( !pDoc->IsDocEditable() ||
-+                         pDoc->IsTabProtected(nTab) ||nTabSelCount > 1 ||
-+                         ( pDocShell && pDocShell->IsDocShared() ) )
++                            pDoc->IsTabProtected(nTab) ||nTabSelCount > 1 ||
++                            ( pDocShell && pDocShell->IsDocShared() ) )
 +                        rSet.DisableItem( nWhich );
 +                    break;
 +                }
 +            case FID_TAB_SET_TAB_BG_COLOR:
 +                {
 +                    Color aColor;
-+                    aColor = pDoc->GetTabBgColor( nTab );
++                    aColor = pViewData->GetTabBgColor( nTab );
 +                    rSet.Put( SvxColorItem( aColor, nWhich ) );
 +                }
 +                break;
-+// TabBgColor -----------------------------------------------------------------
  		}
  		nWhich = aIter.NextWhich();
  	}
+diff --git sc/source/ui/view/viewdata.cxx sc/source/ui/view/viewdata.cxx
+index bba31fc..22526b2 100644
+--- sc/source/ui/view/viewdata.cxx
++++ sc/source/ui/view/viewdata.cxx
+@@ -105,7 +105,9 @@ ScViewDataTable::ScViewDataTable() :
+ 				nCurX( 0 ),
+ 				nCurY( 0 ),
+                 bShowGrid( true ),
+-                bOldCurValid( FALSE )
++                bOldCurValid( FALSE ),
++                bIsDefaultTabBgColor( TRUE ),
++                aTabBgColor( Color(COL_AUTO) )
+ {
+ 	nPosX[0]=nPosX[1]=0;
+ 	nPosY[0]=nPosY[1]=0;
+@@ -168,6 +170,12 @@ void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>
+         pSettings[SC_TABLE_SHOWGRID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID));
+         pSettings[SC_TABLE_SHOWGRID].Value <<= static_cast<sal_Bool>(bShowGrid);
+ 
++        if (!bIsDefaultTabBgColor)
++        {
++            pSettings[SC_TABLE_TAB_BG_COLOR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_TABCOLOR));
++            pSettings[SC_TABLE_TAB_BG_COLOR].Value <<= static_cast<sal_Int32>(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,6 +292,16 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV
+             aSettings[i].Value >>= 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<ColorData>(nColor));
++                bIsDefaultTabBgColor = false;
++            }
++        }
+ 	}
+ 	if (eHSplitMode == SC_SPLIT_FIX)
+ 		nFixPosX = SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH ));
+@@ -589,6 +607,39 @@ 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;
++        pTabData[nTab]->bIsDefaultTabBgColor = FALSE;
++    }
++    else
++    {
++        if ( pTabData[nTab] )
++        {
++            pTabData[nTab]->bIsDefaultTabBgColor = TRUE;
++            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;
++    return pTabData[nTab]->bIsDefaultTabBgColor;
++}
++
+ //UNUSED2008-05  void ScViewData::UpdateOle( ScSplitPos /* eWhich */ )
+ //UNUSED2008-05  {
+ //UNUSED2008-05      GetDocShell()->UpdateOle(this);
+@@ -2477,6 +2528,10 @@ 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.mbIsDefaultTabBgColor = pViewTab->bIsDefaultTabBgColor;
++            rTabSett.maTabBgColor = pViewTab->aTabBgColor;
+ 		}
+ 	}
+ }
+@@ -2633,6 +2688,13 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt )
+                     update map modes that are needed to draw text correctly. */
+                 SetPagebreakMode( rTabSett.mbPageMode );
+             }
++
++            // Tab Bg Color
++            if( !rTabSett.mbIsDefaultTabBgColor)
++            {
++                rViewTab.bIsDefaultTabBgColor = rTabSett.mbIsDefaultTabBgColor;
++                rViewTab.aTabBgColor = rTabSett.maTabBgColor;
++            }
+ 		}
+ 	}
+ 
 diff --git sc/source/ui/view/viewfun2.cxx sc/source/ui/view/viewfun2.cxx
-index cd5a120..5e32603 100644
+index 30f3976..b5e3c57 100644
 --- sc/source/ui/view/viewfun2.cxx
 +++ sc/source/ui/view/viewfun2.cxx
-@@ -2268,8 +2268,23 @@ BOOL ScViewFunc::RenameTable( const String& rName, SCTAB nTab )
- 	return bSuccess;
- }
+@@ -2271,6 +2271,19 @@ BOOL ScViewFunc::RenameTable( const String& rName, SCTAB nTab )
  
-+// TabBgColor -----------------------------------------------------------------
-+//----------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
  
 +BOOL ScViewFunc::SetTabBgColor( const Color& rColor, SCTAB nTab )
 +{
-+	//	Reihenfolge Tabelle/Name ist bei DocFunc umgekehrt
-+	BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
-+						SetTabBgColor( nTab, rColor, TRUE, FALSE );
-+	if (bSuccess)
-+	{
-+		//	Der Tabellenname koennte in einer Formel vorkommen...
-+		GetViewData()->GetViewShell()->UpdateInputHandler();
-+	}
-+	return bSuccess;
++    BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( nTab, rColor, TRUE, FALSE );
++    if (bSuccess)
++    {
++        GetViewData()->GetViewShell()->UpdateInputHandler();
++    }
++    return bSuccess;
 +}
- //----------------------------------------------------------------------------
-+// TabBgColor -----------------------------------------------------------------
- 
++
++
++//----------------------------------------------------------------------------
++
  void ScViewFunc::InsertAreaLink( const String& rFile,
  									const String& rFilter, const String& rOptions,
+ 									const String& rSource, ULONG nRefresh )
 diff --git sc/uiconfig/scalc/menubar/menubar.xml sc/uiconfig/scalc/menubar/menubar.xml
-index 05c9d0a..84cf8ef 100644
+index 7c95dda..ed0e663 100644
 --- sc/uiconfig/scalc/menubar/menubar.xml
 +++ sc/uiconfig/scalc/menubar/menubar.xml
 @@ -211,6 +211,7 @@

Modified: trunk/patches/dev300/calc-sheet-tab-color-svtools.diff
==============================================================================
--- trunk/patches/dev300/calc-sheet-tab-color-svtools.diff	(original)
+++ trunk/patches/dev300/calc-sheet-tab-color-svtools.diff	Fri Jan 30 21:42:36 2009
@@ -1,80 +1,63 @@
 diff --git svtools/inc/tabbar.hxx svtools/inc/tabbar.hxx
-index ee25537..9f31e7f 100644
+index ee25537..fed6e1d 100644
 --- svtools/inc/tabbar.hxx
 +++ svtools/inc/tabbar.hxx
-@@ -430,6 +430,13 @@ public:
+@@ -430,6 +430,11 @@ public:
                                  USHORT nPos = TAB_APPEND );
      void            RemovePage( USHORT nPageId );
      void            MovePage( USHORT nPageId, USHORT nNewPos );
 +
-+// TabBgColor -----------------------------------------------------------------
 +    Color           GetTabBgColor( USHORT nPageId ) const;
 +    void            SetTabBgColor( USHORT nPageId, const Color& aTabBgColor, const BOOL& bIsDefaultTabBgColor );
 +    BOOL            IsDefaultTabBgColor( USHORT nPageId );
-+// TabBgColor -----------------------------------------------------------------
 +
      void            Clear();
  
      void            EnablePage( USHORT nPageId, BOOL bEnable = TRUE );
 diff --git svtools/source/control/tabbar.cxx svtools/source/control/tabbar.cxx
-index 81795e7..d0c87c4 100644
+index 81795e7..9a03230 100644
 --- svtools/source/control/tabbar.cxx
 +++ svtools/source/control/tabbar.cxx
-@@ -75,6 +75,13 @@ struct ImplTabBarItem
+@@ -75,6 +75,9 @@ struct ImplTabBarItem
      BOOL            mbShort;
      BOOL            mbSelect;
      BOOL            mbEnable;
-+// TabBgColor -----------------------------------------------------------------
 +    BOOL            mbIsDefaultTabBgColor;
 +    Color           maTabBgColor;
 +    Color           maTabTextColor;
-+    Color           maTabSelBgColor;
-+    Color           maTabSelTextColor;
-+// TabBgColor -----------------------------------------------------------------
  
                      ImplTabBarItem( USHORT nItemId, const XubString& rText,
                                      TabBarPageBits nPageBits ) :
-@@ -87,6 +94,13 @@ struct ImplTabBarItem
+@@ -87,6 +90,9 @@ struct ImplTabBarItem
                          mbShort  = FALSE;
                          mbSelect = FALSE;
                          mbEnable = TRUE;
-+// TabBgColor -----------------------------------------------------------------
 +                        mbIsDefaultTabBgColor = TRUE;
-+                        maTabBgColor = Color( COL_LIGHTGRAY );
-+                        maTabTextColor = Color( COL_BLACK );
-+                        maTabSelBgColor = Color( COL_WHITE );
-+                        maTabSelTextColor = Color( COL_BLACK );
-+// TabBgColor -----------------------------------------------------------------
++                        maTabBgColor = Color( COL_AUTO );
++                        maTabTextColor = Color( COL_AUTO );
                      }
  };
  
-@@ -1059,7 +1073,8 @@ void TabBar::Paint( const Rectangle& )
+@@ -1059,7 +1065,8 @@ void TabBar::Paint( const Rectangle& )
      // Font selektieren
      Font aFont = GetFont();
      Font aLightFont = aFont;
 -    aLightFont.SetWeight( WEIGHT_LIGHT );
 +    //aLightFont.SetWeight( WEIGHT_LIGHT );
-+    aLightFont.SetWeight( WEIGHT_NORMAL );
++	aLightFont.SetWeight( WEIGHT_NORMAL );
  
      // #i36013# exclude push buttons from painting area
      Rectangle aClipRect( Point( mnOffX, 0 ), Point( mnLastOffX, GetOutputHeightPixel() - 1 ) );
-@@ -1133,15 +1148,27 @@ void TabBar::Paint( const Rectangle& )
+@@ -1133,15 +1140,22 @@ void TabBar::Paint( const Rectangle& )
                      SetFont( aLightFont );
  
                  // Je nach Status die richtige FillInBrush setzen
 +                // Set the correct FillInBrush depending upon status
                  if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) )
                  {
--                    SetFillColor( aSelectColor );
--                    SetTextColor( aSelectTextColor );
 +                    // Currently selected Tab
-+                    if ( !pItem->mbIsDefaultTabBgColor ) {
-+                        SetFillColor( pItem->maTabSelBgColor );
-+                        SetTextColor( pItem->maTabSelTextColor );
-+                    } else {
-+                        SetFillColor( aSelectColor );
-+                        SetTextColor( aSelectTextColor );
-+                    }
+                     SetFillColor( aSelectColor );
+                     SetTextColor( aSelectTextColor );
                  }
                  else
                  {
@@ -90,7 +73,7 @@
                  }
  
                  // Muss Font Kursiv geschaltet werden
-@@ -1183,11 +1210,27 @@ void TabBar::Paint( const Rectangle& )
+@@ -1183,11 +1197,26 @@ void TabBar::Paint( const Rectangle& )
                  aPos1.X()++;
                  aPos2.X()--;
                  aPos3.X()--;
@@ -113,13 +96,12 @@
  
                  if ( !pItem->mbSelect && (pItem->mnId != mnCurPageId) )
                  {
-+                    //SetLineColor( pItem->maTabBgColor ); //DBW
 +                    // Draw the top inner shadow
 +                    // ToDo: Change from this static color to tab custom bg color
                      DrawLine( Point( aPos0.X(), aPos0.Y()+1 ),
                                  Point( aPos3.X(), aPos3.Y()+1 ) );
                  }
-@@ -1197,7 +1240,19 @@ void TabBar::Paint( const Rectangle& )
+@@ -1197,8 +1226,20 @@ void TabBar::Paint( const Rectangle& )
                  aPos1.X()--;
                  aPos1.Y()--;
                  aPos2.Y()--;
@@ -128,7 +110,7 @@
 +                    SetLineColor( pItem->maTabBgColor );
 +                }
                  DrawLine( aPos1, aPos2 );
-+                
+ 
 +                // draw a small 2px sliver of the original background color at the bottom of the selected tab
 +                if ( !pItem->mbIsDefaultTabBgColor )
 +                {
@@ -136,23 +118,22 @@
 +                        SetLineColor( pItem->maTabBgColor );
 +                    }
 +                }
- 
++
                  // Da etwas uebermalt werden konnte, muessen wir die Polygon-
                  // umrandung nocheinmal ausgeben
-@@ -1548,7 +1603,7 @@ void TabBar::InsertPage( USHORT nPageId, const XubString& rText,
-     DBG_ASSERT( nBits <= TPB_SPECIAL, "TabBar::InsertPage(): nBits is wrong" );
+                 SetLineColor( rStyleSettings.GetDarkShadowColor() );
+@@ -1549,6 +1590,7 @@ void TabBar::InsertPage( USHORT nPageId, const XubString& rText,
  
      // PageItem anlegen und in die Item-Liste eintragen
--    ImplTabBarItem* pItem = new ImplTabBarItem( nPageId, rText, nBits );
-+    ImplTabBarItem* pItem = new ImplTabBarItem( nPageId, rText, nBits );    
+     ImplTabBarItem* pItem = new ImplTabBarItem( nPageId, rText, nBits );
++    
      mpItemList->Insert( pItem, nPos );
      mbSizeFormat = TRUE;
  
-@@ -1564,6 +1619,38 @@ void TabBar::InsertPage( USHORT nPageId, const XubString& rText,
- }
+@@ -1565,6 +1607,46 @@ void TabBar::InsertPage( USHORT nPageId, const XubString& rText,
  
  // -----------------------------------------------------------------------
-+// TabBgColor
+ 
 +Color TabBar::GetTabBgColor( USHORT nPageId ) const
 +{
 +    USHORT nPos = GetPagePos( nPageId );
@@ -160,10 +141,11 @@
 +    if ( nPos != TAB_PAGE_NOTFOUND )
 +        return mpItemList->GetObject( nPos )->maTabBgColor;
 +    else
-+        return FALSE;
++        return Color( COL_AUTO ); //TODO Find a better way to report back error FIXME
 +}
 +
-+void TabBar::SetTabBgColor( USHORT nPageId, const Color& aTabBgColor, const BOOL& bIsDefaultTabBgColor )
++void TabBar::SetTabBgColor( USHORT nPageId, const Color& aTabBgColor, 
++                                            const BOOL& bIsDefaultTabBgColor )
 +{
 +    USHORT nPos = GetPagePos( nPageId );
 +    ImplTabBarItem* pItem;
@@ -172,18 +154,26 @@
 +        pItem = mpItemList->GetObject( nPos );
 +        // TODO: Need to take the color specification out of this code!
 +        pItem->mbIsDefaultTabBgColor = bIsDefaultTabBgColor;
-+        if ( !bIsDefaultTabBgColor )
++        if ( aTabBgColor == Color(COL_AUTO) )
++            pItem->mbIsDefaultTabBgColor = TRUE;
++        if ( !pItem->mbIsDefaultTabBgColor  )
 +        {
 +            pItem->maTabBgColor = aTabBgColor;
 +            if ( aTabBgColor.GetLuminance() <= 128 ) //Do not use aTabBgColor.IsDark(), because that threshold is way too low...
-+            {
 +                pItem->maTabTextColor = Color( COL_WHITE );
-+            }
++            else
++                pItem->maTabTextColor = Color( COL_BLACK );
++        }
++        else
++        {
++            pItem->maTabBgColor = Color( COL_AUTO );
++            pItem->maTabTextColor = Color( COL_AUTO );
 +        }
 +    }
 +}
 +
 +// -----------------------------------------------------------------------
- 
++
  void TabBar::RemovePage( USHORT nPageId )
  {
+     USHORT nPos = GetPagePos( nPageId );



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]