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