oox/source/export/chartexport.cxx |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 8758fa5ab4b8c99ab15334653c58651c6edd2e35
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Nov 5 13:35:49 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Nov 6 06:59:31 2025 +0100

    mso-test: fix export of rotX
    
    This is using the test document from ooo72994-7.xls.
    
    Fix the export of the rotX value for 3D charts.
    We cannot easily map the value here, all we can do is clamp it.
    
    Change-Id: I1beba485c66babfbe03830c79b8b8c72a7560bfd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193456
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 30dda3e7792e..22dd456bb801 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -5747,17 +5747,24 @@ void ChartExport::exportView3D()
     {
         sal_Int32 nRotationX = 0;
         mAny >>= nRotationX;
-        if( nRotationX < 0 )
+        if(eChartType == chart::TYPEID_PIE)
         {
-            if(eChartType == chart::TYPEID_PIE)
-            {
             /* In OOXML we get value in 0..90 range for pie chart X rotation , 
whereas we expect it to be in -90..90 range,
                so we convert that during import. It is modified in 
View3DConverter::convertFromModel()
                here we convert it back to 0..90 as we received in import */
-               nRotationX += 90;  // X rotation (map Chart2 [-179,180] to 
OOXML [0..90])
-            }
-            else
-                nRotationX += 360; // X rotation (map Chart2 [-179,180] to 
OOXML [-90..90])
+            if( nRotationX < 0 )
+                nRotationX += 90;  // X rotation (map Chart2 [-179,180] to 
OOXML [0..90])
+        }
+        else
+        {
+            assert(nRotationX >= -180 && nRotationX <= 180);
+            // X rotation (map Chart2 [-179,180] to OOXML [-90..90])
+            // This is not ideal, we are losing information, but that is 
unavoidable since OOXML does not
+            // allow upside down 3d charts.
+            if( nRotationX < -90 )
+                nRotationX = -90;
+            else if( nRotationX > 90 )
+                nRotationX = 90;
         }
         pFS->singleElement(FSNS(XML_c, XML_rotX), XML_val, 
OString::number(nRotationX));
     }

Reply via email to