1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <svx/svdoedge.hxx> 32*cdf0e10cSrcweir #include <svx/xpool.hxx> 33*cdf0e10cSrcweir #include <svx/xpoly.hxx> 34*cdf0e10cSrcweir #include <svx/svdattrx.hxx> 35*cdf0e10cSrcweir #include <svx/svdpool.hxx> 36*cdf0e10cSrcweir #include <svx/svdmodel.hxx> 37*cdf0e10cSrcweir #include <svx/svdpage.hxx> 38*cdf0e10cSrcweir #include <svx/svdpagv.hxx> 39*cdf0e10cSrcweir #include <svx/svdview.hxx> 40*cdf0e10cSrcweir #include <svx/svddrag.hxx> 41*cdf0e10cSrcweir #include <svx/svddrgv.hxx> 42*cdf0e10cSrcweir #include "svddrgm1.hxx" 43*cdf0e10cSrcweir #include <svx/svdhdl.hxx> 44*cdf0e10cSrcweir #include <svx/svdtrans.hxx> 45*cdf0e10cSrcweir #include <svx/svdetc.hxx> 46*cdf0e10cSrcweir #include "svx/svdglob.hxx" // StringCache 47*cdf0e10cSrcweir #include "svx/svdstr.hrc" // Objektname 48*cdf0e10cSrcweir #include <svl/style.hxx> 49*cdf0e10cSrcweir #include <svl/smplhint.hxx> 50*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 51*cdf0e10cSrcweir #include "svdoimp.hxx" 52*cdf0e10cSrcweir #include <svx/sdr/properties/connectorproperties.hxx> 53*cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdredgeobj.hxx> 54*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 55*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 56*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 57*cdf0e10cSrcweir #include <svx/sdrhittesthelper.hxx> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir SdrObjConnection::~SdrObjConnection() 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void SdrObjConnection::ResetVars() 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir pObj=NULL; 68*cdf0e10cSrcweir nConId=0; 69*cdf0e10cSrcweir nXDist=0; 70*cdf0e10cSrcweir nYDist=0; 71*cdf0e10cSrcweir bBestConn=sal_True; 72*cdf0e10cSrcweir bBestVertex=sal_True; 73*cdf0e10cSrcweir bXDistOvr=sal_False; 74*cdf0e10cSrcweir bYDistOvr=sal_False; 75*cdf0e10cSrcweir bAutoVertex=sal_False; 76*cdf0e10cSrcweir bAutoCorner=sal_False; 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir FASTBOOL SdrObjConnection::TakeGluePoint(SdrGluePoint& rGP, FASTBOOL bSetAbsPos) const 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir FASTBOOL bRet=sal_False; 82*cdf0e10cSrcweir if (pObj!=NULL) { // Ein Obj muss schon angedockt sein! 83*cdf0e10cSrcweir if (bAutoVertex) { 84*cdf0e10cSrcweir rGP=pObj->GetVertexGluePoint(nConId); 85*cdf0e10cSrcweir bRet=sal_True; 86*cdf0e10cSrcweir } else if (bAutoCorner) { 87*cdf0e10cSrcweir rGP=pObj->GetCornerGluePoint(nConId); 88*cdf0e10cSrcweir bRet=sal_True; 89*cdf0e10cSrcweir } else { 90*cdf0e10cSrcweir const SdrGluePointList* pGPL=pObj->GetGluePointList(); 91*cdf0e10cSrcweir if (pGPL!=NULL) { 92*cdf0e10cSrcweir sal_uInt16 nNum=pGPL->FindGluePoint(nConId); 93*cdf0e10cSrcweir if (nNum!=SDRGLUEPOINT_NOTFOUND) { 94*cdf0e10cSrcweir rGP=(*pGPL)[nNum]; 95*cdf0e10cSrcweir bRet=sal_True; 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir if (bRet && bSetAbsPos) { 101*cdf0e10cSrcweir Point aPt(rGP.GetAbsolutePos(*pObj)); 102*cdf0e10cSrcweir aPt+=aObjOfs; 103*cdf0e10cSrcweir rGP.SetPos(aPt); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir return bRet; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir Point& SdrEdgeInfoRec::ImpGetLineVersatzPoint(SdrEdgeLineCode eLineCode) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir switch (eLineCode) { 111*cdf0e10cSrcweir case OBJ1LINE2 : return aObj1Line2; 112*cdf0e10cSrcweir case OBJ1LINE3 : return aObj1Line3; 113*cdf0e10cSrcweir case OBJ2LINE2 : return aObj2Line2; 114*cdf0e10cSrcweir case OBJ2LINE3 : return aObj2Line3; 115*cdf0e10cSrcweir case MIDDLELINE: return aMiddleLine; 116*cdf0e10cSrcweir } // switch 117*cdf0e10cSrcweir return aMiddleLine; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir sal_uInt16 SdrEdgeInfoRec::ImpGetPolyIdx(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir switch (eLineCode) { 123*cdf0e10cSrcweir case OBJ1LINE2 : return 1; 124*cdf0e10cSrcweir case OBJ1LINE3 : return 2; 125*cdf0e10cSrcweir case OBJ2LINE2 : return rXP.GetPointCount()-3; 126*cdf0e10cSrcweir case OBJ2LINE3 : return rXP.GetPointCount()-4; 127*cdf0e10cSrcweir case MIDDLELINE: return nMiddleLine; 128*cdf0e10cSrcweir } // switch 129*cdf0e10cSrcweir return 0; 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir FASTBOOL SdrEdgeInfoRec::ImpIsHorzLine(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir sal_uInt16 nIdx=ImpGetPolyIdx(eLineCode,rXP); 135*cdf0e10cSrcweir FASTBOOL bHorz=nAngle1==0 || nAngle1==18000; 136*cdf0e10cSrcweir if (eLineCode==OBJ2LINE2 || eLineCode==OBJ2LINE3) { 137*cdf0e10cSrcweir nIdx=rXP.GetPointCount()-nIdx; // #36314# 138*cdf0e10cSrcweir bHorz=nAngle2==0 || nAngle2==18000; // #52000# 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir if ((nIdx & 1)==1) bHorz=!bHorz; 141*cdf0e10cSrcweir return bHorz; 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir void SdrEdgeInfoRec::ImpSetLineVersatz(SdrEdgeLineCode eLineCode, const XPolygon& rXP, long nVal) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir Point& rPt=ImpGetLineVersatzPoint(eLineCode); 147*cdf0e10cSrcweir if (ImpIsHorzLine(eLineCode,rXP)) rPt.Y()=nVal; 148*cdf0e10cSrcweir else rPt.X()=nVal; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir long SdrEdgeInfoRec::ImpGetLineVersatz(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir const Point& rPt=ImpGetLineVersatzPoint(eLineCode); 154*cdf0e10cSrcweir if (ImpIsHorzLine(eLineCode,rXP)) return rPt.Y(); 155*cdf0e10cSrcweir else return rPt.X(); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 159*cdf0e10cSrcweir // BaseProperties section 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir sdr::properties::BaseProperties* SdrEdgeObj::CreateObjectSpecificProperties() 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir return new sdr::properties::ConnectorProperties(*this); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 167*cdf0e10cSrcweir // DrawContact section 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir sdr::contact::ViewContact* SdrEdgeObj::CreateObjectSpecificViewContact() 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir return new sdr::contact::ViewContactOfSdrEdgeObj(*this); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir TYPEINIT1(SdrEdgeObj,SdrTextObj); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir SdrEdgeObj::SdrEdgeObj() 179*cdf0e10cSrcweir : SdrTextObj(), 180*cdf0e10cSrcweir nNotifyingCount(0), 181*cdf0e10cSrcweir bEdgeTrackDirty(sal_False), 182*cdf0e10cSrcweir bEdgeTrackUserDefined(sal_False), 183*cdf0e10cSrcweir // #109007# Default is to allow default connects 184*cdf0e10cSrcweir mbSuppressDefaultConnect(sal_False), 185*cdf0e10cSrcweir // #110649# 186*cdf0e10cSrcweir mbBoundRectCalculationRunning(sal_False) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir bClosedObj=sal_False; 189*cdf0e10cSrcweir bIsEdge=sal_True; 190*cdf0e10cSrcweir pEdgeTrack=new XPolygon; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir SdrEdgeObj::~SdrEdgeObj() 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir DisconnectFromNode(sal_True); 197*cdf0e10cSrcweir DisconnectFromNode(sal_False); 198*cdf0e10cSrcweir delete pEdgeTrack; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir void SdrEdgeObj::ImpSetAttrToEdgeInfo() 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet(); 204*cdf0e10cSrcweir SdrEdgeKind eKind = ((SdrEdgeKindItem&)(rSet.Get(SDRATTR_EDGEKIND))).GetValue(); 205*cdf0e10cSrcweir sal_Int32 nVal1 = ((SdrEdgeLine1DeltaItem&)rSet.Get(SDRATTR_EDGELINE1DELTA)).GetValue(); 206*cdf0e10cSrcweir sal_Int32 nVal2 = ((SdrEdgeLine2DeltaItem&)rSet.Get(SDRATTR_EDGELINE2DELTA)).GetValue(); 207*cdf0e10cSrcweir sal_Int32 nVal3 = ((SdrEdgeLine3DeltaItem&)rSet.Get(SDRATTR_EDGELINE3DELTA)).GetValue(); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir if(eKind == SDREDGE_ORTHOLINES || eKind == SDREDGE_BEZIER) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir sal_Int32 nVals[3] = { nVal1, nVal2, nVal3 }; 212*cdf0e10cSrcweir sal_uInt16 n = 0; 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir if(aEdgeInfo.nObj1Lines >= 2 && n < 3) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir aEdgeInfo.ImpSetLineVersatz(OBJ1LINE2, *pEdgeTrack, nVals[n]); 217*cdf0e10cSrcweir n++; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir if(aEdgeInfo.nObj1Lines >= 3 && n < 3) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir aEdgeInfo.ImpSetLineVersatz(OBJ1LINE3, *pEdgeTrack, nVals[n]); 223*cdf0e10cSrcweir n++; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir if(aEdgeInfo.nMiddleLine != 0xFFFF && n < 3) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir aEdgeInfo.ImpSetLineVersatz(MIDDLELINE, *pEdgeTrack, nVals[n]); 229*cdf0e10cSrcweir n++; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir if(aEdgeInfo.nObj2Lines >= 3 && n < 3) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir aEdgeInfo.ImpSetLineVersatz(OBJ2LINE3, *pEdgeTrack, nVals[n]); 235*cdf0e10cSrcweir n++; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir if(aEdgeInfo.nObj2Lines >= 2 && n < 3) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir aEdgeInfo.ImpSetLineVersatz(OBJ2LINE2, *pEdgeTrack, nVals[n]); 241*cdf0e10cSrcweir n++; 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir else if(eKind == SDREDGE_THREELINES) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir sal_Bool bHor1 = aEdgeInfo.nAngle1 == 0 || aEdgeInfo.nAngle1 == 18000; 247*cdf0e10cSrcweir sal_Bool bHor2 = aEdgeInfo.nAngle2 == 0 || aEdgeInfo.nAngle2 == 18000; 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir if(bHor1) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir aEdgeInfo.aObj1Line2.X() = nVal1; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir else 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir aEdgeInfo.aObj1Line2.Y() = nVal1; 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir if(bHor2) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir aEdgeInfo.aObj2Line2.X() = nVal2; 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir else 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir aEdgeInfo.aObj2Line2.Y() = nVal2; 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir // #84649# 269*cdf0e10cSrcweir ImpDirtyEdgeTrack(); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir void SdrEdgeObj::ImpSetEdgeInfoToAttr() 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet(); 275*cdf0e10cSrcweir SdrEdgeKind eKind = ((SdrEdgeKindItem&)(rSet.Get(SDRATTR_EDGEKIND))).GetValue(); 276*cdf0e10cSrcweir sal_Int32 nValAnz = ((SdrEdgeLineDeltaAnzItem&)rSet.Get(SDRATTR_EDGELINEDELTAANZ)).GetValue(); 277*cdf0e10cSrcweir sal_Int32 nVal1 = ((SdrEdgeLine1DeltaItem&)rSet.Get(SDRATTR_EDGELINE1DELTA)).GetValue(); 278*cdf0e10cSrcweir sal_Int32 nVal2 = ((SdrEdgeLine2DeltaItem&)rSet.Get(SDRATTR_EDGELINE2DELTA)).GetValue(); 279*cdf0e10cSrcweir sal_Int32 nVal3 = ((SdrEdgeLine3DeltaItem&)rSet.Get(SDRATTR_EDGELINE3DELTA)).GetValue(); 280*cdf0e10cSrcweir sal_Int32 nVals[3] = { nVal1, nVal2, nVal3 }; 281*cdf0e10cSrcweir sal_uInt16 n = 0; 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir if(eKind == SDREDGE_ORTHOLINES || eKind == SDREDGE_BEZIER) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir if(aEdgeInfo.nObj1Lines >= 2 && n < 3) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ1LINE2, *pEdgeTrack); 288*cdf0e10cSrcweir n++; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir if(aEdgeInfo.nObj1Lines >= 3 && n < 3) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ1LINE3, *pEdgeTrack); 294*cdf0e10cSrcweir n++; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir if(aEdgeInfo.nMiddleLine != 0xFFFF && n < 3) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir nVals[n] = aEdgeInfo.ImpGetLineVersatz(MIDDLELINE, *pEdgeTrack); 300*cdf0e10cSrcweir n++; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir if(aEdgeInfo.nObj2Lines >= 3 && n < 3) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ2LINE3, *pEdgeTrack); 306*cdf0e10cSrcweir n++; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir if(aEdgeInfo.nObj2Lines >= 2 && n < 3) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ2LINE2, *pEdgeTrack); 312*cdf0e10cSrcweir n++; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir else if(eKind == SDREDGE_THREELINES) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir sal_Bool bHor1 = aEdgeInfo.nAngle1 == 0 || aEdgeInfo.nAngle1 == 18000; 318*cdf0e10cSrcweir sal_Bool bHor2 = aEdgeInfo.nAngle2 == 0 || aEdgeInfo.nAngle2 == 18000; 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir n = 2; 321*cdf0e10cSrcweir nVals[0] = bHor1 ? aEdgeInfo.aObj1Line2.X() : aEdgeInfo.aObj1Line2.Y(); 322*cdf0e10cSrcweir nVals[1] = bHor2 ? aEdgeInfo.aObj2Line2.X() : aEdgeInfo.aObj2Line2.Y(); 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir if(n != nValAnz || nVals[0] != nVal1 || nVals[1] != nVal2 || nVals[2] != nVal3) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir // #75371# Here no more notifying is necessary, just local changes are OK. 328*cdf0e10cSrcweir if(n != nValAnz) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir GetProperties().SetObjectItemDirect(SdrEdgeLineDeltaAnzItem(n)); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir if(nVals[0] != nVal1) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir GetProperties().SetObjectItemDirect(SdrEdgeLine1DeltaItem(nVals[0])); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir if(nVals[1] != nVal2) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir GetProperties().SetObjectItemDirect(SdrEdgeLine2DeltaItem(nVals[1])); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir if(nVals[2] != nVal3) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir GetProperties().SetObjectItemDirect(SdrEdgeLine3DeltaItem(nVals[2])); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if(n < 3) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE3DELTA); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir if(n < 2) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE2DELTA); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir if(n < 1) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE1DELTA); 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir void SdrEdgeObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir rInfo.bRotateFreeAllowed=sal_False; 368*cdf0e10cSrcweir rInfo.bRotate90Allowed =sal_False; 369*cdf0e10cSrcweir rInfo.bMirrorFreeAllowed=sal_False; 370*cdf0e10cSrcweir rInfo.bMirror45Allowed =sal_False; 371*cdf0e10cSrcweir rInfo.bMirror90Allowed =sal_False; 372*cdf0e10cSrcweir rInfo.bTransparenceAllowed = sal_False; 373*cdf0e10cSrcweir rInfo.bGradientAllowed = sal_False; 374*cdf0e10cSrcweir rInfo.bShearAllowed =sal_False; 375*cdf0e10cSrcweir rInfo.bEdgeRadiusAllowed=sal_False; 376*cdf0e10cSrcweir FASTBOOL bCanConv=!HasText() || ImpCanConvTextToCurve(); 377*cdf0e10cSrcweir rInfo.bCanConvToPath=bCanConv; 378*cdf0e10cSrcweir rInfo.bCanConvToPoly=bCanConv; 379*cdf0e10cSrcweir rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir sal_uInt16 SdrEdgeObj::GetObjIdentifier() const 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir return sal_uInt16(OBJ_EDGE); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir const Rectangle& SdrEdgeObj::GetCurrentBoundRect() const 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir if(bEdgeTrackDirty) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir return SdrTextObj::GetCurrentBoundRect(); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir const Rectangle& SdrEdgeObj::GetSnapRect() const 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir if(bEdgeTrackDirty) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack(); 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir return SdrTextObj::GetSnapRect(); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir void SdrEdgeObj::RecalcSnapRect() 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir maSnapRect=pEdgeTrack->GetBoundRect(); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir void SdrEdgeObj::TakeUnrotatedSnapRect(Rectangle& rRect) const 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir rRect=GetSnapRect(); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::IsNode() const 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir return sal_True; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir SdrGluePoint SdrEdgeObj::GetVertexGluePoint(sal_uInt16 nNum) const 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir Point aPt; 425*cdf0e10cSrcweir sal_uInt16 nPntAnz=pEdgeTrack->GetPointCount(); 426*cdf0e10cSrcweir if (nPntAnz>0) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir Point aOfs = GetSnapRect().Center(); 429*cdf0e10cSrcweir if (nNum==2 && GetConnectedNode(sal_True)==NULL) aPt=(*pEdgeTrack)[0]; 430*cdf0e10cSrcweir else if (nNum==3 && GetConnectedNode(sal_False)==NULL) aPt=(*pEdgeTrack)[nPntAnz-1]; 431*cdf0e10cSrcweir else { 432*cdf0e10cSrcweir if ((nPntAnz & 1) ==1) { 433*cdf0e10cSrcweir aPt=(*pEdgeTrack)[nPntAnz/2]; 434*cdf0e10cSrcweir } else { 435*cdf0e10cSrcweir Point aPt1((*pEdgeTrack)[nPntAnz/2-1]); 436*cdf0e10cSrcweir Point aPt2((*pEdgeTrack)[nPntAnz/2]); 437*cdf0e10cSrcweir aPt1+=aPt2; 438*cdf0e10cSrcweir aPt1.X()/=2; 439*cdf0e10cSrcweir aPt1.Y()/=2; 440*cdf0e10cSrcweir aPt=aPt1; 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir aPt-=aOfs; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir SdrGluePoint aGP(aPt); 446*cdf0e10cSrcweir aGP.SetPercent(sal_False); 447*cdf0e10cSrcweir return aGP; 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir SdrGluePoint SdrEdgeObj::GetCornerGluePoint(sal_uInt16 nNum) const 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir return GetVertexGluePoint(nNum); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir const SdrGluePointList* SdrEdgeObj::GetGluePointList() const 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671# 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir SdrGluePointList* SdrEdgeObj::ForceGluePointList() 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671# 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::IsEdge() const 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir return sal_True; 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir void SdrEdgeObj::ConnectToNode(FASTBOOL bTail1, SdrObject* pObj) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir SdrObjConnection& rCon=GetConnection(bTail1); 473*cdf0e10cSrcweir DisconnectFromNode(bTail1); 474*cdf0e10cSrcweir if (pObj!=NULL) { 475*cdf0e10cSrcweir pObj->AddListener(*this); 476*cdf0e10cSrcweir rCon.pObj=pObj; 477*cdf0e10cSrcweir ImpDirtyEdgeTrack(); 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir void SdrEdgeObj::DisconnectFromNode(FASTBOOL bTail1) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir SdrObjConnection& rCon=GetConnection(bTail1); 484*cdf0e10cSrcweir if (rCon.pObj!=NULL) { 485*cdf0e10cSrcweir rCon.pObj->RemoveListener(*this); 486*cdf0e10cSrcweir rCon.pObj=NULL; 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir SdrObject* SdrEdgeObj::GetConnectedNode(FASTBOOL bTail1) const 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir SdrObject* pObj=GetConnection(bTail1).pObj; 493*cdf0e10cSrcweir if (pObj!=NULL && (pObj->GetPage()!=pPage || !pObj->IsInserted())) pObj=NULL; 494*cdf0e10cSrcweir return pObj; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::CheckNodeConnection(FASTBOOL bTail1) const 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir FASTBOOL bRet=sal_False; 500*cdf0e10cSrcweir const SdrObjConnection& rCon=GetConnection(bTail1); 501*cdf0e10cSrcweir sal_uInt16 nPtAnz=pEdgeTrack->GetPointCount(); 502*cdf0e10cSrcweir if (rCon.pObj!=NULL && rCon.pObj->GetPage()==pPage && nPtAnz!=0) { 503*cdf0e10cSrcweir const SdrGluePointList* pGPL=rCon.pObj->GetGluePointList(); 504*cdf0e10cSrcweir sal_uInt16 nConAnz=pGPL==NULL ? 0 : pGPL->GetCount(); 505*cdf0e10cSrcweir sal_uInt16 nGesAnz=nConAnz+8; 506*cdf0e10cSrcweir Point aTail(bTail1 ? (*pEdgeTrack)[0] : (*pEdgeTrack)[sal_uInt16(nPtAnz-1)]); 507*cdf0e10cSrcweir for (sal_uInt16 i=0; i<nGesAnz && !bRet; i++) { 508*cdf0e10cSrcweir if (i<nConAnz) { // UserDefined 509*cdf0e10cSrcweir bRet=aTail==(*pGPL)[i].GetAbsolutePos(*rCon.pObj); 510*cdf0e10cSrcweir } else if (i<nConAnz+4) { // Vertex 511*cdf0e10cSrcweir SdrGluePoint aPt(rCon.pObj->GetVertexGluePoint(i-nConAnz)); 512*cdf0e10cSrcweir bRet=aTail==aPt.GetAbsolutePos(*rCon.pObj); 513*cdf0e10cSrcweir } else { // Corner 514*cdf0e10cSrcweir SdrGluePoint aPt(rCon.pObj->GetCornerGluePoint(i-nConAnz-4)); 515*cdf0e10cSrcweir bRet=aTail==aPt.GetAbsolutePos(*rCon.pObj); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir return bRet; 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir void SdrEdgeObj::ImpSetTailPoint(FASTBOOL bTail1, const Point& rPt) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir sal_uInt16 nPtAnz=pEdgeTrack->GetPointCount(); 525*cdf0e10cSrcweir if (nPtAnz==0) { 526*cdf0e10cSrcweir (*pEdgeTrack)[0]=rPt; 527*cdf0e10cSrcweir (*pEdgeTrack)[1]=rPt; 528*cdf0e10cSrcweir } else if (nPtAnz==1) { 529*cdf0e10cSrcweir if (!bTail1) (*pEdgeTrack)[1]=rPt; 530*cdf0e10cSrcweir else { (*pEdgeTrack)[1]=(*pEdgeTrack)[0]; (*pEdgeTrack)[0]=rPt; } 531*cdf0e10cSrcweir } else { 532*cdf0e10cSrcweir if (!bTail1) (*pEdgeTrack)[sal_uInt16(nPtAnz-1)]=rPt; 533*cdf0e10cSrcweir else (*pEdgeTrack)[0]=rPt; 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir ImpRecalcEdgeTrack(); 536*cdf0e10cSrcweir SetRectsDirty(); 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir void SdrEdgeObj::ImpDirtyEdgeTrack() 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir if ( !bEdgeTrackUserDefined || !(GetModel() && GetModel()->isLocked()) ) 542*cdf0e10cSrcweir bEdgeTrackDirty = sal_True; 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir void SdrEdgeObj::ImpUndirtyEdgeTrack() 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir if (bEdgeTrackDirty && (GetModel() && GetModel()->isLocked()) ) { 548*cdf0e10cSrcweir ImpRecalcEdgeTrack(); 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir void SdrEdgeObj::ImpRecalcEdgeTrack() 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir if ( bEdgeTrackUserDefined && (GetModel() && GetModel()->isLocked()) ) 555*cdf0e10cSrcweir return; 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir // #110649# 558*cdf0e10cSrcweir if(IsBoundRectCalculationRunning()) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir // this object is involved into another ImpRecalcEdgeTrack() call 561*cdf0e10cSrcweir // from another SdrEdgeObj. Do not calculate again to avoid loop. 562*cdf0e10cSrcweir // Also, do not change bEdgeTrackDirty so that it gets recalculated 563*cdf0e10cSrcweir // later at the first non-looping call. 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir // #i43068# 566*cdf0e10cSrcweir else if(GetModel() && GetModel()->isLocked()) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir // avoid re-layout during imports/API call sequences 569*cdf0e10cSrcweir // #i45294# but calc EdgeTrack and secure properties there 570*cdf0e10cSrcweir ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_True; 571*cdf0e10cSrcweir *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo); 572*cdf0e10cSrcweir ImpSetAttrToEdgeInfo(); 573*cdf0e10cSrcweir bEdgeTrackDirty=sal_False; 574*cdf0e10cSrcweir ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_False; 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir else 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir // To not run in a depth loop, use a coloring algorythm on 579*cdf0e10cSrcweir // SdrEdgeObj BoundRect calculations 580*cdf0e10cSrcweir ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_True; 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); 583*cdf0e10cSrcweir SetRectsDirty(); 584*cdf0e10cSrcweir // #110094#-14 if (!bEdgeTrackDirty) SendRepaintBroadcast(); 585*cdf0e10cSrcweir *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo); 586*cdf0e10cSrcweir ImpSetEdgeInfoToAttr(); // Die Werte aus aEdgeInfo in den Pool kopieren 587*cdf0e10cSrcweir bEdgeTrackDirty=sal_False; 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir // Only redraw here, no object change 590*cdf0e10cSrcweir ActionChanged(); 591*cdf0e10cSrcweir // BroadcastObjectChange(); 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir // #110649# 596*cdf0e10cSrcweir ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_False; 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir sal_uInt16 SdrEdgeObj::ImpCalcEscAngle(SdrObject* pObj, const Point& rPt) const 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir if (pObj==NULL) return SDRESC_ALL; 603*cdf0e10cSrcweir Rectangle aR(pObj->GetSnapRect()); 604*cdf0e10cSrcweir long dxl=rPt.X()-aR.Left(); 605*cdf0e10cSrcweir long dyo=rPt.Y()-aR.Top(); 606*cdf0e10cSrcweir long dxr=aR.Right()-rPt.X(); 607*cdf0e10cSrcweir long dyu=aR.Bottom()-rPt.Y(); 608*cdf0e10cSrcweir FASTBOOL bxMitt=Abs(dxl-dxr)<2; 609*cdf0e10cSrcweir FASTBOOL byMitt=Abs(dyo-dyu)<2; 610*cdf0e10cSrcweir long dx=Min(dxl,dxr); 611*cdf0e10cSrcweir long dy=Min(dyo,dyu); 612*cdf0e10cSrcweir FASTBOOL bDiag=Abs(dx-dy)<2; 613*cdf0e10cSrcweir if (bxMitt && byMitt) return SDRESC_ALL; // In der Mitte 614*cdf0e10cSrcweir if (bDiag) { // diagonal 615*cdf0e10cSrcweir sal_uInt16 nRet=0; 616*cdf0e10cSrcweir if (byMitt) nRet|=SDRESC_VERT; 617*cdf0e10cSrcweir if (bxMitt) nRet|=SDRESC_HORZ; 618*cdf0e10cSrcweir if (dxl<dxr) { // Links 619*cdf0e10cSrcweir if (dyo<dyu) nRet|=SDRESC_LEFT | SDRESC_TOP; 620*cdf0e10cSrcweir else nRet|=SDRESC_LEFT | SDRESC_BOTTOM; 621*cdf0e10cSrcweir } else { // Rechts 622*cdf0e10cSrcweir if (dyo<dyu) nRet|=SDRESC_RIGHT | SDRESC_TOP; 623*cdf0e10cSrcweir else nRet|=SDRESC_RIGHT | SDRESC_BOTTOM; 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir return nRet; 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir if (dx<dy) { // waagerecht 628*cdf0e10cSrcweir if (bxMitt) return SDRESC_HORZ; 629*cdf0e10cSrcweir if (dxl<dxr) return SDRESC_LEFT; 630*cdf0e10cSrcweir else return SDRESC_RIGHT; 631*cdf0e10cSrcweir } else { // senkrecht 632*cdf0e10cSrcweir if (byMitt) return SDRESC_VERT; 633*cdf0e10cSrcweir if (dyo<dyu) return SDRESC_TOP; 634*cdf0e10cSrcweir else return SDRESC_BOTTOM; 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::ImpStripPolyPoints(XPolygon& /*rXP*/) const 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir // fehlende Implementation !!! 641*cdf0e10cSrcweir return sal_False; 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir XPolygon SdrEdgeObj::ImpCalcObjToCenter(const Point& rStPt, long nEscAngle, const Rectangle& rRect, const Point& rMeeting) const 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir XPolygon aXP; 647*cdf0e10cSrcweir aXP.Insert(XPOLY_APPEND,rStPt,XPOLY_NORMAL); 648*cdf0e10cSrcweir FASTBOOL bRts=nEscAngle==0; 649*cdf0e10cSrcweir FASTBOOL bObn=nEscAngle==9000; 650*cdf0e10cSrcweir FASTBOOL bLks=nEscAngle==18000; 651*cdf0e10cSrcweir FASTBOOL bUnt=nEscAngle==27000; 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir Point aP1(rStPt); // erstmal den Pflichtabstand 654*cdf0e10cSrcweir if (bLks) aP1.X()=rRect.Left(); 655*cdf0e10cSrcweir if (bRts) aP1.X()=rRect.Right(); 656*cdf0e10cSrcweir if (bObn) aP1.Y()=rRect.Top(); 657*cdf0e10cSrcweir if (bUnt) aP1.Y()=rRect.Bottom(); 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir FASTBOOL bFinish=sal_False; 660*cdf0e10cSrcweir if (!bFinish) { 661*cdf0e10cSrcweir Point aP2(aP1); // Und nun den Pflichtabstand ggf. bis auf Meetinghoehe erweitern 662*cdf0e10cSrcweir if (bLks && rMeeting.X()<=aP2.X()) aP2.X()=rMeeting.X(); 663*cdf0e10cSrcweir if (bRts && rMeeting.X()>=aP2.X()) aP2.X()=rMeeting.X(); 664*cdf0e10cSrcweir if (bObn && rMeeting.Y()<=aP2.Y()) aP2.Y()=rMeeting.Y(); 665*cdf0e10cSrcweir if (bUnt && rMeeting.Y()>=aP2.Y()) aP2.Y()=rMeeting.Y(); 666*cdf0e10cSrcweir aXP.Insert(XPOLY_APPEND,aP2,XPOLY_NORMAL); 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir Point aP3(aP2); 669*cdf0e10cSrcweir if ((bLks && rMeeting.X()>aP2.X()) || (bRts && rMeeting.X()<aP2.X())) { // Aussenrum 670*cdf0e10cSrcweir if (rMeeting.Y()<aP2.Y()) { 671*cdf0e10cSrcweir aP3.Y()=rRect.Top(); 672*cdf0e10cSrcweir if (rMeeting.Y()<aP3.Y()) aP3.Y()=rMeeting.Y(); 673*cdf0e10cSrcweir } else { 674*cdf0e10cSrcweir aP3.Y()=rRect.Bottom(); 675*cdf0e10cSrcweir if (rMeeting.Y()>aP3.Y()) aP3.Y()=rMeeting.Y(); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL); 678*cdf0e10cSrcweir if (aP3.Y()!=rMeeting.Y()) { 679*cdf0e10cSrcweir aP3.X()=rMeeting.X(); 680*cdf0e10cSrcweir aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL); 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir if ((bObn && rMeeting.Y()>aP2.Y()) || (bUnt && rMeeting.Y()<aP2.Y())) { // Aussenrum 684*cdf0e10cSrcweir if (rMeeting.X()<aP2.X()) { 685*cdf0e10cSrcweir aP3.X()=rRect.Left(); 686*cdf0e10cSrcweir if (rMeeting.X()<aP3.X()) aP3.X()=rMeeting.X(); 687*cdf0e10cSrcweir } else { 688*cdf0e10cSrcweir aP3.X()=rRect.Right(); 689*cdf0e10cSrcweir if (rMeeting.X()>aP3.X()) aP3.X()=rMeeting.X(); 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL); 692*cdf0e10cSrcweir if (aP3.X()!=rMeeting.X()) { 693*cdf0e10cSrcweir aP3.Y()=rMeeting.Y(); 694*cdf0e10cSrcweir aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL); 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir #ifdef DBG_UTIL 699*cdf0e10cSrcweir if (aXP.GetPointCount()>4) { 700*cdf0e10cSrcweir DBG_ERROR("SdrEdgeObj::ImpCalcObjToCenter(): Polygon hat mehr als 4 Punkte!"); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir #endif 703*cdf0e10cSrcweir return aXP; 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& rTrack0, SdrObjConnection& rCon1, SdrObjConnection& rCon2, SdrEdgeInfoRec* pInfo) const 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir Point aPt1,aPt2; 709*cdf0e10cSrcweir SdrGluePoint aGP1,aGP2; 710*cdf0e10cSrcweir sal_uInt16 nEsc1=SDRESC_ALL,nEsc2=SDRESC_ALL; 711*cdf0e10cSrcweir Rectangle aBoundRect1; 712*cdf0e10cSrcweir Rectangle aBoundRect2; 713*cdf0e10cSrcweir Rectangle aBewareRect1; 714*cdf0e10cSrcweir Rectangle aBewareRect2; 715*cdf0e10cSrcweir // Erstmal die alten Endpunkte wiederholen 716*cdf0e10cSrcweir if (rTrack0.GetPointCount()!=0) { 717*cdf0e10cSrcweir aPt1=rTrack0[0]; 718*cdf0e10cSrcweir sal_uInt16 nSiz=rTrack0.GetPointCount(); 719*cdf0e10cSrcweir nSiz--; 720*cdf0e10cSrcweir aPt2=rTrack0[nSiz]; 721*cdf0e10cSrcweir } else { 722*cdf0e10cSrcweir if (!aOutRect.IsEmpty()) { 723*cdf0e10cSrcweir aPt1=aOutRect.TopLeft(); 724*cdf0e10cSrcweir aPt2=aOutRect.BottomRight(); 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir FASTBOOL bCon1=rCon1.pObj!=NULL && rCon1.pObj->GetPage()==pPage && rCon1.pObj->IsInserted(); 728*cdf0e10cSrcweir FASTBOOL bCon2=rCon2.pObj!=NULL && rCon2.pObj->GetPage()==pPage && rCon2.pObj->IsInserted(); 729*cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet(); 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir if (bCon1) { 732*cdf0e10cSrcweir if (rCon1.pObj==(SdrObject*)this) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir // sicherheitshalber Abfragen #44515# 735*cdf0e10cSrcweir aBoundRect1=aOutRect; 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir else 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir aBoundRect1 = rCon1.pObj->GetCurrentBoundRect(); 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir aBoundRect1.Move(rCon1.aObjOfs.X(),rCon1.aObjOfs.Y()); 742*cdf0e10cSrcweir aBewareRect1=aBoundRect1; 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir sal_Int32 nH = ((SdrEdgeNode1HorzDistItem&)rSet.Get(SDRATTR_EDGENODE1HORZDIST)).GetValue(); 745*cdf0e10cSrcweir sal_Int32 nV = ((SdrEdgeNode1VertDistItem&)rSet.Get(SDRATTR_EDGENODE1VERTDIST)).GetValue(); 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir aBewareRect1.Left()-=nH; 748*cdf0e10cSrcweir aBewareRect1.Right()+=nH; 749*cdf0e10cSrcweir aBewareRect1.Top()-=nV; 750*cdf0e10cSrcweir aBewareRect1.Bottom()+=nV; 751*cdf0e10cSrcweir } else { 752*cdf0e10cSrcweir aBoundRect1=Rectangle(aPt1,aPt1); 753*cdf0e10cSrcweir aBoundRect1.Move(rCon1.aObjOfs.X(),rCon1.aObjOfs.Y()); 754*cdf0e10cSrcweir aBewareRect1=aBoundRect1; 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir if (bCon2) { 757*cdf0e10cSrcweir if (rCon2.pObj==(SdrObject*)this) { // sicherheitshalber Abfragen #44515# 758*cdf0e10cSrcweir aBoundRect2=aOutRect; 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir else 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir aBoundRect2 = rCon2.pObj->GetCurrentBoundRect(); 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir aBoundRect2.Move(rCon2.aObjOfs.X(),rCon2.aObjOfs.Y()); 765*cdf0e10cSrcweir aBewareRect2=aBoundRect2; 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir sal_Int32 nH = ((SdrEdgeNode2HorzDistItem&)rSet.Get(SDRATTR_EDGENODE2HORZDIST)).GetValue(); 768*cdf0e10cSrcweir sal_Int32 nV = ((SdrEdgeNode2VertDistItem&)rSet.Get(SDRATTR_EDGENODE2VERTDIST)).GetValue(); 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir aBewareRect2.Left()-=nH; 771*cdf0e10cSrcweir aBewareRect2.Right()+=nH; 772*cdf0e10cSrcweir aBewareRect2.Top()-=nV; 773*cdf0e10cSrcweir aBewareRect2.Bottom()+=nV; 774*cdf0e10cSrcweir } else { 775*cdf0e10cSrcweir aBoundRect2=Rectangle(aPt2,aPt2); 776*cdf0e10cSrcweir aBoundRect2.Move(rCon2.aObjOfs.X(),rCon2.aObjOfs.Y()); 777*cdf0e10cSrcweir aBewareRect2=aBoundRect2; 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir XPolygon aBestXP; 780*cdf0e10cSrcweir sal_uIntPtr nBestQual=0xFFFFFFFF; 781*cdf0e10cSrcweir SdrEdgeInfoRec aBestInfo; 782*cdf0e10cSrcweir FASTBOOL bAuto1=bCon1 && rCon1.bBestVertex; 783*cdf0e10cSrcweir FASTBOOL bAuto2=bCon2 && rCon2.bBestVertex; 784*cdf0e10cSrcweir if (bAuto1) rCon1.bAutoVertex=sal_True; 785*cdf0e10cSrcweir if (bAuto2) rCon2.bAutoVertex=sal_True; 786*cdf0e10cSrcweir sal_uInt16 nBestAuto1=0; 787*cdf0e10cSrcweir sal_uInt16 nBestAuto2=0; 788*cdf0e10cSrcweir sal_uInt16 nAnz1=bAuto1 ? 4 : 1; 789*cdf0e10cSrcweir sal_uInt16 nAnz2=bAuto2 ? 4 : 1; 790*cdf0e10cSrcweir for (sal_uInt16 nNum1=0; nNum1<nAnz1; nNum1++) { 791*cdf0e10cSrcweir if (bAuto1) rCon1.nConId=nNum1; 792*cdf0e10cSrcweir if (bCon1 && rCon1.TakeGluePoint(aGP1,sal_True)) { 793*cdf0e10cSrcweir aPt1=aGP1.GetPos(); 794*cdf0e10cSrcweir nEsc1=aGP1.GetEscDir(); 795*cdf0e10cSrcweir if (nEsc1==SDRESC_SMART) nEsc1=ImpCalcEscAngle(rCon1.pObj,aPt1-rCon1.aObjOfs); 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir for (sal_uInt16 nNum2=0; nNum2<nAnz2; nNum2++) { 798*cdf0e10cSrcweir if (bAuto2) rCon2.nConId=nNum2; 799*cdf0e10cSrcweir if (bCon2 && rCon2.TakeGluePoint(aGP2,sal_True)) { 800*cdf0e10cSrcweir aPt2=aGP2.GetPos(); 801*cdf0e10cSrcweir nEsc2=aGP2.GetEscDir(); 802*cdf0e10cSrcweir if (nEsc2==SDRESC_SMART) nEsc2=ImpCalcEscAngle(rCon2.pObj,aPt2-rCon2.aObjOfs); 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir for (long nA1=0; nA1<36000; nA1+=9000) { 805*cdf0e10cSrcweir sal_uInt16 nE1=nA1==0 ? SDRESC_RIGHT : nA1==9000 ? SDRESC_TOP : nA1==18000 ? SDRESC_LEFT : nA1==27000 ? SDRESC_BOTTOM : 0; 806*cdf0e10cSrcweir for (long nA2=0; nA2<36000; nA2+=9000) { 807*cdf0e10cSrcweir sal_uInt16 nE2=nA2==0 ? SDRESC_RIGHT : nA2==9000 ? SDRESC_TOP : nA2==18000 ? SDRESC_LEFT : nA2==27000 ? SDRESC_BOTTOM : 0; 808*cdf0e10cSrcweir if ((nEsc1&nE1)!=0 && (nEsc2&nE2)!=0) { 809*cdf0e10cSrcweir sal_uIntPtr nQual=0; 810*cdf0e10cSrcweir SdrEdgeInfoRec aInfo; 811*cdf0e10cSrcweir if (pInfo!=NULL) aInfo=*pInfo; 812*cdf0e10cSrcweir XPolygon aXP(ImpCalcEdgeTrack(aPt1,nA1,aBoundRect1,aBewareRect1,aPt2,nA2,aBoundRect2,aBewareRect2,&nQual,&aInfo)); 813*cdf0e10cSrcweir if (nQual<nBestQual) { 814*cdf0e10cSrcweir aBestXP=aXP; 815*cdf0e10cSrcweir nBestQual=nQual; 816*cdf0e10cSrcweir aBestInfo=aInfo; 817*cdf0e10cSrcweir nBestAuto1=nNum1; 818*cdf0e10cSrcweir nBestAuto2=nNum2; 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir } 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir } 825*cdf0e10cSrcweir if (bAuto1) rCon1.nConId=nBestAuto1; 826*cdf0e10cSrcweir if (bAuto2) rCon2.nConId=nBestAuto2; 827*cdf0e10cSrcweir if (pInfo!=NULL) *pInfo=aBestInfo; 828*cdf0e10cSrcweir return aBestXP; 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const Point& rPt1, long nAngle1, const Rectangle& rBoundRect1, const Rectangle& rBewareRect1, 832*cdf0e10cSrcweir const Point& rPt2, long nAngle2, const Rectangle& rBoundRect2, const Rectangle& rBewareRect2, 833*cdf0e10cSrcweir sal_uIntPtr* pnQuality, SdrEdgeInfoRec* pInfo) const 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue(); 836*cdf0e10cSrcweir FASTBOOL bRts1=nAngle1==0; 837*cdf0e10cSrcweir FASTBOOL bObn1=nAngle1==9000; 838*cdf0e10cSrcweir FASTBOOL bLks1=nAngle1==18000; 839*cdf0e10cSrcweir FASTBOOL bUnt1=nAngle1==27000; 840*cdf0e10cSrcweir FASTBOOL bHor1=bLks1 || bRts1; 841*cdf0e10cSrcweir FASTBOOL bVer1=bObn1 || bUnt1; 842*cdf0e10cSrcweir FASTBOOL bRts2=nAngle2==0; 843*cdf0e10cSrcweir FASTBOOL bObn2=nAngle2==9000; 844*cdf0e10cSrcweir FASTBOOL bLks2=nAngle2==18000; 845*cdf0e10cSrcweir FASTBOOL bUnt2=nAngle2==27000; 846*cdf0e10cSrcweir FASTBOOL bHor2=bLks2 || bRts2; 847*cdf0e10cSrcweir FASTBOOL bVer2=bObn2 || bUnt2; 848*cdf0e10cSrcweir FASTBOOL bInfo=pInfo!=NULL; 849*cdf0e10cSrcweir if (bInfo) { 850*cdf0e10cSrcweir pInfo->cOrthoForm=0; 851*cdf0e10cSrcweir pInfo->nAngle1=nAngle1; 852*cdf0e10cSrcweir pInfo->nAngle2=nAngle2; 853*cdf0e10cSrcweir pInfo->nObj1Lines=1; 854*cdf0e10cSrcweir pInfo->nObj2Lines=1; 855*cdf0e10cSrcweir pInfo->nMiddleLine=0xFFFF; 856*cdf0e10cSrcweir } 857*cdf0e10cSrcweir Point aPt1(rPt1); 858*cdf0e10cSrcweir Point aPt2(rPt2); 859*cdf0e10cSrcweir Rectangle aBoundRect1 (rBoundRect1 ); 860*cdf0e10cSrcweir Rectangle aBoundRect2 (rBoundRect2 ); 861*cdf0e10cSrcweir Rectangle aBewareRect1(rBewareRect1); 862*cdf0e10cSrcweir Rectangle aBewareRect2(rBewareRect2); 863*cdf0e10cSrcweir Point aMeeting((aPt1.X()+aPt2.X()+1)/2,(aPt1.Y()+aPt2.Y()+1)/2); 864*cdf0e10cSrcweir FASTBOOL bMeetingXMid=sal_True; 865*cdf0e10cSrcweir FASTBOOL bMeetingYMid=sal_True; 866*cdf0e10cSrcweir if (eKind==SDREDGE_ONELINE) { 867*cdf0e10cSrcweir XPolygon aXP(2); 868*cdf0e10cSrcweir aXP[0]=rPt1; 869*cdf0e10cSrcweir aXP[1]=rPt2; 870*cdf0e10cSrcweir if (pnQuality!=NULL) { 871*cdf0e10cSrcweir *pnQuality=Abs(rPt1.X()-rPt2.X())+Abs(rPt1.Y()-rPt2.Y()); 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir return aXP; 874*cdf0e10cSrcweir } else if (eKind==SDREDGE_THREELINES) { 875*cdf0e10cSrcweir XPolygon aXP(4); 876*cdf0e10cSrcweir aXP[0]=rPt1; 877*cdf0e10cSrcweir aXP[1]=rPt1; 878*cdf0e10cSrcweir aXP[2]=rPt2; 879*cdf0e10cSrcweir aXP[3]=rPt2; 880*cdf0e10cSrcweir if (bRts1) aXP[1].X()=aBewareRect1.Right(); //+=500; 881*cdf0e10cSrcweir if (bObn1) aXP[1].Y()=aBewareRect1.Top(); //-=500; 882*cdf0e10cSrcweir if (bLks1) aXP[1].X()=aBewareRect1.Left(); //-=500; 883*cdf0e10cSrcweir if (bUnt1) aXP[1].Y()=aBewareRect1.Bottom(); //+=500; 884*cdf0e10cSrcweir if (bRts2) aXP[2].X()=aBewareRect2.Right(); //+=500; 885*cdf0e10cSrcweir if (bObn2) aXP[2].Y()=aBewareRect2.Top(); //-=500; 886*cdf0e10cSrcweir if (bLks2) aXP[2].X()=aBewareRect2.Left(); //-=500; 887*cdf0e10cSrcweir if (bUnt2) aXP[2].Y()=aBewareRect2.Bottom(); //+=500; 888*cdf0e10cSrcweir if (pnQuality!=NULL) { 889*cdf0e10cSrcweir long nQ=Abs(aXP[1].X()-aXP[0].X())+Abs(aXP[1].Y()-aXP[0].Y()); 890*cdf0e10cSrcweir nQ+=Abs(aXP[2].X()-aXP[1].X())+Abs(aXP[2].Y()-aXP[1].Y()); 891*cdf0e10cSrcweir nQ+=Abs(aXP[3].X()-aXP[2].X())+Abs(aXP[3].Y()-aXP[2].Y()); 892*cdf0e10cSrcweir *pnQuality=nQ; 893*cdf0e10cSrcweir } 894*cdf0e10cSrcweir if (bInfo) { 895*cdf0e10cSrcweir pInfo->nObj1Lines=2; 896*cdf0e10cSrcweir pInfo->nObj2Lines=2; 897*cdf0e10cSrcweir if (bHor1) { 898*cdf0e10cSrcweir aXP[1].X()+=pInfo->aObj1Line2.X(); 899*cdf0e10cSrcweir } else { 900*cdf0e10cSrcweir aXP[1].Y()+=pInfo->aObj1Line2.Y(); 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir if (bHor2) { 903*cdf0e10cSrcweir aXP[2].X()+=pInfo->aObj2Line2.X(); 904*cdf0e10cSrcweir } else { 905*cdf0e10cSrcweir aXP[2].Y()+=pInfo->aObj2Line2.Y(); 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir } 908*cdf0e10cSrcweir return aXP; 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir sal_uInt16 nIntersections=0; 911*cdf0e10cSrcweir FASTBOOL bForceMeeting=sal_False; // Muss die Linie durch den MeetingPoint laufen? 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir Point aC1(aBewareRect1.Center()); 914*cdf0e10cSrcweir Point aC2(aBewareRect2.Center()); 915*cdf0e10cSrcweir if (aBewareRect1.Left()<=aBewareRect2.Right() && aBewareRect1.Right()>=aBewareRect2.Left()) { 916*cdf0e10cSrcweir // Ueberschneidung auf der X-Achse 917*cdf0e10cSrcweir long n1=Max(aBewareRect1.Left(),aBewareRect2.Left()); 918*cdf0e10cSrcweir long n2=Min(aBewareRect1.Right(),aBewareRect2.Right()); 919*cdf0e10cSrcweir aMeeting.X()=(n1+n2+1)/2; 920*cdf0e10cSrcweir } else { 921*cdf0e10cSrcweir // Ansonsten den Mittelpunkt des Freiraums 922*cdf0e10cSrcweir if (aC1.X()<aC2.X()) { 923*cdf0e10cSrcweir aMeeting.X()=(aBewareRect1.Right()+aBewareRect2.Left()+1)/2; 924*cdf0e10cSrcweir } else { 925*cdf0e10cSrcweir aMeeting.X()=(aBewareRect1.Left()+aBewareRect2.Right()+1)/2; 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir } 928*cdf0e10cSrcweir if (aBewareRect1.Top()<=aBewareRect2.Bottom() && aBewareRect1.Bottom()>=aBewareRect2.Top()) { 929*cdf0e10cSrcweir // Ueberschneidung auf der Y-Achse 930*cdf0e10cSrcweir long n1=Max(aBewareRect1.Top(),aBewareRect2.Top()); 931*cdf0e10cSrcweir long n2=Min(aBewareRect1.Bottom(),aBewareRect2.Bottom()); 932*cdf0e10cSrcweir aMeeting.Y()=(n1+n2+1)/2; 933*cdf0e10cSrcweir } else { 934*cdf0e10cSrcweir // Ansonsten den Mittelpunkt des Freiraums 935*cdf0e10cSrcweir if (aC1.Y()<aC2.Y()) { 936*cdf0e10cSrcweir aMeeting.Y()=(aBewareRect1.Bottom()+aBewareRect2.Top()+1)/2; 937*cdf0e10cSrcweir } else { 938*cdf0e10cSrcweir aMeeting.Y()=(aBewareRect1.Top()+aBewareRect2.Bottom()+1)/2; 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir // Im Prinzip gibt es 3 zu unterscheidene Faelle: 942*cdf0e10cSrcweir // 1. Beide in die selbe Richtung 943*cdf0e10cSrcweir // 2. Beide in genau entgegengesetzte Richtungen 944*cdf0e10cSrcweir // 3. Einer waagerecht und der andere senkrecht 945*cdf0e10cSrcweir long nXMin=Min(aBewareRect1.Left(),aBewareRect2.Left()); 946*cdf0e10cSrcweir long nXMax=Max(aBewareRect1.Right(),aBewareRect2.Right()); 947*cdf0e10cSrcweir long nYMin=Min(aBewareRect1.Top(),aBewareRect2.Top()); 948*cdf0e10cSrcweir long nYMax=Max(aBewareRect1.Bottom(),aBewareRect2.Bottom()); 949*cdf0e10cSrcweir //int bBoundOverlap=aBoundRect1.Right()>aBoundRect2.Left() && aBoundRect1.Left()<aBoundRect2.Right() && 950*cdf0e10cSrcweir aBoundRect1.Bottom()>aBoundRect2.Top() && aBoundRect1.Top()<aBoundRect2.Bottom(); 951*cdf0e10cSrcweir FASTBOOL bBewareOverlap=aBewareRect1.Right()>aBewareRect2.Left() && aBewareRect1.Left()<aBewareRect2.Right() && 952*cdf0e10cSrcweir aBewareRect1.Bottom()>aBewareRect2.Top() && aBewareRect1.Top()<aBewareRect2.Bottom(); 953*cdf0e10cSrcweir unsigned nMainCase=3; 954*cdf0e10cSrcweir if (nAngle1==nAngle2) nMainCase=1; 955*cdf0e10cSrcweir else if ((bHor1 && bHor2) || (bVer1 && bVer2)) nMainCase=2; 956*cdf0e10cSrcweir if (nMainCase==1) { // Fall 1: Beide in eine Richtung moeglich. 957*cdf0e10cSrcweir if (bVer1) aMeeting.X()=(aPt1.X()+aPt2.X()+1)/2; // ist hier besser, als der 958*cdf0e10cSrcweir if (bHor1) aMeeting.Y()=(aPt1.Y()+aPt2.Y()+1)/2; // Mittelpunkt des Freiraums 959*cdf0e10cSrcweir // bX1Ok bedeutet, dass die Vertikale, die aus Obj1 austritt, keinen Konflikt mit Obj2 bildet, ... 960*cdf0e10cSrcweir FASTBOOL bX1Ok=aPt1.X()<=aBewareRect2.Left() || aPt1.X()>=aBewareRect2.Right(); 961*cdf0e10cSrcweir FASTBOOL bX2Ok=aPt2.X()<=aBewareRect1.Left() || aPt2.X()>=aBewareRect1.Right(); 962*cdf0e10cSrcweir FASTBOOL bY1Ok=aPt1.Y()<=aBewareRect2.Top() || aPt1.Y()>=aBewareRect2.Bottom(); 963*cdf0e10cSrcweir FASTBOOL bY2Ok=aPt2.Y()<=aBewareRect1.Top() || aPt2.Y()>=aBewareRect1.Bottom(); 964*cdf0e10cSrcweir if (bLks1 && (bY1Ok || aBewareRect1.Left()<aBewareRect2.Right()) && (bY2Ok || aBewareRect2.Left()<aBewareRect1.Right())) { 965*cdf0e10cSrcweir aMeeting.X()=nXMin; 966*cdf0e10cSrcweir bMeetingXMid=sal_False; 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir if (bRts1 && (bY1Ok || aBewareRect1.Right()>aBewareRect2.Left()) && (bY2Ok || aBewareRect2.Right()>aBewareRect1.Left())) { 969*cdf0e10cSrcweir aMeeting.X()=nXMax; 970*cdf0e10cSrcweir bMeetingXMid=sal_False; 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir if (bObn1 && (bX1Ok || aBewareRect1.Top()<aBewareRect2.Bottom()) && (bX2Ok || aBewareRect2.Top()<aBewareRect1.Bottom())) { 973*cdf0e10cSrcweir aMeeting.Y()=nYMin; 974*cdf0e10cSrcweir bMeetingYMid=sal_False; 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir if (bUnt1 && (bX1Ok || aBewareRect1.Bottom()>aBewareRect2.Top()) && (bX2Ok || aBewareRect2.Bottom()>aBewareRect1.Top())) { 977*cdf0e10cSrcweir aMeeting.Y()=nYMax; 978*cdf0e10cSrcweir bMeetingYMid=sal_False; 979*cdf0e10cSrcweir } 980*cdf0e10cSrcweir } else if (nMainCase==2) { 981*cdf0e10cSrcweir // Fall 2: 982*cdf0e10cSrcweir bForceMeeting=sal_True; 983*cdf0e10cSrcweir if (bHor1) { // beide waagerecht 984*cdf0e10cSrcweir /* 9 Moeglichkeiten: � � � */ 985*cdf0e10cSrcweir /* 2.1 Gegenueber, Ueberschneidung � � � */ 986*cdf0e10cSrcweir /* nur auf der Y-Achse � � � */ 987*cdf0e10cSrcweir /* 2.2, 2.3 Gegenueber, vertikal versetzt. � � � � � � */ 988*cdf0e10cSrcweir /* Ueberschneidung weder auf der � � � � � � */ 989*cdf0e10cSrcweir /* X- noch auf der Y-Achse � � � � � � */ 990*cdf0e10cSrcweir /* 2.4, 2.5 Untereinander, � � � � � � */ 991*cdf0e10cSrcweir /* Ueberschneidung � � � � � � */ 992*cdf0e10cSrcweir /* nur auf X-Achse � � � � � � */ 993*cdf0e10cSrcweir /* 2.6, 2.7 Gegeneinander, vertikal versetzt. � � � � � � */ 994*cdf0e10cSrcweir /* Ueberschneidung weder auf der � � � � � � */ 995*cdf0e10cSrcweir /* X- noch auf der Y-Achse. � � � � � � */ 996*cdf0e10cSrcweir /* 2.8 Gegeneinander. � � � */ 997*cdf0e10cSrcweir /* Ueberschneidung nur � � � */ 998*cdf0e10cSrcweir /* auf der Y-Achse. � � � */ 999*cdf0e10cSrcweir /* 2.9 Die BewareRects der Objekte ueberschneiden */ 1000*cdf0e10cSrcweir /* sich auf X- und Y-Achse. */ 1001*cdf0e10cSrcweir /* Die Faelle gelten entsprechend umgesetzt auch fuer */ 1002*cdf0e10cSrcweir /* senkrechte Linienaustritte. */ 1003*cdf0e10cSrcweir /* Die Faelle 2.1-2.7 werden mit dem Default-Meeting ausreichend*/ 1004*cdf0e10cSrcweir /* gut behandelt. Spezielle MeetingPoints werden hier also nur */ 1005*cdf0e10cSrcweir /* fuer 2.8 und 2.9 bestimmt. */ 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir // Normalisierung. aR1 soll der nach rechts und 1008*cdf0e10cSrcweir // aR2 der nach links austretende sein. 1009*cdf0e10cSrcweir Rectangle aBewR1(bRts1 ? aBewareRect1 : aBewareRect2); 1010*cdf0e10cSrcweir Rectangle aBewR2(bRts1 ? aBewareRect2 : aBewareRect1); 1011*cdf0e10cSrcweir Rectangle aBndR1(bRts1 ? aBoundRect1 : aBoundRect2); 1012*cdf0e10cSrcweir Rectangle aBndR2(bRts1 ? aBoundRect2 : aBoundRect1); 1013*cdf0e10cSrcweir if (aBewR1.Bottom()>aBewR2.Top() && aBewR1.Top()<aBewR2.Bottom()) { 1014*cdf0e10cSrcweir // Ueberschneidung auf der Y-Achse. Faelle 2.1, 2.8, 2.9 1015*cdf0e10cSrcweir if (aBewR1.Right()>aBewR2.Left()) { 1016*cdf0e10cSrcweir // Faelle 2.8, 2.9 1017*cdf0e10cSrcweir // Fall 2.8 ist immer Aussenrumlauf (bDirect=sal_False). 1018*cdf0e10cSrcweir // Fall 2.9 kann auch Direktverbindung sein (bei geringer 1019*cdf0e10cSrcweir // Ueberschneidung der BewareRects ohne Ueberschneidung der 1020*cdf0e10cSrcweir // Boundrects wenn die Linienaustritte sonst das BewareRect 1021*cdf0e10cSrcweir // des jeweils anderen Objekts verletzen wuerden. 1022*cdf0e10cSrcweir FASTBOOL bCase29Direct=sal_False; 1023*cdf0e10cSrcweir FASTBOOL bCase29=aBewR1.Right()>aBewR2.Left(); 1024*cdf0e10cSrcweir if (aBndR1.Right()<=aBndR2.Left()) { // Fall 2.9 und keine Boundrectueberschneidung 1025*cdf0e10cSrcweir if ((aPt1.Y()>aBewareRect2.Top() && aPt1.Y()<aBewareRect2.Bottom()) || 1026*cdf0e10cSrcweir (aPt2.Y()>aBewareRect1.Top() && aPt2.Y()<aBewareRect1.Bottom())) { 1027*cdf0e10cSrcweir bCase29Direct=sal_True; 1028*cdf0e10cSrcweir } 1029*cdf0e10cSrcweir } 1030*cdf0e10cSrcweir if (!bCase29Direct) { 1031*cdf0e10cSrcweir FASTBOOL bObenLang=Abs(nYMin-aMeeting.Y())<=Abs(nYMax-aMeeting.Y()); 1032*cdf0e10cSrcweir if (bObenLang) { 1033*cdf0e10cSrcweir aMeeting.Y()=nYMin; 1034*cdf0e10cSrcweir } else { 1035*cdf0e10cSrcweir aMeeting.Y()=nYMax; 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir bMeetingYMid=sal_False; 1038*cdf0e10cSrcweir if (bCase29) { 1039*cdf0e10cSrcweir // und nun noch dafuer sorgen, dass das 1040*cdf0e10cSrcweir // umzingelte Obj nicht durchquert wird 1041*cdf0e10cSrcweir if ((aBewR1.Center().Y()<aBewR2.Center().Y()) != bObenLang) { 1042*cdf0e10cSrcweir aMeeting.X()=aBewR2.Right(); 1043*cdf0e10cSrcweir } else { 1044*cdf0e10cSrcweir aMeeting.X()=aBewR1.Left(); 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir bMeetingXMid=sal_False; 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir } else { 1049*cdf0e10cSrcweir // Direkte Verbindung (3-Linien Z-Verbindung), da 1050*cdf0e10cSrcweir // Verletzung der BewareRects unvermeidlich ist. 1051*cdf0e10cSrcweir // Via Dreisatz werden die BewareRects nun verkleinert. 1052*cdf0e10cSrcweir long nWant1=aBewR1.Right()-aBndR1.Right(); // Abstand bei Obj1 1053*cdf0e10cSrcweir long nWant2=aBndR2.Left()-aBewR2.Left(); // Abstand bei Obj2 1054*cdf0e10cSrcweir long nSpace=aBndR2.Left()-aBndR1.Right(); // verfuegbarer Platz 1055*cdf0e10cSrcweir long nGet1=BigMulDiv(nWant1,nSpace,nWant1+nWant2); 1056*cdf0e10cSrcweir long nGet2=nSpace-nGet1; 1057*cdf0e10cSrcweir if (bRts1) { // Normalisierung zurueckwandeln 1058*cdf0e10cSrcweir aBewareRect1.Right()+=nGet1-nWant1; 1059*cdf0e10cSrcweir aBewareRect2.Left()-=nGet2-nWant2; 1060*cdf0e10cSrcweir } else { 1061*cdf0e10cSrcweir aBewareRect2.Right()+=nGet1-nWant1; 1062*cdf0e10cSrcweir aBewareRect1.Left()-=nGet2-nWant2; 1063*cdf0e10cSrcweir } 1064*cdf0e10cSrcweir nIntersections++; // Qualitaet herabsetzen 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir } 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir } else if (bVer1) { // beide senkrecht 1069*cdf0e10cSrcweir Rectangle aBewR1(bUnt1 ? aBewareRect1 : aBewareRect2); 1070*cdf0e10cSrcweir Rectangle aBewR2(bUnt1 ? aBewareRect2 : aBewareRect1); 1071*cdf0e10cSrcweir Rectangle aBndR1(bUnt1 ? aBoundRect1 : aBoundRect2); 1072*cdf0e10cSrcweir Rectangle aBndR2(bUnt1 ? aBoundRect2 : aBoundRect1); 1073*cdf0e10cSrcweir if (aBewR1.Right()>aBewR2.Left() && aBewR1.Left()<aBewR2.Right()) { 1074*cdf0e10cSrcweir // Ueberschneidung auf der Y-Achse. Faelle 2.1, 2.8, 2.9 1075*cdf0e10cSrcweir if (aBewR1.Bottom()>aBewR2.Top()) { 1076*cdf0e10cSrcweir // Faelle 2.8, 2.9 1077*cdf0e10cSrcweir // Fall 2.8 ist immer Aussenrumlauf (bDirect=sal_False). 1078*cdf0e10cSrcweir // Fall 2.9 kann auch Direktverbindung sein (bei geringer 1079*cdf0e10cSrcweir // Ueberschneidung der BewareRects ohne Ueberschneidung der 1080*cdf0e10cSrcweir // Boundrects wenn die Linienaustritte sonst das BewareRect 1081*cdf0e10cSrcweir // des jeweils anderen Objekts verletzen wuerden. 1082*cdf0e10cSrcweir FASTBOOL bCase29Direct=sal_False; 1083*cdf0e10cSrcweir FASTBOOL bCase29=aBewR1.Bottom()>aBewR2.Top(); 1084*cdf0e10cSrcweir if (aBndR1.Bottom()<=aBndR2.Top()) { // Fall 2.9 und keine Boundrectueberschneidung 1085*cdf0e10cSrcweir if ((aPt1.X()>aBewareRect2.Left() && aPt1.X()<aBewareRect2.Right()) || 1086*cdf0e10cSrcweir (aPt2.X()>aBewareRect1.Left() && aPt2.X()<aBewareRect1.Right())) { 1087*cdf0e10cSrcweir bCase29Direct=sal_True; 1088*cdf0e10cSrcweir } 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir if (!bCase29Direct) { 1091*cdf0e10cSrcweir FASTBOOL bLinksLang=Abs(nXMin-aMeeting.X())<=Abs(nXMax-aMeeting.X()); 1092*cdf0e10cSrcweir if (bLinksLang) { 1093*cdf0e10cSrcweir aMeeting.X()=nXMin; 1094*cdf0e10cSrcweir } else { 1095*cdf0e10cSrcweir aMeeting.X()=nXMax; 1096*cdf0e10cSrcweir } 1097*cdf0e10cSrcweir bMeetingXMid=sal_False; 1098*cdf0e10cSrcweir if (bCase29) { 1099*cdf0e10cSrcweir // und nun noch dafuer sorgen, dass das 1100*cdf0e10cSrcweir // umzingelte Obj nicht durchquert wird 1101*cdf0e10cSrcweir if ((aBewR1.Center().X()<aBewR2.Center().X()) != bLinksLang) { 1102*cdf0e10cSrcweir aMeeting.Y()=aBewR2.Bottom(); 1103*cdf0e10cSrcweir } else { 1104*cdf0e10cSrcweir aMeeting.Y()=aBewR1.Top(); 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir bMeetingYMid=sal_False; 1107*cdf0e10cSrcweir } 1108*cdf0e10cSrcweir } else { 1109*cdf0e10cSrcweir // Direkte Verbindung (3-Linien Z-Verbindung), da 1110*cdf0e10cSrcweir // Verletzung der BewareRects unvermeidlich ist. 1111*cdf0e10cSrcweir // Via Dreisatz werden die BewareRects nun verkleinert. 1112*cdf0e10cSrcweir long nWant1=aBewR1.Bottom()-aBndR1.Bottom(); // Abstand bei Obj1 1113*cdf0e10cSrcweir long nWant2=aBndR2.Top()-aBewR2.Top(); // Abstand bei Obj2 1114*cdf0e10cSrcweir long nSpace=aBndR2.Top()-aBndR1.Bottom(); // verfuegbarer Platz 1115*cdf0e10cSrcweir long nGet1=BigMulDiv(nWant1,nSpace,nWant1+nWant2); 1116*cdf0e10cSrcweir long nGet2=nSpace-nGet1; 1117*cdf0e10cSrcweir if (bUnt1) { // Normalisierung zurueckwandeln 1118*cdf0e10cSrcweir aBewareRect1.Bottom()+=nGet1-nWant1; 1119*cdf0e10cSrcweir aBewareRect2.Top()-=nGet2-nWant2; 1120*cdf0e10cSrcweir } else { 1121*cdf0e10cSrcweir aBewareRect2.Bottom()+=nGet1-nWant1; 1122*cdf0e10cSrcweir aBewareRect1.Top()-=nGet2-nWant2; 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir nIntersections++; // Qualitaet herabsetzen 1125*cdf0e10cSrcweir } 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir } else if (nMainCase==3) { // Fall 3: Einer waagerecht und der andere senkrecht. Sehr viele Fallunterscheidungen 1130*cdf0e10cSrcweir /* Kleine Legende: � � � � � -> Ohne Ueberschneidung, maximal Beruehrung. */ 1131*cdf0e10cSrcweir /* � � � � � -> Ueberschneidung */ 1132*cdf0e10cSrcweir /* � � � � � -> Selbe Hoehe */ 1133*cdf0e10cSrcweir /* � � � � � -> Ueberschneidung */ 1134*cdf0e10cSrcweir /* � � � � � -> Ohne Ueberschneidung, maximal Beruehrung. */ 1135*cdf0e10cSrcweir /* Linienaustritte links �, rechts �, oben � und unten �. */ 1136*cdf0e10cSrcweir /* Insgesamt sind 96 Konstellationen moeglich, wobei einige nicht einmal */ 1137*cdf0e10cSrcweir /* eindeutig einem Fall und damit einer Behandlungsmethode zugeordnet werden */ 1138*cdf0e10cSrcweir /* koennen. */ 1139*cdf0e10cSrcweir /* 3.1: Hierzu moegen alle Konstellationen zaehlen, die durch den */ 1140*cdf0e10cSrcweir /* Default-MeetingPoint zufriedenstellend abgedeckt sind (20+12). */ 1141*cdf0e10cSrcweir /* � � � � � � � � � � Diese 12 � � � � � � � � � � � � � � � � � � � � */ 1142*cdf0e10cSrcweir /* � � � � � � � � � � Konstel. � � � � � � � � � � � � � � � � � � � � */ 1143*cdf0e10cSrcweir /* � � � � � � � � � � jedoch � � � � � � � � � � � � � � � � � � � � */ 1144*cdf0e10cSrcweir /* � � � � � � � � � � nur zum � � � � � � � � � � � � � � � � � � � � */ 1145*cdf0e10cSrcweir /* � � � � � � � � � � Teil: � � � � � � � � � � � � � � � � � � � � */ 1146*cdf0e10cSrcweir /* Letztere 16 Faelle scheiden aus, sobald sich die Objekte offen */ 1147*cdf0e10cSrcweir /* gegenueberstehen (siehe Fall 3.2). */ 1148*cdf0e10cSrcweir /* 3.2: Die Objekte stehen sich offen gegenueber und somit ist eine */ 1149*cdf0e10cSrcweir /* Verbindung mit lediglich 2 Linien moeglich (4+20). */ 1150*cdf0e10cSrcweir /* Dieser Fall hat 1. Prioritaet. */ 1151*cdf0e10cSrcweir /* � � � � � � � � � � Diese 20 � � � � � � � � � � � � � � � � � � � � */ 1152*cdf0e10cSrcweir /* � � � � � � � � � � Konstel. � � � � � � � � � � � � � � � � � � � � */ 1153*cdf0e10cSrcweir /* � � � � � � � � � � jedoch � � � � � � � � � � � � � � � � � � � � */ 1154*cdf0e10cSrcweir /* � � � � � � � � � � nur zum � � � � � � � � � � � � � � � � � � � � */ 1155*cdf0e10cSrcweir /* � � � � � � � � � � Teil: � � � � � � � � � � � � � � � � � � � � */ 1156*cdf0e10cSrcweir /* 3.3: Die Linienaustritte zeigen vom anderen Objekt weg bzw. hinter */ 1157*cdf0e10cSrcweir /* dessen Ruecken vorbei (52+4). */ 1158*cdf0e10cSrcweir /* � � � � � � � � � � � � � � � � � � � � Diese 4 � � � � � � � � � � */ 1159*cdf0e10cSrcweir /* � � � � � � � � � � � � � � � � � � � � Konstel. � � � � � � � � � � */ 1160*cdf0e10cSrcweir /* � � � � � � � � � � � � � � � � � � � � jedoch � � � � � � � � � � */ 1161*cdf0e10cSrcweir /* � � � � � � � � � � � � � � � � � � � � nur zum � � � � � � � � � � */ 1162*cdf0e10cSrcweir /* � � � � � � � � � � � � � � � � � � � � Teil: � � � � � � � � � � */ 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir // Fall 3.2 1165*cdf0e10cSrcweir Rectangle aTmpR1(aBewareRect1); 1166*cdf0e10cSrcweir Rectangle aTmpR2(aBewareRect2); 1167*cdf0e10cSrcweir if (bBewareOverlap) { 1168*cdf0e10cSrcweir // Ueberschneidung der BewareRects: BoundRects fuer Check auf Fall 3.2 verwenden. 1169*cdf0e10cSrcweir aTmpR1=aBoundRect1; 1170*cdf0e10cSrcweir aTmpR2=aBoundRect2; 1171*cdf0e10cSrcweir } 1172*cdf0e10cSrcweir if ((((bRts1 && aTmpR1.Right ()<=aPt2.X()) || (bLks1 && aTmpR1.Left()>=aPt2.X())) && 1173*cdf0e10cSrcweir ((bUnt2 && aTmpR2.Bottom()<=aPt1.Y()) || (bObn2 && aTmpR2.Top ()>=aPt1.Y()))) || 1174*cdf0e10cSrcweir (((bRts2 && aTmpR2.Right ()<=aPt1.X()) || (bLks2 && aTmpR2.Left()>=aPt1.X())) && 1175*cdf0e10cSrcweir ((bUnt1 && aTmpR1.Bottom()<=aPt2.Y()) || (bObn1 && aTmpR1.Top ()>=aPt2.Y())))) { 1176*cdf0e10cSrcweir // Fall 3.2 trifft zu: Verbindung mit lediglich 2 Linien 1177*cdf0e10cSrcweir bForceMeeting=sal_True; 1178*cdf0e10cSrcweir bMeetingXMid=sal_False; 1179*cdf0e10cSrcweir bMeetingYMid=sal_False; 1180*cdf0e10cSrcweir if (bHor1) { 1181*cdf0e10cSrcweir aMeeting.X()=aPt2.X(); 1182*cdf0e10cSrcweir aMeeting.Y()=aPt1.Y(); 1183*cdf0e10cSrcweir } else { 1184*cdf0e10cSrcweir aMeeting.X()=aPt1.X(); 1185*cdf0e10cSrcweir aMeeting.Y()=aPt2.Y(); 1186*cdf0e10cSrcweir } 1187*cdf0e10cSrcweir // Falls Ueberschneidung der BewareRects: 1188*cdf0e10cSrcweir aBewareRect1=aTmpR1; 1189*cdf0e10cSrcweir aBewareRect2=aTmpR2; 1190*cdf0e10cSrcweir } else if ((((bRts1 && aBewareRect1.Right ()>aBewareRect2.Left ()) || 1191*cdf0e10cSrcweir (bLks1 && aBewareRect1.Left ()<aBewareRect2.Right ())) && 1192*cdf0e10cSrcweir ((bUnt2 && aBewareRect2.Bottom()>aBewareRect1.Top ()) || 1193*cdf0e10cSrcweir (bObn2 && aBewareRect2.Top ()<aBewareRect1.Bottom()))) || 1194*cdf0e10cSrcweir (((bRts2 && aBewareRect2.Right ()>aBewareRect1.Left ()) || 1195*cdf0e10cSrcweir (bLks2 && aBewareRect2.Left ()<aBewareRect1.Right ())) && 1196*cdf0e10cSrcweir ((bUnt1 && aBewareRect1.Bottom()>aBewareRect2.Top ()) || 1197*cdf0e10cSrcweir (bObn1 && aBewareRect1.Top ()<aBewareRect2.Bottom())))) { 1198*cdf0e10cSrcweir // Fall 3.3 1199*cdf0e10cSrcweir bForceMeeting=sal_True; 1200*cdf0e10cSrcweir if (bRts1 || bRts2) { aMeeting.X()=nXMax; bMeetingXMid=sal_False; } 1201*cdf0e10cSrcweir if (bLks1 || bLks2) { aMeeting.X()=nXMin; bMeetingXMid=sal_False; } 1202*cdf0e10cSrcweir if (bUnt1 || bUnt2) { aMeeting.Y()=nYMax; bMeetingYMid=sal_False; } 1203*cdf0e10cSrcweir if (bObn1 || bObn2) { aMeeting.Y()=nYMin; bMeetingYMid=sal_False; } 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir } 1207*cdf0e10cSrcweir 1208*cdf0e10cSrcweir XPolygon aXP1(ImpCalcObjToCenter(aPt1,nAngle1,aBewareRect1,aMeeting)); 1209*cdf0e10cSrcweir XPolygon aXP2(ImpCalcObjToCenter(aPt2,nAngle2,aBewareRect2,aMeeting)); 1210*cdf0e10cSrcweir sal_uInt16 nXP1Anz=aXP1.GetPointCount(); 1211*cdf0e10cSrcweir sal_uInt16 nXP2Anz=aXP2.GetPointCount(); 1212*cdf0e10cSrcweir if (bInfo) { 1213*cdf0e10cSrcweir pInfo->nObj1Lines=nXP1Anz; if (nXP1Anz>1) pInfo->nObj1Lines--; 1214*cdf0e10cSrcweir pInfo->nObj2Lines=nXP2Anz; if (nXP2Anz>1) pInfo->nObj2Lines--; 1215*cdf0e10cSrcweir } 1216*cdf0e10cSrcweir Point aEP1(aXP1[nXP1Anz-1]); 1217*cdf0e10cSrcweir Point aEP2(aXP2[nXP2Anz-1]); 1218*cdf0e10cSrcweir FASTBOOL bInsMeetingPoint=aEP1.X()!=aEP2.X() && aEP1.Y()!=aEP2.Y(); 1219*cdf0e10cSrcweir FASTBOOL bHorzE1=aEP1.Y()==aXP1[nXP1Anz-2].Y(); // letzte Linie von XP1 horizontal? 1220*cdf0e10cSrcweir FASTBOOL bHorzE2=aEP2.Y()==aXP2[nXP2Anz-2].Y(); // letzte Linie von XP2 horizontal? 1221*cdf0e10cSrcweir if (aEP1==aEP2 && (bHorzE1 && bHorzE2 && aEP1.Y()==aEP2.Y()) || (!bHorzE1 && !bHorzE2 && aEP1.X()==aEP2.X())) { 1222*cdf0e10cSrcweir // Sonderbehandlung fuer 'I'-Verbinder 1223*cdf0e10cSrcweir nXP1Anz--; aXP1.Remove(nXP1Anz,1); 1224*cdf0e10cSrcweir nXP2Anz--; aXP2.Remove(nXP2Anz,1); 1225*cdf0e10cSrcweir bMeetingXMid=sal_False; 1226*cdf0e10cSrcweir bMeetingYMid=sal_False; 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir if (bInsMeetingPoint) { 1229*cdf0e10cSrcweir aXP1.Insert(XPOLY_APPEND,aMeeting,XPOLY_NORMAL); 1230*cdf0e10cSrcweir if (bInfo) { 1231*cdf0e10cSrcweir // Durch einfuegen des MeetingPoints kommen 2 weitere Linie hinzu. 1232*cdf0e10cSrcweir // Evtl. wird eine von diesen die Mittellinie. 1233*cdf0e10cSrcweir if (pInfo->nObj1Lines==pInfo->nObj2Lines) { 1234*cdf0e10cSrcweir pInfo->nObj1Lines++; 1235*cdf0e10cSrcweir pInfo->nObj2Lines++; 1236*cdf0e10cSrcweir } else { 1237*cdf0e10cSrcweir if (pInfo->nObj1Lines>pInfo->nObj2Lines) { 1238*cdf0e10cSrcweir pInfo->nObj2Lines++; 1239*cdf0e10cSrcweir pInfo->nMiddleLine=nXP1Anz-1; 1240*cdf0e10cSrcweir } else { 1241*cdf0e10cSrcweir pInfo->nObj1Lines++; 1242*cdf0e10cSrcweir pInfo->nMiddleLine=nXP1Anz; 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir } 1245*cdf0e10cSrcweir } 1246*cdf0e10cSrcweir } else if (bInfo && aEP1!=aEP2 && nXP1Anz+nXP2Anz>=4) { 1247*cdf0e10cSrcweir // Durch Verbinden der beiden Enden kommt eine weitere Linie hinzu. 1248*cdf0e10cSrcweir // Dies wird die Mittellinie. 1249*cdf0e10cSrcweir pInfo->nMiddleLine=nXP1Anz-1; 1250*cdf0e10cSrcweir } 1251*cdf0e10cSrcweir sal_uInt16 nNum=aXP2.GetPointCount(); 1252*cdf0e10cSrcweir if (aXP1[nXP1Anz-1]==aXP2[nXP2Anz-1] && nXP1Anz>1 && nXP2Anz>1) nNum--; 1253*cdf0e10cSrcweir while (nNum>0) { 1254*cdf0e10cSrcweir nNum--; 1255*cdf0e10cSrcweir aXP1.Insert(XPOLY_APPEND,aXP2[nNum],XPOLY_NORMAL); 1256*cdf0e10cSrcweir } 1257*cdf0e10cSrcweir sal_uInt16 nPntAnz=aXP1.GetPointCount(); 1258*cdf0e10cSrcweir char cForm=0; 1259*cdf0e10cSrcweir if (bInfo || pnQuality!=NULL) { 1260*cdf0e10cSrcweir cForm='?'; 1261*cdf0e10cSrcweir if (nPntAnz==2) cForm='I'; 1262*cdf0e10cSrcweir else if (nPntAnz==3) cForm='L'; 1263*cdf0e10cSrcweir else if (nPntAnz==4) { // Z oder U 1264*cdf0e10cSrcweir if (nAngle1==nAngle2) cForm='U'; 1265*cdf0e10cSrcweir else cForm='Z'; 1266*cdf0e10cSrcweir } else if (nPntAnz==4) { /* �-� �-� */ 1267*cdf0e10cSrcweir /* ... -� -� */ 1268*cdf0e10cSrcweir } else if (nPntAnz==6) { // S oder C oder ... 1269*cdf0e10cSrcweir if (nAngle1!=nAngle2) { 1270*cdf0e10cSrcweir // Fuer Typ S hat Linie2 dieselbe Richtung wie Linie4. 1271*cdf0e10cSrcweir // Bei Typ C sind die beiden genau entgegengesetzt. 1272*cdf0e10cSrcweir Point aP1(aXP1[1]); 1273*cdf0e10cSrcweir Point aP2(aXP1[2]); 1274*cdf0e10cSrcweir Point aP3(aXP1[3]); 1275*cdf0e10cSrcweir Point aP4(aXP1[4]); 1276*cdf0e10cSrcweir if (aP1.Y()==aP2.Y()) { // beide Linien Horz 1277*cdf0e10cSrcweir if ((aP1.X()<aP2.X())==(aP3.X()<aP4.X())) cForm='S'; 1278*cdf0e10cSrcweir else cForm='C'; 1279*cdf0e10cSrcweir } else { // sonst beide Linien Vert 1280*cdf0e10cSrcweir if ((aP1.Y()<aP2.Y())==(aP3.Y()<aP4.Y())) cForm='S'; 1281*cdf0e10cSrcweir else cForm='C'; 1282*cdf0e10cSrcweir } 1283*cdf0e10cSrcweir } else cForm='4'; // sonst der 3. Fall mit 5 Linien 1284*cdf0e10cSrcweir } else cForm='?'; // 1285*cdf0e10cSrcweir // Weitere Formen: 1286*cdf0e10cSrcweir if (bInfo) { 1287*cdf0e10cSrcweir pInfo->cOrthoForm=cForm; 1288*cdf0e10cSrcweir if (cForm=='I' || cForm=='L' || cForm=='Z' || cForm=='U') { 1289*cdf0e10cSrcweir pInfo->nObj1Lines=1; 1290*cdf0e10cSrcweir pInfo->nObj2Lines=1; 1291*cdf0e10cSrcweir if (cForm=='Z' || cForm=='U') { 1292*cdf0e10cSrcweir pInfo->nMiddleLine=1; 1293*cdf0e10cSrcweir } else { 1294*cdf0e10cSrcweir pInfo->nMiddleLine=0xFFFF; 1295*cdf0e10cSrcweir } 1296*cdf0e10cSrcweir } else if (cForm=='S' || cForm=='C') { 1297*cdf0e10cSrcweir pInfo->nObj1Lines=2; 1298*cdf0e10cSrcweir pInfo->nObj2Lines=2; 1299*cdf0e10cSrcweir pInfo->nMiddleLine=2; 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir } 1303*cdf0e10cSrcweir if (pnQuality!=NULL) { 1304*cdf0e10cSrcweir sal_uIntPtr nQual=0; 1305*cdf0e10cSrcweir sal_uIntPtr nQual0=nQual; // Ueberlaeufe vorbeugen 1306*cdf0e10cSrcweir FASTBOOL bOverflow=sal_False; 1307*cdf0e10cSrcweir Point aPt0(aXP1[0]); 1308*cdf0e10cSrcweir for (sal_uInt16 nPntNum=1; nPntNum<nPntAnz; nPntNum++) { 1309*cdf0e10cSrcweir Point aPt1b(aXP1[nPntNum]); 1310*cdf0e10cSrcweir nQual+=Abs(aPt1b.X()-aPt0.X())+Abs(aPt1b.Y()-aPt0.Y()); 1311*cdf0e10cSrcweir if (nQual<nQual0) bOverflow=sal_True; 1312*cdf0e10cSrcweir nQual0=nQual; 1313*cdf0e10cSrcweir aPt0=aPt1b; 1314*cdf0e10cSrcweir } 1315*cdf0e10cSrcweir 1316*cdf0e10cSrcweir sal_uInt16 nTmp=nPntAnz; 1317*cdf0e10cSrcweir if (cForm=='Z') { 1318*cdf0e10cSrcweir nTmp=2; // Z-Form hat gute Qualitaet (nTmp=2 statt 4) 1319*cdf0e10cSrcweir sal_uIntPtr n1=Abs(aXP1[1].X()-aXP1[0].X())+Abs(aXP1[1].Y()-aXP1[0].Y()); 1320*cdf0e10cSrcweir sal_uIntPtr n2=Abs(aXP1[2].X()-aXP1[1].X())+Abs(aXP1[2].Y()-aXP1[1].Y()); 1321*cdf0e10cSrcweir sal_uIntPtr n3=Abs(aXP1[3].X()-aXP1[2].X())+Abs(aXP1[3].Y()-aXP1[2].Y()); 1322*cdf0e10cSrcweir // fuer moeglichst gleichlange Linien sorgen 1323*cdf0e10cSrcweir sal_uIntPtr nBesser=0; 1324*cdf0e10cSrcweir n1+=n3; 1325*cdf0e10cSrcweir n3=n2/4; 1326*cdf0e10cSrcweir if (n1>=n2) nBesser=6; 1327*cdf0e10cSrcweir else if (n1>=3*n3) nBesser=4; 1328*cdf0e10cSrcweir else if (n1>=2*n3) nBesser=2; 1329*cdf0e10cSrcweir if (aXP1[0].Y()!=aXP1[1].Y()) nBesser++; // Senkrechte Startlinie kriegt auch noch einen Pluspunkt (fuer H/V-Prio) 1330*cdf0e10cSrcweir if (nQual>nBesser) nQual-=nBesser; else nQual=0; 1331*cdf0e10cSrcweir } 1332*cdf0e10cSrcweir if (nTmp>=3) { 1333*cdf0e10cSrcweir nQual0=nQual; 1334*cdf0e10cSrcweir nQual+=(sal_uIntPtr)nTmp*0x01000000; 1335*cdf0e10cSrcweir if (nQual<nQual0 || nTmp>15) bOverflow=sal_True; 1336*cdf0e10cSrcweir } 1337*cdf0e10cSrcweir if (nPntAnz>=2) { // Austrittswinkel nochmal pruefen 1338*cdf0e10cSrcweir Point aP1(aXP1[1]); aP1-=aXP1[0]; 1339*cdf0e10cSrcweir Point aP2(aXP1[nPntAnz-2]); aP2-=aXP1[nPntAnz-1]; 1340*cdf0e10cSrcweir long nAng1=0; if (aP1.X()<0) nAng1=18000; if (aP1.Y()>0) nAng1=27000; 1341*cdf0e10cSrcweir if (aP1.Y()<0) nAng1=9000; if (aP1.X()!=0 && aP1.Y()!=0) nAng1=1; // Schraeg!?! 1342*cdf0e10cSrcweir long nAng2=0; if (aP2.X()<0) nAng2=18000; if (aP2.Y()>0) nAng2=27000; 1343*cdf0e10cSrcweir if (aP2.Y()<0) nAng2=9000; if (aP2.X()!=0 && aP2.Y()!=0) nAng2=1; // Schraeg!?! 1344*cdf0e10cSrcweir if (nAng1!=nAngle1) nIntersections++; 1345*cdf0e10cSrcweir if (nAng2!=nAngle2) nIntersections++; 1346*cdf0e10cSrcweir } 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir // Fuer den Qualitaetscheck wieder die Original-Rects verwenden und 1349*cdf0e10cSrcweir // gleichzeitig checken, ob eins fuer die Edge-Berechnung verkleinert 1350*cdf0e10cSrcweir // wurde (z.B. Fall 2.9) 1351*cdf0e10cSrcweir aBewareRect1=rBewareRect1; 1352*cdf0e10cSrcweir aBewareRect2=rBewareRect2; 1353*cdf0e10cSrcweir 1354*cdf0e10cSrcweir for (sal_uInt16 i=0; i<nPntAnz; i++) { 1355*cdf0e10cSrcweir Point aPt1b(aXP1[i]); 1356*cdf0e10cSrcweir FASTBOOL b1=aPt1b.X()>aBewareRect1.Left() && aPt1b.X()<aBewareRect1.Right() && 1357*cdf0e10cSrcweir aPt1b.Y()>aBewareRect1.Top() && aPt1b.Y()<aBewareRect1.Bottom(); 1358*cdf0e10cSrcweir FASTBOOL b2=aPt1b.X()>aBewareRect2.Left() && aPt1b.X()<aBewareRect2.Right() && 1359*cdf0e10cSrcweir aPt1b.Y()>aBewareRect2.Top() && aPt1b.Y()<aBewareRect2.Bottom(); 1360*cdf0e10cSrcweir sal_uInt16 nInt0=nIntersections; 1361*cdf0e10cSrcweir if (i==0 || i==nPntAnz-1) { 1362*cdf0e10cSrcweir if (b1 && b2) nIntersections++; 1363*cdf0e10cSrcweir } else { 1364*cdf0e10cSrcweir if (b1) nIntersections++; 1365*cdf0e10cSrcweir if (b2) nIntersections++; 1366*cdf0e10cSrcweir } 1367*cdf0e10cSrcweir // und nun noch auf Ueberschneidungen checken 1368*cdf0e10cSrcweir if (i>0 && nInt0==nIntersections) { 1369*cdf0e10cSrcweir if (aPt0.Y()==aPt1b.Y()) { // Horizontale Linie 1370*cdf0e10cSrcweir if (aPt0.Y()>aBewareRect1.Top() && aPt0.Y()<aBewareRect1.Bottom() && 1371*cdf0e10cSrcweir ((aPt0.X()<=aBewareRect1.Left() && aPt1b.X()>=aBewareRect1.Right()) || 1372*cdf0e10cSrcweir (aPt1b.X()<=aBewareRect1.Left() && aPt0.X()>=aBewareRect1.Right()))) nIntersections++; 1373*cdf0e10cSrcweir if (aPt0.Y()>aBewareRect2.Top() && aPt0.Y()<aBewareRect2.Bottom() && 1374*cdf0e10cSrcweir ((aPt0.X()<=aBewareRect2.Left() && aPt1b.X()>=aBewareRect2.Right()) || 1375*cdf0e10cSrcweir (aPt1b.X()<=aBewareRect2.Left() && aPt0.X()>=aBewareRect2.Right()))) nIntersections++; 1376*cdf0e10cSrcweir } else { // Vertikale Linie 1377*cdf0e10cSrcweir if (aPt0.X()>aBewareRect1.Left() && aPt0.X()<aBewareRect1.Right() && 1378*cdf0e10cSrcweir ((aPt0.Y()<=aBewareRect1.Top() && aPt1b.Y()>=aBewareRect1.Bottom()) || 1379*cdf0e10cSrcweir (aPt1b.Y()<=aBewareRect1.Top() && aPt0.Y()>=aBewareRect1.Bottom()))) nIntersections++; 1380*cdf0e10cSrcweir if (aPt0.X()>aBewareRect2.Left() && aPt0.X()<aBewareRect2.Right() && 1381*cdf0e10cSrcweir ((aPt0.Y()<=aBewareRect2.Top() && aPt1b.Y()>=aBewareRect2.Bottom()) || 1382*cdf0e10cSrcweir (aPt1b.Y()<=aBewareRect2.Top() && aPt0.Y()>=aBewareRect2.Bottom()))) nIntersections++; 1383*cdf0e10cSrcweir } 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir aPt0=aPt1b; 1386*cdf0e10cSrcweir } 1387*cdf0e10cSrcweir if (nPntAnz<=1) nIntersections++; 1388*cdf0e10cSrcweir nQual0=nQual; 1389*cdf0e10cSrcweir nQual+=(sal_uIntPtr)nIntersections*0x10000000; 1390*cdf0e10cSrcweir if (nQual<nQual0 || nIntersections>15) bOverflow=sal_True; 1391*cdf0e10cSrcweir 1392*cdf0e10cSrcweir if (bOverflow || nQual==0xFFFFFFFF) nQual=0xFFFFFFFE; 1393*cdf0e10cSrcweir *pnQuality=nQual; 1394*cdf0e10cSrcweir } 1395*cdf0e10cSrcweir if (bInfo) { // nun die Linienversaetze auf aXP1 anwenden 1396*cdf0e10cSrcweir if (pInfo->nMiddleLine!=0xFFFF) { 1397*cdf0e10cSrcweir sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(MIDDLELINE,aXP1); 1398*cdf0e10cSrcweir if (pInfo->ImpIsHorzLine(MIDDLELINE,aXP1)) { 1399*cdf0e10cSrcweir aXP1[nIdx].Y()+=pInfo->aMiddleLine.Y(); 1400*cdf0e10cSrcweir aXP1[nIdx+1].Y()+=pInfo->aMiddleLine.Y(); 1401*cdf0e10cSrcweir } else { 1402*cdf0e10cSrcweir aXP1[nIdx].X()+=pInfo->aMiddleLine.X(); 1403*cdf0e10cSrcweir aXP1[nIdx+1].X()+=pInfo->aMiddleLine.X(); 1404*cdf0e10cSrcweir } 1405*cdf0e10cSrcweir } 1406*cdf0e10cSrcweir if (pInfo->nObj1Lines>=2) { 1407*cdf0e10cSrcweir sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE2,aXP1); 1408*cdf0e10cSrcweir if (pInfo->ImpIsHorzLine(OBJ1LINE2,aXP1)) { 1409*cdf0e10cSrcweir aXP1[nIdx].Y()+=pInfo->aObj1Line2.Y(); 1410*cdf0e10cSrcweir aXP1[nIdx+1].Y()+=pInfo->aObj1Line2.Y(); 1411*cdf0e10cSrcweir } else { 1412*cdf0e10cSrcweir aXP1[nIdx].X()+=pInfo->aObj1Line2.X(); 1413*cdf0e10cSrcweir aXP1[nIdx+1].X()+=pInfo->aObj1Line2.X(); 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir } 1416*cdf0e10cSrcweir if (pInfo->nObj1Lines>=3) { 1417*cdf0e10cSrcweir sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE3,aXP1); 1418*cdf0e10cSrcweir if (pInfo->ImpIsHorzLine(OBJ1LINE3,aXP1)) { 1419*cdf0e10cSrcweir aXP1[nIdx].Y()+=pInfo->aObj1Line3.Y(); 1420*cdf0e10cSrcweir aXP1[nIdx+1].Y()+=pInfo->aObj1Line3.Y(); 1421*cdf0e10cSrcweir } else { 1422*cdf0e10cSrcweir aXP1[nIdx].X()+=pInfo->aObj1Line3.X(); 1423*cdf0e10cSrcweir aXP1[nIdx+1].X()+=pInfo->aObj1Line3.X(); 1424*cdf0e10cSrcweir } 1425*cdf0e10cSrcweir } 1426*cdf0e10cSrcweir if (pInfo->nObj2Lines>=2) { 1427*cdf0e10cSrcweir sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE2,aXP1); 1428*cdf0e10cSrcweir if (pInfo->ImpIsHorzLine(OBJ2LINE2,aXP1)) { 1429*cdf0e10cSrcweir aXP1[nIdx].Y()+=pInfo->aObj2Line2.Y(); 1430*cdf0e10cSrcweir aXP1[nIdx+1].Y()+=pInfo->aObj2Line2.Y(); 1431*cdf0e10cSrcweir } else { 1432*cdf0e10cSrcweir aXP1[nIdx].X()+=pInfo->aObj2Line2.X(); 1433*cdf0e10cSrcweir aXP1[nIdx+1].X()+=pInfo->aObj2Line2.X(); 1434*cdf0e10cSrcweir } 1435*cdf0e10cSrcweir } 1436*cdf0e10cSrcweir if (pInfo->nObj2Lines>=3) { 1437*cdf0e10cSrcweir sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE3,aXP1); 1438*cdf0e10cSrcweir if (pInfo->ImpIsHorzLine(OBJ2LINE3,aXP1)) { 1439*cdf0e10cSrcweir aXP1[nIdx].Y()+=pInfo->aObj2Line3.Y(); 1440*cdf0e10cSrcweir aXP1[nIdx+1].Y()+=pInfo->aObj2Line3.Y(); 1441*cdf0e10cSrcweir } else { 1442*cdf0e10cSrcweir aXP1[nIdx].X()+=pInfo->aObj2Line3.X(); 1443*cdf0e10cSrcweir aXP1[nIdx+1].X()+=pInfo->aObj2Line3.X(); 1444*cdf0e10cSrcweir } 1445*cdf0e10cSrcweir } 1446*cdf0e10cSrcweir } 1447*cdf0e10cSrcweir // Nun mache ich ggf. aus dem Verbinder eine Bezierkurve 1448*cdf0e10cSrcweir if (eKind==SDREDGE_BEZIER && nPntAnz>2) { 1449*cdf0e10cSrcweir Point* pPt1=&aXP1[0]; 1450*cdf0e10cSrcweir Point* pPt2=&aXP1[1]; 1451*cdf0e10cSrcweir Point* pPt3=&aXP1[nPntAnz-2]; 1452*cdf0e10cSrcweir Point* pPt4=&aXP1[nPntAnz-1]; 1453*cdf0e10cSrcweir long dx1=pPt2->X()-pPt1->X(); 1454*cdf0e10cSrcweir long dy1=pPt2->Y()-pPt1->Y(); 1455*cdf0e10cSrcweir long dx2=pPt3->X()-pPt4->X(); 1456*cdf0e10cSrcweir long dy2=pPt3->Y()-pPt4->Y(); 1457*cdf0e10cSrcweir if (cForm=='L') { // nPntAnz==3 1458*cdf0e10cSrcweir aXP1.SetFlags(1,XPOLY_CONTROL); 1459*cdf0e10cSrcweir Point aPt3(*pPt2); 1460*cdf0e10cSrcweir aXP1.Insert(2,aPt3,XPOLY_CONTROL); 1461*cdf0e10cSrcweir nPntAnz=aXP1.GetPointCount(); 1462*cdf0e10cSrcweir pPt1=&aXP1[0]; 1463*cdf0e10cSrcweir pPt2=&aXP1[1]; 1464*cdf0e10cSrcweir pPt3=&aXP1[nPntAnz-2]; 1465*cdf0e10cSrcweir pPt4=&aXP1[nPntAnz-1]; 1466*cdf0e10cSrcweir pPt2->X()-=dx1/3; 1467*cdf0e10cSrcweir pPt2->Y()-=dy1/3; 1468*cdf0e10cSrcweir pPt3->X()-=dx2/3; 1469*cdf0e10cSrcweir pPt3->Y()-=dy2/3; 1470*cdf0e10cSrcweir } else if (nPntAnz>=4 && nPntAnz<=6) { // Z oder U oder ... 1471*cdf0e10cSrcweir // fuer Alle Anderen werden die Endpunkte der Ausgangslinien 1472*cdf0e10cSrcweir // erstmal zu Kontrollpunkten. Bei nPntAnz>4 ist also noch 1473*cdf0e10cSrcweir // Nacharbeit erforderlich! 1474*cdf0e10cSrcweir aXP1.SetFlags(1,XPOLY_CONTROL); 1475*cdf0e10cSrcweir aXP1.SetFlags(nPntAnz-2,XPOLY_CONTROL); 1476*cdf0e10cSrcweir // Distanz x1.5 1477*cdf0e10cSrcweir pPt2->X()+=dx1/2; 1478*cdf0e10cSrcweir pPt2->Y()+=dy1/2; 1479*cdf0e10cSrcweir pPt3->X()+=dx2/2; 1480*cdf0e10cSrcweir pPt3->Y()+=dy2/2; 1481*cdf0e10cSrcweir if (nPntAnz==5) { 1482*cdf0e10cSrcweir // Vor und hinter dem Mittelpunkt jeweils 1483*cdf0e10cSrcweir // noch einen Kontrollpunkt einfuegen 1484*cdf0e10cSrcweir Point aCenter(aXP1[2]); 1485*cdf0e10cSrcweir long dx1b=aCenter.X()-aXP1[1].X(); 1486*cdf0e10cSrcweir long dy1b=aCenter.Y()-aXP1[1].Y(); 1487*cdf0e10cSrcweir long dx2b=aCenter.X()-aXP1[3].X(); 1488*cdf0e10cSrcweir long dy2b=aCenter.Y()-aXP1[3].Y(); 1489*cdf0e10cSrcweir aXP1.Insert(2,aCenter,XPOLY_CONTROL); 1490*cdf0e10cSrcweir aXP1.SetFlags(3,XPOLY_SYMMTR); 1491*cdf0e10cSrcweir aXP1.Insert(4,aCenter,XPOLY_CONTROL); 1492*cdf0e10cSrcweir aXP1[2].X()-=dx1b/2; 1493*cdf0e10cSrcweir aXP1[2].Y()-=dy1b/2; 1494*cdf0e10cSrcweir aXP1[3].X()-=(dx1b+dx2b)/4; 1495*cdf0e10cSrcweir aXP1[3].Y()-=(dy1b+dy2b)/4; 1496*cdf0e10cSrcweir aXP1[4].X()-=dx2b/2; 1497*cdf0e10cSrcweir aXP1[4].Y()-=dy2b/2; 1498*cdf0e10cSrcweir } 1499*cdf0e10cSrcweir if (nPntAnz==6) { 1500*cdf0e10cSrcweir Point aPt1b(aXP1[2]); 1501*cdf0e10cSrcweir Point aPt2b(aXP1[3]); 1502*cdf0e10cSrcweir aXP1.Insert(2,aPt1b,XPOLY_CONTROL); 1503*cdf0e10cSrcweir aXP1.Insert(5,aPt2b,XPOLY_CONTROL); 1504*cdf0e10cSrcweir long dx=aPt1b.X()-aPt2b.X(); 1505*cdf0e10cSrcweir long dy=aPt1b.Y()-aPt2b.Y(); 1506*cdf0e10cSrcweir aXP1[3].X()-=dx/2; 1507*cdf0e10cSrcweir aXP1[3].Y()-=dy/2; 1508*cdf0e10cSrcweir aXP1.SetFlags(3,XPOLY_SYMMTR); 1509*cdf0e10cSrcweir //aXP1[4].X()+=dx/2; 1510*cdf0e10cSrcweir //aXP1[4].Y()+=dy/2; 1511*cdf0e10cSrcweir aXP1.Remove(4,1); // weil identisch mit aXP1[3] 1512*cdf0e10cSrcweir } 1513*cdf0e10cSrcweir } 1514*cdf0e10cSrcweir } 1515*cdf0e10cSrcweir return aXP1; 1516*cdf0e10cSrcweir } 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir /* 1519*cdf0e10cSrcweir Nach einer einfachen Rechnung koennte es max. 64 unterschiedliche Verlaeufe mit 1520*cdf0e10cSrcweir 5 Linien, 32 mit 4 Linien, 16 mit 3, 8 mit 2 Linien und 4 mit 1 Linie geben=124. 1521*cdf0e10cSrcweir Normalisiert auf 1. Austrittswinkel nach rechts bleiben dann noch 31. 1522*cdf0e10cSrcweir Dann noch eine vertikale Spiegelung wegnormalisiert bleiben noch 16 1523*cdf0e10cSrcweir characteristische Verlaufszuege mit 1-5 Linien: 1524*cdf0e10cSrcweir Mit 1 Linie (Typ 'I'): -- 1525*cdf0e10cSrcweir Mit 2 Linien (Typ 'L'): -� 1526*cdf0e10cSrcweir Mit 3 Linien (Typ 'U'): -� (Typ 'Z'): �- 1527*cdf0e10cSrcweir -� -� 1528*cdf0e10cSrcweir Mit 4 Linien: 1 ist nicht plausibel, 3 ist=2 (90deg Drehung). Verbleibt 2,4 1529*cdf0e10cSrcweir �-� ڿ �� ڿ ڿ �-� 1530*cdf0e10cSrcweir -� -� -� -� -� -� 1531*cdf0e10cSrcweir Mit 5 Linien: nicht plausibel sind 1,2,4,5. 7 ist identisch mit 3 (Richtungsumkehr) 1532*cdf0e10cSrcweir Bleibt also 3,6 und 8. '4' 'S' 'C' 1533*cdf0e10cSrcweir � � -� �- �-� �- 1534*cdf0e10cSrcweir �-� �-� �-� �-� �� �� -� � �-� �-� �� �-� 1535*cdf0e10cSrcweir -� -� -� � -� �- -� -� --� � � -� � -� � � 1536*cdf0e10cSrcweir Insgesamt sind also 9 Grundtypen zu unterscheiden die den 400 Konstellationen 1537*cdf0e10cSrcweir aus Objektposition und Austrittswinkeln zuzuordnen sind. 1538*cdf0e10cSrcweir 4 der 9 Grundtypen haben eine 'Mittellinie'. Die Anzahl der zu Objektabstaende 1539*cdf0e10cSrcweir je Objekt variiert von 0-3: 1540*cdf0e10cSrcweir Mi O1 O2 Anmerkung 1541*cdf0e10cSrcweir 'I': n 0 0 1542*cdf0e10cSrcweir 'L': n 0 0 1543*cdf0e10cSrcweir 'U': n 0-1 0-1 1544*cdf0e10cSrcweir 'Z': j 0 0 1545*cdf0e10cSrcweir 4.1: j 0 1 = U+1 bzw. 1+U 1546*cdf0e10cSrcweir 4.2: n 0-2 0-2 = Z+1 1547*cdf0e10cSrcweir '4': j 0 2 = Z+2 1548*cdf0e10cSrcweir 'S': j 1 1 = 1+Z+1 1549*cdf0e10cSrcweir 'C': n 0-3 0-3 = 1+U+1 1550*cdf0e10cSrcweir */ 1551*cdf0e10cSrcweir 1552*cdf0e10cSrcweir void __EXPORT SdrEdgeObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 1553*cdf0e10cSrcweir { 1554*cdf0e10cSrcweir SfxSimpleHint* pSimple=PTR_CAST(SfxSimpleHint,&rHint); 1555*cdf0e10cSrcweir sal_uIntPtr nId=pSimple==0 ? 0 : pSimple->GetId(); 1556*cdf0e10cSrcweir FASTBOOL bDataChg=nId==SFX_HINT_DATACHANGED; 1557*cdf0e10cSrcweir FASTBOOL bDying=nId==SFX_HINT_DYING; 1558*cdf0e10cSrcweir FASTBOOL bObj1=aCon1.pObj!=NULL && aCon1.pObj->GetBroadcaster()==&rBC; 1559*cdf0e10cSrcweir FASTBOOL bObj2=aCon2.pObj!=NULL && aCon2.pObj->GetBroadcaster()==&rBC; 1560*cdf0e10cSrcweir if (bDying && (bObj1 || bObj2)) { 1561*cdf0e10cSrcweir // #35605# Dying vorher abfangen, damit AttrObj nicht 1562*cdf0e10cSrcweir // wg. vermeintlicher Vorlagenaenderung rumbroadcastet 1563*cdf0e10cSrcweir if (bObj1) aCon1.pObj=NULL; 1564*cdf0e10cSrcweir if (bObj2) aCon2.pObj=NULL; 1565*cdf0e10cSrcweir return; // Und mehr braucht hier nicht getan werden. 1566*cdf0e10cSrcweir } 1567*cdf0e10cSrcweir if ( bObj1 || bObj2 ) 1568*cdf0e10cSrcweir { 1569*cdf0e10cSrcweir bEdgeTrackUserDefined = sal_False; 1570*cdf0e10cSrcweir } 1571*cdf0e10cSrcweir SdrTextObj::Notify(rBC,rHint); 1572*cdf0e10cSrcweir if (nNotifyingCount==0) { // Hier nun auch ein VerriegelungsFlag 1573*cdf0e10cSrcweir ((SdrEdgeObj*)this)->nNotifyingCount++; 1574*cdf0e10cSrcweir SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint); 1575*cdf0e10cSrcweir if (bDataChg) { // StyleSheet geaendert 1576*cdf0e10cSrcweir ImpSetAttrToEdgeInfo(); // Werte bei Vorlagenaenderung vom Pool nach aEdgeInfo kopieren 1577*cdf0e10cSrcweir } 1578*cdf0e10cSrcweir if (bDataChg || 1579*cdf0e10cSrcweir (bObj1 && aCon1.pObj->GetPage()==pPage) || 1580*cdf0e10cSrcweir (bObj2 && aCon2.pObj->GetPage()==pPage) || 1581*cdf0e10cSrcweir (pSdrHint && pSdrHint->GetKind()==HINT_OBJREMOVED)) 1582*cdf0e10cSrcweir { 1583*cdf0e10cSrcweir // Broadcasting nur, wenn auf der selben Page 1584*cdf0e10cSrcweir Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); 1585*cdf0e10cSrcweir // #110094#-14 if (!bEdgeTrackDirty) SendRepaintBroadcast(); 1586*cdf0e10cSrcweir ImpDirtyEdgeTrack(); 1587*cdf0e10cSrcweir 1588*cdf0e10cSrcweir // only redraw here, no objectchange 1589*cdf0e10cSrcweir ActionChanged(); 1590*cdf0e10cSrcweir // BroadcastObjectChange(); 1591*cdf0e10cSrcweir 1592*cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 1593*cdf0e10cSrcweir } 1594*cdf0e10cSrcweir ((SdrEdgeObj*)this)->nNotifyingCount--; 1595*cdf0e10cSrcweir } 1596*cdf0e10cSrcweir } 1597*cdf0e10cSrcweir 1598*cdf0e10cSrcweir /** updates edges that are connected to the edges of this object 1599*cdf0e10cSrcweir as if the connected objects send a repaint broadcast 1600*cdf0e10cSrcweir #103122# 1601*cdf0e10cSrcweir */ 1602*cdf0e10cSrcweir void SdrEdgeObj::Reformat() 1603*cdf0e10cSrcweir { 1604*cdf0e10cSrcweir if( NULL != aCon1.pObj ) 1605*cdf0e10cSrcweir { 1606*cdf0e10cSrcweir SfxSimpleHint aHint( SFX_HINT_DATACHANGED ); 1607*cdf0e10cSrcweir Notify( *const_cast<SfxBroadcaster*>(aCon1.pObj->GetBroadcaster()), aHint ); 1608*cdf0e10cSrcweir } 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir if( NULL != aCon2.pObj ) 1611*cdf0e10cSrcweir { 1612*cdf0e10cSrcweir SfxSimpleHint aHint( SFX_HINT_DATACHANGED ); 1613*cdf0e10cSrcweir Notify( *const_cast<SfxBroadcaster*>(aCon2.pObj->GetBroadcaster()), aHint ); 1614*cdf0e10cSrcweir } 1615*cdf0e10cSrcweir } 1616*cdf0e10cSrcweir 1617*cdf0e10cSrcweir void SdrEdgeObj::operator=(const SdrObject& rObj) 1618*cdf0e10cSrcweir { 1619*cdf0e10cSrcweir SdrTextObj::operator=(rObj); 1620*cdf0e10cSrcweir *pEdgeTrack =*((SdrEdgeObj&)rObj).pEdgeTrack; 1621*cdf0e10cSrcweir bEdgeTrackDirty=((SdrEdgeObj&)rObj).bEdgeTrackDirty; 1622*cdf0e10cSrcweir aCon1 =((SdrEdgeObj&)rObj).aCon1; 1623*cdf0e10cSrcweir aCon2 =((SdrEdgeObj&)rObj).aCon2; 1624*cdf0e10cSrcweir aCon1.pObj=NULL; 1625*cdf0e10cSrcweir aCon2.pObj=NULL; 1626*cdf0e10cSrcweir aEdgeInfo=((SdrEdgeObj&)rObj).aEdgeInfo; 1627*cdf0e10cSrcweir } 1628*cdf0e10cSrcweir 1629*cdf0e10cSrcweir void SdrEdgeObj::TakeObjNameSingul(XubString& rName) const 1630*cdf0e10cSrcweir { 1631*cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNameSingulEDGE); 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir String aName( GetName() ); 1634*cdf0e10cSrcweir if(aName.Len()) 1635*cdf0e10cSrcweir { 1636*cdf0e10cSrcweir rName += sal_Unicode(' '); 1637*cdf0e10cSrcweir rName += sal_Unicode('\''); 1638*cdf0e10cSrcweir rName += aName; 1639*cdf0e10cSrcweir rName += sal_Unicode('\''); 1640*cdf0e10cSrcweir } 1641*cdf0e10cSrcweir } 1642*cdf0e10cSrcweir 1643*cdf0e10cSrcweir void SdrEdgeObj::TakeObjNamePlural(XubString& rName) const 1644*cdf0e10cSrcweir { 1645*cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNamePluralEDGE); 1646*cdf0e10cSrcweir } 1647*cdf0e10cSrcweir 1648*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrEdgeObj::TakeXorPoly() const 1649*cdf0e10cSrcweir { 1650*cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPolygon; 1651*cdf0e10cSrcweir 1652*cdf0e10cSrcweir if (bEdgeTrackDirty) 1653*cdf0e10cSrcweir { 1654*cdf0e10cSrcweir ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack(); 1655*cdf0e10cSrcweir } 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir if(pEdgeTrack) 1658*cdf0e10cSrcweir { 1659*cdf0e10cSrcweir aPolyPolygon.append(pEdgeTrack->getB2DPolygon()); 1660*cdf0e10cSrcweir } 1661*cdf0e10cSrcweir 1662*cdf0e10cSrcweir return aPolyPolygon; 1663*cdf0e10cSrcweir } 1664*cdf0e10cSrcweir 1665*cdf0e10cSrcweir void SdrEdgeObj::SetEdgeTrackPath( const basegfx::B2DPolyPolygon& rPoly ) 1666*cdf0e10cSrcweir { 1667*cdf0e10cSrcweir if ( !rPoly.count() ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir bEdgeTrackDirty = sal_True; 1670*cdf0e10cSrcweir bEdgeTrackUserDefined = sal_False; 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir else 1673*cdf0e10cSrcweir { 1674*cdf0e10cSrcweir *pEdgeTrack = XPolygon( rPoly.getB2DPolygon( 0 ) ); 1675*cdf0e10cSrcweir bEdgeTrackDirty = sal_False; 1676*cdf0e10cSrcweir bEdgeTrackUserDefined = sal_True; 1677*cdf0e10cSrcweir 1678*cdf0e10cSrcweir // #i110629# also set aRect and maSnapeRect dependent from pEdgeTrack 1679*cdf0e10cSrcweir const Rectangle aPolygonBounds(pEdgeTrack->GetBoundRect()); 1680*cdf0e10cSrcweir aRect = aPolygonBounds; 1681*cdf0e10cSrcweir maSnapRect = aPolygonBounds; 1682*cdf0e10cSrcweir } 1683*cdf0e10cSrcweir } 1684*cdf0e10cSrcweir 1685*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrEdgeObj::GetEdgeTrackPath() const 1686*cdf0e10cSrcweir { 1687*cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPolygon; 1688*cdf0e10cSrcweir 1689*cdf0e10cSrcweir if (bEdgeTrackDirty) 1690*cdf0e10cSrcweir ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack(); 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir aPolyPolygon.append( pEdgeTrack->getB2DPolygon() ); 1693*cdf0e10cSrcweir 1694*cdf0e10cSrcweir return aPolyPolygon; 1695*cdf0e10cSrcweir } 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir sal_uInt32 SdrEdgeObj::GetHdlCount() const 1698*cdf0e10cSrcweir { 1699*cdf0e10cSrcweir SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue(); 1700*cdf0e10cSrcweir sal_uInt32 nHdlAnz(0L); 1701*cdf0e10cSrcweir sal_uInt32 nPntAnz(pEdgeTrack->GetPointCount()); 1702*cdf0e10cSrcweir 1703*cdf0e10cSrcweir if(nPntAnz) 1704*cdf0e10cSrcweir { 1705*cdf0e10cSrcweir nHdlAnz = 2L; 1706*cdf0e10cSrcweir 1707*cdf0e10cSrcweir if ((eKind==SDREDGE_ORTHOLINES || eKind==SDREDGE_BEZIER) && nPntAnz >= 4L) 1708*cdf0e10cSrcweir { 1709*cdf0e10cSrcweir sal_uInt32 nO1(aEdgeInfo.nObj1Lines > 0L ? aEdgeInfo.nObj1Lines - 1L : 0L); 1710*cdf0e10cSrcweir sal_uInt32 nO2(aEdgeInfo.nObj2Lines > 0L ? aEdgeInfo.nObj2Lines - 1L : 0L); 1711*cdf0e10cSrcweir sal_uInt32 nM(aEdgeInfo.nMiddleLine != 0xFFFF ? 1L : 0L); 1712*cdf0e10cSrcweir nHdlAnz += nO1 + nO2 + nM; 1713*cdf0e10cSrcweir } 1714*cdf0e10cSrcweir else if (eKind==SDREDGE_THREELINES && nPntAnz == 4L) 1715*cdf0e10cSrcweir { 1716*cdf0e10cSrcweir if(GetConnectedNode(sal_True)) 1717*cdf0e10cSrcweir nHdlAnz++; 1718*cdf0e10cSrcweir 1719*cdf0e10cSrcweir if(GetConnectedNode(sal_False)) 1720*cdf0e10cSrcweir nHdlAnz++; 1721*cdf0e10cSrcweir } 1722*cdf0e10cSrcweir } 1723*cdf0e10cSrcweir 1724*cdf0e10cSrcweir return nHdlAnz; 1725*cdf0e10cSrcweir } 1726*cdf0e10cSrcweir 1727*cdf0e10cSrcweir SdrHdl* SdrEdgeObj::GetHdl(sal_uInt32 nHdlNum) const 1728*cdf0e10cSrcweir { 1729*cdf0e10cSrcweir SdrHdl* pHdl=NULL; 1730*cdf0e10cSrcweir sal_uInt32 nPntAnz(pEdgeTrack->GetPointCount()); 1731*cdf0e10cSrcweir if (nPntAnz!=0) { 1732*cdf0e10cSrcweir if (nHdlNum==0) { 1733*cdf0e10cSrcweir pHdl=new ImpEdgeHdl((*pEdgeTrack)[0],HDL_POLY); 1734*cdf0e10cSrcweir if (aCon1.pObj!=NULL && aCon1.bBestVertex) pHdl->Set1PixMore(sal_True); 1735*cdf0e10cSrcweir } else if (nHdlNum==1) { 1736*cdf0e10cSrcweir pHdl=new ImpEdgeHdl((*pEdgeTrack)[sal_uInt16(nPntAnz-1)],HDL_POLY); 1737*cdf0e10cSrcweir if (aCon2.pObj!=NULL && aCon2.bBestVertex) pHdl->Set1PixMore(sal_True); 1738*cdf0e10cSrcweir } else { 1739*cdf0e10cSrcweir SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue(); 1740*cdf0e10cSrcweir if (eKind==SDREDGE_ORTHOLINES || eKind==SDREDGE_BEZIER) { 1741*cdf0e10cSrcweir sal_uInt32 nO1(aEdgeInfo.nObj1Lines > 0L ? aEdgeInfo.nObj1Lines - 1L : 0L); 1742*cdf0e10cSrcweir sal_uInt32 nO2(aEdgeInfo.nObj2Lines > 0L ? aEdgeInfo.nObj2Lines - 1L : 0L); 1743*cdf0e10cSrcweir sal_uInt32 nM(aEdgeInfo.nMiddleLine != 0xFFFF ? 1L : 0L); 1744*cdf0e10cSrcweir sal_uInt32 nNum(nHdlNum - 2L); 1745*cdf0e10cSrcweir sal_Int32 nPt(0L); 1746*cdf0e10cSrcweir pHdl=new ImpEdgeHdl(Point(),HDL_POLY); 1747*cdf0e10cSrcweir if (nNum<nO1) { 1748*cdf0e10cSrcweir nPt=nNum+1L; 1749*cdf0e10cSrcweir if (nNum==0) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE2); 1750*cdf0e10cSrcweir if (nNum==1) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE3); 1751*cdf0e10cSrcweir } else { 1752*cdf0e10cSrcweir nNum=nNum-nO1; 1753*cdf0e10cSrcweir if (nNum<nO2) { 1754*cdf0e10cSrcweir nPt=nPntAnz-3-nNum; 1755*cdf0e10cSrcweir if (nNum==0) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE2); 1756*cdf0e10cSrcweir if (nNum==1) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE3); 1757*cdf0e10cSrcweir } else { 1758*cdf0e10cSrcweir nNum=nNum-nO2; 1759*cdf0e10cSrcweir if (nNum<nM) { 1760*cdf0e10cSrcweir nPt=aEdgeInfo.nMiddleLine; 1761*cdf0e10cSrcweir ((ImpEdgeHdl*)pHdl)->SetLineCode(MIDDLELINE); 1762*cdf0e10cSrcweir } 1763*cdf0e10cSrcweir } 1764*cdf0e10cSrcweir } 1765*cdf0e10cSrcweir if (nPt>0) { 1766*cdf0e10cSrcweir Point aPos((*pEdgeTrack)[(sal_uInt16)nPt]); 1767*cdf0e10cSrcweir aPos+=(*pEdgeTrack)[(sal_uInt16)nPt+1]; 1768*cdf0e10cSrcweir aPos.X()/=2; 1769*cdf0e10cSrcweir aPos.Y()/=2; 1770*cdf0e10cSrcweir pHdl->SetPos(aPos); 1771*cdf0e10cSrcweir } else { 1772*cdf0e10cSrcweir delete pHdl; 1773*cdf0e10cSrcweir pHdl=NULL; 1774*cdf0e10cSrcweir } 1775*cdf0e10cSrcweir } else if (eKind==SDREDGE_THREELINES) { 1776*cdf0e10cSrcweir sal_uInt32 nNum(nHdlNum); 1777*cdf0e10cSrcweir if (GetConnectedNode(sal_True)==NULL) nNum++; 1778*cdf0e10cSrcweir Point aPos((*pEdgeTrack)[(sal_uInt16)nNum-1]); 1779*cdf0e10cSrcweir pHdl=new ImpEdgeHdl(aPos,HDL_POLY); 1780*cdf0e10cSrcweir if (nNum==2) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE2); 1781*cdf0e10cSrcweir if (nNum==3) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE2); 1782*cdf0e10cSrcweir } 1783*cdf0e10cSrcweir } 1784*cdf0e10cSrcweir if (pHdl!=NULL) { 1785*cdf0e10cSrcweir pHdl->SetPointNum(nHdlNum); 1786*cdf0e10cSrcweir } 1787*cdf0e10cSrcweir } 1788*cdf0e10cSrcweir return pHdl; 1789*cdf0e10cSrcweir } 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1792*cdf0e10cSrcweir 1793*cdf0e10cSrcweir bool SdrEdgeObj::hasSpecialDrag() const 1794*cdf0e10cSrcweir { 1795*cdf0e10cSrcweir return true; 1796*cdf0e10cSrcweir } 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir SdrObject* SdrEdgeObj::getFullDragClone() const 1799*cdf0e10cSrcweir { 1800*cdf0e10cSrcweir // use Clone operator 1801*cdf0e10cSrcweir SdrEdgeObj* pRetval = (SdrEdgeObj*)Clone(); 1802*cdf0e10cSrcweir 1803*cdf0e10cSrcweir // copy connections for clone, SdrEdgeObj::operator= does not do this 1804*cdf0e10cSrcweir pRetval->ConnectToNode(true, GetConnectedNode(true)); 1805*cdf0e10cSrcweir pRetval->ConnectToNode(false, GetConnectedNode(false)); 1806*cdf0e10cSrcweir 1807*cdf0e10cSrcweir return pRetval; 1808*cdf0e10cSrcweir } 1809*cdf0e10cSrcweir 1810*cdf0e10cSrcweir bool SdrEdgeObj::beginSpecialDrag(SdrDragStat& rDrag) const 1811*cdf0e10cSrcweir { 1812*cdf0e10cSrcweir if(!rDrag.GetHdl()) 1813*cdf0e10cSrcweir return false; 1814*cdf0e10cSrcweir 1815*cdf0e10cSrcweir rDrag.SetEndDragChangesAttributes(true); 1816*cdf0e10cSrcweir 1817*cdf0e10cSrcweir if(rDrag.GetHdl()->GetPointNum() < 2) 1818*cdf0e10cSrcweir { 1819*cdf0e10cSrcweir rDrag.SetNoSnap(true); 1820*cdf0e10cSrcweir } 1821*cdf0e10cSrcweir 1822*cdf0e10cSrcweir return true; 1823*cdf0e10cSrcweir } 1824*cdf0e10cSrcweir 1825*cdf0e10cSrcweir bool SdrEdgeObj::applySpecialDrag(SdrDragStat& rDragStat) 1826*cdf0e10cSrcweir { 1827*cdf0e10cSrcweir SdrEdgeObj* pOriginalEdge = dynamic_cast< SdrEdgeObj* >(rDragStat.GetHdl()->GetObj()); 1828*cdf0e10cSrcweir const bool bOriginalEdgeModified(pOriginalEdge == this); 1829*cdf0e10cSrcweir 1830*cdf0e10cSrcweir if(!bOriginalEdgeModified && pOriginalEdge) 1831*cdf0e10cSrcweir { 1832*cdf0e10cSrcweir // copy connections when clone is modified. This is needed because 1833*cdf0e10cSrcweir // as preparation to this modification the data from the original object 1834*cdf0e10cSrcweir // was copied to the clone using the operator=. As can be seen there, 1835*cdf0e10cSrcweir // that operator does not copy the connections (for good reason) 1836*cdf0e10cSrcweir ConnectToNode(true, pOriginalEdge->GetConnection(true).GetObject()); 1837*cdf0e10cSrcweir ConnectToNode(false, pOriginalEdge->GetConnection(false).GetObject()); 1838*cdf0e10cSrcweir } 1839*cdf0e10cSrcweir 1840*cdf0e10cSrcweir if(rDragStat.GetHdl()->GetPointNum() < 2) 1841*cdf0e10cSrcweir { 1842*cdf0e10cSrcweir // start or end point connector drag 1843*cdf0e10cSrcweir const bool bDragA(0 == rDragStat.GetHdl()->GetPointNum()); 1844*cdf0e10cSrcweir const Point aPointNow(rDragStat.GetNow()); 1845*cdf0e10cSrcweir 1846*cdf0e10cSrcweir if(rDragStat.GetPageView()) 1847*cdf0e10cSrcweir { 1848*cdf0e10cSrcweir SdrObjConnection* pDraggedOne(bDragA ? &aCon1 : &aCon2); 1849*cdf0e10cSrcweir 1850*cdf0e10cSrcweir // clear connection 1851*cdf0e10cSrcweir DisconnectFromNode(bDragA); 1852*cdf0e10cSrcweir 1853*cdf0e10cSrcweir // look for new connection 1854*cdf0e10cSrcweir ImpFindConnector(aPointNow, *rDragStat.GetPageView(), *pDraggedOne, pOriginalEdge); 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweir if(pDraggedOne->pObj) 1857*cdf0e10cSrcweir { 1858*cdf0e10cSrcweir // if found, officially connect to it; ImpFindConnector only 1859*cdf0e10cSrcweir // sets pObj hard 1860*cdf0e10cSrcweir SdrObject* pNewConnection = pDraggedOne->pObj; 1861*cdf0e10cSrcweir pDraggedOne->pObj = 0; 1862*cdf0e10cSrcweir ConnectToNode(bDragA, pNewConnection); 1863*cdf0e10cSrcweir } 1864*cdf0e10cSrcweir 1865*cdf0e10cSrcweir if(rDragStat.GetView() && !bOriginalEdgeModified) 1866*cdf0e10cSrcweir { 1867*cdf0e10cSrcweir // show IA helper, but only do this during IA, so not when the original 1868*cdf0e10cSrcweir // Edge gets modified in the last call 1869*cdf0e10cSrcweir rDragStat.GetView()->SetConnectMarker(*pDraggedOne, *rDragStat.GetPageView()); 1870*cdf0e10cSrcweir } 1871*cdf0e10cSrcweir } 1872*cdf0e10cSrcweir 1873*cdf0e10cSrcweir if(pEdgeTrack) 1874*cdf0e10cSrcweir { 1875*cdf0e10cSrcweir // change pEdgeTrack to modified position 1876*cdf0e10cSrcweir if(bDragA) 1877*cdf0e10cSrcweir { 1878*cdf0e10cSrcweir (*pEdgeTrack)[0] = aPointNow; 1879*cdf0e10cSrcweir } 1880*cdf0e10cSrcweir else 1881*cdf0e10cSrcweir { 1882*cdf0e10cSrcweir (*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount()-1)] = aPointNow; 1883*cdf0e10cSrcweir } 1884*cdf0e10cSrcweir } 1885*cdf0e10cSrcweir 1886*cdf0e10cSrcweir // reset edge info's offsets, this is a end point drag 1887*cdf0e10cSrcweir aEdgeInfo.aObj1Line2 = Point(); 1888*cdf0e10cSrcweir aEdgeInfo.aObj1Line3 = Point(); 1889*cdf0e10cSrcweir aEdgeInfo.aObj2Line2 = Point(); 1890*cdf0e10cSrcweir aEdgeInfo.aObj2Line3 = Point(); 1891*cdf0e10cSrcweir aEdgeInfo.aMiddleLine = Point(); 1892*cdf0e10cSrcweir } 1893*cdf0e10cSrcweir else 1894*cdf0e10cSrcweir { 1895*cdf0e10cSrcweir // control point connector drag 1896*cdf0e10cSrcweir const ImpEdgeHdl* pEdgeHdl = (ImpEdgeHdl*)rDragStat.GetHdl(); 1897*cdf0e10cSrcweir const SdrEdgeLineCode eLineCode = pEdgeHdl->GetLineCode(); 1898*cdf0e10cSrcweir const Point aDist(rDragStat.GetNow() - rDragStat.GetStart()); 1899*cdf0e10cSrcweir sal_Int32 nDist(pEdgeHdl->IsHorzDrag() ? aDist.X() : aDist.Y()); 1900*cdf0e10cSrcweir 1901*cdf0e10cSrcweir nDist += aEdgeInfo.ImpGetLineVersatz(eLineCode, *pEdgeTrack); 1902*cdf0e10cSrcweir aEdgeInfo.ImpSetLineVersatz(eLineCode, *pEdgeTrack, nDist); 1903*cdf0e10cSrcweir } 1904*cdf0e10cSrcweir 1905*cdf0e10cSrcweir // force recalc EdgeTrack 1906*cdf0e10cSrcweir *pEdgeTrack = ImpCalcEdgeTrack(*pEdgeTrack, aCon1, aCon2, &aEdgeInfo); 1907*cdf0e10cSrcweir bEdgeTrackDirty=sal_False; 1908*cdf0e10cSrcweir 1909*cdf0e10cSrcweir // save EdgeInfos and mark object as user modified 1910*cdf0e10cSrcweir ImpSetEdgeInfoToAttr(); 1911*cdf0e10cSrcweir bEdgeTrackUserDefined = false; 1912*cdf0e10cSrcweir //SetRectsDirty(); 1913*cdf0e10cSrcweir //SetChanged(); 1914*cdf0e10cSrcweir 1915*cdf0e10cSrcweir if(bOriginalEdgeModified && rDragStat.GetView()) 1916*cdf0e10cSrcweir { 1917*cdf0e10cSrcweir // hide connect marker helper again when original gets changed. 1918*cdf0e10cSrcweir // This happens at the end of the interaction 1919*cdf0e10cSrcweir rDragStat.GetView()->HideConnectMarker(); 1920*cdf0e10cSrcweir } 1921*cdf0e10cSrcweir 1922*cdf0e10cSrcweir return true; 1923*cdf0e10cSrcweir } 1924*cdf0e10cSrcweir 1925*cdf0e10cSrcweir String SdrEdgeObj::getSpecialDragComment(const SdrDragStat& rDrag) const 1926*cdf0e10cSrcweir { 1927*cdf0e10cSrcweir const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); 1928*cdf0e10cSrcweir 1929*cdf0e10cSrcweir if(bCreateComment) 1930*cdf0e10cSrcweir { 1931*cdf0e10cSrcweir return String(); 1932*cdf0e10cSrcweir } 1933*cdf0e10cSrcweir else 1934*cdf0e10cSrcweir { 1935*cdf0e10cSrcweir XubString aStr; 1936*cdf0e10cSrcweir ImpTakeDescriptionStr(STR_DragEdgeTail, aStr); 1937*cdf0e10cSrcweir 1938*cdf0e10cSrcweir return aStr; 1939*cdf0e10cSrcweir } 1940*cdf0e10cSrcweir } 1941*cdf0e10cSrcweir 1942*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1943*cdf0e10cSrcweir 1944*cdf0e10cSrcweir basegfx::B2DPolygon SdrEdgeObj::ImplAddConnectorOverlay(SdrDragMethod& rDragMethod, bool bTail1, bool bTail2, bool bDetail) const 1945*cdf0e10cSrcweir { 1946*cdf0e10cSrcweir basegfx::B2DPolygon aResult; 1947*cdf0e10cSrcweir 1948*cdf0e10cSrcweir if(bDetail) 1949*cdf0e10cSrcweir { 1950*cdf0e10cSrcweir SdrObjConnection aMyCon1(aCon1); 1951*cdf0e10cSrcweir SdrObjConnection aMyCon2(aCon2); 1952*cdf0e10cSrcweir 1953*cdf0e10cSrcweir if (bTail1) 1954*cdf0e10cSrcweir { 1955*cdf0e10cSrcweir const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon1.aObjOfs.X(), aMyCon1.aObjOfs.Y())); 1956*cdf0e10cSrcweir aMyCon1.aObjOfs.X() = basegfx::fround(aTemp.getX()); 1957*cdf0e10cSrcweir aMyCon1.aObjOfs.Y() = basegfx::fround(aTemp.getY()); 1958*cdf0e10cSrcweir } 1959*cdf0e10cSrcweir 1960*cdf0e10cSrcweir if (bTail2) 1961*cdf0e10cSrcweir { 1962*cdf0e10cSrcweir const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon2.aObjOfs.X(), aMyCon2.aObjOfs.Y())); 1963*cdf0e10cSrcweir aMyCon2.aObjOfs.X() = basegfx::fround(aTemp.getX()); 1964*cdf0e10cSrcweir aMyCon2.aObjOfs.Y() = basegfx::fround(aTemp.getY()); 1965*cdf0e10cSrcweir } 1966*cdf0e10cSrcweir 1967*cdf0e10cSrcweir SdrEdgeInfoRec aInfo(aEdgeInfo); 1968*cdf0e10cSrcweir XPolygon aXP(ImpCalcEdgeTrack(*pEdgeTrack, aMyCon1, aMyCon2, &aInfo)); 1969*cdf0e10cSrcweir 1970*cdf0e10cSrcweir if(aXP.GetPointCount()) 1971*cdf0e10cSrcweir { 1972*cdf0e10cSrcweir aResult = aXP.getB2DPolygon(); 1973*cdf0e10cSrcweir } 1974*cdf0e10cSrcweir } 1975*cdf0e10cSrcweir else 1976*cdf0e10cSrcweir { 1977*cdf0e10cSrcweir Point aPt1((*pEdgeTrack)[0]); 1978*cdf0e10cSrcweir Point aPt2((*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount() - 1)]); 1979*cdf0e10cSrcweir 1980*cdf0e10cSrcweir if (aCon1.pObj && (aCon1.bBestConn || aCon1.bBestVertex)) 1981*cdf0e10cSrcweir aPt1 = aCon1.pObj->GetSnapRect().Center(); 1982*cdf0e10cSrcweir 1983*cdf0e10cSrcweir if (aCon2.pObj && (aCon2.bBestConn || aCon2.bBestVertex)) 1984*cdf0e10cSrcweir aPt2 = aCon2.pObj->GetSnapRect().Center(); 1985*cdf0e10cSrcweir 1986*cdf0e10cSrcweir if (bTail1) 1987*cdf0e10cSrcweir { 1988*cdf0e10cSrcweir const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt1.X(), aPt1.Y())); 1989*cdf0e10cSrcweir aPt1.X() = basegfx::fround(aTemp.getX()); 1990*cdf0e10cSrcweir aPt1.Y() = basegfx::fround(aTemp.getY()); 1991*cdf0e10cSrcweir } 1992*cdf0e10cSrcweir 1993*cdf0e10cSrcweir if (bTail2) 1994*cdf0e10cSrcweir { 1995*cdf0e10cSrcweir const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt2.X(), aPt2.Y())); 1996*cdf0e10cSrcweir aPt2.X() = basegfx::fround(aTemp.getX()); 1997*cdf0e10cSrcweir aPt2.Y() = basegfx::fround(aTemp.getY()); 1998*cdf0e10cSrcweir } 1999*cdf0e10cSrcweir 2000*cdf0e10cSrcweir aResult.append(basegfx::B2DPoint(aPt1.X(), aPt1.Y())); 2001*cdf0e10cSrcweir aResult.append(basegfx::B2DPoint(aPt2.X(), aPt2.Y())); 2002*cdf0e10cSrcweir } 2003*cdf0e10cSrcweir 2004*cdf0e10cSrcweir return aResult; 2005*cdf0e10cSrcweir } 2006*cdf0e10cSrcweir 2007*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::BegCreate(SdrDragStat& rDragStat) 2008*cdf0e10cSrcweir { 2009*cdf0e10cSrcweir rDragStat.SetNoSnap(sal_True); 2010*cdf0e10cSrcweir pEdgeTrack->SetPointCount(2); 2011*cdf0e10cSrcweir (*pEdgeTrack)[0]=rDragStat.GetStart(); 2012*cdf0e10cSrcweir (*pEdgeTrack)[1]=rDragStat.GetNow(); 2013*cdf0e10cSrcweir if (rDragStat.GetPageView()!=NULL) { 2014*cdf0e10cSrcweir ImpFindConnector(rDragStat.GetStart(),*rDragStat.GetPageView(),aCon1,this); 2015*cdf0e10cSrcweir ConnectToNode(sal_True,aCon1.pObj); 2016*cdf0e10cSrcweir } 2017*cdf0e10cSrcweir *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo); 2018*cdf0e10cSrcweir return sal_True; 2019*cdf0e10cSrcweir } 2020*cdf0e10cSrcweir 2021*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::MovCreate(SdrDragStat& rDragStat) 2022*cdf0e10cSrcweir { 2023*cdf0e10cSrcweir sal_uInt16 nMax=pEdgeTrack->GetPointCount(); 2024*cdf0e10cSrcweir (*pEdgeTrack)[nMax-1]=rDragStat.GetNow(); 2025*cdf0e10cSrcweir if (rDragStat.GetPageView()!=NULL) { 2026*cdf0e10cSrcweir ImpFindConnector(rDragStat.GetNow(),*rDragStat.GetPageView(),aCon2,this); 2027*cdf0e10cSrcweir rDragStat.GetView()->SetConnectMarker(aCon2,*rDragStat.GetPageView()); 2028*cdf0e10cSrcweir } 2029*cdf0e10cSrcweir SetBoundRectDirty(); 2030*cdf0e10cSrcweir bSnapRectDirty=sal_True; 2031*cdf0e10cSrcweir ConnectToNode(sal_False,aCon2.pObj); 2032*cdf0e10cSrcweir *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo); 2033*cdf0e10cSrcweir bEdgeTrackDirty=sal_False; 2034*cdf0e10cSrcweir return sal_True; 2035*cdf0e10cSrcweir } 2036*cdf0e10cSrcweir 2037*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::EndCreate(SdrDragStat& rDragStat, SdrCreateCmd eCmd) 2038*cdf0e10cSrcweir { 2039*cdf0e10cSrcweir FASTBOOL bOk=(eCmd==SDRCREATE_FORCEEND || rDragStat.GetPointAnz()>=2); 2040*cdf0e10cSrcweir if (bOk) { 2041*cdf0e10cSrcweir ConnectToNode(sal_True,aCon1.pObj); 2042*cdf0e10cSrcweir ConnectToNode(sal_False,aCon2.pObj); 2043*cdf0e10cSrcweir if (rDragStat.GetView()!=NULL) { 2044*cdf0e10cSrcweir rDragStat.GetView()->HideConnectMarker(); 2045*cdf0e10cSrcweir } 2046*cdf0e10cSrcweir ImpSetEdgeInfoToAttr(); // Die Werte aus aEdgeInfo in den Pool kopieren 2047*cdf0e10cSrcweir } 2048*cdf0e10cSrcweir SetRectsDirty(); 2049*cdf0e10cSrcweir return bOk; 2050*cdf0e10cSrcweir } 2051*cdf0e10cSrcweir 2052*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::BckCreate(SdrDragStat& rDragStat) 2053*cdf0e10cSrcweir { 2054*cdf0e10cSrcweir if (rDragStat.GetView()!=NULL) { 2055*cdf0e10cSrcweir rDragStat.GetView()->HideConnectMarker(); 2056*cdf0e10cSrcweir } 2057*cdf0e10cSrcweir return sal_False; 2058*cdf0e10cSrcweir } 2059*cdf0e10cSrcweir 2060*cdf0e10cSrcweir void SdrEdgeObj::BrkCreate(SdrDragStat& rDragStat) 2061*cdf0e10cSrcweir { 2062*cdf0e10cSrcweir if (rDragStat.GetView()!=NULL) { 2063*cdf0e10cSrcweir rDragStat.GetView()->HideConnectMarker(); 2064*cdf0e10cSrcweir } 2065*cdf0e10cSrcweir } 2066*cdf0e10cSrcweir 2067*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrEdgeObj::TakeCreatePoly(const SdrDragStat& /*rStatDrag*/) const 2068*cdf0e10cSrcweir { 2069*cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval; 2070*cdf0e10cSrcweir aRetval.append(pEdgeTrack->getB2DPolygon()); 2071*cdf0e10cSrcweir return aRetval; 2072*cdf0e10cSrcweir } 2073*cdf0e10cSrcweir 2074*cdf0e10cSrcweir Pointer SdrEdgeObj::GetCreatePointer() const 2075*cdf0e10cSrcweir { 2076*cdf0e10cSrcweir return Pointer(POINTER_DRAW_CONNECT); 2077*cdf0e10cSrcweir } 2078*cdf0e10cSrcweir 2079*cdf0e10cSrcweir FASTBOOL SdrEdgeObj::ImpFindConnector(const Point& rPt, const SdrPageView& rPV, SdrObjConnection& rCon, const SdrEdgeObj* pThis, OutputDevice* pOut) 2080*cdf0e10cSrcweir { 2081*cdf0e10cSrcweir rCon.ResetVars(); 2082*cdf0e10cSrcweir if (pOut==NULL) pOut=rPV.GetView().GetFirstOutputDevice(); // GetWin(0); 2083*cdf0e10cSrcweir if (pOut==NULL) return sal_False; 2084*cdf0e10cSrcweir SdrObjList* pOL=rPV.GetObjList(); 2085*cdf0e10cSrcweir const SetOfByte& rVisLayer=rPV.GetVisibleLayers(); 2086*cdf0e10cSrcweir // Sensitiver Bereich der Konnektoren ist doppelt so gross wie die Handles: 2087*cdf0e10cSrcweir sal_uInt16 nMarkHdSiz=rPV.GetView().GetMarkHdlSizePixel(); 2088*cdf0e10cSrcweir Size aHalfConSiz(nMarkHdSiz,nMarkHdSiz); 2089*cdf0e10cSrcweir aHalfConSiz=pOut->PixelToLogic(aHalfConSiz); 2090*cdf0e10cSrcweir Size aHalfCenterSiz(2*aHalfConSiz.Width(),2*aHalfConSiz.Height()); 2091*cdf0e10cSrcweir Rectangle aMouseRect(rPt,rPt); 2092*cdf0e10cSrcweir aMouseRect.Left() -=aHalfConSiz.Width(); 2093*cdf0e10cSrcweir aMouseRect.Top() -=aHalfConSiz.Height(); 2094*cdf0e10cSrcweir aMouseRect.Right() +=aHalfConSiz.Width(); 2095*cdf0e10cSrcweir aMouseRect.Bottom()+=aHalfConSiz.Height(); 2096*cdf0e10cSrcweir sal_uInt16 nBoundHitTol=(sal_uInt16)aHalfConSiz.Width()/2; if (nBoundHitTol==0) nBoundHitTol=1; 2097*cdf0e10cSrcweir sal_uIntPtr no=pOL->GetObjCount(); 2098*cdf0e10cSrcweir FASTBOOL bFnd=sal_False; 2099*cdf0e10cSrcweir SdrObjConnection aTestCon; 2100*cdf0e10cSrcweir SdrObjConnection aBestCon; 2101*cdf0e10cSrcweir FASTBOOL bTestBoundHit=sal_False; 2102*cdf0e10cSrcweir //int bBestBoundHit=sal_False; 2103*cdf0e10cSrcweir 2104*cdf0e10cSrcweir while (no>0 && !bFnd) { 2105*cdf0e10cSrcweir // Problem: Gruppenobjekt mit verschiedenen Layern liefert LayerID 0 !!!! 2106*cdf0e10cSrcweir no--; 2107*cdf0e10cSrcweir SdrObject* pObj=pOL->GetObj(no); 2108*cdf0e10cSrcweir if (rVisLayer.IsSet(pObj->GetLayer()) && pObj->IsVisible() && // only visible objects 2109*cdf0e10cSrcweir (pThis==NULL || pObj!=(SdrObject*)pThis) && // nicht an mich selbst connecten 2110*cdf0e10cSrcweir pObj->IsNode()) 2111*cdf0e10cSrcweir { 2112*cdf0e10cSrcweir Rectangle aObjBound(pObj->GetCurrentBoundRect()); 2113*cdf0e10cSrcweir if (aObjBound.IsOver(aMouseRect)) { 2114*cdf0e10cSrcweir aTestCon.ResetVars(); 2115*cdf0e10cSrcweir bTestBoundHit=sal_False; 2116*cdf0e10cSrcweir FASTBOOL bEdge=HAS_BASE(SdrEdgeObj,pObj); // kein BestCon fuer Edge 2117*cdf0e10cSrcweir // Die Userdefined Konnektoren haben absolute Prioritaet. 2118*cdf0e10cSrcweir // Danach kommt Vertex, Corner und Mitte(Best) gleich priorisiert. 2119*cdf0e10cSrcweir // Zum Schluss kommt noch ein HitTest aufs Obj. 2120*cdf0e10cSrcweir const SdrGluePointList* pGPL=pObj->GetGluePointList(); 2121*cdf0e10cSrcweir sal_uInt16 nConAnz=pGPL==NULL ? 0 : pGPL->GetCount(); 2122*cdf0e10cSrcweir sal_uInt16 nGesAnz=nConAnz+9; 2123*cdf0e10cSrcweir FASTBOOL bUserFnd=sal_False; 2124*cdf0e10cSrcweir sal_uIntPtr nBestDist=0xFFFFFFFF; 2125*cdf0e10cSrcweir for (sal_uInt16 i=0; i<nGesAnz; i++) 2126*cdf0e10cSrcweir { 2127*cdf0e10cSrcweir FASTBOOL bUser=i<nConAnz; 2128*cdf0e10cSrcweir FASTBOOL bVertex=i>=nConAnz+0 && i<nConAnz+4; 2129*cdf0e10cSrcweir FASTBOOL bCorner=i>=nConAnz+4 && i<nConAnz+8; 2130*cdf0e10cSrcweir FASTBOOL bCenter=i==nConAnz+8; 2131*cdf0e10cSrcweir FASTBOOL bOk=sal_False; 2132*cdf0e10cSrcweir Point aConPos; 2133*cdf0e10cSrcweir sal_uInt16 nConNum=i; 2134*cdf0e10cSrcweir if (bUser) { 2135*cdf0e10cSrcweir const SdrGluePoint& rGP=(*pGPL)[nConNum]; 2136*cdf0e10cSrcweir aConPos=rGP.GetAbsolutePos(*pObj); 2137*cdf0e10cSrcweir nConNum=rGP.GetId(); 2138*cdf0e10cSrcweir bOk=sal_True; 2139*cdf0e10cSrcweir } else if (bVertex && !bUserFnd) { 2140*cdf0e10cSrcweir nConNum=nConNum-nConAnz; 2141*cdf0e10cSrcweir if (rPV.GetView().IsAutoVertexConnectors()) { 2142*cdf0e10cSrcweir SdrGluePoint aPt(pObj->GetVertexGluePoint(nConNum)); 2143*cdf0e10cSrcweir aConPos=aPt.GetAbsolutePos(*pObj); 2144*cdf0e10cSrcweir bOk=sal_True; 2145*cdf0e10cSrcweir } else i+=3; 2146*cdf0e10cSrcweir } else if (bCorner && !bUserFnd) { 2147*cdf0e10cSrcweir nConNum-=nConAnz+4; 2148*cdf0e10cSrcweir if (rPV.GetView().IsAutoCornerConnectors()) { 2149*cdf0e10cSrcweir SdrGluePoint aPt(pObj->GetCornerGluePoint(nConNum)); 2150*cdf0e10cSrcweir aConPos=aPt.GetAbsolutePos(*pObj); 2151*cdf0e10cSrcweir bOk=sal_True; 2152*cdf0e10cSrcweir } else i+=3; 2153*cdf0e10cSrcweir } 2154*cdf0e10cSrcweir else if (bCenter && !bUserFnd && !bEdge) 2155*cdf0e10cSrcweir { 2156*cdf0e10cSrcweir // #109007# 2157*cdf0e10cSrcweir // Suppress default connect at object center 2158*cdf0e10cSrcweir if(!pThis || !pThis->GetSuppressDefaultConnect()) 2159*cdf0e10cSrcweir { 2160*cdf0e10cSrcweir // Edges nicht! 2161*cdf0e10cSrcweir nConNum=0; 2162*cdf0e10cSrcweir aConPos=aObjBound.Center(); 2163*cdf0e10cSrcweir bOk=sal_True; 2164*cdf0e10cSrcweir } 2165*cdf0e10cSrcweir } 2166*cdf0e10cSrcweir if (bOk && aMouseRect.IsInside(aConPos)) { 2167*cdf0e10cSrcweir if (bUser) bUserFnd=sal_True; 2168*cdf0e10cSrcweir bFnd=sal_True; 2169*cdf0e10cSrcweir sal_uIntPtr nDist=(sal_uIntPtr)Abs(aConPos.X()-rPt.X())+(sal_uIntPtr)Abs(aConPos.Y()-rPt.Y()); 2170*cdf0e10cSrcweir if (nDist<nBestDist) { 2171*cdf0e10cSrcweir nBestDist=nDist; 2172*cdf0e10cSrcweir aTestCon.pObj=pObj; 2173*cdf0e10cSrcweir aTestCon.nConId=nConNum; 2174*cdf0e10cSrcweir aTestCon.bAutoCorner=bCorner; 2175*cdf0e10cSrcweir aTestCon.bAutoVertex=bVertex; 2176*cdf0e10cSrcweir aTestCon.bBestConn=sal_False; // bCenter; 2177*cdf0e10cSrcweir aTestCon.bBestVertex=bCenter; 2178*cdf0e10cSrcweir } 2179*cdf0e10cSrcweir } 2180*cdf0e10cSrcweir } 2181*cdf0e10cSrcweir // Falls kein Konnektor getroffen wird nochmal 2182*cdf0e10cSrcweir // HitTest versucht fuer BestConnector (=bCenter) 2183*cdf0e10cSrcweir if(!bFnd && 2184*cdf0e10cSrcweir !bEdge && 2185*cdf0e10cSrcweir SdrObjectPrimitiveHit(*pObj, rPt, nBoundHitTol, rPV, &rVisLayer, false)) 2186*cdf0e10cSrcweir { 2187*cdf0e10cSrcweir // #109007# 2188*cdf0e10cSrcweir // Suppress default connect at object inside bound 2189*cdf0e10cSrcweir if(!pThis || !pThis->GetSuppressDefaultConnect()) 2190*cdf0e10cSrcweir { 2191*cdf0e10cSrcweir bFnd=sal_True; 2192*cdf0e10cSrcweir aTestCon.pObj=pObj; 2193*cdf0e10cSrcweir aTestCon.bBestConn=sal_True; 2194*cdf0e10cSrcweir } 2195*cdf0e10cSrcweir } 2196*cdf0e10cSrcweir if (bFnd) { 2197*cdf0e10cSrcweir Rectangle aMouseRect2(rPt,rPt); 2198*cdf0e10cSrcweir aMouseRect.Left() -=nBoundHitTol; 2199*cdf0e10cSrcweir aMouseRect.Top() -=nBoundHitTol; 2200*cdf0e10cSrcweir aMouseRect.Right() +=nBoundHitTol; 2201*cdf0e10cSrcweir aMouseRect.Bottom()+=nBoundHitTol; 2202*cdf0e10cSrcweir bTestBoundHit=aObjBound.IsOver(aMouseRect2); 2203*cdf0e10cSrcweir } 2204*cdf0e10cSrcweir 2205*cdf0e10cSrcweir } 2206*cdf0e10cSrcweir } 2207*cdf0e10cSrcweir } 2208*cdf0e10cSrcweir rCon=aTestCon; 2209*cdf0e10cSrcweir return bFnd; 2210*cdf0e10cSrcweir } 2211*cdf0e10cSrcweir 2212*cdf0e10cSrcweir void SdrEdgeObj::NbcSetSnapRect(const Rectangle& rRect) 2213*cdf0e10cSrcweir { 2214*cdf0e10cSrcweir const Rectangle aOld(GetSnapRect()); 2215*cdf0e10cSrcweir 2216*cdf0e10cSrcweir if(aOld != rRect) 2217*cdf0e10cSrcweir { 2218*cdf0e10cSrcweir if(aRect.IsEmpty() && 0 == pEdgeTrack->GetPointCount()) 2219*cdf0e10cSrcweir { 2220*cdf0e10cSrcweir // #i110629# When initializing, do not scale on empty Rectangle; this 2221*cdf0e10cSrcweir // will mirror the underlying text object (!) 2222*cdf0e10cSrcweir aRect = rRect; 2223*cdf0e10cSrcweir maSnapRect = rRect; 2224*cdf0e10cSrcweir } 2225*cdf0e10cSrcweir else 2226*cdf0e10cSrcweir { 2227*cdf0e10cSrcweir long nMulX = rRect.Right() - rRect.Left(); 2228*cdf0e10cSrcweir long nDivX = aOld.Right() - aOld.Left(); 2229*cdf0e10cSrcweir long nMulY = rRect.Bottom() - rRect.Top(); 2230*cdf0e10cSrcweir long nDivY = aOld.Bottom() - aOld.Top(); 2231*cdf0e10cSrcweir if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; } 2232*cdf0e10cSrcweir if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; } 2233*cdf0e10cSrcweir Fraction aX(nMulX, nDivX); 2234*cdf0e10cSrcweir Fraction aY(nMulY, nDivY); 2235*cdf0e10cSrcweir NbcResize(aOld.TopLeft(), aX, aY); 2236*cdf0e10cSrcweir NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top())); 2237*cdf0e10cSrcweir } 2238*cdf0e10cSrcweir } 2239*cdf0e10cSrcweir } 2240*cdf0e10cSrcweir 2241*cdf0e10cSrcweir void SdrEdgeObj::NbcMove(const Size& rSiz) 2242*cdf0e10cSrcweir { 2243*cdf0e10cSrcweir SdrTextObj::NbcMove(rSiz); 2244*cdf0e10cSrcweir MoveXPoly(*pEdgeTrack,rSiz); 2245*cdf0e10cSrcweir } 2246*cdf0e10cSrcweir 2247*cdf0e10cSrcweir void SdrEdgeObj::NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact) 2248*cdf0e10cSrcweir { 2249*cdf0e10cSrcweir SdrTextObj::NbcResize(rRefPnt,aXFact,aXFact); 2250*cdf0e10cSrcweir ResizeXPoly(*pEdgeTrack,rRefPnt,aXFact,aYFact); 2251*cdf0e10cSrcweir 2252*cdf0e10cSrcweir // #75371# if resize is not from paste, forget user distances 2253*cdf0e10cSrcweir if(!GetModel()->IsPasteResize()) 2254*cdf0e10cSrcweir { 2255*cdf0e10cSrcweir // #75735# 2256*cdf0e10cSrcweir aEdgeInfo.aObj1Line2 = Point(); 2257*cdf0e10cSrcweir aEdgeInfo.aObj1Line3 = Point(); 2258*cdf0e10cSrcweir aEdgeInfo.aObj2Line2 = Point(); 2259*cdf0e10cSrcweir aEdgeInfo.aObj2Line3 = Point(); 2260*cdf0e10cSrcweir aEdgeInfo.aMiddleLine = Point(); 2261*cdf0e10cSrcweir } 2262*cdf0e10cSrcweir } 2263*cdf0e10cSrcweir 2264*cdf0e10cSrcweir SdrObject* SdrEdgeObj::DoConvertToPolyObj(sal_Bool bBezier) const 2265*cdf0e10cSrcweir { 2266*cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPolygon; 2267*cdf0e10cSrcweir aPolyPolygon.append(pEdgeTrack->getB2DPolygon()); 2268*cdf0e10cSrcweir SdrObject* pRet = ImpConvertMakeObj(aPolyPolygon, sal_False, bBezier); 2269*cdf0e10cSrcweir pRet = ImpConvertAddText(pRet, bBezier); 2270*cdf0e10cSrcweir 2271*cdf0e10cSrcweir return pRet; 2272*cdf0e10cSrcweir } 2273*cdf0e10cSrcweir 2274*cdf0e10cSrcweir sal_uInt32 SdrEdgeObj::GetSnapPointCount() const 2275*cdf0e10cSrcweir { 2276*cdf0e10cSrcweir return 2L; 2277*cdf0e10cSrcweir } 2278*cdf0e10cSrcweir 2279*cdf0e10cSrcweir Point SdrEdgeObj::GetSnapPoint(sal_uInt32 i) const 2280*cdf0e10cSrcweir { 2281*cdf0e10cSrcweir ((SdrEdgeObj*)this)->ImpUndirtyEdgeTrack(); 2282*cdf0e10cSrcweir sal_uInt16 nAnz=pEdgeTrack->GetPointCount(); 2283*cdf0e10cSrcweir if (i==0) return (*pEdgeTrack)[0]; 2284*cdf0e10cSrcweir else return (*pEdgeTrack)[nAnz-1]; 2285*cdf0e10cSrcweir } 2286*cdf0e10cSrcweir 2287*cdf0e10cSrcweir sal_Bool SdrEdgeObj::IsPolyObj() const 2288*cdf0e10cSrcweir { 2289*cdf0e10cSrcweir return sal_False; 2290*cdf0e10cSrcweir } 2291*cdf0e10cSrcweir 2292*cdf0e10cSrcweir sal_uInt32 SdrEdgeObj::GetPointCount() const 2293*cdf0e10cSrcweir { 2294*cdf0e10cSrcweir return 0L; 2295*cdf0e10cSrcweir } 2296*cdf0e10cSrcweir 2297*cdf0e10cSrcweir Point SdrEdgeObj::GetPoint(sal_uInt32 i) const 2298*cdf0e10cSrcweir { 2299*cdf0e10cSrcweir ((SdrEdgeObj*)this)->ImpUndirtyEdgeTrack(); 2300*cdf0e10cSrcweir sal_uInt16 nAnz=pEdgeTrack->GetPointCount(); 2301*cdf0e10cSrcweir if (0L == i) 2302*cdf0e10cSrcweir return (*pEdgeTrack)[0]; 2303*cdf0e10cSrcweir else 2304*cdf0e10cSrcweir return (*pEdgeTrack)[nAnz-1]; 2305*cdf0e10cSrcweir } 2306*cdf0e10cSrcweir 2307*cdf0e10cSrcweir void SdrEdgeObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i) 2308*cdf0e10cSrcweir { 2309*cdf0e10cSrcweir // ToDo: Umconnekten fehlt noch 2310*cdf0e10cSrcweir ImpUndirtyEdgeTrack(); 2311*cdf0e10cSrcweir sal_uInt16 nAnz=pEdgeTrack->GetPointCount(); 2312*cdf0e10cSrcweir if (0L == i) 2313*cdf0e10cSrcweir (*pEdgeTrack)[0]=rPnt; 2314*cdf0e10cSrcweir if (1L == i) 2315*cdf0e10cSrcweir (*pEdgeTrack)[nAnz-1]=rPnt; 2316*cdf0e10cSrcweir SetEdgeTrackDirty(); 2317*cdf0e10cSrcweir SetRectsDirty(); 2318*cdf0e10cSrcweir } 2319*cdf0e10cSrcweir 2320*cdf0e10cSrcweir SdrEdgeObjGeoData::SdrEdgeObjGeoData() 2321*cdf0e10cSrcweir { 2322*cdf0e10cSrcweir pEdgeTrack=new XPolygon; 2323*cdf0e10cSrcweir } 2324*cdf0e10cSrcweir 2325*cdf0e10cSrcweir SdrEdgeObjGeoData::~SdrEdgeObjGeoData() 2326*cdf0e10cSrcweir { 2327*cdf0e10cSrcweir delete pEdgeTrack; 2328*cdf0e10cSrcweir } 2329*cdf0e10cSrcweir 2330*cdf0e10cSrcweir SdrObjGeoData* SdrEdgeObj::NewGeoData() const 2331*cdf0e10cSrcweir { 2332*cdf0e10cSrcweir return new SdrEdgeObjGeoData; 2333*cdf0e10cSrcweir } 2334*cdf0e10cSrcweir 2335*cdf0e10cSrcweir void SdrEdgeObj::SaveGeoData(SdrObjGeoData& rGeo) const 2336*cdf0e10cSrcweir { 2337*cdf0e10cSrcweir SdrTextObj::SaveGeoData(rGeo); 2338*cdf0e10cSrcweir SdrEdgeObjGeoData& rEGeo=(SdrEdgeObjGeoData&)rGeo; 2339*cdf0e10cSrcweir rEGeo.aCon1 =aCon1; 2340*cdf0e10cSrcweir rEGeo.aCon2 =aCon2; 2341*cdf0e10cSrcweir *rEGeo.pEdgeTrack =*pEdgeTrack; 2342*cdf0e10cSrcweir rEGeo.bEdgeTrackDirty=bEdgeTrackDirty; 2343*cdf0e10cSrcweir rEGeo.bEdgeTrackUserDefined=bEdgeTrackUserDefined; 2344*cdf0e10cSrcweir rEGeo.aEdgeInfo =aEdgeInfo; 2345*cdf0e10cSrcweir } 2346*cdf0e10cSrcweir 2347*cdf0e10cSrcweir void SdrEdgeObj::RestGeoData(const SdrObjGeoData& rGeo) 2348*cdf0e10cSrcweir { 2349*cdf0e10cSrcweir SdrTextObj::RestGeoData(rGeo); 2350*cdf0e10cSrcweir SdrEdgeObjGeoData& rEGeo=(SdrEdgeObjGeoData&)rGeo; 2351*cdf0e10cSrcweir if (aCon1.pObj!=rEGeo.aCon1.pObj) { 2352*cdf0e10cSrcweir if (aCon1.pObj!=NULL) aCon1.pObj->RemoveListener(*this); 2353*cdf0e10cSrcweir aCon1=rEGeo.aCon1; 2354*cdf0e10cSrcweir if (aCon1.pObj!=NULL) aCon1.pObj->AddListener(*this); 2355*cdf0e10cSrcweir } 2356*cdf0e10cSrcweir if (aCon2.pObj!=rEGeo.aCon2.pObj) { 2357*cdf0e10cSrcweir if (aCon2.pObj!=NULL) aCon2.pObj->RemoveListener(*this); 2358*cdf0e10cSrcweir aCon2=rEGeo.aCon2; 2359*cdf0e10cSrcweir if (aCon2.pObj!=NULL) aCon2.pObj->AddListener(*this); 2360*cdf0e10cSrcweir } 2361*cdf0e10cSrcweir *pEdgeTrack =*rEGeo.pEdgeTrack; 2362*cdf0e10cSrcweir bEdgeTrackDirty=rEGeo.bEdgeTrackDirty; 2363*cdf0e10cSrcweir bEdgeTrackUserDefined=rEGeo.bEdgeTrackUserDefined; 2364*cdf0e10cSrcweir aEdgeInfo =rEGeo.aEdgeInfo; 2365*cdf0e10cSrcweir } 2366*cdf0e10cSrcweir 2367*cdf0e10cSrcweir Point SdrEdgeObj::GetTailPoint( sal_Bool bTail ) const 2368*cdf0e10cSrcweir { 2369*cdf0e10cSrcweir if( pEdgeTrack && pEdgeTrack->GetPointCount()!=0) 2370*cdf0e10cSrcweir { 2371*cdf0e10cSrcweir const XPolygon& rTrack0 = *pEdgeTrack; 2372*cdf0e10cSrcweir if(bTail) 2373*cdf0e10cSrcweir { 2374*cdf0e10cSrcweir return rTrack0[0]; 2375*cdf0e10cSrcweir } 2376*cdf0e10cSrcweir else 2377*cdf0e10cSrcweir { 2378*cdf0e10cSrcweir const sal_uInt16 nSiz = rTrack0.GetPointCount() - 1; 2379*cdf0e10cSrcweir return rTrack0[nSiz]; 2380*cdf0e10cSrcweir } 2381*cdf0e10cSrcweir } 2382*cdf0e10cSrcweir else 2383*cdf0e10cSrcweir { 2384*cdf0e10cSrcweir if(bTail) 2385*cdf0e10cSrcweir return aOutRect.TopLeft(); 2386*cdf0e10cSrcweir else 2387*cdf0e10cSrcweir return aOutRect.BottomRight(); 2388*cdf0e10cSrcweir } 2389*cdf0e10cSrcweir 2390*cdf0e10cSrcweir } 2391*cdf0e10cSrcweir 2392*cdf0e10cSrcweir void SdrEdgeObj::SetTailPoint( sal_Bool bTail, const Point& rPt ) 2393*cdf0e10cSrcweir { 2394*cdf0e10cSrcweir ImpSetTailPoint( bTail, rPt ); 2395*cdf0e10cSrcweir SetChanged(); 2396*cdf0e10cSrcweir } 2397*cdf0e10cSrcweir 2398*cdf0e10cSrcweir /** this method is used by the api to set a glue point for a connection 2399*cdf0e10cSrcweir nId == -1 : The best default point is automaticly choosen 2400*cdf0e10cSrcweir 0 <= nId <= 3 : One of the default points is choosen 2401*cdf0e10cSrcweir nId >= 4 : A user defined glue point is choosen 2402*cdf0e10cSrcweir */ 2403*cdf0e10cSrcweir void SdrEdgeObj::setGluePointIndex( sal_Bool bTail, sal_Int32 nIndex /* = -1 */ ) 2404*cdf0e10cSrcweir { 2405*cdf0e10cSrcweir Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetCurrentBoundRect(); 2406*cdf0e10cSrcweir // #110094#-14 BroadcastObjectChange(); 2407*cdf0e10cSrcweir 2408*cdf0e10cSrcweir SdrObjConnection& rConn1 = GetConnection( bTail ); 2409*cdf0e10cSrcweir 2410*cdf0e10cSrcweir rConn1.SetAutoVertex( nIndex >= 0 && nIndex <= 3 ); 2411*cdf0e10cSrcweir rConn1.SetBestConnection( nIndex < 0 ); 2412*cdf0e10cSrcweir rConn1.SetBestVertex( nIndex < 0 ); 2413*cdf0e10cSrcweir 2414*cdf0e10cSrcweir if( nIndex > 3 ) 2415*cdf0e10cSrcweir { 2416*cdf0e10cSrcweir // nIndex -= 4; 2417*cdf0e10cSrcweir nIndex -= 3; // SJ: the start api index is 0, whereas the implementation in svx starts from 1 2418*cdf0e10cSrcweir 2419*cdf0e10cSrcweir // for user defined glue points we have 2420*cdf0e10cSrcweir // to get the id for this index first 2421*cdf0e10cSrcweir const SdrGluePointList* pList = rConn1.GetObject() ? rConn1.GetObject()->GetGluePointList() : NULL; 2422*cdf0e10cSrcweir if( pList == NULL || SDRGLUEPOINT_NOTFOUND == pList->FindGluePoint((sal_uInt16)nIndex) ) 2423*cdf0e10cSrcweir return; 2424*cdf0e10cSrcweir } 2425*cdf0e10cSrcweir else if( nIndex < 0 ) 2426*cdf0e10cSrcweir { 2427*cdf0e10cSrcweir nIndex = 0; 2428*cdf0e10cSrcweir } 2429*cdf0e10cSrcweir 2430*cdf0e10cSrcweir rConn1.SetConnectorId( (sal_uInt16)nIndex ); 2431*cdf0e10cSrcweir 2432*cdf0e10cSrcweir SetChanged(); 2433*cdf0e10cSrcweir SetRectsDirty(); 2434*cdf0e10cSrcweir ImpRecalcEdgeTrack(); 2435*cdf0e10cSrcweir // bEdgeTrackDirty=sal_True; 2436*cdf0e10cSrcweir } 2437*cdf0e10cSrcweir 2438*cdf0e10cSrcweir /** this method is used by the api to return a glue point id for a connection. 2439*cdf0e10cSrcweir See setGluePointId for possible return values */ 2440*cdf0e10cSrcweir sal_Int32 SdrEdgeObj::getGluePointIndex( sal_Bool bTail ) 2441*cdf0e10cSrcweir { 2442*cdf0e10cSrcweir SdrObjConnection& rConn1 = GetConnection( bTail ); 2443*cdf0e10cSrcweir sal_Int32 nId = -1; 2444*cdf0e10cSrcweir if( !rConn1.IsBestConnection() ) 2445*cdf0e10cSrcweir { 2446*cdf0e10cSrcweir nId = rConn1.GetConnectorId(); 2447*cdf0e10cSrcweir if( !rConn1.IsAutoVertex() ) 2448*cdf0e10cSrcweir // nId += 4; 2449*cdf0e10cSrcweir nId += 3; // SJ: the start api index is 0, whereas the implementation in svx starts from 1 2450*cdf0e10cSrcweir } 2451*cdf0e10cSrcweir return nId; 2452*cdf0e10cSrcweir } 2453*cdf0e10cSrcweir 2454*cdf0e10cSrcweir // #102344# Implementation was missing; edge track needs to be invalidated additionally. 2455*cdf0e10cSrcweir void SdrEdgeObj::NbcSetAnchorPos(const Point& rPnt) 2456*cdf0e10cSrcweir { 2457*cdf0e10cSrcweir // call parent functionality 2458*cdf0e10cSrcweir SdrTextObj::NbcSetAnchorPos(rPnt); 2459*cdf0e10cSrcweir 2460*cdf0e10cSrcweir // Additionally, invalidate edge track 2461*cdf0e10cSrcweir ImpDirtyEdgeTrack(); 2462*cdf0e10cSrcweir } 2463*cdf0e10cSrcweir 2464*cdf0e10cSrcweir sal_Bool SdrEdgeObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const 2465*cdf0e10cSrcweir { 2466*cdf0e10cSrcweir // use base method from SdrObject, it's not rotatable and 2467*cdf0e10cSrcweir // a call to GetSnapRect() is used. That's what we need for Connector. 2468*cdf0e10cSrcweir return SdrObject::TRGetBaseGeometry(rMatrix, rPolyPolygon); 2469*cdf0e10cSrcweir } 2470*cdf0e10cSrcweir 2471*cdf0e10cSrcweir void SdrEdgeObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) 2472*cdf0e10cSrcweir { 2473*cdf0e10cSrcweir // evtl. take care for existing connections. For now, just use the 2474*cdf0e10cSrcweir // implementation from SdrObject. 2475*cdf0e10cSrcweir SdrObject::TRSetBaseGeometry(rMatrix, rPolyPolygon); 2476*cdf0e10cSrcweir } 2477*cdf0e10cSrcweir 2478*cdf0e10cSrcweir // for geometry access 2479*cdf0e10cSrcweir ::basegfx::B2DPolygon SdrEdgeObj::getEdgeTrack() const 2480*cdf0e10cSrcweir { 2481*cdf0e10cSrcweir if(bEdgeTrackDirty) 2482*cdf0e10cSrcweir { 2483*cdf0e10cSrcweir const_cast< SdrEdgeObj* >(this)->ImpRecalcEdgeTrack(); 2484*cdf0e10cSrcweir } 2485*cdf0e10cSrcweir 2486*cdf0e10cSrcweir if(pEdgeTrack) 2487*cdf0e10cSrcweir { 2488*cdf0e10cSrcweir return pEdgeTrack->getB2DPolygon(); 2489*cdf0e10cSrcweir } 2490*cdf0e10cSrcweir else 2491*cdf0e10cSrcweir { 2492*cdf0e10cSrcweir return ::basegfx::B2DPolygon(); 2493*cdf0e10cSrcweir } 2494*cdf0e10cSrcweir } 2495*cdf0e10cSrcweir 2496*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 2497*cdf0e10cSrcweir // eof 2498