[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sc/qa sc/source
Justin Luth
justin_luth at sil.org
Wed Feb 15 16:05:54 UTC 2017
sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx |binary
sc/qa/unit/subsequent_export-test.cxx | 14 ++++++++++++++
sc/source/filter/excel/xetable.cxx | 21 +++++++++++++--------
sc/source/filter/inc/xetable.hxx | 2 ++
4 files changed, 29 insertions(+), 8 deletions(-)
New commits:
commit 7003415978b162bdd9f84d3e2ea0d05e5599137a
Author: Justin Luth <justin_luth at sil.org>
Date: Fri Feb 10 12:44:47 2017 +0300
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 at libreoffice.org>
Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Reviewed-on: https://gerrit.libreoffice.org/34277
diff --git a/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx b/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx
new file mode 100644
index 0000000..e2c22cd
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 2a088dd..7060520 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -114,6 +114,7 @@ public:
void testColumnWidthExportFromODStoXLSX();
void testOutlineExportXLSX();
void testHiddenEmptyRowsXLSX();
+ void testAllRowsHiddenXLSX();
void testLandscapeOrientationXLSX();
void testInlineArrayXLS();
@@ -214,6 +215,7 @@ public:
CPPUNIT_TEST(testColumnWidthExportFromODStoXLSX);
CPPUNIT_TEST(testOutlineExportXLSX);
CPPUNIT_TEST(testHiddenEmptyRowsXLSX);
+ CPPUNIT_TEST(testAllRowsHiddenXLSX);
CPPUNIT_TEST(testLandscapeOrientationXLSX);
CPPUNIT_TEST(testInlineArrayXLS);
CPPUNIT_TEST(testEmbeddedChartXLS);
@@ -870,6 +872,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()
{
@@ -881,6 +894,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 b954c74..45db9a1 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2046,7 +2046,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();
}
@@ -2055,6 +2055,7 @@ void XclExpRow::DisableIfDefault( const XclExpDefaultRowData& rDefRowData )
{
mbEnabled = !IsDefaultable() ||
(mnHeight != rDefRowData.mnHeight) ||
+ (IsHidden() != rDefRowData.IsHidden()) ||
(IsUnsynced() != rDefRowData.IsUnsynced());
}
@@ -2274,12 +2275,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 *** ---------------------
@@ -2398,16 +2402,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 )
@@ -2702,10 +2707,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 16894b6..4eaea15 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 ); }
};
More information about the Libreoffice-commits
mailing list