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/svddrgv.hxx>
28cdf0e10cSrcweir #include "svx/xattr.hxx"
29cdf0e10cSrcweir #include <svx/xpoly.hxx>
30cdf0e10cSrcweir #include <svx/svdetc.hxx>
31cdf0e10cSrcweir #include <svx/svdtrans.hxx>
32cdf0e10cSrcweir #include <svx/svdundo.hxx>
33cdf0e10cSrcweir #include <svx/svdocapt.hxx>
34cdf0e10cSrcweir #include <svx/svdpagv.hxx>
35cdf0e10cSrcweir #include <svx/svdopath.hxx>
36cdf0e10cSrcweir #include <svx/svdoedge.hxx>
37cdf0e10cSrcweir #include "svx/svdstr.hrc"
38cdf0e10cSrcweir #include "svx/svdglob.hxx"
39cdf0e10cSrcweir #include "svddrgm1.hxx"
40cdf0e10cSrcweir #include <svx/obj3d.hxx>
41cdf0e10cSrcweir #include <svx/svdoashp.hxx>
42cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
43cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
44cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
45cdf0e10cSrcweir #include <svx/polypolygoneditor.hxx>
46cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
47cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx>
48cdf0e10cSrcweir
49cdf0e10cSrcweir using namespace sdr;
50cdf0e10cSrcweir
51cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
52cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
53cdf0e10cSrcweir //
54cdf0e10cSrcweir // @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@ @@@@@ @@ @@
55cdf0e10cSrcweir // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
56cdf0e10cSrcweir // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
57cdf0e10cSrcweir // @@ @@ @@@@@ @@@@@@ @@ @@@ @@@@@ @@ @@@@ @@@@@@@
58cdf0e10cSrcweir // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
59cdf0e10cSrcweir // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
60cdf0e10cSrcweir // @@@@@ @@ @@ @@ @@ @@@@@ @ @@ @@@@@ @@ @@
61cdf0e10cSrcweir //
62cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
63cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
64cdf0e10cSrcweir
ImpClearVars()65cdf0e10cSrcweir void SdrDragView::ImpClearVars()
66cdf0e10cSrcweir {
67cdf0e10cSrcweir bFramDrag=sal_False;
68cdf0e10cSrcweir eDragMode=SDRDRAG_MOVE;
69cdf0e10cSrcweir bDragLimit=sal_False;
70cdf0e10cSrcweir bMarkedHitMovesAlways=sal_False;
71cdf0e10cSrcweir eDragHdl=HDL_MOVE;
72cdf0e10cSrcweir pDragHdl=NULL;
73cdf0e10cSrcweir bDragHdl=sal_False;
74cdf0e10cSrcweir bDragSpecial=sal_False;
75cdf0e10cSrcweir mpCurrentSdrDragMethod=NULL;
76cdf0e10cSrcweir bDragStripes=sal_False;
77cdf0e10cSrcweir bMirrRefDragObj=sal_True;
78cdf0e10cSrcweir bDragWithCopy=sal_False;
79cdf0e10cSrcweir pInsPointUndo=NULL;
80cdf0e10cSrcweir bInsGluePoint=sal_False;
81cdf0e10cSrcweir bInsObjPointMode=sal_False;
82cdf0e10cSrcweir bInsGluePointMode=sal_False;
83cdf0e10cSrcweir nDragXorPolyLimit=100;
84cdf0e10cSrcweir nDragXorPointLimit=500;
85cdf0e10cSrcweir bNoDragXorPolys=sal_False;
86cdf0e10cSrcweir bAutoVertexCon=sal_True;
87cdf0e10cSrcweir bAutoCornerCon=sal_False;
88cdf0e10cSrcweir bRubberEdgeDragging=sal_True;
89cdf0e10cSrcweir nRubberEdgeDraggingLimit=100;
90cdf0e10cSrcweir bDetailedEdgeDragging=sal_True;
91cdf0e10cSrcweir nDetailedEdgeDraggingLimit=10;
92cdf0e10cSrcweir bResizeAtCenter=sal_False;
93cdf0e10cSrcweir bCrookAtCenter=sal_False;
94cdf0e10cSrcweir bMouseHideWhileDraggingPoints=sal_False;
95cdf0e10cSrcweir
96cdf0e10cSrcweir // init using default
97cdf0e10cSrcweir mbSolidDragging = getOptionsDrawinglayer().IsSolidDragCreate();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
ImpMakeDragAttr()100cdf0e10cSrcweir void SdrDragView::ImpMakeDragAttr()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir ImpDelDragAttr();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
SdrDragView(SdrModel * pModel1,OutputDevice * pOut)105cdf0e10cSrcweir SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut)
106cdf0e10cSrcweir : SdrExchangeView(pModel1,pOut)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir ImpClearVars();
109cdf0e10cSrcweir ImpMakeDragAttr();
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
~SdrDragView()112cdf0e10cSrcweir SdrDragView::~SdrDragView()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir ImpDelDragAttr();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
ImpDelDragAttr()117cdf0e10cSrcweir void SdrDragView::ImpDelDragAttr()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
IsAction() const121cdf0e10cSrcweir sal_Bool SdrDragView::IsAction() const
122cdf0e10cSrcweir {
123cdf0e10cSrcweir return (mpCurrentSdrDragMethod || SdrExchangeView::IsAction());
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
MovAction(const Point & rPnt)126cdf0e10cSrcweir void SdrDragView::MovAction(const Point& rPnt)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir SdrExchangeView::MovAction(rPnt);
129cdf0e10cSrcweir if (mpCurrentSdrDragMethod)
130cdf0e10cSrcweir {
131cdf0e10cSrcweir MovDragObj(rPnt);
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
EndAction()135cdf0e10cSrcweir void SdrDragView::EndAction()
136cdf0e10cSrcweir {
137cdf0e10cSrcweir if (mpCurrentSdrDragMethod)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir EndDragObj(sal_False);
140cdf0e10cSrcweir }
141cdf0e10cSrcweir SdrExchangeView::EndAction();
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
BckAction()144cdf0e10cSrcweir void SdrDragView::BckAction()
145cdf0e10cSrcweir {
146cdf0e10cSrcweir SdrExchangeView::BckAction();
147cdf0e10cSrcweir BrkDragObj();
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
BrkAction()150cdf0e10cSrcweir void SdrDragView::BrkAction()
151cdf0e10cSrcweir {
152cdf0e10cSrcweir SdrExchangeView::BrkAction();
153cdf0e10cSrcweir BrkDragObj();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
TakeActionRect(Rectangle & rRect) const156cdf0e10cSrcweir void SdrDragView::TakeActionRect(Rectangle& rRect) const
157cdf0e10cSrcweir {
158cdf0e10cSrcweir if (mpCurrentSdrDragMethod)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir rRect=aDragStat.GetActionRect();
161cdf0e10cSrcweir if (rRect.IsEmpty())
162cdf0e10cSrcweir {
163cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView();
164cdf0e10cSrcweir
165cdf0e10cSrcweir if(pPV&& pPV->HasMarkedObjPageView())
166cdf0e10cSrcweir {
167cdf0e10cSrcweir // #i95646# is this used..?
168cdf0e10cSrcweir const basegfx::B2DRange aBoundRange(mpCurrentSdrDragMethod->getCurrentRange());
169cdf0e10cSrcweir rRect = Rectangle(
170cdf0e10cSrcweir basegfx::fround(aBoundRange.getMinX()), basegfx::fround(aBoundRange.getMinY()),
171cdf0e10cSrcweir basegfx::fround(aBoundRange.getMaxX()), basegfx::fround(aBoundRange.getMaxY()));
172cdf0e10cSrcweir }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir if (rRect.IsEmpty())
175cdf0e10cSrcweir {
176cdf0e10cSrcweir rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
177cdf0e10cSrcweir }
178cdf0e10cSrcweir }
179cdf0e10cSrcweir else
180cdf0e10cSrcweir {
181cdf0e10cSrcweir SdrExchangeView::TakeActionRect(rRect);
182cdf0e10cSrcweir }
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
TakeDragObjAnchorPos(Point & rPos,sal_Bool bTR) const185cdf0e10cSrcweir sal_Bool SdrDragView::TakeDragObjAnchorPos(Point& rPos, sal_Bool bTR ) const
186cdf0e10cSrcweir {
187cdf0e10cSrcweir Rectangle aR;
188cdf0e10cSrcweir TakeActionRect(aR);
189cdf0e10cSrcweir rPos = bTR ? aR.TopRight() : aR.TopLeft();
190cdf0e10cSrcweir if (GetMarkedObjectCount()==1 && IsDragObj() && // nur bei Einzelselektion
191cdf0e10cSrcweir !IsDraggingPoints() && !IsDraggingGluePoints() && // nicht beim Punkteschieben
192cdf0e10cSrcweir !mpCurrentSdrDragMethod->ISA(SdrDragMovHdl)) // nicht beim Handlesschieben
193cdf0e10cSrcweir {
194cdf0e10cSrcweir SdrObject* pObj=GetMarkedObjectByIndex(0);
195cdf0e10cSrcweir if (pObj->ISA(SdrCaptionObj))
196cdf0e10cSrcweir {
197cdf0e10cSrcweir Point aPt(((SdrCaptionObj*)pObj)->GetTailPos());
198cdf0e10cSrcweir sal_Bool bTail=eDragHdl==HDL_POLY; // Schwanz wird gedraggt (nicht so ganz feine Abfrage hier)
199cdf0e10cSrcweir sal_Bool bOwn=mpCurrentSdrDragMethod->ISA(SdrDragObjOwn); // Objektspeziefisch
200cdf0e10cSrcweir if (!bTail)
201cdf0e10cSrcweir { // bei bTail liefert TakeActionRect schon das richtige
202cdf0e10cSrcweir if (bOwn)
203cdf0e10cSrcweir { // bOwn kann sein MoveTextFrame, ResizeTextFrame aber eben nicht mehr DragTail
204cdf0e10cSrcweir rPos=aPt;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir else
207cdf0e10cSrcweir {
208cdf0e10cSrcweir // drag the whole Object (Move, Resize, ...)
209cdf0e10cSrcweir const basegfx::B2DPoint aTransformed(mpCurrentSdrDragMethod->getCurrentTransformation() * basegfx::B2DPoint(aPt.X(), aPt.Y()));
210cdf0e10cSrcweir rPos.X() = basegfx::fround(aTransformed.getX());
211cdf0e10cSrcweir rPos.Y() = basegfx::fround(aTransformed.getY());
212cdf0e10cSrcweir }
213cdf0e10cSrcweir }
214cdf0e10cSrcweir }
215cdf0e10cSrcweir return sal_True;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir return sal_False;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
221cdf0e10cSrcweir
TakeDragLimit(SdrDragMode,Rectangle &) const222cdf0e10cSrcweir sal_Bool SdrDragView::TakeDragLimit(SdrDragMode /*eMode*/, Rectangle& /*rRect*/) const
223cdf0e10cSrcweir {
224cdf0e10cSrcweir return sal_False;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
BegDragObj(const Point & rPnt,OutputDevice * pOut,SdrHdl * pHdl,short nMinMov,SdrDragMethod * pForcedMeth)227cdf0e10cSrcweir sal_Bool SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl, short nMinMov, SdrDragMethod* pForcedMeth)
228cdf0e10cSrcweir {
229cdf0e10cSrcweir BrkAction();
230cdf0e10cSrcweir
231cdf0e10cSrcweir bool bRet=false;
232cdf0e10cSrcweir {
233cdf0e10cSrcweir SetDragWithCopy(sal_False);
234cdf0e10cSrcweir //ForceEdgesOfMarkedNodes();
235cdf0e10cSrcweir //TODO: aAni.Reset();
236cdf0e10cSrcweir mpCurrentSdrDragMethod=NULL;
237cdf0e10cSrcweir bDragSpecial=sal_False;
238cdf0e10cSrcweir bDragLimit=sal_False;
239cdf0e10cSrcweir SdrDragMode eTmpMode=eDragMode;
240cdf0e10cSrcweir if (eTmpMode==SDRDRAG_MOVE && pHdl!=NULL && pHdl->GetKind()!=HDL_MOVE) {
241cdf0e10cSrcweir eTmpMode=SDRDRAG_RESIZE;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir bDragLimit=TakeDragLimit(eTmpMode,aDragLimit);
244cdf0e10cSrcweir bFramDrag=ImpIsFrameHandles();
245cdf0e10cSrcweir if (!bFramDrag &&
246cdf0e10cSrcweir (pMarkedObj==NULL || !pMarkedObj->hasSpecialDrag()) &&
247cdf0e10cSrcweir (pHdl==NULL || pHdl->GetObj()==NULL)) {
248cdf0e10cSrcweir bFramDrag=sal_True;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
251cdf0e10cSrcweir Point aPnt(rPnt);
252cdf0e10cSrcweir if(pHdl == NULL
253cdf0e10cSrcweir || pHdl->GetKind() == HDL_MOVE
254cdf0e10cSrcweir || pHdl->GetKind() == HDL_MIRX
255cdf0e10cSrcweir || pHdl->GetKind() == HDL_TRNS
256cdf0e10cSrcweir || pHdl->GetKind() == HDL_GRAD)
257cdf0e10cSrcweir {
258cdf0e10cSrcweir aDragStat.Reset(aPnt);
259cdf0e10cSrcweir }
260cdf0e10cSrcweir else
261cdf0e10cSrcweir {
262cdf0e10cSrcweir aDragStat.Reset(pHdl->GetPos());
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir aDragStat.SetView((SdrView*)this);
266cdf0e10cSrcweir aDragStat.SetPageView(pMarkedPV); // <<-- hier muss die DragPV rein!!!
267cdf0e10cSrcweir aDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
268cdf0e10cSrcweir aDragStat.SetHdl(pHdl);
269cdf0e10cSrcweir aDragStat.NextPoint();
270cdf0e10cSrcweir pDragWin=pOut;
271cdf0e10cSrcweir pDragHdl=pHdl;
272cdf0e10cSrcweir eDragHdl= pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
273cdf0e10cSrcweir bDragHdl=eDragHdl==HDL_REF1 || eDragHdl==HDL_REF2 || eDragHdl==HDL_MIRX;
274cdf0e10cSrcweir
275cdf0e10cSrcweir // #103894# Expand test for HDL_ANCHOR_TR
276cdf0e10cSrcweir sal_Bool bNotDraggable = (HDL_ANCHOR == eDragHdl || HDL_ANCHOR_TR == eDragHdl);
277cdf0e10cSrcweir
278cdf0e10cSrcweir if(pHdl && (pHdl->GetKind() == HDL_SMARTTAG) && pForcedMeth )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir // just use the forced method for smart tags
281cdf0e10cSrcweir }
282cdf0e10cSrcweir else if(bDragHdl)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMovHdl(*this);
285cdf0e10cSrcweir }
286cdf0e10cSrcweir else if(!bNotDraggable)
287cdf0e10cSrcweir {
288cdf0e10cSrcweir switch (eDragMode)
289cdf0e10cSrcweir {
290cdf0e10cSrcweir case SDRDRAG_ROTATE: case SDRDRAG_SHEAR: case SDRDRAG_DISTORT:
291cdf0e10cSrcweir {
292cdf0e10cSrcweir switch (eDragHdl)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir case HDL_LEFT: case HDL_RIGHT:
295cdf0e10cSrcweir case HDL_UPPER: case HDL_LOWER:
296cdf0e10cSrcweir {
297cdf0e10cSrcweir // Sind 3D-Objekte selektiert?
298cdf0e10cSrcweir sal_Bool b3DObjSelected = sal_False;
299cdf0e10cSrcweir for(sal_uInt32 a=0;!b3DObjSelected && a<GetMarkedObjectCount();a++)
300cdf0e10cSrcweir {
301cdf0e10cSrcweir SdrObject* pObj = GetMarkedObjectByIndex(a);
302cdf0e10cSrcweir if(pObj && pObj->ISA(E3dObject))
303cdf0e10cSrcweir b3DObjSelected = sal_True;
304cdf0e10cSrcweir }
305cdf0e10cSrcweir // Falls ja, Shear auch bei !IsShearAllowed zulassen,
306cdf0e10cSrcweir // da es sich bei 3D-Objekten um eingeschraenkte
307cdf0e10cSrcweir // Rotationen handelt
308cdf0e10cSrcweir if (!b3DObjSelected && !IsShearAllowed())
309cdf0e10cSrcweir return sal_False;
310cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragShear(*this,eDragMode==SDRDRAG_ROTATE);
311cdf0e10cSrcweir } break;
312cdf0e10cSrcweir case HDL_UPLFT: case HDL_UPRGT:
313cdf0e10cSrcweir case HDL_LWLFT: case HDL_LWRGT:
314cdf0e10cSrcweir {
315cdf0e10cSrcweir if (eDragMode==SDRDRAG_SHEAR || eDragMode==SDRDRAG_DISTORT)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir if (!IsDistortAllowed(sal_True) && !IsDistortAllowed(sal_False)) return sal_False;
318cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragDistort(*this);
319cdf0e10cSrcweir }
320cdf0e10cSrcweir else
321cdf0e10cSrcweir {
322cdf0e10cSrcweir if (!IsRotateAllowed(sal_True)) return sal_False;
323cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragRotate(*this);
324cdf0e10cSrcweir }
325cdf0e10cSrcweir } break;
326cdf0e10cSrcweir default:
327cdf0e10cSrcweir {
328cdf0e10cSrcweir if (IsMarkedHitMovesAlways() && eDragHdl==HDL_MOVE)
329cdf0e10cSrcweir { // HDL_MOVE ist auch wenn Obj direkt getroffen
330cdf0e10cSrcweir if (!IsMoveAllowed()) return sal_False;
331cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
332cdf0e10cSrcweir }
333cdf0e10cSrcweir else
334cdf0e10cSrcweir {
335cdf0e10cSrcweir if (!IsRotateAllowed(sal_True)) return sal_False;
336cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragRotate(*this);
337cdf0e10cSrcweir }
338cdf0e10cSrcweir }
339cdf0e10cSrcweir }
340cdf0e10cSrcweir } break;
341cdf0e10cSrcweir case SDRDRAG_MIRROR:
342cdf0e10cSrcweir {
343cdf0e10cSrcweir if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
344cdf0e10cSrcweir {
345cdf0e10cSrcweir if (!IsMoveAllowed()) return sal_False;
346cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
347cdf0e10cSrcweir }
348cdf0e10cSrcweir else
349cdf0e10cSrcweir {
350cdf0e10cSrcweir if (!IsMirrorAllowed(sal_True,sal_True)) return sal_False;
351cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMirror(*this);
352cdf0e10cSrcweir }
353cdf0e10cSrcweir } break;
354cdf0e10cSrcweir
355cdf0e10cSrcweir case SDRDRAG_CROP:
356cdf0e10cSrcweir {
357cdf0e10cSrcweir if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
358cdf0e10cSrcweir {
359cdf0e10cSrcweir if (!IsMoveAllowed())
360cdf0e10cSrcweir return sal_False;
361cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
362cdf0e10cSrcweir }
363cdf0e10cSrcweir else
364cdf0e10cSrcweir {
365cdf0e10cSrcweir if (!IsCrookAllowed(sal_True) && !IsCrookAllowed(sal_False))
366cdf0e10cSrcweir return sal_False;
367cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragCrop(*this);
368cdf0e10cSrcweir }
369cdf0e10cSrcweir }
370cdf0e10cSrcweir break;
371cdf0e10cSrcweir
372cdf0e10cSrcweir case SDRDRAG_TRANSPARENCE:
373cdf0e10cSrcweir {
374cdf0e10cSrcweir if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
375cdf0e10cSrcweir {
376cdf0e10cSrcweir if(!IsMoveAllowed())
377cdf0e10cSrcweir return sal_False;
378cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
379cdf0e10cSrcweir }
380cdf0e10cSrcweir else
381cdf0e10cSrcweir {
382cdf0e10cSrcweir if(!IsTransparenceAllowed())
383cdf0e10cSrcweir return sal_False;
384cdf0e10cSrcweir
385cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragGradient(*this, sal_False);
386cdf0e10cSrcweir }
387cdf0e10cSrcweir break;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir case SDRDRAG_GRADIENT:
390cdf0e10cSrcweir {
391cdf0e10cSrcweir if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
392cdf0e10cSrcweir {
393cdf0e10cSrcweir if(!IsMoveAllowed())
394cdf0e10cSrcweir return sal_False;
395cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
396cdf0e10cSrcweir }
397cdf0e10cSrcweir else
398cdf0e10cSrcweir {
399cdf0e10cSrcweir if(!IsGradientAllowed())
400cdf0e10cSrcweir return sal_False;
401cdf0e10cSrcweir
402cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragGradient(*this);
403cdf0e10cSrcweir }
404cdf0e10cSrcweir break;
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir case SDRDRAG_CROOK :
408cdf0e10cSrcweir {
409cdf0e10cSrcweir if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
410cdf0e10cSrcweir {
411cdf0e10cSrcweir if (!IsMoveAllowed()) return sal_False;
412cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
413cdf0e10cSrcweir }
414cdf0e10cSrcweir else
415cdf0e10cSrcweir {
416cdf0e10cSrcweir if (!IsCrookAllowed(sal_True) && !IsCrookAllowed(sal_False)) return sal_False;
417cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragCrook(*this);
418cdf0e10cSrcweir }
419cdf0e10cSrcweir } break;
420cdf0e10cSrcweir
421cdf0e10cSrcweir default:
422cdf0e10cSrcweir {
423cdf0e10cSrcweir // SDRDRAG_MOVE
424cdf0e10cSrcweir if((eDragHdl == HDL_MOVE) && !IsMoveAllowed())
425cdf0e10cSrcweir {
426cdf0e10cSrcweir return sal_False;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir else if(eDragHdl == HDL_GLUE)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
431cdf0e10cSrcweir }
432cdf0e10cSrcweir else
433cdf0e10cSrcweir {
434cdf0e10cSrcweir if(bFramDrag)
435cdf0e10cSrcweir {
436cdf0e10cSrcweir if(eDragHdl == HDL_MOVE)
437cdf0e10cSrcweir {
438cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
439cdf0e10cSrcweir }
440cdf0e10cSrcweir else
441cdf0e10cSrcweir {
442cdf0e10cSrcweir if(!IsResizeAllowed(sal_True))
443cdf0e10cSrcweir {
444cdf0e10cSrcweir return sal_False;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
447cdf0e10cSrcweir sal_Bool bSingleTextObjMark = sal_False; // SJ: #i100490#
448cdf0e10cSrcweir if ( GetMarkedObjectCount() == 1 )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir pMarkedObj=GetMarkedObjectByIndex(0);
451cdf0e10cSrcweir if ( pMarkedObj &&
452cdf0e10cSrcweir pMarkedObj->ISA( SdrTextObj ) &&
453cdf0e10cSrcweir static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame() )
454cdf0e10cSrcweir bSingleTextObjMark = sal_True;
455cdf0e10cSrcweir }
456cdf0e10cSrcweir if ( bSingleTextObjMark )
457cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
458cdf0e10cSrcweir else
459cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragResize(*this);
460cdf0e10cSrcweir }
461cdf0e10cSrcweir }
462cdf0e10cSrcweir else
463cdf0e10cSrcweir {
464cdf0e10cSrcweir if(HDL_MOVE == eDragHdl)
465cdf0e10cSrcweir {
466cdf0e10cSrcweir const bool bCustomShapeSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrObjCustomShape));
467cdf0e10cSrcweir
468cdf0e10cSrcweir if(bCustomShapeSelected)
469cdf0e10cSrcweir {
470cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove( *this );
471cdf0e10cSrcweir }
472cdf0e10cSrcweir }
473cdf0e10cSrcweir else if(HDL_POLY == eDragHdl)
474cdf0e10cSrcweir {
475cdf0e10cSrcweir const bool bConnectorSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrEdgeObj));
476cdf0e10cSrcweir
477cdf0e10cSrcweir if(bConnectorSelected)
478cdf0e10cSrcweir {
479cdf0e10cSrcweir // #i97784#
480cdf0e10cSrcweir // fallback to old behaviour for connectors (see
481cdf0e10cSrcweir // text in task description for more details)
482cdf0e10cSrcweir }
483cdf0e10cSrcweir else if(!IsMoveAllowed() || !IsResizeAllowed())
484cdf0e10cSrcweir {
485cdf0e10cSrcweir // #i77187#
486cdf0e10cSrcweir // do not allow move of polygon points if object is move or size protected
487cdf0e10cSrcweir return sal_False;
488cdf0e10cSrcweir }
489cdf0e10cSrcweir }
490cdf0e10cSrcweir
491cdf0e10cSrcweir if(!mpCurrentSdrDragMethod)
492cdf0e10cSrcweir {
493cdf0e10cSrcweir // fallback to DragSpecial if no interaction defined
494cdf0e10cSrcweir bDragSpecial = sal_True;
495cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
496cdf0e10cSrcweir }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir }
499cdf0e10cSrcweir }
500cdf0e10cSrcweir }
501cdf0e10cSrcweir }
502cdf0e10cSrcweir if (pForcedMeth!=NULL)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir delete mpCurrentSdrDragMethod;
505cdf0e10cSrcweir mpCurrentSdrDragMethod = pForcedMeth;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
508cdf0e10cSrcweir if (mpCurrentSdrDragMethod)
509cdf0e10cSrcweir {
510cdf0e10cSrcweir bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
511cdf0e10cSrcweir if (!bRet)
512cdf0e10cSrcweir {
513cdf0e10cSrcweir if (pHdl==NULL && IS_TYPE(SdrDragObjOwn,mpCurrentSdrDragMethod))
514cdf0e10cSrcweir {
515cdf0e10cSrcweir // Aha, Obj kann nicht Move SpecialDrag, also MoveFrameDrag versuchen
516cdf0e10cSrcweir delete mpCurrentSdrDragMethod;
517cdf0e10cSrcweir mpCurrentSdrDragMethod = 0;
518cdf0e10cSrcweir bDragSpecial=sal_False;
519cdf0e10cSrcweir
520cdf0e10cSrcweir if (!IsMoveAllowed())
521cdf0e10cSrcweir return sal_False;
522cdf0e10cSrcweir
523cdf0e10cSrcweir bFramDrag=sal_True;
524cdf0e10cSrcweir mpCurrentSdrDragMethod = new SdrDragMove(*this);
525cdf0e10cSrcweir aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
526cdf0e10cSrcweir bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
527cdf0e10cSrcweir }
528cdf0e10cSrcweir }
529cdf0e10cSrcweir if (!bRet)
530cdf0e10cSrcweir {
531cdf0e10cSrcweir delete mpCurrentSdrDragMethod;
532cdf0e10cSrcweir mpCurrentSdrDragMethod = 0;
533cdf0e10cSrcweir aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
534cdf0e10cSrcweir }
535cdf0e10cSrcweir }
536cdf0e10cSrcweir }
537cdf0e10cSrcweir
538cdf0e10cSrcweir return bRet;
539cdf0e10cSrcweir }
540cdf0e10cSrcweir
MovDragObj(const Point & rPnt)541cdf0e10cSrcweir void SdrDragView::MovDragObj(const Point& rPnt)
542cdf0e10cSrcweir {
543cdf0e10cSrcweir if (mpCurrentSdrDragMethod)
544cdf0e10cSrcweir {
545cdf0e10cSrcweir Point aPnt(rPnt);
546cdf0e10cSrcweir ImpLimitToWorkArea(aPnt);
547cdf0e10cSrcweir mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination
548cdf0e10cSrcweir }
549cdf0e10cSrcweir }
550cdf0e10cSrcweir
EndDragObj(sal_Bool bCopy)551cdf0e10cSrcweir sal_Bool SdrDragView::EndDragObj(sal_Bool bCopy)
552cdf0e10cSrcweir {
553cdf0e10cSrcweir bool bRet(false);
554cdf0e10cSrcweir
555cdf0e10cSrcweir // #i73341# If insert GluePoint, do not insist on last points being different
556cdf0e10cSrcweir if(mpCurrentSdrDragMethod && aDragStat.IsMinMoved() && (IsInsertGluePoint() || aDragStat.GetNow() != aDragStat.GetPrev()))
557cdf0e10cSrcweir {
558cdf0e10cSrcweir sal_uIntPtr nHdlAnzMerk=0;
559cdf0e10cSrcweir
560cdf0e10cSrcweir if (bEliminatePolyPoints)
561cdf0e10cSrcweir { // IBM Special
562cdf0e10cSrcweir nHdlAnzMerk=GetMarkablePointCount();
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
565cdf0e10cSrcweir const bool bUndo = IsUndoEnabled();
566cdf0e10cSrcweir if (IsInsertGluePoint() && bUndo)
567cdf0e10cSrcweir {
568cdf0e10cSrcweir BegUndo(aInsPointUndoStr);
569cdf0e10cSrcweir AddUndo(pInsPointUndo);
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
572cdf0e10cSrcweir bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy);
573cdf0e10cSrcweir
574cdf0e10cSrcweir if( IsInsertGluePoint() && bUndo)
575cdf0e10cSrcweir EndUndo();
576cdf0e10cSrcweir
577cdf0e10cSrcweir delete mpCurrentSdrDragMethod;
578cdf0e10cSrcweir mpCurrentSdrDragMethod = 0;
579cdf0e10cSrcweir
580cdf0e10cSrcweir if (bEliminatePolyPoints)
581cdf0e10cSrcweir { // IBM Special
582cdf0e10cSrcweir if (nHdlAnzMerk!=GetMarkablePointCount())
583cdf0e10cSrcweir {
584cdf0e10cSrcweir UnmarkAllPoints();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
588cdf0e10cSrcweir if (bInsPolyPoint)
589cdf0e10cSrcweir {
590cdf0e10cSrcweir SetMarkHandles();
591cdf0e10cSrcweir bInsPolyPoint=sal_False;
592cdf0e10cSrcweir if( bUndo )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir BegUndo(aInsPointUndoStr);
595cdf0e10cSrcweir AddUndo(pInsPointUndo);
596cdf0e10cSrcweir EndUndo();
597cdf0e10cSrcweir }
598cdf0e10cSrcweir }
599cdf0e10cSrcweir
600cdf0e10cSrcweir eDragHdl=HDL_MOVE;
601cdf0e10cSrcweir pDragHdl=NULL;
602cdf0e10cSrcweir
603cdf0e10cSrcweir if (!bSomeObjChgdFlag)
604cdf0e10cSrcweir {
605cdf0e10cSrcweir // Aha, Obj hat nicht gebroadcastet (z.B. Writer FlyFrames)
606cdf0e10cSrcweir if(!bDragHdl)
607cdf0e10cSrcweir {
608cdf0e10cSrcweir AdjustMarkHdl();
609cdf0e10cSrcweir }
610cdf0e10cSrcweir }
611cdf0e10cSrcweir }
612cdf0e10cSrcweir else
613cdf0e10cSrcweir {
614cdf0e10cSrcweir BrkDragObj();
615cdf0e10cSrcweir }
616cdf0e10cSrcweir
617cdf0e10cSrcweir bInsPolyPoint=sal_False;
618cdf0e10cSrcweir SetInsertGluePoint(sal_False);
619cdf0e10cSrcweir
620cdf0e10cSrcweir return bRet;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir
BrkDragObj()623cdf0e10cSrcweir void SdrDragView::BrkDragObj()
624cdf0e10cSrcweir {
625cdf0e10cSrcweir if (mpCurrentSdrDragMethod)
626cdf0e10cSrcweir {
627cdf0e10cSrcweir mpCurrentSdrDragMethod->CancelSdrDrag();
628cdf0e10cSrcweir
629cdf0e10cSrcweir delete mpCurrentSdrDragMethod;
630cdf0e10cSrcweir mpCurrentSdrDragMethod = 0;
631cdf0e10cSrcweir
632cdf0e10cSrcweir if (bInsPolyPoint)
633cdf0e10cSrcweir {
634cdf0e10cSrcweir pInsPointUndo->Undo(); // Den eingefuegten Punkt wieder raus
635cdf0e10cSrcweir delete pInsPointUndo;
636cdf0e10cSrcweir pInsPointUndo=NULL;
637cdf0e10cSrcweir SetMarkHandles();
638cdf0e10cSrcweir bInsPolyPoint=sal_False;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
641cdf0e10cSrcweir if (IsInsertGluePoint())
642cdf0e10cSrcweir {
643cdf0e10cSrcweir pInsPointUndo->Undo(); // Den eingefuegten Klebepunkt wieder raus
644cdf0e10cSrcweir delete pInsPointUndo;
645cdf0e10cSrcweir pInsPointUndo=NULL;
646cdf0e10cSrcweir SetInsertGluePoint(sal_False);
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
649cdf0e10cSrcweir eDragHdl=HDL_MOVE;
650cdf0e10cSrcweir pDragHdl=NULL;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir }
653cdf0e10cSrcweir
IsInsObjPointPossible() const654cdf0e10cSrcweir sal_Bool SdrDragView::IsInsObjPointPossible() const
655cdf0e10cSrcweir {
656cdf0e10cSrcweir return pMarkedObj!=NULL && pMarkedObj->IsPolyObj();
657cdf0e10cSrcweir }
658cdf0e10cSrcweir
ImpBegInsObjPoint(sal_Bool bIdxZwang,sal_uInt32 nIdx,const Point & rPnt,sal_Bool bNewObj,OutputDevice * pOut)659cdf0e10cSrcweir sal_Bool SdrDragView::ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, sal_Bool bNewObj, OutputDevice* pOut)
660cdf0e10cSrcweir {
661cdf0e10cSrcweir sal_Bool bRet(sal_False);
662cdf0e10cSrcweir
663cdf0e10cSrcweir if(pMarkedObj && pMarkedObj->ISA(SdrPathObj))
664cdf0e10cSrcweir {
665cdf0e10cSrcweir SdrPathObj* pMarkedPath = (SdrPathObj*)pMarkedObj;
666cdf0e10cSrcweir BrkAction();
667cdf0e10cSrcweir pInsPointUndo = dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pMarkedObj) );
668cdf0e10cSrcweir DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
669cdf0e10cSrcweir
670cdf0e10cSrcweir XubString aStr(ImpGetResStr(STR_DragInsertPoint));
671cdf0e10cSrcweir XubString aName;
672cdf0e10cSrcweir pMarkedObj->TakeObjNameSingul(aName);
673cdf0e10cSrcweir xub_StrLen nPos(aStr.SearchAscii("%1"));
674cdf0e10cSrcweir
675cdf0e10cSrcweir if(STRING_NOTFOUND != nPos)
676cdf0e10cSrcweir {
677cdf0e10cSrcweir aStr.Erase(nPos, 2);
678cdf0e10cSrcweir aStr.Insert(aName, nPos);
679cdf0e10cSrcweir }
680cdf0e10cSrcweir
681cdf0e10cSrcweir aInsPointUndoStr = aStr;
682cdf0e10cSrcweir Point aPt(rPnt);
683cdf0e10cSrcweir
684cdf0e10cSrcweir if(bNewObj)
685cdf0e10cSrcweir aPt = GetSnapPos(aPt,pMarkedPV);
686cdf0e10cSrcweir
687cdf0e10cSrcweir sal_Bool bClosed0(pMarkedPath->IsClosedObj());
688cdf0e10cSrcweir
689cdf0e10cSrcweir if(bIdxZwang)
690cdf0e10cSrcweir {
691cdf0e10cSrcweir mnInsPointNum = pMarkedPath->NbcInsPoint(nIdx, aPt, bNewObj, sal_True);
692cdf0e10cSrcweir }
693cdf0e10cSrcweir else
694cdf0e10cSrcweir {
695cdf0e10cSrcweir mnInsPointNum = pMarkedPath->NbcInsPointOld(aPt, bNewObj, sal_True);
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir if(bClosed0 != pMarkedPath->IsClosedObj())
699cdf0e10cSrcweir {
700cdf0e10cSrcweir // Obj was closed implicit
701cdf0e10cSrcweir // object changed
702cdf0e10cSrcweir pMarkedPath->SetChanged();
703cdf0e10cSrcweir pMarkedPath->BroadcastObjectChange();
704cdf0e10cSrcweir }
705cdf0e10cSrcweir
706cdf0e10cSrcweir if(0xffffffff != mnInsPointNum)
707cdf0e10cSrcweir {
708cdf0e10cSrcweir bInsPolyPoint = sal_True;
709cdf0e10cSrcweir UnmarkAllPoints();
710cdf0e10cSrcweir AdjustMarkHdl();
711cdf0e10cSrcweir
712cdf0e10cSrcweir bRet = BegDragObj(rPnt, pOut, aHdl.GetHdl(mnInsPointNum), 0);
713cdf0e10cSrcweir
714cdf0e10cSrcweir if (bRet)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir aDragStat.SetMinMoved();
717cdf0e10cSrcweir MovDragObj(rPnt);
718cdf0e10cSrcweir }
719cdf0e10cSrcweir }
720cdf0e10cSrcweir else
721cdf0e10cSrcweir {
722cdf0e10cSrcweir delete pInsPointUndo;
723cdf0e10cSrcweir pInsPointUndo = NULL;
724cdf0e10cSrcweir }
725cdf0e10cSrcweir }
726cdf0e10cSrcweir
727cdf0e10cSrcweir return bRet;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir
EndInsObjPoint(SdrCreateCmd eCmd)730cdf0e10cSrcweir sal_Bool SdrDragView::EndInsObjPoint(SdrCreateCmd eCmd)
731cdf0e10cSrcweir {
732cdf0e10cSrcweir if(IsInsObjPoint())
733cdf0e10cSrcweir {
734cdf0e10cSrcweir sal_uInt32 nNextPnt(mnInsPointNum);
735cdf0e10cSrcweir Point aPnt(aDragStat.GetNow());
736cdf0e10cSrcweir sal_Bool bOk=EndDragObj(sal_False);
737cdf0e10cSrcweir if (bOk==sal_True && eCmd!=SDRCREATE_FORCEEND)
738cdf0e10cSrcweir {
739cdf0e10cSrcweir // Ret=True bedeutet: Action ist vorbei.
740cdf0e10cSrcweir bOk=!(ImpBegInsObjPoint(sal_True, nNextPnt, aPnt, eCmd == SDRCREATE_NEXTOBJECT, pDragWin));
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
743cdf0e10cSrcweir return bOk;
744cdf0e10cSrcweir } else return sal_False;
745cdf0e10cSrcweir }
746cdf0e10cSrcweir
IsInsGluePointPossible() const747cdf0e10cSrcweir sal_Bool SdrDragView::IsInsGluePointPossible() const
748cdf0e10cSrcweir {
749cdf0e10cSrcweir sal_Bool bRet=sal_False;
750cdf0e10cSrcweir if (IsInsGluePointMode() && AreObjectsMarked())
751cdf0e10cSrcweir {
752cdf0e10cSrcweir if (GetMarkedObjectCount()==1)
753cdf0e10cSrcweir {
754cdf0e10cSrcweir // sal_False liefern, wenn 1 Objekt und dieses ein Verbinder ist.
755cdf0e10cSrcweir const SdrObject* pObj=GetMarkedObjectByIndex(0);
756cdf0e10cSrcweir if (!HAS_BASE(SdrEdgeObj,pObj))
757cdf0e10cSrcweir {
758cdf0e10cSrcweir bRet=sal_True;
759cdf0e10cSrcweir }
760cdf0e10cSrcweir }
761cdf0e10cSrcweir else
762cdf0e10cSrcweir {
763cdf0e10cSrcweir bRet=sal_True;
764cdf0e10cSrcweir }
765cdf0e10cSrcweir }
766cdf0e10cSrcweir return bRet;
767cdf0e10cSrcweir }
768cdf0e10cSrcweir
BegInsGluePoint(const Point & rPnt)769cdf0e10cSrcweir sal_Bool SdrDragView::BegInsGluePoint(const Point& rPnt)
770cdf0e10cSrcweir {
771cdf0e10cSrcweir sal_Bool bRet=sal_False;
772cdf0e10cSrcweir SdrObject* pObj;
773cdf0e10cSrcweir SdrPageView* pPV;
774cdf0e10cSrcweir sal_uIntPtr nMarkNum;
775cdf0e10cSrcweir if (PickMarkedObj(rPnt,pObj,pPV,&nMarkNum,SDRSEARCH_PASS2BOUND))
776cdf0e10cSrcweir {
777cdf0e10cSrcweir BrkAction();
778cdf0e10cSrcweir UnmarkAllGluePoints();
779cdf0e10cSrcweir pInsPointUndo= dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj) );
780cdf0e10cSrcweir DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
781cdf0e10cSrcweir XubString aStr(ImpGetResStr(STR_DragInsertGluePoint));
782cdf0e10cSrcweir XubString aName; pObj->TakeObjNameSingul(aName);
783cdf0e10cSrcweir
784cdf0e10cSrcweir aStr.SearchAndReplaceAscii("%1", aName);
785cdf0e10cSrcweir
786cdf0e10cSrcweir aInsPointUndoStr=aStr;
787cdf0e10cSrcweir SdrGluePointList* pGPL=pObj->ForceGluePointList();
788cdf0e10cSrcweir if (pGPL!=NULL)
789cdf0e10cSrcweir {
790cdf0e10cSrcweir sal_uInt16 nGlueIdx=pGPL->Insert(SdrGluePoint());
791cdf0e10cSrcweir SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
792cdf0e10cSrcweir sal_uInt16 nGlueId=rGP.GetId();
793cdf0e10cSrcweir rGP.SetAbsolutePos(rPnt,*pObj);
794cdf0e10cSrcweir
795cdf0e10cSrcweir SdrHdl* pHdl=NULL;
796cdf0e10cSrcweir if (MarkGluePoint(pObj,nGlueId,pPV))
797cdf0e10cSrcweir {
798cdf0e10cSrcweir pHdl=GetGluePointHdl(pObj,nGlueId);
799cdf0e10cSrcweir }
800cdf0e10cSrcweir if (pHdl!=NULL && pHdl->GetKind()==HDL_GLUE && pHdl->GetObj()==pObj && pHdl->GetObjHdlNum()==nGlueId)
801cdf0e10cSrcweir {
802cdf0e10cSrcweir SetInsertGluePoint(sal_True);
803cdf0e10cSrcweir bRet=BegDragObj(rPnt,NULL,pHdl,0);
804cdf0e10cSrcweir if (bRet)
805cdf0e10cSrcweir {
806cdf0e10cSrcweir aDragStat.SetMinMoved();
807cdf0e10cSrcweir MovDragObj(rPnt);
808cdf0e10cSrcweir }
809cdf0e10cSrcweir else
810cdf0e10cSrcweir {
811cdf0e10cSrcweir SetInsertGluePoint(sal_False);
812cdf0e10cSrcweir delete pInsPointUndo;
813cdf0e10cSrcweir pInsPointUndo=NULL;
814cdf0e10cSrcweir }
815cdf0e10cSrcweir }
816cdf0e10cSrcweir else
817cdf0e10cSrcweir {
818cdf0e10cSrcweir DBG_ERROR("BegInsGluePoint(): GluePoint-Handle nicht gefunden");
819cdf0e10cSrcweir }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir else
822cdf0e10cSrcweir {
823cdf0e10cSrcweir // Keine Klebepunkte moeglich bei diesem Objekt (z.B. Edge)
824cdf0e10cSrcweir SetInsertGluePoint(sal_False);
825cdf0e10cSrcweir delete pInsPointUndo;
826cdf0e10cSrcweir pInsPointUndo=NULL;
827cdf0e10cSrcweir }
828cdf0e10cSrcweir }
829cdf0e10cSrcweir
830cdf0e10cSrcweir return bRet;
831cdf0e10cSrcweir }
832cdf0e10cSrcweir
ShowDragObj()833cdf0e10cSrcweir void SdrDragView::ShowDragObj()
834cdf0e10cSrcweir {
835cdf0e10cSrcweir if(mpCurrentSdrDragMethod && !aDragStat.IsShown())
836cdf0e10cSrcweir {
837cdf0e10cSrcweir for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
838cdf0e10cSrcweir {
839cdf0e10cSrcweir SdrPaintWindow* pCandidate = GetPaintWindow(a);
840cdf0e10cSrcweir sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager();
841cdf0e10cSrcweir
842cdf0e10cSrcweir if(pOverlayManager)
843cdf0e10cSrcweir {
844cdf0e10cSrcweir mpCurrentSdrDragMethod->CreateOverlayGeometry(*pOverlayManager);
845cdf0e10cSrcweir
846cdf0e10cSrcweir // #i101679# Force changed overlay to be shown
847cdf0e10cSrcweir pOverlayManager->flush();
848cdf0e10cSrcweir }
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
851cdf0e10cSrcweir aDragStat.SetShown(sal_True);
852cdf0e10cSrcweir }
853cdf0e10cSrcweir }
854cdf0e10cSrcweir
HideDragObj()855cdf0e10cSrcweir void SdrDragView::HideDragObj()
856cdf0e10cSrcweir {
857cdf0e10cSrcweir if(mpCurrentSdrDragMethod && aDragStat.IsShown())
858cdf0e10cSrcweir {
859cdf0e10cSrcweir mpCurrentSdrDragMethod->destroyOverlayGeometry();
860cdf0e10cSrcweir aDragStat.SetShown(sal_False);
861cdf0e10cSrcweir }
862cdf0e10cSrcweir }
863cdf0e10cSrcweir
864cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
865cdf0e10cSrcweir
SetNoDragXorPolys(sal_Bool bOn)866cdf0e10cSrcweir void SdrDragView::SetNoDragXorPolys(sal_Bool bOn)
867cdf0e10cSrcweir {
868cdf0e10cSrcweir if (IsNoDragXorPolys()!=bOn)
869cdf0e10cSrcweir {
870cdf0e10cSrcweir const bool bDragging(mpCurrentSdrDragMethod);
871cdf0e10cSrcweir const bool bShown(bDragging && aDragStat.IsShown());
872cdf0e10cSrcweir
873cdf0e10cSrcweir if(bShown)
874cdf0e10cSrcweir {
875cdf0e10cSrcweir HideDragObj();
876cdf0e10cSrcweir }
877cdf0e10cSrcweir
878cdf0e10cSrcweir bNoDragXorPolys = bOn;
879cdf0e10cSrcweir
880cdf0e10cSrcweir if(bDragging)
881cdf0e10cSrcweir {
882cdf0e10cSrcweir // force recreation of drag content
883cdf0e10cSrcweir mpCurrentSdrDragMethod->resetSdrDragEntries();
884cdf0e10cSrcweir }
885cdf0e10cSrcweir
886cdf0e10cSrcweir if(bShown)
887cdf0e10cSrcweir {
888cdf0e10cSrcweir ShowDragObj();
889cdf0e10cSrcweir }
890cdf0e10cSrcweir }
891cdf0e10cSrcweir }
892cdf0e10cSrcweir
SetDragStripes(sal_Bool bOn)893cdf0e10cSrcweir void SdrDragView::SetDragStripes(sal_Bool bOn)
894cdf0e10cSrcweir {
895cdf0e10cSrcweir if (mpCurrentSdrDragMethod && aDragStat.IsShown())
896cdf0e10cSrcweir {
897cdf0e10cSrcweir HideDragObj();
898cdf0e10cSrcweir bDragStripes=bOn;
899cdf0e10cSrcweir ShowDragObj();
900cdf0e10cSrcweir }
901cdf0e10cSrcweir else
902cdf0e10cSrcweir {
903cdf0e10cSrcweir bDragStripes=bOn;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir }
906cdf0e10cSrcweir
IsOrthoDesired() const907cdf0e10cSrcweir sal_Bool SdrDragView::IsOrthoDesired() const
908cdf0e10cSrcweir {
909cdf0e10cSrcweir if(mpCurrentSdrDragMethod && (IS_TYPE(SdrDragObjOwn, mpCurrentSdrDragMethod) || IS_TYPE(SdrDragResize, mpCurrentSdrDragMethod)))
910cdf0e10cSrcweir {
911cdf0e10cSrcweir return bOrthoDesiredOnMarked;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir
914cdf0e10cSrcweir return sal_False;
915cdf0e10cSrcweir }
916cdf0e10cSrcweir
917cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
918cdf0e10cSrcweir
SetRubberEdgeDragging(sal_Bool bOn)919cdf0e10cSrcweir void SdrDragView::SetRubberEdgeDragging(sal_Bool bOn)
920cdf0e10cSrcweir {
921cdf0e10cSrcweir if (bOn!=IsRubberEdgeDragging())
922cdf0e10cSrcweir {
923cdf0e10cSrcweir sal_uIntPtr nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
924cdf0e10cSrcweir sal_Bool bShowHide=nAnz!=0 && IsDragObj() &&
925cdf0e10cSrcweir (nRubberEdgeDraggingLimit>=nAnz);
926cdf0e10cSrcweir if (bShowHide)
927cdf0e10cSrcweir HideDragObj();
928cdf0e10cSrcweir bRubberEdgeDragging=bOn;
929cdf0e10cSrcweir if (bShowHide)
930cdf0e10cSrcweir ShowDragObj();
931cdf0e10cSrcweir }
932cdf0e10cSrcweir }
933cdf0e10cSrcweir
SetRubberEdgeDraggingLimit(sal_uInt16 nEdgeObjAnz)934cdf0e10cSrcweir void SdrDragView::SetRubberEdgeDraggingLimit(sal_uInt16 nEdgeObjAnz)
935cdf0e10cSrcweir {
936cdf0e10cSrcweir if (nEdgeObjAnz!=nRubberEdgeDraggingLimit)
937cdf0e10cSrcweir {
938cdf0e10cSrcweir sal_uIntPtr nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
939cdf0e10cSrcweir sal_Bool bShowHide=IsRubberEdgeDragging() && nAnz!=0 && IsDragObj() &&
940cdf0e10cSrcweir (nEdgeObjAnz>=nAnz)!=(nRubberEdgeDraggingLimit>=nAnz);
941cdf0e10cSrcweir if (bShowHide)
942cdf0e10cSrcweir HideDragObj();
943cdf0e10cSrcweir nRubberEdgeDraggingLimit=nEdgeObjAnz;
944cdf0e10cSrcweir if (bShowHide)
945cdf0e10cSrcweir ShowDragObj();
946cdf0e10cSrcweir }
947cdf0e10cSrcweir }
948cdf0e10cSrcweir
SetDetailedEdgeDragging(sal_Bool bOn)949cdf0e10cSrcweir void SdrDragView::SetDetailedEdgeDragging(sal_Bool bOn)
950cdf0e10cSrcweir {
951cdf0e10cSrcweir if (bOn!=IsDetailedEdgeDragging())
952cdf0e10cSrcweir {
953cdf0e10cSrcweir sal_uIntPtr nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
954cdf0e10cSrcweir sal_Bool bShowHide=nAnz!=0 && IsDragObj() &&
955cdf0e10cSrcweir (nDetailedEdgeDraggingLimit>=nAnz);
956cdf0e10cSrcweir if (bShowHide)
957cdf0e10cSrcweir HideDragObj();
958cdf0e10cSrcweir bDetailedEdgeDragging=bOn;
959cdf0e10cSrcweir if (bShowHide)
960cdf0e10cSrcweir ShowDragObj();
961cdf0e10cSrcweir }
962cdf0e10cSrcweir }
963cdf0e10cSrcweir
SetDetailedEdgeDraggingLimit(sal_uInt16 nEdgeObjAnz)964cdf0e10cSrcweir void SdrDragView::SetDetailedEdgeDraggingLimit(sal_uInt16 nEdgeObjAnz)
965cdf0e10cSrcweir {
966cdf0e10cSrcweir if (nEdgeObjAnz!=nDetailedEdgeDraggingLimit)
967cdf0e10cSrcweir {
968cdf0e10cSrcweir sal_uIntPtr nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
969cdf0e10cSrcweir sal_Bool bShowHide=IsDetailedEdgeDragging() && nAnz!=0 && IsDragObj() &&
970cdf0e10cSrcweir (nEdgeObjAnz>=nAnz)!=(nDetailedEdgeDraggingLimit>=nAnz);
971cdf0e10cSrcweir if (bShowHide)
972cdf0e10cSrcweir HideDragObj();
973cdf0e10cSrcweir nDetailedEdgeDraggingLimit=nEdgeObjAnz;
974cdf0e10cSrcweir if (bShowHide)
975cdf0e10cSrcweir ShowDragObj();
976cdf0e10cSrcweir }
977cdf0e10cSrcweir }
978cdf0e10cSrcweir
SetMarkHandles()979cdf0e10cSrcweir void SdrDragView::SetMarkHandles()
980cdf0e10cSrcweir {
981cdf0e10cSrcweir if( pDragHdl )
982cdf0e10cSrcweir pDragHdl = 0;
983cdf0e10cSrcweir
984cdf0e10cSrcweir SdrExchangeView::SetMarkHandles();
985cdf0e10cSrcweir }
986cdf0e10cSrcweir
SetSolidDragging(bool bOn)987cdf0e10cSrcweir void SdrDragView::SetSolidDragging(bool bOn)
988cdf0e10cSrcweir {
989cdf0e10cSrcweir if((bool)mbSolidDragging != bOn)
990cdf0e10cSrcweir {
991cdf0e10cSrcweir mbSolidDragging = bOn;
992cdf0e10cSrcweir }
993cdf0e10cSrcweir }
994cdf0e10cSrcweir
IsSolidDragging() const995cdf0e10cSrcweir bool SdrDragView::IsSolidDragging() const
996cdf0e10cSrcweir {
997cdf0e10cSrcweir // allow each user to disable by having a local setting, but using AND for
998cdf0e10cSrcweir // checking allowance
999cdf0e10cSrcweir return mbSolidDragging && getOptionsDrawinglayer().IsSolidDragCreate();
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir // eof
1003