summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-04-02 16:10:00 +0200
committerLászló Németh <nemeth@numbertext.org>2019-04-08 15:30:03 +0200
commita3881a66b8ffda4a8a89ecfc4347555e34193665 (patch)
tree403934182fbcb8b39d39ceb9af69e598e885cd1e /chart2
parent69b5da392951fbd655912185434edab94f8ac0af (diff)
tdf#124466 XLSX: fix broken export by removing chart type data redundancy
XLSX import created a redundant series container for data series with the same chart type, when they were attached to a different axis. Modifying the loaded chart by the user, ie. attaching one of its data series to a different axis resulted broken OOXML export later, because based on the new axis, splitDataSeriesByAxis splitted the first or the redundant series container further. Now the import creates only a single series container for the series with the same chart type, preventing potential export problems. Change-Id: If951feaca3cb3b5df7718e9d7bfd59620ef3c4d3 Reviewed-on: https://gerrit.libreoffice.org/70141 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2export.cxx21
-rwxr-xr-xchart2/qa/extras/data/xlsx/add_series_secondary_axis.xlsxbin0 -> 20217 bytes
2 files changed, 21 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 3d537cf2ab90..6c769f0bbe63 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -113,6 +113,7 @@ public:
void testBarChartVaryColorsXLSX();
void testMultipleAxisXLSX();
void testSecondaryAxisXLSX();
+ void testSetSeriesToSecondaryAxisXLSX();
void testAxisTitleRotationXLSX();
void testAxisCrossBetweenXSLX();
void testPieChartDataPointExplosionXLSX();
@@ -206,6 +207,7 @@ public:
CPPUNIT_TEST(testBarChartVaryColorsXLSX);
CPPUNIT_TEST(testMultipleAxisXLSX);
CPPUNIT_TEST(testSecondaryAxisXLSX);
+ CPPUNIT_TEST(testSetSeriesToSecondaryAxisXLSX);
CPPUNIT_TEST(testAxisTitleRotationXLSX);
CPPUNIT_TEST(testAxisCrossBetweenXSLX);
CPPUNIT_TEST(testPieChartDataPointExplosionXLSX);
@@ -1760,6 +1762,25 @@ void Chart2ExportTest::testSecondaryAxisXLSX()
assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", "a");
}
+void Chart2ExportTest::testSetSeriesToSecondaryAxisXLSX()
+{
+ load("/chart2/qa/extras/data/xlsx/", "add_series_secondary_axis.xlsx");
+ Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ // Second series
+ Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xChartDoc, 1);
+ CPPUNIT_ASSERT(xSeries.is());
+
+ Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
+ sal_Int32 AxisIndex = 1;
+ // Attach the second series to the secondary axis. (The third series is already attached.)
+ xPropSet->setPropertyValue("AttachedAxisIndex", uno::Any(AxisIndex));
+
+ xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+ // Check there are only two <lineChart> tag in the XML, one for the primary and one for the secondary axis.
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart", 2);
+}
+
void Chart2ExportTest::testAxisTitleRotationXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/add_series_secondary_axis.xlsx b/chart2/qa/extras/data/xlsx/add_series_secondary_axis.xlsx
new file mode 100755
index 000000000000..03d7a47f6c3d
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/add_series_secondary_axis.xlsx
Binary files differ