summaryrefslogtreecommitdiff
path: root/sc
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-06 18:08:12 +0200
commitf54d3aa9bee7bc794b18b968835c6d6393f350ea (patch)
tree8b1f59c06e13886081df29526b68479e3d5d02dc /sc
parent22d458164ae903f502e82f471c22ff8e1ebbb839 (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>
Diffstat (limited to 'sc')
-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 20730f1912ea..b51e63419f57 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -494,6 +494,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,
@@ -505,7 +531,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();