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 6991784d9759ebfe0686f96a242d091799f81012 Author: Balazs Varga <[email protected]> AuthorDate: Sat Dec 15 10:06:03 2018 +0100 Commit: Thorsten Behrens <[email protected]> CommitDate: Tue Dec 18 22:41:25 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 <[email protected]> (cherry picked from commit 527772d8dfcedad56b11b5b13540ec1defa464e5) Reviewed-on: https://gerrit.libreoffice.org/65351 Reviewed-by: Balazs Varga <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index b07e98661574..d39a6829bd9f 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(); @@ -204,6 +205,7 @@ public: CPPUNIT_TEST(testChartTitlePropertiesColorFillPPTX); CPPUNIT_TEST(testChartTitlePropertiesGradientFillPPTX); CPPUNIT_TEST(testChartTitlePropertiesBitmapFillPPTX); + CPPUNIT_TEST(testxAxisLabelsRotation); CPPUNIT_TEST(testTdf116163); CPPUNIT_TEST(testTdf119029); CPPUNIT_TEST_SUITE_END(); @@ -1916,6 +1918,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 08b296f57cb6..706f6c60265f 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 [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
