diff options
author | Justin Luth <justin_luth@sil.org> | 2017-02-10 12:44:47 +0300 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2017-02-14 01:14:28 +0000 |
commit | 1cde2eb9d128c9b1b658b1380074461429ab2214 (patch) | |
tree | a32594b08b8fb7f809173109dda25fd1e146071c /sc | |
parent | 86ff0df3bd71f2e79f85b1facc7737455e732309 (diff) |
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/34128
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx | bin | 0 -> 7015 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 21 | ||||
-rw-r--r-- | sc/source/filter/inc/xetable.hxx | 2 |
4 files changed, 29 insertions, 8 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx b/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx Binary files differnew file mode 100644 index 000000000000..e2c22cd16d8f --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 6413db82c015..fbb16cd9748c 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -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"); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index ee16f1690e08..9ec23a1aa79b 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -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 ); diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx index 6354fff38089..12837cac6964 100644 --- a/sc/source/filter/inc/xetable.hxx +++ b/sc/source/filter/inc/xetable.hxx @@ -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 ); } }; |