summaryrefslogtreecommitdiff
path: root/chart2
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-20 23:24:21 +0200
commit5d542b733aac7901589161425bc8eb809220a79b (patch)
tree96ddfceb798506989eb18c0b7dd7aa1c24c73e70 /chart2
parentcdec7c46c8e231efe1022149cf2eb73cbb3bbede (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> (cherry picked from commit 203eaefb4ac012c36a1ecdd3753e1cb2c5876efc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138529 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2export2.cxx52
-rw-r--r--chart2/qa/extras/data/xlsx/ChartDataTable.xlsxbin0 -> 8142 bytes
2 files changed, 52 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export2.cxx b/chart2/qa/extras/chart2export2.cxx
index 588cbe1d84f2..1ea349af82fe 100644
--- a/chart2/qa/extras/chart2export2.cxx
+++ b/chart2/qa/extras/chart2export2.cxx
@@ -103,6 +103,7 @@ public:
void testNameRangeXLSX();
void testTdf143942();
void testDateCategoriesPPTX();
+ void testDataTableImportExport();
CPPUNIT_TEST_SUITE(Chart2ExportTest2);
CPPUNIT_TEST(testSetSeriesToSecondaryAxisXLSX);
@@ -168,6 +169,7 @@ public:
CPPUNIT_TEST(testNameRangeXLSX);
CPPUNIT_TEST(testTdf143942);
CPPUNIT_TEST(testDateCategoriesPPTX);
+ CPPUNIT_TEST(testDataTableImportExport);
CPPUNIT_TEST_SUITE_END();
};
@@ -1640,6 +1642,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();
diff --git a/chart2/qa/extras/data/xlsx/ChartDataTable.xlsx b/chart2/qa/extras/data/xlsx/ChartDataTable.xlsx
new file mode 100644
index 000000000000..fff4f00aeafa
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/ChartDataTable.xlsx
Binary files differ