sc/source/filter/excel/xistyle.cxx |   18 ++++++++++++++++--
 sc/source/filter/inc/xistyle.hxx   |    2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 2d208c4e42595bb85fd0ef726a89e10dd32b48b1
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jun 25 09:03:49 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jun 25 11:53:31 2024 +0200

    tdf#161210 speed xls load
    
    instead of applying row styles to all 16384 columns, only apply them to
    columns that have data.
    
    That takes the load time for this file from 19s to 1s for me.
    
    Change-Id: Ifec56995e0053938dc5a7ed0d15ae3a173614dd4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169506
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/filter/excel/xistyle.cxx 
b/sc/source/filter/excel/xistyle.cxx
index 5eeff7e19a91..dddf509b0944 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -1890,6 +1890,7 @@ XclImpXFRangeBuffer::~XclImpXFRangeBuffer()
 void XclImpXFRangeBuffer::Initialize()
 {
     maColumns.clear();
+    maRows.clear();
     maHyperlinks.clear();
     maMergeList.RemoveAll();
 }
@@ -1942,8 +1943,10 @@ void XclImpXFRangeBuffer::SetBoolXF( const ScAddress& 
rScPos, sal_uInt16 nXFInde
 
 void XclImpXFRangeBuffer::SetRowDefXF( SCROW nScRow, sal_uInt16 nXFIndex )
 {
-    for( SCCOL nScCol = 0; nScCol <= GetDoc().MaxCol(); ++nScCol )
-        SetXF( ScAddress( nScCol, nScRow, 0 ), nXFIndex, xlXFModeRow );
+    size_t nIndex = static_cast< size_t >( nScRow );
+    if( maRows.size() <= nIndex )
+        maRows.resize( nIndex + 1 );
+    maRows[ nIndex ].emplace(nXFIndex);
 }
 
 void XclImpXFRangeBuffer::SetColumnDefXF( SCCOL nScCol, sal_uInt16 nXFIndex )
@@ -1990,6 +1993,17 @@ void XclImpXFRangeBuffer::Finalize()
     ScDocument& rDoc = rDocImport.getDoc();
     SCTAB nScTab = GetCurrScTab();
 
+    // apply row styles
+    for( SCROW nScRow = 0; nScRow < static_cast<SCROW>(maRows.size()); 
++nScRow )
+    {
+        if (!maRows[nScRow])
+            continue;
+        sal_uInt16 nXFIndex = *maRows[nScRow];
+        for( SCCOL nScCol = 0; nScCol < static_cast<SCCOL>(maColumns.size()); 
++nScCol )
+            if (maColumns[nScCol])
+                SetXF( ScAddress( nScCol, nScRow, 0 ), nXFIndex, xlXFModeRow );
+    }
+
     // apply patterns
     XclImpXFBuffer& rXFBuffer = GetXFBuffer();
     ScDocumentImport::Attrs aPendingAttrParam;
diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx
index ff56c5d1d370..450719832042 100644
--- a/sc/source/filter/inc/xistyle.hxx
+++ b/sc/source/filter/inc/xistyle.hxx
@@ -659,6 +659,8 @@ private:
 
     std::vector< std::optional<XclImpXFRangeColumn> >
                         maColumns;        /// Array of column XF index buffers.
+    std::vector< std::optional<sal_uInt16> >
+                        maRows;        /// Array of row XF index.
     std::vector< std::pair< XclRange, OUString > >
                         maHyperlinks;     /// Maps URLs to hyperlink cells.
     ScRangeList         maMergeList;      /// List of merged cell ranges.

Reply via email to