sc/source/ui/inc/tabview.hxx  |    2 ++
 sc/source/ui/view/tabview.cxx |   31 ++++++++++++++++++-------------
 2 files changed, 20 insertions(+), 13 deletions(-)

New commits:
commit f87a0480af5b15d673490a5b1736133148ec7333
Author:     Povilas Kanapickas <povi...@radix.lt>
AuthorDate: Wed Dec 7 03:13:28 2022 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Dec 14 13:46:49 2022 +0000

    sc: Extract ScTabView::SetZoomPercentFromCommand()
    
    Change-Id: I06ece9a99886d94bf0b3396730951760cb199e97
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143755
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

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;

Reply via email to