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