Kaydet (Commit) 1e55a47e authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Thorsten Behrens

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.

Change-Id: Ib38b5b753d9ff8352116d77851d228c5d77bd530
Reviewed-on: https://gerrit.libreoffice.org/52521Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 2a7f7490
......@@ -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( 3, abs( nHeight - nExpectedHeight ) );
}
}
xShell->DoClose();
......
......@@ -1026,60 +1026,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()
......
......@@ -245,6 +245,7 @@ public:
void testBorderColorsXLSXML();
void testHiddenRowsColumnsXLSXML();
void testColumnWidthRowHeightXLSXML();
void testTdf62268();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
......@@ -376,6 +377,7 @@ public:
CPPUNIT_TEST(testHiddenRowsColumnsXLSXML);
CPPUNIT_TEST(testColumnWidthRowHeightXLSXML);
CPPUNIT_TEST(testCondFormatFormulaListenerXLSX);
CPPUNIT_TEST(testTdf62268);
CPPUNIT_TEST_SUITE_END();
......@@ -2652,8 +2654,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 },
};
......@@ -2685,8 +2687,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( 3, abs( nHeight - 701 ) );
ScDocFunc &rFunc = xDocSh->GetDocFunc();
......@@ -4059,6 +4062,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" )
{
......
......@@ -76,6 +76,7 @@
#include "pivotsource.hxx"
#include <unonames.hxx>
#include <numformat.hxx>
#include <sizedev.hxx>
#include <comphelper/base64.hxx>
#include <comphelper/extract.hxx>
......@@ -1803,6 +1804,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())
......
......@@ -32,6 +32,7 @@
#include <global.hxx>
#include <formula/grammar.hxx>
#include <compiler.hxx>
#include <dociter.hxx>
#include "xmlstyle.hxx"
#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
......@@ -270,6 +271,8 @@ class ScXMLImport: public SvXMLImport
ScMyTables aTables;
std::vector<ScDocRowHeightUpdater::TabRanges> maRecalcRowRanges;
std::unique_ptr<ScMyNamedExpressions> m_pMyNamedExpressions;
SheetNamedExpMap m_SheetNamedExpressions;
......@@ -342,6 +345,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);
......
......@@ -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);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment