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



Author: kyoshida
Date: Mon Jan 26 22:19:20 2009
New Revision: 15156
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15156&view=rev

Log:
2009-01-26  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:
	* patches/dev300/apply: preliminary work toward supporting custom tab 
	color for Calc.  Currently only working with xls import/export, with 
	work on supporting .ods on the way.


Added:
   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/ChangeLog
   trunk/patches/dev300/apply

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Mon Jan 26 22:19:20 2009
@@ -2029,6 +2029,11 @@
 # fix assertions to prevent them from being incorrectly triggered.
 chart-odf-export-assert-removal.diff, i#97563, kohei
 
+# Support custom sheet tab colors option (by Daniel Watson).
+calc-sheet-tab-color-officecfg.diff, kohei
+calc-sheet-tab-color-svtools.diff, kohei
+calc-sheet-tab-color-sc.diff, kohei
+
 [ CalcRowLimit ]
 # The work to increase Calc's row size limit, and any work associated with it.
 SectionOwner => kohei

Added: trunk/patches/dev300/calc-sheet-tab-color-officecfg.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/calc-sheet-tab-color-officecfg.diff	Mon Jan 26 22:19:20 2009
@@ -0,0 +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
+--- 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:Move" oor:op="replace">
+ 				<prop oor:name="Label" oor:type="xs:string">
+ 					<value xml:lang="en-US">~Move/Copy Sheet...</value>

Added: trunk/patches/dev300/calc-sheet-tab-color-sc.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/calc-sheet-tab-color-sc.diff	Mon Jan 26 22:19:20 2009
@@ -0,0 +1,970 @@
+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/sc.hrc sc/inc/sc.hrc
+index 9fdc0ac..cf9c139 100644
+--- sc/inc/sc.hrc
++++ sc/inc/sc.hrc
+@@ -1663,6 +1663,10 @@
+ #define RID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 5)
+ #define HID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 6)
+ 
++#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) 
++
+ #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; }
+ 
++// TabBgColor -----------------------------------------------------------------
++    void        GetTabBgColor( Color& rColor ) const;
++    void        SetTabBgColor( const Color& rNewColor );
++    BOOL        IsDefaultTabBgColor() const                 { return bIsDefaultTabBgColor; };
++// TabBgColor -----------------------------------------------------------------
++
+     const String&   GetUpperName() const;
+ 
+ 	const String&	GetPageStyle() const					{ return aPageStyle; }
+diff --git sc/sdi/docsh.sdi sc/sdi/docsh.sdi
+index 16dff9a..a5ff00c 100644
+--- sc/sdi/docsh.sdi
++++ sc/sdi/docsh.sdi
+@@ -62,6 +62,9 @@ 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_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
+--- sc/sdi/scalc.sdi
++++ sc/sdi/scalc.sdi
+@@ -7875,4 +7875,56 @@ SfxBoolItem ToggleSheetGrid FID_TAB_TOGGLE_GRID
+     GroupId = GID_FORMAT;
+ ]
+ 
++// TabBgColor -----------------------------------------------------------------
++//--------------------------------------------------------------------------
++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;
++]
++// TabBgColor -----------------------------------------------------------------
+diff --git sc/sdi/tabvwsh.sdi sc/sdi/tabvwsh.sdi
+index bd51c83..a2c68dd 100644
+--- sc/sdi/tabvwsh.sdi
++++ sc/sdi/tabvwsh.sdi
+@@ -60,6 +60,9 @@ 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
+--- sc/source/filter/excel/read.cxx
++++ sc/source/filter/excel/read.cxx
+@@ -1157,6 +1157,14 @@ 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 -----------------------------------------------------------------
+                 }
+ 			}
+             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 )
+     }
+ }
+ 
++// TabBgColor -----------------------------------------------------------------
++XclExpTabColor::XclExpTabColor( const XclPageData& rPageData ) :
++    XclExpRecord( 0x0862, 18 ), //TODO Use Real ID!
++    mrData( rPageData )
++{
++}
++//TODO Fix savexml...
++/*void XclExpTabColor::SaveXml( XclExpXmlStream& rStrm )
++{
++}*/
++
++void XclExpTabColor::WriteBody( XclExpStream& rStrm )
++{
++    if ( mrData.mbIsDefaultTabBgColor )
++        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(mrData.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 ---------------------------------------------------------
+ 
+ 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) )
++        {
++            XclExpPalette& rPal = GetPalette();
++            maData.mbIsDefaultTabBgColor = false;
++            maData.maTabBgColor = rDoc.GetTabBgColor(nScTab);
++            maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG );
++        }
++// TabBgColor -----------------------------------------------------------------
+ 
+         maData.mxBrushItem.reset( new SvxBrushItem( GETITEM( rItemSet, SvxBrushItem, ATTR_BACKGROUND ) ) );
+ 
+@@ -271,6 +310,12 @@ void XclExpPageSettings::Save( XclExpStream& rStrm )
+     XclExpDoubleRecord( EXC_ID_BOTTOMMARGIN, maData.mfBottomMargin ).Save( rStrm );
+     XclExpSetup( maData ).Save( rStrm );
+ 
++// TabBgColor -----------------------------------------------------------------
++//  TODO I think this is where I need to inject bits for tab colors
++    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" );
+diff --git sc/source/filter/excel/xichart.cxx sc/source/filter/excel/xichart.cxx
+index 255c7e7..31acf41 100644
+--- sc/source/filter/excel/xichart.cxx
++++ sc/source/filter/excel/xichart.cxx
+@@ -3566,6 +3566,15 @@ 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:
++            {
++                XclImpPalette& rPal = GetPalette();
++                rPageSett.ReadTabBgColor( rStrm,  rPal);
++                break;
++            }
++// TabBgColor -----------------------------------------------------------------
+         }
+ 
+         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 )
+     }
+ }
+ 
++// TabBgColor -----------------------------------------------------------------
++void XclImpPageSettings::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() & 0x7F;
++    if ( ColorIndex >= 8 && ColorIndex <= 63 ) //only accept valid index values
++    {
++        TabBgColor = rPal.GetColor( ColorIndex );
++        maData.maTabBgColor = TabBgColor;
++        maData.mbIsDefaultTabBgColor = false;
++    }
++}
++// TabBgColor -----------------------------------------------------------------
++
+ void XclImpPageSettings::ReadMargin( XclImpStream& rStrm )
+ {
+     switch( rStrm.GetRecId() )
+@@ -387,6 +409,22 @@ void XclImpPageSettings::Finalize()
+         if( nScCol <= MAXCOL )
+             rDoc.SetColFlags( nScCol, nScTab, rDoc.GetColFlags( nScCol, nScTab ) | CR_MANUALBREAK );
+     }
++// 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 );
++    }
++// 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 -----------------------------------------------------------------
++    mbIsDefaultTabBgColor = true;
++// TabBgColor -----------------------------------------------------------------
+ }
+ 
+ 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. */
+diff --git sc/source/filter/inc/xestyle.hxx sc/source/filter/inc/xestyle.hxx
+index 8a17a74..77394a2 100644
+--- sc/source/filter/inc/xestyle.hxx
++++ 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 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:
+ 
+     /** 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 @@
+ 
+ #include <tools/gen.hxx>
+ #include "xltools.hxx"
++// TabBgColor -----------------------------------------------------------------
++#include <tools/color.hxx>
++// TabBgColor -----------------------------------------------------------------
+ 
+ // Constants and Enumerations =================================================
+ 
+@@ -141,6 +144,12 @@ struct XclPageData : ScfNoCopy
+     bool                mbPrintHeadings;    /// true = print column and row headings.
+     bool                mbPrintGrid;        /// true = print grid lines.
+ 
++// 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 -----------------------------------------------------------------
++
+     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_COLOR_NOTABBG          = 0x7F;     /// Excel ignores Tab color when set to this value...
+ 
+ // (0x0293) STYLE -------------------------------------------------------------
+ 
+diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
+index a4f0cc6..b7fd459 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
+ 	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);
++        return FALSE;
++    }
++
++    ScDocShellModificator aModificator( rDocShell );
++
++    BOOL bSuccess = FALSE;
++    if (pDoc->SetTabBgColor( nTab, rColor ))
++    {
++        if (bRecord)
++        {
++            //TODO Add undo action! this is how renametab does it...
++            /*
++            rDocShell.GetUndoManager()->AddUndoAction(
++                            new ScUndoRenameTab( &rDocShell, nTab, sOldName, rName));
++            */
++        }
++        rDocShell.PostPaintExtras();
++        aModificator.SetDocumentModified();
++        SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
++
++        bSuccess = TRUE;
++    }
++    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
+--- sc/source/ui/inc/docfunc.hxx
++++ sc/source/ui/inc/docfunc.hxx
+@@ -116,6 +116,10 @@ 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/viewfunc.hxx sc/source/ui/inc/viewfunc.hxx
+index 72e2d96..a6a0599 100644
+--- sc/source/ui/inc/viewfunc.hxx
++++ sc/source/ui/inc/viewfunc.hxx
+@@ -276,6 +276,10 @@ 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
+--- sc/source/ui/src/globstr.src
++++ sc/source/ui/src/globstr.src
+@@ -1134,6 +1134,13 @@ 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_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
+--- sc/source/ui/src/popup.src
++++ sc/source/ui/src/popup.src
+@@ -169,6 +169,14 @@ 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_MOVE ;
+diff --git sc/source/ui/src/scstring.src sc/source/ui/src/scstring.src
+index ed03d74..9851aa6 100644
+--- sc/source/ui/src/scstring.src
++++ sc/source/ui/src/scstring.src
+@@ -283,6 +283,12 @@ String SCSTR_RENAMETAB
+ {
+ 	Text [ en-US ] = "Rename Sheet" ;
+ };
++// TabBgColor -----------------------------------------------------------------
++String SCSTR_SET_TAB_BG_COLOR
++{
++	Text [ en-US ] = "Set Tab Color" ;
++};
++// TabBgColor -----------------------------------------------------------------
+ String SCSTR_RENAMEOBJECT
+ {
+ 	Text [ en-US ] = "Name Object";
+diff --git sc/source/ui/view/tabcont.cxx sc/source/ui/view/tabcont.cxx
+index 5117f2b..9b59119 100644
+--- sc/source/ui/view/tabcont.cxx
++++ sc/source/ui/view/tabcont.cxx
+@@ -68,6 +68,9 @@ 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 ) :
+ 					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 -----------------------------------------------------------------
+ 			}
+ 		}
+ 	}
+@@ -259,6 +269,9 @@ 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()
+ 	SCTAB i;
+ 	String aString;
+ 	SCTAB nMaxCnt = Max( nCount, static_cast<SCTAB>(GetMaxId()) );
++// TabBgColor -----------------------------------------------------------------
++	Color aTabBgColor;
++// TabBgColor -----------------------------------------------------------------
+ 
+ 	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 -----------------------------------------------------------------
++		}
+ 		else
++		{
+ 			aString.Erase();
++		}
+ 
+-		if (GetPageText(static_cast<sal_uInt16>(i)+1) != aString)
++		if ( (GetPageText(static_cast<sal_uInt16>(i)+1) != aString) || (GetTabBgColor(static_cast<sal_uInt16>(i)+1) != aTabBgColor) )
+ 			bModified = TRUE;
+ 	}
+ 
+@@ -311,6 +334,13 @@ 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 -----------------------------------------------------------------
+ 				}
+ 			}
+ 		}
+diff --git sc/source/ui/view/tabvwshf.cxx sc/source/ui/view/tabvwshf.cxx
+index 6987883..dc17fc2 100644
+--- sc/source/ui/view/tabvwshf.cxx
++++ sc/source/ui/view/tabvwshf.cxx
+@@ -60,6 +60,12 @@
+ 
+ #include "scabstdlg.hxx" //CHINA001
+ 
++// TabBgColor -----------------------------------------------------------------
++#include <svtools/colrdlg.hxx>
++#include <svx/svxdlg.hxx>
++#include <svx/colritem.hxx>
++// TabBgColor -----------------------------------------------------------------
++
+ #define IS_AVAILABLE(WhichId,ppItem) \
+     (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+ 
+@@ -698,6 +704,107 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
+                 rReq.Done();
+             }
+             break;
++// TabBgColor -----------------------------------------------------------------
++        case FID_TAB_SET_TAB_BG_COLOR:
++        case FID_TAB_MENU_SET_TAB_BG_COLOR:         
++            {
++                if ( nSlot == FID_TAB_MENU_SET_TAB_BG_COLOR )
++                    nSlot = FID_TAB_SET_TAB_BG_COLOR;
++
++                SCTAB nTabNr = pViewData->GetTabNo();
++                ScMarkData& rMark = pViewData->GetMarkData();
++                SCTAB nTabSelCount = rMark.GetSelectCount();
++                
++                if ( !pDoc->IsDocEditable() )
++                    break;
++                
++                if ( pDoc->IsTabProtected( nTabNr ) || nTabSelCount > 1 )
++                    break;
++
++                if( pReqArgs != NULL )
++                {
++                    BOOL        bDone   = FALSE;
++                    const SfxPoolItem* pItem;
++                    Color       aColor;
++ 
++                    if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
++                        nTabNr = ((const SfxUInt16Item*)pItem)->GetValue();
++ 
++                    if( IS_AVAILABLE( nSlot, &pItem ) )
++                        aColor = ((const SvxColorItem*)pItem)->GetValue();
++
++                    bDone = SetTabBgColor( aColor, nTabNr );
++ 
++                    if( bDone )
++                    {
++                        rReq.Done( *pReqArgs );
++                    }
++                }
++                else
++                {
++                    USHORT      nRet    = RET_OK;
++                    BOOL        bDone   = FALSE;
++                    //TODO Create Resource...
++                    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() );
++
++                    SvColorDialog* pColorDlg = new SvColorDialog( GetDialogParent() );
++                            pColorDlg->SetColor( aTabBgColor );
++                    
++                    while ( !bDone && nRet == RET_OK )
++                    {
++                        nRet = pColorDlg->Execute();
++                        if( nRet == RET_OK )
++                        {
++                            Color aSelectedColor = pColorDlg->GetColor();
++                            bDone = SetTabBgColor( aSelectedColor, nTabNr );
++                            if ( bDone )
++                            {
++                                rReq.AppendItem( SvxColorItem( aTabBgColor, nSlot ) );
++                                rReq.Done();
++                            }
++                            else
++                            {
++                                if( rReq.IsAPI() )
++                                {
++                                    StarBASIC::Error( SbERR_SETPROP_FAILED );
++                                }
++                                else
++                                {
++                                    nRet = ErrorBox( GetDialogParent(),
++                                                     WinBits( WB_OK | WB_DEF_OK ),
++                                                     aErrMsg
++                                                   ).Execute();
++                                }
++                            }
++                        }
++                    }
++                    delete( pColorDlg );
++                }
++                /*DBW
++                SvColorDialog* pColorDlg = new SvColorDialog( GetDialogParent() );
++                            pColorDlg->SetColor( aTabBgColor );
++                    
++                            while ( !bDone && nRet == RET_OK )
++                            {
++                                nRet = pColorDlg->Execute();
++                                if( nRet == RET_OK )
++                                {
++                                    Color aSelectedColor = pColorDlg->GetColor();
++                                    SetTabBgColor( aSelectedColor, nTabNr );
++                                    bDone = TRUE;
++                                }
++                            }
++                            delete( pColorDlg );
++                */
++                
++            }
++            break;
++// TabBgColor -----------------------------------------------------------------
+ 
+ 		default:
+ 			DBG_ERROR("Unbekannte Message bei ViewShell");
+@@ -821,6 +928,23 @@ 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() ) )
++                        rSet.DisableItem( nWhich );
++                    break;
++                }
++            case FID_TAB_SET_TAB_BG_COLOR:
++                {
++                    Color aColor;
++                    aColor = pDoc->GetTabBgColor( nTab );
++                    rSet.Put( SvxColorItem( aColor, nWhich ) );
++                }
++                break;
++// TabBgColor -----------------------------------------------------------------
+ 		}
+ 		nWhich = aIter.NextWhich();
+ 	}
+diff --git sc/source/ui/view/viewfun2.cxx sc/source/ui/view/viewfun2.cxx
+index cd5a120..5e32603 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;
+ }
+ 
++// 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;
++}
+ //----------------------------------------------------------------------------
++// TabBgColor -----------------------------------------------------------------
+ 
+ void ScViewFunc::InsertAreaLink( const String& rFile,
+ 									const String& rFilter, const String& rOptions,
+diff --git sc/uiconfig/scalc/menubar/menubar.xml sc/uiconfig/scalc/menubar/menubar.xml
+index 05c9d0a..84cf8ef 100644
+--- sc/uiconfig/scalc/menubar/menubar.xml
++++ sc/uiconfig/scalc/menubar/menubar.xml
+@@ -211,6 +211,7 @@
+             <menu:menu menu:id=".uno:SheetMenu">
+                 <menu:menupopup>
+                     <menu:menuitem menu:id=".uno:RenameTable"/>
++                    <menu:menuitem menu:id=".uno:SetTabBgColor"/>
+                     <menu:menuitem menu:id=".uno:Hide"/>
+                     <menu:menuitem menu:id=".uno:Show"/>
+                     <menu:menuitem menu:id=".uno:SheetRightToLeft"/>

Added: trunk/patches/dev300/calc-sheet-tab-color-svtools.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/calc-sheet-tab-color-svtools.diff	Mon Jan 26 22:19:20 2009
@@ -0,0 +1,189 @@
+diff --git svtools/inc/tabbar.hxx svtools/inc/tabbar.hxx
+index ee25537..9f31e7f 100644
+--- svtools/inc/tabbar.hxx
++++ svtools/inc/tabbar.hxx
+@@ -430,6 +430,13 @@ 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
+--- svtools/source/control/tabbar.cxx
++++ svtools/source/control/tabbar.cxx
+@@ -75,6 +75,13 @@ 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
+                         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 -----------------------------------------------------------------
+                     }
+ };
+ 
+@@ -1059,7 +1073,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 );
+ 
+     // #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& )
+                     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 );
++                    }
+                 }
+                 else
+                 {
+-                    SetFillColor( aFaceColor );
+-                    SetTextColor( aFaceTextColor );
++                    if ( !pItem->mbIsDefaultTabBgColor ) {
++                        SetFillColor( pItem->maTabBgColor );
++                        SetTextColor( pItem->maTabTextColor );
++                    } else {
++                        SetFillColor( aFaceColor );
++                        SetTextColor( aFaceTextColor );
++                    }
+                 }
+ 
+                 // Muss Font Kursiv geschaltet werden
+@@ -1183,11 +1210,27 @@ void TabBar::Paint( const Rectangle& )
+                 aPos1.X()++;
+                 aPos2.X()--;
+                 aPos3.X()--;
+-                SetLineColor( rStyleSettings.GetLightColor() );
++
++                // If this is the current tab, draw the left inner shadow the default color, 
++                // otherwise make it the same as the custom background color
++                if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) ) {
++                    SetLineColor( rStyleSettings.GetLightColor() );
++                } else {
++                    if ( !pItem->mbIsDefaultTabBgColor )
++                    {
++                        SetLineColor( pItem->maTabBgColor );
++                    } else {
++                        SetLineColor( rStyleSettings.GetLightColor() );
++                    }
++                }
++                // Draw the left side of the tab
+                 DrawLine( aPos0, aPos1 );
+ 
+                 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& )
+                 aPos1.X()--;
+                 aPos1.Y()--;
+                 aPos2.Y()--;
++                if ( !pItem->mbIsDefaultTabBgColor && ( pItem->mbSelect || (pItem->mnId == mnCurPageId) ) )
++                {
++                    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 )
++                {
++                    if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) ) {
++                        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" );
+ 
+     // PageItem anlegen und in die Item-Liste eintragen
+-    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,
+ }
+ 
+ // -----------------------------------------------------------------------
++// TabBgColor
++Color TabBar::GetTabBgColor( USHORT nPageId ) const
++{
++    USHORT nPos = GetPagePos( nPageId );
++
++    if ( nPos != TAB_PAGE_NOTFOUND )
++        return mpItemList->GetObject( nPos )->maTabBgColor;
++    else
++        return FALSE;
++}
++
++void TabBar::SetTabBgColor( USHORT nPageId, const Color& aTabBgColor, const BOOL& bIsDefaultTabBgColor )
++{
++    USHORT nPos = GetPagePos( nPageId );
++    ImplTabBarItem* pItem;
++    if ( nPos != TAB_PAGE_NOTFOUND )
++    {
++        pItem = mpItemList->GetObject( nPos );
++        // TODO: Need to take the color specification out of this code!
++        pItem->mbIsDefaultTabBgColor = bIsDefaultTabBgColor;
++        if ( !bIsDefaultTabBgColor )
++        {
++            pItem->maTabBgColor = aTabBgColor;
++            if ( aTabBgColor.GetLuminance() <= 128 ) //Do not use aTabBgColor.IsDark(), because that threshold is way too low...
++            {
++                pItem->maTabTextColor = Color( COL_WHITE );
++            }
++        }
++    }
++}
++
++// -----------------------------------------------------------------------
+ 
+ void TabBar::RemovePage( USHORT nPageId )
+ {



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