diff options
author | Vasily Melenchuk <Vasily.Melenchuk@cib.de> | 2018-04-06 20:19:10 +0300 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-22 23:30:23 +0200 |
commit | 693953dd4699887bd3f5bca2c3582b5fae1d6992 (patch) | |
tree | 2091b2fe8d997ef84f149ace1e6a1f00fd8e08fe /sc/source/filter/xml | |
parent | fad764c02c7a9cd210bfa44ea0ce1ac5354d6427 (diff) |
tdf#62268: allow row height recalculation on document load
During document load rows with style:use-optimal-row-height="true"
should recalculate it's height.
* includes: Row height tolerance level increase for unittest
* tdf#118086: calc: invalid row autoheight fixed
Change-Id: Ib38b5b753d9ff8352116d77851d228c5d77bd530
Reviewed-on: https://gerrit.libreoffice.org/52521
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
(cherry picked from commit 1e55a47e89a9d9d6cf9cb3993484022aaf2c097b)
Reviewed-on: https://gerrit.libreoffice.org/61898
Tested-by: Jenkins
Diffstat (limited to 'sc/source/filter/xml')
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 21 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.hxx | 5 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlrowi.cxx | 16 |
3 files changed, 42 insertions, 0 deletions
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index ca24d77523b5..3be69b5ae4f0 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -76,6 +76,7 @@ #include "pivotsource.hxx" #include <unonames.hxx> #include <numformat.hxx> +#include <sizedev.hxx> #include <comphelper/base64.hxx> #include <comphelper/extract.hxx> @@ -1809,6 +1810,26 @@ void SAL_CALL ScXMLImport::endDocument() pDoc->SetStreamValid( nTab, true ); } } + + // There are rows with optimal height which need to be updated + if (!maRecalcRowRanges.empty()) + { + bool bLockHeight = pDoc->IsAdjustHeightLocked(); + if (bLockHeight) + { + pDoc->UnlockAdjustHeight(); + } + + ScSizeDeviceProvider aProv(static_cast<ScDocShell*>(pDoc->GetDocumentShell())); + ScDocRowHeightUpdater aUpdater(*pDoc, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), &maRecalcRowRanges); + aUpdater.update(); + + if (bLockHeight) + { + pDoc->LockAdjustHeight(); + } + } + aTables.FixupOLEs(); } if (GetModel().is()) diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 59b4fb1fce18..555835033747 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -31,6 +31,7 @@ #include <global.hxx> #include <formula/grammar.hxx> #include <compiler.hxx> +#include <dociter.hxx> #include "xmlstyle.hxx" #include <com/sun/star/sheet/ValidationAlertStyle.hpp> @@ -269,6 +270,8 @@ class ScXMLImport: public SvXMLImport ScMyTables aTables; + std::vector<ScDocRowHeightUpdater::TabRanges> maRecalcRowRanges; + std::unique_ptr<ScMyNamedExpressions> m_pMyNamedExpressions; SheetNamedExpMap m_SheetNamedExpressions; @@ -341,6 +344,8 @@ public: ScMyTables& GetTables() { return aTables; } + std::vector<ScDocRowHeightUpdater::TabRanges>& GetRecalcRowRanges() { return maRecalcRowRanges; } + bool IsStylesOnlyMode() const { return !bLoadDoc; } static sal_Int16 GetCellType(const char* rStrValue, const sal_Int32 nStrLength); diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx index 7f958d459f4d..3093c33f0a8e 100644 --- a/sc/source/filter/xml/xmlrowi.cxx +++ b/sc/source/filter/xml/xmlrowi.cxx @@ -27,6 +27,7 @@ #include <olinetab.hxx> #include <sheetdata.hxx> #include <documentimport.hxx> +#include <unonames.hxx> #include <xmloff/xmltkmap.hxx> #include <xmloff/nmspmap.hxx> @@ -198,6 +199,21 @@ void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/) } if (bFiltered) xRowProperties->setPropertyValue(SC_ISFILTERED, uno::makeAny(bFiltered)); + + uno::Any any = xRowProperties->getPropertyValue(SC_UNONAME_OHEIGHT); + bool bOptionalHeight = false; + any >>= bOptionalHeight; + if (bOptionalHeight) + { + // Save this row for later height update + std::vector<ScDocRowHeightUpdater::TabRanges>& rRecalcRanges = rXMLImport.GetRecalcRowRanges(); + while (static_cast<SCTAB>(rRecalcRanges.size()) <= nSheet) + { + rRecalcRanges.emplace_back(0); + } + rRecalcRanges.at(nSheet).mnTab = nSheet; + rRecalcRanges.at(nSheet).mpRanges->setTrue(nFirstRow, nCurrentRow); + } } } } |