summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga.extern@allotropia.de>2022-10-11 09:43:20 +0200
committerEike Rathke <erack@redhat.com>2022-11-09 16:34:03 +0100
commitba59e8e3544190f4c1464d2ce18b1386c0d8a678 (patch)
tree7a44231e4934296d6fa8d37a2b210c68cff84d59 /sc
parent61fb619b43534e47c5d3fbc125257b0e48499213 (diff)
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.extern@allotropia.de> Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de> (cherry picked from commit e8fae4d0fb2994a7b4ac00e9da35e1deccb296dd) (cherry picked from commit b57307e8f3553fcb292c9c11fcf58bcef3a6cb3c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141317 Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/xmlrowi.cxx29
1 files changed, 27 insertions, 2 deletions
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index fc6a3a7c36c4..d510d5557eed 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;
+ XMLTableStyleContext* ptmpStyle = nullptr;
+
if (!sStyleName.isEmpty())
{
XMLTableStylesContext *pStyles(static_cast<XMLTableStylesContext *>(rXMLImport.GetAutoStyles()));
@@ -183,6 +187,9 @@ void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
pSheetData->AddRowStyle( sStyleName, ScAddress( 0, static_cast<SCROW>(nFirstRow), nSheet ) );
pStyle->SetLastSheet(nSheet);
}
+
+ // for later checking of optimal row height
+ ptmpStyle = pStyle;
}
}
}
@@ -209,14 +216,32 @@ 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);
+
+ // check that, we already have valid optimal row heights
+ if (nCurrentRow > 200 && ptmpStyle && !ptmpStyle->FindProperty(CTF_SC_ROWHEIGHT))
+ {
+ XMLPropertyState* pOptimalHeight = ptmpStyle->FindProperty(CTF_SC_ROWOPTIMALHEIGHT);
+ if (pOptimalHeight && ::cppu::any2bool(pOptimalHeight->maValue))
+ {
+ rRecalcRanges.at(nSheet).maRanges.setFalse(nFirstRow, nCurrentRow);
+ }
+ else
+ {
+ rRecalcRanges.at(nSheet).maRanges.setTrue(nFirstRow, nCurrentRow);
+ }
+ }
+ else
+ {
+ rRecalcRanges.at(nSheet).maRanges.setTrue(nFirstRow, nCurrentRow);
+ }
}
}