summaryrefslogtreecommitdiff
path: root/chart2/qa/extras/chart2export2.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-07-29 15:57:42 +0200
committerTomaž Vajngerl <quikee@gmail.com>2022-08-15 13:08:17 +0200
commit203eaefb4ac012c36a1ecdd3753e1cb2c5876efc (patch)
treebec856e355c47cf7bf528865bcfa0232d28a16ee /chart2/qa/extras/chart2export2.cxx
parent5861af0da5179689870d5b4f5ff56a5ea0a79901 (diff)
xmloff: import and export for the chart data table
This change adds import and export code for the the chart's data table properties to the ODF format for chart documents. The data table properties are exported to a new element "data-table", which then references a auto style with all the properties of a data table + new data table specific properties: HBorder, VBorder, Outline, Keys which are mapped to "show-horizontal-border", "show-vertical-border", "show-outline" and "show-keys" chart attributes. Also adds a test for the import and export: imports xlsx -> exports to ods -> imports ods Change-Id: Id45d9369fd619959e4d6eba7ca51c8ddce9c8f56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138260 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2/qa/extras/chart2export2.cxx')
-rw-r--r--chart2/qa/extras/chart2export2.cxx52
1 files changed, 52 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export2.cxx b/chart2/qa/extras/chart2export2.cxx
index be2902cbb15c..b9b77c0bd112 100644
--- a/chart2/qa/extras/chart2export2.cxx
+++ b/chart2/qa/extras/chart2export2.cxx
@@ -93,6 +93,7 @@ public:
void testNameRangeXLSX();
void testTdf143942();
void testDateCategoriesPPTX();
+ void testDataTableImportExport();
CPPUNIT_TEST_SUITE(Chart2ExportTest2);
CPPUNIT_TEST(testSetSeriesToSecondaryAxisXLSX);
@@ -158,6 +159,7 @@ public:
CPPUNIT_TEST(testNameRangeXLSX);
CPPUNIT_TEST(testTdf143942);
CPPUNIT_TEST(testDateCategoriesPPTX);
+ CPPUNIT_TEST(testDataTableImportExport);
CPPUNIT_TEST_SUITE_END();
};
@@ -1630,6 +1632,56 @@ void Chart2ExportTest2::testDateCategoriesPPTX()
}
}
+void Chart2ExportTest2::testDataTableImportExport()
+{
+ load(u"/chart2/qa/extras/data/xlsx/", u"ChartDataTable.xlsx");
+ {
+ uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+ auto xDiagram = xChartDoc->getFirstDiagram();
+ CPPUNIT_ASSERT(xDiagram.is());
+ auto xDataTable = xDiagram->getDataTable();
+ CPPUNIT_ASSERT(xDataTable.is());
+ uno::Reference<beans::XPropertySet> xPropertySet(xDataTable, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xPropertySet.is());
+ bool bHBorder;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("HBorder") >>= bHBorder);
+ CPPUNIT_ASSERT_EQUAL(true, bHBorder);
+ bool bVBorder;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("VBorder") >>= bVBorder);
+ CPPUNIT_ASSERT_EQUAL(true, bVBorder);
+ bool bOutline;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Outline") >>= bOutline);
+ CPPUNIT_ASSERT_EQUAL(false, bOutline);
+ bool bKeys;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Keys") >>= bKeys);
+ CPPUNIT_ASSERT_EQUAL(false, bKeys);
+ }
+ reload("calc8");
+ {
+ uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+ auto xDiagram = xChartDoc->getFirstDiagram();
+ CPPUNIT_ASSERT(xDiagram.is());
+ auto xDataTable = xDiagram->getDataTable();
+ CPPUNIT_ASSERT(xDataTable.is());
+ uno::Reference<beans::XPropertySet> xPropertySet(xDataTable, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xPropertySet.is());
+ bool bHBorder;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("HBorder") >>= bHBorder);
+ CPPUNIT_ASSERT_EQUAL(true, bHBorder);
+ bool bVBorder;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("VBorder") >>= bVBorder);
+ CPPUNIT_ASSERT_EQUAL(true, bVBorder);
+ bool bOutline;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Outline") >>= bOutline);
+ CPPUNIT_ASSERT_EQUAL(false, bOutline);
+ bool bKeys;
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Keys") >>= bKeys);
+ CPPUNIT_ASSERT_EQUAL(false, bKeys);
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT();