From 4116c33b12d3787c406f0348f89efcb1cf409507 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 21 Nov 2012 13:23:01 +0000 Subject: For backward compatibility do take mirrorings in setTransformation into account. Also found an error in SdrObjCustomShape::TRGetBaseGeometry when MirrorY was used --- svx/source/svdraw/svdoashp.cxx | 10 +++--- xmloff/source/draw/ximpshap.cxx | 79 +++++++++++++++++++++++++++++------------ xmloff/source/draw/ximpshap.hxx | 5 ++- 3 files changed, 64 insertions(+), 30 deletions(-) diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 95a640eb4d32..aa9fd6f6dbbe 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -3437,11 +3437,11 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba } // Polygon wenden und etwas schieben Polygon aPol0(aPol); - aPol[0]=aPol0[1]; - aPol[1]=aPol0[0]; - aPol[2]=aPol0[3]; - aPol[3]=aPol0[2]; - aPol[4]=aPol0[1]; + aPol[0]=aPol0[3]; // This was WRONG for vertical (!) + aPol[1]=aPol0[2]; + aPol[2]=aPol0[1]; + aPol[3]=aPol0[0]; + aPol[4]=aPol0[3]; Poly2Rect(aPol,aRectangle,aNewGeo); } } diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index d2140a3d05b7..25fdcc070653 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -19,13 +19,9 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" - - #include #include #include @@ -40,7 +36,6 @@ #include #include #include - #include #include #include @@ -74,7 +69,6 @@ #include "XMLImageMapContext.hxx" #include "sdpropls.hxx" #include "eventimp.hxx" - #include "descriptionimp.hxx" #include "ximpcustomshape.hxx" #include "XMLEmbeddedObjectImportContext.hxx" @@ -83,10 +77,8 @@ #include #include #include - -// --> OD 2006-02-22 #b6382898# #include -// <-- +#include using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -164,6 +156,7 @@ SdXMLShapeContext::SdXMLShapeContext( , mnZOrder(-1) , maSize(1, 1) , maPosition(0, 0) +, maUsedTransformation() , mbVisible(true) , mbPrintable(true) { @@ -541,7 +534,7 @@ void SdXMLShapeContext::SetTransformation() uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); if(xPropSet.is()) { - ::basegfx::B2DHomMatrix aTransformation; + maUsedTransformation.identity(); if(maSize.Width != 1 || maSize.Height != 1) { @@ -552,13 +545,13 @@ void SdXMLShapeContext::SetTransformation() maSize.Height = 1; // set global size. This should always be used. - aTransformation.scale(maSize.Width, maSize.Height); + maUsedTransformation.scale(maSize.Width, maSize.Height); } if(maPosition.X != 0 || maPosition.Y != 0) { // if global position is used, add it to transformation - aTransformation.translate(maPosition.X, maPosition.Y); + maUsedTransformation.translate(maPosition.X, maPosition.Y); } if(mnTransform.NeedsAction()) @@ -572,24 +565,24 @@ void SdXMLShapeContext::SetTransformation() mnTransform.GetFullTransform(aMat); // now add to transformation - aTransformation *= aMat; + maUsedTransformation *= aMat; } // now set transformation for this object uno::Any aAny; drawing::HomogenMatrix3 aMatrix; - aMatrix.Line1.Column1 = aTransformation.get(0, 0); - aMatrix.Line1.Column2 = aTransformation.get(0, 1); - aMatrix.Line1.Column3 = aTransformation.get(0, 2); + aMatrix.Line1.Column1 = maUsedTransformation.get(0, 0); + aMatrix.Line1.Column2 = maUsedTransformation.get(0, 1); + aMatrix.Line1.Column3 = maUsedTransformation.get(0, 2); - aMatrix.Line2.Column1 = aTransformation.get(1, 0); - aMatrix.Line2.Column2 = aTransformation.get(1, 1); - aMatrix.Line2.Column3 = aTransformation.get(1, 2); + aMatrix.Line2.Column1 = maUsedTransformation.get(1, 0); + aMatrix.Line2.Column2 = maUsedTransformation.get(1, 1); + aMatrix.Line2.Column3 = maUsedTransformation.get(1, 2); - aMatrix.Line3.Column1 = aTransformation.get(2, 0); - aMatrix.Line3.Column2 = aTransformation.get(2, 1); - aMatrix.Line3.Column3 = aTransformation.get(2, 2); + aMatrix.Line3.Column1 = maUsedTransformation.get(2, 0); + aMatrix.Line3.Column2 = maUsedTransformation.get(2, 1); + aMatrix.Line3.Column3 = maUsedTransformation.get(2, 2); aAny <<= aMatrix; @@ -3683,6 +3676,48 @@ void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAtt void SdXMLCustomShapeContext::EndElement() { + // for backward compatibility, the above SetTransformation() may alraedy have + // applied a call to SetMirroredX/SetMirroredY. This is not yet added to the + // beans::PropertyValues in maCustomShapeGeometry. When applying these now, this + // would be lost again. + // TTTT: Remove again after aw080 + if(!maUsedTransformation.isIdentity()) + { + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + + maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX); + + bool bFlippedX(aScale.getX() < 0.0); + bool bFlippedY(aScale.getY() < 0.0); + + if(bFlippedX && bFlippedY) + { + // when both are used it is the same as 180 degree rotation; reset + bFlippedX = bFlippedY = false; + } + + if(bFlippedX || bFlippedY) + { + beans::PropertyValue aNewPoroperty; + + if(bFlippedX) + { + aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredX")); + } + else + { + aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredY")); + } + + aNewPoroperty.Handle = -1; + aNewPoroperty.Value <<= sal_True; + aNewPoroperty.State = beans::PropertyState_DIRECT_VALUE; + + maCustomShapeGeometry.push_back(aNewPoroperty); + } + } + if ( !maCustomShapeGeometry.empty() ) { const rtl::OUString sCustomShapeGeometry ( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) ); diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx index a1dc22c4c070..94239026991d 100644 --- a/xmloff/source/draw/ximpshap.hxx +++ b/xmloff/source/draw/ximpshap.hxx @@ -19,8 +19,6 @@ * *************************************************************/ - - #ifndef _XIMPSHAPE_HXX #define _XIMPSHAPE_HXX @@ -35,10 +33,10 @@ #include #include #include "xexptran.hxx" - #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// // common shape context @@ -79,6 +77,7 @@ protected: SdXMLImExTransform2D mnTransform; com::sun::star::awt::Size maSize; com::sun::star::awt::Point maPosition; + basegfx::B2DHomMatrix maUsedTransformation; bool mbVisible; bool mbPrintable; -- cgit v1.2.3