diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-08-12 15:51:45 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-08-12 16:08:19 +0200 |
commit | 144ca12ef3e17e1d315a496b456cd2bb4cd08744 (patch) | |
tree | ed0801611ce129853bd55321b577d9a4b18e30bb | |
parent | 9ffd693d6ee326df5d35859f90f08f4f34069dbf (diff) |
VML import: handle rotation on groupshapes
Change-Id: I37f0081ae0a8af838c9f5bf158b340d726d7d1a3
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 13 | ||||
-rwxr-xr-x | sw/qa/extras/ooxmlimport/data/groupshape-rotation.docx | bin | 0 -> 10462 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 10 |
3 files changed, 20 insertions, 3 deletions
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 405c6686457f..e1df8e6ac520 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -490,6 +490,13 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) lcl_setSurround( rPropSet, rTypeModel ); } +void lcl_SetRotation(PropertySet& rPropSet, const sal_Int32 nRotation) +{ + // See DffPropertyReader::Fix16ToAngle(): in VML, positive rotation angles are clockwise, we have them as counter-clockwise. + // Additionally, VML type is 0..360, our is 0.36000. + rPropSet.setAnyProperty(PROP_RotateAngle, makeAny(sal_Int32(NormAngle360(nRotation * -100)))); +} + Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const { awt::Rectangle aShapeRect(rShapeRect); @@ -580,9 +587,7 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes PropertySet aPropertySet(xShape); if (xShape.is() && oRotation) { - // See DffPropertyReader::Fix16ToAngle(): in VML, positive rotation angles are clockwise, we have them as counter-clockwise. - // Additionally, VML type is 0..360, our is 0.36000. - aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(sal_Int32(NormAngle360((*oRotation) * -100)))); + lcl_SetRotation(aPropertySet, *oRotation); // If rotation is used, simple setPosition() is not enough. aPropertySet.setAnyProperty(PROP_HoriOrientPosition, makeAny( aShapeRect.X ) ); aPropertySet.setAnyProperty(PROP_VertOrientPosition, makeAny( aShapeRect.Y ) ); @@ -984,6 +989,8 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes > // Make sure group shapes are inline as well, unless there is an explicit different style. PropertySet aPropertySet(xGroupShape); lcl_SetAnchorType(aPropertySet, maTypeModel); + if (!maTypeModel.maRotation.isEmpty()) + lcl_SetRotation(aPropertySet, maTypeModel.maRotation.toInt32()); return xGroupShape; } diff --git a/sw/qa/extras/ooxmlimport/data/groupshape-rotation.docx b/sw/qa/extras/ooxmlimport/data/groupshape-rotation.docx Binary files differnew file mode 100755 index 000000000000..d63b5d0734e1 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/groupshape-rotation.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 15bc845a8f10..50b6945826b2 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -126,6 +126,7 @@ public: void testFdo46361(); void testFdo65632(); void testFdo66474(); + void testGroupshapeRotation(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -217,6 +218,7 @@ void Test::run() {"fdo46361.docx", &Test::testFdo46361}, {"fdo65632.docx", &Test::testFdo65632}, {"fdo66474.docx", &Test::testFdo66474}, + {"groupshape-rotation.docx", &Test::testGroupshapeRotation}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1527,6 +1529,14 @@ void Test::testFdo66474() CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth")); } +void Test::testGroupshapeRotation() +{ + // Rotation on groupshapes wasn't handled at all by the VML importer. + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty<sal_Int32>(xDraws->getByIndex(0), "RotateAngle")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); |