bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / svdraw / svddrgv.cxx
blobe4cbdd40e1885f8dbded6c62685efc8bc1550c4f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/svddrgv.hxx>
22 #include "svx/xattr.hxx"
23 #include <svx/xpoly.hxx>
24 #include <svx/svdetc.hxx>
25 #include <svx/svdtrans.hxx>
26 #include <svx/svdundo.hxx>
27 #include <svx/svdocapt.hxx>
28 #include <svx/svdpagv.hxx>
29 #include <svx/svdopath.hxx>
30 #include <svx/svdoedge.hxx>
31 #include "svx/svdstr.hrc"
32 #include "svx/svdglob.hxx"
33 #include "svddrgm1.hxx"
34 #include <svx/obj3d.hxx>
35 #include <svx/svdoashp.hxx>
36 #include <svx/sdrpaintwindow.hxx>
37 #include <basegfx/polygon/b2dpolypolygontools.hxx>
38 #include <basegfx/polygon/b2dpolygontools.hxx>
39 #include <svx/polypolygoneditor.hxx>
40 #include <basegfx/matrix/b2dhommatrix.hxx>
41 #include <svx/sdr/overlay/overlaymanager.hxx>
43 using namespace sdr;
45 ////////////////////////////////////////////////////////////////////////////////////////////////////
46 ////////////////////////////////////////////////////////////////////////////////////////////////////
47 // DragView
48 ////////////////////////////////////////////////////////////////////////////////////////////////////
49 ////////////////////////////////////////////////////////////////////////////////////////////////////
51 void SdrDragView::ImpClearVars()
53 bFramDrag=sal_False;
54 eDragMode=SDRDRAG_MOVE;
55 bDragLimit=sal_False;
56 bMarkedHitMovesAlways=sal_False;
57 eDragHdl=HDL_MOVE;
58 pDragHdl=NULL;
59 bDragHdl=sal_False;
60 bDragSpecial=sal_False;
61 mpCurrentSdrDragMethod=NULL;
62 bDragStripes=sal_False;
63 bMirrRefDragObj=sal_True;
64 bDragWithCopy=sal_False;
65 pInsPointUndo=NULL;
66 bInsGluePoint=sal_False;
67 bInsObjPointMode=sal_False;
68 bInsGluePointMode=sal_False;
69 nDragXorPolyLimit=100;
70 nDragXorPointLimit=500;
71 bNoDragXorPolys=sal_False;
72 bAutoVertexCon=sal_True;
73 bAutoCornerCon=sal_False;
74 bRubberEdgeDragging=sal_True;
75 bDetailedEdgeDragging=sal_True;
76 nDetailedEdgeDraggingLimit=10;
77 bResizeAtCenter=sal_False;
78 bCrookAtCenter=sal_False;
79 bMouseHideWhileDraggingPoints=sal_False;
81 // init using default
82 mbSolidDragging = getOptionsDrawinglayer().IsSolidDragCreate();
85 SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut)
86 : SdrExchangeView(pModel1,pOut)
88 ImpClearVars();
91 SdrDragView::~SdrDragView()
95 sal_Bool SdrDragView::IsAction() const
97 return (mpCurrentSdrDragMethod || SdrExchangeView::IsAction());
100 void SdrDragView::MovAction(const Point& rPnt)
102 SdrExchangeView::MovAction(rPnt);
103 if (mpCurrentSdrDragMethod)
105 MovDragObj(rPnt);
109 void SdrDragView::EndAction()
111 if (mpCurrentSdrDragMethod)
113 EndDragObj(sal_False);
115 SdrExchangeView::EndAction();
118 void SdrDragView::BckAction()
120 SdrExchangeView::BckAction();
121 BrkDragObj();
124 void SdrDragView::BrkAction()
126 SdrExchangeView::BrkAction();
127 BrkDragObj();
130 void SdrDragView::TakeActionRect(Rectangle& rRect) const
132 if (mpCurrentSdrDragMethod)
134 rRect=aDragStat.GetActionRect();
135 if (rRect.IsEmpty())
137 SdrPageView* pPV = GetSdrPageView();
139 if(pPV&& pPV->HasMarkedObjPageView())
141 // #i95646# is this used..?
142 const basegfx::B2DRange aBoundRange(mpCurrentSdrDragMethod->getCurrentRange());
143 rRect = Rectangle(
144 basegfx::fround(aBoundRange.getMinX()), basegfx::fround(aBoundRange.getMinY()),
145 basegfx::fround(aBoundRange.getMaxX()), basegfx::fround(aBoundRange.getMaxY()));
148 if (rRect.IsEmpty())
150 rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
153 else
155 SdrExchangeView::TakeActionRect(rRect);
159 sal_Bool SdrDragView::TakeDragObjAnchorPos(Point& rPos, sal_Bool bTR ) const
161 Rectangle aR;
162 TakeActionRect(aR);
163 rPos = bTR ? aR.TopRight() : aR.TopLeft();
164 if (GetMarkedObjectCount()==1 && IsDragObj() && // only on single selection
165 !IsDraggingPoints() && !IsDraggingGluePoints() && // not when moving points
166 !mpCurrentSdrDragMethod->ISA(SdrDragMovHdl)) // not when moving handles
168 SdrObject* pObj=GetMarkedObjectByIndex(0);
169 if (pObj->ISA(SdrCaptionObj))
171 Point aPt(((SdrCaptionObj*)pObj)->GetTailPos());
172 bool bTail=eDragHdl==HDL_POLY; // drag tail
173 sal_Bool bOwn=mpCurrentSdrDragMethod->ISA(SdrDragObjOwn); // specific to object
174 if (!bTail)
175 { // for bTail, TakeActionRect already does the right thing
176 if (bOwn)
177 { // bOwn may be MoveTextFrame, ResizeTextFrame, but may not (any more) be DragTail
178 rPos=aPt;
180 else
182 // drag the whole Object (Move, Resize, ...)
183 const basegfx::B2DPoint aTransformed(mpCurrentSdrDragMethod->getCurrentTransformation() * basegfx::B2DPoint(aPt.X(), aPt.Y()));
184 rPos.X() = basegfx::fround(aTransformed.getX());
185 rPos.Y() = basegfx::fround(aTransformed.getY());
189 return sal_True;
191 return sal_False;
194 ////////////////////////////////////////////////////////////////////////////////////////////////////
196 sal_Bool SdrDragView::TakeDragLimit(SdrDragMode /*eMode*/, Rectangle& /*rRect*/) const
198 return sal_False;
201 sal_Bool SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl, short nMinMov, SdrDragMethod* pForcedMeth)
203 BrkAction();
205 bool bRet=false;
207 SetDragWithCopy(sal_False);
208 //TODO: aAni.Reset();
209 mpCurrentSdrDragMethod=NULL;
210 bDragSpecial=sal_False;
211 bDragLimit=sal_False;
212 SdrDragMode eTmpMode=eDragMode;
213 if (eTmpMode==SDRDRAG_MOVE && pHdl!=NULL && pHdl->GetKind()!=HDL_MOVE) {
214 eTmpMode=SDRDRAG_RESIZE;
216 bDragLimit=TakeDragLimit(eTmpMode,aDragLimit);
217 bFramDrag=ImpIsFrameHandles();
218 if (!bFramDrag &&
219 (pMarkedObj==NULL || !pMarkedObj->hasSpecialDrag()) &&
220 (pHdl==NULL || pHdl->GetObj()==NULL)) {
221 bFramDrag=sal_True;
224 Point aPnt(rPnt);
225 if(pHdl == NULL
226 || pHdl->GetKind() == HDL_MOVE
227 || pHdl->GetKind() == HDL_MIRX
228 || pHdl->GetKind() == HDL_TRNS
229 || pHdl->GetKind() == HDL_GRAD)
231 aDragStat.Reset(aPnt);
233 else
235 aDragStat.Reset(pHdl->GetPos());
238 aDragStat.SetView((SdrView*)this);
239 aDragStat.SetPageView(pMarkedPV); // <<-- DragPV has to go here!!!
240 aDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
241 aDragStat.SetHdl(pHdl);
242 aDragStat.NextPoint();
243 pDragWin=pOut;
244 pDragHdl=pHdl;
245 eDragHdl= pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
246 bDragHdl=eDragHdl==HDL_REF1 || eDragHdl==HDL_REF2 || eDragHdl==HDL_MIRX;
248 // Expand test for HDL_ANCHOR_TR
249 bool bNotDraggable = (HDL_ANCHOR == eDragHdl || HDL_ANCHOR_TR == eDragHdl);
251 if(pHdl && (pHdl->GetKind() == HDL_SMARTTAG) && pForcedMeth )
253 // just use the forced method for smart tags
255 else if(bDragHdl)
257 mpCurrentSdrDragMethod = new SdrDragMovHdl(*this);
259 else if(!bNotDraggable)
261 switch (eDragMode)
263 case SDRDRAG_ROTATE: case SDRDRAG_SHEAR: case SDRDRAG_DISTORT:
265 switch (eDragHdl)
267 case HDL_LEFT: case HDL_RIGHT:
268 case HDL_UPPER: case HDL_LOWER:
270 // are 3D objects selected?
271 bool b3DObjSelected = false;
272 for(sal_uInt32 a=0;!b3DObjSelected && a<GetMarkedObjectCount();a++)
274 SdrObject* pObj = GetMarkedObjectByIndex(a);
275 if(pObj && pObj->ISA(E3dObject))
276 b3DObjSelected = true;
278 // If yes, allow shear even when !IsShearAllowed,
279 // because 3D objects are limited rotations
280 if (!b3DObjSelected && !IsShearAllowed())
281 return sal_False;
282 mpCurrentSdrDragMethod = new SdrDragShear(*this,eDragMode==SDRDRAG_ROTATE);
283 } break;
284 case HDL_UPLFT: case HDL_UPRGT:
285 case HDL_LWLFT: case HDL_LWRGT:
287 if (eDragMode==SDRDRAG_SHEAR || eDragMode==SDRDRAG_DISTORT)
289 if (!IsDistortAllowed(sal_True) && !IsDistortAllowed(sal_False)) return sal_False;
290 mpCurrentSdrDragMethod = new SdrDragDistort(*this);
292 else
294 if (!IsRotateAllowed(sal_True)) return sal_False;
295 mpCurrentSdrDragMethod = new SdrDragRotate(*this);
297 } break;
298 default:
300 if (IsMarkedHitMovesAlways() && eDragHdl==HDL_MOVE)
301 { // HDL_MOVE is true, even if Obj is hit directly
302 if (!IsMoveAllowed()) return sal_False;
303 mpCurrentSdrDragMethod = new SdrDragMove(*this);
305 else
307 if (!IsRotateAllowed(sal_True)) return sal_False;
308 mpCurrentSdrDragMethod = new SdrDragRotate(*this);
312 } break;
313 case SDRDRAG_MIRROR:
315 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
317 if (!IsMoveAllowed()) return sal_False;
318 mpCurrentSdrDragMethod = new SdrDragMove(*this);
320 else
322 if (!IsMirrorAllowed(sal_True,sal_True)) return sal_False;
323 mpCurrentSdrDragMethod = new SdrDragMirror(*this);
325 } break;
327 case SDRDRAG_CROP:
329 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
331 if (!IsMoveAllowed())
332 return sal_False;
333 mpCurrentSdrDragMethod = new SdrDragMove(*this);
335 else
337 if (!IsCrookAllowed(sal_True) && !IsCrookAllowed(sal_False))
338 return sal_False;
339 mpCurrentSdrDragMethod = new SdrDragCrop(*this);
342 break;
344 case SDRDRAG_TRANSPARENCE:
346 if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
348 if(!IsMoveAllowed())
349 return sal_False;
350 mpCurrentSdrDragMethod = new SdrDragMove(*this);
352 else
354 if(!IsTransparenceAllowed())
355 return sal_False;
357 mpCurrentSdrDragMethod = new SdrDragGradient(*this, sal_False);
359 break;
361 case SDRDRAG_GRADIENT:
363 if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
365 if(!IsMoveAllowed())
366 return sal_False;
367 mpCurrentSdrDragMethod = new SdrDragMove(*this);
369 else
371 if(!IsGradientAllowed())
372 return sal_False;
374 mpCurrentSdrDragMethod = new SdrDragGradient(*this);
376 break;
379 case SDRDRAG_CROOK :
381 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
383 if (!IsMoveAllowed()) return sal_False;
384 mpCurrentSdrDragMethod = new SdrDragMove(*this);
386 else
388 if (!IsCrookAllowed(sal_True) && !IsCrookAllowed(sal_False)) return sal_False;
389 mpCurrentSdrDragMethod = new SdrDragCrook(*this);
391 } break;
393 default:
395 // SDRDRAG_MOVE
396 if((eDragHdl == HDL_MOVE) && !IsMoveAllowed())
398 return sal_False;
400 else if(eDragHdl == HDL_GLUE)
402 mpCurrentSdrDragMethod = new SdrDragMove(*this);
404 else
406 if(bFramDrag)
408 if(eDragHdl == HDL_MOVE)
410 mpCurrentSdrDragMethod = new SdrDragMove(*this);
412 else
414 if(!IsResizeAllowed(sal_True))
416 return sal_False;
419 bool bSingleTextObjMark = false; // SJ: #i100490#
420 if ( GetMarkedObjectCount() == 1 )
422 pMarkedObj=GetMarkedObjectByIndex(0);
423 if ( pMarkedObj &&
424 pMarkedObj->ISA( SdrTextObj ) &&
425 static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame() )
426 bSingleTextObjMark = true;
428 if ( bSingleTextObjMark )
429 mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
430 else
431 mpCurrentSdrDragMethod = new SdrDragResize(*this);
434 else
436 if(HDL_MOVE == eDragHdl)
438 const bool bCustomShapeSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrObjCustomShape));
440 if(bCustomShapeSelected)
442 mpCurrentSdrDragMethod = new SdrDragMove( *this );
445 else if(HDL_POLY == eDragHdl)
447 const bool bConnectorSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrEdgeObj));
449 if(bConnectorSelected)
451 // #i97784#
452 // fallback to old behaviour for connectors (see
453 // text in task description for more details)
455 else if(!IsMoveAllowed() || !IsResizeAllowed())
457 // #i77187#
458 // do not allow move of polygon points if object is move or size protected
459 return sal_False;
463 if(!mpCurrentSdrDragMethod)
465 // fallback to DragSpecial if no interaction defined
466 bDragSpecial = sal_True;
467 mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
474 if (pForcedMeth!=NULL)
476 delete mpCurrentSdrDragMethod;
477 mpCurrentSdrDragMethod = pForcedMeth;
479 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
480 if (mpCurrentSdrDragMethod)
482 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
483 if (!bRet)
485 if (pHdl==NULL && IS_TYPE(SdrDragObjOwn,mpCurrentSdrDragMethod))
487 // Obj may not Move SpecialDrag, so try with MoveFrameDrag
488 delete mpCurrentSdrDragMethod;
489 mpCurrentSdrDragMethod = 0;
490 bDragSpecial=sal_False;
492 if (!IsMoveAllowed())
493 return sal_False;
495 bFramDrag=sal_True;
496 mpCurrentSdrDragMethod = new SdrDragMove(*this);
497 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
498 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
501 if (!bRet)
503 delete mpCurrentSdrDragMethod;
504 mpCurrentSdrDragMethod = 0;
505 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
510 return bRet;
513 void SdrDragView::MovDragObj(const Point& rPnt)
515 if (mpCurrentSdrDragMethod)
517 Point aPnt(rPnt);
518 ImpLimitToWorkArea(aPnt);
519 mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination
523 sal_Bool SdrDragView::EndDragObj(sal_Bool bCopy)
525 bool bRet(false);
527 // #i73341# If inserting GluePoint, do not insist on last points being different
528 if(mpCurrentSdrDragMethod && aDragStat.IsMinMoved() && (IsInsertGluePoint() || aDragStat.GetNow() != aDragStat.GetPrev()))
530 sal_uIntPtr nHdlAnzMerk=0;
532 if (bEliminatePolyPoints)
533 { // IBM Special
534 nHdlAnzMerk=GetMarkablePointCount();
537 const bool bUndo = IsUndoEnabled();
538 if (IsInsertGluePoint() && bUndo)
540 BegUndo(aInsPointUndoStr);
541 AddUndo(pInsPointUndo);
544 bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy);
546 if( IsInsertGluePoint() && bUndo)
547 EndUndo();
549 delete mpCurrentSdrDragMethod;
550 mpCurrentSdrDragMethod = 0;
552 if (bEliminatePolyPoints)
553 { // IBM Special
554 if (nHdlAnzMerk!=GetMarkablePointCount())
556 UnmarkAllPoints();
560 if (bInsPolyPoint)
562 SetMarkHandles();
563 bInsPolyPoint=sal_False;
564 if( bUndo )
566 BegUndo(aInsPointUndoStr);
567 AddUndo(pInsPointUndo);
568 EndUndo();
572 eDragHdl=HDL_MOVE;
573 pDragHdl=NULL;
575 if (!bSomeObjChgdFlag)
577 // Obj did not broadcast (e. g. Writer FlyFrames)
578 if(!bDragHdl)
580 AdjustMarkHdl();
584 else
586 BrkDragObj();
589 bInsPolyPoint=sal_False;
590 SetInsertGluePoint(sal_False);
592 return bRet;
595 void SdrDragView::BrkDragObj()
597 if (mpCurrentSdrDragMethod)
599 mpCurrentSdrDragMethod->CancelSdrDrag();
601 delete mpCurrentSdrDragMethod;
602 mpCurrentSdrDragMethod = 0;
604 if (bInsPolyPoint)
606 pInsPointUndo->Undo(); // delete inserted point again
607 delete pInsPointUndo;
608 pInsPointUndo=NULL;
609 SetMarkHandles();
610 bInsPolyPoint=sal_False;
613 if (IsInsertGluePoint())
615 pInsPointUndo->Undo(); // delete inserted glue point again
616 delete pInsPointUndo;
617 pInsPointUndo=NULL;
618 SetInsertGluePoint(sal_False);
621 eDragHdl=HDL_MOVE;
622 pDragHdl=NULL;
626 bool SdrDragView::IsInsObjPointPossible() const
628 return pMarkedObj!=NULL && pMarkedObj->IsPolyObj();
631 sal_Bool SdrDragView::ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, sal_Bool bNewObj, OutputDevice* pOut)
633 sal_Bool bRet(sal_False);
635 if(pMarkedObj && pMarkedObj->ISA(SdrPathObj))
637 SdrPathObj* pMarkedPath = (SdrPathObj*)pMarkedObj;
638 BrkAction();
639 pInsPointUndo = dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pMarkedObj) );
640 DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
642 XubString aStr(ImpGetResStr(STR_DragInsertPoint));
643 XubString aName;
644 pMarkedObj->TakeObjNameSingul(aName);
645 xub_StrLen nPos(aStr.SearchAscii("%1"));
647 if(STRING_NOTFOUND != nPos)
649 aStr.Erase(nPos, 2);
650 aStr.Insert(aName, nPos);
653 aInsPointUndoStr = aStr;
654 Point aPt(rPnt);
656 if(bNewObj)
657 aPt = GetSnapPos(aPt,pMarkedPV);
659 bool bClosed0 = pMarkedPath->IsClosedObj();
661 if(bIdxZwang)
663 mnInsPointNum = pMarkedPath->NbcInsPoint(nIdx, aPt, bNewObj, sal_True);
665 else
667 mnInsPointNum = pMarkedPath->NbcInsPointOld(aPt, bNewObj, sal_True);
670 if(bClosed0 != pMarkedPath->IsClosedObj())
672 // Obj was closed implicitly
673 // object changed
674 pMarkedPath->SetChanged();
675 pMarkedPath->BroadcastObjectChange();
678 if(0xffffffff != mnInsPointNum)
680 bInsPolyPoint = sal_True;
681 UnmarkAllPoints();
682 AdjustMarkHdl();
684 bRet = BegDragObj(rPnt, pOut, aHdl.GetHdl(mnInsPointNum), 0);
686 if (bRet)
688 aDragStat.SetMinMoved();
689 MovDragObj(rPnt);
692 else
694 delete pInsPointUndo;
695 pInsPointUndo = NULL;
699 return bRet;
702 sal_Bool SdrDragView::EndInsObjPoint(SdrCreateCmd eCmd)
704 if(IsInsObjPoint())
706 sal_uInt32 nNextPnt(mnInsPointNum);
707 Point aPnt(aDragStat.GetNow());
708 sal_Bool bOk=EndDragObj(sal_False);
709 if (bOk==sal_True && eCmd!=SDRCREATE_FORCEEND)
711 // Ret=True means: Action is over.
712 bOk=!(ImpBegInsObjPoint(sal_True, nNextPnt, aPnt, eCmd == SDRCREATE_NEXTOBJECT, pDragWin));
715 return bOk;
716 } else return sal_False;
719 sal_Bool SdrDragView::IsInsGluePointPossible() const
721 sal_Bool bRet=sal_False;
722 if (IsInsGluePointMode() && AreObjectsMarked())
724 if (GetMarkedObjectCount()==1)
726 // return sal_False, if only 1 object which is a connector.
727 const SdrObject* pObj=GetMarkedObjectByIndex(0);
728 if (!HAS_BASE(SdrEdgeObj,pObj))
730 bRet=sal_True;
733 else
735 bRet=sal_True;
738 return bRet;
741 sal_Bool SdrDragView::BegInsGluePoint(const Point& rPnt)
743 sal_Bool bRet=sal_False;
744 SdrObject* pObj;
745 SdrPageView* pPV;
746 sal_uIntPtr nMarkNum;
747 if (PickMarkedObj(rPnt,pObj,pPV,&nMarkNum,SDRSEARCH_PASS2BOUND))
749 BrkAction();
750 UnmarkAllGluePoints();
751 pInsPointUndo= dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj) );
752 DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
753 XubString aStr(ImpGetResStr(STR_DragInsertGluePoint));
754 XubString aName; pObj->TakeObjNameSingul(aName);
756 aStr.SearchAndReplaceAscii("%1", aName);
758 aInsPointUndoStr=aStr;
759 SdrGluePointList* pGPL=pObj->ForceGluePointList();
760 if (pGPL!=NULL)
762 sal_uInt16 nGlueIdx=pGPL->Insert(SdrGluePoint());
763 SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
764 sal_uInt16 nGlueId=rGP.GetId();
765 rGP.SetAbsolutePos(rPnt,*pObj);
767 SdrHdl* pHdl=NULL;
768 if (MarkGluePoint(pObj,nGlueId,pPV))
770 pHdl=GetGluePointHdl(pObj,nGlueId);
772 if (pHdl!=NULL && pHdl->GetKind()==HDL_GLUE && pHdl->GetObj()==pObj && pHdl->GetObjHdlNum()==nGlueId)
774 SetInsertGluePoint(sal_True);
775 bRet=BegDragObj(rPnt,NULL,pHdl,0);
776 if (bRet)
778 aDragStat.SetMinMoved();
779 MovDragObj(rPnt);
781 else
783 SetInsertGluePoint(sal_False);
784 delete pInsPointUndo;
785 pInsPointUndo=NULL;
788 else
790 OSL_FAIL("BegInsGluePoint(): GluePoint handle not found.");
793 else
795 // no glue points possible for this object (e. g. Edge)
796 SetInsertGluePoint(sal_False);
797 delete pInsPointUndo;
798 pInsPointUndo=NULL;
802 return bRet;
805 void SdrDragView::ShowDragObj()
807 if(mpCurrentSdrDragMethod && !aDragStat.IsShown())
809 for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
811 SdrPaintWindow* pCandidate = GetPaintWindow(a);
812 rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = pCandidate->GetOverlayManager();
814 if (xOverlayManager.is())
816 mpCurrentSdrDragMethod->CreateOverlayGeometry(*xOverlayManager);
818 // #i101679# Force changed overlay to be shown
819 xOverlayManager->flush();
823 aDragStat.SetShown(sal_True);
827 void SdrDragView::HideDragObj()
829 if(mpCurrentSdrDragMethod && aDragStat.IsShown())
831 mpCurrentSdrDragMethod->destroyOverlayGeometry();
832 aDragStat.SetShown(sal_False);
836 ////////////////////////////////////////////////////////////////////////////////////////////////////
838 void SdrDragView::SetNoDragXorPolys(sal_Bool bOn)
840 if (IsNoDragXorPolys()!=bOn)
842 const bool bDragging(mpCurrentSdrDragMethod);
843 const bool bShown(bDragging && aDragStat.IsShown());
845 if(bShown)
847 HideDragObj();
850 bNoDragXorPolys = bOn;
852 if(bDragging)
854 // force recreation of drag content
855 mpCurrentSdrDragMethod->resetSdrDragEntries();
858 if(bShown)
860 ShowDragObj();
865 void SdrDragView::SetDragStripes(sal_Bool bOn)
867 if (mpCurrentSdrDragMethod && aDragStat.IsShown())
869 HideDragObj();
870 bDragStripes=bOn;
871 ShowDragObj();
873 else
875 bDragStripes=bOn;
879 sal_Bool SdrDragView::IsOrthoDesired() const
881 if(mpCurrentSdrDragMethod && (IS_TYPE(SdrDragObjOwn, mpCurrentSdrDragMethod) || IS_TYPE(SdrDragResize, mpCurrentSdrDragMethod)))
883 return bOrthoDesiredOnMarked;
886 return sal_False;
889 void SdrDragView::SetMarkHandles()
891 if( pDragHdl )
892 pDragHdl = 0;
894 SdrExchangeView::SetMarkHandles();
897 void SdrDragView::SetSolidDragging(bool bOn)
899 if((bool)mbSolidDragging != bOn)
901 mbSolidDragging = bOn;
905 bool SdrDragView::IsSolidDragging() const
907 // allow each user to disable by having a local setting, but using AND for
908 // checking allowance
909 return mbSolidDragging && getOptionsDrawinglayer().IsSolidDragCreate();
912 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */