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