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

Marco Cecchetti marco.cecchetti at collabora.com
Mon Jul 9 15:50:42 UTC 2018


 sc/source/ui/inc/gridwin.hxx   |    2 +-
 sc/source/ui/inc/tabview.hxx   |    7 ++++++-
 sc/source/ui/view/gridwin.cxx  |   35 +++++++++++++++++++++++++++++------
 sc/source/ui/view/gridwin4.cxx |    4 ++++
 sc/source/ui/view/tabview.cxx  |   13 +++++++++++++
 sc/source/ui/view/tabview3.cxx |    4 ++--
 6 files changed, 55 insertions(+), 10 deletions(-)

New commits:
commit daaf101ffe683eb691418ec2df4adc260d7e6a15
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon May 7 12:49:22 2018 +0200

    lok: sc: formulas were not updated correctly
    
    this patch fixes several issues:
    
    - any cell containing a formula above row 1024 causing a tile
    invalidation whenever any cell content was changed, even if unrelated
    to the formula;
    
    - any formula below row 1024 wasn't updated even if it was inside the
    visible area.
    
    Change-Id: Ib92153d5755c4e231aa68dee807fe997f9e80a46
    Reviewed-on: https://gerrit.libreoffice.org/53935
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 1775114c27c8..ff0bd43ea955 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -351,7 +351,7 @@ public:
     void            ScrollPixel( long nDifX, long nDifY );
     void            UpdateEditViewPos();
 
-    void            UpdateFormulas();
+    void            UpdateFormulas(SCCOL nX1 = -1, SCROW nY1 = -1, SCCOL nX2 = -1, SCROW nY2 = -1);
 
     void            LaunchDataSelectMenu( SCCOL nCol, SCROW nRow );
     void            DoScenarioMenu( const ScRange& rScenRange );
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index cc8dd64568c9..4c321ec1653f 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -496,7 +496,7 @@ public:
     void            UpdateShrinkOverlay();
     void            UpdateAllOverlays();
 
-    void            UpdateFormulas();
+    void            UpdateFormulas( SCCOL nStartCol = -1, SCROW nStartRow = -1, SCCOL nEndCol = -1, SCROW nEndRow = -1 );
     void            InterpretVisible();
     void            CheckNeedsRepaint();
     bool            NeedsRepaint();
@@ -611,6 +611,11 @@ public:
     /// @see ScModelObj::getRowColumnHeaders().
     OUString getRowColumnHeaders(const tools::Rectangle& rRectangle);
     static void OnLOKNoteStateChanged(const ScPostIt* pNote);
+
+    SCROW GetLOKStartHeaderRow() { return mnLOKStartHeaderRow; }
+    SCROW GetLOKEndHeaderRow() { return mnLOKEndHeaderRow; }
+    SCCOL GetLOKStartHeaderCol() { return mnLOKStartHeaderCol; }
+    SCCOL GetLOKEndHeaderCol() { return mnLOKEndHeaderCol; }
 };
 
 #endif
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index f3dacb97f4f7..e94a46c3c46b 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -4505,7 +4505,7 @@ void ScGridWindow::ScrollPixel( long nDifX, long nDifY )
 
 // Update Formulas ------------------------------------------------------
 
-void ScGridWindow::UpdateFormulas()
+void ScGridWindow::UpdateFormulas(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2)
 {
     if (pViewData->GetView()->IsMinimized())
         return;
@@ -4520,10 +4520,30 @@ void ScGridWindow::UpdateFormulas()
         return;
     }
 
-    SCCOL   nX1 = pViewData->GetPosX( eHWhich );
-    SCROW   nY1 = pViewData->GetPosY( eVWhich );
-    SCCOL   nX2 = nX1 + pViewData->VisibleCellsX( eHWhich );
-    SCROW   nY2 = nY1 + pViewData->VisibleCellsY( eVWhich );
+    if ( comphelper::LibreOfficeKit::isActive() )
+    {
+        ScTabViewShell* pViewShell = pViewData->GetViewShell();
+        if (nX1 < 0)
+            nX1 = pViewShell->GetLOKStartHeaderCol() + 1;
+        if (nY1 < 0)
+            nY1 = pViewShell->GetLOKStartHeaderRow() + 1;
+        if (nX2 < 0)
+            nX2 = pViewShell->GetLOKEndHeaderCol();
+        if (nY2 < 0)
+            nY2 = pViewShell->GetLOKEndHeaderRow();
+
+        if (nX1 < 0 || nY1 < 0) return;
+    }
+    else
+    {
+        nX1 = pViewData->GetPosX( eHWhich );
+        nY1 = pViewData->GetPosY( eVWhich );
+        nX2 = nX1 + pViewData->VisibleCellsX( eHWhich );
+        nY2 = nY1 + pViewData->VisibleCellsY( eVWhich );
+    }
+
+    if (nX2 < nX1) nX2 = nX1;
+    if (nY2 < nY1) nY2 = nY1;
 
     if (nX2 > MAXCOL) nX2 = MAXCOL;
     if (nY2 > MAXROW) nY2 = MAXROW;
@@ -4537,7 +4557,10 @@ void ScGridWindow::UpdateFormulas()
     ScDocument& rDoc = *pViewData->GetDocument();
     SCTAB nTab = pViewData->GetTabNo();
 
-    rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
+    if ( !comphelper::LibreOfficeKit::isActive() )
+    {
+        rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
+    }
 
     Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
     long nMirrorWidth = GetSizePixel().Width();
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 32fe801027c5..595b7a325d28 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1217,6 +1217,10 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     DrawContent(rDevice, aTabInfo, aOutputData, true);
 
     rDevice.SetMapMode(aOriginalMode);
+
+    // Flag drawn formula cells "unchanged".
+    pDoc->ResetChanged(ScRange(nTopLeftTileCol, nTopLeftTileRow, nTab, nBottomRightTileCol, nBottomRightTileRow, nTab));
+    pDoc->PrepareFormulaCalc();
 }
 
 void ScGridWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index ce567a793310..5e53f937e102 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2493,6 +2493,9 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
     long nStartWidthPx = 0;
     long nEndWidthPx = 0;
 
+    tools::Rectangle aOldVisArea(
+            mnLOKStartHeaderCol + 1, mnLOKStartHeaderRow + 1,
+            mnLOKEndHeaderCol, mnLOKEndHeaderRow);
 
     /// *** start collecting ROWS ***
 
@@ -2777,6 +2780,16 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
     aBuffer.append("\n}");
     OUString sRet = aBuffer.makeStringAndClear();
 
+    vcl::Region aNewVisArea(
+            tools::Rectangle(mnLOKStartHeaderCol + 1, mnLOKStartHeaderRow + 1,
+                    mnLOKEndHeaderCol, mnLOKEndHeaderRow));
+    aNewVisArea.Exclude(aOldVisArea);
+    tools::Rectangle aChangedArea = aNewVisArea.GetBoundRect();
+    if (!aChangedArea.IsEmpty())
+    {
+        UpdateFormulas(aChangedArea.Left(), aChangedArea.Top(), aChangedArea.Right(), aChangedArea.Bottom());
+    }
+
     return sRet;
 }
 
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 393735d3df6b..7030f1b31cdd 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2206,7 +2206,7 @@ void ScTabView::KillEditView( bool bNoPaint )
     }
 }
 
-void ScTabView::UpdateFormulas()
+void ScTabView::UpdateFormulas(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow)
 {
     if ( aViewData.GetDocument()->IsAutoCalcShellDisabled() )
         return;
@@ -2214,7 +2214,7 @@ void ScTabView::UpdateFormulas()
     for (sal_uInt16 i = 0; i < 4; i++)
     {
         if (pGridWin[i] && pGridWin[i]->IsVisible())
-            pGridWin[i]->UpdateFormulas();
+            pGridWin[i]->UpdateFormulas(nStartCol, nStartRow, nEndCol, nEndRow);
     }
 
     if ( aViewData.IsPagebreakMode() )


More information about the Libreoffice-commits mailing list