diff options
author | Winfried Donkers <osc@dci-electronics.nl> | 2012-02-21 14:50:04 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-02-21 14:50:04 +0000 |
commit | 836d98646203e0d9d3916571ed55d6572c2cb3dc (patch) | |
tree | 2e7f4845b93bbc3f4fc05a4845f95ec03edf84df /svx | |
parent | 46cf18fdf137d68ff42d6e037a1285a37c65c07f (diff) |
fdo#44611 writer: paragraph background color picker with split button
Diffstat (limited to 'svx')
-rw-r--r--[-rwxr-xr-x] | svx/inc/svx/svxids.hrc | 0 | ||||
-rw-r--r-- | svx/inc/svx/tbcontrl.hxx | 29 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 115 |
3 files changed, 82 insertions, 62 deletions
diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc index f66af83d2a3c..f66af83d2a3c 100755..100644 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc diff --git a/svx/inc/svx/tbcontrl.hxx b/svx/inc/svx/tbcontrl.hxx index e0f0bdd1a5a6..35806e5c707c 100644 --- a/svx/inc/svx/tbcontrl.hxx +++ b/svx/inc/svx/tbcontrl.hxx @@ -65,23 +65,23 @@ from DocShell: presently none in future: color palette - class SvxFontColorExtToolBoxControl + class SvxColorExtToolBoxControl ----------------------------------- - for font color Item type: SvxColorItem - und SfxBoolItem + and SfxBoolItem + + for font color (writer, ...) Execute-Id SID_ATTR_CHAR_COLOR2 - und SID_ATTR_CHAR_COLOR_EXT + and SID_ATTR_CHAR_COLOR_EXT for character background color (writer) - Item-Typ SvxColorItem - und SfxBoolItem Execute-Id SID_ATTR_CHAR_COLOR_BACKGROUND - und SID_ATTR_CHAR_COLOR_BACKGROUND_EXT + and SID_ATTR_CHAR_COLOR_BACKGROUND_EXT + + for paragraph background color (writer) + Execute-Id SID_BACKGROUND_COLOR for cell background color (calc) - Item-Typ SvxColorItem - und SfxBoolItem Execute-Id SID_ATTR_CHAR_COLOR_BACKGROUND SvxColorToolBoxControl @@ -89,9 +89,6 @@ Item type: SvxBrushItem Execute-Id: SID_BACKGROUND_COLOR -> SvxColorItem - Additional information - from DocShell: presently none - in future: color palette SvxPatternToolBoxControl ------------------------ @@ -306,12 +303,12 @@ public: //======================================================================== -// class SvxFontColorExtToolBoxControl -------------------------------------- +// class SvxColorExtToolBoxControl -------------------------------------- //======================================================================== -class SVX_DLLPUBLIC SvxFontColorExtToolBoxControl : public SfxToolBoxControl +class SVX_DLLPUBLIC SvxColorExtToolBoxControl : public SfxToolBoxControl { using SfxToolBoxControl::StateChanged; using SfxToolBoxControl::Select; @@ -323,8 +320,8 @@ class SVX_DLLPUBLIC SvxFontColorExtToolBoxControl : public SfxToolBoxControl public: SFX_DECL_TOOLBOX_CONTROL(); - SvxFontColorExtToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); - ~SvxFontColorExtToolBoxControl(); + SvxColorExtToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); + ~SvxColorExtToolBoxControl(); virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 6e1421eb91f2..5965dd49b949 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -122,7 +122,7 @@ using namespace ::com::sun::star::lang; SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl, SvxColorItem ); -SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorExtToolBoxControl, SvxColorItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxColorExtToolBoxControl, SvxColorItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxColorToolBoxControl, SvxColorItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem ); @@ -2235,10 +2235,10 @@ void SvxColorToolBoxControl::StateChanged( } //======================================================================== -// class SvxFontColorExtToolBoxControl -------------------------------------- +// class SvxColorExtToolBoxControl ---------------------------------------- //======================================================================== -SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl( +SvxColorExtToolBoxControl::SvxColorExtToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : @@ -2247,37 +2247,47 @@ SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl( pBtnUpdater(0), mLastColor( COL_AUTO ) { + sal_uInt16 nMode; + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 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" ))); + // The following commands are available at the various modules + switch( nSlotId ) + { + case SID_ATTR_CHAR_COLOR2 : + case SID_ATTR_CHAR_COLOR : + addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ))); + nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW; + break; - sal_uInt16 nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW; + case SID_ATTR_CHAR_COLOR_BACKGROUND : + case SID_BACKGROUND_COLOR : + addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" ))); + nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW; + break; + } pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), nMode ); } // ----------------------------------------------------------------------- -SvxFontColorExtToolBoxControl::~SvxFontColorExtToolBoxControl() +SvxColorExtToolBoxControl::~SvxColorExtToolBoxControl() { delete pBtnUpdater; } // ----------------------------------------------------------------------- -SfxPopupWindowType SvxFontColorExtToolBoxControl::GetPopupWindowType() const +SfxPopupWindowType SvxColorExtToolBoxControl::GetPopupWindowType() const { return SFX_POPUPWINDOW_ONTIMEOUT; } // ----------------------------------------------------------------------- -SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow() +SfxPopupWindow* SvxColorExtToolBoxControl::CreatePopupWindow() { SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl( @@ -2288,8 +2298,16 @@ SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow() &GetToolBox(), mLastColor ); - if ( GetSlotId() == SID_ATTR_CHAR_COLOR_BACKGROUND ) - pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) ); + switch( GetSlotId() ) + { + case SID_ATTR_CHAR_COLOR_BACKGROUND : + pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) ); + break; + + case SID_BACKGROUND_COLOR : + pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) ); + break; + } pColorWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF ); @@ -2301,7 +2319,7 @@ SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow() // ----------------------------------------------------------------------- -void SvxFontColorExtToolBoxControl::StateChanged( +void SvxColorExtToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) @@ -2312,53 +2330,58 @@ void SvxFontColorExtToolBoxControl::StateChanged( if ( bChoiceFromPalette ) { bChoiceFromPalette = sal_False; - if ( nSID == SID_ATTR_CHAR_COLOR_EXT || - nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT ) - { - 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 ); - } - else + switch( nSID ) { - if ( SFX_ITEM_DONTCARE != eState ) - pItem = PTR_CAST( SvxColorItem, pState ); + case SID_ATTR_CHAR_COLOR_EXT : + case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT : + 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 ); + break; - if ( pItem ) - { - pBtnUpdater->Update( pItem->GetValue() ); - mLastColor = pItem->GetValue(); - } + case SID_ATTR_CHAR_COLOR2 : + case SID_ATTR_CHAR_COLOR_BACKGROUND : + case SID_BACKGROUND_COLOR : + if ( SFX_ITEM_DONTCARE != eState ) + pItem = PTR_CAST( SvxColorItem, pState ); + + if ( pItem ) + { + pBtnUpdater->Update( pItem->GetValue() ); + mLastColor = pItem->GetValue(); + } + break; } } } // ----------------------------------------------------------------------- -void SvxFontColorExtToolBoxControl::Select( sal_Bool ) +void SvxColorExtToolBoxControl::Select( sal_Bool ) { OUString aCommand; OUString aParamName; - 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 + + switch( GetSlotId() ) { - if ( SID_BACKGROUND_COLOR == GetSlotId() ) - { + case SID_ATTR_CHAR_COLOR2 : + case SID_ATTR_CHAR_COLOR : + aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )); + aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" )); + break; + + case SID_BACKGROUND_COLOR : aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BackgroundColor" )); aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "BackgroundColor" )); - } - else - { + break; + + case SID_ATTR_CHAR_COLOR_BACKGROUND : aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )); aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" )); - } + break; } Sequence< PropertyValue > aArgs( 1 ); |