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

Tamas Bunth tamas.bunth at collabora.co.uk
Thu Jul 20 07:13:07 UTC 2017


 sc/inc/attarray.hxx               |    2 +-
 sc/inc/column.hxx                 |    2 +-
 sc/inc/document.hxx               |    2 +-
 sc/inc/table.hxx                  |    2 +-
 sc/source/core/data/attarray.cxx  |    8 +++++++-
 sc/source/core/data/column.cxx    |    4 ++--
 sc/source/core/data/document.cxx  |    4 ++--
 sc/source/core/data/table2.cxx    |    4 ++--
 sc/source/ui/docshell/docfunc.cxx |   22 ++++++++++++++--------
 9 files changed, 31 insertions(+), 19 deletions(-)

New commits:
commit b8e26ebe2c37640212ef663a483cddf1639af742
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Wed Jul 19 19:38:52 2017 +0000

    Avoid unnecessary calls of AdjustRowHeight
    
    Check if attribute changed during ApplyAttributes. If it did not change,
    it is unnecessary to recalculate cell size, repaint etc.
    
    Change-Id: Ic3a3fa24efa9ad3619b8979a67e972a7635311cc
    Reviewed-on: https://gerrit.libreoffice.org/40198
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index d410e9140a9c..e6767a32a8dd 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -143,7 +143,7 @@ public:
                             bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr );
     void    ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
     void    ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
-                            ScEditDataArray* pDataArray = nullptr );
+                            ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
     void    SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize);
     void    ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
                                 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 68784b9bd932..e280e3c7f692 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -497,7 +497,7 @@ public:
 
     void        RemoveProtected( SCROW nStartRow, SCROW nEndRow );
 
-    SCROW       ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray );
+    SCROW       ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged = nullptr );
     void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
 
     void        ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a2d496538124..76a4251e887d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1685,7 +1685,7 @@ public:
                             const OUString& sValStr, double& nX);
 
     SC_DLLPUBLIC void           ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
-                                                       ScEditDataArray* pDataArray = nullptr );
+                                                       ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr );
     void                        DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
     void                        DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark );
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e34ed5fd2d77..440e0cc414a3 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -696,7 +696,7 @@ public:
     bool        ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
     bool        RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
 
-    void        ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr );
+    void        ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
     void        DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
 
     void        ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 287ece9fcdba..2ecead9c24d2 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -850,12 +850,13 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
 #undef SET_LINECOLOR
 #undef SET_LINE
 
-void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray )
+void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray, bool* const pIsChanged )
 {
 #if DEBUG_SC_TESTATTRARRAY
     TestData();
 #endif
 
+    bool bChanged = false;
     if (ValidRow(nStartRow) && ValidRow(nEndRow))
     {
         SCSIZE nPos;
@@ -880,6 +881,8 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
                 SCROW nY2 = pData[nPos].nRow;
                 nStart = pData[nPos].nRow + 1;
 
+                bChanged = true;
+
                 if ( nY1 < nStartRow || nY2 > nEndRow )
                 {
                     if (nY1 < nStartRow) nY1=nStartRow;
@@ -926,6 +929,9 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
             pDocument->SetStreamValid(nTab, false);
     }
 
+    if( pIsChanged)
+        *pIsChanged = bChanged;
+
 #if DEBUG_SC_TESTATTRARRAY
     TestData();
 #endif
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index ecb0d5e8ab03..716007e9a21e 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -423,7 +423,7 @@ sal_uInt32 ScColumn::GetNumberFormat( SCROW nRow ) const
     return pAttrArray->GetPattern( nRow )->GetNumberFormat( pDocument->GetFormatTable() );
 }
 
-SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray )
+SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged )
 {
     SCROW nTop = 0;
     SCROW nBottom = 0;
@@ -434,7 +434,7 @@ SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData&
         ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol );
         while (aMultiIter.Next( nTop, nBottom ))
         {
-            pAttrArray->ApplyCacheArea( nTop, nBottom, pCache, pDataArray );
+            pAttrArray->ApplyCacheArea( nTop, nBottom, pCache, pDataArray, pIsChanged );
             bFound = true;
         }
     }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 48dab01c45dd..5aa7298a2f75 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5775,7 +5775,7 @@ void ScDocument::ApplyFrameAreaTab(const ScRange& rRange,
                                           rRange.aEnd.Col(),   rRange.aEnd.Row());
 }
 
-void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark, ScEditDataArray* pDataArray )
+void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged )
 {
     const SfxItemSet* pSet = &rAttr.GetItemSet();
     bool bSet = false;
@@ -5801,7 +5801,7 @@ void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMark
             ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
             for (; itr != itrEnd && *itr < nMax; ++itr)
                 if (maTabs[*itr])
-                    maTabs[*itr]->ApplySelectionCache( &aCache, rMark, pDataArray );
+                    maTabs[*itr]->ApplySelectionCache( &aCache, rMark, pDataArray, pIsChanged );
         }
     }
 }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 8677c3f78101..ba78a9e73422 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2746,10 +2746,10 @@ void ScTable::ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr )
 }
 
 void ScTable::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark,
-                                   ScEditDataArray* pDataArray )
+                                   ScEditDataArray* pDataArray, bool* const pIsChanged )
 {
     for (SCCOL i=0; i < aCol.size(); i++)
-        aCol[i].ApplySelectionCache( pCache, rMark, pDataArray );
+        aCol[i].ApplySelectionCache( pCache, rMark, pDataArray, pIsChanged );
 }
 
 void ScTable::ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark )
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 40a578e15a0f..e7f6af5cee32 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1367,16 +1367,22 @@ bool ScDocFunc::ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& r
     sal_uInt16 nExtFlags = 0;
     if ( !bImportingXML )
         rDocShell.UpdatePaintExt( nExtFlags, aMultiRange );     // content before the change
-    rDoc.ApplySelectionPattern( rPattern, rMark );
-    if ( !bImportingXML )
-        rDocShell.UpdatePaintExt( nExtFlags, aMultiRange );     // content after the change
 
-    if (!AdjustRowHeight( aMultiRange ))
-        rDocShell.PostPaint( aMultiRange, PaintPartFlags::Grid, nExtFlags );
-    else if (nExtFlags & SC_PF_LINES)
-        lcl_PaintAbove( rDocShell, aMultiRange );   // because of lines above the range
+    bool bChanged = true;
+    rDoc.ApplySelectionPattern( rPattern, rMark, nullptr, &bChanged );
 
-    aModificator.SetDocumentModified();
+    if(bChanged)
+    {
+        if ( !bImportingXML )
+            rDocShell.UpdatePaintExt( nExtFlags, aMultiRange );     // content after the change
+
+        if (!AdjustRowHeight( aMultiRange ))
+            rDocShell.PostPaint( aMultiRange, PaintPartFlags::Grid, nExtFlags );
+        else if (nExtFlags & SC_PF_LINES)
+            lcl_PaintAbove( rDocShell, aMultiRange );   // because of lines above the range
+
+        aModificator.SetDocumentModified();
+    }
 
     return true;
 }


More information about the Libreoffice-commits mailing list