[Libreoffice-commits] core.git: sc/source

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Sat Jul 11 05:35:23 UTC 2020


 sc/source/ui/unoobj/docuno.cxx |   38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

New commits:
commit b179383df08a9f1e3c8e58e6e41dddb7de85266e
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Tue Jun 23 21:15:40 2020 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Sat Jul 11 07:34:55 2020 +0200

    paintTile: Try to find a view that matches the tile-zoom requested...
    
    by iterating over first few shells to avoid switching of zooms in
    ScGridWindow::PaintTile and hence avoid grid-offset recomputation on all
    shapes which is not cheap.
    
    Change-Id: Ib086112ebd504087d80c6d6f2879a69dca8ce44f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98168
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>
    (cherry picked from commit f54d3aa9bee7bc794b18b968835c6d6393f350ea)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98163
    Tested-by: Jenkins

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index a3e3f8c603b4..50749096ec9c 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -500,6 +500,32 @@ void ScModelObj::RepaintRange( const ScRangeList& rRange )
         pDocShell->PostPaint( rRange, PaintPartFlags::Grid );
 }
 
+static ScViewData* lcl_getViewMatchingDocZoomTab(const Fraction& rZoomX,
+                                              const Fraction& rZoomY,
+                                              const SCTAB nTab,
+                                              const ViewShellDocId& rDocId,
+                                              const size_t nMaxIter = 5)
+{
+    size_t nIter = 0;
+    for (SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+            pViewShell && nIter < nMaxIter;
+            (pViewShell = SfxViewShell::GetNext(*pViewShell)), ++nIter)
+    {
+        if (pViewShell->GetDocId() != rDocId)
+            continue;
+
+        ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
+        if (!pTabViewShell)
+            continue;
+
+        ScViewData& rData = pTabViewShell->GetViewData();
+        if (rData.GetTabNo() == nTab && rData.GetZoomX() == rZoomX && rData.GetZoomY() == rZoomY)
+            return &rData;
+    }
+
+    return nullptr;
+}
+
 void ScModelObj::paintTile( VirtualDevice& rDevice,
                             int nOutputWidth, int nOutputHeight,
                             int nTilePosX, int nTilePosY,
@@ -511,7 +537,17 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
     if (!pViewShell)
         return;
 
-    ScViewData* pViewData = &pViewShell->GetViewData();
+    ScViewData* pActiveViewData = &pViewShell->GetViewData();
+    Fraction aFracX(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
+    Fraction aFracY(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
+
+    // Try to find a view that matches the tile-zoom requested by iterating over
+    // first few shells. This is to avoid switching of zooms in ScGridWindow::PaintTile
+    // and hence avoid grid-offset recomputation on all shapes which is not cheap.
+    ScViewData* pViewData = lcl_getViewMatchingDocZoomTab(aFracX, aFracY,
+            pActiveViewData->GetTabNo(), pViewShell->GetDocId());
+    if (!pViewData)
+        pViewData = pActiveViewData;
 
     ScGridWindow* pGridWindow = pViewData->GetActiveWin();
 


More information about the Libreoffice-commits mailing list