summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-25 18:11:29 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-25 21:34:47 +0200
commitf785c166bd80a4c9f50e6c4f7811bfd7ece16c81 (patch)
treee2fd230696bf84c11b520a8e35d3db193aaf69b1 /svx
parent895efd4f399fd717343bbc1ba3538fa01cf0a40a (diff)
zoom slider: impl as scoped_ptr and reduce code duplication
Change-Id: I274e731c70c2735f513e9e8fbf2273aa52310fd2
Diffstat (limited to 'svx')
-rw-r--r--svx/source/stbctrls/zoomsliderctrl.cxx66
1 files changed, 29 insertions, 37 deletions
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: */