diff options
-rw-r--r-- | include/svx/zoomsliderctrl.hxx | 6 | ||||
-rw-r--r-- | svx/source/stbctrls/zoomsliderctrl.cxx | 66 |
2 files changed, 34 insertions, 38 deletions
diff --git a/include/svx/zoomsliderctrl.hxx b/include/svx/zoomsliderctrl.hxx index a15121782c2c..7af69db82c7c 100644 --- a/include/svx/zoomsliderctrl.hxx +++ b/include/svx/zoomsliderctrl.hxx @@ -22,6 +22,7 @@ #include <sfx2/stbitem.hxx> #include <svx/svxdllapi.h> +#include <boost/scoped_ptr.hpp> // class SvxZoomSliderControl ---------------------------------------- @@ -30,11 +31,14 @@ class SVX_DLLPUBLIC SvxZoomSliderControl : public SfxStatusBarControl private: struct SvxZoomSliderControl_Impl; - SvxZoomSliderControl_Impl* mpImpl; + boost::scoped_ptr<SvxZoomSliderControl_Impl> mpImpl; sal_uInt16 Offset2Zoom( long nOffset ) const; long Zoom2Offset( sal_uInt16 nZoom ) const; + void repaintAndExecute(); + void forceRepaint() const; + public: SFX_DECL_STATUSBAR_CONTROL(); diff --git a/svx/source/stbctrls/zoomsliderctrl.cxx b/svx/source/stbctrls/zoomsliderctrl.cxx index e0fa87935cc8..c7b0092109f3 100644 --- a/svx/source/stbctrls/zoomsliderctrl.cxx +++ b/svx/source/stbctrls/zoomsliderctrl.cxx @@ -194,7 +194,6 @@ SvxZoomSliderControl::SvxZoomSliderControl( sal_uInt16 _nSlotId, sal_uInt16 _nI SvxZoomSliderControl::~SvxZoomSliderControl() { - delete mpImpl; } @@ -255,8 +254,8 @@ void SvxZoomSliderControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eStat } } - if ( !mpImpl->mbOmitPaint && GetStatusBar().AreItemsVisible() ) - GetStatusBar().SetItemData( GetId(), 0 ); // force repaint + if (!mpImpl->mbOmitPaint) + forceRepaint(); } @@ -360,24 +359,7 @@ bool SvxZoomSliderControl::MouseButtonDown( const MouseEvent & rEvt ) if ( nOldZoom == mpImpl->mnCurrentZoom ) return true; - if ( GetStatusBar().AreItemsVisible() ) - GetStatusBar().SetItemData( GetId(), 0 ); // force repaint - - mpImpl->mbOmitPaint = true; // optimization: paint before executing command, - // then omit painting which is triggered by the execute function - - SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom ); - - ::com::sun::star::uno::Any a; - aZoomSliderItem.QueryValue( a ); - - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "ZoomSlider"; - aArgs[0].Value = a; - - execute( aArgs ); - - mpImpl->mbOmitPaint = false; + repaintAndExecute(); return true; } @@ -402,29 +384,39 @@ bool SvxZoomSliderControl::MouseMove( const MouseEvent & rEvt ) { mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff ); - if ( GetStatusBar().AreItemsVisible() ) - GetStatusBar().SetItemData( GetId(), 0 ); // force repaint + repaintAndExecute(); + } + } + + return true; +} - mpImpl->mbOmitPaint = true; // optimization: paint before executing command, - // then omit painting which is triggered by the execute function +void SvxZoomSliderControl::forceRepaint() const +{ + if (GetStatusBar().AreItemsVisible()) + GetStatusBar().SetItemData(GetId(), 0); +} - // commit state change - SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom ); +void SvxZoomSliderControl::repaintAndExecute() +{ + forceRepaint(); - ::com::sun::star::uno::Any a; - aZoomSliderItem.QueryValue( a ); + mpImpl->mbOmitPaint = true; // optimization: paint before executing command, + // then omit painting which is triggered by the execute function - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "ZoomSlider"; - aArgs[0].Value = a; + // commit state change + SvxZoomSliderItem aZoomSliderItem(mpImpl->mnCurrentZoom); - execute( aArgs ); + css::uno::Any any; + aZoomSliderItem.QueryValue(any); - mpImpl->mbOmitPaint = false; - } - } + css::uno::Sequence<css::beans::PropertyValue> aArgs(1); + aArgs[0].Name = "ZoomSlider"; + aArgs[0].Value = any; - return true; + execute(aArgs); + + mpImpl->mbOmitPaint = false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |