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