summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-10-17 12:37:04 +0200
committerLászló Németh <nemeth@numbertext.org>2019-10-22 14:33:46 +0200
commit9ff954d5f780cae5df6942e97b713cfc19449145 (patch)
tree68f1de08936b6e2cd138f38dc33fb3d535e14213 /chart2
parent6fff5e07f63213b711d5ddd25e47e9593e306643 (diff)
tdf#127908 tdf#128193 Chart OOXML: Fix Custom Y axis title position
Import part: set the anchor position to the TOP_LEFT corner of the rectangle during the import, if the textbox is rotated with 90 or 270 degree. Because the OOXML files always contains the TOP_LEFT coordinates of a textbox, even if they are rotated. Note: Unfortunatelly we do not know the shape size, so this fix cannot handle rotations different than 0, 90 or 270 degrees. Export part: export the top left corner coordinates of axis title shape as the OOXML Standerd requires. Change-Id: Id0875d65884f6bfef8726135a7c03418d2ce3f23 Reviewed-on: https://gerrit.libreoffice.org/80939 Tested-by: Jenkins 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.cxx25
-rw-r--r--chart2/qa/extras/chart2import.cxx3
2 files changed, 26 insertions, 2 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 8a0705f7d140..694ba5501043 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -123,6 +123,7 @@ public:
void testCrossBetweenXLSX();
void testCrossBetweenODS();
void testAxisTitleRotationXLSX();
+ void testAxisTitlePositionDOCX();
void testAxisCrossBetweenXSLX();
void testPieChartDataPointExplosionXLSX();
void testCustomDataLabel();
@@ -228,6 +229,7 @@ public:
CPPUNIT_TEST(testCrossBetweenXLSX);
CPPUNIT_TEST(testCrossBetweenODS);
CPPUNIT_TEST(testAxisTitleRotationXLSX);
+ CPPUNIT_TEST(testAxisTitlePositionDOCX);
CPPUNIT_TEST(testAxisCrossBetweenXSLX);
CPPUNIT_TEST(testPieChartDataPointExplosionXLSX);
CPPUNIT_TEST(testCustomDataLabel);
@@ -1932,6 +1934,29 @@ void Chart2ExportTest::testAxisTitleRotationXLSX()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:bodyPr", "rot", "0");
}
+void Chart2ExportTest::testAxisTitlePositionDOCX()
+{
+ load("/chart2/qa/extras/data/docx/", "testAxisTitlePosition.docx");
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // test X Axis title position
+ OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:layout/c:manualLayout/c:x", "val");
+ double nX = aXVal.toDouble();
+ CPPUNIT_ASSERT(nX > 0.698208 && nX < 0.698209);
+ OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:layout/c:manualLayout/c:y", "val");
+ double nY = aYVal.toDouble();
+ CPPUNIT_ASSERT(nY > 0.805152 && nY < 0.805153);
+
+ // test Y Axis title position
+ aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:layout/c:manualLayout/c:x", "val");
+ nX = aXVal.toDouble();
+ CPPUNIT_ASSERT(nX > 0.025395 && nX < 0.025396);
+ aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:layout/c:manualLayout/c:y", "val");
+ nY = aYVal.toDouble();
+ CPPUNIT_ASSERT(nY > 0.384407 && nY < 0.384408);
+}
+
void Chart2ExportTest::testAxisCrossBetweenXSLX()
{
load("/chart2/qa/extras/data/odt/", "axis-position.odt");
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index d0fcb34faafd..ab1233b13110 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -1539,8 +1539,7 @@ void Chart2ImportTest::testAxisTitlePositionDOCX()
aPos = xAxisTitle->getPosition();
CPPUNIT_ASSERT_EQUAL(sal_Int32(387), static_cast<sal_Int32>(aPos.X));
- // y coordinate is still wrong because of another older bug!
- /*CPPUNIT_ASSERT_EQUAL(sal_Int32(1535), static_cast<sal_Int32>(aPos.Y));*/
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(6378), static_cast<sal_Int32>(aPos.Y));
}
void Chart2ImportTest::testCombinedChartAttachedAxisXLSX()