summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2022-09-20 08:14:41 -0400
committerJustin Luth <jluth@mail.com>2023-07-11 19:38:07 +0200
commitd15c4caabaa21e0efe3a08ffbe145390e802bab9 (patch)
tree8b077c29542b78ec4a6370e12ed41ed743fc9780
parentcf07373d84b0ad6d0110b62966705b3e101785b5 (diff)
tdf#123026 xlsx import: recalc optimal row height on import
This patch depends on the previous patch for this bug report, which allows each sheet to hold its own default row height. The given height for the row might not be enough to fit the content. If the row is set to use optimal height, that will be corrected as soon as the row is edited. Obviously, it should not require an edit to be correct on FILEOPEN, so this patch recalculates after loading the document. This might have a very negative effect on the time needed to open a file. I couldn't duplicate the XLS method because Library_scfilt.mk doesn't link to ScSizeDeviceProvider. The existing UpdateAllRowHeights wasn't designed to allow any performance improvements, so I made a new one. The new one is based on the newer ScDocRowHeightUpdater class - so perhaps the older method can be phased out. This new UpdateAllRowHeights could replace the XLS bSetRowHeights clause - with hopefully some performance benefit. I'm not sure I'm ready for the regression hate that would come from the inevitable performance implications. Testing however doesn't suggest a huge slowdown. I tested with time make sc.check before the fix I was getting 16m 4s +- 10s after the fix I was getting 16m 25s +- 10s Specific test showing the need for these patches: make CppunitTest_sc_subsequent_filters_test2 \ CPPUNIT_TEST_NAME=testTdf123026_optimalRowHeight Impacted unit tests (without the previous patch) are documented in earlier patchsets. make CppunitTest_sc_subsequent_export_test \ CPPUNIT_TEST_NAME=testMiscRowHeightExport make CppunitTest_sc_subsequent_export_test2 make CppunitTest_sc_jumbosheets_test CPPUNIT_TEST_NAME=testTdf134553 Change-Id: I6d020c1a5137dd4f05e20e82b1764a102b7f56d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140260 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/dociter.hxx4
-rw-r--r--sc/qa/unit/subsequent_filters_test2.cxx7
-rw-r--r--sc/source/core/data/dociter.cxx11
-rw-r--r--sc/source/filter/oox/workbookhelper.cxx1
-rw-r--r--sc/source/ui/docshell/docsh5.cxx10
-rw-r--r--sc/source/ui/inc/docsh.hxx1
6 files changed, 21 insertions, 13 deletions
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index b73d175a000f..6be5a77e5e5b 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -457,10 +457,10 @@ public:
ScDocument& rDoc, OutputDevice* pOutDev, double fPPTX, double fPPTY,
const ::std::vector<TabRanges>* pTabRangesArray);
- void update();
+ void update(const bool bOnlyUsedRows = false);
private:
- void updateAll();
+ void updateAll(const bool bOnlyUsedRows);
private:
ScDocument& mrDoc;
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx
index d5ce977b3a4e..790ab5c99057 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -148,13 +148,6 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testOptimalHeightReset)
CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testTdf123026_optimalRowHeight)
{
createScDoc("xlsx/tdf123026_optimalRowHeight.xlsx");
-
- dispatchCommand(mxComponent, ".uno:SelectColumn", {});
- dispatchCommand(
- mxComponent, ".uno:SetOptimalRowHeight",
- comphelper::InitPropertySequence({ { "aExtraHeight", uno::Any(sal_uInt16(0)) } }));
- Scheduler::ProcessEventsToIdle();
-
SCTAB nTab = 0;
SCROW nRow = 4;
int nHeight = convertTwipToMm100(getScDoc()->GetRowHeight(nRow, nTab, false));
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index fd4fa7afe42f..267d814daf76 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1615,12 +1615,12 @@ ScDocRowHeightUpdater::ScDocRowHeightUpdater(ScDocument& rDoc, OutputDevice* pOu
{
}
-void ScDocRowHeightUpdater::update()
+void ScDocRowHeightUpdater::update(const bool bOnlyUsedRows)
{
if (!mpTabRangesArray || mpTabRangesArray->empty())
{
// No ranges defined. Update all rows in all tables.
- updateAll();
+ updateAll(bOnlyUsedRows);
return;
}
@@ -1668,7 +1668,7 @@ void ScDocRowHeightUpdater::update()
}
}
-void ScDocRowHeightUpdater::updateAll()
+void ScDocRowHeightUpdater::updateAll(const bool bOnlyUsedRows)
{
sal_uInt64 nCellCount = 0;
for (SCTAB nTab = 0; nTab < mrDoc.GetTableCount(); ++nTab)
@@ -1689,7 +1689,10 @@ void ScDocRowHeightUpdater::updateAll()
if (!ValidTab(nTab) || !mrDoc.maTabs[nTab])
continue;
- mrDoc.maTabs[nTab]->SetOptimalHeight(aCxt, 0, mrDoc.MaxRow(), true, &aProgress, nProgressStart);
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = mrDoc.MaxRow();
+ if (!bOnlyUsedRows || mrDoc.GetPrintArea(nTab, nEndCol, nEndRow))
+ mrDoc.maTabs[nTab]->SetOptimalHeight(aCxt, 0, nEndRow, true, &aProgress, nProgressStart);
nProgressStart += mrDoc.maTabs[nTab]->GetWeightedCount();
}
}
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 3a542df0313e..817340afb341 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -628,6 +628,7 @@ void WorkbookGlobals::finalize()
mpDoc->EnableExecuteLink(true);
// #i79826# enable updating automatic row height after loading the document
mpDoc->UnlockAdjustHeight();
+ mpDocShell->UpdateAllRowHeights(/*bOnlyUsedRows=*/true);
// #i76026# enable Undo after loading the document
mpDoc->EnableUndo(true);
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index d1749fee1e1b..f7c35ba29598 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+#include <dociter.hxx>
#include <docsh.hxx>
#include <global.hxx>
#include <globstr.hrc>
@@ -429,6 +430,15 @@ void ScDocShell::UpdateAllRowHeights( const ScMarkData* pTabMark )
m_pDocument->UpdateAllRowHeights(aCxt, pTabMark);
}
+void ScDocShell::UpdateAllRowHeights(const bool bOnlyUsedRows)
+{
+ // update automatic roow heights on all sheets using the newer ScDocRowHeightUpdater
+ ScSizeDeviceProvider aProv(this);
+ ScDocRowHeightUpdater aUpdater(*m_pDocument, aProv.GetDevice(), aProv.GetPPTX(),
+ aProv.GetPPTY(), nullptr);
+ aUpdater.update(bOnlyUsedRows);
+}
+
void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore )
{
bool bIsUndoEnabled = m_pDocument->IsUndoEnabled();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 096c219f89a6..58741d563737 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -267,6 +267,7 @@ public:
bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab );
void UpdateAllRowHeights( const ScMarkData* pTabMark = nullptr );
+ void UpdateAllRowHeights(const bool bOnlyUsedRows);
void UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore = false );
void RefreshPivotTables( const ScRange& rSource );