diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2018-03-01 20:12:13 -0500 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2018-03-02 03:59:00 +0100 |
commit | 86978ae2471d8a4678b78679540db52a71b2571a (patch) | |
tree | a7f54bd74c984bb6c7fb4e14d2c228acb1b94d4b | |
parent | c348476a2ca16d6c32d2d17a2cae5f59e967bf6d (diff) |
Add a new test case for Excel 2003 XML import.
Change-Id: I1ba74f35e44b9cea3e3770d513ae520da02b3406
Reviewed-on: https://gerrit.libreoffice.org/50610
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
-rw-r--r-- | sc/qa/unit/data/xml/hidden-rows-columns.xml | 115 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 54 |
2 files changed, 169 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xml/hidden-rows-columns.xml b/sc/qa/unit/data/xml/hidden-rows-columns.xml new file mode 100644 index 000000000000..6b4b597bf1d3 --- /dev/null +++ b/sc/qa/unit/data/xml/hidden-rows-columns.xml @@ -0,0 +1,115 @@ +<?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>2018-02-14T01:31:11Z</Created> + <LastSaved>2018-02-14T01:35:31Z</LastSaved> + <Version>16.00</Version> + </DocumentProperties> + <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> + <AllowPNG/> + </OfficeDocumentSettings> + <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> + <WindowHeight>9105</WindowHeight> + <WindowWidth>13800</WindowWidth> + <WindowTopX>0</WindowTopX> + <WindowTopY>0</WindowTopY> + <ActiveSheet>1</ActiveSheet> + <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="Hidden Rows"> + <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="9" x:FullColumns="1" + x:FullRows="1" ss:DefaultRowHeight="15"> + <Row> + <Cell><Data ss:Type="String">visible</Data></Cell> + </Row> + <Row ss:Hidden="1"> + <Cell><Data ss:Type="String">hidden</Data></Cell> + </Row> + <Row ss:Hidden="1"> + <Cell><Data ss:Type="String">hidden</Data></Cell> + </Row> + <Row> + <Cell><Data ss:Type="String">visible</Data></Cell> + </Row> + <Row ss:Hidden="1"> + <Cell><Data ss:Type="String">hidden</Data></Cell> + </Row> + <Row> + <Cell><Data ss:Type="String">visible</Data></Cell> + </Row> + <Row> + <Cell><Data ss:Type="String">visible</Data></Cell> + </Row> + <Row> + <Cell><Data ss:Type="String">visible</Data></Cell> + </Row> + <Row ss:Hidden="1"> + <Cell><Data ss:Type="String">hidden</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> + <Panes> + <Pane> + <Number>3</Number> + <ActiveRow>14</ActiveRow> + <ActiveCol>3</ActiveCol> + </Pane> + </Panes> + <ProtectObjects>False</ProtectObjects> + <ProtectScenarios>False</ProtectScenarios> + </WorksheetOptions> + </Worksheet> + <Worksheet ss:Name="Hidden Columns"> + <Table ss:ExpandedColumnCount="12" ss:ExpandedRowCount="1" x:FullColumns="1" + x:FullRows="1" ss:DefaultRowHeight="15"> + <Column ss:Index="3" ss:Hidden="1" ss:AutoFitWidth="0" ss:Span="3"/> + <Column ss:Index="11" ss:Hidden="1" ss:AutoFitWidth="0"/> + <Row> + <Cell ss:Index="2"><Data ss:Type="String">hidden -></Data></Cell> + <Cell ss:Index="7"><Data ss:Type="String"><- hidden</Data></Cell> + <Cell ss:Index="10"><Data ss:Type="String">hidden -></Data></Cell> + <Cell ss:Index="12"><Data ss:Type="String"><- hidden</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>10</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 be17f2ad3f50..5332bc77722e 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -243,6 +243,7 @@ public: void testEmptyRowsXLSXML(); void testBorderDirectionsXLSXML(); void testBorderColorsXLSXML(); + void testHiddenRowsColumnsXLSXML(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testBooleanFormatXLSX); @@ -371,6 +372,7 @@ public: CPPUNIT_TEST(testEmptyRowsXLSXML); CPPUNIT_TEST(testBorderDirectionsXLSXML); CPPUNIT_TEST(testBorderColorsXLSXML); + CPPUNIT_TEST(testHiddenRowsColumnsXLSXML); CPPUNIT_TEST(testCondFormatFormulaListenerXLSX); CPPUNIT_TEST_SUITE_END(); @@ -3832,6 +3834,58 @@ void ScFiltersTest::testBorderColorsXLSXML() xDocSh->DoClose(); } +void ScFiltersTest::testHiddenRowsColumnsXLSXML() +{ + ScDocShellRef xDocSh = loadDoc("hidden-rows-columns.", FORMAT_XLS_XML); + CPPUNIT_ASSERT_MESSAGE("Failed to load hidden-rows-columns.xml", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + + struct Check + { + SCCOLROW nPos1; + SCCOLROW nPos2; + bool bVisible; + }; + + std::vector<Check> aRowChecks = { + { 0, 0, true }, + { 1, 2, false }, + { 3, 3, true }, + { 4, 4, false }, + { 5, 7, true }, + { 8, 8, false }, + { 9, MAXROW, true }, + }; + + for (const Check& c : aRowChecks) + { + SCROW nRow1 = -1, nRow2 = -1; + bool bVisible = !rDoc.RowHidden(c.nPos1, 0, &nRow1, &nRow2); + CPPUNIT_ASSERT_EQUAL(bVisible, c.bVisible); + CPPUNIT_ASSERT_EQUAL(c.nPos1, nRow1); + CPPUNIT_ASSERT_EQUAL(c.nPos2, nRow2); + } + + std::vector<Check> aColChecks = { + { 0, 1, true }, + { 2, 5, false }, + { 6, 9, true }, + { 10, 10, false }, + { 11, MAXCOL, true }, + }; + + for (const Check& c : aColChecks) + { + SCCOL nCol1 = -1, nCol2 = -1; + bool bVisible = !rDoc.ColHidden(c.nPos1, 1, &nCol1, &nCol2); + CPPUNIT_ASSERT_EQUAL(bVisible, c.bVisible); + CPPUNIT_ASSERT_EQUAL(c.nPos1, SCCOLROW(nCol1)); + CPPUNIT_ASSERT_EQUAL(c.nPos2, SCCOLROW(nCol2)); + } + + xDocSh->DoClose(); +} + void ScFiltersTest::testCondFormatXLSB() { ScDocShellRef xDocSh = loadDoc("cond_format.", FORMAT_XLSB); |