sc/inc/docuno.hxx              |    5 ++++-
 sc/source/ui/inc/gridwin.hxx   |    3 ++-
 sc/source/ui/unoobj/docuno.cxx |   33 ++++++++++++++++++++++++---------
 sc/source/ui/view/gridwin4.cxx |    8 ++++----
 4 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit 51819767d341950dfd67448a6cbbf8c1add45f6c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Jun 14 13:01:20 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Jun 14 20:53:11 2023 +0200

    online: speed up scrolling large excel document
    
    the expensive part is the GetTiledRenderingArea(), so lets only do that
    once, instead of twice
    
    Change-Id: I2d18bce1ff116d6d711f0908502963c9743dea8a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153026
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 23de1dad63ce..a75afa2834df 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -308,7 +308,7 @@ public:
                             tools::Long nTileHeight ) override;
 
     /// @see vcl::ITiledRenderable::getDocumentSize().
-    virtual Size getDocumentSize() override;
+    virtual Size getDocumentSize() final override;
 
     /// @see vcl::ITiledRenderable::getDataArea().
     virtual Size getDataArea(long nPart) override;
@@ -397,6 +397,9 @@ public:
 
     /// @see vcl::ITiledRenderable::getViewRenderState().
     OString getViewRenderState() override;
+
+private:
+    Size getDocumentSize(SCCOL& rnTiledRenderingAreaEndCol, SCROW& 
rnTiledRenderingAreaEndRow );
 };
 
 class ScDrawPagesObj final : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 635dd91dc393..ddc9815c2052 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -373,7 +373,8 @@ public:
     void            PaintTile( VirtualDevice& rDevice,
                                int nOutputWidth, int nOutputHeight,
                                int nTilePosX, int nTilePosY,
-                               tools::Long nTileWidth, tools::Long nTileHeight 
);
+                               tools::Long nTileWidth, tools::Long nTileHeight,
+                               SCCOL nTiledRenderingAreaEndCol, SCROW 
nTiledRenderingAreaEndRow );
 
     /// @see Window::LogicInvalidate().
     void LogicInvalidate(const tools::Rectangle* pRectangle) override;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 1358fb8ec56d..cf744dd97bec 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -550,11 +550,19 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
     //if (pGridWindow->GetOutputSizePixel() != aTileSize)
     //    pGridWindow->SetOutputSizePixel(Size(nOutputWidth, nOutputHeight));
     // so instead for now, set the viewport size to document size
-    Size aDocSize = getDocumentSize();
+
+    // Fetch the document size and the tiled rendering area together,
+    // because the tiled rendering area is not cheap to compute, and we want
+    // to pass it down to ScGridWindow::PaintFile to avoid computing twice.
+    SCCOL nTiledRenderingAreaEndCol = 0;
+    SCROW nTiledRenderingAreaEndRow = 0;
+    Size aDocSize = getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
+
     pGridWindow->SetOutputSizePixel(Size(aDocSize.Width() * 
pViewData->GetPPTX(), aDocSize.Height() * pViewData->GetPPTY()));
 
     pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
-                            nTilePosX, nTilePosY, nTileWidth, nTileHeight );
+                            nTilePosX, nTilePosY, nTileWidth, nTileHeight,
+                            nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow );
 
     // Draw Form controls
     ScDrawLayer* pDrawLayer = pDocShell->GetDocument().GetDrawLayer();
@@ -653,6 +661,13 @@ VclPtr<vcl::Window> ScModelObj::getDocWindow()
 }
 
 Size ScModelObj::getDocumentSize()
+{
+    SCCOL nTiledRenderingAreaEndCol = 0;
+    SCROW nTiledRenderingAreaEndRow = 0;
+    return getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
+}
+
+Size ScModelObj::getDocumentSize(SCCOL& rnTiledRenderingAreaEndCol, SCROW& 
rnTiledRenderingAreaEndRow)
 {
     Size aSize(10, 10); // minimum size
 
@@ -661,11 +676,11 @@ Size ScModelObj::getDocumentSize()
         return aSize;
 
     SCTAB nTab = pViewData->GetTabNo();
-    SCCOL nEndCol = 0;
-    SCROW nEndRow = 0;
+    rnTiledRenderingAreaEndCol = 0;
+    rnTiledRenderingAreaEndRow = 0;
     const ScDocument& rDoc = pDocShell->GetDocument();
 
-    rDoc.GetTiledRenderingArea(nTab, nEndCol, nEndRow);
+    rDoc.GetTiledRenderingArea(nTab, rnTiledRenderingAreaEndCol, 
rnTiledRenderingAreaEndRow);
 
     const ScDocument* pThisDoc = &rDoc;
     const double fPPTX = pViewData->GetPPTX();
@@ -676,8 +691,8 @@ Size ScModelObj::getDocumentSize()
         return ScViewData::ToPixel(nSize, fPPTX);
     };
 
-    tools::Long nDocWidthPixel = 
pViewData->GetLOKWidthHelper().computePosition(nEndCol, GetColWidthPx);
-    tools::Long nDocHeightPixel = pThisDoc->GetScaledRowHeight(0, nEndRow, 
nTab, fPPTY);
+    tools::Long nDocWidthPixel = 
pViewData->GetLOKWidthHelper().computePosition(rnTiledRenderingAreaEndCol, 
GetColWidthPx);
+    tools::Long nDocHeightPixel = pThisDoc->GetScaledRowHeight(0, 
rnTiledRenderingAreaEndRow, nTab, fPPTY);
 
     if (nDocWidthPixel > 0 && nDocHeightPixel > 0)
     {
@@ -688,8 +703,8 @@ Size ScModelObj::getDocumentSize()
     else
     {
         // convert to twips
-        aSize.setWidth(rDoc.GetColWidth(0, nEndCol, nTab));
-        aSize.setHeight(rDoc.GetRowHeight(0, nEndRow, nTab));
+        aSize.setWidth(rDoc.GetColWidth(0, rnTiledRenderingAreaEndCol, nTab));
+        aSize.setHeight(rDoc.GetRowHeight(0, rnTiledRenderingAreaEndRow, 
nTab));
     }
 
     return aSize;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 80217c811847..787d989f3b47 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1543,7 +1543,8 @@ namespace
 void ScGridWindow::PaintTile( VirtualDevice& rDevice,
                               int nOutputWidth, int nOutputHeight,
                               int nTilePosX, int nTilePosY,
-                              tools::Long nTileWidth, tools::Long nTileHeight )
+                              tools::Long nTileWidth, tools::Long nTileHeight,
+                              SCCOL nTiledRenderingAreaEndCol, SCROW 
nTiledRenderingAreaEndRow )
 {
     Fraction origZoomX = mrViewData.GetZoomX();
     Fraction origZoomY = mrViewData.GetZoomY();
@@ -1629,9 +1630,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     }
 
     // size of the document including drawings, charts, etc.
-    SCCOL nEndCol = 0;
-    SCROW nEndRow = 0;
-    rDoc.GetTiledRenderingArea(nTab, nEndCol, nEndRow);
+    SCCOL nEndCol = nTiledRenderingAreaEndCol;
+    SCROW nEndRow = nTiledRenderingAreaEndRow;
 
     if (nEndCol < nBottomRightTileCol)
         nEndCol = nBottomRightTileCol;

Reply via email to