diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-03-05 17:12:39 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-03-23 09:09:08 +0100 |
commit | 8a5ad9e9c16088a94ba0dd7ed6ac9845f92ec650 (patch) | |
tree | dee6aa81f197e35bc276bf5e0195306e799542d8 | |
parent | 62a25aad6d73d214d4ea6d7a50b3eee2c281cae0 (diff) |
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.lunak@collabora.com>
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 11 |
3 files changed, 12 insertions, 5 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 764b69794418..44cedc482e01 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1908,7 +1908,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 d6bb06b85ee9..d790ff74e7eb 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 ) || |