LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdoedge.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 545 1483 36.7 %
Date: 2014-04-11 Functions: 39 96 40.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "svddrgm1.hxx"
      21             : #include "svx/svdglob.hxx"
      22             : #include "svx/svdstr.hrc"
      23             : 
      24             : #include <basegfx/matrix/b2dhommatrix.hxx>
      25             : #include <basegfx/polygon/b2dpolygon.hxx>
      26             : #include <basegfx/polygon/b2dpolygontools.hxx>
      27             : #include <editeng/eeitem.hxx>
      28             : #include <svl/smplhint.hxx>
      29             : #include <svl/style.hxx>
      30             : 
      31             : #include <svx/sdr/contact/viewcontactofsdredgeobj.hxx>
      32             : #include <svx/sdr/properties/connectorproperties.hxx>
      33             : #include <svx/sdrhittesthelper.hxx>
      34             : #include <svx/svddrag.hxx>
      35             : #include <svx/svddrgv.hxx>
      36             : #include <svx/svdetc.hxx>
      37             : #include <svx/svdhdl.hxx>
      38             : #include <svx/svdmodel.hxx>
      39             : #include <svx/svdoedge.hxx>
      40             : #include <svx/svdpage.hxx>
      41             : #include <svx/svdpagv.hxx>
      42             : #include <svx/svdpool.hxx>
      43             : #include <svx/svdtrans.hxx>
      44             : #include <svx/svdview.hxx>
      45             : #include <svx/sxekitm.hxx>
      46             : #include <svx/sxelditm.hxx>
      47             : #include <svx/sxenditm.hxx>
      48             : #include <svx/xpoly.hxx>
      49             : #include <svx/xpool.hxx>
      50             : 
      51             : 
      52             : 
      53          66 : SdrObjConnection::~SdrObjConnection()
      54             : {
      55          66 : }
      56             : 
      57          66 : void SdrObjConnection::ResetVars()
      58             : {
      59          66 :     pObj=NULL;
      60          66 :     nConId=0;
      61          66 :     nXDist=0;
      62          66 :     nYDist=0;
      63          66 :     bBestConn=true;
      64          66 :     bBestVertex=true;
      65          66 :     bXDistOvr=false;
      66          66 :     bYDistOvr=false;
      67          66 :     bAutoVertex=false;
      68          66 :     bAutoCorner=false;
      69          66 : }
      70             : 
      71           0 : bool SdrObjConnection::TakeGluePoint(SdrGluePoint& rGP, bool bSetAbsPos) const
      72             : {
      73           0 :     bool bRet = false;
      74           0 :     if (pObj!=NULL) { // one object has to be docked already!
      75           0 :         if (bAutoVertex) {
      76           0 :             rGP=pObj->GetVertexGluePoint(nConId);
      77           0 :             bRet = true;
      78           0 :         } else if (bAutoCorner) {
      79           0 :             rGP=pObj->GetCornerGluePoint(nConId);
      80           0 :             bRet = true;
      81             :         } else {
      82           0 :             const SdrGluePointList* pGPL=pObj->GetGluePointList();
      83           0 :             if (pGPL!=NULL) {
      84           0 :                 sal_uInt16 nNum=pGPL->FindGluePoint(nConId);
      85           0 :                 if (nNum!=SDRGLUEPOINT_NOTFOUND) {
      86           0 :                     rGP=(*pGPL)[nNum];
      87           0 :                     bRet = true;
      88             :                 }
      89             :             }
      90             :         }
      91             :     }
      92           0 :     if (bRet && bSetAbsPos) {
      93           0 :         Point aPt(rGP.GetAbsolutePos(*pObj));
      94           0 :         aPt+=aObjOfs;
      95           0 :         rGP.SetPos(aPt);
      96             :     }
      97           0 :     return bRet;
      98             : }
      99             : 
     100           0 : Point& SdrEdgeInfoRec::ImpGetLineVersatzPoint(SdrEdgeLineCode eLineCode)
     101             : {
     102           0 :     switch (eLineCode) {
     103           0 :         case OBJ1LINE2 : return aObj1Line2;
     104           0 :         case OBJ1LINE3 : return aObj1Line3;
     105           0 :         case OBJ2LINE2 : return aObj2Line2;
     106           0 :         case OBJ2LINE3 : return aObj2Line3;
     107           0 :         case MIDDLELINE: return aMiddleLine;
     108             :     } // switch
     109           0 :     return aMiddleLine;
     110             : }
     111             : 
     112          16 : sal_uInt16 SdrEdgeInfoRec::ImpGetPolyIdx(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const
     113             : {
     114          16 :     switch (eLineCode) {
     115           4 :         case OBJ1LINE2 : return 1;
     116           0 :         case OBJ1LINE3 : return 2;
     117           4 :         case OBJ2LINE2 : return rXP.GetPointCount()-3;
     118           0 :         case OBJ2LINE3 : return rXP.GetPointCount()-4;
     119           8 :         case MIDDLELINE: return nMiddleLine;
     120             :     } // switch
     121           0 :     return 0;
     122             : }
     123             : 
     124           8 : bool SdrEdgeInfoRec::ImpIsHorzLine(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const
     125             : {
     126           8 :     sal_uInt16 nIdx=ImpGetPolyIdx(eLineCode,rXP);
     127           8 :     bool bHorz=nAngle1==0 || nAngle1==18000;
     128           8 :     if (eLineCode==OBJ2LINE2 || eLineCode==OBJ2LINE3) {
     129           2 :         nIdx=rXP.GetPointCount()-nIdx;
     130           2 :         bHorz=nAngle2==0 || nAngle2==18000;
     131             :     }
     132           8 :     if ((nIdx & 1)==1) bHorz=!bHorz;
     133           8 :     return bHorz;
     134             : }
     135             : 
     136           0 : void SdrEdgeInfoRec::ImpSetLineVersatz(SdrEdgeLineCode eLineCode, const XPolygon& rXP, long nVal)
     137             : {
     138           0 :     Point& rPt=ImpGetLineVersatzPoint(eLineCode);
     139           0 :     if (ImpIsHorzLine(eLineCode,rXP)) rPt.Y()=nVal;
     140           0 :     else rPt.X()=nVal;
     141           0 : }
     142             : 
     143           0 : long SdrEdgeInfoRec::ImpGetLineVersatz(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const
     144             : {
     145           0 :     const Point& rPt=ImpGetLineVersatzPoint(eLineCode);
     146           0 :     if (ImpIsHorzLine(eLineCode,rXP)) return rPt.Y();
     147           0 :     else return rPt.X();
     148             : }
     149             : 
     150             : 
     151             : // BaseProperties section
     152             : 
     153          33 : sdr::properties::BaseProperties* SdrEdgeObj::CreateObjectSpecificProperties()
     154             : {
     155          33 :     return new sdr::properties::ConnectorProperties(*this);
     156             : }
     157             : 
     158             : 
     159             : // DrawContact section
     160             : 
     161          33 : sdr::contact::ViewContact* SdrEdgeObj::CreateObjectSpecificViewContact()
     162             : {
     163          33 :     return new sdr::contact::ViewContactOfSdrEdgeObj(*this);
     164             : }
     165             : 
     166             : 
     167             : 
     168       41003 : TYPEINIT1(SdrEdgeObj,SdrTextObj);
     169             : 
     170          33 : SdrEdgeObj::SdrEdgeObj()
     171             : :   SdrTextObj(),
     172             :     nNotifyingCount(0),
     173             :     bEdgeTrackDirty(false),
     174             :     bEdgeTrackUserDefined(false),
     175             :     // Default is to allow default connects
     176             :     mbSuppressDefaultConnect(false),
     177             :     mbBoundRectCalculationRunning(false),
     178          33 :     mbSuppressed(false)
     179             : {
     180          33 :     bClosedObj=false;
     181          33 :     bIsEdge=true;
     182          33 :     pEdgeTrack=new XPolygon;
     183             : 
     184          33 : }
     185             : 
     186          99 : SdrEdgeObj::~SdrEdgeObj()
     187             : {
     188          33 :     DisconnectFromNode(true);
     189          33 :     DisconnectFromNode(false);
     190          33 :     delete pEdgeTrack;
     191          66 : }
     192             : 
     193         142 : void SdrEdgeObj::ImpSetAttrToEdgeInfo()
     194             : {
     195         142 :     const SfxItemSet& rSet = GetObjectItemSet();
     196         142 :     SdrEdgeKind eKind = ((SdrEdgeKindItem&)(rSet.Get(SDRATTR_EDGEKIND))).GetValue();
     197         142 :     sal_Int32 nVal1 = ((SdrEdgeLine1DeltaItem&)rSet.Get(SDRATTR_EDGELINE1DELTA)).GetValue();
     198         142 :     sal_Int32 nVal2 = ((SdrEdgeLine2DeltaItem&)rSet.Get(SDRATTR_EDGELINE2DELTA)).GetValue();
     199         142 :     sal_Int32 nVal3 = ((SdrEdgeLine3DeltaItem&)rSet.Get(SDRATTR_EDGELINE3DELTA)).GetValue();
     200             : 
     201         142 :     if(eKind == SDREDGE_ORTHOLINES || eKind == SDREDGE_BEZIER)
     202             :     {
     203          64 :         sal_Int32 nVals[3] = { nVal1, nVal2, nVal3 };
     204          64 :         sal_uInt16 n = 0;
     205             : 
     206          64 :         if(aEdgeInfo.nObj1Lines >= 2 && n < 3)
     207             :         {
     208           0 :             aEdgeInfo.ImpSetLineVersatz(OBJ1LINE2, *pEdgeTrack, nVals[n]);
     209           0 :             n++;
     210             :         }
     211             : 
     212          64 :         if(aEdgeInfo.nObj1Lines >= 3 && n < 3)
     213             :         {
     214           0 :             aEdgeInfo.ImpSetLineVersatz(OBJ1LINE3, *pEdgeTrack, nVals[n]);
     215           0 :             n++;
     216             :         }
     217             : 
     218          64 :         if(aEdgeInfo.nMiddleLine != 0xFFFF && n < 3)
     219             :         {
     220           0 :             aEdgeInfo.ImpSetLineVersatz(MIDDLELINE, *pEdgeTrack, nVals[n]);
     221           0 :             n++;
     222             :         }
     223             : 
     224          64 :         if(aEdgeInfo.nObj2Lines >= 3 && n < 3)
     225             :         {
     226           0 :             aEdgeInfo.ImpSetLineVersatz(OBJ2LINE3, *pEdgeTrack, nVals[n]);
     227           0 :             n++;
     228             :         }
     229             : 
     230          64 :         if(aEdgeInfo.nObj2Lines >= 2 && n < 3)
     231             :         {
     232           0 :             aEdgeInfo.ImpSetLineVersatz(OBJ2LINE2, *pEdgeTrack, nVals[n]);
     233           0 :             n++;
     234          64 :         }
     235             :     }
     236          78 :     else if(eKind == SDREDGE_THREELINES)
     237             :     {
     238           0 :         bool bHor1 = aEdgeInfo.nAngle1 == 0 || aEdgeInfo.nAngle1 == 18000;
     239           0 :         bool bHor2 = aEdgeInfo.nAngle2 == 0 || aEdgeInfo.nAngle2 == 18000;
     240             : 
     241           0 :         if(bHor1)
     242             :         {
     243           0 :             aEdgeInfo.aObj1Line2.X() = nVal1;
     244             :         }
     245             :         else
     246             :         {
     247           0 :             aEdgeInfo.aObj1Line2.Y() = nVal1;
     248             :         }
     249             : 
     250           0 :         if(bHor2)
     251             :         {
     252           0 :             aEdgeInfo.aObj2Line2.X() = nVal2;
     253             :         }
     254             :         else
     255             :         {
     256           0 :             aEdgeInfo.aObj2Line2.Y() = nVal2;
     257             :         }
     258             :     }
     259             : 
     260         142 :     ImpDirtyEdgeTrack();
     261         142 : }
     262             : 
     263          27 : void SdrEdgeObj::ImpSetEdgeInfoToAttr()
     264             : {
     265          27 :     const SfxItemSet& rSet = GetObjectItemSet();
     266          27 :     SdrEdgeKind eKind = ((SdrEdgeKindItem&)(rSet.Get(SDRATTR_EDGEKIND))).GetValue();
     267          27 :     sal_Int32 nValAnz = ((SdrEdgeLineDeltaAnzItem&)rSet.Get(SDRATTR_EDGELINEDELTAANZ)).GetValue();
     268          27 :     sal_Int32 nVal1 = ((SdrEdgeLine1DeltaItem&)rSet.Get(SDRATTR_EDGELINE1DELTA)).GetValue();
     269          27 :     sal_Int32 nVal2 = ((SdrEdgeLine2DeltaItem&)rSet.Get(SDRATTR_EDGELINE2DELTA)).GetValue();
     270          27 :     sal_Int32 nVal3 = ((SdrEdgeLine3DeltaItem&)rSet.Get(SDRATTR_EDGELINE3DELTA)).GetValue();
     271          27 :     sal_Int32 nVals[3] = { nVal1, nVal2, nVal3 };
     272          27 :     sal_uInt16 n = 0;
     273             : 
     274          27 :     if(eKind == SDREDGE_ORTHOLINES || eKind == SDREDGE_BEZIER)
     275             :     {
     276           1 :         if(aEdgeInfo.nObj1Lines >= 2 && n < 3)
     277             :         {
     278           0 :             nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ1LINE2, *pEdgeTrack);
     279           0 :             n++;
     280             :         }
     281             : 
     282           1 :         if(aEdgeInfo.nObj1Lines >= 3 && n < 3)
     283             :         {
     284           0 :             nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ1LINE3, *pEdgeTrack);
     285           0 :             n++;
     286             :         }
     287             : 
     288           1 :         if(aEdgeInfo.nMiddleLine != 0xFFFF && n < 3)
     289             :         {
     290           0 :             nVals[n] = aEdgeInfo.ImpGetLineVersatz(MIDDLELINE, *pEdgeTrack);
     291           0 :             n++;
     292             :         }
     293             : 
     294           1 :         if(aEdgeInfo.nObj2Lines >= 3 && n < 3)
     295             :         {
     296           0 :             nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ2LINE3, *pEdgeTrack);
     297           0 :             n++;
     298             :         }
     299             : 
     300           2 :         if(aEdgeInfo.nObj2Lines >= 2 && n < 3)
     301             :         {
     302           0 :             nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ2LINE2, *pEdgeTrack);
     303           0 :             n++;
     304             :         }
     305             :     }
     306          26 :     else if(eKind == SDREDGE_THREELINES)
     307             :     {
     308           0 :         bool bHor1 = aEdgeInfo.nAngle1 == 0 || aEdgeInfo.nAngle1 == 18000;
     309           0 :         bool bHor2 = aEdgeInfo.nAngle2 == 0 || aEdgeInfo.nAngle2 == 18000;
     310             : 
     311           0 :         n = 2;
     312           0 :         nVals[0] = bHor1 ? aEdgeInfo.aObj1Line2.X() : aEdgeInfo.aObj1Line2.Y();
     313           0 :         nVals[1] = bHor2 ? aEdgeInfo.aObj2Line2.X() : aEdgeInfo.aObj2Line2.Y();
     314             :     }
     315             : 
     316          27 :     if(n != nValAnz || nVals[0] != nVal1 || nVals[1] != nVal2 || nVals[2] != nVal3)
     317             :     {
     318             :         // Here no more notifying is necessary, just local changes are OK.
     319           0 :         if(n != nValAnz)
     320             :         {
     321           0 :             GetProperties().SetObjectItemDirect(SdrEdgeLineDeltaAnzItem(n));
     322             :         }
     323             : 
     324           0 :         if(nVals[0] != nVal1)
     325             :         {
     326           0 :             GetProperties().SetObjectItemDirect(SdrEdgeLine1DeltaItem(nVals[0]));
     327             :         }
     328             : 
     329           0 :         if(nVals[1] != nVal2)
     330             :         {
     331           0 :             GetProperties().SetObjectItemDirect(SdrEdgeLine2DeltaItem(nVals[1]));
     332             :         }
     333             : 
     334           0 :         if(nVals[2] != nVal3)
     335             :         {
     336           0 :             GetProperties().SetObjectItemDirect(SdrEdgeLine3DeltaItem(nVals[2]));
     337             :         }
     338             : 
     339           0 :         if(n < 3)
     340             :         {
     341           0 :             GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE3DELTA);
     342             :         }
     343             : 
     344           0 :         if(n < 2)
     345             :         {
     346           0 :             GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE2DELTA);
     347             :         }
     348             : 
     349           0 :         if(n < 1)
     350             :         {
     351           0 :             GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE1DELTA);
     352             :         }
     353             :     }
     354          27 : }
     355             : 
     356           0 : void SdrEdgeObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
     357             : {
     358             :     // #i54102# allow rotation, mirror and shear
     359           0 :     rInfo.bRotateFreeAllowed = true;
     360           0 :     rInfo.bRotate90Allowed = true;
     361           0 :     rInfo.bMirrorFreeAllowed = true;
     362           0 :     rInfo.bMirror45Allowed = true;
     363           0 :     rInfo.bMirror90Allowed = true;
     364           0 :     rInfo.bTransparenceAllowed = false;
     365           0 :     rInfo.bGradientAllowed = false;
     366           0 :     rInfo.bShearAllowed = true;
     367           0 :     rInfo.bEdgeRadiusAllowed = false;
     368           0 :     bool bCanConv=!HasText() || ImpCanConvTextToCurve();
     369           0 :     rInfo.bCanConvToPath=bCanConv;
     370           0 :     rInfo.bCanConvToPoly=bCanConv;
     371           0 :     rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
     372           0 : }
     373             : 
     374         244 : sal_uInt16 SdrEdgeObj::GetObjIdentifier() const
     375             : {
     376         244 :     return sal_uInt16(OBJ_EDGE);
     377             : }
     378             : 
     379          61 : const Rectangle& SdrEdgeObj::GetCurrentBoundRect() const
     380             : {
     381          61 :     if(bEdgeTrackDirty)
     382             :     {
     383          61 :         ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
     384             :     }
     385             : 
     386          61 :     return SdrTextObj::GetCurrentBoundRect();
     387             : }
     388             : 
     389         310 : const Rectangle& SdrEdgeObj::GetSnapRect() const
     390             : {
     391         310 :     if(bEdgeTrackDirty)
     392             :     {
     393          38 :         ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
     394             :     }
     395             : 
     396         310 :     return SdrTextObj::GetSnapRect();
     397             : }
     398             : 
     399          60 : void SdrEdgeObj::RecalcSnapRect()
     400             : {
     401          60 :     maSnapRect=pEdgeTrack->GetBoundRect();
     402          60 : }
     403             : 
     404           0 : void SdrEdgeObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
     405             : {
     406           0 :     rRect=GetSnapRect();
     407           0 : }
     408             : 
     409           0 : bool SdrEdgeObj::IsNode() const
     410             : {
     411           0 :     return true;
     412             : }
     413             : 
     414           0 : SdrGluePoint SdrEdgeObj::GetVertexGluePoint(sal_uInt16 nNum) const
     415             : {
     416           0 :     Point aPt;
     417           0 :     sal_uInt16 nPntAnz=pEdgeTrack->GetPointCount();
     418           0 :     if (nPntAnz>0)
     419             :     {
     420           0 :         Point aOfs = GetSnapRect().Center();
     421           0 :         if (nNum==2 && GetConnectedNode(true)==NULL) aPt=(*pEdgeTrack)[0];
     422           0 :         else if (nNum==3 && GetConnectedNode(false)==NULL) aPt=(*pEdgeTrack)[nPntAnz-1];
     423             :         else {
     424           0 :             if ((nPntAnz & 1) ==1) {
     425           0 :                 aPt=(*pEdgeTrack)[nPntAnz/2];
     426             :             } else {
     427           0 :                 Point aPt1((*pEdgeTrack)[nPntAnz/2-1]);
     428           0 :                 Point aPt2((*pEdgeTrack)[nPntAnz/2]);
     429           0 :                 aPt1+=aPt2;
     430           0 :                 aPt1.X()/=2;
     431           0 :                 aPt1.Y()/=2;
     432           0 :                 aPt=aPt1;
     433             :             }
     434             :         }
     435           0 :         aPt-=aOfs;
     436             :     }
     437           0 :     SdrGluePoint aGP(aPt);
     438           0 :     aGP.SetPercent(false);
     439           0 :     return aGP;
     440             : }
     441             : 
     442           0 : SdrGluePoint SdrEdgeObj::GetCornerGluePoint(sal_uInt16 nNum) const
     443             : {
     444           0 :     return GetVertexGluePoint(nNum);
     445             : }
     446             : 
     447           0 : const SdrGluePointList* SdrEdgeObj::GetGluePointList() const
     448             : {
     449           0 :     return NULL; // no user defined glue points for connectors
     450             : }
     451             : 
     452           0 : SdrGluePointList* SdrEdgeObj::ForceGluePointList()
     453             : {
     454           0 :     return NULL; // no user defined glue points for connectors
     455             : }
     456             : 
     457           0 : bool SdrEdgeObj::IsEdge() const
     458             : {
     459           0 :     return true;
     460             : }
     461             : 
     462          66 : void SdrEdgeObj::ConnectToNode(bool bTail1, SdrObject* pObj)
     463             : {
     464          66 :     SdrObjConnection& rCon=GetConnection(bTail1);
     465          66 :     DisconnectFromNode(bTail1);
     466          66 :     if (pObj!=NULL) {
     467           2 :         pObj->AddListener(*this);
     468           2 :         rCon.pObj=pObj;
     469             : 
     470             :         // #i120437# If connection is set, reset bEdgeTrackUserDefined
     471           2 :         bEdgeTrackUserDefined = false;
     472             : 
     473           2 :         ImpDirtyEdgeTrack();
     474             :     }
     475          66 : }
     476             : 
     477         132 : void SdrEdgeObj::DisconnectFromNode(bool bTail1)
     478             : {
     479         132 :     SdrObjConnection& rCon=GetConnection(bTail1);
     480         132 :     if (rCon.pObj!=NULL) {
     481           2 :         rCon.pObj->RemoveListener(*this);
     482           2 :         rCon.pObj=NULL;
     483             :     }
     484         132 : }
     485             : 
     486          56 : SdrObject* SdrEdgeObj::GetConnectedNode(bool bTail1) const
     487             : {
     488          56 :     SdrObject* pObj=GetConnection(bTail1).pObj;
     489          56 :     if (pObj!=NULL && (pObj->GetPage()!=pPage || !pObj->IsInserted())) pObj=NULL;
     490          56 :     return pObj;
     491             : }
     492             : 
     493           0 : bool SdrEdgeObj::CheckNodeConnection(bool bTail1) const
     494             : {
     495           0 :     bool bRet = false;
     496           0 :     const SdrObjConnection& rCon=GetConnection(bTail1);
     497           0 :     sal_uInt16 nPtAnz=pEdgeTrack->GetPointCount();
     498           0 :     if (rCon.pObj!=NULL && rCon.pObj->GetPage()==pPage && nPtAnz!=0) {
     499           0 :         const SdrGluePointList* pGPL=rCon.pObj->GetGluePointList();
     500           0 :         sal_uInt16 nConAnz=pGPL==NULL ? 0 : pGPL->GetCount();
     501           0 :         sal_uInt16 nGesAnz=nConAnz+8;
     502           0 :         Point aTail(bTail1 ? (*pEdgeTrack)[0] : (*pEdgeTrack)[sal_uInt16(nPtAnz-1)]);
     503           0 :         for (sal_uInt16 i=0; i<nGesAnz && !bRet; i++) {
     504           0 :             if (i<nConAnz) { // UserDefined
     505           0 :                 bRet=aTail==(*pGPL)[i].GetAbsolutePos(*rCon.pObj);
     506           0 :             } else if (i<nConAnz+4) { // Vertex
     507           0 :                 SdrGluePoint aPt(rCon.pObj->GetVertexGluePoint(i-nConAnz));
     508           0 :                 bRet=aTail==aPt.GetAbsolutePos(*rCon.pObj);
     509             :             } else {                  // Corner
     510           0 :                 SdrGluePoint aPt(rCon.pObj->GetCornerGluePoint(i-nConAnz-4));
     511           0 :                 bRet=aTail==aPt.GetAbsolutePos(*rCon.pObj);
     512             :             }
     513             :         }
     514             :     }
     515           0 :     return bRet;
     516             : }
     517             : 
     518           2 : void SdrEdgeObj::ImpSetTailPoint(bool bTail1, const Point& rPt)
     519             : {
     520           2 :     sal_uInt16 nPtAnz=pEdgeTrack->GetPointCount();
     521           2 :     if (nPtAnz==0) {
     522           1 :         (*pEdgeTrack)[0]=rPt;
     523           1 :         (*pEdgeTrack)[1]=rPt;
     524           1 :     } else if (nPtAnz==1) {
     525           0 :         if (!bTail1) (*pEdgeTrack)[1]=rPt;
     526           0 :         else { (*pEdgeTrack)[1]=(*pEdgeTrack)[0]; (*pEdgeTrack)[0]=rPt; }
     527             :     } else {
     528           1 :         if (!bTail1) (*pEdgeTrack)[sal_uInt16(nPtAnz-1)]=rPt;
     529           0 :         else (*pEdgeTrack)[0]=rPt;
     530             :     }
     531           2 :     ImpRecalcEdgeTrack();
     532           2 :     SetRectsDirty();
     533           2 : }
     534             : 
     535         146 : void SdrEdgeObj::ImpDirtyEdgeTrack()
     536             : {
     537         146 :     if ( !bEdgeTrackUserDefined || !(GetModel() && GetModel()->isLocked()) )
     538         146 :         bEdgeTrackDirty = true;
     539         146 : }
     540             : 
     541          64 : void SdrEdgeObj::ImpUndirtyEdgeTrack()
     542             : {
     543          64 :     if (bEdgeTrackDirty && (GetModel() && GetModel()->isLocked()) ) {
     544           0 :         ImpRecalcEdgeTrack();
     545             :     }
     546          64 : }
     547             : 
     548         139 : void SdrEdgeObj::ImpRecalcEdgeTrack()
     549             : {
     550             :     // #i120437# if bEdgeTrackUserDefined, do not recalculate
     551         139 :     if(bEdgeTrackUserDefined)
     552             :     {
     553           0 :         return;
     554             :     }
     555             : 
     556             :     // #i120437# also not when model locked during import, but remember
     557         139 :     if(!GetModel() || GetModel()->isLocked())
     558             :     {
     559         112 :         mbSuppressed = true;
     560         112 :         return;
     561             :     }
     562             : 
     563             :     // #i110649#
     564          27 :     if(IsBoundRectCalculationRunning())
     565             :     {
     566             :         // This object is involved into another ImpRecalcEdgeTrack() call
     567             :         // from another SdrEdgeObj. Do not calculate again to avoid loop.
     568             :         // Also, do not change bEdgeTrackDirty so that it gets recalculated
     569             :         // later at the first non-looping call.
     570             :     }
     571             :     else
     572             :     {
     573          27 :         if(mbSuppressed)
     574             :         {
     575             :             // #i123048# If layouting was ever suppressed, it needs to be done once
     576             :             // and the attr need to be set at EdgeInfo, else these attr *will be lost*
     577             :             // in the following call to ImpSetEdgeInfoToAttr() sice they were never
     578             :             // set before (!)
     579          27 :             *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
     580          27 :             ImpSetAttrToEdgeInfo();
     581          27 :             mbSuppressed = false;
     582             :         }
     583             : 
     584             :         // To not run in a depth loop, use a coloring algorithm on
     585             :         // SdrEdgeObj BoundRect calculations
     586          27 :         mbBoundRectCalculationRunning = true;
     587             : 
     588          27 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetCurrentBoundRect();
     589          27 :         SetRectsDirty();
     590          27 :         *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
     591          27 :         ImpSetEdgeInfoToAttr(); // copy values from aEdgeInfo into the pool
     592          27 :         bEdgeTrackDirty=false;
     593             : 
     594             :         // Only redraw here, no object change
     595          27 :         ActionChanged();
     596             : 
     597          27 :         SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
     598             : 
     599          27 :         mbBoundRectCalculationRunning = false;
     600             :     }
     601             : }
     602             : 
     603           0 : sal_uInt16 SdrEdgeObj::ImpCalcEscAngle(SdrObject* pObj, const Point& rPt) const
     604             : {
     605           0 :     if (pObj==NULL) return SDRESC_ALL;
     606           0 :     Rectangle aR(pObj->GetSnapRect());
     607           0 :     long dxl=rPt.X()-aR.Left();
     608           0 :     long dyo=rPt.Y()-aR.Top();
     609           0 :     long dxr=aR.Right()-rPt.X();
     610           0 :     long dyu=aR.Bottom()-rPt.Y();
     611           0 :     bool bxMitt=std::abs(dxl-dxr)<2;
     612           0 :     bool byMitt=std::abs(dyo-dyu)<2;
     613           0 :     long dx=std::min(dxl,dxr);
     614           0 :     long dy=std::min(dyo,dyu);
     615           0 :     bool bDiag=std::abs(dx-dy)<2;
     616           0 :     if (bxMitt && byMitt) return SDRESC_ALL; // in the center
     617           0 :     if (bDiag) {  // diagonally
     618           0 :         sal_uInt16 nRet=0;
     619           0 :         if (byMitt) nRet|=SDRESC_VERT;
     620           0 :         if (bxMitt) nRet|=SDRESC_HORZ;
     621           0 :         if (dxl<dxr) { // left
     622           0 :             if (dyo<dyu) nRet|=SDRESC_LEFT | SDRESC_TOP;
     623           0 :             else nRet|=SDRESC_LEFT | SDRESC_BOTTOM;
     624             :         } else {       // right
     625           0 :             if (dyo<dyu) nRet|=SDRESC_RIGHT | SDRESC_TOP;
     626           0 :             else nRet|=SDRESC_RIGHT | SDRESC_BOTTOM;
     627             :         }
     628           0 :         return nRet;
     629             :     }
     630           0 :     if (dx<dy) { // horizontal
     631           0 :         if (bxMitt) return SDRESC_HORZ;
     632           0 :         if (dxl<dxr) return SDRESC_LEFT;
     633           0 :         else return SDRESC_RIGHT;
     634             :     } else {     // vertical
     635           0 :         if (byMitt) return SDRESC_VERT;
     636           0 :         if (dyo<dyu) return SDRESC_TOP;
     637           0 :         else return SDRESC_BOTTOM;
     638             :     }
     639             : }
     640             : 
     641          64 : XPolygon SdrEdgeObj::ImpCalcObjToCenter(const Point& rStPt, long nEscAngle, const Rectangle& rRect, const Point& rMeeting) const
     642             : {
     643          64 :     XPolygon aXP;
     644          64 :     aXP.Insert(XPOLY_APPEND,rStPt,XPOLY_NORMAL);
     645          64 :     bool bRts=nEscAngle==0;
     646          64 :     bool bObn=nEscAngle==9000;
     647          64 :     bool bLks=nEscAngle==18000;
     648          64 :     bool bUnt=nEscAngle==27000;
     649             : 
     650          64 :     Point aP1(rStPt); // mandatory difference first,...
     651          64 :     if (bLks) aP1.X()=rRect.Left();
     652          64 :     if (bRts) aP1.X()=rRect.Right();
     653          64 :     if (bObn) aP1.Y()=rRect.Top();
     654          64 :     if (bUnt) aP1.Y()=rRect.Bottom();
     655             : 
     656          64 :     Point aP2(aP1); // ...now increase to Meeting height, if necessary
     657          64 :     if (bLks && rMeeting.X()<=aP2.X()) aP2.X()=rMeeting.X();
     658          64 :     if (bRts && rMeeting.X()>=aP2.X()) aP2.X()=rMeeting.X();
     659          64 :     if (bObn && rMeeting.Y()<=aP2.Y()) aP2.Y()=rMeeting.Y();
     660          64 :     if (bUnt && rMeeting.Y()>=aP2.Y()) aP2.Y()=rMeeting.Y();
     661          64 :     aXP.Insert(XPOLY_APPEND,aP2,XPOLY_NORMAL);
     662             : 
     663          64 :     Point aP3(aP2);
     664          64 :     if ((bLks && rMeeting.X()>aP2.X()) || (bRts && rMeeting.X()<aP2.X())) { // around
     665           0 :         if (rMeeting.Y()<aP2.Y()) {
     666           0 :             aP3.Y()=rRect.Top();
     667           0 :             if (rMeeting.Y()<aP3.Y()) aP3.Y()=rMeeting.Y();
     668             :         } else {
     669           0 :             aP3.Y()=rRect.Bottom();
     670           0 :             if (rMeeting.Y()>aP3.Y()) aP3.Y()=rMeeting.Y();
     671             :         }
     672           0 :         aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
     673           0 :         if (aP3.Y()!=rMeeting.Y()) {
     674           0 :             aP3.X()=rMeeting.X();
     675           0 :             aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
     676             :         }
     677             :     }
     678          64 :     if ((bObn && rMeeting.Y()>aP2.Y()) || (bUnt && rMeeting.Y()<aP2.Y())) { // around
     679           4 :         if (rMeeting.X()<aP2.X()) {
     680           0 :             aP3.X()=rRect.Left();
     681           0 :             if (rMeeting.X()<aP3.X()) aP3.X()=rMeeting.X();
     682             :         } else {
     683           4 :             aP3.X()=rRect.Right();
     684           4 :             if (rMeeting.X()>aP3.X()) aP3.X()=rMeeting.X();
     685             :         }
     686           4 :         aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
     687           4 :         if (aP3.X()!=rMeeting.X()) {
     688           0 :             aP3.Y()=rMeeting.Y();
     689           0 :             aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
     690             :         }
     691             :     }
     692             : #ifdef DBG_UTIL
     693             :     if (aXP.GetPointCount()>4) {
     694             :         OSL_FAIL("SdrEdgeObj::ImpCalcObjToCenter(): Polygon has more than 4 points!");
     695             :     }
     696             : #endif
     697          64 :     return aXP;
     698             : }
     699             : 
     700          54 : XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& rTrack0, SdrObjConnection& rCon1, SdrObjConnection& rCon2, SdrEdgeInfoRec* pInfo) const
     701             : {
     702          54 :     Point aPt1,aPt2;
     703          54 :     SdrGluePoint aGP1,aGP2;
     704          54 :     sal_uInt16 nEsc1=SDRESC_ALL,nEsc2=SDRESC_ALL;
     705          54 :     Rectangle aBoundRect1;
     706          54 :     Rectangle aBoundRect2;
     707          54 :     Rectangle aBewareRect1;
     708          54 :     Rectangle aBewareRect2;
     709             :     // first, get the old corner points
     710          54 :     if (rTrack0.GetPointCount()!=0) {
     711          54 :         aPt1=rTrack0[0];
     712          54 :         sal_uInt16 nSiz=rTrack0.GetPointCount();
     713          54 :         nSiz--;
     714          54 :         aPt2=rTrack0[nSiz];
     715             :     } else {
     716           0 :         if (!aOutRect.IsEmpty()) {
     717           0 :             aPt1=aOutRect.TopLeft();
     718           0 :             aPt2=aOutRect.BottomRight();
     719             :         }
     720             :     }
     721             : 
     722             :     // #i54102# To allow interactive preview, do also if not inserted
     723          54 :     bool bCon1=rCon1.pObj!=NULL && rCon1.pObj->GetPage()==pPage;
     724          54 :     bool bCon2=rCon2.pObj!=NULL && rCon2.pObj->GetPage()==pPage;
     725             : 
     726          54 :     const SfxItemSet& rSet = GetObjectItemSet();
     727             : 
     728          54 :     if (bCon1) {
     729           0 :         if (rCon1.pObj==(SdrObject*)this)
     730             :         {
     731             :             // check, just in case
     732           0 :             aBoundRect1=aOutRect;
     733             :         }
     734             :         else
     735             :         {
     736           0 :             aBoundRect1 = rCon1.pObj->GetCurrentBoundRect();
     737             :         }
     738           0 :         aBoundRect1.Move(rCon1.aObjOfs.X(),rCon1.aObjOfs.Y());
     739           0 :         aBewareRect1=aBoundRect1;
     740             : 
     741           0 :         sal_Int32 nH = ((SdrEdgeNode1HorzDistItem&)rSet.Get(SDRATTR_EDGENODE1HORZDIST)).GetValue();
     742           0 :         sal_Int32 nV = ((SdrEdgeNode1VertDistItem&)rSet.Get(SDRATTR_EDGENODE1VERTDIST)).GetValue();
     743             : 
     744           0 :         aBewareRect1.Left()-=nH;
     745           0 :         aBewareRect1.Right()+=nH;
     746           0 :         aBewareRect1.Top()-=nV;
     747           0 :         aBewareRect1.Bottom()+=nV;
     748             :     } else {
     749          54 :         aBoundRect1=Rectangle(aPt1,aPt1);
     750          54 :         aBoundRect1.Move(rCon1.aObjOfs.X(),rCon1.aObjOfs.Y());
     751          54 :         aBewareRect1=aBoundRect1;
     752             :     }
     753          54 :     if (bCon2) {
     754           0 :         if (rCon2.pObj==(SdrObject*)this) { // check, just in case
     755           0 :             aBoundRect2=aOutRect;
     756             :         }
     757             :         else
     758             :         {
     759           0 :             aBoundRect2 = rCon2.pObj->GetCurrentBoundRect();
     760             :         }
     761           0 :         aBoundRect2.Move(rCon2.aObjOfs.X(),rCon2.aObjOfs.Y());
     762           0 :         aBewareRect2=aBoundRect2;
     763             : 
     764           0 :         sal_Int32 nH = ((SdrEdgeNode2HorzDistItem&)rSet.Get(SDRATTR_EDGENODE2HORZDIST)).GetValue();
     765           0 :         sal_Int32 nV = ((SdrEdgeNode2VertDistItem&)rSet.Get(SDRATTR_EDGENODE2VERTDIST)).GetValue();
     766             : 
     767           0 :         aBewareRect2.Left()-=nH;
     768           0 :         aBewareRect2.Right()+=nH;
     769           0 :         aBewareRect2.Top()-=nV;
     770           0 :         aBewareRect2.Bottom()+=nV;
     771             :     } else {
     772          54 :         aBoundRect2=Rectangle(aPt2,aPt2);
     773          54 :         aBoundRect2.Move(rCon2.aObjOfs.X(),rCon2.aObjOfs.Y());
     774          54 :         aBewareRect2=aBoundRect2;
     775             :     }
     776          54 :     XPolygon aBestXP;
     777          54 :     sal_uIntPtr nBestQual=0xFFFFFFFF;
     778          54 :     SdrEdgeInfoRec aBestInfo;
     779          54 :     bool bAuto1=bCon1 && rCon1.bBestVertex;
     780          54 :     bool bAuto2=bCon2 && rCon2.bBestVertex;
     781          54 :     if (bAuto1) rCon1.bAutoVertex=true;
     782          54 :     if (bAuto2) rCon2.bAutoVertex=true;
     783          54 :     sal_uInt16 nBestAuto1=0;
     784          54 :     sal_uInt16 nBestAuto2=0;
     785          54 :     sal_uInt16 nAnz1=bAuto1 ? 4 : 1;
     786          54 :     sal_uInt16 nAnz2=bAuto2 ? 4 : 1;
     787         108 :     for (sal_uInt16 nNum1=0; nNum1<nAnz1; nNum1++) {
     788          54 :         if (bAuto1) rCon1.nConId=nNum1;
     789          54 :         if (bCon1 && rCon1.TakeGluePoint(aGP1,true)) {
     790           0 :             aPt1=aGP1.GetPos();
     791           0 :             nEsc1=aGP1.GetEscDir();
     792           0 :             if (nEsc1==SDRESC_SMART) nEsc1=ImpCalcEscAngle(rCon1.pObj,aPt1-rCon1.aObjOfs);
     793             :         }
     794         108 :         for (sal_uInt16 nNum2=0; nNum2<nAnz2; nNum2++) {
     795          54 :             if (bAuto2) rCon2.nConId=nNum2;
     796          54 :             if (bCon2 && rCon2.TakeGluePoint(aGP2,true)) {
     797           0 :                 aPt2=aGP2.GetPos();
     798           0 :                 nEsc2=aGP2.GetEscDir();
     799           0 :                 if (nEsc2==SDRESC_SMART) nEsc2=ImpCalcEscAngle(rCon2.pObj,aPt2-rCon2.aObjOfs);
     800             :             }
     801         270 :             for (long nA1=0; nA1<36000; nA1+=9000) {
     802         216 :                 sal_uInt16 nE1=nA1==0 ? SDRESC_RIGHT : nA1==9000 ? SDRESC_TOP : nA1==18000 ? SDRESC_LEFT : nA1==27000 ? SDRESC_BOTTOM : 0;
     803        1080 :                 for (long nA2=0; nA2<36000; nA2+=9000) {
     804         864 :                     sal_uInt16 nE2=nA2==0 ? SDRESC_RIGHT : nA2==9000 ? SDRESC_TOP : nA2==18000 ? SDRESC_LEFT : nA2==27000 ? SDRESC_BOTTOM : 0;
     805         864 :                     if ((nEsc1&nE1)!=0 && (nEsc2&nE2)!=0) {
     806         864 :                         sal_uIntPtr nQual=0;
     807         864 :                         SdrEdgeInfoRec aInfo;
     808         864 :                         if (pInfo!=NULL) aInfo=*pInfo;
     809         864 :                         XPolygon aXP(ImpCalcEdgeTrack(aPt1,nA1,aBoundRect1,aBewareRect1,aPt2,nA2,aBoundRect2,aBewareRect2,&nQual,&aInfo));
     810         864 :                         if (nQual<nBestQual) {
     811          54 :                             aBestXP=aXP;
     812          54 :                             nBestQual=nQual;
     813          54 :                             aBestInfo=aInfo;
     814          54 :                             nBestAuto1=nNum1;
     815          54 :                             nBestAuto2=nNum2;
     816         864 :                         }
     817             :                     }
     818             :                 }
     819             :             }
     820             :         }
     821             :     }
     822          54 :     if (bAuto1) rCon1.nConId=nBestAuto1;
     823          54 :     if (bAuto2) rCon2.nConId=nBestAuto2;
     824          54 :     if (pInfo!=NULL) *pInfo=aBestInfo;
     825          54 :     return aBestXP;
     826             : }
     827             : 
     828         864 : XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const Point& rPt1, long nAngle1, const Rectangle& rBoundRect1, const Rectangle& rBewareRect1,
     829             :     const Point& rPt2, long nAngle2, const Rectangle& rBoundRect2, const Rectangle& rBewareRect2,
     830             :     sal_uIntPtr* pnQuality, SdrEdgeInfoRec* pInfo) const
     831             : {
     832         864 :     SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
     833         864 :     bool bRts1=nAngle1==0;
     834         864 :     bool bObn1=nAngle1==9000;
     835         864 :     bool bLks1=nAngle1==18000;
     836         864 :     bool bUnt1=nAngle1==27000;
     837         864 :     bool bHor1=bLks1 || bRts1;
     838         864 :     bool bVer1=bObn1 || bUnt1;
     839         864 :     bool bRts2=nAngle2==0;
     840         864 :     bool bObn2=nAngle2==9000;
     841         864 :     bool bLks2=nAngle2==18000;
     842         864 :     bool bUnt2=nAngle2==27000;
     843         864 :     bool bHor2=bLks2 || bRts2;
     844         864 :     bool bVer2=bObn2 || bUnt2;
     845         864 :     bool bInfo=pInfo!=NULL;
     846         864 :     if (bInfo) {
     847         864 :         pInfo->cOrthoForm=0;
     848         864 :         pInfo->nAngle1=nAngle1;
     849         864 :         pInfo->nAngle2=nAngle2;
     850         864 :         pInfo->nObj1Lines=1;
     851         864 :         pInfo->nObj2Lines=1;
     852         864 :         pInfo->nMiddleLine=0xFFFF;
     853             :     }
     854         864 :     Point aPt1(rPt1);
     855         864 :     Point aPt2(rPt2);
     856         864 :     Rectangle aBoundRect1 (rBoundRect1 );
     857         864 :     Rectangle aBoundRect2 (rBoundRect2 );
     858         864 :     Rectangle aBewareRect1(rBewareRect1);
     859         864 :     Rectangle aBewareRect2(rBewareRect2);
     860         864 :     Point aMeeting((aPt1.X()+aPt2.X()+1)/2,(aPt1.Y()+aPt2.Y()+1)/2);
     861         864 :     if (eKind==SDREDGE_ONELINE) {
     862         832 :         XPolygon aXP(2);
     863         832 :         aXP[0]=rPt1;
     864         832 :         aXP[1]=rPt2;
     865         832 :         if (pnQuality!=NULL) {
     866         832 :             *pnQuality=std::abs(rPt1.X()-rPt2.X())+std::abs(rPt1.Y()-rPt2.Y());
     867             :         }
     868         832 :         return aXP;
     869          32 :     } else if (eKind==SDREDGE_THREELINES) {
     870           0 :         XPolygon aXP(4);
     871           0 :         aXP[0]=rPt1;
     872           0 :         aXP[1]=rPt1;
     873           0 :         aXP[2]=rPt2;
     874           0 :         aXP[3]=rPt2;
     875           0 :         if (bRts1) aXP[1].X()=aBewareRect1.Right();  //+=500;
     876           0 :         if (bObn1) aXP[1].Y()=aBewareRect1.Top();    //-=500;
     877           0 :         if (bLks1) aXP[1].X()=aBewareRect1.Left();   //-=500;
     878           0 :         if (bUnt1) aXP[1].Y()=aBewareRect1.Bottom(); //+=500;
     879           0 :         if (bRts2) aXP[2].X()=aBewareRect2.Right();  //+=500;
     880           0 :         if (bObn2) aXP[2].Y()=aBewareRect2.Top();    //-=500;
     881           0 :         if (bLks2) aXP[2].X()=aBewareRect2.Left();   //-=500;
     882           0 :         if (bUnt2) aXP[2].Y()=aBewareRect2.Bottom(); //+=500;
     883           0 :         if (pnQuality!=NULL) {
     884           0 :             long nQ=std::abs(aXP[1].X()-aXP[0].X())+std::abs(aXP[1].Y()-aXP[0].Y());
     885           0 :                 nQ+=std::abs(aXP[2].X()-aXP[1].X())+std::abs(aXP[2].Y()-aXP[1].Y());
     886           0 :                 nQ+=std::abs(aXP[3].X()-aXP[2].X())+std::abs(aXP[3].Y()-aXP[2].Y());
     887           0 :             *pnQuality=nQ;
     888             :         }
     889           0 :         if (bInfo) {
     890           0 :             pInfo->nObj1Lines=2;
     891           0 :             pInfo->nObj2Lines=2;
     892           0 :             if (bHor1) {
     893           0 :                 aXP[1].X()+=pInfo->aObj1Line2.X();
     894             :             } else {
     895           0 :                 aXP[1].Y()+=pInfo->aObj1Line2.Y();
     896             :             }
     897           0 :             if (bHor2) {
     898           0 :                 aXP[2].X()+=pInfo->aObj2Line2.X();
     899             :             } else {
     900           0 :                 aXP[2].Y()+=pInfo->aObj2Line2.Y();
     901             :             }
     902             :         }
     903           0 :         return aXP;
     904             :     }
     905          32 :     sal_uInt16 nIntersections=0;
     906             :     {
     907          32 :         Point aC1(aBewareRect1.Center());
     908          32 :         Point aC2(aBewareRect2.Center());
     909          32 :         if (aBewareRect1.Left()<=aBewareRect2.Right() && aBewareRect1.Right()>=aBewareRect2.Left()) {
     910             :             // overlapping on the x axis
     911          32 :             long n1=std::max(aBewareRect1.Left(),aBewareRect2.Left());
     912          32 :             long n2=std::min(aBewareRect1.Right(),aBewareRect2.Right());
     913          32 :             aMeeting.X()=(n1+n2+1)/2;
     914             :         } else {
     915             :             // otherwise the center point of the empty space
     916           0 :             if (aC1.X()<aC2.X()) {
     917           0 :                 aMeeting.X()=(aBewareRect1.Right()+aBewareRect2.Left()+1)/2;
     918             :             } else {
     919           0 :                 aMeeting.X()=(aBewareRect1.Left()+aBewareRect2.Right()+1)/2;
     920             :             }
     921             :         }
     922          32 :         if (aBewareRect1.Top()<=aBewareRect2.Bottom() && aBewareRect1.Bottom()>=aBewareRect2.Top()) {
     923             :             // overlapping on the x axis
     924          32 :             long n1=std::max(aBewareRect1.Top(),aBewareRect2.Top());
     925          32 :             long n2=std::min(aBewareRect1.Bottom(),aBewareRect2.Bottom());
     926          32 :             aMeeting.Y()=(n1+n2+1)/2;
     927             :         } else {
     928             :             // otherwise the center point of the empty space
     929           0 :             if (aC1.Y()<aC2.Y()) {
     930           0 :                 aMeeting.Y()=(aBewareRect1.Bottom()+aBewareRect2.Top()+1)/2;
     931             :             } else {
     932           0 :                 aMeeting.Y()=(aBewareRect1.Top()+aBewareRect2.Bottom()+1)/2;
     933             :             }
     934             :         }
     935             :         // Here, there are three cases:
     936             :         //   1. both go into the same direction
     937             :         //   2. both go into opposite directions
     938             :         //   3. one is vertical, the other is horizontal
     939          32 :         long nXMin=std::min(aBewareRect1.Left(),aBewareRect2.Left());
     940          32 :         long nXMax=std::max(aBewareRect1.Right(),aBewareRect2.Right());
     941          32 :         long nYMin=std::min(aBewareRect1.Top(),aBewareRect2.Top());
     942          32 :         long nYMax=std::max(aBewareRect1.Bottom(),aBewareRect2.Bottom());
     943          32 :         bool bBewareOverlap=aBewareRect1.Right()>aBewareRect2.Left() && aBewareRect1.Left()<aBewareRect2.Right() &&
     944          32 :                             aBewareRect1.Bottom()>aBewareRect2.Top() && aBewareRect1.Top()<aBewareRect2.Bottom();
     945          32 :         unsigned nMainCase=3;
     946          32 :         if (nAngle1==nAngle2) nMainCase=1;
     947          24 :         else if ((bHor1 && bHor2) || (bVer1 && bVer2)) nMainCase=2;
     948          32 :         if (nMainCase==1) { // case 1 (both go in one direction) is possible
     949           8 :             if (bVer1) aMeeting.X()=(aPt1.X()+aPt2.X()+1)/2; // Here, this is better than
     950           8 :             if (bHor1) aMeeting.Y()=(aPt1.Y()+aPt2.Y()+1)/2; // using center point of empty space
     951             :             // bX1Ok means that the vertical exiting Obj1 doesn't conflict with Obj2, ...
     952           8 :             bool bX1Ok=aPt1.X()<=aBewareRect2.Left() || aPt1.X()>=aBewareRect2.Right();
     953           8 :             bool bX2Ok=aPt2.X()<=aBewareRect1.Left() || aPt2.X()>=aBewareRect1.Right();
     954           8 :             bool bY1Ok=aPt1.Y()<=aBewareRect2.Top() || aPt1.Y()>=aBewareRect2.Bottom();
     955           8 :             bool bY2Ok=aPt2.Y()<=aBewareRect1.Top() || aPt2.Y()>=aBewareRect1.Bottom();
     956           8 :             if (bLks1 && (bY1Ok || aBewareRect1.Left()<aBewareRect2.Right()) && (bY2Ok || aBewareRect2.Left()<aBewareRect1.Right())) {
     957           2 :                 aMeeting.X()=nXMin;
     958             :             }
     959           8 :             if (bRts1 && (bY1Ok || aBewareRect1.Right()>aBewareRect2.Left()) && (bY2Ok || aBewareRect2.Right()>aBewareRect1.Left())) {
     960           2 :                 aMeeting.X()=nXMax;
     961             :             }
     962           8 :             if (bObn1 && (bX1Ok || aBewareRect1.Top()<aBewareRect2.Bottom()) && (bX2Ok || aBewareRect2.Top()<aBewareRect1.Bottom())) {
     963           2 :                 aMeeting.Y()=nYMin;
     964             :             }
     965           8 :             if (bUnt1 && (bX1Ok || aBewareRect1.Bottom()>aBewareRect2.Top()) && (bX2Ok || aBewareRect2.Bottom()>aBewareRect1.Top())) {
     966           2 :                 aMeeting.Y()=nYMax;
     967             :             }
     968          24 :         } else if (nMainCase==2) {
     969             :             // case 2:
     970           8 :             if (bHor1) { // both horizontal
     971             :                 /* 9 sub-cases:
     972             :                (legend: line exits to the left (-|), right (|-))
     973             : 
     974             :                     2.1: Facing; overlap only on y axis
     975             :                          *  *  *
     976             :                          |--|  *
     977             :                          *  *  *
     978             : 
     979             :                     2.2, 2.3: Facing, offset vertically; no overlap on either
     980             :                              axis
     981             :                          |- *  *       *  *  *
     982             :                          * -|  *       * -|  *
     983             :                          *  *  *  ,    *  *  *
     984             : 
     985             :                     2.4, 2.5: One below the other; overlap only on y axis
     986             :                          *  |- *       *  *  *
     987             :                          * -|  *       * -|  *
     988             :                          *  *  *  ,    *  |- *
     989             : 
     990             :                     2.6, 2.7: Not facing, offset vertically; no overlap on either
     991             :                              axis
     992             :                          *  *  |-      *  *  *
     993             :                          * -|  *       * -|  *
     994             :                          *  *  *  ,    *  *  |-
     995             : 
     996             :                     2.8: Not facing; overlap only on y axis
     997             :                          *  *  *
     998             :                          * -|  |-
     999             :                          *  *  *
    1000             : 
    1001             :                     2.9: The objects's BewareRects overlap on x and y axis
    1002             : 
    1003             :                    These cases, with some modifications are also valid for
    1004             :                    horizontal line exits.
    1005             :                    Cases 2.1 through 2.7 are covered well enough with the
    1006             :                    default meetings. Only for cases 2.8 and 2.9 do we determine
    1007             :                    special meeting points here.
    1008             :                 */
    1009             : 
    1010             :                 // normalization; be aR1 the one exiting to the right,
    1011             :                 // be aR2 the one exiting to the left
    1012           4 :                 Rectangle aBewR1(bRts1 ? aBewareRect1 : aBewareRect2);
    1013           4 :                 Rectangle aBewR2(bRts1 ? aBewareRect2 : aBewareRect1);
    1014           4 :                 Rectangle aBndR1(bRts1 ? aBoundRect1 : aBoundRect2);
    1015           4 :                 Rectangle aBndR2(bRts1 ? aBoundRect2 : aBoundRect1);
    1016           4 :                 if (aBewR1.Bottom()>aBewR2.Top() && aBewR1.Top()<aBewR2.Bottom()) {
    1017             :                     // overlap on y axis; cases 2.1, 2.8, 2.9
    1018           0 :                     if (aBewR1.Right()>aBewR2.Left()) {
    1019             :                         /* Cases 2.8, 2.9:
    1020             :                              Case 2.8: always going around on the outside
    1021             :                              (bDirect=false).
    1022             : 
    1023             :                              Case 2.9 could also be a direct connection (in the
    1024             :                              case that the BewareRects overlap only slightly and
    1025             :                              the BoundRects don't overlap at all and if the
    1026             :                              line exits would otherwise violate the respective
    1027             :                              other object's BewareRect).
    1028             :                         */
    1029           0 :                         bool bCase29Direct = false;
    1030           0 :                         bool bCase29=aBewR1.Right()>aBewR2.Left();
    1031           0 :                         if (aBndR1.Right()<=aBndR2.Left()) { // case 2.9 without BoundRect overlap
    1032           0 :                             if ((aPt1.Y()>aBewareRect2.Top() && aPt1.Y()<aBewareRect2.Bottom()) ||
    1033           0 :                                 (aPt2.Y()>aBewareRect1.Top() && aPt2.Y()<aBewareRect1.Bottom())) {
    1034           0 :                                bCase29Direct = true;
    1035             :                             }
    1036             :                         }
    1037           0 :                         if (!bCase29Direct) {
    1038           0 :                             bool bObenLang=std::abs(nYMin-aMeeting.Y())<=std::abs(nYMax-aMeeting.Y());
    1039           0 :                             if (bObenLang) {
    1040           0 :                                 aMeeting.Y()=nYMin;
    1041             :                             } else {
    1042           0 :                                 aMeeting.Y()=nYMax;
    1043             :                             }
    1044           0 :                             if (bCase29) {
    1045             :                                 // now make sure that the surrounded object
    1046             :                                 // isn't traversed
    1047           0 :                                 if ((aBewR1.Center().Y()<aBewR2.Center().Y()) != bObenLang) {
    1048           0 :                                     aMeeting.X()=aBewR2.Right();
    1049             :                                 } else {
    1050           0 :                                     aMeeting.X()=aBewR1.Left();
    1051             :                                 }
    1052             :                             }
    1053             :                         } else {
    1054             :                             // We need a direct connection (3-line Z connection),
    1055             :                             // because we have to violate the BewareRects.
    1056             :                             // Use rule of three to scale down the BewareRects.
    1057           0 :                             long nWant1=aBewR1.Right()-aBndR1.Right(); // distance at Obj1
    1058           0 :                             long nWant2=aBndR2.Left()-aBewR2.Left();   // distance at Obj2
    1059           0 :                             long nSpace=aBndR2.Left()-aBndR1.Right(); // available space
    1060           0 :                             long nGet1=BigMulDiv(nWant1,nSpace,nWant1+nWant2);
    1061           0 :                             long nGet2=nSpace-nGet1;
    1062           0 :                             if (bRts1) { // revert normalization
    1063           0 :                                 aBewareRect1.Right()+=nGet1-nWant1;
    1064           0 :                                 aBewareRect2.Left()-=nGet2-nWant2;
    1065             :                             } else {
    1066           0 :                                 aBewareRect2.Right()+=nGet1-nWant1;
    1067           0 :                                 aBewareRect1.Left()-=nGet2-nWant2;
    1068             :                             }
    1069           0 :                             nIntersections++; // lower quality
    1070             :                         }
    1071             :                     }
    1072             :                 }
    1073           4 :             } else if (bVer1) { // both horizontal
    1074           4 :                 Rectangle aBewR1(bUnt1 ? aBewareRect1 : aBewareRect2);
    1075           4 :                 Rectangle aBewR2(bUnt1 ? aBewareRect2 : aBewareRect1);
    1076           4 :                 Rectangle aBndR1(bUnt1 ? aBoundRect1 : aBoundRect2);
    1077           4 :                 Rectangle aBndR2(bUnt1 ? aBoundRect2 : aBoundRect1);
    1078           4 :                 if (aBewR1.Right()>aBewR2.Left() && aBewR1.Left()<aBewR2.Right()) {
    1079             :                     // overlap on y axis; cases 2.1, 2.8, 2.9
    1080           0 :                     if (aBewR1.Bottom()>aBewR2.Top()) {
    1081             :                         /* Cases 2.8, 2.9
    1082             :                            Case 2.8 always going around on the outside (bDirect=false).
    1083             : 
    1084             :                            Case 2.9 could also be a direct connection (in the
    1085             :                            case that the BewareRects overlap only slightly and
    1086             :                            the BoundRects don't overlap at all and if the
    1087             :                            line exits would otherwise violate the respective
    1088             :                            other object's BewareRect).
    1089             :                         */
    1090           0 :                         bool bCase29Direct = false;
    1091           0 :                         bool bCase29=aBewR1.Bottom()>aBewR2.Top();
    1092           0 :                         if (aBndR1.Bottom()<=aBndR2.Top()) { // case 2.9 without BoundRect overlap
    1093           0 :                             if ((aPt1.X()>aBewareRect2.Left() && aPt1.X()<aBewareRect2.Right()) ||
    1094           0 :                                 (aPt2.X()>aBewareRect1.Left() && aPt2.X()<aBewareRect1.Right())) {
    1095           0 :                                bCase29Direct = true;
    1096             :                             }
    1097             :                         }
    1098           0 :                         if (!bCase29Direct) {
    1099           0 :                             bool bLinksLang=std::abs(nXMin-aMeeting.X())<=std::abs(nXMax-aMeeting.X());
    1100           0 :                             if (bLinksLang) {
    1101           0 :                                 aMeeting.X()=nXMin;
    1102             :                             } else {
    1103           0 :                                 aMeeting.X()=nXMax;
    1104             :                             }
    1105           0 :                             if (bCase29) {
    1106             :                                 // now make sure that the surrounded object
    1107             :                                 // isn't traversed
    1108           0 :                                 if ((aBewR1.Center().X()<aBewR2.Center().X()) != bLinksLang) {
    1109           0 :                                     aMeeting.Y()=aBewR2.Bottom();
    1110             :                                 } else {
    1111           0 :                                     aMeeting.Y()=aBewR1.Top();
    1112             :                                 }
    1113             :                             }
    1114             :                         } else {
    1115             :                             // We need a direct connection (3-line Z connection),
    1116             :                             // because we have to violate the BewareRects.
    1117             :                             // Use rule of three to scale down the BewareRects.
    1118           0 :                             long nWant1=aBewR1.Bottom()-aBndR1.Bottom(); // difference at Obj1
    1119           0 :                             long nWant2=aBndR2.Top()-aBewR2.Top();   // difference at Obj2
    1120           0 :                             long nSpace=aBndR2.Top()-aBndR1.Bottom(); // available space
    1121           0 :                             long nGet1=BigMulDiv(nWant1,nSpace,nWant1+nWant2);
    1122           0 :                             long nGet2=nSpace-nGet1;
    1123           0 :                             if (bUnt1) { // revert normalization
    1124           0 :                                 aBewareRect1.Bottom()+=nGet1-nWant1;
    1125           0 :                                 aBewareRect2.Top()-=nGet2-nWant2;
    1126             :                             } else {
    1127           0 :                                 aBewareRect2.Bottom()+=nGet1-nWant1;
    1128           0 :                                 aBewareRect1.Top()-=nGet2-nWant2;
    1129             :                             }
    1130           0 :                             nIntersections++; // lower quality
    1131             :                         }
    1132             :                     }
    1133             :                 }
    1134             :             }
    1135          16 :         } else if (nMainCase==3) { // case 3: one horizontal, the other vertical
    1136             :             /* legend:
    1137             :                The line exits to the:
    1138             :                -|       left
    1139             : 
    1140             :                 |-      right
    1141             : 
    1142             :                _|_      top
    1143             : 
    1144             :                 T       bottom
    1145             : 
    1146             :                *  .  *  .  * -- no overlap, at most might touch
    1147             :                .  .  .  .  . -- overlap
    1148             :                *  .  |- .  * -- same height
    1149             :                .  .  .  .  . -- overlap
    1150             :                *  .  *  .  * -- no overlap, at most might touch
    1151             : 
    1152             :                Overall, there are 96 possible constellations, some of these can't even
    1153             :                be unambiguously assigned to a certain case/method of handling.
    1154             : 
    1155             : 
    1156             :                3.1: All those constellations that are covered reasonably well
    1157             :                by the default MeetingPoint (20+12).
    1158             : 
    1159             :                T  T  T  . _|_    _|_ .  T  T  T     these 12     *  .  *  T  *      *  .  *  .  *      *  T  *  .  *      *  .  *  .  *
    1160             :                .  .  .  . _|_    _|_ .  .  .  .  constellations  .  .  .  .  .      .  .  .  .  T      .  .  .  .  .      T  .  .  .  .
    1161             :                *  .  |- .  *      *  . -|  .  *   are covered    *  .  |- . _|_     *  .  |- .  T     _|_ . -|  .  *      T  . -|  .  *
    1162             :                .  .  .  .  T      T  .  .  .  .     only in      .  .  .  . _|_     .  .  .  .  .     _|_ .  .  .  .      .  .  .  .  .
    1163             :               _|__|__|_ .  T      T  . _|__|__|_     part:       *  .  * _|_ *      *  .  *  .  *      * _|_ *  .  *      *  .  *  .  *
    1164             : 
    1165             :               The last 16 of these cases can be excluded, if the objects face each other openly.
    1166             : 
    1167             : 
    1168             :               3.2: The objects face each other openly, thus a connection using only two lines is possible (4+20);
    1169             :               This case is priority #1.
    1170             :                *  .  *  .  T      T  .  *  .  *     these 20     *  .  *  T  *      *  T  *  .  *      *  .  *  .  *      *  .  *  .  *
    1171             :                .  .  .  .  .      .  .  .  .  .  constellations  .  .  .  T  T      T  T  .  .  .      .  .  .  .  .      .  .  .  .  .
    1172             :                *  .  |- .  *      *  . -|  .  *    are covered   *  .  |-_|__|_    _|__|_-|  .  *      *  .  |- T  T      T  T -|  .  *
    1173             :                .  .  .  .  .      .  .  .  .  .     only in      .  .  . _|__|_    _|__|_ .  .  .      .  .  .  .  .      .  .  .  .  .
    1174             :                *  .  *  . _|_    _|_ .  *  .  *      part:       *  .  * _|_ *      * _|_ *  .  *      *  .  *  .  *      *  .  *  .  *
    1175             : 
    1176             :                3.3: The line exits point away from the other object or or miss its back (52+4).
    1177             :               _|__|__|__|_ *      * _|__|__|__|_     *  .  .  .  *      *  .  *  .  *     these 4      *  .  *  .  *      *  .  *  .  *
    1178             :               _|__|__|__|_ .      . _|__|__|__|_     T  T  T  .  .      .  .  T  T  T  constellations  .  .  .  T  .      .  T  .  .  .
    1179             :               _|__|_ |- .  *      *  . -| _|__|_     T  T  |- .  *      *  . -|  T  T    are covered   *  .  |- .  *      *  . -|  .  *
    1180             :               _|__|__|_ .  .      .  . _|__|__|_     T  T  T  T  .      .  T  T  T  T     only in      .  .  . _|_ .      . _|_ .  .  .
    1181             :                *  .  *  .  *      *  .  *  .  *      T  T  T  T  *      *  T  T  T  T      part:       *  .  *  .  *      *  .  *  .  *
    1182             :             */
    1183             : 
    1184             :             // case 3.2
    1185          16 :             Rectangle aTmpR1(aBewareRect1);
    1186          16 :             Rectangle aTmpR2(aBewareRect2);
    1187          16 :             if (bBewareOverlap) {
    1188             :                 // overlapping BewareRects: use BoundRects for checking for case 3.2
    1189           0 :                 aTmpR1=aBoundRect1;
    1190           0 :                 aTmpR2=aBoundRect2;
    1191             :             }
    1192          20 :             if ((((bRts1 && aTmpR1.Right ()<=aPt2.X()) || (bLks1 && aTmpR1.Left()>=aPt2.X())) &&
    1193          36 :                  ((bUnt2 && aTmpR2.Bottom()<=aPt1.Y()) || (bObn2 && aTmpR2.Top ()>=aPt1.Y()))) ||
    1194           4 :                 (((bRts2 && aTmpR2.Right ()<=aPt1.X()) || (bLks2 && aTmpR2.Left()>=aPt1.X())) &&
    1195           4 :                  ((bUnt1 && aTmpR1.Bottom()<=aPt2.Y()) || (bObn1 && aTmpR1.Top ()>=aPt2.Y())))) {
    1196             :                 // case 3.2 applies: connector with only 2 lines
    1197          16 :                 if (bHor1) {
    1198           8 :                     aMeeting.X()=aPt2.X();
    1199           8 :                     aMeeting.Y()=aPt1.Y();
    1200             :                 } else {
    1201           8 :                     aMeeting.X()=aPt1.X();
    1202           8 :                     aMeeting.Y()=aPt2.Y();
    1203             :                 }
    1204             :                 // in the case of overlapping BewareRects:
    1205          16 :                 aBewareRect1=aTmpR1;
    1206          16 :                 aBewareRect2=aTmpR2;
    1207           0 :             } else if ((((bRts1 && aBewareRect1.Right ()>aBewareRect2.Left  ()) ||
    1208           0 :                          (bLks1 && aBewareRect1.Left  ()<aBewareRect2.Right ())) &&
    1209           0 :                         ((bUnt2 && aBewareRect2.Bottom()>aBewareRect1.Top   ()) ||
    1210           0 :                          (bObn2 && aBewareRect2.Top   ()<aBewareRect1.Bottom()))) ||
    1211           0 :                        (((bRts2 && aBewareRect2.Right ()>aBewareRect1.Left  ()) ||
    1212           0 :                          (bLks2 && aBewareRect2.Left  ()<aBewareRect1.Right ())) &&
    1213           0 :                         ((bUnt1 && aBewareRect1.Bottom()>aBewareRect2.Top   ()) ||
    1214           0 :                          (bObn1 && aBewareRect1.Top   ()<aBewareRect2.Bottom())))) {
    1215             :                 // case 3.3
    1216           0 :                 if (bRts1 || bRts2) { aMeeting.X()=nXMax; }
    1217           0 :                 if (bLks1 || bLks2) { aMeeting.X()=nXMin; }
    1218           0 :                 if (bUnt1 || bUnt2) { aMeeting.Y()=nYMax; }
    1219           0 :                 if (bObn1 || bObn2) { aMeeting.Y()=nYMin; }
    1220             :             }
    1221             :         }
    1222             :     }
    1223             : 
    1224          32 :     XPolygon aXP1(ImpCalcObjToCenter(aPt1,nAngle1,aBewareRect1,aMeeting));
    1225          64 :     XPolygon aXP2(ImpCalcObjToCenter(aPt2,nAngle2,aBewareRect2,aMeeting));
    1226          32 :     sal_uInt16 nXP1Anz=aXP1.GetPointCount();
    1227          32 :     sal_uInt16 nXP2Anz=aXP2.GetPointCount();
    1228          32 :     if (bInfo) {
    1229          32 :         pInfo->nObj1Lines=nXP1Anz; if (nXP1Anz>1) pInfo->nObj1Lines--;
    1230          32 :         pInfo->nObj2Lines=nXP2Anz; if (nXP2Anz>1) pInfo->nObj2Lines--;
    1231             :     }
    1232          32 :     Point aEP1(aXP1[nXP1Anz-1]);
    1233          32 :     Point aEP2(aXP2[nXP2Anz-1]);
    1234          32 :     bool bInsMeetingPoint=aEP1.X()!=aEP2.X() && aEP1.Y()!=aEP2.Y();
    1235          32 :     bool bHorzE1=aEP1.Y()==aXP1[nXP1Anz-2].Y(); // is last line of XP1 horizontal?
    1236          32 :     bool bHorzE2=aEP2.Y()==aXP2[nXP2Anz-2].Y(); // is last line of XP2 horizontal?
    1237          32 :     if (aEP1==aEP2 && ((bHorzE1 && bHorzE2 && aEP1.Y()==aEP2.Y()) || (!bHorzE1 && !bHorzE2 && aEP1.X()==aEP2.X()))) {
    1238             :         // special casing 'I' connectors
    1239          28 :         nXP1Anz--; aXP1.Remove(nXP1Anz,1);
    1240          28 :         nXP2Anz--; aXP2.Remove(nXP2Anz,1);
    1241             :     }
    1242          32 :     if (bInsMeetingPoint) {
    1243           0 :         aXP1.Insert(XPOLY_APPEND,aMeeting,XPOLY_NORMAL);
    1244           0 :         if (bInfo) {
    1245             :             // Inserting a MeetingPoint adds 2 new lines,
    1246             :             // either might become the center line.
    1247           0 :             if (pInfo->nObj1Lines==pInfo->nObj2Lines) {
    1248           0 :                 pInfo->nObj1Lines++;
    1249           0 :                 pInfo->nObj2Lines++;
    1250             :             } else {
    1251           0 :                 if (pInfo->nObj1Lines>pInfo->nObj2Lines) {
    1252           0 :                     pInfo->nObj2Lines++;
    1253           0 :                     pInfo->nMiddleLine=nXP1Anz-1;
    1254             :                 } else {
    1255           0 :                     pInfo->nObj1Lines++;
    1256           0 :                     pInfo->nMiddleLine=nXP1Anz;
    1257             :                 }
    1258             :             }
    1259             :         }
    1260          32 :     } else if (bInfo && aEP1!=aEP2 && nXP1Anz+nXP2Anz>=4) {
    1261             :         // By connecting both ends, another line is added, this becomes the center line.
    1262           4 :         pInfo->nMiddleLine=nXP1Anz-1;
    1263             :     }
    1264          32 :     sal_uInt16 nNum=aXP2.GetPointCount();
    1265          32 :     if (aXP1[nXP1Anz-1]==aXP2[nXP2Anz-1] && nXP1Anz>1 && nXP2Anz>1) nNum--;
    1266         102 :     while (nNum>0) {
    1267          38 :         nNum--;
    1268          38 :         aXP1.Insert(XPOLY_APPEND,aXP2[nNum],XPOLY_NORMAL);
    1269             :     }
    1270          32 :     sal_uInt16 nPntAnz=aXP1.GetPointCount();
    1271          32 :     char cForm=0;
    1272          32 :     if (bInfo || pnQuality!=NULL) {
    1273          32 :         cForm='?';
    1274          32 :         if (nPntAnz==2) cForm='I';
    1275           4 :         else if (nPntAnz==3) cForm='L';
    1276           4 :         else if (nPntAnz==4) { // Z or U
    1277           0 :             if (nAngle1==nAngle2) cForm='U';
    1278           0 :             else cForm='Z';
    1279           4 :         } else if (nPntAnz==6) { // S or C or ...
    1280           0 :             if (nAngle1!=nAngle2) {
    1281             :                 // For type S, line 2 has the same direction as line 4.
    1282             :                 // For type C, the opposite is true.
    1283           0 :                 Point aP1(aXP1[1]);
    1284           0 :                 Point aP2(aXP1[2]);
    1285           0 :                 Point aP3(aXP1[3]);
    1286           0 :                 Point aP4(aXP1[4]);
    1287           0 :                 if (aP1.Y()==aP2.Y()) { // else both lines are horizontal
    1288           0 :                     if ((aP1.X()<aP2.X())==(aP3.X()<aP4.X())) cForm='S';
    1289           0 :                     else cForm='C';
    1290             :                 } else { // else both lines are vertical
    1291           0 :                     if ((aP1.Y()<aP2.Y())==(aP3.Y()<aP4.Y())) cForm='S';
    1292           0 :                     else cForm='C';
    1293             :                 }
    1294           0 :             } else cForm='4'; // else is case 3 with 5 lines
    1295           4 :         } else cForm='?';
    1296             :         // more shapes:
    1297          32 :         if (bInfo) {
    1298          32 :             pInfo->cOrthoForm=cForm;
    1299          32 :             if (cForm=='I' || cForm=='L' || cForm=='Z' || cForm=='U') {
    1300          28 :                 pInfo->nObj1Lines=1;
    1301          28 :                 pInfo->nObj2Lines=1;
    1302          56 :                 if (cForm=='Z' || cForm=='U') {
    1303           0 :                     pInfo->nMiddleLine=1;
    1304             :                 } else {
    1305          28 :                     pInfo->nMiddleLine=0xFFFF;
    1306             :                 }
    1307           4 :             } else if (cForm=='S' || cForm=='C') {
    1308           0 :                 pInfo->nObj1Lines=2;
    1309           0 :                 pInfo->nObj2Lines=2;
    1310           0 :                 pInfo->nMiddleLine=2;
    1311             :             }
    1312             :         }
    1313             :     }
    1314          32 :     if (pnQuality!=NULL) {
    1315          32 :         sal_uIntPtr nQual=0;
    1316          32 :         sal_uIntPtr nQual0=nQual; // prevent overruns
    1317          32 :         bool bOverflow = false;
    1318          32 :         Point aPt0(aXP1[0]);
    1319          76 :         for (sal_uInt16 nPntNum=1; nPntNum<nPntAnz; nPntNum++) {
    1320          44 :             Point aPt1b(aXP1[nPntNum]);
    1321          44 :             nQual+=std::abs(aPt1b.X()-aPt0.X())+std::abs(aPt1b.Y()-aPt0.Y());
    1322          44 :             if (nQual<nQual0) bOverflow = true;
    1323          44 :             nQual0=nQual;
    1324          44 :             aPt0=aPt1b;
    1325             :         }
    1326             : 
    1327          32 :         sal_uInt16 nTmp=nPntAnz;
    1328          32 :         if (cForm=='Z') {
    1329           0 :             nTmp=2; // Z shape with good quality (nTmp=2 instead of 4)
    1330           0 :             sal_uIntPtr n1=std::abs(aXP1[1].X()-aXP1[0].X())+std::abs(aXP1[1].Y()-aXP1[0].Y());
    1331           0 :             sal_uIntPtr n2=std::abs(aXP1[2].X()-aXP1[1].X())+std::abs(aXP1[2].Y()-aXP1[1].Y());
    1332           0 :             sal_uIntPtr n3=std::abs(aXP1[3].X()-aXP1[2].X())+std::abs(aXP1[3].Y()-aXP1[2].Y());
    1333             :             // try to make lines lengths similar
    1334           0 :             sal_uIntPtr nBesser=0;
    1335           0 :             n1+=n3;
    1336           0 :             n3=n2/4;
    1337           0 :             if (n1>=n2) nBesser=6;
    1338           0 :             else if (n1>=3*n3) nBesser=4;
    1339           0 :             else if (n1>=2*n3) nBesser=2;
    1340           0 :             if (aXP1[0].Y()!=aXP1[1].Y()) nBesser++; // vertical starting line gets a plus (for H/V-Prio)
    1341           0 :             if (nQual>nBesser) nQual-=nBesser; else nQual=0;
    1342             :         }
    1343          32 :         if (nTmp>=3) {
    1344           4 :             nQual0=nQual;
    1345           4 :             nQual+=(sal_uIntPtr)nTmp*0x01000000;
    1346           4 :             if (nQual<nQual0 || nTmp>15) bOverflow = true;
    1347             :         }
    1348          32 :         if (nPntAnz>=2) { // check exit angle again
    1349          32 :             Point aP1(aXP1[1]); aP1-=aXP1[0];
    1350          32 :             Point aP2(aXP1[nPntAnz-2]); aP2-=aXP1[nPntAnz-1];
    1351          32 :             long nAng1=0; if (aP1.X()<0) nAng1=18000; if (aP1.Y()>0) nAng1=27000;
    1352          32 :             if (aP1.Y()<0) nAng1=9000; if (aP1.X()!=0 && aP1.Y()!=0) nAng1=1; // slant?!
    1353          32 :             long nAng2=0; if (aP2.X()<0) nAng2=18000; if (aP2.Y()>0) nAng2=27000;
    1354          32 :             if (aP2.Y()<0) nAng2=9000; if (aP2.X()!=0 && aP2.Y()!=0) nAng2=1; // slant?!
    1355          32 :             if (nAng1!=nAngle1) nIntersections++;
    1356          32 :             if (nAng2!=nAngle2) nIntersections++;
    1357             :         }
    1358             : 
    1359             :         // For the quality check, use the original Rects and at the same time
    1360             :         // check whether one them was scaled down for the calculation of the
    1361             :         // Edges (e. g. case 2.9)
    1362          32 :         aBewareRect1=rBewareRect1;
    1363          32 :         aBewareRect2=rBewareRect2;
    1364             : 
    1365         108 :         for (sal_uInt16 i=0; i<nPntAnz; i++) {
    1366          76 :             Point aPt1b(aXP1[i]);
    1367          76 :             bool b1=aPt1b.X()>aBewareRect1.Left() && aPt1b.X()<aBewareRect1.Right() &&
    1368          76 :                         aPt1b.Y()>aBewareRect1.Top() && aPt1b.Y()<aBewareRect1.Bottom();
    1369          76 :             bool b2=aPt1b.X()>aBewareRect2.Left() && aPt1b.X()<aBewareRect2.Right() &&
    1370          76 :                         aPt1b.Y()>aBewareRect2.Top() && aPt1b.Y()<aBewareRect2.Bottom();
    1371          76 :             sal_uInt16 nInt0=nIntersections;
    1372          76 :             if (i==0 || i==nPntAnz-1) {
    1373          64 :                 if (b1 && b2) nIntersections++;
    1374             :             } else {
    1375          12 :                 if (b1) nIntersections++;
    1376          12 :                 if (b2) nIntersections++;
    1377             :             }
    1378             :             // check for overlaps
    1379          76 :             if (i>0 && nInt0==nIntersections) {
    1380          44 :                 if (aPt0.Y()==aPt1b.Y()) { // horizontal line
    1381          36 :                     if (aPt0.Y()>aBewareRect1.Top() && aPt0.Y()<aBewareRect1.Bottom() &&
    1382           0 :                         ((aPt0.X()<=aBewareRect1.Left() && aPt1b.X()>=aBewareRect1.Right()) ||
    1383           0 :                          (aPt1b.X()<=aBewareRect1.Left() && aPt0.X()>=aBewareRect1.Right()))) nIntersections++;
    1384          36 :                     if (aPt0.Y()>aBewareRect2.Top() && aPt0.Y()<aBewareRect2.Bottom() &&
    1385           0 :                         ((aPt0.X()<=aBewareRect2.Left() && aPt1b.X()>=aBewareRect2.Right()) ||
    1386           0 :                          (aPt1b.X()<=aBewareRect2.Left() && aPt0.X()>=aBewareRect2.Right()))) nIntersections++;
    1387             :                 } else { // vertical line
    1388           8 :                     if (aPt0.X()>aBewareRect1.Left() && aPt0.X()<aBewareRect1.Right() &&
    1389           0 :                         ((aPt0.Y()<=aBewareRect1.Top() && aPt1b.Y()>=aBewareRect1.Bottom()) ||
    1390           0 :                          (aPt1b.Y()<=aBewareRect1.Top() && aPt0.Y()>=aBewareRect1.Bottom()))) nIntersections++;
    1391           8 :                     if (aPt0.X()>aBewareRect2.Left() && aPt0.X()<aBewareRect2.Right() &&
    1392           0 :                         ((aPt0.Y()<=aBewareRect2.Top() && aPt1b.Y()>=aBewareRect2.Bottom()) ||
    1393           0 :                          (aPt1b.Y()<=aBewareRect2.Top() && aPt0.Y()>=aBewareRect2.Bottom()))) nIntersections++;
    1394             :                 }
    1395             :             }
    1396          76 :             aPt0=aPt1b;
    1397             :         }
    1398          32 :         if (nPntAnz<=1) nIntersections++;
    1399          32 :         nQual0=nQual;
    1400          32 :         nQual+=(sal_uIntPtr)nIntersections*0x10000000;
    1401          32 :         if (nQual<nQual0 || nIntersections>15) bOverflow = true;
    1402             : 
    1403          32 :         if (bOverflow || nQual==0xFFFFFFFF) nQual=0xFFFFFFFE;
    1404          32 :         *pnQuality=nQual;
    1405             :     }
    1406          32 :     if (bInfo) { // now apply line offsets to aXP1
    1407          32 :         if (pInfo->nMiddleLine!=0xFFFF) {
    1408           4 :             sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(MIDDLELINE,aXP1);
    1409           4 :             if (pInfo->ImpIsHorzLine(MIDDLELINE,aXP1)) {
    1410           2 :                 aXP1[nIdx].Y()+=pInfo->aMiddleLine.Y();
    1411           2 :                 aXP1[nIdx+1].Y()+=pInfo->aMiddleLine.Y();
    1412             :             } else {
    1413           2 :                 aXP1[nIdx].X()+=pInfo->aMiddleLine.X();
    1414           2 :                 aXP1[nIdx+1].X()+=pInfo->aMiddleLine.X();
    1415             :             }
    1416             :         }
    1417          32 :         if (pInfo->nObj1Lines>=2) {
    1418           2 :             sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE2,aXP1);
    1419           2 :             if (pInfo->ImpIsHorzLine(OBJ1LINE2,aXP1)) {
    1420           2 :                 aXP1[nIdx].Y()+=pInfo->aObj1Line2.Y();
    1421           2 :                 aXP1[nIdx+1].Y()+=pInfo->aObj1Line2.Y();
    1422             :             } else {
    1423           0 :                 aXP1[nIdx].X()+=pInfo->aObj1Line2.X();
    1424           0 :                 aXP1[nIdx+1].X()+=pInfo->aObj1Line2.X();
    1425             :             }
    1426             :         }
    1427          32 :         if (pInfo->nObj1Lines>=3) {
    1428           0 :             sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE3,aXP1);
    1429           0 :             if (pInfo->ImpIsHorzLine(OBJ1LINE3,aXP1)) {
    1430           0 :                 aXP1[nIdx].Y()+=pInfo->aObj1Line3.Y();
    1431           0 :                 aXP1[nIdx+1].Y()+=pInfo->aObj1Line3.Y();
    1432             :             } else {
    1433           0 :                 aXP1[nIdx].X()+=pInfo->aObj1Line3.X();
    1434           0 :                 aXP1[nIdx+1].X()+=pInfo->aObj1Line3.X();
    1435             :             }
    1436             :         }
    1437          32 :         if (pInfo->nObj2Lines>=2) {
    1438           2 :             sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE2,aXP1);
    1439           2 :             if (pInfo->ImpIsHorzLine(OBJ2LINE2,aXP1)) {
    1440           2 :                 aXP1[nIdx].Y()+=pInfo->aObj2Line2.Y();
    1441           2 :                 aXP1[nIdx+1].Y()+=pInfo->aObj2Line2.Y();
    1442             :             } else {
    1443           0 :                 aXP1[nIdx].X()+=pInfo->aObj2Line2.X();
    1444           0 :                 aXP1[nIdx+1].X()+=pInfo->aObj2Line2.X();
    1445             :             }
    1446             :         }
    1447          32 :         if (pInfo->nObj2Lines>=3) {
    1448           0 :             sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE3,aXP1);
    1449           0 :             if (pInfo->ImpIsHorzLine(OBJ2LINE3,aXP1)) {
    1450           0 :                 aXP1[nIdx].Y()+=pInfo->aObj2Line3.Y();
    1451           0 :                 aXP1[nIdx+1].Y()+=pInfo->aObj2Line3.Y();
    1452             :             } else {
    1453           0 :                 aXP1[nIdx].X()+=pInfo->aObj2Line3.X();
    1454           0 :                 aXP1[nIdx+1].X()+=pInfo->aObj2Line3.X();
    1455             :             }
    1456             :         }
    1457             :     }
    1458             :     // make the connector a bezier curve, if appropriate
    1459          32 :     if (eKind==SDREDGE_BEZIER && nPntAnz>2) {
    1460           0 :         Point* pPt1=&aXP1[0];
    1461           0 :         Point* pPt2=&aXP1[1];
    1462           0 :         Point* pPt3=&aXP1[nPntAnz-2];
    1463           0 :         Point* pPt4=&aXP1[nPntAnz-1];
    1464           0 :         long dx1=pPt2->X()-pPt1->X();
    1465           0 :         long dy1=pPt2->Y()-pPt1->Y();
    1466           0 :         long dx2=pPt3->X()-pPt4->X();
    1467           0 :         long dy2=pPt3->Y()-pPt4->Y();
    1468           0 :         if (cForm=='L') { // nPntAnz==3
    1469           0 :             aXP1.SetFlags(1,XPOLY_CONTROL);
    1470           0 :             Point aPt3(*pPt2);
    1471           0 :             aXP1.Insert(2,aPt3,XPOLY_CONTROL);
    1472           0 :             nPntAnz=aXP1.GetPointCount();
    1473           0 :             pPt2=&aXP1[1];
    1474           0 :             pPt3=&aXP1[nPntAnz-2];
    1475           0 :             pPt2->X()-=dx1/3;
    1476           0 :             pPt2->Y()-=dy1/3;
    1477           0 :             pPt3->X()-=dx2/3;
    1478           0 :             pPt3->Y()-=dy2/3;
    1479           0 :         } else if (nPntAnz>=4 && nPntAnz<=6) { // Z or U or ...
    1480             :             // To all others, the end points of the original lines become control
    1481             :             // points for now. Thus, we need to do some more work for nPntAnz>4!
    1482           0 :             aXP1.SetFlags(1,XPOLY_CONTROL);
    1483           0 :             aXP1.SetFlags(nPntAnz-2,XPOLY_CONTROL);
    1484             :             // distance x1.5
    1485           0 :             pPt2->X()+=dx1/2;
    1486           0 :             pPt2->Y()+=dy1/2;
    1487           0 :             pPt3->X()+=dx2/2;
    1488           0 :             pPt3->Y()+=dy2/2;
    1489           0 :             if (nPntAnz==5) {
    1490             :                 // add a control point before and after center
    1491           0 :                 Point aCenter(aXP1[2]);
    1492           0 :                 long dx1b=aCenter.X()-aXP1[1].X();
    1493           0 :                 long dy1b=aCenter.Y()-aXP1[1].Y();
    1494           0 :                 long dx2b=aCenter.X()-aXP1[3].X();
    1495           0 :                 long dy2b=aCenter.Y()-aXP1[3].Y();
    1496           0 :                 aXP1.Insert(2,aCenter,XPOLY_CONTROL);
    1497           0 :                 aXP1.SetFlags(3,XPOLY_SYMMTR);
    1498           0 :                 aXP1.Insert(4,aCenter,XPOLY_CONTROL);
    1499           0 :                 aXP1[2].X()-=dx1b/2;
    1500           0 :                 aXP1[2].Y()-=dy1b/2;
    1501           0 :                 aXP1[3].X()-=(dx1b+dx2b)/4;
    1502           0 :                 aXP1[3].Y()-=(dy1b+dy2b)/4;
    1503           0 :                 aXP1[4].X()-=dx2b/2;
    1504           0 :                 aXP1[4].Y()-=dy2b/2;
    1505             :             }
    1506           0 :             if (nPntAnz==6) {
    1507           0 :                 Point aPt1b(aXP1[2]);
    1508           0 :                 Point aPt2b(aXP1[3]);
    1509           0 :                 aXP1.Insert(2,aPt1b,XPOLY_CONTROL);
    1510           0 :                 aXP1.Insert(5,aPt2b,XPOLY_CONTROL);
    1511           0 :                 long dx=aPt1b.X()-aPt2b.X();
    1512           0 :                 long dy=aPt1b.Y()-aPt2b.Y();
    1513           0 :                 aXP1[3].X()-=dx/2;
    1514           0 :                 aXP1[3].Y()-=dy/2;
    1515           0 :                 aXP1.SetFlags(3,XPOLY_SYMMTR);
    1516           0 :                 aXP1.Remove(4,1); // because it's identical with aXP1[3]
    1517             :             }
    1518             :         }
    1519             :     }
    1520          64 :     return aXP1;
    1521             : }
    1522             : 
    1523             : /*
    1524             : There could be a maximum of 64 different developments with with 5 lines, a
    1525             : maximum of 32 developments with 4 lines, a maximum of 16 developments with
    1526             : 3 lines, a maximum of 8 developments with 2 lines.
    1527             : This gives us a total of 124 possibilities.
    1528             : Normalized for the 1st exit angle to the right, there remain 31 possibilities.
    1529             : Now, normalizing away the vertical mirroring, we get to a total of 16
    1530             : characteristic developments with 1 through 5 lines:
    1531             : 
    1532             : 1 line  (type "I")  --
    1533             : 
    1534             : 2 lines (type "L")  __|
    1535             : 
    1536             : 3 lines (type "U")  __          (type "Z")      _
    1537             :                     __|                       _|
    1538             :                                      _                              _
    1539             : 4 lines          #1   _|        #2  | |         #3 |_          #4  | |
    1540             :                     _|             _|               _|              _|
    1541             :     Of these, #1 is implausible, #2 is a rotated version of #3. This leaves
    1542             :     #2 (from now on referred to as 4.1) and #4 (from now on referred to as 4.2).
    1543             :                       _                _
    1544             : 5 lines          #1   _|        #2   _|         #3   ___       #4   _
    1545             :                     _|             _|              _|  _|         _| |_
    1546             :                     _               _                _
    1547             :                  #5  |_         #6 |_           #7 _| |        #8  ____
    1548             :                       _|            _|               _|           |_  _|
    1549             :     Of these, 5.1, 5.2, 5.4 and 5.5 are implausible, 5.7 is a reversed version
    1550             :     of 5.3. This leaves 5.3 (type "4"), 5.6 (type "S") and 5.8 (type "C").
    1551             : 
    1552             : We now have discerned the 9 basic types to cover all 400 possible constellations
    1553             : of object positions and exit angles. 4 of the 9 types have got a center
    1554             : line (CL). The number of object margins per object varies between 0 and 3:
    1555             : 
    1556             :         CL      O1      O2      Note
    1557             : "I":    n       0       0
    1558             : "L":    n       0       0
    1559             : "U":    n       0-1     0-1
    1560             : "Z":    y       0       0
    1561             : 4.2:    y       0       1       = U+1, respectively 1+U
    1562             : 4.4:    n       0-2     0-2     = Z+1
    1563             : "4":    y       0       2       = Z+2
    1564             : "S":    y       1       1       = 1+Z+1
    1565             : "C":    n       0-3     0-3     = 1+U+1
    1566             : */
    1567             : 
    1568           2 : void SdrEdgeObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
    1569             : {
    1570           2 :     SfxSimpleHint* pSimple=PTR_CAST(SfxSimpleHint,&rHint);
    1571           2 :     sal_uIntPtr nId=pSimple==0 ? 0 : pSimple->GetId();
    1572           2 :     bool bDataChg=nId==SFX_HINT_DATACHANGED;
    1573           2 :     bool bDying=nId==SFX_HINT_DYING;
    1574           2 :     bool bObj1=aCon1.pObj!=NULL && aCon1.pObj->GetBroadcaster()==&rBC;
    1575           2 :     bool bObj2=aCon2.pObj!=NULL && aCon2.pObj->GetBroadcaster()==&rBC;
    1576           2 :     if (bDying && (bObj1 || bObj2)) {
    1577             :         // catch Dying, so AttrObj doesn't start broadcasting
    1578             :         // about an alleged change of template
    1579           0 :         if (bObj1) aCon1.pObj=NULL;
    1580           0 :         if (bObj2) aCon2.pObj=NULL;
    1581           2 :         return;
    1582             :     }
    1583           2 :     if ( bObj1 || bObj2 )
    1584             :     {
    1585           2 :         bEdgeTrackUserDefined = false;
    1586             :     }
    1587           2 :     SdrTextObj::Notify(rBC,rHint);
    1588           2 :     if (nNotifyingCount==0) { // a locking flag
    1589           2 :         ((SdrEdgeObj*)this)->nNotifyingCount++;
    1590           2 :         SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
    1591           2 :         if (bDataChg) { // StyleSheet changed
    1592           2 :             ImpSetAttrToEdgeInfo(); // when changing templates, copy values from Pool to aEdgeInfo
    1593             :         }
    1594           2 :         if (bDataChg                                ||
    1595           0 :             (bObj1 && aCon1.pObj->GetPage()==pPage) ||
    1596           4 :             (bObj2 && aCon2.pObj->GetPage()==pPage) ||
    1597           0 :             (pSdrHint && pSdrHint->GetKind()==HINT_OBJREMOVED))
    1598             :         {
    1599             :             // broadcasting only, if on the same page
    1600           2 :             Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetCurrentBoundRect();
    1601           2 :             ImpDirtyEdgeTrack();
    1602             : 
    1603             :             // only redraw here, object hasn't actually changed
    1604           2 :             ActionChanged();
    1605             : 
    1606           2 :             SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
    1607             :         }
    1608           2 :         ((SdrEdgeObj*)this)->nNotifyingCount--;
    1609             :     }
    1610             : }
    1611             : 
    1612             : /** updates edges that are connected to the edges of this object
    1613             :     as if the connected objects sent a repaint broadcast
    1614             : */
    1615           3 : void SdrEdgeObj::Reformat()
    1616             : {
    1617           3 :     if( NULL != aCon1.pObj )
    1618             :     {
    1619           1 :         SfxSimpleHint aHint( SFX_HINT_DATACHANGED );
    1620           1 :         Notify( *const_cast<SfxBroadcaster*>(aCon1.pObj->GetBroadcaster()), aHint );
    1621             :     }
    1622             : 
    1623           3 :     if( NULL != aCon2.pObj )
    1624             :     {
    1625           1 :         SfxSimpleHint aHint( SFX_HINT_DATACHANGED );
    1626           1 :         Notify( *const_cast<SfxBroadcaster*>(aCon2.pObj->GetBroadcaster()), aHint );
    1627             :     }
    1628           3 : }
    1629             : 
    1630           0 : SdrEdgeObj* SdrEdgeObj::Clone() const
    1631             : {
    1632           0 :     return CloneHelper< SdrEdgeObj >();
    1633             : }
    1634             : 
    1635           0 : SdrEdgeObj& SdrEdgeObj::operator=(const SdrEdgeObj& rObj)
    1636             : {
    1637           0 :     if( this == &rObj )
    1638           0 :         return *this;
    1639           0 :     SdrTextObj::operator=(rObj);
    1640           0 :     *pEdgeTrack    =*rObj.pEdgeTrack;
    1641           0 :     bEdgeTrackDirty=rObj.bEdgeTrackDirty;
    1642           0 :     aCon1          =rObj.aCon1;
    1643           0 :     aCon2          =rObj.aCon2;
    1644           0 :     aCon1.pObj=NULL;
    1645           0 :     aCon2.pObj=NULL;
    1646           0 :     aEdgeInfo=rObj.aEdgeInfo;
    1647           0 :     return *this;
    1648             : }
    1649             : 
    1650           0 : OUString SdrEdgeObj::TakeObjNameSingul() const
    1651             : {
    1652           0 :     OUStringBuffer sName(ImpGetResStr(STR_ObjNameSingulEDGE));
    1653             : 
    1654           0 :     OUString aName(GetName());
    1655           0 :     if (!aName.isEmpty())
    1656             :     {
    1657           0 :         sName.append(' ');
    1658           0 :         sName.append('\'');
    1659           0 :         sName.append(aName);
    1660           0 :         sName.append('\'');
    1661             :     }
    1662           0 :     return sName.makeStringAndClear();
    1663             : }
    1664             : 
    1665           0 : OUString SdrEdgeObj::TakeObjNamePlural() const
    1666             : {
    1667           0 :     return ImpGetResStr(STR_ObjNamePluralEDGE);
    1668             : }
    1669             : 
    1670           0 : basegfx::B2DPolyPolygon SdrEdgeObj::TakeXorPoly() const
    1671             : {
    1672           0 :     basegfx::B2DPolyPolygon aPolyPolygon;
    1673             : 
    1674           0 :     if (bEdgeTrackDirty)
    1675             :     {
    1676           0 :         ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
    1677             :     }
    1678             : 
    1679           0 :     if(pEdgeTrack)
    1680             :     {
    1681           0 :         aPolyPolygon.append(pEdgeTrack->getB2DPolygon());
    1682             :     }
    1683             : 
    1684           0 :     return aPolyPolygon;
    1685             : }
    1686             : 
    1687          33 : void SdrEdgeObj::SetEdgeTrackPath( const basegfx::B2DPolyPolygon& rPoly )
    1688             : {
    1689          33 :     if ( !rPoly.count() )
    1690             :     {
    1691          32 :         bEdgeTrackDirty = true;
    1692          32 :         bEdgeTrackUserDefined = false;
    1693             :     }
    1694             :     else
    1695             :     {
    1696           1 :         *pEdgeTrack = XPolygon( rPoly.getB2DPolygon( 0 ) );
    1697           1 :         bEdgeTrackDirty = false;
    1698           1 :         bEdgeTrackUserDefined = true;
    1699             : 
    1700             :         // #i110629# also set aRect and maSnapeRect depending on pEdgeTrack
    1701           1 :         const Rectangle aPolygonBounds(pEdgeTrack->GetBoundRect());
    1702           1 :         aRect = aPolygonBounds;
    1703           1 :         maSnapRect = aPolygonBounds;
    1704             :     }
    1705          33 : }
    1706             : 
    1707           1 : basegfx::B2DPolyPolygon SdrEdgeObj::GetEdgeTrackPath() const
    1708             : {
    1709           1 :     basegfx::B2DPolyPolygon aPolyPolygon;
    1710             : 
    1711           1 :     if (bEdgeTrackDirty)
    1712           0 :         ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
    1713             : 
    1714           1 :     aPolyPolygon.append( pEdgeTrack->getB2DPolygon() );
    1715             : 
    1716           1 :     return aPolyPolygon;
    1717             : }
    1718             : 
    1719           0 : sal_uInt32 SdrEdgeObj::GetHdlCount() const
    1720             : {
    1721           0 :     SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
    1722           0 :     sal_uInt32 nHdlAnz(0L);
    1723           0 :     sal_uInt32 nPntAnz(pEdgeTrack->GetPointCount());
    1724             : 
    1725           0 :     if(nPntAnz)
    1726             :     {
    1727           0 :         nHdlAnz = 2L;
    1728             : 
    1729           0 :         if ((eKind==SDREDGE_ORTHOLINES || eKind==SDREDGE_BEZIER) && nPntAnz >= 4L)
    1730             :         {
    1731           0 :             sal_uInt32 nO1(aEdgeInfo.nObj1Lines > 0L ? aEdgeInfo.nObj1Lines - 1L : 0L);
    1732           0 :             sal_uInt32 nO2(aEdgeInfo.nObj2Lines > 0L ? aEdgeInfo.nObj2Lines - 1L : 0L);
    1733           0 :             sal_uInt32 nM(aEdgeInfo.nMiddleLine != 0xFFFF ? 1L : 0L);
    1734           0 :             nHdlAnz += nO1 + nO2 + nM;
    1735             :         }
    1736           0 :         else if (eKind==SDREDGE_THREELINES && nPntAnz == 4L)
    1737             :         {
    1738           0 :             if(GetConnectedNode(true))
    1739           0 :                 nHdlAnz++;
    1740             : 
    1741           0 :             if(GetConnectedNode(false))
    1742           0 :                 nHdlAnz++;
    1743             :         }
    1744             :     }
    1745             : 
    1746           0 :     return nHdlAnz;
    1747             : }
    1748             : 
    1749           0 : SdrHdl* SdrEdgeObj::GetHdl(sal_uInt32 nHdlNum) const
    1750             : {
    1751           0 :     SdrHdl* pHdl=NULL;
    1752           0 :     sal_uInt32 nPntAnz(pEdgeTrack->GetPointCount());
    1753           0 :     if (nPntAnz!=0) {
    1754           0 :         if (nHdlNum==0) {
    1755           0 :             pHdl=new ImpEdgeHdl((*pEdgeTrack)[0],HDL_POLY);
    1756           0 :             if (aCon1.pObj!=NULL && aCon1.bBestVertex) pHdl->Set1PixMore(true);
    1757           0 :         } else if (nHdlNum==1) {
    1758           0 :             pHdl=new ImpEdgeHdl((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],HDL_POLY);
    1759           0 :             if (aCon2.pObj!=NULL && aCon2.bBestVertex) pHdl->Set1PixMore(true);
    1760             :         } else {
    1761           0 :             SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
    1762           0 :             if (eKind==SDREDGE_ORTHOLINES || eKind==SDREDGE_BEZIER) {
    1763           0 :                 sal_uInt32 nO1(aEdgeInfo.nObj1Lines > 0L ? aEdgeInfo.nObj1Lines - 1L : 0L);
    1764           0 :                 sal_uInt32 nO2(aEdgeInfo.nObj2Lines > 0L ? aEdgeInfo.nObj2Lines - 1L : 0L);
    1765           0 :                 sal_uInt32 nM(aEdgeInfo.nMiddleLine != 0xFFFF ? 1L : 0L);
    1766           0 :                 sal_uInt32 nNum(nHdlNum - 2L);
    1767           0 :                 sal_Int32 nPt(0L);
    1768           0 :                 pHdl=new ImpEdgeHdl(Point(),HDL_POLY);
    1769           0 :                 if (nNum<nO1) {
    1770           0 :                     nPt=nNum+1L;
    1771           0 :                     if (nNum==0) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE2);
    1772           0 :                     if (nNum==1) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE3);
    1773             :                 } else {
    1774           0 :                     nNum=nNum-nO1;
    1775           0 :                     if (nNum<nO2) {
    1776           0 :                         nPt=nPntAnz-3-nNum;
    1777           0 :                         if (nNum==0) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE2);
    1778           0 :                         if (nNum==1) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE3);
    1779             :                     } else {
    1780           0 :                         nNum=nNum-nO2;
    1781           0 :                         if (nNum<nM) {
    1782           0 :                             nPt=aEdgeInfo.nMiddleLine;
    1783           0 :                             ((ImpEdgeHdl*)pHdl)->SetLineCode(MIDDLELINE);
    1784             :                         }
    1785             :                     }
    1786             :                 }
    1787           0 :                 if (nPt>0) {
    1788           0 :                     Point aPos((*pEdgeTrack)[(sal_uInt16)nPt]);
    1789           0 :                     aPos+=(*pEdgeTrack)[(sal_uInt16)nPt+1];
    1790           0 :                     aPos.X()/=2;
    1791           0 :                     aPos.Y()/=2;
    1792           0 :                     pHdl->SetPos(aPos);
    1793             :                 } else {
    1794           0 :                     delete pHdl;
    1795           0 :                     pHdl=NULL;
    1796           0 :                 }
    1797           0 :             } else if (eKind==SDREDGE_THREELINES) {
    1798           0 :                 sal_uInt32 nNum(nHdlNum);
    1799           0 :                 if (GetConnectedNode(true)==NULL) nNum++;
    1800           0 :                 Point aPos((*pEdgeTrack)[(sal_uInt16)nNum-1]);
    1801           0 :                 pHdl=new ImpEdgeHdl(aPos,HDL_POLY);
    1802           0 :                 if (nNum==2) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE2);
    1803           0 :                 if (nNum==3) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE2);
    1804             :             }
    1805             :         }
    1806           0 :         if (pHdl!=NULL) {
    1807           0 :             pHdl->SetPointNum(nHdlNum);
    1808             :         }
    1809             :     }
    1810           0 :     return pHdl;
    1811             : }
    1812             : 
    1813             : 
    1814             : 
    1815           0 : bool SdrEdgeObj::hasSpecialDrag() const
    1816             : {
    1817           0 :     return true;
    1818             : }
    1819             : 
    1820           0 : SdrObject* SdrEdgeObj::getFullDragClone() const
    1821             : {
    1822             :     // use Clone operator
    1823           0 :     SdrEdgeObj* pRetval = (SdrEdgeObj*)Clone();
    1824             : 
    1825             :     // copy connections for clone, SdrEdgeObj::operator= does not do this
    1826           0 :     pRetval->ConnectToNode(true, GetConnectedNode(true));
    1827           0 :     pRetval->ConnectToNode(false, GetConnectedNode(false));
    1828             : 
    1829           0 :     return pRetval;
    1830             : }
    1831             : 
    1832           0 : bool SdrEdgeObj::beginSpecialDrag(SdrDragStat& rDrag) const
    1833             : {
    1834           0 :     if(!rDrag.GetHdl())
    1835           0 :         return false;
    1836             : 
    1837           0 :     rDrag.SetEndDragChangesAttributes(true);
    1838             : 
    1839           0 :     if(rDrag.GetHdl()->GetPointNum() < 2)
    1840             :     {
    1841           0 :         rDrag.SetNoSnap(true);
    1842             :     }
    1843             : 
    1844           0 :     return true;
    1845             : }
    1846             : 
    1847           0 : bool SdrEdgeObj::applySpecialDrag(SdrDragStat& rDragStat)
    1848             : {
    1849           0 :     SdrEdgeObj* pOriginalEdge = dynamic_cast< SdrEdgeObj* >(rDragStat.GetHdl()->GetObj());
    1850           0 :     const bool bOriginalEdgeModified(pOriginalEdge == this);
    1851             : 
    1852           0 :     if(!bOriginalEdgeModified && pOriginalEdge)
    1853             :     {
    1854             :         // copy connections when clone is modified. This is needed because
    1855             :         // as preparation to this modification the data from the original object
    1856             :         // was copied to the clone using the operator=. As can be seen there,
    1857             :         // that operator does not copy the connections (for good reason)
    1858           0 :         ConnectToNode(true, pOriginalEdge->GetConnection(true).GetObject());
    1859           0 :         ConnectToNode(false, pOriginalEdge->GetConnection(false).GetObject());
    1860             :     }
    1861             : 
    1862           0 :     if(rDragStat.GetHdl()->GetPointNum() < 2)
    1863             :     {
    1864             :         // start or end point connector drag
    1865           0 :         const bool bDragA(0 == rDragStat.GetHdl()->GetPointNum());
    1866           0 :         const Point aPointNow(rDragStat.GetNow());
    1867             : 
    1868           0 :         if(rDragStat.GetPageView())
    1869             :         {
    1870           0 :             SdrObjConnection* pDraggedOne(bDragA ? &aCon1 : &aCon2);
    1871             : 
    1872             :             // clear connection
    1873           0 :             DisconnectFromNode(bDragA);
    1874             : 
    1875             :             // look for new connection
    1876           0 :             ImpFindConnector(aPointNow, *rDragStat.GetPageView(), *pDraggedOne, pOriginalEdge);
    1877             : 
    1878           0 :             if(pDraggedOne->pObj)
    1879             :             {
    1880             :                 // if found, officially connect to it; ImpFindConnector only
    1881             :                 // sets pObj hard
    1882           0 :                 SdrObject* pNewConnection = pDraggedOne->pObj;
    1883           0 :                 pDraggedOne->pObj = 0;
    1884           0 :                 ConnectToNode(bDragA, pNewConnection);
    1885             :             }
    1886             : 
    1887           0 :             if(rDragStat.GetView() && !bOriginalEdgeModified)
    1888             :             {
    1889             :                 // show IA helper, but only do this during IA, so not when the original
    1890             :                 // Edge gets modified in the last call
    1891           0 :                 rDragStat.GetView()->SetConnectMarker(*pDraggedOne, *rDragStat.GetPageView());
    1892             :             }
    1893             :         }
    1894             : 
    1895           0 :         if(pEdgeTrack)
    1896             :         {
    1897             :             // change pEdgeTrack to modified position
    1898           0 :             if(bDragA)
    1899             :             {
    1900           0 :                 (*pEdgeTrack)[0] = aPointNow;
    1901             :             }
    1902             :             else
    1903             :             {
    1904           0 :                 (*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount()-1)] = aPointNow;
    1905             :             }
    1906             :         }
    1907             : 
    1908             :         // reset edge info's offsets, this is a end point drag
    1909           0 :         aEdgeInfo.aObj1Line2 = Point();
    1910           0 :         aEdgeInfo.aObj1Line3 = Point();
    1911           0 :         aEdgeInfo.aObj2Line2 = Point();
    1912           0 :         aEdgeInfo.aObj2Line3 = Point();
    1913           0 :         aEdgeInfo.aMiddleLine = Point();
    1914             :     }
    1915             :     else
    1916             :     {
    1917             :         // control point connector drag
    1918           0 :         const ImpEdgeHdl* pEdgeHdl = (ImpEdgeHdl*)rDragStat.GetHdl();
    1919           0 :         const SdrEdgeLineCode eLineCode = pEdgeHdl->GetLineCode();
    1920           0 :         const Point aDist(rDragStat.GetNow() - rDragStat.GetStart());
    1921           0 :         sal_Int32 nDist(pEdgeHdl->IsHorzDrag() ? aDist.X() : aDist.Y());
    1922             : 
    1923           0 :         nDist += aEdgeInfo.ImpGetLineVersatz(eLineCode, *pEdgeTrack);
    1924           0 :         aEdgeInfo.ImpSetLineVersatz(eLineCode, *pEdgeTrack, nDist);
    1925             :     }
    1926             : 
    1927             :     // force recalculation of EdgeTrack
    1928           0 :     *pEdgeTrack = ImpCalcEdgeTrack(*pEdgeTrack, aCon1, aCon2, &aEdgeInfo);
    1929           0 :     bEdgeTrackDirty=false;
    1930             : 
    1931             :     // save EdgeInfos and mark object as user modified
    1932           0 :     ImpSetEdgeInfoToAttr();
    1933           0 :     bEdgeTrackUserDefined = false;
    1934             : 
    1935           0 :     SetRectsDirty();
    1936             : 
    1937           0 :     if(bOriginalEdgeModified && rDragStat.GetView())
    1938             :     {
    1939             :         // hide connect marker helper again when original gets changed.
    1940             :         // This happens at the end of the interaction
    1941           0 :         rDragStat.GetView()->HideConnectMarker();
    1942             :     }
    1943             : 
    1944           0 :        return true;
    1945             : }
    1946             : 
    1947           0 : OUString SdrEdgeObj::getSpecialDragComment(const SdrDragStat& rDrag) const
    1948             : {
    1949           0 :     const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj());
    1950             : 
    1951           0 :     if(bCreateComment)
    1952             :     {
    1953           0 :         return OUString();
    1954             :     }
    1955             :     else
    1956             :     {
    1957           0 :         OUString aStr;
    1958           0 :         ImpTakeDescriptionStr(STR_DragEdgeTail, aStr);
    1959             : 
    1960           0 :         return aStr;
    1961             :     }
    1962             : }
    1963             : 
    1964             : 
    1965             : 
    1966           0 : basegfx::B2DPolygon SdrEdgeObj::ImplAddConnectorOverlay(SdrDragMethod& rDragMethod, bool bTail1, bool bTail2, bool bDetail) const
    1967             : {
    1968           0 :     basegfx::B2DPolygon aResult;
    1969             : 
    1970           0 :     if(bDetail)
    1971             :     {
    1972           0 :         SdrObjConnection aMyCon1(aCon1);
    1973           0 :         SdrObjConnection aMyCon2(aCon2);
    1974             : 
    1975           0 :         if (bTail1)
    1976             :         {
    1977           0 :             const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon1.aObjOfs.X(), aMyCon1.aObjOfs.Y()));
    1978           0 :             aMyCon1.aObjOfs.X() = basegfx::fround(aTemp.getX());
    1979           0 :             aMyCon1.aObjOfs.Y() = basegfx::fround(aTemp.getY());
    1980             :         }
    1981             : 
    1982           0 :         if (bTail2)
    1983             :         {
    1984           0 :             const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon2.aObjOfs.X(), aMyCon2.aObjOfs.Y()));
    1985           0 :             aMyCon2.aObjOfs.X() = basegfx::fround(aTemp.getX());
    1986           0 :             aMyCon2.aObjOfs.Y() = basegfx::fround(aTemp.getY());
    1987             :         }
    1988             : 
    1989           0 :         SdrEdgeInfoRec aInfo(aEdgeInfo);
    1990           0 :         XPolygon aXP(ImpCalcEdgeTrack(*pEdgeTrack, aMyCon1, aMyCon2, &aInfo));
    1991             : 
    1992           0 :         if(aXP.GetPointCount())
    1993             :         {
    1994           0 :             aResult = aXP.getB2DPolygon();
    1995           0 :         }
    1996             :     }
    1997             :     else
    1998             :     {
    1999           0 :         Point aPt1((*pEdgeTrack)[0]);
    2000           0 :         Point aPt2((*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount() - 1)]);
    2001             : 
    2002           0 :         if (aCon1.pObj && (aCon1.bBestConn || aCon1.bBestVertex))
    2003           0 :             aPt1 = aCon1.pObj->GetSnapRect().Center();
    2004             : 
    2005           0 :         if (aCon2.pObj && (aCon2.bBestConn || aCon2.bBestVertex))
    2006           0 :             aPt2 = aCon2.pObj->GetSnapRect().Center();
    2007             : 
    2008           0 :         if (bTail1)
    2009             :         {
    2010           0 :             const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt1.X(), aPt1.Y()));
    2011           0 :             aPt1.X() = basegfx::fround(aTemp.getX());
    2012           0 :             aPt1.Y() = basegfx::fround(aTemp.getY());
    2013             :         }
    2014             : 
    2015           0 :         if (bTail2)
    2016             :         {
    2017           0 :             const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt2.X(), aPt2.Y()));
    2018           0 :             aPt2.X() = basegfx::fround(aTemp.getX());
    2019           0 :             aPt2.Y() = basegfx::fround(aTemp.getY());
    2020             :         }
    2021             : 
    2022           0 :         aResult.append(basegfx::B2DPoint(aPt1.X(), aPt1.Y()));
    2023           0 :         aResult.append(basegfx::B2DPoint(aPt2.X(), aPt2.Y()));
    2024             :     }
    2025             : 
    2026           0 :     return aResult;
    2027             : }
    2028             : 
    2029           0 : bool SdrEdgeObj::BegCreate(SdrDragStat& rDragStat)
    2030             : {
    2031           0 :     rDragStat.SetNoSnap(true);
    2032           0 :     pEdgeTrack->SetPointCount(2);
    2033           0 :     (*pEdgeTrack)[0]=rDragStat.GetStart();
    2034           0 :     (*pEdgeTrack)[1]=rDragStat.GetNow();
    2035           0 :     if (rDragStat.GetPageView()!=NULL) {
    2036           0 :         ImpFindConnector(rDragStat.GetStart(),*rDragStat.GetPageView(),aCon1,this);
    2037           0 :         ConnectToNode(true,aCon1.pObj);
    2038             :     }
    2039           0 :     *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
    2040           0 :     return true;
    2041             : }
    2042             : 
    2043           0 : bool SdrEdgeObj::MovCreate(SdrDragStat& rDragStat)
    2044             : {
    2045           0 :     sal_uInt16 nMax=pEdgeTrack->GetPointCount();
    2046           0 :     (*pEdgeTrack)[nMax-1]=rDragStat.GetNow();
    2047           0 :     if (rDragStat.GetPageView()!=NULL) {
    2048           0 :         ImpFindConnector(rDragStat.GetNow(),*rDragStat.GetPageView(),aCon2,this);
    2049           0 :         rDragStat.GetView()->SetConnectMarker(aCon2,*rDragStat.GetPageView());
    2050             :     }
    2051           0 :     SetBoundRectDirty();
    2052           0 :     bSnapRectDirty=true;
    2053           0 :     ConnectToNode(false,aCon2.pObj);
    2054           0 :     *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
    2055           0 :     bEdgeTrackDirty=false;
    2056           0 :     return true;
    2057             : }
    2058             : 
    2059           0 : bool SdrEdgeObj::EndCreate(SdrDragStat& rDragStat, SdrCreateCmd eCmd)
    2060             : {
    2061           0 :     bool bOk=(eCmd==SDRCREATE_FORCEEND || rDragStat.GetPointAnz()>=2);
    2062           0 :     if (bOk) {
    2063           0 :         ConnectToNode(true,aCon1.pObj);
    2064           0 :         ConnectToNode(false,aCon2.pObj);
    2065           0 :         if (rDragStat.GetView()!=NULL) {
    2066           0 :             rDragStat.GetView()->HideConnectMarker();
    2067             :         }
    2068           0 :         ImpSetEdgeInfoToAttr(); // copy values from aEdgeInfo into the pool
    2069             :     }
    2070           0 :     SetRectsDirty();
    2071           0 :     return bOk;
    2072             : }
    2073             : 
    2074           0 : bool SdrEdgeObj::BckCreate(SdrDragStat& rDragStat)
    2075             : {
    2076           0 :     if (rDragStat.GetView()!=NULL) {
    2077           0 :         rDragStat.GetView()->HideConnectMarker();
    2078             :     }
    2079           0 :     return false;
    2080             : }
    2081             : 
    2082           0 : void SdrEdgeObj::BrkCreate(SdrDragStat& rDragStat)
    2083             : {
    2084           0 :     if (rDragStat.GetView()!=NULL) {
    2085           0 :         rDragStat.GetView()->HideConnectMarker();
    2086             :     }
    2087           0 : }
    2088             : 
    2089           0 : basegfx::B2DPolyPolygon SdrEdgeObj::TakeCreatePoly(const SdrDragStat& /*rStatDrag*/) const
    2090             : {
    2091           0 :     basegfx::B2DPolyPolygon aRetval;
    2092           0 :     aRetval.append(pEdgeTrack->getB2DPolygon());
    2093           0 :     return aRetval;
    2094             : }
    2095             : 
    2096           0 : Pointer SdrEdgeObj::GetCreatePointer() const
    2097             : {
    2098           0 :     return Pointer(POINTER_DRAW_CONNECT);
    2099             : }
    2100             : 
    2101           0 : bool SdrEdgeObj::ImpFindConnector(const Point& rPt, const SdrPageView& rPV, SdrObjConnection& rCon, const SdrEdgeObj* pThis, OutputDevice* pOut)
    2102             : {
    2103           0 :     rCon.ResetVars();
    2104           0 :     if (pOut==NULL) pOut=rPV.GetView().GetFirstOutputDevice();
    2105           0 :     if (pOut==NULL) return false;
    2106           0 :     SdrObjList* pOL=rPV.GetObjList();
    2107           0 :     const SetOfByte& rVisLayer=rPV.GetVisibleLayers();
    2108             :     // sensitive area of connectors is twice as large as the one of the handles
    2109           0 :     sal_uInt16 nMarkHdSiz=rPV.GetView().GetMarkHdlSizePixel();
    2110           0 :     Size aHalfConSiz(nMarkHdSiz,nMarkHdSiz);
    2111           0 :     aHalfConSiz=pOut->PixelToLogic(aHalfConSiz);
    2112           0 :     Rectangle aMouseRect(rPt,rPt);
    2113           0 :     aMouseRect.Left()  -=aHalfConSiz.Width();
    2114           0 :     aMouseRect.Top()   -=aHalfConSiz.Height();
    2115           0 :     aMouseRect.Right() +=aHalfConSiz.Width();
    2116           0 :     aMouseRect.Bottom()+=aHalfConSiz.Height();
    2117           0 :     sal_uInt16 nBoundHitTol=(sal_uInt16)aHalfConSiz.Width()/2; if (nBoundHitTol==0) nBoundHitTol=1;
    2118           0 :     sal_uIntPtr no=pOL->GetObjCount();
    2119           0 :     bool bFnd = false;
    2120           0 :     SdrObjConnection aTestCon;
    2121           0 :     SdrObjConnection aBestCon;
    2122             : 
    2123           0 :     while (no>0 && !bFnd) {
    2124             :         // issue: group objects on different layers return LayerID=0!
    2125           0 :         no--;
    2126           0 :         SdrObject* pObj=pOL->GetObj(no);
    2127           0 :         if (rVisLayer.IsSet(pObj->GetLayer()) && pObj->IsVisible() &&      // only visible objects
    2128           0 :             (pThis==NULL || pObj!=(SdrObject*)pThis) && // don't connect it to itself
    2129           0 :             pObj->IsNode())
    2130             :         {
    2131           0 :             Rectangle aObjBound(pObj->GetCurrentBoundRect());
    2132           0 :             if (aObjBound.IsOver(aMouseRect)) {
    2133           0 :                 aTestCon.ResetVars();
    2134           0 :                 bool bEdge=HAS_BASE(SdrEdgeObj,pObj); // no BestCon for Edge
    2135             :                 // User-defined connectors have absolute priority.
    2136             :                 // After those come Vertex, Corner and center (Best), all prioritized equally.
    2137             :                 // Finally, a HitTest for the object.
    2138           0 :                 const SdrGluePointList* pGPL=pObj->GetGluePointList();
    2139           0 :                 sal_uInt16 nConAnz=pGPL==NULL ? 0 : pGPL->GetCount();
    2140           0 :                 sal_uInt16 nGesAnz=nConAnz+9;
    2141           0 :                 bool bUserFnd = false;
    2142           0 :                 sal_uIntPtr nBestDist=0xFFFFFFFF;
    2143           0 :                 for (sal_uInt16 i=0; i<nGesAnz; i++)
    2144             :                 {
    2145           0 :                     bool bUser=i<nConAnz;
    2146           0 :                     bool bVertex=i>=nConAnz+0 && i<nConAnz+4;
    2147           0 :                     bool bCorner=i>=nConAnz+4 && i<nConAnz+8;
    2148           0 :                     bool bCenter=i==nConAnz+8;
    2149           0 :                     bool bOk = false;
    2150           0 :                     Point aConPos;
    2151           0 :                     sal_uInt16 nConNum=i;
    2152           0 :                     if (bUser) {
    2153           0 :                         const SdrGluePoint& rGP=(*pGPL)[nConNum];
    2154           0 :                         aConPos=rGP.GetAbsolutePos(*pObj);
    2155           0 :                         nConNum=rGP.GetId();
    2156           0 :                         bOk = true;
    2157           0 :                     } else if (bVertex && !bUserFnd) {
    2158           0 :                         nConNum=nConNum-nConAnz;
    2159           0 :                         if (rPV.GetView().IsAutoVertexConnectors()) {
    2160           0 :                             SdrGluePoint aPt(pObj->GetVertexGluePoint(nConNum));
    2161           0 :                             aConPos=aPt.GetAbsolutePos(*pObj);
    2162           0 :                             bOk = true;
    2163           0 :                         } else i+=3;
    2164           0 :                     } else if (bCorner && !bUserFnd) {
    2165           0 :                         nConNum-=nConAnz+4;
    2166           0 :                         if (rPV.GetView().IsAutoCornerConnectors()) {
    2167           0 :                             SdrGluePoint aPt(pObj->GetCornerGluePoint(nConNum));
    2168           0 :                             aConPos=aPt.GetAbsolutePos(*pObj);
    2169           0 :                             bOk = true;
    2170           0 :                         } else i+=3;
    2171             :                     }
    2172           0 :                     else if (bCenter && !bUserFnd && !bEdge)
    2173             :                     {
    2174             :                         // Suppress default connect at object center
    2175           0 :                         if(!pThis || !pThis->GetSuppressDefaultConnect())
    2176             :                         {
    2177             :                             // not the edges!
    2178           0 :                             nConNum=0;
    2179           0 :                             aConPos=aObjBound.Center();
    2180           0 :                             bOk = true;
    2181             :                         }
    2182             :                     }
    2183           0 :                     if (bOk && aMouseRect.IsInside(aConPos)) {
    2184           0 :                         if (bUser) bUserFnd = true;
    2185           0 :                         bFnd = true;
    2186           0 :                         sal_uIntPtr nDist=(sal_uIntPtr)std::abs(aConPos.X()-rPt.X())+(sal_uIntPtr)std::abs(aConPos.Y()-rPt.Y());
    2187           0 :                         if (nDist<nBestDist) {
    2188           0 :                             nBestDist=nDist;
    2189           0 :                             aTestCon.pObj=pObj;
    2190           0 :                             aTestCon.nConId=nConNum;
    2191           0 :                             aTestCon.bAutoCorner=bCorner;
    2192           0 :                             aTestCon.bAutoVertex=bVertex;
    2193           0 :                             aTestCon.bBestConn=false; // bCenter;
    2194           0 :                             aTestCon.bBestVertex=bCenter;
    2195             :                         }
    2196             :                     }
    2197             :                 }
    2198             :                 // if no connector is hit, try HitTest again, for BestConnector (=bCenter)
    2199           0 :                 if(!bFnd &&
    2200           0 :                     !bEdge &&
    2201           0 :                     SdrObjectPrimitiveHit(*pObj, rPt, nBoundHitTol, rPV, &rVisLayer, false))
    2202             :                 {
    2203             :                     // Suppress default connect at object inside bound
    2204           0 :                     if(!pThis || !pThis->GetSuppressDefaultConnect())
    2205             :                     {
    2206           0 :                         bFnd = true;
    2207           0 :                         aTestCon.pObj=pObj;
    2208           0 :                         aTestCon.bBestConn=true;
    2209             :                     }
    2210             :                 }
    2211           0 :                 if (bFnd) {
    2212           0 :                     Rectangle aMouseRect2(rPt,rPt);
    2213           0 :                     aMouseRect.Left()  -=nBoundHitTol;
    2214           0 :                     aMouseRect.Top()   -=nBoundHitTol;
    2215           0 :                     aMouseRect.Right() +=nBoundHitTol;
    2216           0 :                     aMouseRect.Bottom()+=nBoundHitTol;
    2217           0 :                     aObjBound.IsOver(aMouseRect2);
    2218             :                 }
    2219             : 
    2220             :             }
    2221             :         }
    2222             :     }
    2223           0 :     rCon=aTestCon;
    2224           0 :     return bFnd;
    2225             : }
    2226             : 
    2227           2 : void SdrEdgeObj::NbcSetSnapRect(const Rectangle& rRect)
    2228             : {
    2229           2 :     const Rectangle aOld(GetSnapRect());
    2230             : 
    2231           2 :     if(aOld != rRect)
    2232             :     {
    2233           1 :         if(aRect.IsEmpty() && 0 == pEdgeTrack->GetPointCount())
    2234             :         {
    2235             :             // #i110629# When initializing, do not scale on empty Rectangle; this
    2236             :             // will mirror the underlying text object (!)
    2237           1 :             aRect = rRect;
    2238           1 :             maSnapRect = rRect;
    2239             :         }
    2240             :         else
    2241             :         {
    2242           0 :             long nMulX = rRect.Right()  - rRect.Left();
    2243           0 :             long nDivX = aOld.Right()   - aOld.Left();
    2244           0 :             long nMulY = rRect.Bottom() - rRect.Top();
    2245           0 :             long nDivY = aOld.Bottom()  - aOld.Top();
    2246           0 :             if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; }
    2247           0 :             if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; }
    2248           0 :             Fraction aX(nMulX, nDivX);
    2249           0 :             Fraction aY(nMulY, nDivY);
    2250           0 :             NbcResize(aOld.TopLeft(), aX, aY);
    2251           0 :             NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top()));
    2252             :         }
    2253             :     }
    2254           2 : }
    2255             : 
    2256           0 : void SdrEdgeObj::NbcMove(const Size& rSiz)
    2257             : {
    2258           0 :     SdrTextObj::NbcMove(rSiz);
    2259           0 :     MoveXPoly(*pEdgeTrack,rSiz);
    2260           0 : }
    2261             : 
    2262           0 : void SdrEdgeObj::NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact)
    2263             : {
    2264           0 :     SdrTextObj::NbcResize(rRefPnt,aXFact,aXFact);
    2265           0 :     ResizeXPoly(*pEdgeTrack,rRefPnt,aXFact,aYFact);
    2266             : 
    2267             :     // if resize is not from paste, forget user distances
    2268           0 :     if(!GetModel()->IsPasteResize())
    2269             :     {
    2270           0 :         aEdgeInfo.aObj1Line2 = Point();
    2271           0 :         aEdgeInfo.aObj1Line3 = Point();
    2272           0 :         aEdgeInfo.aObj2Line2 = Point();
    2273           0 :         aEdgeInfo.aObj2Line3 = Point();
    2274           0 :         aEdgeInfo.aMiddleLine = Point();
    2275             :     }
    2276           0 : }
    2277             : 
    2278             : // #i54102# added rotation support
    2279           0 : void SdrEdgeObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
    2280             : {
    2281           0 :     if(bEdgeTrackUserDefined)
    2282             :     {
    2283             :         // #i120437# special handling when track is imported, apply
    2284             :         // transformation directly to imported track.
    2285           0 :         SdrTextObj::NbcRotate(rRef, nWink, sn, cs);
    2286           0 :         RotateXPoly(*pEdgeTrack, rRef, sn, cs);
    2287             :     }
    2288             :     else
    2289             :     {
    2290             :         // handle start and end point if not connected
    2291           0 :         bool bCon1=aCon1.pObj!=NULL && aCon1.pObj->GetPage()==pPage;
    2292           0 :         bool bCon2=aCon2.pObj!=NULL && aCon2.pObj->GetPage()==pPage;
    2293             : 
    2294           0 :         if(!bCon1 && pEdgeTrack)
    2295             :         {
    2296           0 :             RotatePoint((*pEdgeTrack)[0],rRef,sn,cs);
    2297           0 :             ImpDirtyEdgeTrack();
    2298             :         }
    2299             : 
    2300           0 :         if(!bCon2 && pEdgeTrack)
    2301             :         {
    2302           0 :             sal_uInt16 nPntAnz = pEdgeTrack->GetPointCount();
    2303           0 :             RotatePoint((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],rRef,sn,cs);
    2304           0 :             ImpDirtyEdgeTrack();
    2305             :         }
    2306             :     }
    2307           0 : }
    2308             : 
    2309             : // #i54102# added mirror support
    2310           0 : void SdrEdgeObj::NbcMirror(const Point& rRef1, const Point& rRef2)
    2311             : {
    2312           0 :     if(bEdgeTrackUserDefined)
    2313             :     {
    2314             :         // #i120437# special handling when track is imported, apply
    2315             :         // transformation directly to imported track.
    2316           0 :         SdrTextObj::NbcMirror(rRef1, rRef2);
    2317           0 :         MirrorXPoly(*pEdgeTrack, rRef1, rRef2);
    2318             :     }
    2319             :     else
    2320             :     {
    2321             :         // handle start and end point if not connected
    2322           0 :         bool bCon1=aCon1.pObj!=NULL && aCon1.pObj->GetPage()==pPage;
    2323           0 :         bool bCon2=aCon2.pObj!=NULL && aCon2.pObj->GetPage()==pPage;
    2324             : 
    2325           0 :         if(!bCon1 && pEdgeTrack)
    2326             :         {
    2327           0 :             MirrorPoint((*pEdgeTrack)[0],rRef1,rRef2);
    2328           0 :             ImpDirtyEdgeTrack();
    2329             :         }
    2330             : 
    2331           0 :         if(!bCon2 && pEdgeTrack)
    2332             :         {
    2333           0 :             sal_uInt16 nPntAnz = pEdgeTrack->GetPointCount();
    2334           0 :             MirrorPoint((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],rRef1,rRef2);
    2335           0 :             ImpDirtyEdgeTrack();
    2336             :         }
    2337             :     }
    2338           0 : }
    2339             : 
    2340             : // #i54102# added shear support
    2341           0 : void SdrEdgeObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
    2342             : {
    2343           0 :     if(bEdgeTrackUserDefined)
    2344             :     {
    2345             :         // #i120437# special handling when track is imported, apply
    2346             :         // transformation directly to imported track.
    2347           0 :         SdrTextObj::NbcShear(rRef, nWink, tn, bVShear);
    2348           0 :         ShearXPoly(*pEdgeTrack, rRef, tn, bVShear);
    2349             :     }
    2350             :     else
    2351             :     {
    2352             :         // handle start and end point if not connected
    2353           0 :         bool bCon1=aCon1.pObj!=NULL && aCon1.pObj->GetPage()==pPage;
    2354           0 :         bool bCon2=aCon2.pObj!=NULL && aCon2.pObj->GetPage()==pPage;
    2355             : 
    2356           0 :         if(!bCon1 && pEdgeTrack)
    2357             :         {
    2358           0 :             ShearPoint((*pEdgeTrack)[0],rRef,tn,bVShear);
    2359           0 :             ImpDirtyEdgeTrack();
    2360             :         }
    2361             : 
    2362           0 :         if(!bCon2 && pEdgeTrack)
    2363             :         {
    2364           0 :             sal_uInt16 nPntAnz = pEdgeTrack->GetPointCount();
    2365           0 :             ShearPoint((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],rRef,tn,bVShear);
    2366           0 :             ImpDirtyEdgeTrack();
    2367             :         }
    2368             :     }
    2369           0 : }
    2370             : 
    2371           0 : SdrObject* SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
    2372             : {
    2373           0 :     basegfx::B2DPolyPolygon aPolyPolygon;
    2374           0 :     aPolyPolygon.append(pEdgeTrack->getB2DPolygon());
    2375           0 :     SdrObject* pRet = ImpConvertMakeObj(aPolyPolygon, false, bBezier);
    2376             : 
    2377           0 :     if(bAddText)
    2378             :     {
    2379           0 :         pRet = ImpConvertAddText(pRet, bBezier);
    2380             :     }
    2381             : 
    2382           0 :     return pRet;
    2383             : }
    2384             : 
    2385           0 : sal_uInt32 SdrEdgeObj::GetSnapPointCount() const
    2386             : {
    2387           0 :     return 2L;
    2388             : }
    2389             : 
    2390           0 : Point SdrEdgeObj::GetSnapPoint(sal_uInt32 i) const
    2391             : {
    2392           0 :     ((SdrEdgeObj*)this)->ImpUndirtyEdgeTrack();
    2393           0 :     sal_uInt16 nAnz=pEdgeTrack->GetPointCount();
    2394           0 :     if (i==0) return (*pEdgeTrack)[0];
    2395           0 :     else return (*pEdgeTrack)[nAnz-1];
    2396             : }
    2397             : 
    2398           0 : bool SdrEdgeObj::IsPolyObj() const
    2399             : {
    2400           0 :     return false;
    2401             : }
    2402             : 
    2403           0 : sal_uInt32 SdrEdgeObj::GetPointCount() const
    2404             : {
    2405           0 :     return 0L;
    2406             : }
    2407             : 
    2408           0 : Point SdrEdgeObj::GetPoint(sal_uInt32 i) const
    2409             : {
    2410           0 :     ((SdrEdgeObj*)this)->ImpUndirtyEdgeTrack();
    2411           0 :     sal_uInt16 nAnz=pEdgeTrack->GetPointCount();
    2412           0 :     if (0L == i)
    2413           0 :         return (*pEdgeTrack)[0];
    2414             :     else
    2415           0 :         return (*pEdgeTrack)[nAnz-1];
    2416             : }
    2417             : 
    2418          64 : void SdrEdgeObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
    2419             : {
    2420             :     // TODO: Need an implementation to connect differently.
    2421          64 :     ImpUndirtyEdgeTrack();
    2422          64 :     sal_uInt16 nAnz=pEdgeTrack->GetPointCount();
    2423          64 :     if (0L == i)
    2424          32 :         (*pEdgeTrack)[0]=rPnt;
    2425          64 :     if (1L == i)
    2426          32 :         (*pEdgeTrack)[nAnz-1]=rPnt;
    2427          64 :     SetEdgeTrackDirty();
    2428          64 :     SetRectsDirty();
    2429          64 : }
    2430             : 
    2431           0 : SdrEdgeObjGeoData::SdrEdgeObjGeoData()
    2432             :     : bEdgeTrackDirty(false)
    2433           0 :     , bEdgeTrackUserDefined(false)
    2434             : {
    2435           0 :     pEdgeTrack=new XPolygon;
    2436           0 : }
    2437             : 
    2438           0 : SdrEdgeObjGeoData::~SdrEdgeObjGeoData()
    2439             : {
    2440           0 :     delete pEdgeTrack;
    2441           0 : }
    2442             : 
    2443           0 : SdrObjGeoData* SdrEdgeObj::NewGeoData() const
    2444             : {
    2445           0 :     return new SdrEdgeObjGeoData;
    2446             : }
    2447             : 
    2448           0 : void SdrEdgeObj::SaveGeoData(SdrObjGeoData& rGeo) const
    2449             : {
    2450           0 :     SdrTextObj::SaveGeoData(rGeo);
    2451           0 :     SdrEdgeObjGeoData& rEGeo=(SdrEdgeObjGeoData&)rGeo;
    2452           0 :     rEGeo.aCon1          =aCon1;
    2453           0 :     rEGeo.aCon2          =aCon2;
    2454           0 :     *rEGeo.pEdgeTrack    =*pEdgeTrack;
    2455           0 :     rEGeo.bEdgeTrackDirty=bEdgeTrackDirty;
    2456           0 :     rEGeo.bEdgeTrackUserDefined=bEdgeTrackUserDefined;
    2457           0 :     rEGeo.aEdgeInfo      =aEdgeInfo;
    2458           0 : }
    2459             : 
    2460           0 : void SdrEdgeObj::RestGeoData(const SdrObjGeoData& rGeo)
    2461             : {
    2462           0 :     SdrTextObj::RestGeoData(rGeo);
    2463           0 :     SdrEdgeObjGeoData& rEGeo=(SdrEdgeObjGeoData&)rGeo;
    2464           0 :     if (aCon1.pObj!=rEGeo.aCon1.pObj) {
    2465           0 :         if (aCon1.pObj!=NULL) aCon1.pObj->RemoveListener(*this);
    2466           0 :         aCon1=rEGeo.aCon1;
    2467           0 :         if (aCon1.pObj!=NULL) aCon1.pObj->AddListener(*this);
    2468             :     }
    2469           0 :     if (aCon2.pObj!=rEGeo.aCon2.pObj) {
    2470           0 :         if (aCon2.pObj!=NULL) aCon2.pObj->RemoveListener(*this);
    2471           0 :         aCon2=rEGeo.aCon2;
    2472           0 :         if (aCon2.pObj!=NULL) aCon2.pObj->AddListener(*this);
    2473             :     }
    2474           0 :     *pEdgeTrack    =*rEGeo.pEdgeTrack;
    2475           0 :     bEdgeTrackDirty=rEGeo.bEdgeTrackDirty;
    2476           0 :     bEdgeTrackUserDefined=rEGeo.bEdgeTrackUserDefined;
    2477           0 :     aEdgeInfo      =rEGeo.aEdgeInfo;
    2478           0 : }
    2479             : 
    2480          54 : Point SdrEdgeObj::GetTailPoint( bool bTail ) const
    2481             : {
    2482          54 :     if( pEdgeTrack && pEdgeTrack->GetPointCount()!=0)
    2483             :     {
    2484          54 :         const XPolygon& rTrack0 = *pEdgeTrack;
    2485          54 :         if(bTail)
    2486             :         {
    2487          27 :             return rTrack0[0];
    2488             :         }
    2489             :         else
    2490             :         {
    2491          27 :             const sal_uInt16 nSiz = rTrack0.GetPointCount() - 1;
    2492          27 :             return rTrack0[nSiz];
    2493             :         }
    2494             :     }
    2495             :     else
    2496             :     {
    2497           0 :         if(bTail)
    2498           0 :             return aOutRect.TopLeft();
    2499             :         else
    2500           0 :             return aOutRect.BottomRight();
    2501             :     }
    2502             : 
    2503             : }
    2504             : 
    2505           2 : void SdrEdgeObj::SetTailPoint( bool bTail, const Point& rPt )
    2506             : {
    2507           2 :     ImpSetTailPoint( bTail, rPt );
    2508           2 :     SetChanged();
    2509           2 : }
    2510             : 
    2511             : /** this method is used by the api to set a glue point for a connection
    2512             :     nId == -1 :     The best default point is automatically chosen
    2513             :     0 <= nId <= 3 : One of the default points is chosen
    2514             :     nId >= 4 :      A user defined glue point is chosen
    2515             : */
    2516           4 : void SdrEdgeObj::setGluePointIndex( bool bTail, sal_Int32 nIndex /* = -1 */ )
    2517             : {
    2518           4 :     Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetCurrentBoundRect();
    2519             : 
    2520           4 :     SdrObjConnection& rConn1 = GetConnection( bTail );
    2521             : 
    2522           4 :     rConn1.SetAutoVertex( nIndex >= 0 && nIndex <= 3 );
    2523           4 :     rConn1.SetBestConnection( nIndex < 0 );
    2524           4 :     rConn1.SetBestVertex( nIndex < 0 );
    2525             : 
    2526           4 :     if( nIndex > 3 )
    2527             :     {
    2528           0 :         nIndex -= 3;        // the start api index is 0, whereas the implementation in svx starts from 1
    2529             : 
    2530             :         // for user defined glue points we have
    2531             :         // to get the id for this index first
    2532           0 :         const SdrGluePointList* pList = rConn1.GetObject() ? rConn1.GetObject()->GetGluePointList() : NULL;
    2533           0 :         if( pList == NULL || SDRGLUEPOINT_NOTFOUND == pList->FindGluePoint((sal_uInt16)nIndex) )
    2534           0 :             return;
    2535             :     }
    2536           4 :     else if( nIndex < 0 )
    2537             :     {
    2538           2 :         nIndex = 0;
    2539             :     }
    2540             : 
    2541           4 :     rConn1.SetConnectorId( (sal_uInt16)nIndex );
    2542             : 
    2543           4 :     SetChanged();
    2544           4 :     SetRectsDirty();
    2545           4 :     ImpRecalcEdgeTrack();
    2546             : }
    2547             : 
    2548             : /** this method is used by the api to return a glue point id for a connection.
    2549             :     See setGluePointId for possible return values */
    2550           0 : sal_Int32 SdrEdgeObj::getGluePointIndex( bool bTail )
    2551             : {
    2552           0 :     SdrObjConnection& rConn1 = GetConnection( bTail );
    2553           0 :     sal_Int32 nId = -1;
    2554           0 :     if( !rConn1.IsBestConnection() )
    2555             :     {
    2556           0 :         nId = rConn1.GetConnectorId();
    2557           0 :         if( !rConn1.IsAutoVertex() )
    2558           0 :             nId += 3;       // the start api index is 0, whereas the implementation in svx starts from 1
    2559             :     }
    2560           0 :     return nId;
    2561             : }
    2562             : 
    2563             : // Implementation was missing; edge track needs to be invalidated additionally.
    2564           0 : void SdrEdgeObj::NbcSetAnchorPos(const Point& rPnt)
    2565             : {
    2566             :     // call parent functionality
    2567           0 :     SdrTextObj::NbcSetAnchorPos(rPnt);
    2568             : 
    2569             :     // Additionally, invalidate edge track
    2570           0 :     ImpDirtyEdgeTrack();
    2571           0 : }
    2572             : 
    2573          27 : bool SdrEdgeObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const
    2574             : {
    2575             :     // use base method from SdrObject, it's not rotatable and
    2576             :     // a call to GetSnapRect() is used. That's what we need for Connector.
    2577          27 :     return SdrObject::TRGetBaseGeometry(rMatrix, rPolyPolygon);
    2578             : }
    2579             : 
    2580           0 : void SdrEdgeObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon)
    2581             : {
    2582             :     // where appropriate take care for existing connections. For now, just use the
    2583             :     // implementation from SdrObject.
    2584           0 :     SdrObject::TRSetBaseGeometry(rMatrix, rPolyPolygon);
    2585           0 : }
    2586             : 
    2587             : // for geometry access
    2588          61 : ::basegfx::B2DPolygon SdrEdgeObj::getEdgeTrack() const
    2589             : {
    2590          61 :     if(bEdgeTrackDirty)
    2591             :     {
    2592          34 :         const_cast< SdrEdgeObj* >(this)->ImpRecalcEdgeTrack();
    2593             :     }
    2594             : 
    2595          61 :     if(pEdgeTrack)
    2596             :     {
    2597          61 :         return pEdgeTrack->getB2DPolygon();
    2598             :     }
    2599             :     else
    2600             :     {
    2601           0 :         return ::basegfx::B2DPolygon();
    2602             :     }
    2603             : }
    2604             : 
    2605             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10