[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/qa sc/source

Jan Holesovsky kendy at collabora.com
Wed May 3 14:18:35 UTC 2017


 sc/qa/unit/tiledrendering/tiledrendering.cxx |    8 ------
 sc/source/ui/view/gridwin4.cxx               |   33 ++++++++++++++++-----------
 2 files changed, 21 insertions(+), 20 deletions(-)

New commits:
commit 23d0b17f259a7bf8bac3cab8fdb97c227c134108
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed May 3 15:51:34 2017 +0200

    sc lok: Extend MaxTiledCol/Row when painting beoyond the current doc area.
    
    We were stripping the painted area only to what was the current document size.
    But the document size has to grow when the user moves outside of the view, and
    we have to be able to draw even tiles that are outside of the area.
    
    Let's play it safe, and actually extend the MaxTiledCol/Row when we paint
    beyond the document size.
    
    The unit test has to be adapted to assert only the tile content - which is
    what actually mattered for the original problem.
    
    Change-Id: I447c006cc184a27e55a345e51b4fe28e77cfc8ae
    Reviewed-on: https://gerrit.libreoffice.org/37205
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 577e79aeb41c..b48d65408470 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1322,8 +1322,6 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN);
     Scheduler::ProcessEventsToIdle();
 
-    Size aDocSize = pModelObj->getDocumentSize();
-
     int nCanvasWidth = 256;
     int nCanvasHeight = 256;
     std::vector<unsigned char> aBuffer1(nCanvasWidth * nCanvasHeight * 4);
@@ -1334,7 +1332,6 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
 
     // Create a new view
     SfxLokHelper::createView();
-    Size aViewSize = pModelObj->getDocumentSize();
 
     std::vector<unsigned char> aBuffer2(nCanvasWidth * nCanvasHeight * 4);
     ScopedVclPtrInstance<VirtualDevice> pDevice2(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
@@ -1342,10 +1339,7 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
     pModelObj->paintTile(*pDevice2.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/291840, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
     Scheduler::ProcessEventsToIdle();
 
-    // Make sure the newly created view has the same size as the original one
-    CPPUNIT_ASSERT_EQUAL(aDocSize, aViewSize);
-
-    // and that the tiles actually have the same content
+    // Check that the tiles actually have the same content
     for (size_t i = 0; i < aBuffer1.size(); ++i)
         CPPUNIT_ASSERT_EQUAL(aBuffer1[i], aBuffer2[i]);
 
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 6454eadcfd9e..5e9b2c07570a 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1140,24 +1140,17 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     SCTAB nTab = pViewData->GetTabNo();
     ScDocument* pDoc = pViewData->GetDocument();
 
-    SCCOL nEndCol = 0;
-    SCROW nEndRow = 0;
-
-    // size of the document including drawings, charts, etc.
-    pDoc->GetTiledRenderingArea(nTab, nEndCol, nEndRow);
-
     const double fPPTX = pViewData->GetPPTX();
     const double fPPTY = pViewData->GetPPTY();
 
-    ScTableInfo aTabInfo(nEndRow + 3);
     sal_Int32 nTopLeftTileRowOffset = 0;
     sal_Int32 nTopLeftTileColOffset = 0;
     sal_Int32 nTopLeftTileRowOrigin = 0;
     sal_Int32 nTopLeftTileColOrigin = 0;
 
     // find approximate col/row offsets of nearby.
-    sal_Int32 nTopLeftTileRow =0;
-    sal_Int32 nTopLeftTileCol =0;
+    sal_Int32 nTopLeftTileRow = 0;
+    sal_Int32 nTopLeftTileCol = 0;
     sal_Int32 nBottomRightTileRow = 0;
     sal_Int32 nBottomRightTileCol = 0;
     sal_Int32 nDummy;
@@ -1175,12 +1168,25 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     nBottomRightTileCol++;
     nBottomRightTileRow++;
 
-    nTopLeftTileCol = std::min(nTopLeftTileCol, (sal_Int32)nEndCol);
-    nTopLeftTileRow = std::min(nTopLeftTileRow, (sal_Int32)nEndRow);
+    // size of the document including drawings, charts, etc.
+    SCCOL nEndCol = 0;
+    SCROW nEndRow = 0;
+    pDoc->GetTiledRenderingArea(nTab, nEndCol, nEndRow);
+
+    if (nEndCol < nBottomRightTileCol)
+    {
+        nEndCol = nBottomRightTileCol;
+        pViewData->SetMaxTiledCol(nEndCol);
+    }
+
+    if (nEndRow < nBottomRightTileRow)
+    {
+        nEndRow = nBottomRightTileRow;
+        pViewData->SetMaxTiledRow(nEndRow);
+    }
+
     nTopLeftTileCol = std::max<sal_Int32>(nTopLeftTileCol, 0);
     nTopLeftTileRow = std::max<sal_Int32>(nTopLeftTileRow, 0);
-    nBottomRightTileCol = std::min(nBottomRightTileCol, (sal_Int32)nEndCol);
-    nBottomRightTileRow = std::min(nBottomRightTileRow, (sal_Int32)nEndRow);
     nTopLeftTileColOrigin = nTopLeftTileColOrigin * TWIPS_PER_PIXEL;
     nTopLeftTileRowOrigin = nTopLeftTileRowOrigin * TWIPS_PER_PIXEL;
 
@@ -1194,6 +1200,7 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     aAbsMode.SetOrigin(aOrigin);
     rDevice.SetMapMode(aAbsMode);
 
+    ScTableInfo aTabInfo(nEndRow + 3);
     pDoc->FillInfo(aTabInfo, nTopLeftTileCol, nTopLeftTileRow,
                    nBottomRightTileCol, nBottomRightTileRow,
                    nTab, fPPTX, fPPTY, false, false);


More information about the Libreoffice-commits mailing list