summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPriyankaGaikwad <priyanka.gaikwad@synerzip.com>2014-01-28 18:28:39 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-03-12 02:41:02 +0100
commit2b6e395152b48e412d3addde7d8b3808b28d32c6 (patch)
tree5c325d9d58304e5fa91802c93d3a47b54ff772c1
parentede99e0daa0701e2d8568d7ed00e2221a4f6a9f6 (diff)
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
-rw-r--r--chart2/qa/extras/chart2export.cxx11
-rw-r--r--chart2/qa/extras/data/docx/pieChartRotation.docxbin0 -> 23528 bytes
-rw-r--r--oox/source/export/chartexport.cxx43
3 files changed, 45 insertions, 9 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index e328f90202ba..3189a227a77f 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 000000000000..f76f602374c4
--- /dev/null
+++ b/chart2/qa/extras/data/docx/pieChartRotation.docx
Binary files differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 201d9882d046..91d761f55ca2 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" ) )