sc/inc/document.hxx                |    2 +-
 sc/source/core/data/document.cxx   |    4 ++--
 sc/source/filter/excel/xetable.cxx |   11 +++++++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

New commits:
commit 8030b9cf1c55cbbf9be8bf0cee0a408ff0a14710
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Sat Mar 5 17:12:39 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Sat Mar 5 18:34:39 2022 +0100

    compress RowHidden()/GetRowHeight() use in excel export (tdf#126326)
    
    Change-Id: Idc6a704cfc820bbbb2b51eff8db8159c251ea9ab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131062
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 4e8eab09ed5d..f78afc46a3da 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1910,7 +1910,7 @@ public:
     SC_DLLPUBLIC sal_uInt16         GetColWidth( SCCOL nCol, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
     SC_DLLPUBLIC tools::Long        GetColWidth( SCCOL nStartCol, SCCOL 
nEndCol, SCTAB nTab ) const;
     SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
-    SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, 
SCROW* pStartRow, SCROW* pEndRow ) const;
+    SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, 
SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
     SC_DLLPUBLIC tools::Long        GetRowHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
 
     /**
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index ae57d12033a9..a7fabf46d1df 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4177,10 +4177,10 @@ sal_uInt16 ScDocument::GetRowHeight( SCROW nRow, SCTAB 
nTab, bool bHiddenAsZero
     return 0;
 }
 
-sal_uInt16 ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, 
SCROW* pEndRow ) const
+sal_uInt16 ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, 
SCROW* pEndRow, bool bHiddenAsZero ) const
 {
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && 
maTabs[nTab] )
-        return maTabs[nTab]->GetRowHeight( nRow, pStartRow, pEndRow );
+        return maTabs[nTab]->GetRowHeight( nRow, pStartRow, pEndRow, 
bHiddenAsZero );
     OSL_FAIL("Wrong sheet number");
     return 0;
 }
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index cf46590cebfc..c527d525adba 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2479,16 +2479,23 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 
nXclRow, bool bRowAlwaysE
 
     const ScDocument& rDoc = GetRoot().GetDoc();
     const SCTAB nScTab = GetRoot().GetCurrScTab();
+    // Do not repeatedly call RowHidden() / GetRowHeight() for same values.
+    bool bHidden = false;
+    SCROW lastSameHiddenRow = -1;
+    sal_uInt16 nHeight = 0;
+    SCROW lastSameHeightRow = -1;
     // create the missing rows first
     while( nFrom <= nXclRow )
     {
         // only create RowMap entries if it is first row in spreadsheet,
         // if it is the desired row, or for rows that differ from previous.
-        const bool bHidden = rDoc.RowHidden(nFrom, nScTab);
+        if( static_cast<SCROW>(nFrom) > lastSameHiddenRow )
+            bHidden = rDoc.RowHidden(nFrom, nScTab, nullptr, 
&lastSameHiddenRow);
         // Always get the actual row height even if the manual size flag is
         // not set, to correctly export the heights of rows with wrapped
         // texts.
-        const sal_uInt16 nHeight = rDoc.GetRowHeight(nFrom, nScTab, false);
+        if( static_cast<SCROW>(nFrom) > lastSameHeightRow )
+            nHeight = rDoc.GetRowHeight(nFrom, nScTab, nullptr, 
&lastSameHeightRow, false);
         if ( !pPrevEntry || ( nFrom == nXclRow ) ||
              ( maOutlineBfr.IsCollapsed() ) ||
              ( maOutlineBfr.GetLevel() != 0 ) ||

Reply via email to