Author: alg
Date: Tue Nov 19 17:47:11 2013
New Revision: 1543517

URL: http://svn.apache.org/r1543517
Log:
More connector refinements

Modified:
    openoffice/branches/alg/aw080/main/sd/source/ui/func/fupoor.cxx
    
openoffice/branches/alg/aw080/main/svx/inc/svx/sdr/properties/connectorproperties.hxx
    openoffice/branches/alg/aw080/main/svx/inc/svx/svdoedge.hxx
    
openoffice/branches/alg/aw080/main/svx/source/sdr/properties/connectorproperties.cxx
    openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx

Modified: openoffice/branches/alg/aw080/main/sd/source/ui/func/fupoor.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/sd/source/ui/func/fupoor.cxx?rev=1543517&r1=1543516&r2=1543517&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/sd/source/ui/func/fupoor.cxx (original)
+++ openoffice/branches/alg/aw080/main/sd/source/ui/func/fupoor.cxx Tue Nov 19 
17:47:11 2013
@@ -737,8 +737,8 @@ bool FuPoor::KeyInput(const KeyEvent& rK
                                                        
mpWindow->GetInverseViewTransformation() *
                                                        
basegfx::B2DVector(mpView->GetMarkHdlSizePixel(), 
mpView->GetMarkHdlSizePixel()));
 
-                                               aDist.setX(std::min(100.0, 
aDist.getX()));
-                                               aDist.setY(std::min(100.0, 
aDist.getY()));
+                                               aDist.setX(std::max(100.0, 
aDist.getX()));
+                                               aDist.setY(std::max(100.0, 
aDist.getY()));
 
                                                aMove *= aDist;
                                        }

Modified: 
openoffice/branches/alg/aw080/main/svx/inc/svx/sdr/properties/connectorproperties.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/inc/svx/sdr/properties/connectorproperties.hxx?rev=1543517&r1=1543516&r2=1543517&view=diff
==============================================================================
--- 
openoffice/branches/alg/aw080/main/svx/inc/svx/sdr/properties/connectorproperties.hxx
 (original)
+++ 
openoffice/branches/alg/aw080/main/svx/inc/svx/sdr/properties/connectorproperties.hxx
 Tue Nov 19 17:47:11 2013
@@ -56,6 +56,9 @@ namespace sdr
 
                        // set a new StyleSheet and broadcast
                        virtual void SetStyleSheet(SfxStyleSheet* 
pNewStyleSheet, bool bDontRemoveHardAttr);
+
+            // This is the notifyer from SfxListener
+            virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
                };
        } // end of namespace properties
 } // end of namespace sdr

Modified: openoffice/branches/alg/aw080/main/svx/inc/svx/svdoedge.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/inc/svx/svdoedge.hxx?rev=1543517&r1=1543516&r2=1543517&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/svx/inc/svx/svdoedge.hxx (original)
+++ openoffice/branches/alg/aw080/main/svx/inc/svx/svdoedge.hxx Tue Nov 19 
17:47:11 2013
@@ -32,6 +32,7 @@
 namespace sdr { namespace properties { class ConnectorProperties; }}
 class SdrObjConnection;
 class SdrEdgeInfoRec;
+
 enum SdrEdgeLineCode 
 {
     OBJ1LINE2,
@@ -42,24 +43,6 @@ enum SdrEdgeLineCode 
 };
 
 
////////////////////////////////////////////////////////////////////////////////////////////////////
-// SdrEdgeObjGeoData
-
-class SdrEdgeObjGeoData : public SdrObjGeoData
-{
-public:
-    SdrObjConnection*           mpCon1;  // Verbindungszustand des 
Linienanfangs
-    SdrObjConnection*           mpCon2;  // Verbindungszustand des Linienendes
-    basegfx::B2DPolygon         maEdgeTrack;
-    SdrEdgeInfoRec*             mpEdgeInfo;
-
-    /// bitfield
-    bool                        mbEdgeTrackUserDefined : 1;
-
-    SdrEdgeObjGeoData();
-    virtual ~SdrEdgeObjGeoData();
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
 // SdrEdgeObj
 
 class SVX_DLLPUBLIC SdrEdgeObj : public SdrTextObj
@@ -83,21 +66,23 @@ private:
     SdrEdgeInfoRec*             mpEdgeInfo;
 
     /// bitfield
+    /// defines if this edge was set from external and thus is defined by
+    /// user; this mode is used for compatibility with other file formats.
+    /// This state is not editable; any change on geometry data will reset
+    /// this flag
     bool                        mbEdgeTrackUserDefined : 1;
 
-    // #109007#
     // Bool to allow supporession of default connects at object
     // inside test (HitTest) and object center test (see FindConnector())
     bool                        mbSuppressDefaultConnect : 1;
 
-    // #110649#
     // Flag value for avoiding death loops when calculating BoundRects
     // from circularly connected connectors. A coloring algorythm is used
     // here. When the GetCurrentBoundRect() calculation of a SdrEdgeObj
     // is running, the flag is set, else it is always sal_False.
     unsigned                    mbBoundRectCalculationRunning : 1;
 
-    // #123048# need to remember if layouting was suppressed before to get
+    // need to remember if layouting was suppressed before to get
     // to a correct state for first real layouting
     unsigned                    mbSuppressed : 1;
 
@@ -134,14 +119,11 @@ protected:
     virtual void copyDataFromSdrObject(const SdrObject& rSource);
 
 public:
-    // check if rCandidate is a listener (one of the SdrObjConnections) and
-    // if yes, return the owner of the SdrObjConnection
+    // check if rCandidate is a listener (in one of the SdrObjConnections) and
+    // if yes, return the owner of the SdrObjConnection and thus the SdrEdgeObj
+    // which is connected to the given listener (which probably is a SdrObject)
     static SdrEdgeObj* checkIfUsesListener(SfxListener& rCandidate);
 
-    // called from SdrObjConnection child when a SFX_HINT_DATACHANGED is 
detected
-    // from a connected SdrObject
-    void StyleSheetChanged();
-
     // #109007# Interface to default connect suppression
     void SetSuppressDefaultConnect(sal_Bool bNew) { mbSuppressDefaultConnect = 
bNew; }
     sal_Bool GetSuppressDefaultConnect() const { return 
mbSuppressDefaultConnect; }
@@ -152,6 +134,9 @@ public:
     /// create a copy, evtl. with a different target model (if given)
     virtual SdrObject* CloneSdrObject(SdrModel* pTargetModel = 0) const;
 
+    // react on model/page change
+    virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage);
+
     virtual bool IsClosedObj() const;
 
     SdrEdgeObj(SdrModel& rSdrModel);
@@ -159,15 +144,15 @@ public:
     virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
     virtual sal_uInt16 GetObjIdentifier() const;
 
-    void SetEdgeTrackDirty(); // { mbEdgeTrackDirty = true; }
+    void SetEdgeTrackDirty();
 
-    // bTail=true: Linienanfang, sonst LinienEnde
-    // pObj=NULL -> Disconnect
+    // bTail = true: connector start, else connector end
+    // no SdrObject given: disconnect
     void ConnectToSdrObject(bool bTail, SdrObject* pObj = 0);
     SdrObject* GetSdrObjectConnection(bool bTail) const;
     bool CheckSdrObjectConnection(bool bTail) const;
 
-    /// interface to hold a user-defined EdgeTrack
+    /// interface to hold a user-defined EdgeTrack (see mbEdgeTrackUserDefined)
     void SetEdgeTrackPath( const basegfx::B2DPolygon& rPoly );
     basegfx::B2DPolygon GetEdgeTrackPath() const;
 
@@ -193,19 +178,24 @@ public:
     // FullDrag support
     virtual SdrObject* getFullDragClone() const;
 
+    // creation support
     virtual bool BegCreate(SdrDragStat& rStat);
     virtual bool MovCreate(SdrDragStat& rStat);
     virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
     virtual bool BckCreate(SdrDragStat& rStat);
-
     virtual void BrkCreate(SdrDragStat& rStat);
     virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) 
const;
+
+    // convert to polygon support
     virtual SdrObject* DoConvertToPolygonObject(bool bBezier, bool bAddText) 
const;
 
+    // snap point support
     virtual sal_uInt32 GetSnapPointCount() const;
     virtual basegfx::B2DPoint GetSnapPoint(sal_uInt32 i) const;
+
     virtual bool IsPolygonObject() const;
 
+    // GeoData (Undo/Redo) support
     virtual SdrObjGeoData* NewGeoData() const;
     virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
     virtual void RestGeoData(const SdrObjGeoData& rGeo);

Modified: 
openoffice/branches/alg/aw080/main/svx/source/sdr/properties/connectorproperties.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/source/sdr/properties/connectorproperties.cxx?rev=1543517&r1=1543516&r2=1543517&view=diff
==============================================================================
--- 
openoffice/branches/alg/aw080/main/svx/source/sdr/properties/connectorproperties.cxx
 (original)
+++ 
openoffice/branches/alg/aw080/main/svx/source/sdr/properties/connectorproperties.cxx
 Tue Nov 19 17:47:11 2013
@@ -19,8 +19,6 @@
  * 
  *************************************************************/
 
-
-
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_svx.hxx"
 #include <svx/sdr/properties/connectorproperties.hxx>
@@ -29,6 +27,7 @@
 #include <svx/svddef.hxx>
 #include <editeng/eeitem.hxx>
 #include <svx/svdoedge.hxx>
+#include <svl/smplhint.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -96,6 +95,23 @@ namespace sdr
                        // local changes
                        rObj.ImpSetAttrToEdgeInfo();
                }
+
+        void ConnectorProperties::Notify(SfxBroadcaster& rBC, const SfxHint& 
rHint)
+        {
+            // call parent
+            TextProperties::Notify(rBC, rHint);
+
+            // local changes (could need more checks, but is not expensive)
+            const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* 
>(&rHint);
+
+            if(pSimple && SFX_HINT_DATACHANGED == pSimple->GetId())
+            {
+                // style sheet change, copy evtl. changed style items to 
EdgeInfo
+                SdrEdgeObj& rObj = (SdrEdgeObj&)GetSdrObject();
+
+                rObj.ImpSetAttrToEdgeInfo();
+            }
+        }
        } // end of namespace properties
 } // end of namespace sdr
 

Modified: openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx?rev=1543517&r1=1543516&r2=1543517&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx (original)
+++ openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx Tue Nov 
19 17:47:11 2013
@@ -70,9 +70,11 @@ private:
     sal_uInt32                  mnConnectorId;          // Connector ID
 
     /// bitfield
+    /// when set, connector will find best connection itself
     bool                        mbBestConnection : 1;
-    bool                        mbBestVertex : 1;
-    bool                        mbAutoVertex : 1;       // connected to 
automatic gluepoint
+
+    // connected to automatic gluepoint (AutoGluePoint)
+    bool                        mbAutoVertex : 1;
 
 protected:
     // object notifies; e.g. connected SDrObjects changed
@@ -97,16 +99,23 @@ public:
     /// assignment operator; will not copy mpOwner
     SdrObjConnection& operator=(const SdrObjConnection&);
 
+    /// called when page access of owner changes (owner gets removed/
+    /// inserted, e.g deleted but put to undo stack)
+    void ownerPageChange();
+
     // get a copy of the GluePoint referenced; returns true if 
     // a GluePoint is referenced and when it got copied to rGP
     bool TakeGluePoint(sdr::glue::GluePoint& rGP) const;
 
+    // allow SdrEdgeObj to adapt position in two cases: user defined
+    // EdgeTrack or result of BestConnection being available
+    void adaptBestConnectionPosition(const basegfx::B2DPoint& rPosition);
+
     // data write access
     void SetPosition(const basegfx::B2DPoint& rPosition);
     void SetConnectedSdrObject(SdrObject* pConnectedSdrObject);
     void SetConnectorID(sal_uInt32 nNew);
     void setBestConnection(bool bNew) { mbBestConnection = bNew; }
-    void setBestVertex(bool bNew) { mbBestVertex = bNew; }
     void setAutoVertex(bool bNew) { mbAutoVertex = bNew; }
 
     // data read access
@@ -115,7 +124,6 @@ public:
     SdrObject* GetConnectedSdrObject() const { return mpConnectedSdrObject; }
     sal_uInt32 GetConnectorId() const { return mnConnectorId; };
     bool IsBestConnection() const { return mbBestConnection; };
-    bool IsBestVertex() const { return mbBestVertex; };
     bool IsAutoVertex() const { return mbAutoVertex; };
 };
 
@@ -132,7 +140,7 @@ void SdrObjConnection::Notify(SfxBroadca
             {
                 const SdrHintKind eSdrHintKind(pBase->GetSdrHintKind());
 
-                // on object delete and/or object removed from page, break 
linkage
+                // object listening to is delete and/or removed from page, 
break linkage
                 if(HINT_SDROBJECTDYING == eSdrHintKind || HINT_OBJREMOVED == 
eSdrHintKind)
                 {
                     EndListening(*mpConnectedSdrObject);
@@ -145,14 +153,6 @@ void SdrObjConnection::Notify(SfxBroadca
                 checkPositionFromObject();
             }
         }
-
-        const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* 
>(&rHint);
-
-        if(pSimple && SFX_HINT_DATACHANGED == pSimple->GetId())
-        {
-            // StyleSheet change on listened object, get the evtl. changed 
parameters for connectors
-            mpOwner->StyleSheetChanged(); 
-        }
     }
 }
 
@@ -217,7 +217,6 @@ SdrObjConnection::SdrObjConnection(SdrEd
     mpConnectedSdrObject(0),
     mnConnectorId(0),
     mbBestConnection(true),
-    mbBestVertex(true),
     mbAutoVertex(false)
 { 
     SetConnectedSdrObject(mpConnectedSdrObject);
@@ -230,7 +229,6 @@ SdrObjConnection::SdrObjConnection(const
     mpConnectedSdrObject(rSource.mpConnectedSdrObject),
     mnConnectorId(rSource.mnConnectorId),
     mbBestConnection(rSource.mbBestConnection),
-    mbBestVertex(rSource.mbBestVertex),
     mbAutoVertex(rSource.mbAutoVertex)
 {
 }
@@ -254,10 +252,9 @@ SdrObjConnection& SdrObjConnection::oper
     mpConnectedSdrObject = rSource.mpConnectedSdrObject;
     mnConnectorId = rSource.mnConnectorId;
     mbBestConnection = rSource.mbBestConnection;
-    mbBestVertex = rSource.mbBestVertex;
     mbAutoVertex = rSource.mbAutoVertex;
 
-    if(mpOwner && mpConnectedSdrObject)
+    if(mpOwner && mpConnectedSdrObject && mpOwner->getSdrPageFromSdrObject())
     {
         StartListening(*mpConnectedSdrObject);
     }
@@ -266,6 +263,18 @@ SdrObjConnection& SdrObjConnection::oper
     return *this;
 }
 
+void SdrObjConnection::adaptBestConnectionPosition(const basegfx::B2DPoint& 
rPosition)
+{
+    if(IsBestConnection() || (mpOwner && mpOwner->mbEdgeTrackUserDefined))
+    {
+        maPosition = rPosition;
+    }
+    else
+    {
+        OSL_ENSURE(false, "SdrObjConnection::adaptBestConnectionPosition only 
allowed for BestConnection or UserDefined (!)");
+    }
+}
+
 void SdrObjConnection::SetPosition(const basegfx::B2DPoint& rPosition)
 {
     basegfx::B2DPoint aNewPosition(rPosition);
@@ -297,7 +306,7 @@ void SdrObjConnection::SetConnectedSdrOb
 
         mpConnectedSdrObject = pConnectedSdrObject;
 
-        if(mpOwner && mpConnectedSdrObject)
+        if(mpOwner && mpConnectedSdrObject && 
mpOwner->getSdrPageFromSdrObject())
         {
             StartListening(*mpConnectedSdrObject);
         }
@@ -315,6 +324,21 @@ void SdrObjConnection::SetConnectorID(sa
     }
 }
 
+void SdrObjConnection::ownerPageChange()
+{
+    if(mpOwner && mpConnectedSdrObject)
+    {
+        if(mpOwner->getSdrPageFromSdrObject())
+        {
+            StartListening(*mpConnectedSdrObject);
+        }
+        else
+        {
+            EndListening(*mpConnectedSdrObject);
+        }
+    }
+}
+
 bool SdrObjConnection::TakeGluePoint(sdr::glue::GluePoint& rGP) const
 {
     if(mpConnectedSdrObject) 
@@ -388,6 +412,9 @@ public:
     long ImpGetLineVersatz(SdrEdgeLineCode eLineCode, sal_uInt32 nPointCount) 
const;
     void ImpResetUserDistances() { aObj1Line2 = aObj1Line3 = aObj2Line2 = 
aObj2Line3 = aMiddleLine = basegfx::B2DPoint(); }
     bool ImpUsesUserDistances() const;
+
+    bool operator==(const SdrEdgeInfoRec& rCompare) const;
+    bool operator!=(const SdrEdgeInfoRec& rCompare) const { return 
!operator==(rCompare); }
 };
 
 basegfx::B2DPoint& SdrEdgeInfoRec::ImpGetLineVersatzPoint(SdrEdgeLineCode 
eLineCode)
@@ -473,16 +500,45 @@ bool SdrEdgeInfoRec::ImpUsesUserDistance
     return false;
 }
 
+bool SdrEdgeInfoRec::operator==(const SdrEdgeInfoRec& rCompare) const
+{
+    return aObj1Line2.equal(rCompare.aObj1Line2)
+        && aObj1Line3.equal(rCompare.aObj1Line3)
+        && aObj2Line2.equal(rCompare.aObj2Line2)
+        && aObj2Line3.equal(rCompare.aObj2Line3)
+        && aMiddleLine.equal(rCompare.aMiddleLine)
+        && nAngle1 == rCompare.nAngle1
+        && nAngle2 == rCompare.nAngle2
+        && nObj1Lines == rCompare.nObj1Lines
+        && nObj2Lines == rCompare.nObj2Lines
+        && nMiddleLine == rCompare.nMiddleLine
+        && cOrthoForm == rCompare.cOrthoForm;
+}
+
 
////////////////////////////////////////////////////////////////////////////////////////////////////
 
-SdrEdgeObjGeoData::SdrEdgeObjGeoData()
-:   mpCon1(new SdrObjConnection(0)),
-    mpCon2(new SdrObjConnection(0)),
-    maEdgeTrack(),
-    mpEdgeInfo(new SdrEdgeInfoRec()),
-    mbEdgeTrackUserDefined(false)
+class SdrEdgeObjGeoData : public SdrObjGeoData
 {
-}
+public:
+    SdrObjConnection*           mpCon1;  // Verbindungszustand des 
Linienanfangs
+    SdrObjConnection*           mpCon2;  // Verbindungszustand des Linienendes
+    basegfx::B2DPolygon         maEdgeTrack;
+    SdrEdgeInfoRec*             mpEdgeInfo;
+
+    /// bitfield
+    bool                        mbEdgeTrackUserDefined : 1;
+
+    SdrEdgeObjGeoData()
+    :   mpCon1(new SdrObjConnection(0)),
+        mpCon2(new SdrObjConnection(0)),
+        maEdgeTrack(),
+        mpEdgeInfo(new SdrEdgeInfoRec()),
+        mbEdgeTrackUserDefined(false)
+    {
+    }
+
+    virtual ~SdrEdgeObjGeoData();
+};
 
 SdrEdgeObjGeoData::~SdrEdgeObjGeoData()
 {
@@ -778,11 +834,11 @@ namespace
                 }
             }
         }
-    #ifdef DBG_UTIL
+#ifdef DBG_UTIL
         if (aXP.GetPointCount()>4) {
             DBG_ERROR("SdrEdgeObj::impOldCalcObjToCenter(): Polygon hat mehr 
als 4 Punkte!");
         }
-    #endif
+#endif
         return aXP;
     }
 
@@ -1597,6 +1653,19 @@ SdrObject* SdrEdgeObj::CloneSdrObject(Sd
     return pClone;
 }
 
+void SdrEdgeObj::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage)
+{
+    if(pOldPage != pNewPage)
+    {
+        // call parent
+        SdrTextObj::handlePageChange(pOldPage, pNewPage);
+
+        // check broadcasters; when we are not inserted we do not need 
broadcasters
+        mpCon1->ownerPageChange();
+        mpCon2->ownerPageChange();
+    }
+}
+
 bool SdrEdgeObj::IsClosedObj() const
 {
     return false;
@@ -1842,51 +1911,60 @@ bool SdrEdgeObj::CheckSdrObjectConnectio
 
     if(!pConnectedNode)
     {
+        // not connected to any object -> no valid connection
         return false;
     }
 
+    const SdrObjConnection& rCon(bTail ? *mpCon1 : *mpCon2);
     const sdr::glue::GluePointProvider& rProvider = 
pConnectedNode->GetGluePointProvider();
 
-    if(rProvider.hasUserGluePoints())
+    if(rCon.IsBestConnection() && (rProvider.hasUserGluePoints() || 
rProvider.getAutoGluePointCount()))
+    {
+        // best connection is always valid when there are any GluePoints
+        return true;
+    }
+
+    const basegfx::B2DPoint aCurrentPosition(rCon.GetPosition());
+
+    if(rCon.IsAutoVertex())
+    {
+        // AutoGluePoints
+        const sal_uInt32 nConAnz(rProvider.getAutoGluePointCount());
+
+        for(sal_uInt32 i(0); i < nConAnz; i++) 
+        {
+            const sdr::glue::GluePoint 
aPt(rProvider.getAutoGluePointByIndex(i));
+            const basegfx::B2DPoint 
aGluePos(pConnectedNode->getSdrObjectTransformation() * aPt.getUnitPosition());
+
+            if(aCurrentPosition.equal(aGluePos))
+            {
+                return true;
+            }
+        }
+    }
+    else
     {
+        // User-Defined (or CustomShape) GluePoints
         const sdr::glue::GluePointVector 
aGluePointVector(rProvider.getUserGluePointVector());
         const sal_uInt32 nConAnz(aGluePointVector.size());
-        const sal_uInt32 nGesAnz(nConAnz + rProvider.getAutoGluePointCount());
-        const SdrObjConnection& rCon(bTail ? *mpCon1 : *mpCon2);
-        const basegfx::B2DPoint aCurrentPosition(rCon.GetPosition());
-
-        for(sal_uInt32 i(0); i < nGesAnz; i++) 
-        {
-            if(i < nConAnz) 
-            { 
-                // UserDefined or CustomShape
-                const sdr::glue::GluePoint* pCandidate = aGluePointVector[i];
 
-                if(pCandidate)
-                {
-                    const basegfx::B2DPoint 
aGluePos(pConnectedNode->getSdrObjectTransformation() * 
pCandidate->getUnitPosition());
+        for(sal_uInt32 i(0); i < nConAnz; i++) 
+        {
+            const sdr::glue::GluePoint* pCandidate = aGluePointVector[i];
 
-                    if(aCurrentPosition.equal(aGluePos))
-                    {
-                        return true;
-                    }
-                }
-                else
-                {
-                    OSL_ENSURE(false, "Got sdr::glue::PointVector with emty 
entries (!)");
-                }
-            } 
-            else //if (i<nConAnz+4) 
-            { 
-                // Vertex
-                const sdr::glue::GluePoint 
aPt(rProvider.getAutoGluePointByIndex(i - nConAnz));
-                const basegfx::B2DPoint 
aGluePos(pConnectedNode->getSdrObjectTransformation() * aPt.getUnitPosition());
+            if(pCandidate)
+            {
+                const basegfx::B2DPoint 
aGluePos(pConnectedNode->getSdrObjectTransformation() * 
pCandidate->getUnitPosition());
 
                 if(aCurrentPosition.equal(aGluePos))
                 {
                     return true;
                 }
             }
+            else
+            {
+                OSL_ENSURE(false, "Got sdr::glue::PointVector with emty 
entries (!)");
+            }
         }
     }
 
@@ -1953,12 +2031,47 @@ void SdrEdgeObj::ImpRecalcEdgeTrack()
         // SdrEdgeObj BoundRect calculations
         mbBoundRectCalculationRunning = true;
 
+        // remember current SdrEdgeInfoRec and new polygon
+        const SdrEdgeInfoRec aPreserved(*mpEdgeInfo);
+        const basegfx::B2DPolygon aNew(ImpCalcEdgeTrack(*mpCon1, *mpCon2, 
mpEdgeInfo, 0, 0));
+        bool bBroadcastChange(false);
+
+        if(aNew != maEdgeTrack)
+        {
+            maEdgeTrack = aNew;
+
+            // if connections are in 'BestConnection' mode, update their 
oposition to the
+            // computed one, just to make sure when that data is fetched from 
the connection
+            // itself that it is correct
+            if(maEdgeTrack.count())
+            {
+                const basegfx::B2DPoint aStart(maEdgeTrack.getB2DPoint(0));
+                const basegfx::B2DPoint 
aEnd(maEdgeTrack.getB2DPoint(maEdgeTrack.count() - 1));
+
+                if(mpCon1->IsBestConnection())
+                {
+                    mpCon1->adaptBestConnectionPosition(aStart);
+                }
+
+                if(mpCon2->IsBestConnection())
+                {
+                    mpCon2->adaptBestConnectionPosition(aEnd);
+                }
+            }
+
+            bBroadcastChange = true;
+        }
+
+        if(aPreserved != *mpEdgeInfo)
+        {
+            ImpSetEdgeInfoToAttr();
+            bBroadcastChange = true;
+        }
+
+        if(bBroadcastChange)
         {
             // use local scope to trigger locally
             const SdrObjectChangeBroadcaster 
aSdrObjectChangeBroadcaster(*this);
-
-            maEdgeTrack = ImpCalcEdgeTrack(*mpCon1, *mpCon2, mpEdgeInfo, 0, 0);
-            ImpSetEdgeInfoToAttr(); // Die Werte aus mpEdgeInfo in den Pool 
kopieren
         }
 
         // #110649#
@@ -1984,7 +2097,7 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
     basegfx::B2DRange aBoundRange2;
     basegfx::B2DRange aBewareRange1;
     basegfx::B2DRange aBewareRange2;
-    const const SdrPage* pOwningPage = getSdrPageFromSdrObject();
+    const SdrPage* pOwningPage = getSdrPageFromSdrObject();
     const bool bCon1(rCon1.GetConnectedSdrObject() && (!pOwningPage || 
rCon1.GetConnectedSdrObject()->getSdrPageFromSdrObject() == pOwningPage));
     const bool bCon2(rCon2.GetConnectedSdrObject() && (!pOwningPage || 
rCon2.GetConnectedSdrObject()->getSdrPageFromSdrObject() == pOwningPage));
     const SfxItemSet& rSet = GetObjectItemSet();
@@ -2051,8 +2164,8 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
 
     sal_uInt32 nBestQual=0xFFFFFFFF;
     SdrEdgeInfoRec aBestInfo;
-    const bool bAuto1(bCon1 && rCon1.IsBestVertex());
-    const bool bAuto2(bCon2 && rCon2.IsBestVertex());
+    const bool bAuto1(bCon1 && rCon1.IsBestConnection());
+    const bool bAuto2(bCon2 && rCon2.IsBestConnection());
 
     if(bAuto1) 
     {
@@ -2203,16 +2316,6 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
     return aRetval;
 }
 
-void SdrEdgeObj::StyleSheetChanged()
-{
-    if(mpCon1->GetConnectedSdrObject() || mpCon2->GetConnectedSdrObject())
-    {
-        ImpSetAttrToEdgeInfo(); 
-        SetEdgeTrackDirty();
-        SetChanged();
-    }
-}
-
 void SdrEdgeObj::TakeObjNameSingul(XubString& rName) const
 {
     rName=ImpGetResStr(STR_ObjNameSingulEDGE);
@@ -2245,10 +2348,10 @@ void SdrEdgeObj::SetEdgeTrackPath(const 
         mbEdgeTrackUserDefined = true;
 
         mpCon1->SetConnectedSdrObject(0);
-        mpCon1->SetPosition(maEdgeTrack.getB2DPoint(0));
+        mpCon1->adaptBestConnectionPosition(maEdgeTrack.getB2DPoint(0));
 
         mpCon2->SetConnectedSdrObject(0);
-        mpCon2->SetPosition(maEdgeTrack.getB2DPoint(maEdgeTrack.count() - 1));
+        
mpCon2->adaptBestConnectionPosition(maEdgeTrack.getB2DPoint(maEdgeTrack.count() 
- 1));
     }
     else
     {
@@ -2345,7 +2448,7 @@ SdrHdl* SdrEdgeObj::impOldGetHdl(SdrHdlL
         {
             pHdl = new ImpEdgeHdl(rHdlList, *this, HDL_POLY, 
mpCon1->GetPosition());
 
-            if(mpCon1->GetConnectedSdrObject() && mpCon1->IsBestVertex()) 
+            if(mpCon1->GetConnectedSdrObject() && mpCon1->IsBestConnection()) 
             {
                 pHdl->Set1PixMore(true);
             }
@@ -2354,7 +2457,7 @@ SdrHdl* SdrEdgeObj::impOldGetHdl(SdrHdlL
         {
             pHdl = new ImpEdgeHdl(rHdlList, *this, HDL_POLY, 
mpCon2->GetPosition());
 
-            if(mpCon2->GetConnectedSdrObject() && mpCon2->IsBestVertex()) 
+            if(mpCon2->GetConnectedSdrObject() && mpCon2->IsBestConnection()) 
             {
                 pHdl->Set1PixMore(true);
             }
@@ -2527,7 +2630,6 @@ bool SdrEdgeObj::applySpecialDrag(SdrDra
             rDraggedOne.SetPosition(rDragStat.GetNow());
             rDraggedOne.SetConnectorID(nID);
             rDraggedOne.setBestConnection(bBest);
-            rDraggedOne.setBestVertex(bBest);
             rDraggedOne.setAutoVertex(bAuto);
             rDraggedOne.SetConnectedSdrObject(pNewContact);
 
@@ -2573,6 +2675,10 @@ bool SdrEdgeObj::applySpecialDrag(SdrDra
         // hide connect marker helper again when original gets changed.
         // This happens at the end of the interaction
         rDragStat.GetSdrViewFromSdrDragStat().HideConnectMarker();
+
+        // modified is needed at the end of interaction, too
+        SetEdgeTrackDirty();
+        SetChanged();
     }
 
     return true;
@@ -2639,12 +2745,12 @@ basegfx::B2DPolygon SdrEdgeObj::CreateCo
         basegfx::B2DPoint aPt1(mpCon1->GetPosition());
         basegfx::B2DPoint aPt2(mpCon2->GetPosition());
         
-        if(mpCon1->GetConnectedSdrObject() && (mpCon1->IsBestConnection() || 
mpCon1->IsBestVertex())) 
+        if(mpCon1->GetConnectedSdrObject() && mpCon1->IsBestConnection()) 
         {
             aPt1 = 
mpCon1->GetConnectedSdrObject()->getSdrObjectTransformation() * 
basegfx::B2DPoint(0.5, 0.5);
         }
 
-        if(mpCon2->GetConnectedSdrObject() && (mpCon2->IsBestConnection() || 
mpCon2->IsBestVertex())) 
+        if(mpCon2->GetConnectedSdrObject() && mpCon2->IsBestConnection()) 
         {
             aPt2 = 
mpCon2->GetConnectedSdrObject()->getSdrObjectTransformation() * 
basegfx::B2DPoint(0.5, 0.5);
         }
@@ -2686,7 +2792,13 @@ bool SdrEdgeObj::BegCreate(SdrDragStat& 
         bool bBest(false);
         bool bAuto(false);
 
-        
mpCon1->SetConnectedSdrObject(rSdrView.FindConnector(rDragStat.GetStart(), nID, 
bBest, bAuto, this));
+        // look for new connection
+        SdrObject* pNewContact = rSdrView.FindConnector(rDragStat.GetStart(), 
nID, bBest, bAuto, this);
+
+        mpCon1->SetConnectorID(nID);
+        mpCon1->setBestConnection(bBest);
+        mpCon1->setAutoVertex(bAuto);
+        mpCon1->SetConnectedSdrObject(pNewContact);
     }
 
     return true;
@@ -2707,8 +2819,15 @@ bool SdrEdgeObj::MovCreate(SdrDragStat& 
         bool bBest(false);
         bool bAuto(false);
 
-        
mpCon2->SetConnectedSdrObject(rSdrView.FindConnector(rDragStat.GetNow(), nID, 
bBest, bAuto, this));
-        
rDragStat.GetSdrViewFromSdrDragStat().SetConnectMarker(mpCon2->GetConnectedSdrObject());
+        // look for new connection
+        SdrObject* pNewContact = rSdrView.FindConnector(rDragStat.GetNow(), 
nID, bBest, bAuto, this);
+
+        mpCon2->SetConnectorID(nID);
+        mpCon2->setBestConnection(bBest);
+        mpCon2->setAutoVertex(bAuto);
+        mpCon2->SetConnectedSdrObject(pNewContact);
+
+        rDragStat.GetSdrViewFromSdrDragStat().SetConnectMarker(pNewContact);
     }
 
     return true;
@@ -2788,10 +2907,10 @@ void SdrEdgeObj::setSdrObjectTransformat
                 maEdgeTrack.transform(aCompleteTransform);
 
                 mpCon1->SetConnectedSdrObject(0);
-                mpCon1->SetPosition(maEdgeTrack.getB2DPoint(0));
+                
mpCon1->adaptBestConnectionPosition(maEdgeTrack.getB2DPoint(0));
 
                 mpCon2->SetConnectedSdrObject(0);
-                
mpCon2->SetPosition(maEdgeTrack.getB2DPoint(maEdgeTrack.count() - 1));
+                
mpCon2->adaptBestConnectionPosition(maEdgeTrack.getB2DPoint(maEdgeTrack.count() 
- 1));
             }
             else
             {
@@ -2967,7 +3086,6 @@ void SdrEdgeObj::setGluePointIndex(bool 
 
     rConn1.SetConnectorID(nIndex);
     rConn1.setBestConnection(nIndex < 0);
-    rConn1.setBestVertex(nIndex < 0);
     rConn1.setAutoVertex(nIndex >= 0 && nIndex <= 3);
 }
 


Reply via email to