diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2018-03-02 22:04:51 -0500 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2018-03-03 05:21:40 +0100 |
commit | 08b8b55d9d540fcd29d18dd8883d24de457e2675 (patch) | |
tree | fb9c3b7aec8d52a92452c2e620d967a25fe44bf0 /sc | |
parent | 44b4ad7d210097fdaed7dd94c5746b03f43592d3 (diff) |
Add a new test case for Excel 2003 XML import.
This one checks on importing column widths and row heights.
Change-Id: I19c63230666aa949eb61805ed2bffe46199a305e
Reviewed-on: https://gerrit.libreoffice.org/50653
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/xml/column-width-row-height.xml | 100 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 60 |
2 files changed, 160 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xml/column-width-row-height.xml b/sc/qa/unit/data/xml/column-width-row-height.xml new file mode 100644 index 000000000000..170cd28cd31f --- /dev/null +++ b/sc/qa/unit/data/xml/column-width-row-height.xml @@ -0,0 +1,100 @@ +<?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>2013-04-16T23:00:57Z</Created> + <LastSaved>2013-04-16T23:09:17Z</LastSaved> + <Company>Novell, Inc.</Company> + <Version>16.00</Version> + </DocumentProperties> + <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> + <AllowPNG/> + </OfficeDocumentSettings> + <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> + <WindowHeight>12210</WindowHeight> + <WindowWidth>28800</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="12" ss:ExpandedRowCount="14" x:FullColumns="1" + x:FullRows="1" ss:DefaultRowHeight="15"> + <Column ss:AutoFitWidth="0" ss:Width="93"/> + <Column ss:AutoFitWidth="0" ss:Width="56"/> + <Column ss:AutoFitWidth="0" ss:Width="83"/> + <Column ss:AutoFitWidth="0" ss:Width="109"/> + <Column ss:Index="6" ss:AutoFitWidth="0" ss:Width="67" ss:Span="2"/> + <Column ss:Index="11" ss:AutoFitWidth="0" ss:Width="119" ss:Span="1"/> + <Row ss:AutoFitHeight="0"> + <Cell><Data ss:Type="String">Column Width</Data></Cell> + <Cell><Data ss:Type="Number">10</Data></Cell> + <Cell><Data ss:Type="Number">15</Data></Cell> + <Cell><Data ss:Type="Number">20</Data></Cell> + <Cell ss:Index="6"><Data ss:Type="Number">12</Data></Cell> + <Cell><Data ss:Type="Number">12</Data></Cell> + <Cell><Data ss:Type="Number">12</Data></Cell> + <Cell ss:Index="11"><Data ss:Type="Number">22</Data></Cell> + <Cell><Data ss:Type="Number">22</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0"> + <Cell><Data ss:Type="String">Row Height</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0" ss:Height="20"> + <Cell><Data ss:Type="Number">20</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0" ss:Height="30"> + <Cell><Data ss:Type="Number">30</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0" ss:Height="40"> + <Cell><Data ss:Type="Number">40</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0" ss:Height="50"> + <Cell><Data ss:Type="Number">50</Data></Cell> + </Row> + <Row ss:Index="8" ss:AutoFitHeight="0" ss:Height="25"> + <Cell><Data ss:Type="Number">25</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0" ss:Height="25"> + <Cell><Data ss:Type="Number">25</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0" ss:Height="25"> + <Cell><Data ss:Type="Number">25</Data></Cell> + </Row> + <Row ss:Index="13" ss:AutoFitHeight="0" ss:Height="35"> + <Cell><Data ss:Type="Number">35</Data></Cell> + </Row> + <Row ss:AutoFitHeight="0" ss:Height="35"> + <Cell><Data ss:Type="Number">35</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> + <Unsynced/> + <Selected/> + <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 6742e12b999e..3ec2982ada04 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -244,6 +244,7 @@ public: void testBorderDirectionsXLSXML(); void testBorderColorsXLSXML(); void testHiddenRowsColumnsXLSXML(); + void testColumnWidthRowHeightXLSXML(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testBooleanFormatXLSX); @@ -373,6 +374,7 @@ public: CPPUNIT_TEST(testBorderDirectionsXLSXML); CPPUNIT_TEST(testBorderColorsXLSXML); CPPUNIT_TEST(testHiddenRowsColumnsXLSXML); + CPPUNIT_TEST(testColumnWidthRowHeightXLSXML); CPPUNIT_TEST(testCondFormatFormulaListenerXLSX); CPPUNIT_TEST_SUITE_END(); @@ -3887,6 +3889,64 @@ void ScFiltersTest::testHiddenRowsColumnsXLSXML() xDocSh->DoClose(); } +void ScFiltersTest::testColumnWidthRowHeightXLSXML() +{ + ScDocShellRef xDocSh = loadDoc("column-width-row-height.", FORMAT_XLS_XML); + CPPUNIT_ASSERT_MESSAGE("Failed to load column-width-row-height.xml", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + + struct RowHeight + { + SCROW nRow1; + SCROW nRow2; + sal_uInt16 nHeight; // in points (1 point == 20 twips) + }; + + std::vector<RowHeight> aRowChecks = { + { 2, 2, 20 }, + { 3, 3, 30 }, + { 4, 4, 40 }, + { 5, 5, 50 }, + { 7, 9, 25 }, + { 12, 13, 35 }, + }; + + for (const RowHeight& rh : aRowChecks) + { + for (SCROW i = rh.nRow1; i <= rh.nRow2; ++i) + { + sal_uInt16 nHeight = rDoc.GetRowHeight(i, 0); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(rh.nHeight*20), nHeight); + } + } + + struct ColWidth + { + SCCOL nCol1; + SCCOL nCol2; + sal_uInt16 nWidth; // in points (1 point == 20 twips + }; + + std::vector<ColWidth> aColChecks = { + { 1, 1, 56 }, + { 2, 2, 83 }, + { 3, 3, 109 }, + { 5, 7, 67 }, + { 10, 11, 119 }, + }; + + for (const ColWidth& cw : aColChecks) + { + for (SCCOL i = cw.nCol1; i <= cw.nCol2; ++i) + { + sal_uInt16 nWidth = rDoc.GetColWidth(i, 0); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(cw.nWidth*20), nWidth); + } + } + + xDocSh->DoClose(); +} + void ScFiltersTest::testCondFormatXLSB() { ScDocShellRef xDocSh = loadDoc("cond_format.", FORMAT_XLSB); |