For backward compatibility do take mirrorings in setTransformation into account. Also found an error in SdrObjCustomShape::TRGetBaseGeometry when MirrorY was used

Notes:

merged as: 13ef16423e78d3ea825172594f08c47d2f9bfd09
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 95a640e..aa9fd6f 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 d2140a3..25fdcc0 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 <tools/debug.hxx>
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
@@ -40,7 +36,6 @@
#include <com/sun/star/drawing/EscapeDirection.hpp>
#include <com/sun/star/media/ZoomLevel.hpp>
#include <com/sun/star/awt/Rectangle.hpp>

#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <comphelper/extract.hxx>
@@ -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 <tools/string.hxx>
#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
#include <com/sun/star/container/XChild.hpp>

// --> OD 2006-02-22 #b6382898#
#include <com/sun/star/text/XTextDocument.hpp>
// <--
#include <basegfx/vector/b2dvector.hxx>

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 a1dc22c..9423902 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 <com/sun/star/awt/Point.hpp>
#include <tools/rtti.hxx>
#include "xexptran.hxx"

#include <vector>
#include <xmloff/shapeimport.hxx>
#include <xmloff/xmlmultiimagehelper.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>

//////////////////////////////////////////////////////////////////////////////
// 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;