diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2016-06-17 16:21:06 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-02-08 11:56:05 +0100 |
commit | 50f348bc6d20ff7c84016f7b6cee326e0a85c71b (patch) | |
tree | 243267b7c8ddeefcf12f826eb6cc13694ebcd9a7 /sc | |
parent | 4184364712caa9899af6d986aa37b4b470511a97 (diff) |
tdf#98106 Preserving hidden and empty rows after xlsx export
Change-Id: I1ff2bab766eadac1dd5d483453af0e760634083d
Reviewed-on: https://gerrit.libreoffice.org/26421
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
(cherry picked from commit 228c25fd17727660a3372307e3f73dbcff5e71d2)
Reviewed-on: https://gerrit.libreoffice.org/31640
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit 7dd19273530730478b5ed24b79f42ac480c7ae43)
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/ods/hidden-empty-rows.ods | bin | 0 -> 7660 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 19 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 16 | ||||
-rw-r--r-- | sc/source/filter/inc/xetable.hxx | 2 |
4 files changed, 29 insertions, 8 deletions
diff --git a/sc/qa/unit/data/ods/hidden-empty-rows.ods b/sc/qa/unit/data/ods/hidden-empty-rows.ods Binary files differnew file mode 100644 index 000000000000..f3435ad4304a --- /dev/null +++ b/sc/qa/unit/data/ods/hidden-empty-rows.ods diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 388d6aeb14b4..c89ff6ad6af7 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -108,6 +108,8 @@ public: void testCellNoteExportXLS(); void testFormatExportODS(); + void testHiddenEmptyRowsXLSX(); + void testInlineArrayXLS(); void testEmbeddedChartXLS(); void testFormulaReferenceXLS(); @@ -181,6 +183,7 @@ public: CPPUNIT_TEST(testCellNoteExportODS); CPPUNIT_TEST(testCellNoteExportXLS); CPPUNIT_TEST(testFormatExportODS); + CPPUNIT_TEST(testHiddenEmptyRowsXLSX); CPPUNIT_TEST(testInlineArrayXLS); CPPUNIT_TEST(testEmbeddedChartXLS); CPPUNIT_TEST(testFormulaReferenceXLS); @@ -453,6 +456,22 @@ void ScExportTest::testFormatExportODS() xDocSh->DoClose(); } +void ScExportTest::testHiddenEmptyRowsXLSX() +{ + //tdf#98106 FILESAVE: Hidden and empty rows became visible when export to .XLSX + ScDocShellRef xShell = loadDoc("hidden-empty-rows.", FORMAT_ODS); + CPPUNIT_ASSERT(xShell.Is()); + + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX); + xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pSheet); + + 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"); + assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "hidden", "false"); +} + void ScExportTest::testDataBarExportXLSX() { ScDocShellRef xShell = loadDoc("databar.", FORMAT_XLSX); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 7ea06f7db8e0..68cc5ac4ccf8 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -2008,15 +2008,14 @@ sal_uInt16 XclExpRow::GetFirstFreeXclCol() const bool XclExpRow::IsDefaultable() const { - const sal_uInt16 nAllowedFlags = EXC_ROW_DEFAULTFLAGS | EXC_ROW_HIDDEN | EXC_ROW_UNSYNCED; - return !::get_flag( mnFlags, static_cast< sal_uInt16 >( ~nAllowedFlags ) ) && IsEmpty(); + const sal_uInt16 nFlagsAlwaysMarkedAsDefault = EXC_ROW_DEFAULTFLAGS | EXC_ROW_UNSYNCED; + return !::get_flag( mnFlags, static_cast< sal_uInt16 >( ~nFlagsAlwaysMarkedAsDefault ) ) && IsEmpty(); } void XclExpRow::DisableIfDefault( const XclExpDefaultRowData& rDefRowData ) { mbEnabled = !IsDefaultable() || (mnHeight != rDefRowData.mnHeight) || - (IsHidden() != rDefRowData.IsHidden()) || (IsUnsynced() != rDefRowData.IsUnsynced()); } @@ -2187,6 +2186,7 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt XclExpDefaultRowData aMaxDefData; size_t nMaxDefCount = 0; // only look for default format in existing rows, if there are more than unused + // if the row is hidden, then row xml must be created even if it not contain cells XclExpRow* pPrev = nullptr; typedef std::vector< XclExpRow* > XclRepeatedRows; XclRepeatedRows aRepeated; @@ -2194,7 +2194,7 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt for (itr = itrBeg; itr != itrEnd; ++itr) { const RowRef& rRow = itr->second; - if (rRow->IsDefaultable()) + if ( rRow->IsDefaultable() ) { XclExpDefaultRowData aDefData( *rRow ); size_t& rnDefCount = aDefRowMap[ aDefData ]; @@ -2207,7 +2207,7 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt } if ( pPrev ) { - if ( pPrev->IsDefaultable()) + if ( pPrev->IsDefaultable() ) { // if the previous row we processed is not // defaultable then afaict the rows in between are @@ -2340,8 +2340,10 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysE if ( itr == maRowMap.end() ) { // only create RowMap entries for rows that differ from previous, - // or if it is the desired row - if ( !nFrom || ( nFrom == nXclRow ) || ( nFrom && ( rDoc.GetRowHeight(nFrom, nScTab, false) != rDoc.GetRowHeight(nFrom-1, nScTab, false) ) ) ) + // the row is hidden (tdf#98106) or if it is the desired row + if ( !nFrom || ( nFrom == nXclRow ) || + ( rDoc.GetRowHeight(nFrom, nScTab, false) != rDoc.GetRowHeight(nFrom - 1, nScTab, false) ) || + ( rDoc.RowHidden(nFrom, nScTab) ) ) { RowRef p(new XclExpRow(GetRoot(), nFrom, maOutlineBfr, bRowAlwaysEmpty)); maRowMap.insert(RowMap::value_type(nFrom, p)); diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx index e6318fd1b4b0..6ea30c4dcd53 100644 --- a/sc/source/filter/inc/xetable.hxx +++ b/sc/source/filter/inc/xetable.hxx @@ -591,7 +591,7 @@ public: protected: /** Constructs the outline buffer. - @param bRows true = Process row ouline array; false = Process column outline array. */ + @param bRows true = Process row outline array; false = Process column outline array. */ explicit XclExpOutlineBuffer( const XclExpRoot& rRoot, bool bRows ); /** Updates the current state by processing the settings at the passed Calc position. */ |