[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Justin Luth
justin_luth at sil.org
Tue Feb 14 01:14:34 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 | 26 ++++++++++++++--------
sc/source/filter/inc/xetable.hxx | 2 +
4 files changed, 33 insertions(+), 9 deletions(-)
New commits:
commit 1cde2eb9d128c9b1b658b1380074461429ab2214
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>
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 6413db8..fbb16cd 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 ee16f16..9ec23a1 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 6354fff..12837ca 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 ); }
};
commit 86ff0df3bd71f2e79f85b1facc7737455e732309
Author: Justin Luth <justin_luth at sil.org>
Date: Wed Feb 8 19:32:14 2017 +0300
Optimize Excel GetOrCreateRow: compare to previous map entry
Follow-up patch to 09e9274fc080b471393b806617eb03124db67590 and
related to tdf#105840. Just keeping the non-dependent parts
separate, and building up to a solution for bug 105840.
Change-Id: I129e671f71de6abf876a82d4a6503695add85548
Reviewed-on: https://gerrit.libreoffice.org/34039
Reviewed-by: Justin Luth <justin_luth at sil.org>
Tested-by: Justin Luth <justin_luth at sil.org>
Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 0c573e9..ee16f16 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2382,9 +2382,11 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysE
if( !bFound || bFoundHigher )
{
size_t nFrom = 0;
+ RowRef pPrevEntry = nullptr;
if( itr != maRowMap.begin() )
{
--itr;
+ pPrevEntry = itr->second;
if( bFoundHigher )
nFrom = nXclRow;
else
@@ -2404,10 +2406,10 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysE
// not set, to correctly export the heights of rows with wrapped
// texts.
const sal_uInt16 nHeight = rDoc.GetRowHeight(nFrom, nScTab, false);
- if ( !nFrom || ( nFrom == nXclRow ) || bHidden ||
+ if ( !pPrevEntry || ( nFrom == nXclRow ) || bHidden ||
( maOutlineBfr.IsCollapsed() ) ||
( maOutlineBfr.GetLevel() != 0 ) ||
- ( nHeight != rDoc.GetRowHeight(nFrom - 1, nScTab, false) ) )
+ ( nHeight != pPrevEntry->GetHeight() ) )
{
if( maOutlineBfr.GetLevel() > mnHighestOutlineLevel )
{
@@ -2415,6 +2417,7 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysE
}
RowRef p(new XclExpRow(GetRoot(), nFrom, maOutlineBfr, bRowAlwaysEmpty, bHidden, nHeight));
maRowMap.insert(RowMap::value_type(nFrom, p));
+ pPrevEntry = p;
}
++nFrom;
}
More information about the Libreoffice-commits
mailing list