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