From f87a0480af5b15d673490a5b1736133148ec7333 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 7 Dec 2022 03:13:28 +0200 Subject: sc: Extract ScTabView::SetZoomPercentFromCommand() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I06ece9a99886d94bf0b3396730951760cb199e97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143755 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- sc/source/ui/inc/tabview.hxx | 2 ++ sc/source/ui/view/tabview.cxx | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index ebb7337d78b7..f62b2c4f9cba 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -254,6 +254,8 @@ private: void PaintRangeFinderEntry (const ScRangeFindData* pData, SCTAB nTab); + void SetZoomPercentFromCommand(sal_uInt16 nZoomPercent); + protected: void UpdateHeaderWidth( const ScVSplitPos* pWhich = nullptr, const SCROW* pPosY = nullptr ); diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 94a9aa144ad6..f12327b04a5d 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -935,6 +935,23 @@ Point ScTabView::GetGridOffset() const // --- Scroll-Bars -------------------------------------------------------- +void ScTabView::SetZoomPercentFromCommand(sal_uInt16 nZoomPercent) +{ + // scroll wheel doesn't set the AppOptions default + + bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); + SetZoomType(SvxZoomType::PERCENT, bSyncZoom); + Fraction aFract(nZoomPercent, 100); + SetZoom(aFract, aFract, bSyncZoom); + PaintGrid(); + PaintTop(); + PaintLeft(); + aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM); + aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER); + aViewData.GetBindings().Invalidate( SID_ZOOM_IN); + aViewData.GetBindings().Invalidate( SID_ZOOM_OUT); +} + bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) { HideNoteMarker(); @@ -957,19 +974,7 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) nNew = std::min( MAXZOOM, basegfx::zoomtools::zoomIn( nOld )); if ( nNew != nOld ) { - // scroll wheel doesn't set the AppOptions default - - bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); - SetZoomType( SvxZoomType::PERCENT, bSyncZoom ); - Fraction aFract( nNew, 100 ); - SetZoom( aFract, aFract, bSyncZoom ); - PaintGrid(); - PaintTop(); - PaintLeft(); - aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM ); - aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); - aViewData.GetBindings().Invalidate( SID_ZOOM_IN); - aViewData.GetBindings().Invalidate( SID_ZOOM_OUT); + SetZoomPercentFromCommand(nNew); } bDone = true; -- cgit