[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - chart2/qa include/oox oox/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 2 10:31:18 UTC 2018


 chart2/qa/extras/chart2export.cxx       |   14 ++++++++++++++
 chart2/qa/extras/data/odp/tdf119029.odp |binary
 include/oox/export/chartexport.hxx      |    2 +-
 oox/source/export/chartexport.cxx       |   28 +++++++++++++++++++++-------
 4 files changed, 36 insertions(+), 8 deletions(-)

New commits:
commit 2d3e5db2669d8643e60918c67319b31e65093eb8
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 1 12:52:10 2018 +0300
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Aug 2 12:30:56 2018 +0200

    tdf#119029: also export rotation for data series
    
    Change-Id: I6a9895145e0c54d35bf404f209721a0c718e4446
    Reviewed-on: https://gerrit.libreoffice.org/58401
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 8f90492812d1edac6c91e83b84f3512877dcd552)
    Reviewed-on: https://gerrit.libreoffice.org/58460
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 124dd4735e3a..ffbe040a42dd 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -117,6 +117,7 @@ public:
     void testChartTitlePropertiesGradientFillPPTX();
     void testChartTitlePropertiesBitmapFillPPTX();
     void testTdf116163();
+    void testTdf119029();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(testErrorBarXLSX);
@@ -196,6 +197,7 @@ public:
     CPPUNIT_TEST(testChartTitlePropertiesGradientFillPPTX);
     CPPUNIT_TEST(testChartTitlePropertiesBitmapFillPPTX);
     CPPUNIT_TEST(testTdf116163);
+    CPPUNIT_TEST(testTdf119029);
     CPPUNIT_TEST_SUITE_END();
 
 protected:
@@ -1853,6 +1855,18 @@ void Chart2ExportTest::testTdf116163()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", "-5400000");
 }
 
+void Chart2ExportTest::testTdf119029()
+{
+    load("/chart2/qa/extras/data/odp/", "tdf119029.odp");
+    // Only use "chart", without number, because the number depends on the previous tests
+    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPath(pXmlDoc,
+                "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:txPr/a:bodyPr", "rot",
+                "-5400000");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/odp/tdf119029.odp b/chart2/qa/extras/data/odp/tdf119029.odp
new file mode 100644
index 000000000000..87e4a03c844a
Binary files /dev/null and b/chart2/qa/extras/data/odp/tdf119029.odp differ
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index d6761bdea021..9deb8ff95bf7 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -174,7 +174,7 @@ private:
     void exportSeriesValues(
         const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val );
     void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
-    void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet, bool bAxis = false);
+    void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet);
     void exportDataPoints(
         const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties,
         sal_Int32 nSeriesLength, sal_Int32 eChartType );
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 18d748fca05d..891bb9707e55 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2313,18 +2313,32 @@ void ChartExport::exportShapeProps( const Reference< XPropertySet >& xPropSet )
     pFS->endElement( FSNS( XML_c, XML_spPr ) );
 }
 
-void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet, bool bAxis)
+void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet)
 {
     FSHelperPtr pFS = GetFS();
     pFS->startElement(FSNS(XML_c, XML_txPr), FSEND);
 
     sal_Int32 nRotation = 0;
-    if (bAxis)
+    if (auto xServiceInfo = uno::Reference<lang::XServiceInfo>(xPropSet, uno::UNO_QUERY))
     {
-        double fTextRotation = 0;
-        uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
-        if (aAny.hasValue() && (aAny >>= fTextRotation))
-            nRotation = fTextRotation * -600.0;
+        double fMultiplier = 0;
+        // We have at least two possible units of returned value: degrees (e.g., for data labels),
+        // and 100ths of degree (e.g., for axes labels). The latter is returned as an Any wrapping
+        // a sal_Int32 value (see WrappedTextRotationProperty::convertInnerToOuterValue), while
+        // the former is double. So we could test the contained type to decide which multiplier to
+        // use. But testing the service info should be more robust.
+        if (xServiceInfo->supportsService("com.sun.star.chart.ChartAxis"))
+            fMultiplier = -600.0;
+        else if (xServiceInfo->supportsService("com.sun.star.chart2.DataSeries"))
+            fMultiplier = -60000.0;
+
+        if (fMultiplier)
+        {
+            double fTextRotation = 0;
+            uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
+            if (aAny.hasValue() && (aAny >>= fTextRotation))
+                nRotation = std::round(fTextRotation * fMultiplier);
+        }
     }
 
     if (nRotation)
@@ -2738,7 +2752,7 @@ void ChartExport::_exportAxis(
     // shape properties
     exportShapeProps( xAxisProp );
 
-    exportTextProps(xAxisProp, true);
+    exportTextProps(xAxisProp);
 
     pFS->singleElement( FSNS( XML_c, XML_crossAx ),
             XML_val, I32S( rAxisIdPair.nCrossAx ),


More information about the Libreoffice-commits mailing list