From a7a048f9a2ee1ef88eec0b02d44a94562788aa8a Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Wed, 12 Oct 2016 21:11:04 +0300 Subject: [PATCH] SvxColorToolBoxControl: Some cleanup Change-Id: Iaf908b0c2456a239e343d0fcb89a2ba163b74010 --- include/svx/tbxcolorupdate.hxx | 1 + svx/source/tbxctrls/PaletteManager.cxx | 1 + svx/source/tbxctrls/tbcontrl.cxx | 85 +++----------------------- svx/source/tbxctrls/tbxcolorupdate.cxx | 1 + 4 files changed, 11 insertions(+), 77 deletions(-) diff --git a/include/svx/tbxcolorupdate.hxx b/include/svx/tbxcolorupdate.hxx index 34e1689915a7..0077eb84f0d4 100644 --- a/include/svx/tbxcolorupdate.hxx +++ b/include/svx/tbxcolorupdate.hxx @@ -49,6 +49,7 @@ namespace svx ~ToolboxButtonColorUpdater(); void Update( const Color& rColor, bool bForceUpdate = false ); + Color GetCurrentColor() const { return maCurColor; } private: ToolboxButtonColorUpdater(ToolboxButtonColorUpdater &) = delete; diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index db9b012fc423..3ba048559620 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -282,6 +282,7 @@ void PaletteManager::AddRecentColor(const Color& rRecentColor, const OUString& r void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater) { mpBtnUpdater = pBtnUpdater; + mLastColor = mpBtnUpdater->GetCurrentColor(); } void PaletteManager::SetColorSelectFunction(const std::function& aColorSelectFunction) diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 59cef347186f..688a348fa2df 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -2624,56 +2625,24 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( m_bSplitButton(dynamic_cast< sfx2::sidebar::SidebarToolBox* >(&rTbx) == nullptr), m_aColorSelectFunction(PaletteManager::DispatchColorCommand) { - // The following commands are available at the various modules switch( nSlotId ) { - case SID_ATTR_CHAR_COLOR: - addStatusListener( ".uno:Color"); - m_aPaletteManager.SetLastColor( COL_RED ); - m_bSplitButton = true; - break; - case SID_ATTR_CHAR_COLOR2: addStatusListener( ".uno:CharColorExt"); - m_aPaletteManager.SetLastColor( COL_RED ); - m_bSplitButton = true; - break; + SAL_FALLTHROUGH; - case SID_BACKGROUND_COLOR: - addStatusListener( ".uno:BackgroundColor"); - m_aPaletteManager.SetLastColor( COL_YELLOW ); + case SID_ATTR_CHAR_COLOR: + m_bSplitButton = true; break; case SID_ATTR_CHAR_COLOR_BACKGROUND: addStatusListener( ".uno:CharBackgroundExt"); - m_aPaletteManager.SetLastColor( COL_YELLOW ); m_bSplitButton = true; break; - case SID_ATTR_CHAR_BACK_COLOR: - addStatusListener( ".uno:CharBackColor"); - m_aPaletteManager.SetLastColor( COL_YELLOW ); - break; - case SID_FRAME_LINECOLOR: - addStatusListener( ".uno:FrameLineColor"); addStatusListener( ".uno:BorderTLBR"); addStatusListener( ".uno:BorderBLTR"); - m_aPaletteManager.SetLastColor( COL_BLUE ); - break; - - case SID_EXTRUSION_3D_COLOR: - addStatusListener( ".uno:Extrusion3DColor"); - break; - - case SID_ATTR_LINE_COLOR: - addStatusListener( ".uno:XLineColor"); - m_aPaletteManager.SetLastColor( COL_DEFAULT_SHAPE_STROKE ); - break; - - case SID_ATTR_FILL_COLOR: - addStatusListener( ".uno:FillColor"); - m_aPaletteManager.SetLastColor( COL_DEFAULT_SHAPE_FILLING ); break; } @@ -2790,60 +2759,22 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) return; } - OUString aCommand; - OUString aParamName; + OUString aCommand = m_aCommandURL; switch( GetSlotId() ) { case SID_ATTR_CHAR_COLOR2 : aCommand = ".uno:CharColorExt"; - aParamName = "FontColor"; - break; - - case SID_ATTR_CHAR_COLOR : - aCommand = ".uno:Color"; - aParamName = "Color"; - break; - - case SID_BACKGROUND_COLOR : - aCommand = ".uno:BackgroundColor"; - aParamName = "BackgroundColor"; break; case SID_ATTR_CHAR_COLOR_BACKGROUND : aCommand = ".uno:CharBackgroundExt"; - aParamName = "BackColor"; - break; - - case SID_ATTR_CHAR_BACK_COLOR : - aCommand = ".uno:CharBackColor"; - aParamName = "CharBackColor"; - break; - - case SID_FRAME_LINECOLOR : - aCommand = ".uno:FrameLineColor"; - aParamName = "FrameLineColor"; - break; - - case SID_EXTRUSION_3D_COLOR: - aCommand = ".uno:Extrusion3DColor"; - aParamName = "Extrusion3DColor"; - break; - - case SID_ATTR_LINE_COLOR: - aCommand = ".uno:XLineColor"; - aParamName = "XLineColor"; - break; - - case SID_ATTR_FILL_COLOR: - aCommand = ".uno:FillColor"; - aParamName = "FillColor"; break; } - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = aParamName; - aArgs[0].Value = makeAny( (sal_uInt32)( m_aPaletteManager.GetLastColor().GetColor() )); + auto aArgs( comphelper::InitPropertySequence( { + { m_aCommandURL.copy(5), css::uno::makeAny( m_aPaletteManager.GetLastColor().GetColor() ) } + } ) ); Dispatch( aCommand, aArgs ); } diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx index ef16fc185bc5..4756980d14e1 100644 --- a/svx/source/tbxctrls/tbxcolorupdate.cxx +++ b/svx/source/tbxctrls/tbxcolorupdate.cxx @@ -59,6 +59,7 @@ namespace svx Update(COL_BLUE); break; case SID_ATTR_CHAR_COLOR_BACKGROUND: + case SID_ATTR_CHAR_BACK_COLOR: case SID_BACKGROUND_COLOR: Update(COL_YELLOW); break;