incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1351648 - in /incubator/ooo/trunk/main/svx: inc/svx/svddrgmt.hxx inc/svx/svdoedge.hxx source/svdraw/svddrgmt.cxx source/svdraw/svdoedge.cxx
Date Tue, 19 Jun 2012 10:47:16 GMT
Author: alg
Date: Tue Jun 19 10:47:15 2012
New Revision: 1351648

URL: http://svn.apache.org/viewvc?rev=1351648&view=rev
Log:
#54102# added support for rotation, shear and mirror for SdrEdgeObj (Edges, Connectors), added
interactive preview, allowed these actions for editing

Modified:
    incubator/ooo/trunk/main/svx/inc/svx/svddrgmt.hxx
    incubator/ooo/trunk/main/svx/inc/svx/svdoedge.hxx
    incubator/ooo/trunk/main/svx/source/svdraw/svddrgmt.cxx
    incubator/ooo/trunk/main/svx/source/svdraw/svdoedge.cxx

Modified: incubator/ooo/trunk/main/svx/inc/svx/svddrgmt.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/svddrgmt.hxx?rev=1351648&r1=1351647&r2=1351648&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/inc/svx/svddrgmt.hxx (original)
+++ incubator/ooo/trunk/main/svx/inc/svx/svddrgmt.hxx Tue Jun 19 10:47:15 2012
@@ -95,7 +95,13 @@ public:
     SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact&
rObjectContact, bool bModify);
     virtual ~SdrDragEntrySdrObject();
 
-	virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod&
rDragMethod);
+    // #54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
+    // added accessors to original and clone
+    void prepareCurrentState(SdrDragMethod& rDragMethod);
+    const SdrObject& getOriginal() const { return maOriginal; }
+    SdrObject* getClone() { return mpClone; }
+
+    virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod&
rDragMethod);
 };
 
 //////////////////////////////////////////////////////////////////////////////
@@ -144,8 +150,8 @@ private:
 
 protected:
 	// access for derivated classes to maSdrDragEntries
-	void clearSdrDragEntries() { for(sal_uInt32 a(0); a < maSdrDragEntries.size(); a++) {
delete maSdrDragEntries[a]; } maSdrDragEntries.clear(); }
-    void addSdrDragEntry(SdrDragEntry* pNew) { if(pNew) { maSdrDragEntries.push_back(pNew);
}}
+	void clearSdrDragEntries();
+    void addSdrDragEntry(SdrDragEntry* pNew);
     virtual void createSdrDragEntries();
     virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact&
rObjectContact, bool bModify);
 

Modified: incubator/ooo/trunk/main/svx/inc/svx/svdoedge.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/svdoedge.hxx?rev=1351648&r1=1351647&r2=1351648&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/inc/svx/svdoedge.hxx (original)
+++ incubator/ooo/trunk/main/svx/inc/svx/svdoedge.hxx Tue Jun 19 10:47:15 2012
@@ -265,6 +265,11 @@ public:
     virtual void NbcSetSnapRect(const Rectangle& rRect);
 	virtual void NbcMove(const Size& aSize);
 	virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction&
aYFact);
+	
+    // #54102# added rotate, mirrorn and shear support
+    virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs);
+	virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
+	virtual void NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear);
 
 	// #102344# Added missing implementation
 	virtual void NbcSetAnchorPos(const Point& rPnt);

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svddrgmt.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svddrgmt.cxx?rev=1351648&r1=1351647&r2=1351648&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svddrgmt.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svddrgmt.cxx Tue Jun 19 10:47:15 2012
@@ -32,7 +32,6 @@
 #endif
 #include <tools/bigint.hxx>
 #include <vcl/svapp.hxx>
-
 #include "svx/xattr.hxx"
 #include <svx/xpoly.hxx>
 #include <svx/svdetc.hxx>
@@ -79,6 +78,8 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <drawinglayer/attribute/sdrlineattribute.hxx>
 #include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
+#include <map>
+#include <vector>
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -153,7 +154,7 @@ SdrDragEntrySdrObject::~SdrDragEntrySdrO
     }
 }
 
-drawinglayer::primitive2d::Primitive2DSequence SdrDragEntrySdrObject::createPrimitive2DSequenceInCurrentState(SdrDragMethod&
rDragMethod)
+void SdrDragEntrySdrObject::prepareCurrentState(SdrDragMethod& rDragMethod)
 {
 	// for the moment, i need to re-create the clone in all cases. I need to figure
 	// out when clone and original have the same class, so that i can use operator=
@@ -165,8 +166,6 @@ drawinglayer::primitive2d::Primitive2DSe
     //	    pOleObject->TRGetBaseGeometry(aMatrix, aPolyPolygon);
     //        pClone->TRSetBaseGeometry(aMatrix, aPolyPolygon);
 
-	const SdrObject* pSource = &maOriginal;
-
 	if(mpClone)
     {
         SdrObject::Free(mpClone);
@@ -182,7 +181,15 @@ drawinglayer::primitive2d::Primitive2DSe
 		
 		// apply original transformation, implemented at the DragMethods
 		rDragMethod.applyCurrentTransformationToSdrObject(*mpClone);
+	}
+}
 
+drawinglayer::primitive2d::Primitive2DSequence SdrDragEntrySdrObject::createPrimitive2DSequenceInCurrentState(SdrDragMethod&
rDragMethod)
+{
+	const SdrObject* pSource = &maOriginal;
+
+	if(mbModify && mpClone)
+	{
 		// choose source for geometry data
 		pSource = mpClone;
 	}
@@ -313,6 +320,24 @@ basegfx::B2DRange SdrDragMethod::getCurr
     return getB2DRangeFromOverlayObjectList();
 }
 
+void SdrDragMethod::clearSdrDragEntries() 
+{ 
+    for(sal_uInt32 a(0); a < maSdrDragEntries.size(); a++) 
+    { 
+        delete maSdrDragEntries[a]; 
+    } 
+
+    maSdrDragEntries.clear(); 
+}
+
+void SdrDragMethod::addSdrDragEntry(SdrDragEntry* pNew) 
+{ 
+    if(pNew) 
+    { 
+        maSdrDragEntries.push_back(pNew); 
+    }
+}
+
 void SdrDragMethod::createSdrDragEntries()
 {
 	if(getSdrDragView().GetSdrPageView() && getSdrDragView().GetSdrPageView()->HasMarkedObjPageView())
@@ -663,6 +688,16 @@ void SdrDragMethod::CancelSdrDrag()
 	Hide();
 }
 
+struct compareConstSdrObjectRefs
+{
+    bool operator()(const SdrObject* p1, const SdrObject* p2) const
+    {
+        return (p1 < p2);
+    }
+};
+
+typedef std::map< const SdrObject*, SdrObject*, compareConstSdrObjectRefs> SdrObjectAndCloneMap;
+
 void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager)
 {
     // create SdrDragEntries on demand
@@ -675,10 +710,77 @@ void SdrDragMethod::CreateOverlayGeometr
     // modification from current interactive state
     if(!maSdrDragEntries.empty())
     {
+        // #54102# SdrDragEntrySdrObject creates clones of SdrObjects as base for creating
the needed
+        // primitives, holding the original and the clone. If connectors (Edges) are involved,
+        // the cloned connectors need to be connected to the cloned SdrObjects (after cloning
+        // they are connected to the original SdrObjects). To do so, trigger the preparation
+        // steps for SdrDragEntrySdrObject, save an association of (orig, clone) in a helper
+        // and evtl. remember if it was an edge
+        SdrObjectAndCloneMap aOriginalAndClones;
+        std::vector< SdrEdgeObj* > aEdges;
+        sal_uInt32 a;
+		
+        // #54102# execute prepareCurrentState for all SdrDragEntrySdrObject, register pair
of original and
+        // clone, remember edges
+		for(a = 0; a < maSdrDragEntries.size(); a++)
+        {
+            SdrDragEntrySdrObject* pSdrDragEntrySdrObject = dynamic_cast< SdrDragEntrySdrObject*>(maSdrDragEntries[a]);
+
+            if(pSdrDragEntrySdrObject)
+            {
+                pSdrDragEntrySdrObject->prepareCurrentState(*this);
+
+                SdrEdgeObj* pSdrEdgeObj = dynamic_cast< SdrEdgeObj* >(pSdrDragEntrySdrObject->getClone());
+
+                if(pSdrEdgeObj)
+                {
+                    aEdges.push_back(pSdrEdgeObj);
+                }
+
+                if(pSdrDragEntrySdrObject->getClone())
+                {
+                    aOriginalAndClones[&pSdrDragEntrySdrObject->getOriginal()] = pSdrDragEntrySdrObject->getClone();
+                }
+            }
+        }
+
+        // #54102# if there are edges, reconnect their ends to the corresponding clones (if
found)
+        if(aEdges.size())
+        {
+            for(a = 0; a < aEdges.size(); a++)
+            {
+                SdrEdgeObj* pSdrEdgeObj = aEdges[a];
+                SdrObject* pConnectedTo = pSdrEdgeObj->GetConnectedNode(true);
+
+                if(pConnectedTo)
+                {
+                    SdrObjectAndCloneMap::iterator aEntry = aOriginalAndClones.find(pConnectedTo);
+
+                    if(aEntry != aOriginalAndClones.end())
+                    {
+                        pSdrEdgeObj->ConnectToNode(true, aEntry->second);
+                    }
+                }
+
+                pConnectedTo = pSdrEdgeObj->GetConnectedNode(false);
+
+                if(pConnectedTo)
+                {
+                    SdrObjectAndCloneMap::iterator aEntry = aOriginalAndClones.find(pConnectedTo);
+
+                    if(aEntry != aOriginalAndClones.end())
+                    {
+                        pSdrEdgeObj->ConnectToNode(false, aEntry->second);
+                    }
+                }
+            }
+        }
+
+        // collect primitives for visualisation
 		drawinglayer::primitive2d::Primitive2DSequence aResult;
 		drawinglayer::primitive2d::Primitive2DSequence aResultTransparent;
-		
-		for(sal_uInt32 a(0); a < maSdrDragEntries.size(); a++)
+
+        for(a = 0; a < maSdrDragEntries.size(); a++)
         {
             SdrDragEntry* pCandidate = maSdrDragEntries[a];
 

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdoedge.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdoedge.cxx?rev=1351648&r1=1351647&r2=1351648&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdoedge.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdoedge.cxx Tue Jun 19 10:47:15 2012
@@ -360,15 +360,16 @@ void SdrEdgeObj::ImpSetEdgeInfoToAttr()
 
 void SdrEdgeObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
 {
-	rInfo.bRotateFreeAllowed=sal_False;
-	rInfo.bRotate90Allowed  =sal_False;
-	rInfo.bMirrorFreeAllowed=sal_False;
-	rInfo.bMirror45Allowed  =sal_False;
-	rInfo.bMirror90Allowed  =sal_False;
+    // #54102# allow rotation, mirror and shear
+	rInfo.bRotateFreeAllowed = true;
+	rInfo.bRotate90Allowed = true;
+	rInfo.bMirrorFreeAllowed = true;
+	rInfo.bMirror45Allowed = true;
+	rInfo.bMirror90Allowed = true;
 	rInfo.bTransparenceAllowed = sal_False;
 	rInfo.bGradientAllowed = sal_False;
-	rInfo.bShearAllowed     =sal_False;
-	rInfo.bEdgeRadiusAllowed=sal_False;
+	rInfo.bShearAllowed = true;
+	rInfo.bEdgeRadiusAllowed = sal_False;
 	FASTBOOL bCanConv=!HasText() || ImpCanConvTextToCurve();
 	rInfo.bCanConvToPath=bCanConv;
 	rInfo.bCanConvToPoly=bCanConv;
@@ -575,7 +576,7 @@ void SdrEdgeObj::ImpRecalcEdgeTrack()
 		// SdrEdgeObj BoundRect calculations
 		((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_True;
 
-		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetCurrentBoundRect();
 		SetRectsDirty();
 		// #110094#-14 if (!bEdgeTrackDirty) SendRepaintBroadcast();
 		*pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
@@ -720,8 +721,10 @@ XPolygon SdrEdgeObj::ImpCalcEdgeTrack(co
 			aPt2=aOutRect.BottomRight();
 		}
 	}
-	FASTBOOL bCon1=rCon1.pObj!=NULL && rCon1.pObj->GetPage()==pPage && rCon1.pObj->IsInserted();
-	FASTBOOL bCon2=rCon2.pObj!=NULL && rCon2.pObj->GetPage()==pPage && rCon2.pObj->IsInserted();
+
+    // #54102# To allow interactive preview, do also if not inserted
+	FASTBOOL bCon1=rCon1.pObj!=NULL && rCon1.pObj->GetPage()==pPage; // &&
rCon1.pObj->IsInserted();
+	FASTBOOL bCon2=rCon2.pObj!=NULL && rCon2.pObj->GetPage()==pPage; // &&
rCon2.pObj->IsInserted();
 	const SfxItemSet& rSet = GetObjectItemSet();
 
 	if (bCon1) {
@@ -1577,7 +1580,7 @@ void __EXPORT SdrEdgeObj::Notify(SfxBroa
 			(pSdrHint && pSdrHint->GetKind()==HINT_OBJREMOVED))
 		{
 			// Broadcasting nur, wenn auf der selben Page
-			Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+			Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetCurrentBoundRect();
 			// #110094#-14 if (!bEdgeTrackDirty) SendRepaintBroadcast();
 			ImpDirtyEdgeTrack();
 
@@ -2257,6 +2260,69 @@ void SdrEdgeObj::NbcResize(const Point& 
 	}
 }
 
+// #54102# added rotation support
+void SdrEdgeObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+    // handle start and end point if not connected
+	FASTBOOL bCon1=aCon1.pObj!=NULL && aCon1.pObj->GetPage()==pPage && aCon1.pObj->IsInserted();
+	FASTBOOL bCon2=aCon2.pObj!=NULL && aCon2.pObj->GetPage()==pPage && aCon2.pObj->IsInserted();
+
+    if(!bCon1 && pEdgeTrack)
+    {
+        RotatePoint((*pEdgeTrack)[0],rRef,sn,cs);
+        ImpDirtyEdgeTrack();
+    }
+
+    if(!bCon2 && pEdgeTrack)
+    {
+    	sal_uInt16 nPntAnz = pEdgeTrack->GetPointCount();
+        RotatePoint((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],rRef,sn,cs);
+        ImpDirtyEdgeTrack();
+    }
+}
+
+// #54102# added mirror support
+void SdrEdgeObj::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+    // handle start and end point if not connected
+	FASTBOOL bCon1=aCon1.pObj!=NULL && aCon1.pObj->GetPage()==pPage && aCon1.pObj->IsInserted();
+	FASTBOOL bCon2=aCon2.pObj!=NULL && aCon2.pObj->GetPage()==pPage && aCon2.pObj->IsInserted();
+
+    if(!bCon1 && pEdgeTrack)
+    {
+    	MirrorPoint((*pEdgeTrack)[0],rRef1,rRef2);
+        ImpDirtyEdgeTrack();
+    }
+
+    if(!bCon2 && pEdgeTrack)
+    {
+    	sal_uInt16 nPntAnz = pEdgeTrack->GetPointCount();
+    	MirrorPoint((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],rRef1,rRef2);
+        ImpDirtyEdgeTrack();
+    }
+}
+
+// #54102# added shear support
+void SdrEdgeObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
+{
+    // handle start and end point if not connected
+	FASTBOOL bCon1=aCon1.pObj!=NULL && aCon1.pObj->GetPage()==pPage && aCon1.pObj->IsInserted();
+	FASTBOOL bCon2=aCon2.pObj!=NULL && aCon2.pObj->GetPage()==pPage && aCon2.pObj->IsInserted();
+
+    if(!bCon1 && pEdgeTrack)
+    {
+    	ShearPoint((*pEdgeTrack)[0],rRef,tn,bVShear);
+        ImpDirtyEdgeTrack();
+    }
+
+    if(!bCon2 && pEdgeTrack)
+    {
+    	sal_uInt16 nPntAnz = pEdgeTrack->GetPointCount();
+    	ShearPoint((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],rRef,tn,bVShear);
+        ImpDirtyEdgeTrack();
+    }
+}
+
 SdrObject* SdrEdgeObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
 {
 	basegfx::B2DPolyPolygon aPolyPolygon;



Mime
View raw message