summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2018-02-19 19:35:20 -0500
committerKohei Yoshida <libreoffice@kohei.us>2018-02-20 12:48:37 +0100
commit55cdba99f695017c8f2e30eb561e2695a67042ae (patch)
tree486a2705e951d40589fc8a29dfecc2a6ffc159ed /sc
parent3be02487f09720061f5efe7f309401795c380ab9 (diff)
Add another test case for Excel 2003 XML import.
This one is for importing border directions. Change-Id: I92666c30b629109a1061b7ae1fad31841850d34b Reviewed-on: https://gerrit.libreoffice.org/50021 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/border-directions.xml121
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx92
2 files changed, 213 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xml/border-directions.xml b/sc/qa/unit/data/xml/border-directions.xml
new file mode 100644
index 000000000000..77be73b91eb6
--- /dev/null
+++ b/sc/qa/unit/data/xml/border-directions.xml
@@ -0,0 +1,121 @@
+<?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-01-14T17:03:52Z</Created>
+ <LastSaved>2018-01-25T01:00:20Z</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>7680</WindowHeight>
+ <WindowWidth>20490</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>
+ <Style ss:ID="s16">
+ <Borders>
+ <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
+ </Borders>
+ </Style>
+ <Style ss:ID="s17">
+ <Borders>
+ <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
+ </Borders>
+ </Style>
+ <Style ss:ID="s18">
+ <Borders>
+ <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
+ </Borders>
+ </Style>
+ <Style ss:ID="s19">
+ <Borders>
+ <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
+ </Borders>
+ </Style>
+ <Style ss:ID="s20">
+ <Borders>
+ <Border ss:Position="DiagonalLeft" ss:LineStyle="Continuous" ss:Weight="1"/>
+ </Borders>
+ </Style>
+ <Style ss:ID="s21">
+ <Borders>
+ <Border ss:Position="DiagonalRight" ss:LineStyle="Continuous" ss:Weight="1"/>
+ </Borders>
+ </Style>
+ <Style ss:ID="s22">
+ <Borders>
+ <Border ss:Position="DiagonalLeft" ss:LineStyle="Continuous" ss:Weight="1"/>
+ <Border ss:Position="DiagonalRight" ss:LineStyle="Continuous" ss:Weight="1"/>
+ </Borders>
+ </Style>
+ </Styles>
+ <Worksheet ss:Name="Directions">
+ <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="14" x:FullColumns="1"
+ x:FullRows="1" ss:DefaultRowHeight="15">
+ <Column ss:Index="2" ss:AutoFitWidth="0" ss:Width="92.25"/>
+ <Row ss:Index="2">
+ <Cell ss:Index="2" ss:StyleID="s16"><Data ss:Type="String">top</Data></Cell>
+ </Row>
+ <Row ss:Index="4">
+ <Cell ss:Index="2" ss:StyleID="s17"><Data ss:Type="String">left</Data></Cell>
+ </Row>
+ <Row ss:Index="6">
+ <Cell ss:Index="2" ss:StyleID="s18"><Data ss:Type="String">right</Data></Cell>
+ </Row>
+ <Row ss:Index="8">
+ <Cell ss:Index="2" ss:StyleID="s19"><Data ss:Type="String">bottom</Data></Cell>
+ </Row>
+ <Row ss:Index="10">
+ <Cell ss:Index="2" ss:StyleID="s20"><Data ss:Type="String">tl to br</Data></Cell>
+ </Row>
+ <Row ss:Index="12">
+ <Cell ss:Index="2" ss:StyleID="s21"><Data ss:Type="String">tr to bl</Data></Cell>
+ </Row>
+ <Row ss:Index="14">
+ <Cell ss:Index="2" ss:StyleID="s22"><Data ss:Type="String">cross diagonal</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>13</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 6a8c051cf15e..003ad24e2c94 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -241,6 +241,7 @@ public:
void testBackgroundColorStandardXLSXML();
void testNamedExpressionsXLSXML();
void testEmptyRowsXLSXML();
+ void testBorderDirectionsXLSXML();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -367,6 +368,7 @@ public:
CPPUNIT_TEST(testBackgroundColorStandardXLSXML);
CPPUNIT_TEST(testNamedExpressionsXLSXML);
CPPUNIT_TEST(testEmptyRowsXLSXML);
+ CPPUNIT_TEST(testBorderDirectionsXLSXML);
CPPUNIT_TEST(testCondFormatFormulaListenerXLSX);
CPPUNIT_TEST_SUITE_END();
@@ -3681,6 +3683,96 @@ void ScFiltersTest::testEmptyRowsXLSXML()
xDocSh->DoClose();
}
+void ScFiltersTest::testBorderDirectionsXLSXML()
+{
+ ScDocShellRef xDocSh = loadDoc("border-directions.", FORMAT_XLS_XML);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load border-directions.xml", xDocSh.is());
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ struct Check
+ {
+ ScAddress aPos;
+ bool bTop;
+ bool bBottom;
+ bool bLeft;
+ bool bRight;
+ bool bTLtoBR;
+ bool bTRtoBL;
+ };
+
+ std::vector<Check> aChecks = {
+ { { 1, 1, 0 }, true, false, false, false, false, false }, // B2 - top
+ { { 1, 3, 0 }, false, false, true, false, false, false }, // B4 - left
+ { { 1, 5, 0 }, false, false, false, true, false, false }, // B6 - right
+ { { 1, 7, 0 }, false, true, false, false, false, false }, // B8 - bottom
+ { { 1, 9, 0 }, false, false, false, false, true, false }, // B10 - tl to br
+ { { 1, 11, 0 }, false, false, false, false, false, true }, // B12 - tr to bl
+ { { 1, 13, 0 }, false, false, false, false, true, true }, // B14 - cross-diagonal
+ };
+
+ auto funcCheckBorder = []( bool bHasBorder, const editeng::SvxBorderLine* pLine ) -> bool
+ {
+ if (bHasBorder)
+ {
+ if (!pLine)
+ {
+ std::cout << "Border was expected, but not found!" << std::endl;
+ return false;
+ }
+
+ if (SvxBorderLineStyle::SOLID != pLine->GetBorderLineStyle())
+ {
+ std::cout << "Border type was expected to be of SOLID, but is not." << std::endl;
+ return false;
+ }
+
+ if (Color(COL_BLACK) != pLine->GetColor())
+ {
+ std::cout << "Border color was expected to be black, but is not." << std::endl;
+ return false;
+ }
+ }
+ else
+ {
+ if (pLine)
+ {
+ std::cout << "Border was not expected, but is found!" << std::endl;
+ return false;
+ }
+ }
+
+ return true;
+ };
+
+ for (const Check& c : aChecks)
+ {
+ const ScPatternAttr* pPat = rDoc.GetPattern(c.aPos);
+ CPPUNIT_ASSERT(pPat);
+
+ const SvxBoxItem& rBox = pPat->GetItem(ATTR_BORDER);
+
+ const editeng::SvxBorderLine* pLine = rBox.GetTop();
+ CPPUNIT_ASSERT(funcCheckBorder(c.bTop, pLine));
+
+ pLine = rBox.GetBottom();
+ CPPUNIT_ASSERT(funcCheckBorder(c.bBottom, pLine));
+
+ pLine = rBox.GetLeft();
+ CPPUNIT_ASSERT(funcCheckBorder(c.bLeft, pLine));
+
+ pLine = rBox.GetRight();
+ CPPUNIT_ASSERT(funcCheckBorder(c.bRight, pLine));
+
+ pLine = pPat->GetItem(ATTR_BORDER_TLBR).GetLine();
+ CPPUNIT_ASSERT(funcCheckBorder(c.bTLtoBR, pLine));
+
+ pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine();
+ CPPUNIT_ASSERT(funcCheckBorder(c.bTRtoBL, pLine));
+ }
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testCondFormatXLSB()
{
ScDocShellRef xDocSh = loadDoc("cond_format.", FORMAT_XLSB);