[Libreoffice-commits] core.git: chart2/qa oox/source

PriyankaGaikwad priyanka.gaikwad at synerzip.com
Tue Mar 11 18:42:32 PDT 2014


 chart2/qa/extras/chart2export.cxx                |   11 +++++
 chart2/qa/extras/data/docx/pieChartRotation.docx |binary
 oox/source/export/chartexport.cxx                |   43 ++++++++++++++++++-----
 3 files changed, 45 insertions(+), 9 deletions(-)

New commits:
commit 2b6e395152b48e412d3addde7d8b3808b28d32c6
Author: PriyankaGaikwad <priyanka.gaikwad at synerzip.com>
Date:   Tue Jan 28 18:28:39 2014 +0530

    fdo#74111 3D Rotation is wrong after Round trip for pie chart
    
    3D Rotation is lost after Round trip for pie chart.
    XML Difference:
    
    Original:
    <c:rotX val="40"/>
    <c:rotY val="30"/>
    
    Round Trip:
    <c:rotX val="310"/>
    <c:rotY val="0"/>
    
    Conflicts:
    	chart2/qa/extras/chart2export.cxx
    
    Change-Id: I60132fef071e0573b17c35f509f3a74bd4ffcc66

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index e328f90..3189a22 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -51,6 +51,7 @@ public:
     void testSeriesIdxOrder();
     void testErrorBarDataRangeODS();
     void testChartCrash();
+    void testPieChartRotation();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(test);
@@ -74,6 +75,7 @@ public:
     CPPUNIT_TEST(testSeriesIdxOrder);
     CPPUNIT_TEST(testErrorBarDataRangeODS);
     CPPUNIT_TEST(testChartCrash);
+    CPPUNIT_TEST(testPieChartRotation);
     CPPUNIT_TEST_SUITE_END();
 
 protected:
@@ -662,6 +664,15 @@ void Chart2ExportTest::testChartCrash()
     CPPUNIT_ASSERT(pXmlDoc);
 }
 
+void Chart2ExportTest::testPieChartRotation()
+{
+    load ("/chart2/qa/extras/data/docx/", "pieChartRotation.docx");
+    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    CPPUNIT_ASSERT(pXmlDoc);
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotX", "val", "40");
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotY", "val", "30");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/pieChartRotation.docx b/chart2/qa/extras/data/docx/pieChartRotation.docx
new file mode 100644
index 0000000..f76f602
Binary files /dev/null and b/chart2/qa/extras/data/docx/pieChartRotation.docx differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 201d988..91d761f 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3191,14 +3191,24 @@ void ChartExport::exportView3D()
     FSHelperPtr pFS = GetFS();
     pFS->startElement( FSNS( XML_c, XML_view3D ),
             FSEND );
+    sal_Int32 eChartType = getChartType( );
     // rotX
     if( GetProperty( xPropSet, "RotationHorizontal" ) )
     {
         sal_Int32 nRotationX = 0;
         mAny >>= nRotationX;
-        // X rotation (map Chart2 [-179,180] to OOXML [0..359])
         if( nRotationX < 0 )
-            nRotationX += 360;
+        {
+            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 conver 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])
+        }
         pFS->singleElement( FSNS( XML_c, XML_rotX ),
             XML_val, I32S( nRotationX ),
             FSEND );
@@ -3206,14 +3216,29 @@ void ChartExport::exportView3D()
     // rotY
     if( GetProperty( xPropSet, "RotationVertical" ) )
     {
-        sal_Int32 nRotationY = 0;
-        mAny >>= nRotationY;
         // Y rotation (map Chart2 [-179,180] to OOXML [0..359])
-        if( nRotationY < 0 )
-            nRotationY += 360;
-        pFS->singleElement( FSNS( XML_c, XML_rotY ),
-            XML_val, I32S( nRotationY ),
-            FSEND );
+        if( eChartType == chart::TYPEID_PIE && GetProperty( xPropSet, "StartingAngle" ) )
+        {
+         // Y rotation used as 'first pie slice angle' in 3D pie charts
+            sal_Int32 nStartingAngle=0;
+            mAny >>= nStartingAngle;
+            // convert to ooxml angle
+            nStartingAngle = (450 - nStartingAngle ) % 360;
+            pFS->singleElement( FSNS( XML_c, XML_rotY ),
+                           XML_val, I32S( nStartingAngle ),
+                           FSEND );
+        }
+        else
+        {
+            sal_Int32 nRotationY = 0;
+            mAny >>= nRotationY;
+            // Y rotation (map Chart2 [-179,180] to OOXML [0..359])
+            if( nRotationY < 0 )
+                nRotationY += 360;
+            pFS->singleElement( FSNS( XML_c, XML_rotY ),
+                            XML_val, I32S( nRotationY ),
+                            FSEND );
+        }
     }
     // rAngAx
     if( GetProperty( xPropSet, "RightAngledAxes" ) )


More information about the Libreoffice-commits mailing list