diff options
author | Winfried Donkers <W.Donkers@dci-electronics.nl> | 2012-02-01 13:17:26 +0530 |
---|---|---|
committer | Muthu Subramanian <sumuthu@suse.com> | 2012-02-01 13:17:26 +0530 |
commit | 4daa3f54437730fe4e509082faa0d3509c62cea0 (patch) | |
tree | 57599148e17793bffcccc5b0e41d5f9d0095ba92 | |
parent | afc2de3e042401cee079b0bb65873ac7beca1769 (diff) |
fdo#34425: [Feature] Persist bgcolor toolbar button.
This is to avoid background color selection evertime.
-rw-r--r-- | sc/source/ui/app/scdll.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/tabvwsh.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/formatsh.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh4.cxx | 1 | ||||
-rw-r--r-- | svx/inc/svx/tbcontrl.hxx | 3 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 60 |
6 files changed, 50 insertions, 29 deletions
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx index 0a57bf693321..4675a2e3a891 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -204,7 +204,7 @@ void ScDLL::Init() SvxFontNameToolBoxControl ::RegisterControl(SID_ATTR_CHAR_FONT, pMod); // SvxFontHeightToolBoxControl ::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod); SvxFontColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_COLOR, pMod); - SvxColorToolBoxControl ::RegisterControl(SID_BACKGROUND_COLOR, pMod); + SvxFontColorExtToolBoxControl ::RegisterControl(SID_BACKGROUND_COLOR, pMod); SvxFrameToolBoxControl ::RegisterControl(SID_ATTR_BORDER, pMod); SvxFrameLineStyleToolBoxControl ::RegisterControl(SID_FRAME_LINESTYLE, pMod); SvxFrameLineColorToolBoxControl ::RegisterControl(SID_FRAME_LINECOLOR, pMod); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 05e68387d8ba..1bd0fb1aa5ce 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -108,6 +108,7 @@ private: static sal_uInt16 nInsertCtrlState; static sal_uInt16 nInsCellsCtrlState; static sal_uInt16 nInsObjCtrlState; + static Color aBackgroundColor; SvxHtmlOptions aHTMLOpt; ObjectSelectionType eCurOST; @@ -423,6 +424,9 @@ public: bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash); + void SetBackgroundColor( const Color& aCol ) { aBackgroundColor = aCol; } + Color GetBackgroundColor() { return aBackgroundColor; } + using ScTabView::ShowCursor; // ugly hack to call Define Names from Manage Names diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index 1718741dab58..bbb44aedaab8 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1452,13 +1452,12 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) case SID_BACKGROUND_COLOR: { - // SID_BACKGROUND_COLOR without arguments -> set transparent background - + // SID_BACKGROUND_COLOR without arguments -> set background to last used color SvxBrushItem aBrushItem( (const SvxBrushItem&) pTabViewShell->GetSelectionPattern()-> GetItem( ATTR_BACKGROUND ) ); - aBrushItem.SetColor( COL_TRANSPARENT ); + aBrushItem.SetColor( pTabViewShell->GetBackgroundColor() ); pTabViewShell->ApplyAttr( aBrushItem ); } @@ -1643,7 +1642,9 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) pTabViewShell->GetSelectionPattern()-> GetItem( ATTR_BACKGROUND ) ); - aBrushItem.SetColor( rNewColorItem.GetValue() ); + Color aSet = rNewColorItem.GetValue(); + pTabViewShell->SetBackgroundColor( aSet ); + aBrushItem.SetColor( aSet ); pTabViewShell->ApplyAttr( aBrushItem ); } diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index f8e2ab84d788..5ad0d03b843d 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -109,6 +109,7 @@ using namespace com::sun::star; sal_uInt16 ScTabViewShell::nInsertCtrlState = SID_INSERT_GRAPHIC; sal_uInt16 ScTabViewShell::nInsCellsCtrlState = 0; sal_uInt16 ScTabViewShell::nInsObjCtrlState = SID_INSERT_DIAGRAM; +Color ScTabViewShell::aBackgroundColor = COL_TRANSPARENT; // ----------------------------------------------------------------------- diff --git a/svx/inc/svx/tbcontrl.hxx b/svx/inc/svx/tbcontrl.hxx index cdbd93b8f7a3..32f218d15f17 100644 --- a/svx/inc/svx/tbcontrl.hxx +++ b/svx/inc/svx/tbcontrl.hxx @@ -104,7 +104,7 @@ Note: Analysis of BrushItem: Brush-FillColor() is misused as switch, to distinguish whether a new style - or a new color has been set + or a new color has been set GetFillColor() == COL_BLACK -> GetStyle() , GetFillColor() == COL_WHITE -> GetColor() @@ -319,6 +319,7 @@ class SVX_DLLPUBLIC SvxFontColorExtToolBoxControl : public SfxToolBoxControl // SfxStatusForwarder aForward; ::svx::ToolboxButtonColorUpdater* pBtnUpdater; Color mLastColor; + sal_Bool bChoiceFromPalette; public: SFX_DECL_TOOLBOX_CONTROL(); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 9d9745b98a1c..067a0ca79707 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -2244,14 +2244,16 @@ SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl( mLastColor( COL_AUTO ) { rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); - // The following commands are available at the writer module. - if ( SID_ATTR_CHAR_COLOR2 == nSlotId ) + bChoiceFromPalette = sal_False; + + // The following commands are available at the writer and the calc module. + if ( SID_ATTR_CHAR_COLOR2 == nSlotId || SID_ATTR_CHAR_COLOR == nSlotId ) addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ))); else addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" ))); - sal_uInt16 nMode = SID_ATTR_CHAR_COLOR2 == nSlotId - ? TBX_UPDATER_MODE_CHAR_COLOR_NEW : TBX_UPDATER_MODE_CHAR_COLOR_NEW; + sal_uInt16 nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW; + pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), nMode ); } @@ -2289,6 +2291,7 @@ SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow() FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF ); pColorWin->StartSelection(); SetPopupWindow( pColorWin ); + bChoiceFromPalette = sal_True; return pColorWin; } @@ -2302,26 +2305,29 @@ void SvxFontColorExtToolBoxControl::StateChanged( sal_uInt16 nId = GetId(); ToolBox& rTbx = GetToolBox(); const SvxColorItem* pItem = 0; - - if ( nSID == SID_ATTR_CHAR_COLOR_EXT || - nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT ) + if ( bChoiceFromPalette ) { - if ( SFX_ITEM_DONTCARE != eState ) + bChoiceFromPalette = sal_False; + if ( nSID == SID_ATTR_CHAR_COLOR_EXT || + nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT ) { - const SfxBoolItem* pBool = PTR_CAST( SfxBoolItem, pState ); - rTbx.CheckItem( nId, pBool && pBool->GetValue()); + if ( SFX_ITEM_DONTCARE != eState ) + { + const SfxBoolItem* pBool = PTR_CAST( SfxBoolItem, pState ); + rTbx.CheckItem( nId, pBool && pBool->GetValue()); + } + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); } - rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); - } - else - { - if ( SFX_ITEM_DONTCARE != eState ) - pItem = PTR_CAST( SvxColorItem, pState ); - - if ( pItem ) + else { - pBtnUpdater->Update( pItem->GetValue() ); - mLastColor = pItem->GetValue(); + if ( SFX_ITEM_DONTCARE != eState ) + pItem = PTR_CAST( SvxColorItem, pState ); + + if ( pItem ) + { + pBtnUpdater->Update( pItem->GetValue() ); + mLastColor = pItem->GetValue(); + } } } } @@ -2332,15 +2338,23 @@ void SvxFontColorExtToolBoxControl::Select( sal_Bool ) { OUString aCommand; OUString aParamName; - if ( SID_ATTR_CHAR_COLOR2 == GetSlotId() ) + if ( SID_ATTR_CHAR_COLOR2 == GetSlotId() || SID_ATTR_CHAR_COLOR == GetSlotId() ) { aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )); aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" )); } else { - aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )); - aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" )); + if ( SID_BACKGROUND_COLOR == GetSlotId() ) + { + aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BackgroundColor" )); + aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "BackgroundColor" )); + } + else + { + aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )); + aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" )); + } } Sequence< PropertyValue > aArgs( 1 ); |