sc/source/filter/xml/xmlrowi.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
New commits: commit e8fae4d0fb2994a7b4ac00e9da35e1deccb296dd Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Tue Oct 11 09:43:20 2022 +0200 Commit: Balazs Varga <balazs.varga.ext...@allotropia.de> CommitDate: Thu Oct 13 18:05:38 2022 +0200 tdf#124098: sc, ods import: do not recalculate row heights if we have already optimal heights in the xml, because it is not necessary and it takes a lot of time loading a file. Citing here for completeness: a) if there is no height attribute and the "use_optimal-row-height" attribute is set then calculate the row height b) if there is a height attribute just use it and do not recalculate. Maybe TODO for later: optimize row height calculation more in sc Change-Id: I9d964aad744970e5d36f239c0ce39ce98c00f273 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141204 Tested-by: Jenkins Tested-by: Balazs Varga <balazs.varga.ext...@allotropia.de> Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx index fc6a3a7c36c4..cf4f41d682d9 100644 --- a/sc/source/filter/xml/xmlrowi.cxx +++ b/sc/source/filter/xml/xmlrowi.cxx @@ -21,6 +21,7 @@ #include "xmlimprt.hxx" #include "xmlcelli.hxx" #include "xmlstyli.hxx" +#include "xmlstyle.hxx" #include <document.hxx> #include <docuno.hxx> #include <olinetab.hxx> @@ -28,6 +29,7 @@ #include <documentimport.hxx> #include <unonames.hxx> +#include <comphelper/extract.hxx> #include <unotools/configmgr.hxx> #include <xmloff/xmlnamespace.hxx> #include <xmloff/families.hxx> @@ -166,6 +168,8 @@ void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/) if (!xRowProperties.is()) return; + bool bHasRowOptimalHeight = false; + if (!sStyleName.isEmpty()) { XMLTableStylesContext *pStyles(static_cast<XMLTableStylesContext *>(rXMLImport.GetAutoStyles())); @@ -183,6 +187,14 @@ void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/) pSheetData->AddRowStyle( sStyleName, ScAddress( 0, static_cast<SCROW>(nFirstRow), nSheet ) ); pStyle->SetLastSheet(nSheet); } + + // check that, we already have valid optimal row heights + XMLPropertyState* pHeight = pStyle->FindProperty(CTF_SC_ROWHEIGHT); + XMLPropertyState* pOptimalHeight = pStyle->FindProperty(CTF_SC_ROWOPTIMALHEIGHT); + if (!pHeight && pOptimalHeight && ::cppu::any2bool(pOptimalHeight->maValue)) + { + bHasRowOptimalHeight = true; + } } } } @@ -209,14 +221,19 @@ void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/) any >>= bOptionalHeight; if (bOptionalHeight) { - // Save this row for later height update + // Save this row for later height update, only if we have no already optimal row heights + // If we have already optimal row heights, recalc only the first 200 row in case of optimal document loading std::vector<ScDocRowHeightUpdater::TabRanges>& rRecalcRanges = rXMLImport.GetRecalcRowRanges(); while (static_cast<SCTAB>(rRecalcRanges.size()) <= nSheet) { rRecalcRanges.emplace_back(0, pDoc->MaxRow()); } rRecalcRanges.at(nSheet).mnTab = nSheet; - rRecalcRanges.at(nSheet).maRanges.setTrue(nFirstRow, nCurrentRow); + if (bHasRowOptimalHeight && nCurrentRow > 200) { + rRecalcRanges.at(nSheet).maRanges.setFalse(nFirstRow, nCurrentRow); + } else { + rRecalcRanges.at(nSheet).maRanges.setTrue(nFirstRow, nCurrentRow); + } } }