summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-06-23 21:15:40 +0530
committerDennis Francis <dennis.francis@collabora.com>2020-07-11 07:34:55 +0200
commitb179383df08a9f1e3c8e58e6e41dddb7de85266e (patch)
tree60d42427c12ebbebd852aab0c8554d356570c048
parent390ea54b54003845cef59622c2a4705824555096 (diff)
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@gmail.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com> (cherry picked from commit f54d3aa9bee7bc794b18b968835c6d6393f350ea) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98163 Tested-by: Jenkins
-rw-r--r--sc/source/ui/unoobj/docuno.cxx38
1 files changed, 37 insertions, 1 deletions
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();