summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-10-13 10:20:31 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2016-10-13 11:12:27 +0300
commit9125a4f3f63a7f49fd307908c181e999120063e0 (patch)
treeef7d47475a37b87cda0e97b766143ab3e4c55cb5 /svx
parentf1bae1b5c0ba7949f6a91ba938be18589f9accaa (diff)
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
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/colorwindow.hxx4
-rw-r--r--svx/source/tbxctrls/lboxctrl.cxx12
-rw-r--r--svx/source/tbxctrls/linectrl.cxx10
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx106
4 files changed, 60 insertions, 72 deletions
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 22b6d8af9d5e..56b9ed27d70e 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 cb81b3d342e8..1aab1bfd8fd3 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 c0b1c3eb45a0..5d5a2f54d0eb 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 6ea8a30c53cd..e6309dd0c428 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*/)