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

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Apr 14 05:33:22 UTC 2016


 sc/source/filter/xml/cachedattraccess.cxx |    7 +++++--
 sc/source/filter/xml/cachedattraccess.hxx |    4 ++--
 sc/source/filter/xml/xmlexprt.cxx         |   21 +++++++++++++++------
 3 files changed, 22 insertions(+), 10 deletions(-)

New commits:
commit 44c1cfc7d8ab7afb1e01ac57d3feeb410ba43748
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 13 12:37:10 2016 +0200

    no need to call rowHidden and rowFiltered repeatedly, tdf#90659
    
    Change-Id: Ie104a0d6c2ee0a88363fb461762e2bcca00976dd
    Reviewed-on: https://gerrit.libreoffice.org/24052
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/filter/xml/cachedattraccess.cxx b/sc/source/filter/xml/cachedattraccess.cxx
index 334e154..288c996 100644
--- a/sc/source/filter/xml/cachedattraccess.cxx
+++ b/sc/source/filter/xml/cachedattraccess.cxx
@@ -21,7 +21,7 @@ bool ScXMLCachedRowAttrAccess::Cache::hasCache(sal_Int32 nTab, sal_Int32 nRow) c
 ScXMLCachedRowAttrAccess::ScXMLCachedRowAttrAccess(ScDocument* pDoc) :
     mpDoc(pDoc) {}
 
-bool ScXMLCachedRowAttrAccess::rowHidden(sal_Int32 nTab, sal_Int32 nRow)
+bool ScXMLCachedRowAttrAccess::rowHidden(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow)
 {
     if (!maHidden.hasCache(nTab, nRow))
     {
@@ -31,10 +31,12 @@ bool ScXMLCachedRowAttrAccess::rowHidden(sal_Int32 nTab, sal_Int32 nRow)
         maHidden.mnRow1 = static_cast<sal_Int32>(nRow1);
         maHidden.mnRow2 = static_cast<sal_Int32>(nRow2);
     }
+
+    nEndRow = maHidden.mnRow2;
     return maHidden.mbValue;
 }
 
-bool ScXMLCachedRowAttrAccess::rowFiltered(sal_Int32 nTab, sal_Int32 nRow)
+bool ScXMLCachedRowAttrAccess::rowFiltered(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow)
 {
     if (!maFiltered.hasCache(nTab, nRow))
     {
@@ -44,6 +46,7 @@ bool ScXMLCachedRowAttrAccess::rowFiltered(sal_Int32 nTab, sal_Int32 nRow)
         maFiltered.mnRow1 = static_cast<sal_Int32>(nRow1);
         maFiltered.mnRow2 = static_cast<sal_Int32>(nRow2);
     }
+    nEndRow = maFiltered.mnRow2;
     return maFiltered.mbValue;
 }
 
diff --git a/sc/source/filter/xml/cachedattraccess.hxx b/sc/source/filter/xml/cachedattraccess.hxx
index 6556617..ce07299 100644
--- a/sc/source/filter/xml/cachedattraccess.hxx
+++ b/sc/source/filter/xml/cachedattraccess.hxx
@@ -34,8 +34,8 @@ class ScXMLCachedRowAttrAccess
 public:
     explicit ScXMLCachedRowAttrAccess(ScDocument* pDoc);
 
-    bool rowHidden(sal_Int32 nTab, sal_Int32 nRow);
-    bool rowFiltered(sal_Int32 nTab, sal_Int32 nRow);
+    bool rowHidden(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow);
+    bool rowFiltered(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow);
 private:
     Cache maHidden;
     Cache maFiltered;
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index d8b855f..58464e0 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1429,6 +1429,8 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con
         bool bFiltered = false;
         sal_Int32 nEqualRows(1);
         sal_Int32 nEndRow(nStartRow + nRepeatRow);
+        sal_Int32 nEndRowHidden = nStartRow - 1;
+        sal_Int32 nEndRowFiltered = nStartRow - 1;
         sal_Int32 nRow;
         for (nRow = nStartRow; nRow < nEndRow; ++nRow)
         {
@@ -1437,17 +1439,22 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con
                 nPrevIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
                 if (pDoc)
                 {
-                    bPrevHidden = rRowAttr.rowHidden(nTable, nRow);
-                    bPrevFiltered = rRowAttr.rowFiltered(nTable, nRow);
+                    if (nRow > nEndRowHidden)
+                        bPrevHidden = rRowAttr.rowHidden(nTable, nRow, nEndRowHidden);
+                    if (nRow > nEndRowFiltered)
+                        bPrevFiltered = rRowAttr.rowFiltered(nTable, nRow, nEndRowFiltered);
                 }
+
             }
             else
             {
                 nIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
                 if (pDoc)
                 {
-                    bHidden = rRowAttr.rowHidden(nTable, nRow);
-                    bFiltered = rRowAttr.rowFiltered(nTable, nRow);
+                    if (nRow > nEndRowHidden)
+                        bHidden = rRowAttr.rowHidden(nTable, nRow, nEndRowHidden);
+                    if (nRow > nEndRowFiltered)
+                        bFiltered = rRowAttr.rowFiltered(nTable, nRow, nEndRowFiltered);
                 }
                 if (nIndex == nPrevIndex && bHidden == bPrevHidden && bFiltered == bPrevFiltered &&
                     !(bHasRowHeader && ((nRow == aRowHeaderRange.StartRow) || (nRow - 1 == aRowHeaderRange.EndRow))) &&
@@ -1481,8 +1488,10 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con
         bool bFiltered = false;
         if (pDoc)
         {
-            bHidden = rRowAttr.rowHidden(nTable, nStartRow);
-            bFiltered = rRowAttr.rowFiltered(nTable, nStartRow);
+            sal_Int32 nEndRowHidden;
+            sal_Int32 nEndRowFiltered;
+            bHidden = rRowAttr.rowHidden(nTable, nStartRow, nEndRowHidden);
+            bFiltered = rRowAttr.rowFiltered(nTable, nStartRow, nEndRowFiltered);
         }
         OpenNewRow(nIndex, nStartRow, 1, bHidden, bFiltered);
     }


More information about the Libreoffice-commits mailing list