chart2/source/controller/sidebar/ChartColorWrapper.cxx | 15 - include/sfx2/tbxctrl.hxx | 5 include/svx/linectrl.hxx | 5 include/svx/tbcontrl.hxx | 17 - include/svx/tbxcolorupdate.hxx | 1 reportdesign/source/ui/misc/toolboxcontroller.cxx | 8 sfx2/source/toolbox/tbxitem.cxx | 133 --------- svx/source/tbxctrls/PaletteManager.cxx | 1 svx/source/tbxctrls/colorwindow.hxx | 4 svx/source/tbxctrls/lboxctrl.cxx | 12 svx/source/tbxctrls/linectrl.cxx | 10 svx/source/tbxctrls/tbcontrl.cxx | 248 +++++------------ svx/source/tbxctrls/tbxcolorupdate.cxx | 12 sw/source/uibase/docvw/edtwin.cxx | 6 14 files changed, 113 insertions(+), 364 deletions(-)
New commits: commit 9125a4f3f63a7f49fd307908c181e999120063e0 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu Oct 13 10:20:31 2016 +0300 Use FeatureStateEvent directly for status updates ... for SfxPopupWindow and SvxColorToolBoxControl (the latter shares BorderColorStatus with SvxColorWindow_Impl, so it was easier to convert it too). Change-Id: Ifcb23fe5809e467322d1cf4d790420886ac79b47 diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.cxx b/chart2/source/controller/sidebar/ChartColorWrapper.cxx index 4b2c769..b2ff619 100644 --- a/chart2/source/controller/sidebar/ChartColorWrapper.cxx +++ b/chart2/source/controller/sidebar/ChartColorWrapper.cxx @@ -11,9 +11,7 @@ #include "ChartController.hxx" -#include <editeng/colritem.hxx> #include <svx/tbcontrl.hxx> -#include <svx/svxids.hrc> namespace chart { namespace sidebar { @@ -88,13 +86,14 @@ void ChartColorWrapper::updateData() if (!xPropSet.is()) return; - css::uno::Any aAny = xPropSet->getPropertyValue(maPropertyName); - sal_uInt32 nColor = 0; - aAny >>= nColor; - Color aColor(nColor); + css::util::URL aUrl; + aUrl.Complete = ".uno:FillColor"; - SvxColorItem aItem(aColor, SID_ATTR_FILL_COLOR); - mpControl->StateChanged(SID_ATTR_FILL_COLOR, SfxItemState::SET, &aItem); + css::frame::FeatureStateEvent aEvent; + aEvent.FeatureURL = aUrl; + aEvent.IsEnabled = true; + aEvent.State = xPropSet->getPropertyValue(maPropertyName); + mpControl->statusChanged(aEvent); } } } diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx index 60536f5..6185ce7 100644 --- a/include/sfx2/tbxctrl.hxx +++ b/include/sfx2/tbxctrl.hxx @@ -95,10 +95,7 @@ protected: void UnbindListener(); void AddStatusListener( const OUString& rCommandURL ); - // SfxStatusListenerInterface - using FloatingWindow::StateChanged; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState ); + virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ); public: SfxPopupWindow( sal_uInt16 nId, diff --git a/include/svx/linectrl.hxx b/include/svx/linectrl.hxx index e29fe6c..99c4dbc 100644 --- a/include/svx/linectrl.hxx +++ b/include/svx/linectrl.hxx @@ -77,8 +77,6 @@ public: class SvxLineEndWindow : public SfxPopupWindow { - using FloatingWindow::StateChanged; - private: XLineEndListRef pLineEndList; VclPtr<ValueSet> aLineEndSet; @@ -116,8 +114,7 @@ public: void StartSelection(); - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState ) override; + virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; }; diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx index 174c16d..21f07f2 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -222,15 +222,13 @@ class BorderColorStatus public: BorderColorStatus(); ~BorderColorStatus(); - void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState); + bool statusChanged( const css::frame::FeatureStateEvent& rEvent ); Color GetColor(); }; typedef std::function<void(const OUString&, const Color&)> ColorSelectFunction; class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl { - using SfxToolBoxControl::StateChanged; - std::unique_ptr<svx::ToolboxButtonColorUpdater> m_xBtnUpdater; PaletteManager m_aPaletteManager; BorderColorStatus m_aBorderColorStatus; @@ -242,8 +240,9 @@ public: SvxColorToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rToolBox); virtual ~SvxColorToolBoxControl() override; - virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState) override; + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException, std::exception ) override; + virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override; virtual void Select(sal_uInt16 nSelectModifier) override; diff --git a/reportdesign/source/ui/misc/toolboxcontroller.cxx b/reportdesign/source/ui/misc/toolboxcontroller.cxx index c103c20..5e05843 100644 --- a/reportdesign/source/ui/misc/toolboxcontroller.cxx +++ b/reportdesign/source/ui/misc/toolboxcontroller.cxx @@ -38,7 +38,6 @@ #include <editeng/fontitem.hxx> #include <editeng/fhgtitem.hxx> #include <svx/tbcontrl.hxx> -#include <editeng/colritem.hxx> #include <cppuhelper/supportsservice.hxx> @@ -195,12 +194,7 @@ void SAL_CALL OToolboxController::statusChanged( const FeatureStateEvent& Event { case SID_ATTR_CHAR_COLOR2: case SID_BACKGROUND_COLOR: - { - util::Color nColor(COL_TRANSPARENT); - Event.State >>= nColor; - SvxColorItem aColorItem(::Color(nColor), 1); - static_cast<SvxColorToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled ? SfxItemState::SET : SfxItemState::DISABLED,&aColorItem); - } + m_pToolbarController->statusChanged( Event ); break; case SID_ATTR_CHAR_FONT: { diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index ba6da54..08f0ae9 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -754,121 +754,7 @@ SfxFrameStatusListener::~SfxFrameStatusListener() void SAL_CALL SfxFrameStatusListener::statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException, std::exception ) { - SfxViewFrame* pViewFrame = nullptr; - Reference < XController > xController; - - SolarMutexGuard aGuard; - if ( m_xFrame.is() ) - xController = m_xFrame->getController(); - - Reference < XDispatchProvider > xProvider( xController, UNO_QUERY ); - if ( xProvider.is() ) - { - Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, OUString(), 0 ); - if ( xDisp.is() ) - { - Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY ); - SfxOfficeDispatch* pDisp = nullptr; - if ( xTunnel.is() ) - { - sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier()); - pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation )); - } - - if ( pDisp ) - pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); - } - } - - sal_uInt16 nSlotId = 0; - SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame ); - const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path ); - if ( pSlot ) - nSlotId = pSlot->GetSlotId(); - - if ( nSlotId > 0 ) - { - if ( rEvent.Requery ) - { - // requery for the notified state - addStatusListener( rEvent.FeatureURL.Complete ); - } - else - { - SfxItemState eState = SfxItemState::DISABLED; - SfxPoolItem* pItem = nullptr; - if ( rEvent.IsEnabled ) - { - eState = SfxItemState::DEFAULT; - css::uno::Type aType = rEvent.State.getValueType(); - - if ( aType == cppu::UnoType<void>::get() ) - { - pItem = new SfxVoidItem( nSlotId ); - eState = SfxItemState::UNKNOWN; - } - else if ( aType == cppu::UnoType<bool>::get() ) - { - bool bTemp = false; - rEvent.State >>= bTemp ; - pItem = new SfxBoolItem( nSlotId, bTemp ); - } - else if ( aType == ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get()) - { - sal_uInt16 nTemp = 0; - rEvent.State >>= nTemp ; - pItem = new SfxUInt16Item( nSlotId, nTemp ); - } - else if ( aType == cppu::UnoType<sal_uInt32>::get() ) - { - sal_uInt32 nTemp = 0; - rEvent.State >>= nTemp ; - pItem = new SfxUInt32Item( nSlotId, nTemp ); - } - else if ( aType == cppu::UnoType<OUString>::get() ) - { - OUString sTemp ; - rEvent.State >>= sTemp ; - pItem = new SfxStringItem( nSlotId, sTemp ); - } - else if ( aType == cppu::UnoType< css::frame::status::ItemStatus>::get() ) - { - ItemStatus aItemStatus; - rEvent.State >>= aItemStatus; - SfxItemState tmpState = (SfxItemState) aItemStatus.State; - // make sure no-one tries to send us a combination of states - if (tmpState != SfxItemState::UNKNOWN && tmpState != SfxItemState::DISABLED && - tmpState != SfxItemState::READONLY && tmpState != SfxItemState::DONTCARE && - tmpState != SfxItemState::DEFAULT && tmpState != SfxItemState::SET) - throw css::uno::RuntimeException("unknown status"); - eState = tmpState; - pItem = new SfxVoidItem( nSlotId ); - } - else if ( aType == cppu::UnoType< css::frame::status::Visibility>::get() ) - { - Visibility aVisibilityStatus; - rEvent.State >>= aVisibilityStatus; - pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible ); - } - else - { - if ( pSlot ) - pItem = pSlot->GetType()->CreateItem(); - if ( pItem ) - { - pItem->SetWhich( nSlotId ); - pItem->PutValue( rEvent.State, 0 ); - } - else - pItem = new SfxVoidItem( nSlotId ); - } - } - - if ( m_pCallee ) - m_pCallee->StateChanged( nSlotId, eState, pItem ); - delete pItem; - } - } + m_pCallee->statusChanged( rEvent ); } SfxPopupWindow::SfxPopupWindow( @@ -1060,22 +946,9 @@ void SfxPopupWindow::StartCascading() } -void SfxPopupWindow::StateChanged( - sal_uInt16 /*nSID*/, - SfxItemState eState, - const SfxPoolItem* /*pState*/ ) -/* [Description] - - See also <SfxControllerItem::StateChanged()>. In addition the Popup - will become hidden when eState==SfxItemState::DISABLED and in all other - cases it will be shown again if it is floating. In general this requires - to call the Base class. - - Due to the parent the presentation mode is handled in a special way. -*/ - +void SfxPopupWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent ) { - if ( SfxItemState::DISABLED == eState ) + if ( !rEvent.IsEnabled ) { Hide(); } diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx index 22b6d8a..56b9ed2 100644 --- a/svx/source/tbxctrls/colorwindow.hxx +++ b/svx/source/tbxctrls/colorwindow.hxx @@ -35,8 +35,6 @@ class BorderColorStatus; class SvxColorWindow_Impl : public SfxPopupWindow { - using FloatingWindow::StateChanged; - private: const sal_uInt16 theSlotId; VclPtr<SvxColorValueSet> mpColorSet; @@ -76,7 +74,7 @@ public: void StartSelection(); virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; + virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; void SetSelectedHdl( const Link<const Color&, void>& rLink ) { maSelectedLink = rLink; } }; diff --git a/svx/source/tbxctrls/lboxctrl.cxx b/svx/source/tbxctrls/lboxctrl.cxx index cb81b3d..1aab1bf 100644 --- a/svx/source/tbxctrls/lboxctrl.cxx +++ b/svx/source/tbxctrls/lboxctrl.cxx @@ -50,8 +50,6 @@ class SvxPopupWindowListBox; class SvxPopupWindowListBox: public SfxPopupWindow { - using FloatingWindow::StateChanged; - VclPtr<ListBox> m_pListBox; ToolBox & rToolBox; bool bUserSel; @@ -64,8 +62,7 @@ public: // SfxPopupWindow virtual void PopupModeEnd() override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState ) override; + virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; inline ListBox & GetListBox() { return *m_pListBox; } @@ -118,11 +115,10 @@ void SvxPopupWindowListBox::PopupModeEnd() } -void SvxPopupWindowListBox::StateChanged( - sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SvxPopupWindowListBox::statusChanged( const css::frame::FeatureStateEvent& rEvent ) { - rToolBox.EnableItem( nTbxId, ( SfxToolBoxControl::GetItemState( pState ) != SfxItemState::DISABLED) ); - SfxPopupWindow::StateChanged( nSID, eState, pState ); + rToolBox.EnableItem( nTbxId, rEvent.IsEnabled ); + SfxPopupWindow::statusChanged( rEvent ); } SvxListBoxControl::SvxListBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx index c0b1c3e..5d5a2f5 100644 --- a/svx/source/tbxctrls/linectrl.cxx +++ b/svx/source/tbxctrls/linectrl.cxx @@ -483,15 +483,15 @@ void SvxLineEndWindow::StartSelection() } -void SvxLineEndWindow::StateChanged( - sal_uInt16 nSID, SfxItemState, const SfxPoolItem* pState ) +void SvxLineEndWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent ) { - if ( nSID == SID_LINEEND_LIST ) + if ( rEvent.FeatureURL.Complete == ".uno:LineEndListState" ) { // The list of line ends (LineEndList) has changed - if ( pState && dynamic_cast<const SvxLineEndListItem*>( pState) != nullptr) + css::uno::Reference< css::uno::XWeak > xWeak; + if ( rEvent.State >>= xWeak ) { - pLineEndList = static_cast<const SvxLineEndListItem*>(pState)->GetLineEndList(); + pLineEndList.set( static_cast< XLineEndList* >( xWeak.get() ) ); DBG_ASSERT( pLineEndList.is(), "LineEndList not found" ); aLineEndSet->Clear(); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 6ea8a30..e6309dd 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -54,6 +54,7 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <svtools/colorcfg.hxx> +#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -1466,38 +1467,28 @@ void SvxColorWindow_Impl::StartSelection() mpColorSet->StartSelection(); } -void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SvxColorWindow_Impl::statusChanged( const css::frame::FeatureStateEvent& rEvent ) { - if ( nSID == SID_COLOR_TABLE ) + if ( rEvent.IsEnabled && rEvent.FeatureURL.Complete == ".uno:ColorTableState" + && mrPaletteManager.GetPalette() == 0) { - if ( SfxItemState::DEFAULT == eState && mrPaletteManager.GetPalette() == 0 ) - { - mrPaletteManager.ReloadColorSet(*mpColorSet); - mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount()); - } + mrPaletteManager.ReloadColorSet(*mpColorSet); + mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount()); } else { mpColorSet->SetNoSelection(); Color aColor( COL_TRANSPARENT ); - if ( nSID == SID_FRAME_LINECOLOR - || nSID == SID_ATTR_BORDER_DIAG_TLBR - || nSID == SID_ATTR_BORDER_DIAG_BLTR ) + if ( mrBorderColorStatus.statusChanged( rEvent ) ) { - mrBorderColorStatus.StateChanged( nSID, eState, pState ); aColor = mrBorderColorStatus.GetColor(); } - else if ( SfxItemState::DEFAULT <= eState && pState ) + else if ( rEvent.IsEnabled ) { - if ( dynamic_cast<const SvxColorItem*>( pState) != nullptr ) - aColor = static_cast<const SvxColorItem*>(pState)->GetValue(); - else if ( dynamic_cast<const XLineColorItem*>( pState) != nullptr ) - aColor = static_cast<const XLineColorItem*>(pState)->GetColorValue(); - else if ( dynamic_cast<const XFillColorItem*>( pState) != nullptr ) - aColor = static_cast<const XFillColorItem*>(pState)->GetColorValue(); - else if ( dynamic_cast<const SvxBackgroundColorItem*>( pState) != nullptr ) - aColor = static_cast<const SvxBackgroundColorItem*>(pState)->GetValue(); + sal_Int32 nValue; + if ( rEvent.State >>= nValue ) + aColor = nValue; } if ( aColor == COL_TRANSPARENT ) @@ -1526,33 +1517,38 @@ BorderColorStatus::~BorderColorStatus() { } -void BorderColorStatus::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState ) +bool BorderColorStatus::statusChanged( const css::frame::FeatureStateEvent& rEvent ) { - if ( SfxItemState::DEFAULT <= eState && pState ) + Color aColor( COL_TRANSPARENT ); + + if ( rEvent.FeatureURL.Complete == ".uno:FrameLineColor" ) + { + sal_Int32 nValue; + if ( rEvent.IsEnabled && ( rEvent.State >>= nValue ) ) + aColor = nValue; + + maColor = aColor; + return true; + } + else { - if ( nSID == SID_FRAME_LINECOLOR && dynamic_cast<const SvxColorItem*>( pState) != nullptr ) + css::table::BorderLine2 aTable; + if ( rEvent.IsEnabled && ( rEvent.State >>= aTable ) ) + aColor = aTable.Color; + + if ( rEvent.FeatureURL.Complete == ".uno:BorderTLBR" ) { - maColor = static_cast< const SvxColorItem* >(pState)->GetValue(); + maTLBRColor = aColor; + return true; } - else if ( dynamic_cast<const SvxLineItem*>( pState) != nullptr ) + else if ( rEvent.FeatureURL.Complete == ".uno:BorderBLTR" ) { - const SvxBorderLine* pLine = static_cast< const SvxLineItem* >(pState)->GetLine(); - Color aColor ( COL_TRANSPARENT ); - if ( pLine ) - aColor = pLine->GetColor(); - - if ( nSID == SID_ATTR_BORDER_DIAG_TLBR ) - maTLBRColor = aColor; - else if ( nSID == SID_ATTR_BORDER_DIAG_BLTR ) - maBLTRColor = aColor; + maBLTRColor = aColor; + return true; } } - else if ( nSID == SID_FRAME_LINECOLOR ) - maColor = COL_TRANSPARENT; - else if ( nSID == SID_ATTR_BORDER_DIAG_TLBR ) - maTLBRColor = COL_TRANSPARENT; - else if ( nSID == SID_ATTR_BORDER_DIAG_BLTR ) - maBLTRColor = COL_TRANSPARENT; + + return false; } Color BorderColorStatus::GetColor() @@ -2709,34 +2705,32 @@ IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const Color&, rColor, void) m_aPaletteManager.SetLastColor( rColor ); } -void SvxColorToolBoxControl::StateChanged( - sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent ) + throw ( css::uno::RuntimeException, std::exception ) { - if ( nSID == SID_ATTR_CHAR_COLOR_EXT || nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT ) - SfxToolBoxControl::StateChanged( nSID, eState, pState ); - else if ( !m_bSplitButton ) + if ( rEvent.FeatureURL.Complete == m_aCommandURL ) + GetToolBox().EnableItem( GetId(), rEvent.IsEnabled ); + + bool bValue; + if ( !m_bSplitButton ) { Color aColor( COL_TRANSPARENT ); - if ( nSID == SID_FRAME_LINECOLOR - || nSID == SID_ATTR_BORDER_DIAG_TLBR - || nSID == SID_ATTR_BORDER_DIAG_BLTR ) + if ( m_aBorderColorStatus.statusChanged( rEvent ) ) { - m_aBorderColorStatus.StateChanged( nSID, eState, pState ); aColor = m_aBorderColorStatus.GetColor(); } - else if ( SfxItemState::DEFAULT <= eState && pState ) + else if ( rEvent.IsEnabled ) { - if ( dynamic_cast<const SvxColorItem*>( pState) != nullptr ) - aColor = static_cast< const SvxColorItem* >(pState)->GetValue(); - else if ( dynamic_cast<const XLineColorItem*>( pState) != nullptr ) - aColor = static_cast< const XLineColorItem* >(pState)->GetColorValue(); - else if ( dynamic_cast<const XFillColorItem*>( pState) != nullptr ) - aColor = static_cast< const XFillColorItem* >(pState)->GetColorValue(); + sal_Int32 nValue; + if ( rEvent.State >>= nValue ) + aColor = nValue; } m_xBtnUpdater->Update( aColor ); m_aPaletteManager.SetLastColor(aColor); } + else if ( rEvent.State >>= bValue ) + GetToolBox().CheckItem( GetId(), bValue ); } void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) commit f1bae1b5c0ba7949f6a91ba938be18589f9accaa Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed Oct 12 21:15:03 2016 +0300 This comment is no longer true Change-Id: I5ad9bcba65f1f467f230fe05dff725c474c75494 diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 688a348..6ea8a30 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -2608,15 +2608,6 @@ VclPtr<vcl::Window> SvxFontNameToolBoxControl::CreateItemWindow( vcl::Window *pP return pBox.get(); } -/* Note: - The initial color shown on the button is set in /core/svx/source/tbxctrls/tbxcolorupdate.cxx - (ToolboxButtonColorUpdater::ToolboxButtonColorUpdater()) . - The initial color used by the button is set in /core/svx/source/tbxcntrls/tbcontrl.cxx - (SvxColorToolBoxControl::SvxColorToolBoxControl()) - and in case of writer for text(background)color also in /core/sw/source/uibase/docvw/edtwin.cxx - (SwEditWin::m_aTextBackColor and SwEditWin::m_aTextColor) - */ - SvxColorToolBoxControl::SvxColorToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx index 4756980..f41b913 100644 --- a/svx/source/tbxctrls/tbxcolorupdate.cxx +++ b/svx/source/tbxctrls/tbxcolorupdate.cxx @@ -29,17 +29,6 @@ namespace svx { - //= ToolboxButtonColorUpdater - - /* Note: - The initial color shown on the button is set in /core/svx/source/tbxctrls/tbxcolorupdate.cxx - (ToolboxButtonColorUpdater::ToolboxButtonColorUpdater()) . - The initial color used by the button is set in /core/svx/source/tbxctrls/tbcontrl.cxx - (SvxColorToolBoxControl::SvxColorToolBoxControl()) - and in case of writer for text(background)color also in /core/sw/source/uibase/docvw/edtwin.cxx - (SwEditWin::m_aTextBackColor and SwEditWin::m_aTextColor) - */ - ToolboxButtonColorUpdater::ToolboxButtonColorUpdater( sal_uInt16 nId, sal_uInt16 nTbxBtnId, ToolBox* pToolBox) : mnBtnId(nTbxBtnId) diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index d39c6d9..d4a3514 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -186,12 +186,8 @@ QuickHelpData* SwEditWin::m_pQuickHlpData = nullptr; long SwEditWin::m_nDDStartPosY = 0; long SwEditWin::m_nDDStartPosX = 0; /** - * The initial color shown on the button is set in /core/svx/source/tbxctrls/tbxcolorupdate.cxx + * The actual color used by the button is set in svx/source/tbxctrls/tbxcolorupdate.cxx * (ToolboxButtonColorUpdater::ToolboxButtonColorUpdater()) . - * The initial color used by the button is set in /core/svx/source/tbxcntrls/tbcontrl.cxx - * (SvxColorToolBoxControl::SvxColorToolBoxControl()) - * and in case of writer for text(background)color also in /core/sw/source/uibase/docvw/edtwin.cxx - * (SwEditWin::m_aTextBackColor and SwEditWin::m_aTextColor) */ Color SwEditWin::m_aWaterCanTextBackColor(COL_YELLOW); Color SwEditWin::m_aWaterCanTextColor(COL_RED); commit a7a048f9a2ee1ef88eec0b02d44a94562788aa8a Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed Oct 12 21:11:04 2016 +0300 SvxColorToolBoxControl: Some cleanup Change-Id: Iaf908b0c2456a239e343d0fcb89a2ba163b74010 diff --git a/include/svx/tbxcolorupdate.hxx b/include/svx/tbxcolorupdate.hxx index 34e1689..0077eb8 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 db9b012..3ba0485 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<void(const OUString&, const Color&)>& aColorSelectFunction) diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 59cef34..688a348 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -20,6 +20,7 @@ #include <string> #include <utility> +#include <comphelper/propertysequence.hxx> #include <tools/color.hxx> #include <svl/poolitem.hxx> #include <svl/eitem.hxx> @@ -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 ef16fc1..4756980 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; commit 670dc7515046dbb1c3574329fe22721d81e9a15e Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu Oct 13 10:29:19 2016 +0300 SvxColorToolBoxControl: Unify members prefix and rename bSidebarType to something more sensible. Change-Id: Ia41afe4ecc3068394cb41cc4c3caddce59905103 diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx index 7c19420..174c16d 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -232,10 +232,10 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl using SfxToolBoxControl::StateChanged; std::unique_ptr<svx::ToolboxButtonColorUpdater> m_xBtnUpdater; - PaletteManager mPaletteManager; - BorderColorStatus maBorderColorStatus; - bool bSidebarType; - ColorSelectFunction maColorSelectFunction; + PaletteManager m_aPaletteManager; + BorderColorStatus m_aBorderColorStatus; + bool m_bSplitButton; + ColorSelectFunction m_aColorSelectFunction; DECL_LINK(SelectedHdl, const Color&, void); public: SFX_DECL_TOOLBOX_CONTROL(); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 6006c4e..59cef34 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -2621,49 +2621,45 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( sal_uInt16 nId, ToolBox& rTbx ): SfxToolBoxControl( nSlotId, nId, rTbx ), - maColorSelectFunction(PaletteManager::DispatchColorCommand) + m_bSplitButton(dynamic_cast< sfx2::sidebar::SidebarToolBox* >(&rTbx) == nullptr), + m_aColorSelectFunction(PaletteManager::DispatchColorCommand) { - if ( dynamic_cast< sfx2::sidebar::SidebarToolBox* >(&rTbx) ) - bSidebarType = true; - else - bSidebarType = false; - // The following commands are available at the various modules switch( nSlotId ) { case SID_ATTR_CHAR_COLOR: addStatusListener( ".uno:Color"); - mPaletteManager.SetLastColor( COL_RED ); - bSidebarType = false; + m_aPaletteManager.SetLastColor( COL_RED ); + m_bSplitButton = true; break; case SID_ATTR_CHAR_COLOR2: addStatusListener( ".uno:CharColorExt"); - mPaletteManager.SetLastColor( COL_RED ); - bSidebarType = false; + m_aPaletteManager.SetLastColor( COL_RED ); + m_bSplitButton = true; break; case SID_BACKGROUND_COLOR: addStatusListener( ".uno:BackgroundColor"); - mPaletteManager.SetLastColor( COL_YELLOW ); + m_aPaletteManager.SetLastColor( COL_YELLOW ); break; case SID_ATTR_CHAR_COLOR_BACKGROUND: addStatusListener( ".uno:CharBackgroundExt"); - mPaletteManager.SetLastColor( COL_YELLOW ); - bSidebarType = false; + m_aPaletteManager.SetLastColor( COL_YELLOW ); + m_bSplitButton = true; break; case SID_ATTR_CHAR_BACK_COLOR: addStatusListener( ".uno:CharBackColor"); - mPaletteManager.SetLastColor( COL_YELLOW ); + m_aPaletteManager.SetLastColor( COL_YELLOW ); break; case SID_FRAME_LINECOLOR: addStatusListener( ".uno:FrameLineColor"); addStatusListener( ".uno:BorderTLBR"); addStatusListener( ".uno:BorderBLTR"); - mPaletteManager.SetLastColor( COL_BLUE ); + m_aPaletteManager.SetLastColor( COL_BLUE ); break; case SID_EXTRUSION_3D_COLOR: @@ -2672,22 +2668,18 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( case SID_ATTR_LINE_COLOR: addStatusListener( ".uno:XLineColor"); - mPaletteManager.SetLastColor( COL_DEFAULT_SHAPE_STROKE ); + m_aPaletteManager.SetLastColor( COL_DEFAULT_SHAPE_STROKE ); break; case SID_ATTR_FILL_COLOR: addStatusListener( ".uno:FillColor"); - mPaletteManager.SetLastColor( COL_DEFAULT_SHAPE_FILLING ); + m_aPaletteManager.SetLastColor( COL_DEFAULT_SHAPE_FILLING ); break; } - if ( bSidebarType ) - rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits( nId ) ); - else - rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) ); - + rTbx.SetItemBits( nId, rTbx.GetItemBits( nId ) | ( m_bSplitButton ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY ) ); m_xBtnUpdater.reset( new svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) ); - mPaletteManager.SetBtnUpdater( m_xBtnUpdater.get() ); + m_aPaletteManager.SetBtnUpdater( m_xBtnUpdater.get() ); } SvxColorToolBoxControl::~SvxColorToolBoxControl() @@ -2696,8 +2688,8 @@ SvxColorToolBoxControl::~SvxColorToolBoxControl() void SvxColorToolBoxControl::setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction) { - maColorSelectFunction = aColorSelectFunction; - mPaletteManager.SetColorSelectFunction(aColorSelectFunction); + m_aColorSelectFunction = aColorSelectFunction; + m_aPaletteManager.SetColorSelectFunction(aColorSelectFunction); } VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow() @@ -2706,13 +2698,13 @@ VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow() VclPtr<SvxColorWindow_Impl>::Create( m_aCommandURL, - mPaletteManager, - maBorderColorStatus, + m_aPaletteManager, + m_aBorderColorStatus, GetSlotId(), m_xFrame, SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ), &GetToolBox(), - maColorSelectFunction); + m_aColorSelectFunction); switch( GetSlotId() ) { @@ -2746,7 +2738,7 @@ VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow() FloatWinPopupFlags::AllowTearOff|FloatWinPopupFlags::NoAppFocusClose ); pColorWin->StartSelection(); SetPopupWindow( pColorWin ); - if ( !bSidebarType ) + if ( m_bSplitButton ) pColorWin->SetSelectedHdl( LINK( this, SvxColorToolBoxControl, SelectedHdl ) ); return pColorWin; } @@ -2754,7 +2746,7 @@ VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow() IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const Color&, rColor, void) { m_xBtnUpdater->Update( rColor ); - mPaletteManager.SetLastColor( rColor ); + m_aPaletteManager.SetLastColor( rColor ); } void SvxColorToolBoxControl::StateChanged( @@ -2762,7 +2754,7 @@ void SvxColorToolBoxControl::StateChanged( { if ( nSID == SID_ATTR_CHAR_COLOR_EXT || nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT ) SfxToolBoxControl::StateChanged( nSID, eState, pState ); - else if ( bSidebarType ) + else if ( !m_bSplitButton ) { Color aColor( COL_TRANSPARENT ); @@ -2770,8 +2762,8 @@ void SvxColorToolBoxControl::StateChanged( || nSID == SID_ATTR_BORDER_DIAG_TLBR || nSID == SID_ATTR_BORDER_DIAG_BLTR ) { - maBorderColorStatus.StateChanged( nSID, eState, pState ); - aColor = maBorderColorStatus.GetColor(); + m_aBorderColorStatus.StateChanged( nSID, eState, pState ); + aColor = m_aBorderColorStatus.GetColor(); } else if ( SfxItemState::DEFAULT <= eState && pState ) { @@ -2783,13 +2775,13 @@ void SvxColorToolBoxControl::StateChanged( aColor = static_cast< const XFillColorItem* >(pState)->GetColorValue(); } m_xBtnUpdater->Update( aColor ); - mPaletteManager.SetLastColor(aColor); + m_aPaletteManager.SetLastColor(aColor); } } void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) { - if ( bSidebarType ) + if ( !m_bSplitButton ) { // Open the popup also when Enter key is pressed. css::uno::Reference< css::awt::XWindow > xWin = createPopupWindow(); @@ -2851,17 +2843,17 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) Sequence< PropertyValue > aArgs( 1 ); aArgs[0].Name = aParamName; - aArgs[0].Value = makeAny( (sal_uInt32)( mPaletteManager.GetLastColor().GetColor() )); + aArgs[0].Value = makeAny( (sal_uInt32)( m_aPaletteManager.GetLastColor().GetColor() )); Dispatch( aCommand, aArgs ); } sal_Bool SvxColorToolBoxControl::opensSubToolbar() throw (css::uno::RuntimeException, std::exception) { - // For a split button (i.e. bSidebarType == false), we mark this controller as - // a sub-toolbar controller, so we get notified (through updateImage method) on - // button image changes, and could redraw the last used color on top of it. - return !bSidebarType; + // For a split button, we mark this controller as a sub-toolbar controller, + // so we get notified (through updateImage method) on button image changes, + // and could redraw the last used color on top of it. + return m_bSplitButton; } void SvxColorToolBoxControl::updateImage() @@ -2871,7 +2863,7 @@ void SvxColorToolBoxControl::updateImage() if ( !!aImage ) { GetToolBox().SetItemImage( GetId(), aImage ); - m_xBtnUpdater->Update( mPaletteManager.GetLastColor(), true ); + m_xBtnUpdater->Update( m_aPaletteManager.GetLastColor(), true ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits