1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir #include <tools/debug.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <svx/svdglue.hxx> 33*cdf0e10cSrcweir #include <svx/svdobj.hxx> 34*cdf0e10cSrcweir #include <svx/svdtrans.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir void SdrGluePoint::SetReallyAbsolute(FASTBOOL bOn, const SdrObject& rObj) 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir if ( bReallyAbsolute != bOn ) 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir if ( bOn ) 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir aPos=GetAbsolutePos(rObj); 45*cdf0e10cSrcweir bReallyAbsolute=bOn; 46*cdf0e10cSrcweir } 47*cdf0e10cSrcweir else 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir bReallyAbsolute=bOn; 50*cdf0e10cSrcweir Point aPt(aPos); 51*cdf0e10cSrcweir SetAbsolutePos(aPt,rObj); 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir Point SdrGluePoint::GetAbsolutePos(const SdrObject& rObj) const 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir if (bReallyAbsolute) return aPos; 59*cdf0e10cSrcweir Rectangle aSnap(rObj.GetSnapRect()); 60*cdf0e10cSrcweir Rectangle aBound(rObj.GetSnapRect()); 61*cdf0e10cSrcweir Point aPt(aPos); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir Point aOfs(aSnap.Center()); 64*cdf0e10cSrcweir switch (GetHorzAlign()) { 65*cdf0e10cSrcweir case SDRHORZALIGN_LEFT : aOfs.X()=aSnap.Left(); break; 66*cdf0e10cSrcweir case SDRHORZALIGN_RIGHT : aOfs.X()=aSnap.Right(); break; 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir switch (GetVertAlign()) { 69*cdf0e10cSrcweir case SDRVERTALIGN_TOP : aOfs.Y()=aSnap.Top(); break; 70*cdf0e10cSrcweir case SDRVERTALIGN_BOTTOM: aOfs.Y()=aSnap.Bottom(); break; 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir if (!bNoPercent) { 73*cdf0e10cSrcweir long nXMul=aSnap.Right()-aSnap.Left(); 74*cdf0e10cSrcweir long nYMul=aSnap.Bottom()-aSnap.Top(); 75*cdf0e10cSrcweir long nXDiv=10000; 76*cdf0e10cSrcweir long nYDiv=10000; 77*cdf0e10cSrcweir if (nXMul!=nXDiv) { 78*cdf0e10cSrcweir aPt.X()*=nXMul; 79*cdf0e10cSrcweir aPt.X()/=nXDiv; 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir if (nYMul!=nYDiv) { 82*cdf0e10cSrcweir aPt.Y()*=nYMul; 83*cdf0e10cSrcweir aPt.Y()/=nYDiv; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir aPt+=aOfs; 87*cdf0e10cSrcweir // Und nun auf's BoundRect des Objekts begrenzen 88*cdf0e10cSrcweir if (aPt.X()<aBound.Left ()) aPt.X()=aBound.Left (); 89*cdf0e10cSrcweir if (aPt.X()>aBound.Right ()) aPt.X()=aBound.Right (); 90*cdf0e10cSrcweir if (aPt.Y()<aBound.Top ()) aPt.Y()=aBound.Top (); 91*cdf0e10cSrcweir if (aPt.Y()>aBound.Bottom()) aPt.Y()=aBound.Bottom(); 92*cdf0e10cSrcweir return aPt; 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void SdrGluePoint::SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir if (bReallyAbsolute) { 98*cdf0e10cSrcweir aPos=rNewPos; 99*cdf0e10cSrcweir return; 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir Rectangle aSnap(rObj.GetSnapRect()); 102*cdf0e10cSrcweir Point aPt(rNewPos); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir Point aOfs(aSnap.Center()); 105*cdf0e10cSrcweir switch (GetHorzAlign()) { 106*cdf0e10cSrcweir case SDRHORZALIGN_LEFT : aOfs.X()=aSnap.Left(); break; 107*cdf0e10cSrcweir case SDRHORZALIGN_RIGHT : aOfs.X()=aSnap.Right(); break; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir switch (GetVertAlign()) { 110*cdf0e10cSrcweir case SDRVERTALIGN_TOP : aOfs.Y()=aSnap.Top(); break; 111*cdf0e10cSrcweir case SDRVERTALIGN_BOTTOM: aOfs.Y()=aSnap.Bottom(); break; 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir aPt-=aOfs; 114*cdf0e10cSrcweir if (!bNoPercent) { 115*cdf0e10cSrcweir long nXMul=aSnap.Right()-aSnap.Left(); 116*cdf0e10cSrcweir long nYMul=aSnap.Bottom()-aSnap.Top(); 117*cdf0e10cSrcweir if (nXMul==0) nXMul=1; 118*cdf0e10cSrcweir if (nYMul==0) nYMul=1; 119*cdf0e10cSrcweir long nXDiv=10000; 120*cdf0e10cSrcweir long nYDiv=10000; 121*cdf0e10cSrcweir if (nXMul!=nXDiv) { 122*cdf0e10cSrcweir aPt.X()*=nXDiv; 123*cdf0e10cSrcweir aPt.X()/=nXMul; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir if (nYMul!=nYDiv) { 126*cdf0e10cSrcweir aPt.Y()*=nYDiv; 127*cdf0e10cSrcweir aPt.Y()/=nYMul; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir aPos=aPt; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir long SdrGluePoint::GetAlignAngle() const 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir switch (nAlign) { 136*cdf0e10cSrcweir case SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER: return 0; // Invalid! 137*cdf0e10cSrcweir case SDRHORZALIGN_RIGHT |SDRVERTALIGN_CENTER: return 0; 138*cdf0e10cSrcweir case SDRHORZALIGN_RIGHT |SDRVERTALIGN_TOP : return 4500; 139*cdf0e10cSrcweir case SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP : return 9000; 140*cdf0e10cSrcweir case SDRHORZALIGN_LEFT |SDRVERTALIGN_TOP : return 13500; 141*cdf0e10cSrcweir case SDRHORZALIGN_LEFT |SDRVERTALIGN_CENTER: return 18000; 142*cdf0e10cSrcweir case SDRHORZALIGN_LEFT |SDRVERTALIGN_BOTTOM: return 22500; 143*cdf0e10cSrcweir case SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM: return 27000; 144*cdf0e10cSrcweir case SDRHORZALIGN_RIGHT |SDRVERTALIGN_BOTTOM: return 31500; 145*cdf0e10cSrcweir } // switch 146*cdf0e10cSrcweir return 0; 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir void SdrGluePoint::SetAlignAngle(long nWink) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir nWink=NormAngle360(nWink); 152*cdf0e10cSrcweir if (nWink>=33750 || nWink<2250) nAlign=SDRHORZALIGN_RIGHT |SDRVERTALIGN_CENTER; 153*cdf0e10cSrcweir else if (nWink< 6750) nAlign=SDRHORZALIGN_RIGHT |SDRVERTALIGN_TOP ; 154*cdf0e10cSrcweir else if (nWink<11250) nAlign=SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP ; 155*cdf0e10cSrcweir else if (nWink<15750) nAlign=SDRHORZALIGN_LEFT |SDRVERTALIGN_TOP ; 156*cdf0e10cSrcweir else if (nWink<20250) nAlign=SDRHORZALIGN_LEFT |SDRVERTALIGN_CENTER; 157*cdf0e10cSrcweir else if (nWink<24750) nAlign=SDRHORZALIGN_LEFT |SDRVERTALIGN_BOTTOM; 158*cdf0e10cSrcweir else if (nWink<29250) nAlign=SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM; 159*cdf0e10cSrcweir else if (nWink<33750) nAlign=SDRHORZALIGN_RIGHT |SDRVERTALIGN_BOTTOM; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir long SdrGluePoint::EscDirToAngle(sal_uInt16 nEsc) const 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir switch (nEsc) { 165*cdf0e10cSrcweir case SDRESC_RIGHT : return 0; 166*cdf0e10cSrcweir case SDRESC_TOP : return 9000; 167*cdf0e10cSrcweir case SDRESC_LEFT : return 18000; 168*cdf0e10cSrcweir case SDRESC_BOTTOM: return 27000; 169*cdf0e10cSrcweir } // switch 170*cdf0e10cSrcweir return 0; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir sal_uInt16 SdrGluePoint::EscAngleToDir(long nWink) const 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir nWink=NormAngle360(nWink); 176*cdf0e10cSrcweir if (nWink>=31500 || nWink<4500) return SDRESC_RIGHT; 177*cdf0e10cSrcweir if (nWink<13500) return SDRESC_TOP; 178*cdf0e10cSrcweir if (nWink<22500) return SDRESC_LEFT; 179*cdf0e10cSrcweir if (nWink<31500) return SDRESC_BOTTOM; 180*cdf0e10cSrcweir return 0; 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir void SdrGluePoint::Rotate(const Point& rRef, long nWink, double sn, double cs, const SdrObject* pObj) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos()); 186*cdf0e10cSrcweir RotatePoint(aPt,rRef,sn,cs); 187*cdf0e10cSrcweir // Bezugskante drehen 188*cdf0e10cSrcweir if(nAlign != (SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER)) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir SetAlignAngle(GetAlignAngle()+nWink); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir // Austrittsrichtungen drehen 193*cdf0e10cSrcweir sal_uInt16 nEscDir0=nEscDir; 194*cdf0e10cSrcweir sal_uInt16 nEscDir1=0; 195*cdf0e10cSrcweir if ((nEscDir0&SDRESC_LEFT )!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_LEFT )+nWink); 196*cdf0e10cSrcweir if ((nEscDir0&SDRESC_TOP )!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_TOP )+nWink); 197*cdf0e10cSrcweir if ((nEscDir0&SDRESC_RIGHT )!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_RIGHT )+nWink); 198*cdf0e10cSrcweir if ((nEscDir0&SDRESC_BOTTOM)!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_BOTTOM)+nWink); 199*cdf0e10cSrcweir nEscDir=nEscDir1; 200*cdf0e10cSrcweir if (pObj!=NULL) SetAbsolutePos(aPt,*pObj); else SetPos(aPt); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir void SdrGluePoint::Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir Point aPt(rRef2); aPt-=rRef1; 206*cdf0e10cSrcweir long nWink=GetAngle(aPt); 207*cdf0e10cSrcweir Mirror(rRef1,rRef2,nWink,pObj); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir void SdrGluePoint::Mirror(const Point& rRef1, const Point& rRef2, long nWink, const SdrObject* pObj) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos()); 213*cdf0e10cSrcweir MirrorPoint(aPt,rRef1,rRef2); 214*cdf0e10cSrcweir // Bezugskante spiegeln 215*cdf0e10cSrcweir if(nAlign != (SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER)) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir long nAW=GetAlignAngle(); 218*cdf0e10cSrcweir nAW+=2*(nWink-nAW); 219*cdf0e10cSrcweir SetAlignAngle(nAW); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir // Austrittsrichtungen spiegeln 222*cdf0e10cSrcweir sal_uInt16 nEscDir0=nEscDir; 223*cdf0e10cSrcweir sal_uInt16 nEscDir1=0; 224*cdf0e10cSrcweir if ((nEscDir0&SDRESC_LEFT)!=0) { 225*cdf0e10cSrcweir long nEW=EscDirToAngle(SDRESC_LEFT); 226*cdf0e10cSrcweir nEW+=2*(nWink-nEW); 227*cdf0e10cSrcweir nEscDir1|=EscAngleToDir(nEW); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir if ((nEscDir0&SDRESC_TOP)!=0) { 230*cdf0e10cSrcweir long nEW=EscDirToAngle(SDRESC_TOP); 231*cdf0e10cSrcweir nEW+=2*(nWink-nEW); 232*cdf0e10cSrcweir nEscDir1|=EscAngleToDir(nEW); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir if ((nEscDir0&SDRESC_RIGHT)!=0) { 235*cdf0e10cSrcweir long nEW=EscDirToAngle(SDRESC_RIGHT); 236*cdf0e10cSrcweir nEW+=2*(nWink-nEW); 237*cdf0e10cSrcweir nEscDir1|=EscAngleToDir(nEW); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir if ((nEscDir0&SDRESC_BOTTOM)!=0) { 240*cdf0e10cSrcweir long nEW=EscDirToAngle(SDRESC_BOTTOM); 241*cdf0e10cSrcweir nEW+=2*(nWink-nEW); 242*cdf0e10cSrcweir nEscDir1|=EscAngleToDir(nEW); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir nEscDir=nEscDir1; 245*cdf0e10cSrcweir if (pObj!=NULL) SetAbsolutePos(aPt,*pObj); else SetPos(aPt); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir void SdrGluePoint::Shear(const Point& rRef, long /*nWink*/, double tn, FASTBOOL bVShear, const SdrObject* pObj) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos()); 251*cdf0e10cSrcweir ShearPoint(aPt,rRef,tn,bVShear); 252*cdf0e10cSrcweir if (pObj!=NULL) SetAbsolutePos(aPt,*pObj); else SetPos(aPt); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir void SdrGluePoint::Draw(OutputDevice& rOut, const SdrObject* pObj) const 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir Color aBackPenColor(COL_WHITE); 258*cdf0e10cSrcweir Color aForePenColor(COL_LIGHTBLUE); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir bool bMapMerk=rOut.IsMapModeEnabled(); 261*cdf0e10cSrcweir Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos()); 262*cdf0e10cSrcweir aPt=rOut.LogicToPixel(aPt); 263*cdf0e10cSrcweir rOut.EnableMapMode(sal_False); 264*cdf0e10cSrcweir long x=aPt.X(),y=aPt.Y(); // Groesse erstmal fest auf 7 Pixel 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir rOut.SetLineColor( aBackPenColor ); 267*cdf0e10cSrcweir rOut.DrawLine(Point(x-2,y-3),Point(x+3,y+2)); 268*cdf0e10cSrcweir rOut.DrawLine(Point(x-3,y-2),Point(x+2,y+3)); 269*cdf0e10cSrcweir rOut.DrawLine(Point(x-3,y+2),Point(x+2,y-3)); 270*cdf0e10cSrcweir rOut.DrawLine(Point(x-2,y+3),Point(x+3,y-2)); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir if (bNoPercent) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir switch (GetHorzAlign()) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir case SDRHORZALIGN_LEFT : rOut.DrawLine(Point(x-3,y-1),Point(x-3,y+1)); break; 277*cdf0e10cSrcweir case SDRHORZALIGN_RIGHT : rOut.DrawLine(Point(x+3,y-1),Point(x+3,y+1)); break; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir switch (GetVertAlign()) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir case SDRVERTALIGN_TOP : rOut.DrawLine(Point(x-1,y-3),Point(x+1,y-3)); break; 283*cdf0e10cSrcweir case SDRVERTALIGN_BOTTOM: rOut.DrawLine(Point(x-1,y+3),Point(x+1,y+3)); break; 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir rOut.SetLineColor( aForePenColor ); 288*cdf0e10cSrcweir rOut.DrawLine(Point(x-2,y-2),Point(x+2,y+2)); 289*cdf0e10cSrcweir rOut.DrawLine(Point(x-2,y+2),Point(x+2,y-2)); 290*cdf0e10cSrcweir rOut.EnableMapMode(bMapMerk); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir void SdrGluePoint::Invalidate(Window& rWin, const SdrObject* pObj) const 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir bool bMapMerk=rWin.IsMapModeEnabled(); 296*cdf0e10cSrcweir Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos()); 297*cdf0e10cSrcweir aPt=rWin.LogicToPixel(aPt); 298*cdf0e10cSrcweir rWin.EnableMapMode(sal_False); 299*cdf0e10cSrcweir long x=aPt.X(),y=aPt.Y(); // Groesse erstmal fest auf 7 Pixel 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir // #111096# 302*cdf0e10cSrcweir // do not erase background, that causes flicker (!) 303*cdf0e10cSrcweir rWin.Invalidate(Rectangle(Point(x-3,y-3),Point(x+3,y+3)), INVALIDATE_NOERASE); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir rWin.EnableMapMode(bMapMerk); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir FASTBOOL SdrGluePoint::IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos()); 311*cdf0e10cSrcweir Size aSiz=rOut.PixelToLogic(Size(3,3)); 312*cdf0e10cSrcweir Rectangle aRect(aPt.X()-aSiz.Width(),aPt.Y()-aSiz.Height(),aPt.X()+aSiz.Width(),aPt.Y()+aSiz.Height()); 313*cdf0e10cSrcweir return aRect.IsInside(rPnt); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir void SdrGluePointList::Clear() 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 321*cdf0e10cSrcweir for (sal_uInt16 i=0; i<nAnz; i++) { 322*cdf0e10cSrcweir delete GetObject(i); 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir aList.Clear(); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir void SdrGluePointList::operator=(const SdrGluePointList& rSrcList) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir if (GetCount()!=0) Clear(); 330*cdf0e10cSrcweir sal_uInt16 nAnz=rSrcList.GetCount(); 331*cdf0e10cSrcweir for (sal_uInt16 i=0; i<nAnz; i++) { 332*cdf0e10cSrcweir Insert(rSrcList[i]); 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir // Die Id's der Klebepunkte in der Liste sind stets streng monoton steigend! 337*cdf0e10cSrcweir // Ggf. wird dem neuen Klebepunkt eine neue Id zugewiesen (wenn diese bereits 338*cdf0e10cSrcweir // vergeben ist). Die Id 0 ist reserviert. 339*cdf0e10cSrcweir sal_uInt16 SdrGluePointList::Insert(const SdrGluePoint& rGP) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir SdrGluePoint* pGP=new SdrGluePoint(rGP); 342*cdf0e10cSrcweir sal_uInt16 nId=pGP->GetId(); 343*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 344*cdf0e10cSrcweir sal_uInt16 nInsPos=nAnz; 345*cdf0e10cSrcweir sal_uInt16 nLastId=nAnz!=0 ? GetObject(nAnz-1)->GetId() : 0; 346*cdf0e10cSrcweir DBG_ASSERT(nLastId>=nAnz,"SdrGluePointList::Insert(): nLastId<nAnz"); 347*cdf0e10cSrcweir FASTBOOL bHole=nLastId>nAnz; 348*cdf0e10cSrcweir if (nId<=nLastId) { 349*cdf0e10cSrcweir if (!bHole || nId==0) { 350*cdf0e10cSrcweir nId=nLastId+1; 351*cdf0e10cSrcweir } else { 352*cdf0e10cSrcweir FASTBOOL bBrk=sal_False; 353*cdf0e10cSrcweir for (sal_uInt16 nNum=0; nNum<nAnz && !bBrk; nNum++) { 354*cdf0e10cSrcweir const SdrGluePoint* pGP2=GetObject(nNum); 355*cdf0e10cSrcweir sal_uInt16 nTmpId=pGP2->GetId(); 356*cdf0e10cSrcweir if (nTmpId==nId) { 357*cdf0e10cSrcweir nId=nLastId+1; // bereits vorhanden 358*cdf0e10cSrcweir bBrk=sal_True; 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir if (nTmpId>nId) { 361*cdf0e10cSrcweir nInsPos=nNum; // Hier einfuegen (einsortieren) 362*cdf0e10cSrcweir bBrk=sal_True; 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir pGP->SetId(nId); 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir aList.Insert(pGP,nInsPos); 369*cdf0e10cSrcweir return nInsPos; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir void SdrGluePointList::Invalidate(Window& rWin, const SdrObject* pObj) const 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 375*cdf0e10cSrcweir for (sal_uInt16 nNum=0; nNum<nAnz; nNum++) { 376*cdf0e10cSrcweir GetObject(nNum)->Invalidate(rWin,pObj); 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir sal_uInt16 SdrGluePointList::FindGluePoint(sal_uInt16 nId) const 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir // Hier noch einen optimaleren Suchalgorithmus implementieren. 383*cdf0e10cSrcweir // Die Liste sollte stets sortiert sein!!!! 384*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 385*cdf0e10cSrcweir sal_uInt16 nRet=SDRGLUEPOINT_NOTFOUND; 386*cdf0e10cSrcweir for (sal_uInt16 nNum=0; nNum<nAnz && nRet==SDRGLUEPOINT_NOTFOUND; nNum++) { 387*cdf0e10cSrcweir const SdrGluePoint* pGP=GetObject(nNum); 388*cdf0e10cSrcweir if (pGP->GetId()==nId) nRet=nNum; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir return nRet; 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir sal_uInt16 SdrGluePointList::HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj, FASTBOOL bBack, FASTBOOL bNext, sal_uInt16 nId0) const 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 396*cdf0e10cSrcweir sal_uInt16 nRet=SDRGLUEPOINT_NOTFOUND; 397*cdf0e10cSrcweir sal_uInt16 nNum=bBack ? 0 : nAnz; 398*cdf0e10cSrcweir while ((bBack ? nNum<nAnz : nNum>0) && nRet==SDRGLUEPOINT_NOTFOUND) { 399*cdf0e10cSrcweir if (!bBack) nNum--; 400*cdf0e10cSrcweir const SdrGluePoint* pGP=GetObject(nNum); 401*cdf0e10cSrcweir if (bNext) { 402*cdf0e10cSrcweir if (pGP->GetId()==nId0) bNext=sal_False; 403*cdf0e10cSrcweir } else { 404*cdf0e10cSrcweir if (pGP->IsHit(rPnt,rOut,pObj)) nRet=nNum; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir if (bBack) nNum++; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir return nRet; 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir void SdrGluePointList::SetReallyAbsolute(FASTBOOL bOn, const SdrObject& rObj) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 414*cdf0e10cSrcweir for (sal_uInt16 nNum=0; nNum<nAnz; nNum++) { 415*cdf0e10cSrcweir GetObject(nNum)->SetReallyAbsolute(bOn,rObj); 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir void SdrGluePointList::Rotate(const Point& rRef, long nWink, double sn, double cs, const SdrObject* pObj) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 422*cdf0e10cSrcweir for (sal_uInt16 nNum=0; nNum<nAnz; nNum++) { 423*cdf0e10cSrcweir GetObject(nNum)->Rotate(rRef,nWink,sn,cs,pObj); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir void SdrGluePointList::Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir Point aPt(rRef2); aPt-=rRef1; 430*cdf0e10cSrcweir long nWink=GetAngle(aPt); 431*cdf0e10cSrcweir Mirror(rRef1,rRef2,nWink,pObj); 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir void SdrGluePointList::Mirror(const Point& rRef1, const Point& rRef2, long nWink, const SdrObject* pObj) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 437*cdf0e10cSrcweir for (sal_uInt16 nNum=0; nNum<nAnz; nNum++) { 438*cdf0e10cSrcweir GetObject(nNum)->Mirror(rRef1,rRef2,nWink,pObj); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir void SdrGluePointList::Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear, const SdrObject* pObj) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir sal_uInt16 nAnz=GetCount(); 445*cdf0e10cSrcweir for (sal_uInt16 nNum=0; nNum<nAnz; nNum++) { 446*cdf0e10cSrcweir GetObject(nNum)->Shear(rRef,nWink,tn,bVShear,pObj); 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir // eof 451