sc/source/filter/xml/XMLStylesImportHelper.cxx |   68 +++++++++++--------------
 sc/source/filter/xml/xmlcelli.cxx              |    7 ++
 sc/source/filter/xml/xmlsubti.cxx              |    5 +
 sc/source/filter/xml/xmlsubti.hxx              |    1 
 4 files changed, 45 insertions(+), 36 deletions(-)

New commits:
commit 4dfffddceb12fe25ac3dd97281c3006502e04934
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Oct 2 10:15:30 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Oct 2 14:00:20 2024 +0200

    flatten ScMyStylesImportHelper::AddDefaultRange
    
    Change-Id: I7a3afbed392786eea3533318421959d8e2b0dbd6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174377
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/filter/xml/XMLStylesImportHelper.cxx 
b/sc/source/filter/xml/XMLStylesImportHelper.cxx
index ed3a210fc347..d2d71aa7994a 100644
--- a/sc/source/filter/xml/XMLStylesImportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesImportHelper.cxx
@@ -232,48 +232,44 @@ ScMyStylesMap::iterator 
ScMyStylesImportHelper::GetIterator(const OUString & rSt
 void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange)
 {
     OSL_ENSURE(aRowDefaultStyle != aCellStyles.end(), "no row default style");
-    if (aRowDefaultStyle->first.isEmpty())
+    if (!aRowDefaultStyle->first.isEmpty())
     {
-        SCCOL nStartCol(rRange.aStart.Col());
-        SCCOL nEndCol(rRange.aEnd.Col());
-        if (aColDefaultStyles.size() > 
sal::static_int_cast<sal_uInt32>(nStartCol))
-        {
-            ScMyStylesMap::iterator aPrevItr(aColDefaultStyles[nStartCol]);
-            for (SCCOL i = nStartCol + 1; (i <= nEndCol) && (i < 
sal::static_int_cast<SCCOL>(aColDefaultStyles.size())); ++i)
-            {
-                if (aPrevItr != aColDefaultStyles[i])
-                {
-                    OSL_ENSURE(aPrevItr != aCellStyles.end(), "no column 
default style");
-                    ScRange aRange(rRange);
-                    aRange.aStart.SetCol(nStartCol);
-                    aRange.aEnd.SetCol(i - 1);
-                    pPrevStyleName = aPrevItr->first;
-                    AddSingleRange(aRange);
-                    nStartCol = i;
-                    aPrevItr = aColDefaultStyles[i];
-                }
-            }
-            if (aPrevItr != aCellStyles.end())
-            {
-                ScRange aRange(rRange);
-                aRange.aStart.SetCol(nStartCol);
-                pPrevStyleName = aPrevItr->first;
-                AddSingleRange(aRange);
-            }
-            else
-            {
-                OSL_FAIL("no column default style");
-            }
-        }
-        else
+        pPrevStyleName = aRowDefaultStyle->first;
+        AddSingleRange(rRange);
+        return;
+    }
+    SCCOL nStartCol(rRange.aStart.Col());
+    SCCOL nEndCol(rRange.aEnd.Col());
+    if (aColDefaultStyles.size() <= 
sal::static_int_cast<sal_uInt32>(nStartCol))
+    {
+        OSL_FAIL("too many columns");
+        return;
+    }
+    ScMyStylesMap::iterator aPrevItr(aColDefaultStyles[nStartCol]);
+    for (SCCOL i = nStartCol + 1; (i <= nEndCol) && (i < 
sal::static_int_cast<SCCOL>(aColDefaultStyles.size())); ++i)
+    {
+        if (aPrevItr != aColDefaultStyles[i])
         {
-            OSL_FAIL("too many columns");
+            OSL_ENSURE(aPrevItr != aCellStyles.end(), "no column default 
style");
+            ScRange aRange(rRange);
+            aRange.aStart.SetCol(nStartCol);
+            aRange.aEnd.SetCol(i - 1);
+            pPrevStyleName = aPrevItr->first;
+            AddSingleRange(aRange);
+            nStartCol = i;
+            aPrevItr = aColDefaultStyles[i];
         }
     }
+    if (aPrevItr != aCellStyles.end())
+    {
+        ScRange aRange(rRange);
+        aRange.aStart.SetCol(nStartCol);
+        pPrevStyleName = aPrevItr->first;
+        AddSingleRange(aRange);
+    }
     else
     {
-        pPrevStyleName = aRowDefaultStyle->first;
-        AddSingleRange(rRange);
+        OSL_FAIL("no column default style");
     }
 }
 
commit 5f6b8b18dc16d290382187693861404e9a405b34
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Oct 2 10:02:12 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Oct 2 14:00:10 2024 +0200

    tdf#161986 speedup ODS with large merged range
    
    reduces load time from 90s to 25s
    
    Change-Id: I7523776e5f4e2c4dc8645ccdf303e51178a9848a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174376
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 0de47dcfbe5e..911586eb2683 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1269,6 +1269,13 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( 
const ScAddress& rCellPos,
                     rTables.AddColumn(false);
                 }
             }
+            // if nothing else useful can happen in the loop, just exit early
+            if (i != 0 && bIsEmpty && rCurrentPos.Row() != 0)
+            {
+                rCurrentPos.SetCol( rCellPos.Col() + nColsRepeated - 1 );
+                rTables.AddColumns(nColsRepeated - i - 1);
+                break;
+            }
         }
     }
 }
diff --git a/sc/source/filter/xml/xmlsubti.cxx 
b/sc/source/filter/xml/xmlsubti.cxx
index aa48f37833b3..0d865721b930 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -179,6 +179,11 @@ void ScMyTables::AddColumn(bool bIsCovered)
         rImport.GetStylesImportHelper()->InsertCol(maCurrentCellPos.Col(), 
maCurrentCellPos.Tab());
 }
 
+void ScMyTables::AddColumns(sal_Int32 nRepeat)
+{
+    maCurrentCellPos.SetCol( maCurrentCellPos.Col() + nRepeat );
+}
+
 void ScMyTables::DeleteTable()
 {
     ScXMLImport::MutexGuard aGuard(rImport);
diff --git a/sc/source/filter/xml/xmlsubti.hxx 
b/sc/source/filter/xml/xmlsubti.hxx
index b0c6e7457224..49e148b3db16 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -73,6 +73,7 @@ public:
     void                                AddRow();
     void                                SetRowStyle(const OUString& 
rCellStyleName);
     void                                AddColumn(bool bIsCovered);
+    void                                AddColumns(sal_Int32 nRepeat);
     void                                FixupOLEs() { aFixupOLEs.FixupOLEs(); }
     static bool                         IsOLE(const css::uno::Reference< 
css::drawing::XShape >& rShape)
                                             { return 
ScMyOLEFixer::IsOLE(rShape); }

Reply via email to