summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2018-02-17 09:12:48 -0500
committerKohei Yoshida <libreoffice@kohei.us>2018-02-17 21:04:59 +0100
commit1c791a9b28af5e6ece46e1d48a2acde9d4c81c78 (patch)
treefb51695e4fb77bfde6ebcb3bf4d2391194e8576e
parent5b9e76557d2b5c835a5873de1ce530f36ea98d2d (diff)
Add a test to make sure we import docs with empty rows correctly.
The previous XSLT-based filter failed to import this correctly. Change-Id: I6218bd2b3e5c5ac1514f84b959be27df23a0c3f8 Reviewed-on: https://gerrit.libreoffice.org/49907 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
-rw-r--r--sc/qa/unit/data/xml/empty-rows.xml79
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx35
2 files changed, 114 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xml/empty-rows.xml b/sc/qa/unit/data/xml/empty-rows.xml
new file mode 100644
index 000000000000..624e94bb4201
--- /dev/null
+++ b/sc/qa/unit/data/xml/empty-rows.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+<?mso-application progid="Excel.Sheet"?>
+<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
+ xmlns:o="urn:schemas-microsoft-com:office:office"
+ xmlns:x="urn:schemas-microsoft-com:office:excel"
+ xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
+ xmlns:html="http://www.w3.org/TR/REC-html40">
+ <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
+ <Author>Kohei Yoshida</Author>
+ <LastAuthor>Kohei Yoshida</LastAuthor>
+ <Created>2016-12-14T01:54:30Z</Created>
+ <LastSaved>2016-12-14T01:58:30Z</LastSaved>
+ <Version>15.00</Version>
+ </DocumentProperties>
+ <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
+ <AllowPNG/>
+ </OfficeDocumentSettings>
+ <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
+ <WindowHeight>14385</WindowHeight>
+ <WindowWidth>24000</WindowWidth>
+ <WindowTopX>0</WindowTopX>
+ <WindowTopY>0</WindowTopY>
+ <ProtectStructure>False</ProtectStructure>
+ <ProtectWindows>False</ProtectWindows>
+ </ExcelWorkbook>
+ <Styles>
+ <Style ss:ID="Default" ss:Name="Normal">
+ <Alignment ss:Vertical="Bottom"/>
+ <Borders/>
+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
+ <Interior/>
+ <NumberFormat/>
+ <Protection/>
+ </Style>
+ </Styles>
+ <Worksheet ss:Name="Sheet1">
+ <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="9" x:FullColumns="1"
+ x:FullRows="1" ss:DefaultRowHeight="15">
+ <Row>
+ <Cell><Data ss:Type="String">Top row, followed by 2 empty rows.</Data></Cell>
+ </Row>
+ <Row ss:Index="4">
+ <Cell ss:Index="2"><Data ss:Type="Number">1</Data></Cell>
+ </Row>
+ <Row>
+ <Cell ss:Index="2"><Data ss:Type="Number">2</Data></Cell>
+ </Row>
+ <Row>
+ <Cell ss:Index="2"><Data ss:Type="Number">3</Data></Cell>
+ </Row>
+ <Row>
+ <Cell ss:Index="2"><Data ss:Type="Number">4</Data></Cell>
+ </Row>
+ <Row>
+ <Cell ss:Index="2"><Data ss:Type="Number">5</Data></Cell>
+ </Row>
+ <Row>
+ <Cell ss:Index="2" ss:Formula="=SUM(R[-5]C:R[-1]C)"><Data ss:Type="Number">15</Data></Cell>
+ </Row>
+ </Table>
+ <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
+ <PageSetup>
+ <Header x:Margin="0.3"/>
+ <Footer x:Margin="0.3"/>
+ <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
+ </PageSetup>
+ <Selected/>
+ <Panes>
+ <Pane>
+ <Number>3</Number>
+ <ActiveRow>9</ActiveRow>
+ <ActiveCol>1</ActiveCol>
+ </Pane>
+ </Panes>
+ <ProtectObjects>False</ProtectObjects>
+ <ProtectScenarios>False</ProtectScenarios>
+ </WorksheetOptions>
+ </Worksheet>
+</Workbook>
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 214062f30ef0..4f72dddadf44 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -238,6 +238,7 @@ public:
void testMergedCellsXLSXML();
void testBackgroundColorStandardXLSXML();
void testNamedExpressionsXLSXML();
+ void testEmptyRowsXLSXML();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -363,6 +364,7 @@ public:
CPPUNIT_TEST(testMergedCellsXLSXML);
CPPUNIT_TEST(testBackgroundColorStandardXLSXML);
CPPUNIT_TEST(testNamedExpressionsXLSXML);
+ CPPUNIT_TEST(testEmptyRowsXLSXML);
CPPUNIT_TEST_SUITE_END();
@@ -3643,6 +3645,39 @@ void ScFiltersTest::testNamedExpressionsXLSXML()
}
}
+void ScFiltersTest::testEmptyRowsXLSXML()
+{
+ ScDocShellRef xDocSh = loadDoc("empty-rows.", FORMAT_XLS_XML);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load empty-rows.xml", xDocSh.is());
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ {
+ // Expected output table content. 0 = empty cell
+ std::vector<std::vector<const char*>> aOutputCheck = {
+ { "Top row, followed by 2 empty rows.", nullptr },
+ { nullptr, nullptr },
+ { nullptr, nullptr },
+ { nullptr, "1" },
+ { nullptr, "2" },
+ { nullptr, "3" },
+ { nullptr, "4" },
+ { nullptr, "5" },
+ { nullptr, "15" },
+ };
+
+ ScRange aDataRange;
+ aDataRange.Parse("A1:B9");
+ bool bSuccess = checkOutput(&rDoc, aDataRange, aOutputCheck, "Expected output");
+ CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+ }
+
+ ScAddress aPos;
+ aPos.Parse("B9");
+ ASSERT_FORMULA_EQUAL(rDoc, aPos, "SUM(B4:B8)", nullptr);
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testCondFormatXLSB()
{
ScDocShellRef xDocSh = loadDoc("cond_format.", FORMAT_XLSB);