diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2018-02-16 15:54:15 -0500 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2018-02-16 23:25:42 +0100 |
commit | 028d4f9025c0d285bc5acdd0250b9e8120156925 (patch) | |
tree | 329635cd8ffecdf3f761a80ce0aa62196c98730b /sc/qa | |
parent | 40530d0ce4883ac999d53f86c0483e1a47c9fd74 (diff) |
Add a test case for importing cell background colors...
... from an Excel 2003 XML file via orcus.
Change-Id: I58783acf80de7935e98673b982d8cfb0d4f085ce
Reviewed-on: https://gerrit.libreoffice.org/49880
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/xml/background-color-standard.xml | 150 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 49 |
2 files changed, 199 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xml/background-color-standard.xml b/sc/qa/unit/data/xml/background-color-standard.xml new file mode 100644 index 000000000000..7ccfef8a2e23 --- /dev/null +++ b/sc/qa/unit/data/xml/background-color-standard.xml @@ -0,0 +1,150 @@ +<?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-10-21T23:43:59Z</Created> + <LastSaved>2013-10-21T23:51:49Z</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>9270</WindowHeight> + <WindowWidth>24915</WindowWidth> + <WindowTopX>480</WindowTopX> + <WindowTopY>120</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> + <Style ss:ID="s16"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000" + ss:Bold="1"/> + </Style> + <Style ss:ID="s17"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#C00000" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s18"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#FF0000" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s19"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#FFC000" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s20"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#FFFF00" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s21"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#92D050" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s22"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#00B050" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s23"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#00B0F0" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s24"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#0070C0" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s25"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#002060" ss:Pattern="Solid"/> + </Style> + <Style ss:ID="s26"> + <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#FFFFFF" + ss:Bold="1"/> + <Interior ss:Color="#7030A0" ss:Pattern="Solid"/> + </Style> + </Styles> + <Worksheet ss:Name="BackgroundColor"> + <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="11" x:FullColumns="1" + x:FullRows="1" ss:DefaultRowHeight="15"> + <Column ss:AutoFitWidth="0" ss:Width="222.75"/> + <Row> + <Cell ss:StyleID="s16"><Data ss:Type="String">Background Color</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s17"><Data ss:Type="String">Dark Red</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s18"><Data ss:Type="String">Red</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s19"><Data ss:Type="String">Orange</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s20"><Data ss:Type="String">Yellow</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s21"><Data ss:Type="String">Light Green</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s22"><Data ss:Type="String">Green</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s23"><Data ss:Type="String">Light Blue</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s24"><Data ss:Type="String">Blue</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s25"><Data ss:Type="String">Dark Blue</Data></Cell> + </Row> + <Row> + <Cell ss:StyleID="s26"><Data ss:Type="String">Purple</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/> + <HorizontalResolution>600</HorizontalResolution> + <VerticalResolution>600</VerticalResolution> + </Print> + <Selected/> + <Panes> + <Pane> + <Number>3</Number> + <ActiveRow>12</ActiveRow> + </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 a38396ceb674..5eb5303b397f 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -236,6 +236,7 @@ public: #endif void testMergedCellsXLSXML(); + void testBackgroundColorStandardXLSXML(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testBooleanFormatXLSX); @@ -359,6 +360,7 @@ public: CPPUNIT_TEST(testUnicodeFileNameGnumeric); #endif CPPUNIT_TEST(testMergedCellsXLSXML); + CPPUNIT_TEST(testBackgroundColorStandardXLSXML); CPPUNIT_TEST_SUITE_END(); @@ -3535,6 +3537,53 @@ void ScFiltersTest::testMergedCellsXLSXML() xDocSh->DoClose(); } +void ScFiltersTest::testBackgroundColorStandardXLSXML() +{ + ScDocShellRef xDocSh = loadDoc("background-color-standard.", FORMAT_XLS_XML); + CPPUNIT_ASSERT_MESSAGE("Failed to load background-color-standard.xml", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + + struct Check + { + OUString aCellValue; + Color aFontColor; + Color aBgColor; + }; + + const std::vector<Check> aChecks = + { + { OUString("Background Color"), Color(COL_BLACK), Color(COL_TRANSPARENT) }, + { OUString("Dark Red"), Color(COL_WHITE), Color(192, 0, 0) }, + { OUString("Red"), Color(COL_WHITE), Color(255, 0, 0) }, + { OUString("Orange"), Color(COL_WHITE), Color(255, 192, 0) }, + { OUString("Yellow"), Color(COL_WHITE), Color(255, 255, 0) }, + { OUString("Light Green"), Color(COL_WHITE), Color(146, 208, 80) }, + { OUString("Green"), Color(COL_WHITE), Color( 0, 176, 80) }, + { OUString("Light Blue"), Color(COL_WHITE), Color( 0, 176, 240) }, + { OUString("Blue"), Color(COL_WHITE), Color( 0, 112, 192) }, + { OUString("Dark Blue"), Color(COL_WHITE), Color( 0, 32, 96) }, + { OUString("Purple"), Color(COL_WHITE), Color(112, 48, 160) }, + }; + + for (size_t nRow = 0; nRow < aChecks.size(); ++nRow) + { + ScAddress aPos(0, nRow, 0); + OUString aStr = rDoc.GetString(aPos); + CPPUNIT_ASSERT_EQUAL(aChecks[nRow].aCellValue, aStr); + + const ScPatternAttr* pPat = rDoc.GetPattern(aPos); + CPPUNIT_ASSERT(pPat); + + const SvxColorItem& rColor = pPat->GetItem(ATTR_FONT_COLOR); + CPPUNIT_ASSERT_EQUAL(aChecks[nRow].aFontColor, rColor.GetValue()); + + const SvxBrushItem& rBgColor = pPat->GetItem(ATTR_BACKGROUND); + CPPUNIT_ASSERT_EQUAL(aChecks[nRow].aBgColor, rBgColor.GetColor()); + } + + xDocSh->DoClose(); +} + void ScFiltersTest::testCondFormatXLSB() { ScDocShellRef xDocSh = loadDoc("cond_format.", FORMAT_XLSB); |