diff options
author | Kurt Nordback <kurt.nordback@protonmail.com> | 2024-07-17 17:07:05 -0600 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-11-26 01:34:07 +0100 |
commit | b10d331c1c9801adbf6d014d9348bb0a4dad3d2c (patch) | |
tree | 7fa23c258510338aedc321294e6962555f2f9265 /chart2/qa | |
parent | 7c7e7da1538c1ed0c65821e18233ec9dcdc6cd2b (diff) |
tdf#161800 - I/O of '# of values in second plot' parameter not supported
Add support for input and output of 'split position' parameter (number of entries
in second plot) for of-pie charts. In OOXML this uses the supported split-pos
tag. For ODF I added an extension in loext namespace for this parameter.
This commit also includes simple tests for the I/O functionality in OOXML and
ODF.
Change-Id: I00ff59db721867fa836eb99b6677350040d005dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170666
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2/qa')
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 65 | ||||
-rw-r--r-- | chart2/qa/extras/data/ods/tdf161800_barOfPie_split_pos.ods | bin | 0 -> 15011 bytes | |||
-rw-r--r-- | chart2/qa/extras/data/ods/tdf161800_pieOfPie_split_pos.ods | bin | 0 -> 15964 bytes | |||
-rw-r--r-- | chart2/qa/extras/data/xlsx/barOfPieChart2.xlsx | bin | 0 -> 8130 bytes | |||
-rw-r--r-- | chart2/qa/extras/data/xlsx/pieOfPieChart2.xlsx | bin | 0 -> 8036 bytes |
5 files changed, 65 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index c57c238ef3b0..3f37794e1d10 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -546,6 +546,28 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testBarOfPieChart) assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:ofPieType[1]", "val", u"bar"); } +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testPieOfPieSplitPos) +{ + loadFromFile(u"xlsx/pieOfPieChart2.xlsx"); + save(u"Calc Office Open XML"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"xl/charts/chart1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:splitPos[1]", "val", u"4"); +} + +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testBarOfPieSplitPos) +{ + loadFromFile(u"xlsx/barOfPieChart2.xlsx"); + save(u"Calc Office Open XML"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"xl/charts/chart1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:splitPos[1]", "val", u"5"); +} + CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testDisplayUnits) { loadFromFile(u"docx/DisplayUnits.docx"); @@ -1133,6 +1155,49 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf50934_pieOfPie) CPPUNIT_ASSERT_EQUAL(chart2::PieChartSubType_PIE, subPieType); } +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf161800_barOfPie_split_pos) +{ + loadFromFile(u"ods/tdf161800_barOfPie_split_pos.ods"); + saveAndReload(u"calc8"_ustr); + + uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0 ); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 ); + CPPUNIT_ASSERT(xChartType.is()); + + // Verify that it saves and loads with the correct split position + Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW ); + uno::Any aAny = xPropSet->getPropertyValue(u"SplitPos"_ustr); + CPPUNIT_ASSERT(aAny.hasValue()); + double nSplitPos; + aAny >>= nSplitPos; + CPPUNIT_ASSERT_EQUAL(4.0, nSplitPos); +} + +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf161800_pieOfPie_split_pos) +{ + loadFromFile(u"ods/tdf161800_pieOfPie_split_pos.ods"); + saveAndReload(u"calc8"_ustr); + + uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0 ); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 ); + CPPUNIT_ASSERT(xChartType.is()); + + CPPUNIT_ASSERT_EQUAL(u"com.sun.star.chart2.PieChartType"_ustr, + xChartType->getChartType()); + + // Verify that it saves and loads with the correct split position + Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW ); + uno::Any aAny = xPropSet->getPropertyValue(u"SplitPos"_ustr); + CPPUNIT_ASSERT(aAny.hasValue()); + double nSplitPos; + aAny >>= nSplitPos; + CPPUNIT_ASSERT_EQUAL(3.0, nSplitPos); +} + CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testChartCrash) { loadFromFile(u"docx/FDO75975.docx"); diff --git a/chart2/qa/extras/data/ods/tdf161800_barOfPie_split_pos.ods b/chart2/qa/extras/data/ods/tdf161800_barOfPie_split_pos.ods Binary files differnew file mode 100644 index 000000000000..a87941bfa22d --- /dev/null +++ b/chart2/qa/extras/data/ods/tdf161800_barOfPie_split_pos.ods diff --git a/chart2/qa/extras/data/ods/tdf161800_pieOfPie_split_pos.ods b/chart2/qa/extras/data/ods/tdf161800_pieOfPie_split_pos.ods Binary files differnew file mode 100644 index 000000000000..9a08628a91e7 --- /dev/null +++ b/chart2/qa/extras/data/ods/tdf161800_pieOfPie_split_pos.ods diff --git a/chart2/qa/extras/data/xlsx/barOfPieChart2.xlsx b/chart2/qa/extras/data/xlsx/barOfPieChart2.xlsx Binary files differnew file mode 100644 index 000000000000..be24cd293915 --- /dev/null +++ b/chart2/qa/extras/data/xlsx/barOfPieChart2.xlsx diff --git a/chart2/qa/extras/data/xlsx/pieOfPieChart2.xlsx b/chart2/qa/extras/data/xlsx/pieOfPieChart2.xlsx Binary files differnew file mode 100644 index 000000000000..c80f0169cc89 --- /dev/null +++ b/chart2/qa/extras/data/xlsx/pieOfPieChart2.xlsx |