[Libreoffice-commits] core.git: 3 commits - sd/source svx/source xmloff/source

Armin Le Grand alg at apache.org
Fri Jun 7 12:50:06 PDT 2013


 sd/source/ui/view/sdview3.cxx   |   14 ++++++-
 sd/source/ui/view/sdview4.cxx   |   12 +++---
 svx/source/svdraw/svdoashp.cxx  |   14 ++++---
 svx/source/svdraw/svdoole2.cxx  |    9 +---
 xmloff/source/draw/ximpshap.cxx |   73 +++++++++++++++++++++++++++++++---------
 xmloff/source/draw/ximpshap.hxx |    3 +
 6 files changed, 89 insertions(+), 36 deletions(-)

New commits:
commit 6e4637db213e7570d3920902288ca15b5e61b190
Author: Armin Le Grand <alg at apache.org>
Date:   Mon Apr 8 17:04:41 2013 +0000

    Resolves: #i121932# fixed ODF CustomShape import/export
    
    (cherry picked from commit 970ff93fdf7d85b5d4f96d35aff641fe3c681668)
    
    Change-Id: Ib95e9a551912de1aff2318093b0104cf4699df77

diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index e930d31..a0c09cb 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -3029,7 +3029,8 @@ void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix,
     if(!basegfx::fTools::equalZero(fShearX))
     {
         GeoStat aGeoStat;
-        aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0);
+        // #i121932# do *not* forget to invert shearX(!)
+        aGeoStat.nShearWink = FRound((atan(-fShearX) / F_PI180) * 100.0);
         aGeoStat.RecalcTan();
         Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, sal_False);
     }
@@ -3108,11 +3109,11 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba
             }
             // mirror polygon and move it a bit
             Polygon aPol0(aPol);
-            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];
+            aPol[0]=aPol0[1]; // This was WRONG for vertical (!)
+            aPol[1]=aPol0[0]; // #i121932# Despite my own coment above
+            aPol[2]=aPol0[3]; // it was *not* wrong even when the reordering
+            aPol[3]=aPol0[2]; // *seems* to be specific for X-Mirrorings. Oh
+            aPol[4]=aPol0[1]; // will I be happy when this old stuff is |gone| with aw080 (!)
             Poly2Rect(aPol,aRectangle,aNewGeo);
         }
     }
commit 501e0246bc72783f2dc830ea6b29f4a9e7c3045f
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Jan 9 14:49:01 2013 +0000

    Resolves: #i121603# corrected D&D on existing shapes (CTRL+SHIFT pressed)
    
    (cherry picked from commit 5f81e1134607ae67d7c598f695bd0997cd9c9284)
    
    Conflicts:
    	sd/source/ui/view/sdview3.cxx
    	sd/source/ui/view/sdview4.cxx
    	svx/source/svdraw/svdoole2.cxx
    
    Change-Id: I91634de52a23ebe897f2d38a6cca763aed19dfc0

diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 123a3f4..38079c5 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -53,7 +53,6 @@
 #include <vcl/metaact.hxx>
 #include <svx/svxids.hrc>
 #include <toolkit/helper/vclunohelper.hxx>
-
 #include "DrawDocShell.hxx"
 #include "fupoor.hxx"
 #include "Window.hxx"
@@ -68,13 +67,13 @@
 #include "strmname.h"
 #include "unomodel.hxx"
 #include "ViewClipboard.hxx"
-
 #include <sfx2/ipclient.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <tools/stream.hxx>
 #include <vcl/cvtgrf.hxx>
 #include <svx/sdrhittesthelper.hxx>
+#include <svx/xbtmpit.hxx>
 
 // --------------
 // - Namespaces -
@@ -731,6 +730,7 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper,
                                 BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
                                 AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
                             }
+
                             aSet.Put( pObj->GetMergedItemSet() );
 
                             /* Do not take over corner radius. There are
@@ -739,6 +739,16 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper,
                                object. */
                             aSet.ClearItem( SDRATTR_ECKENRADIUS );
 
+                            const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
+
+                            if(pSdrGrafObj)
+                            {
+                                // If we have a graphic as source object, use it's graphic
+                                // content as fill style
+                                aSet.Put(XFillStyleItem(XFILL_BITMAP));
+                                aSet.Put(XFillBitmapItem(&mrDoc.GetPool(), pSdrGrafObj->GetGraphic()));
+                            }
+
                             pPickObj->SetMergedItemSetAndBroadcast( aSet );
 
                             if( pPickObj->ISA( E3dObject ) && pObj->ISA( E3dObject ) )
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 53d414c..067b677 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -50,15 +50,14 @@
 #include "sdpage.hxx"
 #include "view/SlideSorterView.hxx"
 #include "undo/undoobjects.hxx"
-
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/embed/XEmbedPersist.hpp>
 #include <com/sun/star/embed/Aspects.hpp>
 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
 #include <svtools/soerr.hxx>
-
 #include <sfx2/ipclient.hxx>
+#include <svx/svdoashp.hxx>
 #include "glob.hrc"
 
 using namespace com::sun::star;
@@ -96,8 +95,9 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
 
     if( mnAction == DND_ACTION_LINK && pPickObj && pPV )
     {
-        const bool bIsGraphic = pPickObj->ISA( SdrGrafObj );
-        if( bIsGraphic || (pObj && pObj->IsEmptyPresObj() && !bOnMaster) )
+        const bool bIsGraphic(0 != dynamic_cast< SdrGrafObj* >(pPickObj));
+
+        if(bIsGraphic || (pPickObj && pPickObj->IsEmptyPresObj() && !bOnMaster)) // #i121603# Do not use pObj, it may be NULL
         {
             if( IsUndoEnabled() )
                 BegUndo(String(SdResId(STR_INSERTGRAPHIC)));
@@ -139,9 +139,9 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
             if( IsUndoEnabled() )
                 EndUndo();
         }
-        else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj))
+        else if(pPickObj->IsClosedObj())
         {
-            // we fill the object with the graphic
+            // fill object with graphic
             if( IsUndoEnabled() )
             {
                 BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 15aaa01..e930d31 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -855,6 +855,7 @@ SdrObjCustomShape::SdrObjCustomShape() :
     fObjectRotation( 0.0 ),
     mpLastShadowGeometry(0L)
 {
+    bClosedObj = true; // custom shapes may be filled
     bTextFrame = sal_True;
 }
 
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index af194c0..d00e0b8 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -770,8 +770,7 @@ SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef&  rNewObjRef, const XubStri
         SetResizeProtect(sal_True);
 
     // For math objects, set closed state to transparent
-    if( ImplIsMathObj( xObjRef.GetObject() ) )
-        SetClosedObj( false );
+    SetClosedObj(!ImplIsMathObj( xObjRef.GetObject() ));
 }
 
 // -----------------------------------------------------------------------------
@@ -1508,8 +1507,7 @@ void SdrOle2Obj::SetObjRef( const com::sun::star::uno::Reference < com::sun::sta
             SetResizeProtect(sal_True);
 
         // For math objects, set closed state to transparent
-        if( ImplIsMathObj( rNewObjRef ) )
-            SetClosedObj( false );
+        SetClosedObj(!ImplIsMathObj( rNewObjRef ));
 
         Connect();
     }
@@ -2015,8 +2013,7 @@ void SdrOle2Obj::GetObjRef_Impl()
             }
 
             // For math objects, set closed state to transparent
-            if( ImplIsMathObj( xObjRef.GetObject() ) )
-                SetClosedObj( false );
+            SetClosedObj(!ImplIsMathObj( xObjRef.GetObject() ));
         }
 
         if ( xObjRef.is() )
commit 13ef16423e78d3ea825172594f08c47d2f9bfd09
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Nov 21 13:23:01 2012 +0000

    For backward compatibility take mirrorings in setTransformation into account
    
    Also found an error in SdrObjCustomShape::TRGetBaseGeometry when MirrorY was used
    
    (cherry picked from commit 4116c33b12d3787c406f0348f89efcb1cf409507)
    
    Conflicts:
    	xmloff/source/draw/ximpshap.cxx
    	xmloff/source/draw/ximpshap.hxx
    
    Change-Id: Id85ae4c4f5e26d53d501c72b84fc0e1b5cfe23b2

diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 91e46be..15aaa01 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -3107,11 +3107,11 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba
             }
             // mirror polygon and move it a bit
             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 1906703..54eb00b 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -33,7 +33,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>
@@ -69,7 +68,6 @@
 #include "XMLImageMapContext.hxx"
 #include "sdpropls.hxx"
 #include "eventimp.hxx"
-
 #include "descriptionimp.hxx"
 #include "ximpcustomshape.hxx"
 #include "XMLEmbeddedObjectImportContext.hxx"
@@ -79,6 +77,8 @@
 #include <com/sun/star/container/XChild.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -153,6 +153,7 @@ SdXMLShapeContext::SdXMLShapeContext(
 ,   mnZOrder(-1)
 ,   maSize(1, 1)
 ,   maPosition(0, 0)
+,   maUsedTransformation()
 ,   mbVisible(true)
 ,   mbPrintable(true)
 ,   mbHaveXmlId(false)
@@ -529,7 +530,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)
             {
@@ -540,13 +541,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())
@@ -560,24 +561,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;
 
@@ -3741,6 +3742,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 OUString sCustomShapeGeometry    (  "CustomShapeGeometry"  );
diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx
index 4d64a63..ab00515 100644
--- a/xmloff/source/draw/ximpshap.hxx
+++ b/xmloff/source/draw/ximpshap.hxx
@@ -31,10 +31,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
@@ -75,6 +75,7 @@ protected:
     SdXMLImExTransform2D        mnTransform;
     com::sun::star::awt::Size   maSize;
     com::sun::star::awt::Point  maPosition;
+    basegfx::B2DHomMatrix       maUsedTransformation;
 
     bool                        mbVisible;
     bool                        mbPrintable;


More information about the Libreoffice-commits mailing list