Kaydet (Commit) 4116c33b authored tarafından Armin Le Grand's avatar Armin Le Grand

For backward compatibility do take mirrorings in setTransformation into account.…

For backward compatibility do take mirrorings in setTransformation into account. Also found an error in SdrObjCustomShape::TRGetBaseGeometry when MirrorY was used
üst 7f5c9441
...@@ -3437,11 +3437,11 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba ...@@ -3437,11 +3437,11 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba
} }
// Polygon wenden und etwas schieben // Polygon wenden und etwas schieben
Polygon aPol0(aPol); Polygon aPol0(aPol);
aPol[0]=aPol0[1]; aPol[0]=aPol0[3]; // This was WRONG for vertical (!)
aPol[1]=aPol0[0]; aPol[1]=aPol0[2];
aPol[2]=aPol0[3]; aPol[2]=aPol0[1];
aPol[3]=aPol0[2]; aPol[3]=aPol0[0];
aPol[4]=aPol0[1]; aPol[4]=aPol0[3];
Poly2Rect(aPol,aRectangle,aNewGeo); Poly2Rect(aPol,aRectangle,aNewGeo);
} }
} }
......
...@@ -19,13 +19,9 @@ ...@@ -19,13 +19,9 @@
* *
*************************************************************/ *************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove // MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx" #include "precompiled_xmloff.hxx"
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/container/XNameReplace.hpp>
...@@ -40,7 +36,6 @@ ...@@ -40,7 +36,6 @@
#include <com/sun/star/drawing/EscapeDirection.hpp> #include <com/sun/star/drawing/EscapeDirection.hpp>
#include <com/sun/star/media/ZoomLevel.hpp> #include <com/sun/star/media/ZoomLevel.hpp>
#include <com/sun/star/awt/Rectangle.hpp> #include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp>
#include <comphelper/extract.hxx> #include <comphelper/extract.hxx>
...@@ -74,7 +69,6 @@ ...@@ -74,7 +69,6 @@
#include "XMLImageMapContext.hxx" #include "XMLImageMapContext.hxx"
#include "sdpropls.hxx" #include "sdpropls.hxx"
#include "eventimp.hxx" #include "eventimp.hxx"
#include "descriptionimp.hxx" #include "descriptionimp.hxx"
#include "ximpcustomshape.hxx" #include "ximpcustomshape.hxx"
#include "XMLEmbeddedObjectImportContext.hxx" #include "XMLEmbeddedObjectImportContext.hxx"
...@@ -83,10 +77,8 @@ ...@@ -83,10 +77,8 @@
#include <tools/string.hxx> #include <tools/string.hxx>
#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp> #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XChild.hpp>
// --> OD 2006-02-22 #b6382898#
#include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextDocument.hpp>
// <-- #include <basegfx/vector/b2dvector.hxx>
using ::rtl::OUString; using ::rtl::OUString;
using ::rtl::OUStringBuffer; using ::rtl::OUStringBuffer;
...@@ -164,6 +156,7 @@ SdXMLShapeContext::SdXMLShapeContext( ...@@ -164,6 +156,7 @@ SdXMLShapeContext::SdXMLShapeContext(
, mnZOrder(-1) , mnZOrder(-1)
, maSize(1, 1) , maSize(1, 1)
, maPosition(0, 0) , maPosition(0, 0)
, maUsedTransformation()
, mbVisible(true) , mbVisible(true)
, mbPrintable(true) , mbPrintable(true)
{ {
...@@ -541,7 +534,7 @@ void SdXMLShapeContext::SetTransformation() ...@@ -541,7 +534,7 @@ void SdXMLShapeContext::SetTransformation()
uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
if(xPropSet.is()) if(xPropSet.is())
{ {
::basegfx::B2DHomMatrix aTransformation; maUsedTransformation.identity();
if(maSize.Width != 1 || maSize.Height != 1) if(maSize.Width != 1 || maSize.Height != 1)
{ {
...@@ -552,13 +545,13 @@ void SdXMLShapeContext::SetTransformation() ...@@ -552,13 +545,13 @@ void SdXMLShapeContext::SetTransformation()
maSize.Height = 1; maSize.Height = 1;
// set global size. This should always be used. // 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(maPosition.X != 0 || maPosition.Y != 0)
{ {
// if global position is used, add it to transformation // if global position is used, add it to transformation
aTransformation.translate(maPosition.X, maPosition.Y); maUsedTransformation.translate(maPosition.X, maPosition.Y);
} }
if(mnTransform.NeedsAction()) if(mnTransform.NeedsAction())
...@@ -572,24 +565,24 @@ void SdXMLShapeContext::SetTransformation() ...@@ -572,24 +565,24 @@ void SdXMLShapeContext::SetTransformation()
mnTransform.GetFullTransform(aMat); mnTransform.GetFullTransform(aMat);
// now add to transformation // now add to transformation
aTransformation *= aMat; maUsedTransformation *= aMat;
} }
// now set transformation for this object // now set transformation for this object
uno::Any aAny; uno::Any aAny;
drawing::HomogenMatrix3 aMatrix; drawing::HomogenMatrix3 aMatrix;
aMatrix.Line1.Column1 = aTransformation.get(0, 0); aMatrix.Line1.Column1 = maUsedTransformation.get(0, 0);
aMatrix.Line1.Column2 = aTransformation.get(0, 1); aMatrix.Line1.Column2 = maUsedTransformation.get(0, 1);
aMatrix.Line1.Column3 = aTransformation.get(0, 2); aMatrix.Line1.Column3 = maUsedTransformation.get(0, 2);
aMatrix.Line2.Column1 = aTransformation.get(1, 0); aMatrix.Line2.Column1 = maUsedTransformation.get(1, 0);
aMatrix.Line2.Column2 = aTransformation.get(1, 1); aMatrix.Line2.Column2 = maUsedTransformation.get(1, 1);
aMatrix.Line2.Column3 = aTransformation.get(1, 2); aMatrix.Line2.Column3 = maUsedTransformation.get(1, 2);
aMatrix.Line3.Column1 = aTransformation.get(2, 0); aMatrix.Line3.Column1 = maUsedTransformation.get(2, 0);
aMatrix.Line3.Column2 = aTransformation.get(2, 1); aMatrix.Line3.Column2 = maUsedTransformation.get(2, 1);
aMatrix.Line3.Column3 = aTransformation.get(2, 2); aMatrix.Line3.Column3 = maUsedTransformation.get(2, 2);
aAny <<= aMatrix; aAny <<= aMatrix;
...@@ -3683,6 +3676,48 @@ void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAtt ...@@ -3683,6 +3676,48 @@ void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAtt
void SdXMLCustomShapeContext::EndElement() 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() ) if ( !maCustomShapeGeometry.empty() )
{ {
const rtl::OUString sCustomShapeGeometry ( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) ); const rtl::OUString sCustomShapeGeometry ( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) );
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
* *
*************************************************************/ *************************************************************/
#ifndef _XIMPSHAPE_HXX #ifndef _XIMPSHAPE_HXX
#define _XIMPSHAPE_HXX #define _XIMPSHAPE_HXX
...@@ -35,10 +33,10 @@ ...@@ -35,10 +33,10 @@
#include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Point.hpp>
#include <tools/rtti.hxx> #include <tools/rtti.hxx>
#include "xexptran.hxx" #include "xexptran.hxx"
#include <vector> #include <vector>
#include <xmloff/shapeimport.hxx> #include <xmloff/shapeimport.hxx>
#include <xmloff/xmlmultiimagehelper.hxx> #include <xmloff/xmlmultiimagehelper.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// common shape context // common shape context
...@@ -79,6 +77,7 @@ protected: ...@@ -79,6 +77,7 @@ protected:
SdXMLImExTransform2D mnTransform; SdXMLImExTransform2D mnTransform;
com::sun::star::awt::Size maSize; com::sun::star::awt::Size maSize;
com::sun::star::awt::Point maPosition; com::sun::star::awt::Point maPosition;
basegfx::B2DHomMatrix maUsedTransformation;
bool mbVisible; bool mbVisible;
bool mbPrintable; bool mbPrintable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment