chart2/qa/extras/chart2export.cxx | 12 ++++++++++++ chart2/qa/extras/data/xlsx/xAxisLabelsRotation.xlsx |binary oox/source/export/chartexport.cxx | 14 +++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-)
New commits: commit 527772d8dfcedad56b11b5b13540ec1defa464e5 Author: Balazs Varga <balazs.varga...@gmail.com> AuthorDate: Sat Dec 15 10:06:03 2018 +0100 Commit: Bartosz Kosiorek <gan...@poczta.onet.pl> CommitDate: Tue Dec 18 16:53:24 2018 +0100 tdf#122090 Chart: Fix OOXML export of X axis labels rotation The MS Office UI allows values only in range of [-90,90]. Because of this, we should reflect the angle if the Textrotation is between 90 and 270 degree. Also we have to recalculated the the Textrotation between 270 and 360 degree, because the OOXML counts clockwise. Change-Id: I2fbd53d93ab2e8ea4e26840fd056de20b337daa3 Reviewed-on: https://gerrit.libreoffice.org/65194 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl> diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 7ed7e6afaee9..5bf1e730f93c 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -120,6 +120,7 @@ public: void testChartTitlePropertiesColorFillPPTX(); void testChartTitlePropertiesGradientFillPPTX(); void testChartTitlePropertiesBitmapFillPPTX(); + void testxAxisLabelsRotation(); void testTdf116163(); void testTdf119029(); void testTdf108022(); @@ -206,6 +207,7 @@ public: CPPUNIT_TEST(testChartTitlePropertiesColorFillPPTX); CPPUNIT_TEST(testChartTitlePropertiesGradientFillPPTX); CPPUNIT_TEST(testChartTitlePropertiesBitmapFillPPTX); + CPPUNIT_TEST(testxAxisLabelsRotation); CPPUNIT_TEST(testTdf116163); CPPUNIT_TEST(testTdf119029); CPPUNIT_TEST(testTdf108022); @@ -1920,6 +1922,16 @@ void Chart2ExportTest::testChartTitlePropertiesBitmapFillPPTX() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); } +void Chart2ExportTest::testxAxisLabelsRotation() +{ + load ("/chart2/qa/extras/data/xlsx/", "xAxisLabelsRotation.xlsx"); + xmlDocPtr pXmlDoc1 = parseExport("xl/charts/chart","Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc1); + + // Chart1 xAxis labels should be 45 degree + assertXPath(pXmlDoc1, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", "2700000"); +} + void Chart2ExportTest::testTdf116163() { load("/chart2/qa/extras/data/pptx/", "tdf116163.pptx"); diff --git a/chart2/qa/extras/data/xlsx/xAxisLabelsRotation.xlsx b/chart2/qa/extras/data/xlsx/xAxisLabelsRotation.xlsx new file mode 100755 index 000000000000..cf511dfaf2d7 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/xAxisLabelsRotation.xlsx differ diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index ce3c6984ad40..00b631688b14 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -2366,10 +2366,22 @@ void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet) if (fMultiplier) { - double fTextRotation = 0; + double fTextRotation = 0.0; uno::Any aAny = xPropSet->getPropertyValue("TextRotation"); if (aAny.hasValue() && (aAny >>= fTextRotation)) + { + // The MS Office UI allows values only in range of [-90,90]. + if (fTextRotation > 9000.0 && fTextRotation < 27000.0) + { + // Reflect the angle if the value is between 90° and 270° + fTextRotation -= 18000.0; + } + else if (fTextRotation >=27000.0) + { + fTextRotation -= 36000.0; + } nRotation = std::round(fTextRotation * fMultiplier); + } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits