File bsc1095639.patch of Package libreoffice.openSUSE_Leap_42.3_Update

From cd4c95b40783d501ed3b96ff1daf3cec0e6ab2b0 Mon Sep 17 00:00:00 2001
From: Mike Kaganski <mike.kaganski@collabora.com>
Date: Wed, 1 Aug 2018 12:52:10 +0300
Subject: [PATCH] tdf#119029: also export rotation for data series

Reviewed-on: https://gerrit.libreoffice.org/58401
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 8f90492812d1edac6c91e83b84f3512877dcd552)

Change-Id: I6a9895145e0c54d35bf404f209721a0c718e4446
---
 chart2/qa/extras/chart2export.cxx       |  14 ++++++++++++++
 chart2/qa/extras/data/odp/tdf119029.odp | Bin 0 -> 13643 bytes
 include/oox/export/chartexport.hxx      |   2 +-
 oox/source/export/chartexport.cxx       |  28 +++++++++++++++++++++-------
 4 files changed, 36 insertions(+), 8 deletions(-)
 create mode 100644 chart2/qa/extras/data/odp/tdf119029.odp

diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index 9bbf1d3e16f9..e1ae1f4f0a9b 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -172,7 +172,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 bd33471c9dad..e127ee8480b0 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2282,18 +2282,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)
@@ -2707,7 +2721,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 ),
--
2.13.7

openSUSE Build Service is sponsored by