Kaydet (Commit) 1cde2eb9 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Bartosz Kosiorek

tdf#105840 EXCEL export: fixes for hidden defaultRow

second attempt at fixing hidden rows without creating
a million repeated rows. (related to tdf#98106)
This affects both .xls and .xlsx.  XLSX previously had
NO support for default-hidden(zeroHeight), but XLS already did.

Change-Id: I804e3f2ba21e595a1c2b2ebb355f0995868dd289
Reviewed-on: https://gerrit.libreoffice.org/34128Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst 86ff0df3
......@@ -116,6 +116,7 @@ public:
void testColumnWidthExportFromODStoXLSX();
void testOutlineExportXLSX();
void testHiddenEmptyRowsXLSX();
void testAllRowsHiddenXLSX();
void testLandscapeOrientationXLSX();
void testInlineArrayXLS();
......@@ -217,6 +218,7 @@ public:
CPPUNIT_TEST(testColumnWidthExportFromODStoXLSX);
CPPUNIT_TEST(testOutlineExportXLSX);
CPPUNIT_TEST(testHiddenEmptyRowsXLSX);
CPPUNIT_TEST(testAllRowsHiddenXLSX);
CPPUNIT_TEST(testLandscapeOrientationXLSX);
CPPUNIT_TEST(testInlineArrayXLS);
CPPUNIT_TEST(testEmbeddedChartXLS);
......@@ -891,6 +893,17 @@ void ScExportTest::testOutlineExportXLSX()
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 30);
}
void ScExportTest::testAllRowsHiddenXLSX()
{
ScDocShellRef xOrigDocSh = loadDoc("tdf105840_allRowsHidden.", FORMAT_XLSX);
CPPUNIT_ASSERT(xOrigDocSh.is());
std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xOrigDocSh), FORMAT_XLSX);
xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
CPPUNIT_ASSERT(pSheet);
assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "zeroHeight", "true" );
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 0);
}
void ScExportTest::testHiddenEmptyRowsXLSX()
{
......@@ -902,6 +915,7 @@ void ScExportTest::testHiddenEmptyRowsXLSX()
xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
CPPUNIT_ASSERT(pSheet);
assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "zeroHeight", "false" );
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "hidden", "true");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "hidden", "true");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "hidden", "true");
......
......@@ -2047,7 +2047,7 @@ sal_uInt16 XclExpRow::GetFirstFreeXclCol() const
bool XclExpRow::IsDefaultable() const
{
const sal_uInt16 nFlagsAlwaysMarkedAsDefault = EXC_ROW_DEFAULTFLAGS | EXC_ROW_UNSYNCED;
const sal_uInt16 nFlagsAlwaysMarkedAsDefault = EXC_ROW_DEFAULTFLAGS | EXC_ROW_HIDDEN | EXC_ROW_UNSYNCED;
return !::get_flag( mnFlags, static_cast< sal_uInt16 >( ~nFlagsAlwaysMarkedAsDefault ) ) &&
IsEmpty();
}
......@@ -2056,6 +2056,7 @@ void XclExpRow::DisableIfDefault( const XclExpDefaultRowData& rDefRowData )
{
mbEnabled = !IsDefaultable() ||
(mnHeight != rDefRowData.mnHeight) ||
(IsHidden() != rDefRowData.IsHidden()) ||
(IsUnsynced() != rDefRowData.IsUnsynced());
}
......@@ -2275,12 +2276,15 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt
// return the default row format to caller
rDefRowData = aMaxDefData;
// now disable repeating extra (empty) rows that are equal to
// default row height
// now disable repeating extra (empty) rows that are equal to the default row
for ( XclRepeatedRows::iterator it = aRepeated.begin(), it_end = aRepeated.end(); it != it_end; ++it)
{
if ( (*it)->GetXclRowRpt() > 1 && (*it)->GetHeight() == rDefRowData.mnHeight )
if ( (*it)->GetXclRowRpt() > 1
&& (*it)->GetHeight() == rDefRowData.mnHeight
&& (*it)->IsHidden() == rDefRowData.IsHidden() )
{
(*it)->SetXclRowRpt( 1 );
}
}
// *** Disable unused ROW records, find used area *** ---------------------
......@@ -2399,16 +2403,17 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysE
while( nFrom <= nXclRow )
{
// only create RowMap entries if it is first row in spreadsheet,
// if it is the desired row, for rows that height differ from previous,
// if row is collapsed, has outline level (tdf#100347), or row is hidden (tdf#98106).
// if it is the desired row, or for rows that differ from previous.
const bool bHidden = rDoc.RowHidden(nFrom, nScTab);
// Always get the actual row height even if the manual size flag is
// not set, to correctly export the heights of rows with wrapped
// texts.
const sal_uInt16 nHeight = rDoc.GetRowHeight(nFrom, nScTab, false);
if ( !pPrevEntry || ( nFrom == nXclRow ) || bHidden ||
if ( !pPrevEntry || ( nFrom == nXclRow ) ||
( maOutlineBfr.IsCollapsed() ) ||
( maOutlineBfr.GetLevel() != 0 ) ||
( bRowAlwaysEmpty && !pPrevEntry->IsEmpty() ) ||
( bHidden != pPrevEntry->IsHidden() ) ||
( nHeight != pPrevEntry->GetHeight() ) )
{
if( maOutlineBfr.GetLevel() > mnHighestOutlineLevel )
......@@ -2703,10 +2708,10 @@ void XclExpCellTable::SaveXml( XclExpXmlStream& rStrm )
// OOXTODO: XML_baseColWidth
// OOXTODO: XML_defaultColWidth
// OOXTODO: XML_customHeight
// OOXTODO: XML_zeroHeight
// OOXTODO: XML_thickTop
// OOXTODO: XML_thickBottom
XML_defaultRowHeight, OString::number( static_cast< double> ( rDefData.mnHeight ) / 20.0 ).getStr(),
XML_zeroHeight, XclXmlUtils::ToPsz( rDefData.IsHidden() ),
XML_outlineLevelRow, OString::number( maRowBfr.GetHighestOutlineLevel() ).getStr(),
XML_outlineLevelCol, OString::number( maColInfoBfr.GetHighestOutlineLevel() ).getStr(),
FSEND );
......
......@@ -797,6 +797,8 @@ struct XclExpDefaultRowData
explicit XclExpDefaultRowData();
explicit XclExpDefaultRowData( const XclExpRow& rRow );
/** Returns true, if rows are hidden by default. */
inline bool IsHidden() const { return ::get_flag( mnFlags, EXC_DEFROW_HIDDEN ); }
/** Returns true, if the rows have a manually set height by default. */
inline bool IsUnsynced() const { return ::get_flag( mnFlags, EXC_DEFROW_UNSYNCED ); }
};
......
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