VML import: handle rotation on groupshapes

Change-Id: I37f0081ae0a8af838c9f5bf158b340d726d7d1a3
This commit is contained in:
Miklos Vajna
2013-08-12 16:08:19 +02:00
parent 9ffd693d6e
commit 144ca12ef3
3 changed files with 20 additions and 3 deletions
+10 -3
View File
@@ -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;
}
Binary file not shown.
+10
View File
@@ -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();