sc/CppunitTest_sc_bugfix_test.mk | 4 - sc/CppunitTest_sc_filters_test.mk | 4 - sc/inc/document.hxx | 2 sc/qa/unit/data/xml/merged-cells.xml | 101 +++++++++++++++++++++++++++++++++ sc/qa/unit/helper/qahelper.cxx | 2 sc/qa/unit/helper/qahelper.hxx | 2 sc/qa/unit/subsequent_filters-test.cxx | 37 ++++++++++++ 7 files changed, 141 insertions(+), 11 deletions(-)
New commits: commit cbec4cb7b11081ccc75822cf4954a5cc253c15f3 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Feb 15 23:04:58 2018 -0500 Add a test case for importing merged cells from Excel 2003 XML file. Since the filter type has changed, we need to also update the filter flags used in the unit tests. And because the new filter no longer relies on XSLT, we can drop the dependency on xslt. Change-Id: I9dd040b3c8c0e95300c4dda1b87bf448a800097d Reviewed-on: https://gerrit.libreoffice.org/49832 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Kohei Yoshida <libreoff...@kohei.us> diff --git a/sc/CppunitTest_sc_bugfix_test.mk b/sc/CppunitTest_sc_bugfix_test.mk index d14a9e1154da..7a5d5825d1d8 100644 --- a/sc/CppunitTest_sc_bugfix_test.mk +++ b/sc/CppunitTest_sc_bugfix_test.mk @@ -119,8 +119,4 @@ endif $(eval $(call gb_CppunitTest_use_configuration,sc_bugfix_test)) -$(eval $(call gb_CppunitTest_use_packages,sc_bugfix_test,\ - filter_xslt \ -)) - # vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk index 3026f841504a..1f83822b107a 100644 --- a/sc/CppunitTest_sc_filters_test.mk +++ b/sc/CppunitTest_sc_filters_test.mk @@ -113,8 +113,4 @@ $(eval $(call gb_CppunitTest_use_components,sc_filters_test,\ $(eval $(call gb_CppunitTest_use_configuration,sc_filters_test)) -$(eval $(call gb_CppunitTest_use_packages,sc_filters_test,\ - filter_xslt \ -)) - # vim: set noet sw=4 ts=4: diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 26d82e631683..c74e6789cf36 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1196,7 +1196,7 @@ public: SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab, bool bRefresh = false ); bool ExtendMerge( ScRange& rRange, bool bRefresh = false ); - void ExtendTotalMerge( ScRange& rRange ) const; + SC_DLLPUBLIC void ExtendTotalMerge( ScRange& rRange ) const; SC_DLLPUBLIC void ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const; SC_DLLPUBLIC void ExtendOverlapped( ScRange& rRange ) const; diff --git a/sc/qa/unit/data/xml/merged-cells.xml b/sc/qa/unit/data/xml/merged-cells.xml new file mode 100644 index 000000000000..6bc69d55b165 --- /dev/null +++ b/sc/qa/unit/data/xml/merged-cells.xml @@ -0,0 +1,101 @@ +<?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-15T03:48:24Z</Created> + <LastSaved>2016-12-15T03:54:21Z</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> + <RefModeR1C1/> + <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> + <Style ss:ID="s17"> + <Interior ss:Color="#FCE4D6" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s22"> + <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/> + <Interior ss:Color="#EDEDED" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s23"> + <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/> + <Interior ss:Color="#FFF2CC" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s24"> + <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/> + <Interior ss:Color="#F8CBAD" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s25"> + <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/> + <Interior ss:Color="#F4B084" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s26"> + <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/> + <Interior ss:Color="#FFFF00" ss:Pattern="Solid"/> + </Style> + </Styles> + <Worksheet ss:Name="Sheet1"> + <Table ss:ExpandedColumnCount="6" ss:ExpandedRowCount="6" x:FullColumns="1" + x:FullRows="1" ss:DefaultRowHeight="15"> + <Row> + <Cell ss:StyleID="s17"><Data ss:Type="Number">1</Data></Cell> + <Cell ss:MergeAcross="1" ss:StyleID="s22"><Data ss:Type="Number">2</Data></Cell> + <Cell ss:MergeAcross="2" ss:StyleID="s23"><Data ss:Type="Number">3</Data></Cell> + </Row> + <Row> + <Cell ss:MergeDown="1" ss:StyleID="s24"><Data ss:Type="Number">2</Data></Cell> + </Row> + <Row> + <Cell ss:Index="3" ss:MergeAcross="3" ss:MergeDown="3" ss:StyleID="s26"><Data + ss:Type="String">merged cell</Data></Cell> + </Row> + <Row> + <Cell ss:MergeDown="2" ss:StyleID="s25"><Data ss:Type="Number">3</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> + <Print> + <ValidPrinterInfo/> + <VerticalResolution>0</VerticalResolution> + </Print> + <Selected/> + <Panes> + <Pane> + <Number>3</Number> + <ActiveRow>8</ActiveRow> + <ActiveCol>5</ActiveCol> + </Pane> + </Panes> + <ProtectObjects>False</ProtectObjects> + <ProtectScenarios>False</ProtectScenarios> + </WorksheetOptions> + </Worksheet> +</Workbook> diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index bb260aa23080..90f37a89db56 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -78,7 +78,7 @@ const FileFormat ScBootstrapFixture::aFileFormats[] = { { "html" , "calc_HTML_WebQuery", "generic_HTML", HTML_FORMAT_TYPE }, { "123" , "Lotus", "calc_Lotus", LOTUS123_FORMAT_TYPE }, { "dif", "DIF", "calc_DIF", DIF_FORMAT_TYPE }, - { "xml", "MS Excel 2003 XML", "calc_MS_Excel_2003_XML", XLS_XML_FORMAT_TYPE }, + { "xml", "MS Excel 2003 XML Orcus", "calc_MS_Excel_2003_XML", XLS_XML_FORMAT_TYPE }, { "xlsb", "Calc MS Excel 2007 Binary", "MS Excel 2007 Binary", XLSB_XML_FORMAT_TYPE }, { "fods", "OpenDocument Spreadsheet Flat XML", "calc_ODS_FlatXML", FODS_FORMAT_TYPE }, { "gnumeric", "Gnumeric Spreadsheet", "Gnumeric XML", GNUMERIC_FORMAT_TYPE } diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 92c91b37564f..69f1f7735791 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -50,7 +50,7 @@ #define CSV_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN ) #define HTML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN ) #define DIF_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN ) -#define XLS_XML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER) +#define XLS_XML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED) #define XLSB_XML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED) #define FODS_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::OWN | SfxFilterFlags::STARONEFILTER ) #define GNUMERIC_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED ) diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 24b93c5e6a8f..a38396ceb674 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -235,6 +235,8 @@ public: void testUnicodeFileNameGnumeric(); #endif + void testMergedCellsXLSXML(); + CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testBooleanFormatXLSX); CPPUNIT_TEST(testBasicCellContentODS); @@ -356,6 +358,7 @@ public: #ifdef UNX CPPUNIT_TEST(testUnicodeFileNameGnumeric); #endif + CPPUNIT_TEST(testMergedCellsXLSXML); CPPUNIT_TEST_SUITE_END(); @@ -3498,6 +3501,40 @@ void ScFiltersTest::testUnicodeFileNameGnumeric() } #endif +void ScFiltersTest::testMergedCellsXLSXML() +{ + ScDocShellRef xDocSh = loadDoc("merged-cells.", FORMAT_XLS_XML); + CPPUNIT_ASSERT_MESSAGE("Failed to load merged-cells.xml", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + + // B1:C1 is merged. + ScRange aMergedRange(1,0,0); // B1 + rDoc.ExtendTotalMerge(aMergedRange); + CPPUNIT_ASSERT_EQUAL(ScRange(1,0,0,2,0,0), aMergedRange); + + // D1:F1 is merged. + aMergedRange = ScRange(3,0,0); // D1 + rDoc.ExtendTotalMerge(aMergedRange); + CPPUNIT_ASSERT_EQUAL(ScRange(3,0,0,5,0,0), aMergedRange); + + // A2:A3 is merged. + aMergedRange = ScRange(0,1,0); // A2 + rDoc.ExtendTotalMerge(aMergedRange); + CPPUNIT_ASSERT_EQUAL(ScRange(0,1,0,0,2,0), aMergedRange); + + // A4:A6 is merged. + aMergedRange = ScRange(0,3,0); // A4 + rDoc.ExtendTotalMerge(aMergedRange); + CPPUNIT_ASSERT_EQUAL(ScRange(0,3,0,0,5,0), aMergedRange); + + // C3:F6 is merged. + aMergedRange = ScRange(2,2,0); // C3 + rDoc.ExtendTotalMerge(aMergedRange); + CPPUNIT_ASSERT_EQUAL(ScRange(2,2,0,5,5,0), aMergedRange); + + xDocSh->DoClose(); +} + void ScFiltersTest::testCondFormatXLSB() { ScDocShellRef xDocSh = loadDoc("cond_format.", FORMAT_XLSB); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits