xref: /aoo42x/main/svx/source/svdraw/svdsnpv.cxx (revision cdf0e10c)
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 
31*cdf0e10cSrcweir #include <svx/svdsnpv.hxx>
32*cdf0e10cSrcweir #include <math.h>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <svx/svdetc.hxx>
35*cdf0e10cSrcweir #include <svx/svdobj.hxx>
36*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
37*cdf0e10cSrcweir #include <svx/svdpage.hxx>
38*cdf0e10cSrcweir #include "svx/svditer.hxx"
39*cdf0e10cSrcweir #include <svx/sdr/overlay/overlayobjectlist.hxx>
40*cdf0e10cSrcweir #include <svx/sdr/overlay/overlaycrosshair.hxx>
41*cdf0e10cSrcweir #include <svx/sdr/overlay/overlayhelpline.hxx>
42*cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx>
43*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
44*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
47*cdf0e10cSrcweir // #114409#-1 Migrate PageOrigin
48*cdf0e10cSrcweir class ImplPageOriginOverlay
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 	// The OverlayObjects
51*cdf0e10cSrcweir 	::sdr::overlay::OverlayObjectList				maObjects;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 	// The current position in logical coodinates
54*cdf0e10cSrcweir 	basegfx::B2DPoint								maPosition;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir public:
57*cdf0e10cSrcweir 	ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos);
58*cdf0e10cSrcweir 	~ImplPageOriginOverlay();
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	void SetPosition(const basegfx::B2DPoint& rNewPosition);
61*cdf0e10cSrcweir };
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir ImplPageOriginOverlay::ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos)
64*cdf0e10cSrcweir :	maPosition(rStartPos)
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir 	for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
67*cdf0e10cSrcweir 	{
68*cdf0e10cSrcweir 		SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
69*cdf0e10cSrcweir 		::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 		if(pTargetOverlay)
72*cdf0e10cSrcweir 		{
73*cdf0e10cSrcweir 			::sdr::overlay::OverlayCrosshairStriped* aNew = new ::sdr::overlay::OverlayCrosshairStriped(
74*cdf0e10cSrcweir 				maPosition);
75*cdf0e10cSrcweir 			pTargetOverlay->add(*aNew);
76*cdf0e10cSrcweir 			maObjects.append(*aNew);
77*cdf0e10cSrcweir 		}
78*cdf0e10cSrcweir 	}
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir ImplPageOriginOverlay::~ImplPageOriginOverlay()
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir 	// The OverlayObjects are cleared using the destructor of OverlayObjectList.
84*cdf0e10cSrcweir 	// That destructor calls clear() at the list which removes all objects from the
85*cdf0e10cSrcweir 	// OverlayManager and deletes them.
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir void ImplPageOriginOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir 	if(rNewPosition != maPosition)
91*cdf0e10cSrcweir 	{
92*cdf0e10cSrcweir 		// apply to OverlayObjects
93*cdf0e10cSrcweir 		for(sal_uInt32 a(0); a < maObjects.count(); a++)
94*cdf0e10cSrcweir 		{
95*cdf0e10cSrcweir 			sdr::overlay::OverlayCrosshairStriped* pCandidate =
96*cdf0e10cSrcweir 				static_cast< sdr::overlay::OverlayCrosshairStriped* >(&maObjects.getOverlayObject(a));
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 			if(pCandidate)
99*cdf0e10cSrcweir 			{
100*cdf0e10cSrcweir 				pCandidate->setBasePosition(rNewPosition);
101*cdf0e10cSrcweir 			}
102*cdf0e10cSrcweir 		}
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 		// remember new position
105*cdf0e10cSrcweir 		maPosition = rNewPosition;
106*cdf0e10cSrcweir 	}
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
110*cdf0e10cSrcweir // #114409#-2 Migrate HelpLine
111*cdf0e10cSrcweir class ImplHelpLineOverlay
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	// The OverlayObjects
114*cdf0e10cSrcweir 	::sdr::overlay::OverlayObjectList				maObjects;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	// The current position in logical coodinates
117*cdf0e10cSrcweir 	basegfx::B2DPoint								maPosition;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	// HelpLine specific stuff
120*cdf0e10cSrcweir 	SdrPageView*									mpPageView;
121*cdf0e10cSrcweir 	sal_uInt16										mnHelpLineNumber;
122*cdf0e10cSrcweir 	SdrHelpLineKind									meHelpLineKind;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir public:
125*cdf0e10cSrcweir 	ImplHelpLineOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
126*cdf0e10cSrcweir 		SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind);
127*cdf0e10cSrcweir 	~ImplHelpLineOverlay();
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	void SetPosition(const basegfx::B2DPoint& rNewPosition);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	// access to HelpLine specific stuff
132*cdf0e10cSrcweir 	SdrPageView* GetPageView() const { return mpPageView; }
133*cdf0e10cSrcweir 	sal_uInt16 GetHelpLineNumber() const { return mnHelpLineNumber; }
134*cdf0e10cSrcweir 	SdrHelpLineKind GetHelpLineKind() const { return meHelpLineKind; }
135*cdf0e10cSrcweir };
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir ImplHelpLineOverlay::ImplHelpLineOverlay(
138*cdf0e10cSrcweir 	const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
139*cdf0e10cSrcweir 	SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind)
140*cdf0e10cSrcweir :	maPosition(rStartPos),
141*cdf0e10cSrcweir 	mpPageView(pPageView),
142*cdf0e10cSrcweir 	mnHelpLineNumber(nHelpLineNumber),
143*cdf0e10cSrcweir 	meHelpLineKind(eKind)
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
146*cdf0e10cSrcweir 	{
147*cdf0e10cSrcweir 		SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
148*cdf0e10cSrcweir 		::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 		if(pTargetOverlay)
151*cdf0e10cSrcweir 		{
152*cdf0e10cSrcweir 			::sdr::overlay::OverlayHelplineStriped* aNew = new ::sdr::overlay::OverlayHelplineStriped(
153*cdf0e10cSrcweir 				maPosition, meHelpLineKind);
154*cdf0e10cSrcweir 			pTargetOverlay->add(*aNew);
155*cdf0e10cSrcweir 			maObjects.append(*aNew);
156*cdf0e10cSrcweir 		}
157*cdf0e10cSrcweir 	}
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir ImplHelpLineOverlay::~ImplHelpLineOverlay()
161*cdf0e10cSrcweir {
162*cdf0e10cSrcweir 	// The OverlayObjects are cleared using the destructor of OverlayObjectList.
163*cdf0e10cSrcweir 	// That destructor calls clear() at the list which removes all objects from the
164*cdf0e10cSrcweir 	// OverlayManager and deletes them.
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir void ImplHelpLineOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir 	if(rNewPosition != maPosition)
170*cdf0e10cSrcweir 	{
171*cdf0e10cSrcweir 		// apply to OverlayObjects
172*cdf0e10cSrcweir 		// apply to OverlayObjects
173*cdf0e10cSrcweir 		for(sal_uInt32 a(0); a < maObjects.count(); a++)
174*cdf0e10cSrcweir 		{
175*cdf0e10cSrcweir 			sdr::overlay::OverlayHelplineStriped* pCandidate =
176*cdf0e10cSrcweir 				static_cast< sdr::overlay::OverlayHelplineStriped* >(&maObjects.getOverlayObject(a));
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 			if(pCandidate)
179*cdf0e10cSrcweir 			{
180*cdf0e10cSrcweir 				pCandidate->setBasePosition(rNewPosition);
181*cdf0e10cSrcweir 			}
182*cdf0e10cSrcweir 		}
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 		// remember new position
185*cdf0e10cSrcweir 		maPosition = rNewPosition;
186*cdf0e10cSrcweir 	}
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
190*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
191*cdf0e10cSrcweir //
192*cdf0e10cSrcweir //  @@@@  @@  @@  @@@@  @@@@@   @@ @@ @@ @@@@@ @@   @@
193*cdf0e10cSrcweir // @@  @@ @@@ @@ @@  @@ @@  @@  @@ @@ @@ @@    @@   @@
194*cdf0e10cSrcweir // @@     @@@@@@ @@  @@ @@  @@  @@ @@ @@ @@    @@ @ @@
195*cdf0e10cSrcweir //  @@@@  @@@@@@ @@@@@@ @@@@@   @@@@@ @@ @@@@  @@@@@@@
196*cdf0e10cSrcweir //     @@ @@ @@@ @@  @@ @@       @@@  @@ @@    @@@@@@@
197*cdf0e10cSrcweir // @@  @@ @@  @@ @@  @@ @@       @@@  @@ @@    @@@ @@@
198*cdf0e10cSrcweir //  @@@@  @@  @@ @@  @@ @@        @   @@ @@@@@ @@   @@
199*cdf0e10cSrcweir //
200*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
201*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir void SdrSnapView::ClearVars()
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir 	nMagnSizPix=4;
206*cdf0e10cSrcweir 	bSnapEnab=sal_True;
207*cdf0e10cSrcweir 	bGridSnap=sal_True;
208*cdf0e10cSrcweir 	bSnapTo1Pix=sal_True;
209*cdf0e10cSrcweir 	bBordSnap=sal_True;
210*cdf0e10cSrcweir 	bHlplSnap=sal_True;
211*cdf0e10cSrcweir 	bOFrmSnap=sal_True;
212*cdf0e10cSrcweir 	bOPntSnap=sal_False;
213*cdf0e10cSrcweir 	bOConSnap=sal_True;
214*cdf0e10cSrcweir 	bMoveMFrmSnap=sal_True;
215*cdf0e10cSrcweir 	bMoveOFrmSnap=sal_True;
216*cdf0e10cSrcweir 	bMoveOPntSnap=sal_True;
217*cdf0e10cSrcweir 	bMoveOConSnap=sal_True;
218*cdf0e10cSrcweir 	bMoveSnapOnlyTopLeft=sal_False;
219*cdf0e10cSrcweir 	bOrtho=sal_False;
220*cdf0e10cSrcweir 	bBigOrtho=sal_True;
221*cdf0e10cSrcweir 	nSnapAngle=1500;
222*cdf0e10cSrcweir 	bAngleSnapEnab=sal_False;
223*cdf0e10cSrcweir 	bMoveOnlyDragging=sal_False;
224*cdf0e10cSrcweir 	bSlantButShear=sal_False;
225*cdf0e10cSrcweir 	bCrookNoContortion=sal_False;
226*cdf0e10cSrcweir 	eCrookMode=SDRCROOK_ROTATE;
227*cdf0e10cSrcweir 	bHlplFixed=sal_False;
228*cdf0e10cSrcweir 	bEliminatePolyPoints=sal_False;
229*cdf0e10cSrcweir 	nEliminatePolyPointLimitAngle=0;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	// #114409#-1 Migrate PageOrigin
232*cdf0e10cSrcweir 	BrkSetPageOrg();
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 	// #114409#-2 Migrate HelpLine
235*cdf0e10cSrcweir 	BrkDragHelpLine();
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir SdrSnapView::SdrSnapView(SdrModel* pModel1, OutputDevice* pOut):
239*cdf0e10cSrcweir 	SdrPaintView(pModel1,pOut),
240*cdf0e10cSrcweir 	// #114409#-1 Migrate PageOrigin
241*cdf0e10cSrcweir 	mpPageOriginOverlay(0L),
242*cdf0e10cSrcweir 	// #114409#-2 Migrate HelpLine
243*cdf0e10cSrcweir 	mpHelpLineOverlay(0L)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	ClearVars();
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir // #114409#-1 Migrate PageOrigin
249*cdf0e10cSrcweir SdrSnapView::~SdrSnapView()
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir 	// #114409#-1 Migrate PageOrigin
252*cdf0e10cSrcweir 	BrkSetPageOrg();
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	// #114409#-2 Migrate HelpLine
255*cdf0e10cSrcweir 	BrkDragHelpLine();
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir sal_Bool SdrSnapView::IsAction() const
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir 	return IsSetPageOrg() || IsDragHelpLine() || SdrPaintView::IsAction();
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir void SdrSnapView::MovAction(const Point& rPnt)
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir 	SdrPaintView::MovAction(rPnt);
268*cdf0e10cSrcweir 	if (IsSetPageOrg()) {
269*cdf0e10cSrcweir 		MovSetPageOrg(rPnt);
270*cdf0e10cSrcweir 	}
271*cdf0e10cSrcweir 	if (IsDragHelpLine()) {
272*cdf0e10cSrcweir 		MovDragHelpLine(rPnt);
273*cdf0e10cSrcweir 	}
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir void SdrSnapView::EndAction()
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir 	if (IsSetPageOrg()) {
279*cdf0e10cSrcweir 		EndSetPageOrg();
280*cdf0e10cSrcweir 	}
281*cdf0e10cSrcweir 	if (IsDragHelpLine()) {
282*cdf0e10cSrcweir 		EndDragHelpLine();
283*cdf0e10cSrcweir 	}
284*cdf0e10cSrcweir 	SdrPaintView::EndAction();
285*cdf0e10cSrcweir }
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir void SdrSnapView::BckAction()
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir 	BrkSetPageOrg();
290*cdf0e10cSrcweir 	BrkDragHelpLine();
291*cdf0e10cSrcweir 	SdrPaintView::BckAction();
292*cdf0e10cSrcweir }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir void SdrSnapView::BrkAction()
295*cdf0e10cSrcweir {
296*cdf0e10cSrcweir 	BrkSetPageOrg();
297*cdf0e10cSrcweir 	BrkDragHelpLine();
298*cdf0e10cSrcweir 	SdrPaintView::BrkAction();
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir void SdrSnapView::TakeActionRect(Rectangle& rRect) const
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir 	if (IsSetPageOrg() || IsDragHelpLine()) {
304*cdf0e10cSrcweir 		rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
305*cdf0e10cSrcweir 	} else {
306*cdf0e10cSrcweir 		SdrPaintView::TakeActionRect(rRect);
307*cdf0e10cSrcweir 	}
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir Point SdrSnapView::GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const
313*cdf0e10cSrcweir {
314*cdf0e10cSrcweir 	Point aPt(rPnt);
315*cdf0e10cSrcweir 	SnapPos(aPt,pPV);
316*cdf0e10cSrcweir 	return aPt;
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir #define NOT_SNAPPED 0x7FFFFFFF
320*cdf0e10cSrcweir sal_uInt16 SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	if (!bSnapEnab) return SDRSNAP_NOTSNAPPED;
323*cdf0e10cSrcweir 	sal_Bool bPVOfs=sal_False;
324*cdf0e10cSrcweir 	long x=rPnt.X();
325*cdf0e10cSrcweir 	long y=rPnt.Y();
326*cdf0e10cSrcweir 	if (pPV==NULL) {
327*cdf0e10cSrcweir 		bPVOfs=sal_True;
328*cdf0e10cSrcweir 		pPV=GetSdrPageView();
329*cdf0e10cSrcweir 		if (pPV==NULL) return SDRSNAP_NOTSNAPPED;
330*cdf0e10cSrcweir 	}
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir 	long dx=NOT_SNAPPED;
333*cdf0e10cSrcweir 	long dy=NOT_SNAPPED;
334*cdf0e10cSrcweir 	long dx1,dy1;
335*cdf0e10cSrcweir 	long mx=aMagnSiz.Width();
336*cdf0e10cSrcweir 	long my=aMagnSiz.Height();
337*cdf0e10cSrcweir 	if (bHlplVisible && bHlplSnap && !IsDragHelpLine())
338*cdf0e10cSrcweir 	{
339*cdf0e10cSrcweir 		const SdrHelpLineList& rHLL=pPV->GetHelpLines();
340*cdf0e10cSrcweir 		sal_uInt16 nAnz=rHLL.GetCount();
341*cdf0e10cSrcweir 		for (sal_uInt16 i=nAnz; i>0;) {
342*cdf0e10cSrcweir 			i--;
343*cdf0e10cSrcweir 			const SdrHelpLine& rHL=rHLL[i];
344*cdf0e10cSrcweir 			const Point& rPos=rHL.GetPos();
345*cdf0e10cSrcweir 			switch (rHL.GetKind()) {
346*cdf0e10cSrcweir 				case SDRHELPLINE_VERTICAL: {
347*cdf0e10cSrcweir 					long a=x-rPos.X();
348*cdf0e10cSrcweir 					if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; }
349*cdf0e10cSrcweir 				} break;
350*cdf0e10cSrcweir 				case SDRHELPLINE_HORIZONTAL: {
351*cdf0e10cSrcweir 					long b=y-rPos.Y();
352*cdf0e10cSrcweir 					if (Abs(b)<=my) { dy1=-b; if (Abs(dy1)<Abs(dy)) dy=dy1; }
353*cdf0e10cSrcweir 				} break;
354*cdf0e10cSrcweir 				case SDRHELPLINE_POINT: {
355*cdf0e10cSrcweir 					long a=x-rPos.X();
356*cdf0e10cSrcweir 					long b=y-rPos.Y();
357*cdf0e10cSrcweir 					if (Abs(a)<=mx && Abs(b)<=my) {
358*cdf0e10cSrcweir 						dx1=-a; dy1=-b;
359*cdf0e10cSrcweir 						if (Abs(dx1)<Abs(dx) && Abs(dy1)<Abs(dy)) { dx=dx1; dy=dy1; }
360*cdf0e10cSrcweir 					}
361*cdf0e10cSrcweir 				} break;
362*cdf0e10cSrcweir 			} // switch
363*cdf0e10cSrcweir 		}
364*cdf0e10cSrcweir 	}
365*cdf0e10cSrcweir 	if (bBordVisible && bBordSnap) {
366*cdf0e10cSrcweir 		SdrPage* pPage=pPV->GetPage();
367*cdf0e10cSrcweir 		long xs=pPage->GetWdt();
368*cdf0e10cSrcweir 		long ys=pPage->GetHgt();
369*cdf0e10cSrcweir 		long lft=pPage->GetLftBorder();
370*cdf0e10cSrcweir 		long rgt=pPage->GetRgtBorder();
371*cdf0e10cSrcweir 		long upp=pPage->GetUppBorder();
372*cdf0e10cSrcweir 		long lwr=pPage->GetLwrBorder();
373*cdf0e10cSrcweir 		long a;
374*cdf0e10cSrcweir 		a=x- lft    ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // linker Rand
375*cdf0e10cSrcweir 		a=x-(xs-rgt); if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // rechter Rand
376*cdf0e10cSrcweir 		a=x         ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // linke Papierkante
377*cdf0e10cSrcweir 		a=x- xs     ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // rechte Papierkante
378*cdf0e10cSrcweir 		a=y- upp    ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // linker Rand
379*cdf0e10cSrcweir 		a=y-(ys-lwr); if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // rechter Rand
380*cdf0e10cSrcweir 		a=y         ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // linke Papierkante
381*cdf0e10cSrcweir 		a=y- ys     ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // rechte Papierkante
382*cdf0e10cSrcweir 	}
383*cdf0e10cSrcweir 	if (bOFrmSnap || bOPntSnap /*|| (bConnVisible && bOConSnap)*/) {
384*cdf0e10cSrcweir 		sal_uIntPtr nMaxPointSnapCount=200;
385*cdf0e10cSrcweir 		sal_uIntPtr nMaxFrameSnapCount=200;
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 		// #97981# go back to IM_DEEPNOGROUPS runthrough for snap to object comparisons
388*cdf0e10cSrcweir 		SdrObjListIter aIter(*pPV->GetPage(),/*IM_FLAT*/IM_DEEPNOGROUPS,sal_True);
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 		while (aIter.IsMore() && (nMaxPointSnapCount>0 || nMaxFrameSnapCount>0)) {
391*cdf0e10cSrcweir 			SdrObject* pO=aIter.Next();
392*cdf0e10cSrcweir 			Rectangle aRect(pO->GetCurrentBoundRect());
393*cdf0e10cSrcweir 			aRect.Left  ()-=mx;
394*cdf0e10cSrcweir 			aRect.Right ()+=mx;
395*cdf0e10cSrcweir 			aRect.Top   ()-=my;
396*cdf0e10cSrcweir 			aRect.Bottom()+=my;
397*cdf0e10cSrcweir 			if (aRect.IsInside(rPnt)) {
398*cdf0e10cSrcweir 				if (bOPntSnap && nMaxPointSnapCount>0)
399*cdf0e10cSrcweir 				{
400*cdf0e10cSrcweir 					sal_uInt32 nAnz(pO->GetSnapPointCount());
401*cdf0e10cSrcweir 					for (sal_uInt32 i(0L); i < nAnz && nMaxPointSnapCount > 0L; i++)
402*cdf0e10cSrcweir 					{
403*cdf0e10cSrcweir 						Point aP(pO->GetSnapPoint(i));
404*cdf0e10cSrcweir 						dx1=x-aP.X();
405*cdf0e10cSrcweir 						dy1=y-aP.Y();
406*cdf0e10cSrcweir 						if (Abs(dx1)<=mx && Abs(dy1)<=my && Abs(dx1)<Abs(dx) && Abs(dy1)<Abs(dy)) {
407*cdf0e10cSrcweir 							dx=-dx1;
408*cdf0e10cSrcweir 							dy=-dy1;
409*cdf0e10cSrcweir 						}
410*cdf0e10cSrcweir 						nMaxPointSnapCount--;
411*cdf0e10cSrcweir 					}
412*cdf0e10cSrcweir 				}
413*cdf0e10cSrcweir 				if (bOFrmSnap && nMaxFrameSnapCount>0) {
414*cdf0e10cSrcweir 					Rectangle aLog(pO->GetSnapRect());
415*cdf0e10cSrcweir 					Rectangle aR1(aLog);
416*cdf0e10cSrcweir 					aR1.Left  ()-=mx;
417*cdf0e10cSrcweir 					aR1.Right ()+=mx;
418*cdf0e10cSrcweir 					aR1.Top   ()-=my;
419*cdf0e10cSrcweir 					aR1.Bottom()+=my;
420*cdf0e10cSrcweir 					if (aR1.IsInside(rPnt)) {
421*cdf0e10cSrcweir 						if (Abs(x-aLog.Left  ())<=mx) { dx1=-(x-aLog.Left  ()); if (Abs(dx1)<Abs(dx)) dx=dx1; }
422*cdf0e10cSrcweir 						if (Abs(x-aLog.Right ())<=mx) { dx1=-(x-aLog.Right ()); if (Abs(dx1)<Abs(dx)) dx=dx1; }
423*cdf0e10cSrcweir 						if (Abs(y-aLog.Top   ())<=my) { dy1=-(y-aLog.Top   ()); if (Abs(dy1)<Abs(dy)) dy=dy1; }
424*cdf0e10cSrcweir 						if (Abs(y-aLog.Bottom())<=my) { dy1=-(y-aLog.Bottom()); if (Abs(dy1)<Abs(dy)) dy=dy1; }
425*cdf0e10cSrcweir 					}
426*cdf0e10cSrcweir 					nMaxFrameSnapCount--;
427*cdf0e10cSrcweir 				}
428*cdf0e10cSrcweir 			}
429*cdf0e10cSrcweir 		}
430*cdf0e10cSrcweir 	}
431*cdf0e10cSrcweir 	if(bGridSnap)
432*cdf0e10cSrcweir 	{
433*cdf0e10cSrcweir 		double fSnapWidth = aSnapWdtX;
434*cdf0e10cSrcweir 		if(dx == NOT_SNAPPED && fSnapWidth != 0.0)
435*cdf0e10cSrcweir 		{
436*cdf0e10cSrcweir 			double fx = (double)x;
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 			// round statt trunc
439*cdf0e10cSrcweir 			if(fx - (double)pPV->GetPageOrigin().X() >= 0.0)
440*cdf0e10cSrcweir 				fx += fSnapWidth / 2.0;
441*cdf0e10cSrcweir 			else
442*cdf0e10cSrcweir 				fx -= fSnapWidth / 2.0;
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 			x = (long)((fx - (double)pPV->GetPageOrigin().X()) / fSnapWidth);
445*cdf0e10cSrcweir 			x = (long)((double)x * fSnapWidth + (double)pPV->GetPageOrigin().X());
446*cdf0e10cSrcweir 			dx = 0;
447*cdf0e10cSrcweir 		}
448*cdf0e10cSrcweir 		fSnapWidth = aSnapWdtY;
449*cdf0e10cSrcweir 		if(dy == NOT_SNAPPED && fSnapWidth)
450*cdf0e10cSrcweir 		{
451*cdf0e10cSrcweir 			double fy = (double)y;
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 			// round statt trunc
454*cdf0e10cSrcweir 			if(fy - (double)pPV->GetPageOrigin().Y() >= 0.0)
455*cdf0e10cSrcweir 				fy += fSnapWidth / 2.0;
456*cdf0e10cSrcweir 			else
457*cdf0e10cSrcweir 				fy -= fSnapWidth / 2.0;
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 			y = (long)((fy - (double)pPV->GetPageOrigin().Y()) / fSnapWidth);
460*cdf0e10cSrcweir 			y = (long)((double)y * fSnapWidth + (double)pPV->GetPageOrigin().Y());
461*cdf0e10cSrcweir 			dy = 0;
462*cdf0e10cSrcweir 		}
463*cdf0e10cSrcweir 	}
464*cdf0e10cSrcweir 	sal_Bool bRet=SDRSNAP_NOTSNAPPED;
465*cdf0e10cSrcweir 	if (dx==NOT_SNAPPED) dx=0; else bRet|=SDRSNAP_XSNAPPED;
466*cdf0e10cSrcweir 	if (dy==NOT_SNAPPED) dy=0; else bRet|=SDRSNAP_YSNAPPED;
467*cdf0e10cSrcweir 	rPnt.X()=x+dx;
468*cdf0e10cSrcweir 	rPnt.Y()=y+dy;
469*cdf0e10cSrcweir 	return bRet;
470*cdf0e10cSrcweir }
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const
473*cdf0e10cSrcweir {
474*cdf0e10cSrcweir 	Point aPt(rPt);
475*cdf0e10cSrcweir 	sal_uInt16 nRet=SnapPos(aPt,pPV);
476*cdf0e10cSrcweir 	aPt-=rPt;
477*cdf0e10cSrcweir 	if ((nRet & SDRSNAP_XSNAPPED) !=0) {
478*cdf0e10cSrcweir 		if (bXSnapped) {
479*cdf0e10cSrcweir 			if (Abs(aPt.X())<Abs(nBestXSnap)) {
480*cdf0e10cSrcweir 				nBestXSnap=aPt.X();
481*cdf0e10cSrcweir 			}
482*cdf0e10cSrcweir 		} else {
483*cdf0e10cSrcweir 			nBestXSnap=aPt.X();
484*cdf0e10cSrcweir 			bXSnapped=sal_True;
485*cdf0e10cSrcweir 		}
486*cdf0e10cSrcweir 	}
487*cdf0e10cSrcweir 	if ((nRet & SDRSNAP_YSNAPPED) !=0) {
488*cdf0e10cSrcweir 		if (bYSnapped) {
489*cdf0e10cSrcweir 			if (Abs(aPt.Y())<Abs(nBestYSnap)) {
490*cdf0e10cSrcweir 				nBestYSnap=aPt.Y();
491*cdf0e10cSrcweir 			}
492*cdf0e10cSrcweir 		} else {
493*cdf0e10cSrcweir 			nBestYSnap=aPt.Y();
494*cdf0e10cSrcweir 			bYSnapped=sal_True;
495*cdf0e10cSrcweir 		}
496*cdf0e10cSrcweir 	}
497*cdf0e10cSrcweir }
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir sal_uInt16 SdrSnapView::SnapRect(const Rectangle& rRect, const SdrPageView* pPV, long& rDX, long& rDY) const
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir 	long nBestXSnap=0;
502*cdf0e10cSrcweir 	long nBestYSnap=0;
503*cdf0e10cSrcweir 	bool bXSnapped=sal_False;
504*cdf0e10cSrcweir 	bool bYSnapped=sal_False;
505*cdf0e10cSrcweir 	CheckSnap(rRect.TopLeft()    ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
506*cdf0e10cSrcweir 	if (!bMoveSnapOnlyTopLeft) {
507*cdf0e10cSrcweir 		CheckSnap(rRect.TopRight()   ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
508*cdf0e10cSrcweir 		CheckSnap(rRect.BottomLeft() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
509*cdf0e10cSrcweir 		CheckSnap(rRect.BottomRight(),pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
510*cdf0e10cSrcweir 	}
511*cdf0e10cSrcweir 	rDX=nBestXSnap;
512*cdf0e10cSrcweir 	rDY=nBestYSnap;
513*cdf0e10cSrcweir 	sal_uInt16 nRet=0;
514*cdf0e10cSrcweir 	if (bXSnapped) nRet+=SDRSNAP_XSNAPPED;
515*cdf0e10cSrcweir 	if (bYSnapped) nRet+=SDRSNAP_YSNAPPED;
516*cdf0e10cSrcweir 	return nRet;
517*cdf0e10cSrcweir }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir sal_Bool SdrSnapView::BegSetPageOrg(const Point& rPnt)
522*cdf0e10cSrcweir {
523*cdf0e10cSrcweir 	BrkAction();
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 	DBG_ASSERT(0L == mpPageOriginOverlay, "SdrSnapView::BegSetPageOrg: There exists a ImplPageOriginOverlay (!)");
526*cdf0e10cSrcweir 	basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
527*cdf0e10cSrcweir 	mpPageOriginOverlay = new ImplPageOriginOverlay(*this, aStartPos);
528*cdf0e10cSrcweir 	aDragStat.Reset(GetSnapPos(rPnt,NULL));
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 	return sal_True;
531*cdf0e10cSrcweir }
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir void SdrSnapView::MovSetPageOrg(const Point& rPnt)
534*cdf0e10cSrcweir {
535*cdf0e10cSrcweir 	if(IsSetPageOrg())
536*cdf0e10cSrcweir 	{
537*cdf0e10cSrcweir 		aDragStat.NextMove(GetSnapPos(rPnt,NULL));
538*cdf0e10cSrcweir 		DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
539*cdf0e10cSrcweir 		basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
540*cdf0e10cSrcweir 		mpPageOriginOverlay->SetPosition(aNewPos);
541*cdf0e10cSrcweir 	}
542*cdf0e10cSrcweir }
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir sal_Bool SdrSnapView::EndSetPageOrg()
545*cdf0e10cSrcweir {
546*cdf0e10cSrcweir 	sal_Bool bRet(sal_False);
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 	if(IsSetPageOrg())
549*cdf0e10cSrcweir 	{
550*cdf0e10cSrcweir 		SdrPageView* pPV = GetSdrPageView();
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir 		if(pPV)
553*cdf0e10cSrcweir 		{
554*cdf0e10cSrcweir 			Point aPnt(aDragStat.GetNow());
555*cdf0e10cSrcweir 			pPV->SetPageOrigin(aPnt);
556*cdf0e10cSrcweir 			bRet = sal_True;
557*cdf0e10cSrcweir 		}
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 		// cleanup
560*cdf0e10cSrcweir 		BrkSetPageOrg();
561*cdf0e10cSrcweir 	}
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir 	return bRet;
564*cdf0e10cSrcweir }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir void SdrSnapView::BrkSetPageOrg()
567*cdf0e10cSrcweir {
568*cdf0e10cSrcweir 	if(IsSetPageOrg())
569*cdf0e10cSrcweir 	{
570*cdf0e10cSrcweir 		DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
571*cdf0e10cSrcweir 		delete mpPageOriginOverlay;
572*cdf0e10cSrcweir 		mpPageOriginOverlay = 0L;
573*cdf0e10cSrcweir 	}
574*cdf0e10cSrcweir }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir sal_Bool SdrSnapView::PickHelpLine(const Point& rPnt, short nTol, const OutputDevice& rOut, sal_uInt16& rnHelpLineNum, SdrPageView*& rpPV) const
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir 	rpPV=NULL;
581*cdf0e10cSrcweir 	nTol=ImpGetHitTolLogic(nTol,&rOut);
582*cdf0e10cSrcweir 	SdrPageView* pPV = GetSdrPageView();
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 	if(pPV)
585*cdf0e10cSrcweir 	{
586*cdf0e10cSrcweir 		Point aPnt(rPnt);
587*cdf0e10cSrcweir 		sal_uInt16 nIndex=pPV->GetHelpLines().HitTest(aPnt,sal_uInt16(nTol),rOut);
588*cdf0e10cSrcweir 		if (nIndex!=SDRHELPLINE_NOTFOUND) {
589*cdf0e10cSrcweir 			rpPV=pPV;
590*cdf0e10cSrcweir 			rnHelpLineNum=nIndex;
591*cdf0e10cSrcweir 			return sal_True;
592*cdf0e10cSrcweir 		}
593*cdf0e10cSrcweir 	}
594*cdf0e10cSrcweir 	return sal_False;
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir // start HelpLine drag for new HelpLine
598*cdf0e10cSrcweir sal_Bool SdrSnapView::BegDragHelpLine(sal_uInt16 nHelpLineNum, SdrPageView* pPV)
599*cdf0e10cSrcweir {
600*cdf0e10cSrcweir 	sal_Bool bRet(sal_False);
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir 	if(!bHlplFixed)
603*cdf0e10cSrcweir 	{
604*cdf0e10cSrcweir 		BrkAction();
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir 		if(pPV && nHelpLineNum < pPV->GetHelpLines().GetCount())
607*cdf0e10cSrcweir 		{
608*cdf0e10cSrcweir 			const SdrHelpLineList& rHelpLines = pPV->GetHelpLines();
609*cdf0e10cSrcweir 			const SdrHelpLine& rHelpLine = rHelpLines[nHelpLineNum];
610*cdf0e10cSrcweir 			Point aHelpLinePos = rHelpLine.GetPos(); // + pPV->GetOffset();
611*cdf0e10cSrcweir 			basegfx::B2DPoint aStartPos(aHelpLinePos.X(), aHelpLinePos.Y());
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 			DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
614*cdf0e10cSrcweir 			mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, pPV, nHelpLineNum, rHelpLine.GetKind());
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 			aDragStat.Reset(GetSnapPos(aHelpLinePos, pPV));
617*cdf0e10cSrcweir 			aDragStat.SetMinMove(ImpGetMinMovLogic(-3, 0L));
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 			bRet = sal_True;
620*cdf0e10cSrcweir 		}
621*cdf0e10cSrcweir 	}
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir 	return bRet;
624*cdf0e10cSrcweir }
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir // start HelpLine drag with existing HelpLine
627*cdf0e10cSrcweir sal_Bool SdrSnapView::BegDragHelpLine(const Point& rPnt, SdrHelpLineKind eNewKind)
628*cdf0e10cSrcweir {
629*cdf0e10cSrcweir 	sal_Bool bRet(sal_False);
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir 	BrkAction();
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir 	if(GetSdrPageView())
634*cdf0e10cSrcweir 	{
635*cdf0e10cSrcweir 		DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
636*cdf0e10cSrcweir 		basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
637*cdf0e10cSrcweir 		mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, 0L, 0, eNewKind);
638*cdf0e10cSrcweir 		aDragStat.Reset(GetSnapPos(rPnt, 0L));
639*cdf0e10cSrcweir 		bRet = sal_True;
640*cdf0e10cSrcweir 	}
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	return bRet;
643*cdf0e10cSrcweir }
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir Pointer SdrSnapView::GetDraggedHelpLinePointer() const
646*cdf0e10cSrcweir {
647*cdf0e10cSrcweir 	if(IsDragHelpLine())
648*cdf0e10cSrcweir 	{
649*cdf0e10cSrcweir 		switch(mpHelpLineOverlay->GetHelpLineKind())
650*cdf0e10cSrcweir 		{
651*cdf0e10cSrcweir 			case SDRHELPLINE_VERTICAL  : return Pointer(POINTER_ESIZE);
652*cdf0e10cSrcweir 			case SDRHELPLINE_HORIZONTAL: return Pointer(POINTER_SSIZE);
653*cdf0e10cSrcweir 			default                    : return Pointer(POINTER_MOVE);
654*cdf0e10cSrcweir 		}
655*cdf0e10cSrcweir 	}
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 	return Pointer(POINTER_MOVE);
658*cdf0e10cSrcweir }
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir void SdrSnapView::MovDragHelpLine(const Point& rPnt)
661*cdf0e10cSrcweir {
662*cdf0e10cSrcweir 	if(IsDragHelpLine() && aDragStat.CheckMinMoved(rPnt))
663*cdf0e10cSrcweir 	{
664*cdf0e10cSrcweir 		Point aPnt(GetSnapPos(rPnt, 0L));
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 		if(aPnt != aDragStat.GetNow())
667*cdf0e10cSrcweir 		{
668*cdf0e10cSrcweir 			aDragStat.NextMove(aPnt);
669*cdf0e10cSrcweir 			DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::MovDragHelpLine: no ImplHelpLineOverlay (!)");
670*cdf0e10cSrcweir 			basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
671*cdf0e10cSrcweir 			mpHelpLineOverlay->SetPosition(aNewPos);
672*cdf0e10cSrcweir 		}
673*cdf0e10cSrcweir 	}
674*cdf0e10cSrcweir }
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir sal_Bool SdrSnapView::EndDragHelpLine()
677*cdf0e10cSrcweir {
678*cdf0e10cSrcweir 	sal_Bool bRet(sal_False);
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir 	if(IsDragHelpLine())
681*cdf0e10cSrcweir 	{
682*cdf0e10cSrcweir 		if(aDragStat.IsMinMoved())
683*cdf0e10cSrcweir 		{
684*cdf0e10cSrcweir 			SdrPageView* pPageView = mpHelpLineOverlay->GetPageView();
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir 			if(pPageView)
687*cdf0e10cSrcweir 			{
688*cdf0e10cSrcweir 				// moved existing one
689*cdf0e10cSrcweir 				Point aPnt(aDragStat.GetNow());
690*cdf0e10cSrcweir 				const SdrHelpLineList& rHelpLines = pPageView->GetHelpLines();
691*cdf0e10cSrcweir 				SdrHelpLine aChangedHelpLine = rHelpLines[mpHelpLineOverlay->GetHelpLineNumber()];
692*cdf0e10cSrcweir 				aChangedHelpLine.SetPos(aPnt);
693*cdf0e10cSrcweir 				pPageView->SetHelpLine(mpHelpLineOverlay->GetHelpLineNumber(), aChangedHelpLine);
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir 				bRet = sal_True;
696*cdf0e10cSrcweir 			}
697*cdf0e10cSrcweir 			else
698*cdf0e10cSrcweir 			{
699*cdf0e10cSrcweir 				// create new one
700*cdf0e10cSrcweir 				pPageView = GetSdrPageView();
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir 				if(pPageView)
703*cdf0e10cSrcweir 				{
704*cdf0e10cSrcweir 					Point aPnt(aDragStat.GetNow());
705*cdf0e10cSrcweir 					SdrHelpLine aNewHelpLine(mpHelpLineOverlay->GetHelpLineKind(), aPnt);
706*cdf0e10cSrcweir 					pPageView->InsertHelpLine(aNewHelpLine);
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir 					bRet = sal_True;
709*cdf0e10cSrcweir 				}
710*cdf0e10cSrcweir 			}
711*cdf0e10cSrcweir 		}
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 		// cleanup
714*cdf0e10cSrcweir 		BrkDragHelpLine();
715*cdf0e10cSrcweir 	}
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir 	return bRet;
718*cdf0e10cSrcweir }
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir void SdrSnapView::BrkDragHelpLine()
721*cdf0e10cSrcweir {
722*cdf0e10cSrcweir 	if(IsDragHelpLine())
723*cdf0e10cSrcweir 	{
724*cdf0e10cSrcweir 		DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::EndDragHelpLine: no ImplHelpLineOverlay (!)");
725*cdf0e10cSrcweir 		delete mpHelpLineOverlay;
726*cdf0e10cSrcweir 		mpHelpLineOverlay = 0L;
727*cdf0e10cSrcweir 	}
728*cdf0e10cSrcweir }
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir // eof
731