summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <Vasily.Melenchuk@cib.de>2018-04-06 20:19:10 +0300
committerKatarina Behrens <Katarina.Behrens@cib.de>2018-10-22 23:30:23 +0200
commit693953dd4699887bd3f5bca2c3582b5fae1d6992 (patch)
tree2091b2fe8d997ef84f149ace1e6a1f00fd8e08fe
parentfad764c02c7a9cd210bfa44ea0ce1ac5354d6427 (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
-rw-r--r--sc/qa/unit/data/ods/tdf62268.odsbin0 -> 9096 bytes
-rw-r--r--sc/qa/unit/helper/qahelper.cxx3
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx59
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx26
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx21
-rw-r--r--sc/source/filter/xml/xmlimprt.hxx5
-rw-r--r--sc/source/filter/xml/xmlrowi.cxx16
7 files changed, 94 insertions, 36 deletions
diff --git a/sc/qa/unit/data/ods/tdf62268.ods b/sc/qa/unit/data/ods/tdf62268.ods
new file mode 100644
index 000000000000..da88adfd25cd
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf62268.ods
Binary files differ
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 8aa9cc883568..d414b1abfb96 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -754,7 +754,8 @@ void ScBootstrapFixture::miscRowHeightsTest( TestParam const * aTestValues, unsi
bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & CRFlags::ManualSize);
CPPUNIT_ASSERT_EQUAL(aTestValues[ index ].pData[ i ].bOptimal, bOpt);
}
- CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight);
+ // Due to some minor differences on Mac this comparison is made bit fuzzy
+ CPPUNIT_ASSERT_LESSEQUAL( 15, abs( nHeight - nExpectedHeight ) );
}
}
xShell->DoClose();
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index ea0792f5acee..36f62373e7e0 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -1034,60 +1034,57 @@ void ScExportTest::testOutlineExportXLSX()
// We expected that exactly 13 unique Nodes will be produced
assertXPath(pSheet, "/x:worksheet/x:cols/x:col", 13);
- // We need to save all 30 rows, as it provides information about outLineLevel
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "r", "1");
+ // First row is empty and default so it is not written into XML file
+ // so we need to save 29 rows, as it provides information about outLineLevel
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "r", "2");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "hidden", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "outlineLevel", "0");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "outlineLevel", "1");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "r", "2");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "r", "3");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "hidden", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "outlineLevel", "1");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "outlineLevel", "2");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "r", "3");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "r", "4");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "hidden", "false");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "outlineLevel", "2");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "r", "4");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "r", "5");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "hidden", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "outlineLevel", "2");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "outlineLevel", "3");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "r", "5");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "r", "6");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "hidden", "false");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "outlineLevel", "3");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "r", "6");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "hidden", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "outlineLevel", "3");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "r", "7");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "hidden", "true");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "outlineLevel", "4");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "r", "7");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "r", "8");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "hidden", "true");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "outlineLevel", "4");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "r", "8");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "r", "9");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "hidden", "true");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "outlineLevel", "4");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "r", "9");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "hidden", "true");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "outlineLevel", "4");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "collapsed", "false");
// Next rows are the same as the previous one but it needs to bre preserved,
// as they contain information about outlineLevel
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "r", "21");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "hidden", "true");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "outlineLevel", "4");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "collapsed", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "r", "22");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "r", "21");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "hidden", "true");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "outlineLevel", "4");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "collapsed", "false");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "r", "22");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "hidden", "false");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "outlineLevel", "3");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "collapsed", "true");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "r", "23");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "hidden", "false");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "outlineLevel", "3");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "collapsed", "true");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "r", "23");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "hidden", "false");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "outlineLevel", "3");
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "collapsed", "false");
-
- // We expected that exactly 30 Row Nodes will be produced
- assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 30);
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "collapsed", "false");
+
+ // We expected that exactly 29 Row Nodes will be produced
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 29);
}
void ScExportTest::testAllRowsHiddenXLSX()
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 0d6bc90761fb..5d112bd73489 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -246,6 +246,7 @@ public:
void testBorderColorsXLSXML();
void testHiddenRowsColumnsXLSXML();
void testColumnWidthRowHeightXLSXML();
+ void testTdf62268();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -378,6 +379,7 @@ public:
CPPUNIT_TEST(testHiddenRowsColumnsXLSXML);
CPPUNIT_TEST(testColumnWidthRowHeightXLSXML);
CPPUNIT_TEST(testCondFormatFormulaListenerXLSX);
+ CPPUNIT_TEST(testTdf62268);
CPPUNIT_TEST_SUITE_END();
@@ -2654,8 +2656,8 @@ void ScFiltersTest::testMiscRowHeights()
TestParam::RowData MultiLineOptData[] =
{
- // Row 0 is 12.63 mm and optimal flag is set
- { 0, 0, 0, 1263, CHECK_OPTIMAL, true },
+ // Row 0 is 12.63 mm, but optimal flag is set
+ { 0, 0, 0, 1236, CHECK_OPTIMAL, true },
// Row 1 is 11.99 mm and optimal flag is NOT set
{ 1, 1, 0, 1199, CHECK_OPTIMAL, false },
};
@@ -2687,8 +2689,9 @@ void ScFiltersTest::testOptimalHeightReset()
ScDocument& rDoc = xDocSh->GetDocument();
// open document in read/write mode ( otherwise optimal height stuff won't
// be triggered ) *and* you can't delete cell contents.
- int nHeight = sc::TwipsToHMM ( rDoc.GetRowHeight(nRow, nTab, false) );
- CPPUNIT_ASSERT_EQUAL(1263, nHeight);
+ int nHeight = rDoc.GetRowHeight(nRow, nTab, false);
+ // Due to some minor differences on Mac this comparison is made bit fuzzy
+ CPPUNIT_ASSERT_LESSEQUAL( 8, abs( nHeight - 701 ) );
ScDocFunc &rFunc = xDocSh->GetDocFunc();
@@ -4078,6 +4081,21 @@ void ScFiltersTest::testCondFormatFormulaListenerXLSX()
xDocSh->DoClose();
}
+void ScFiltersTest::testTdf62268()
+{
+ ScDocShellRef xDocSh = loadDoc("tdf62268.", FORMAT_ODS);
+ ScDocument& rDoc = xDocSh->GetDocument();
+ int nHeight;
+
+ SCTAB nTab = 0;
+ nHeight = rDoc.GetRowHeight(0, nTab, false);
+ CPPUNIT_ASSERT_EQUAL(256, nHeight);
+ nHeight = rDoc.GetRowHeight(1, nTab, false);
+ CPPUNIT_ASSERT_EQUAL(1905, nHeight);
+
+ xDocSh->DoClose();
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{
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);
+ }
}
}
}