summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-02-25 12:48:08 +0100
committerLászló Németh <nemeth@numbertext.org>2020-02-27 16:56:23 +0100
commit2a00d51150d410110602c953b3c3895debfcaa98 (patch)
tree02f40d51e016405cd763e0e4f2cf3d67295629fb /chart2
parent74e3c95b9b628a0b326790b62b4e378a12d02997 (diff)
tdf#108110 ODF chart: import/export of custom position of data point labels
using new attributes loext:custom-label-pos-x and loext:custom-label-pos-y of chart:data-point. This fixes also *import* of DOCX documents with embedded charts, related to the ODF usage in the background. Follow-up of commit 4223ff2be69f03e571464b0b09ad0d278918631b (tdf#48436 Chart: add CustomLabelPosition UNO API property) Change-Id: I985ce27cb6ce988948258d9eab0de13d01c72b97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89446 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2export.cxx40
-rw-r--r--chart2/qa/extras/data/docx/testTdf108110.docxbin0 -> 25892 bytes
2 files changed, 29 insertions, 11 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 469e25618b5f..90b20d363b80 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -2180,18 +2180,36 @@ void Chart2ExportTest::testCustomDataLabel()
void Chart2ExportTest::testCustomPositionofDataLabel()
{
load("/chart2/qa/extras/data/xlsx/", "testCustomPosDataLabels.xlsx");
- xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
- CPPUNIT_ASSERT(pXmlDoc);
-
- // test custom position of data label
- assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", "2");
- OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:layout/c:manualLayout/c:x", "val");
- double nX = aXVal.toDouble();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.11027682973075476, nX, 1e-7);
+ {
+ xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // test custom position of data label (xlsx)
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", "2");
+ OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:layout/c:manualLayout/c:x", "val");
+ double nX = aXVal.toDouble();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.11027682973075476, nX, 1e-7);
+
+ OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:layout/c:manualLayout/c:y", "val");
+ double nY = aYVal.toDouble();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.0742140311063737, nY, 1e-7);
+ }
- OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:layout/c:manualLayout/c:y", "val");
- double nY = aYVal.toDouble();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.0742140311063737, nY, 1e-7);
+ load("/chart2/qa/extras/data/docx/", "testTdf108110.docx");
+ {
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // test custom position of data label (docx)
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[2]/c:idx", "val", "2");
+ OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[2]/c:layout/c:manualLayout/c:x", "val");
+ double nX = aXVal.toDouble();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0227256488772236, nX, 1e-7);
+
+ OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[2]/c:layout/c:manualLayout/c:y", "val");
+ double nY = aYVal.toDouble();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.172648731408574, nY, 1e-7);
+ }
}
void Chart2ExportTest::testCustomDataLabelMultipleSeries()
diff --git a/chart2/qa/extras/data/docx/testTdf108110.docx b/chart2/qa/extras/data/docx/testTdf108110.docx
new file mode 100644
index 000000000000..769360c15203
--- /dev/null
+++ b/chart2/qa/extras/data/docx/testTdf108110.docx
Binary files differ