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