update dev300-m58
[ooovba.git] / svx / source / svdraw / svddrgv.cxx
blob36d78ffc978c805ca1d91abdf73980631401452c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svddrgv.cxx,v $
10 * $Revision: 1.27.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <svx/svddrgv.hxx>
35 #include "xattr.hxx"
36 #include <svx/xpoly.hxx>
37 #include <svx/svdetc.hxx>
38 #include <svx/svdtrans.hxx>
39 #include <svx/svdundo.hxx>
40 #include <svx/svdocapt.hxx>
41 #include <svx/svdpagv.hxx>
42 #include <svx/svdopath.hxx>
43 #include <svx/svdoedge.hxx>
44 #include "svdstr.hrc"
45 #include "svdglob.hxx"
46 #include "svddrgm1.hxx"
47 #include <svx/obj3d.hxx>
48 #include <svx/svdoashp.hxx>
49 #include <sdrpaintwindow.hxx>
50 #include <basegfx/polygon/b2dpolypolygontools.hxx>
51 #include <basegfx/polygon/b2dpolygontools.hxx>
52 #include <svx/polypolygoneditor.hxx>
53 #include <basegfx/matrix/b2dhommatrix.hxx>
54 #include <svx/sdr/overlay/overlaymanager.hxx>
56 using namespace sdr;
58 ////////////////////////////////////////////////////////////////////////////////////////////////////
59 ////////////////////////////////////////////////////////////////////////////////////////////////////
61 // @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@ @@@@@ @@ @@
62 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
63 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
64 // @@ @@ @@@@@ @@@@@@ @@ @@@ @@@@@ @@ @@@@ @@@@@@@
65 // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
66 // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
67 // @@@@@ @@ @@ @@ @@ @@@@@ @ @@ @@@@@ @@ @@
69 ////////////////////////////////////////////////////////////////////////////////////////////////////
70 ////////////////////////////////////////////////////////////////////////////////////////////////////
72 void SdrDragView::ImpClearVars()
74 bFramDrag=FALSE;
75 eDragMode=SDRDRAG_MOVE;
76 bDragLimit=FALSE;
77 bMarkedHitMovesAlways=FALSE;
78 eDragHdl=HDL_MOVE;
79 pDragHdl=NULL;
80 bDragHdl=FALSE;
81 bDragSpecial=FALSE;
82 mpCurrentSdrDragMethod=NULL;
83 bDragStripes=FALSE;
84 bMirrRefDragObj=TRUE;
85 bDragWithCopy=FALSE;
86 pInsPointUndo=NULL;
87 bInsGluePoint=FALSE;
88 bInsObjPointMode=FALSE;
89 bInsGluePointMode=FALSE;
90 nDragXorPolyLimit=100;
91 nDragXorPointLimit=500;
92 bNoDragXorPolys=FALSE;
93 bAutoVertexCon=TRUE;
94 bAutoCornerCon=FALSE;
95 bRubberEdgeDragging=TRUE;
96 nRubberEdgeDraggingLimit=100;
97 bDetailedEdgeDragging=TRUE;
98 nDetailedEdgeDraggingLimit=10;
99 bResizeAtCenter=FALSE;
100 bCrookAtCenter=FALSE;
101 bMouseHideWhileDraggingPoints=FALSE;
103 // init using default
104 mbSolidDragging = getOptionsDrawinglayer().IsSolidDragCreate();
107 void SdrDragView::ImpMakeDragAttr()
109 ImpDelDragAttr();
112 SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut)
113 : SdrExchangeView(pModel1,pOut)
115 ImpClearVars();
116 ImpMakeDragAttr();
119 SdrDragView::~SdrDragView()
121 ImpDelDragAttr();
124 void SdrDragView::ImpDelDragAttr()
128 BOOL SdrDragView::IsAction() const
130 return (mpCurrentSdrDragMethod || SdrExchangeView::IsAction());
133 void SdrDragView::MovAction(const Point& rPnt)
135 SdrExchangeView::MovAction(rPnt);
136 if (mpCurrentSdrDragMethod)
138 MovDragObj(rPnt);
142 void SdrDragView::EndAction()
144 if (mpCurrentSdrDragMethod)
146 EndDragObj(FALSE);
148 SdrExchangeView::EndAction();
151 void SdrDragView::BckAction()
153 SdrExchangeView::BckAction();
154 BrkDragObj();
157 void SdrDragView::BrkAction()
159 SdrExchangeView::BrkAction();
160 BrkDragObj();
163 void SdrDragView::TakeActionRect(Rectangle& rRect) const
165 if (mpCurrentSdrDragMethod)
167 rRect=aDragStat.GetActionRect();
168 if (rRect.IsEmpty())
170 SdrPageView* pPV = GetSdrPageView();
172 if(pPV&& pPV->HasMarkedObjPageView())
174 // #i95646# is this used..?
175 const basegfx::B2DRange aBoundRange(mpCurrentSdrDragMethod->getCurrentRange());
176 rRect = Rectangle(
177 basegfx::fround(aBoundRange.getMinX()), basegfx::fround(aBoundRange.getMinY()),
178 basegfx::fround(aBoundRange.getMaxX()), basegfx::fround(aBoundRange.getMaxY()));
181 if (rRect.IsEmpty())
183 rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
186 else
188 SdrExchangeView::TakeActionRect(rRect);
192 BOOL SdrDragView::TakeDragObjAnchorPos(Point& rPos, BOOL bTR ) const
194 Rectangle aR;
195 TakeActionRect(aR);
196 rPos = bTR ? aR.TopRight() : aR.TopLeft();
197 if (GetMarkedObjectCount()==1 && IsDragObj() && // nur bei Einzelselektion
198 !IsDraggingPoints() && !IsDraggingGluePoints() && // nicht beim Punkteschieben
199 !mpCurrentSdrDragMethod->ISA(SdrDragMovHdl)) // nicht beim Handlesschieben
201 SdrObject* pObj=GetMarkedObjectByIndex(0);
202 if (pObj->ISA(SdrCaptionObj))
204 Point aPt(((SdrCaptionObj*)pObj)->GetTailPos());
205 BOOL bTail=eDragHdl==HDL_POLY; // Schwanz wird gedraggt (nicht so ganz feine Abfrage hier)
206 BOOL bOwn=mpCurrentSdrDragMethod->ISA(SdrDragObjOwn); // Objektspeziefisch
207 if (!bTail)
208 { // bei bTail liefert TakeActionRect schon das richtige
209 if (bOwn)
210 { // bOwn kann sein MoveTextFrame, ResizeTextFrame aber eben nicht mehr DragTail
211 rPos=aPt;
213 else
215 // drag the whole Object (Move, Resize, ...)
216 const basegfx::B2DPoint aTransformed(mpCurrentSdrDragMethod->getCurrentTransformation() * basegfx::B2DPoint(aPt.X(), aPt.Y()));
217 rPos.X() = basegfx::fround(aTransformed.getX());
218 rPos.Y() = basegfx::fround(aTransformed.getY());
222 return TRUE;
224 return FALSE;
227 ////////////////////////////////////////////////////////////////////////////////////////////////////
229 BOOL SdrDragView::TakeDragLimit(SdrDragMode /*eMode*/, Rectangle& /*rRect*/) const
231 return FALSE;
234 BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl, short nMinMov, SdrDragMethod* pForcedMeth)
236 BrkAction();
238 bool bRet=false;
240 SetDragWithCopy(FALSE);
241 //ForceEdgesOfMarkedNodes();
242 //TODO: aAni.Reset();
243 mpCurrentSdrDragMethod=NULL;
244 bDragSpecial=FALSE;
245 bDragLimit=FALSE;
246 SdrDragMode eTmpMode=eDragMode;
247 if (eTmpMode==SDRDRAG_MOVE && pHdl!=NULL && pHdl->GetKind()!=HDL_MOVE) {
248 eTmpMode=SDRDRAG_RESIZE;
250 bDragLimit=TakeDragLimit(eTmpMode,aDragLimit);
251 bFramDrag=ImpIsFrameHandles();
252 if (!bFramDrag &&
253 (pMarkedObj==NULL || !pMarkedObj->hasSpecialDrag()) &&
254 (pHdl==NULL || pHdl->GetObj()==NULL)) {
255 bFramDrag=TRUE;
258 Point aPnt(rPnt);
259 if(pHdl == NULL
260 || pHdl->GetKind() == HDL_MOVE
261 || pHdl->GetKind() == HDL_MIRX
262 || pHdl->GetKind() == HDL_TRNS
263 || pHdl->GetKind() == HDL_GRAD)
265 aDragStat.Reset(aPnt);
267 else
269 aDragStat.Reset(pHdl->GetPos());
272 aDragStat.SetView((SdrView*)this);
273 aDragStat.SetPageView(pMarkedPV); // <<-- hier muss die DragPV rein!!!
274 aDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
275 aDragStat.SetHdl(pHdl);
276 aDragStat.NextPoint();
277 pDragWin=pOut;
278 pDragHdl=pHdl;
279 eDragHdl= pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
280 bDragHdl=eDragHdl==HDL_REF1 || eDragHdl==HDL_REF2 || eDragHdl==HDL_MIRX;
282 // #103894# Expand test for HDL_ANCHOR_TR
283 BOOL bNotDraggable = (HDL_ANCHOR == eDragHdl || HDL_ANCHOR_TR == eDragHdl);
285 if(bDragHdl)
287 mpCurrentSdrDragMethod = new SdrDragMovHdl(*this);
289 else if(!bNotDraggable)
291 switch (eDragMode)
293 case SDRDRAG_ROTATE: case SDRDRAG_SHEAR: case SDRDRAG_DISTORT:
295 switch (eDragHdl)
297 case HDL_LEFT: case HDL_RIGHT:
298 case HDL_UPPER: case HDL_LOWER:
300 // Sind 3D-Objekte selektiert?
301 BOOL b3DObjSelected = FALSE;
302 for(UINT32 a=0;!b3DObjSelected && a<GetMarkedObjectCount();a++)
304 SdrObject* pObj = GetMarkedObjectByIndex(a);
305 if(pObj && pObj->ISA(E3dObject))
306 b3DObjSelected = TRUE;
308 // Falls ja, Shear auch bei !IsShearAllowed zulassen,
309 // da es sich bei 3D-Objekten um eingeschraenkte
310 // Rotationen handelt
311 if (!b3DObjSelected && !IsShearAllowed())
312 return FALSE;
313 mpCurrentSdrDragMethod = new SdrDragShear(*this,eDragMode==SDRDRAG_ROTATE);
314 } break;
315 case HDL_UPLFT: case HDL_UPRGT:
316 case HDL_LWLFT: case HDL_LWRGT:
318 if (eDragMode==SDRDRAG_SHEAR || eDragMode==SDRDRAG_DISTORT)
320 if (!IsDistortAllowed(TRUE) && !IsDistortAllowed(FALSE)) return FALSE;
321 mpCurrentSdrDragMethod = new SdrDragDistort(*this);
323 else
325 if (!IsRotateAllowed(TRUE)) return FALSE;
326 mpCurrentSdrDragMethod = new SdrDragRotate(*this);
328 } break;
329 default:
331 if (IsMarkedHitMovesAlways() && eDragHdl==HDL_MOVE)
332 { // HDL_MOVE ist auch wenn Obj direkt getroffen
333 if (!IsMoveAllowed()) return FALSE;
334 mpCurrentSdrDragMethod = new SdrDragMove(*this);
336 else
338 if (!IsRotateAllowed(TRUE)) return FALSE;
339 mpCurrentSdrDragMethod = new SdrDragRotate(*this);
343 } break;
344 case SDRDRAG_MIRROR:
346 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
348 if (!IsMoveAllowed()) return FALSE;
349 mpCurrentSdrDragMethod = new SdrDragMove(*this);
351 else
353 if (!IsMirrorAllowed(TRUE,TRUE)) return FALSE;
354 mpCurrentSdrDragMethod = new SdrDragMirror(*this);
356 } break;
358 case SDRDRAG_CROP:
360 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
362 if (!IsMoveAllowed())
363 return FALSE;
364 mpCurrentSdrDragMethod = new SdrDragMove(*this);
366 else
368 if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE))
369 return FALSE;
370 mpCurrentSdrDragMethod = new SdrDragCrop(*this);
373 break;
375 case SDRDRAG_TRANSPARENCE:
377 if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
379 if(!IsMoveAllowed())
380 return FALSE;
381 mpCurrentSdrDragMethod = new SdrDragMove(*this);
383 else
385 if(!IsTransparenceAllowed())
386 return FALSE;
388 mpCurrentSdrDragMethod = new SdrDragGradient(*this, FALSE);
390 break;
392 case SDRDRAG_GRADIENT:
394 if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
396 if(!IsMoveAllowed())
397 return FALSE;
398 mpCurrentSdrDragMethod = new SdrDragMove(*this);
400 else
402 if(!IsGradientAllowed())
403 return FALSE;
405 mpCurrentSdrDragMethod = new SdrDragGradient(*this);
407 break;
410 case SDRDRAG_CROOK :
412 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
414 if (!IsMoveAllowed()) return FALSE;
415 mpCurrentSdrDragMethod = new SdrDragMove(*this);
417 else
419 if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE)) return FALSE;
420 mpCurrentSdrDragMethod = new SdrDragCrook(*this);
422 } break;
424 default:
426 // SDRDRAG_MOVE
427 if((eDragHdl == HDL_MOVE) && !IsMoveAllowed())
429 return FALSE;
431 else if(eDragHdl == HDL_GLUE)
433 mpCurrentSdrDragMethod = new SdrDragMove(*this);
435 else
437 if(bFramDrag)
439 if(eDragHdl == HDL_MOVE)
441 mpCurrentSdrDragMethod = new SdrDragMove(*this);
443 else
445 if(!IsResizeAllowed(TRUE))
447 return FALSE;
450 sal_Bool bSingleTextObjMark = sal_False; // SJ: #i100490#
451 if ( GetMarkedObjectCount() == 1 )
453 pMarkedObj=GetMarkedObjectByIndex(0);
454 if ( pMarkedObj &&
455 pMarkedObj->ISA( SdrTextObj ) &&
456 static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame() )
457 bSingleTextObjMark = sal_True;
459 if ( bSingleTextObjMark )
460 mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
461 else
462 mpCurrentSdrDragMethod = new SdrDragResize(*this);
465 else
467 if(HDL_MOVE == eDragHdl)
469 const bool bCustomShapeSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrObjCustomShape));
471 if(bCustomShapeSelected)
473 mpCurrentSdrDragMethod = new SdrDragMove( *this );
476 else if(HDL_POLY == eDragHdl)
478 const bool bConnectorSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrEdgeObj));
480 if(bConnectorSelected)
482 // #i97784#
483 // fallback to old behaviour for connectors (see
484 // text in task description for more details)
486 else if(!IsMoveAllowed() || !IsResizeAllowed())
488 // #i77187#
489 // do not allow move of polygon points if object is move or size protected
490 return FALSE;
494 if(!mpCurrentSdrDragMethod)
496 // fallback to DragSpecial if no interaction defined
497 bDragSpecial = TRUE;
498 mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
505 if (pForcedMeth!=NULL)
507 delete mpCurrentSdrDragMethod;
508 mpCurrentSdrDragMethod = pForcedMeth;
510 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
511 if (mpCurrentSdrDragMethod)
513 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
514 if (!bRet)
516 if (pHdl==NULL && IS_TYPE(SdrDragObjOwn,mpCurrentSdrDragMethod))
518 // Aha, Obj kann nicht Move SpecialDrag, also MoveFrameDrag versuchen
519 delete mpCurrentSdrDragMethod;
520 mpCurrentSdrDragMethod = 0;
521 bDragSpecial=FALSE;
523 if (!IsMoveAllowed())
524 return FALSE;
526 bFramDrag=TRUE;
527 mpCurrentSdrDragMethod = new SdrDragMove(*this);
528 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
529 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
532 if (!bRet)
534 delete mpCurrentSdrDragMethod;
535 mpCurrentSdrDragMethod = 0;
536 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
541 return bRet;
544 void SdrDragView::MovDragObj(const Point& rPnt)
546 if (mpCurrentSdrDragMethod)
548 Point aPnt(rPnt);
549 ImpLimitToWorkArea(aPnt);
550 mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination
554 BOOL SdrDragView::EndDragObj(BOOL bCopy)
556 bool bRet(false);
558 // #i73341# If insert GluePoint, do not insist on last points being different
559 if(mpCurrentSdrDragMethod && aDragStat.IsMinMoved() && (IsInsertGluePoint() || aDragStat.GetNow() != aDragStat.GetPrev()))
561 ULONG nHdlAnzMerk=0;
563 if (bEliminatePolyPoints)
564 { // IBM Special
565 nHdlAnzMerk=GetMarkablePointCount();
568 const bool bUndo = IsUndoEnabled();
569 if (IsInsertGluePoint() && bUndo)
571 BegUndo(aInsPointUndoStr);
572 AddUndo(pInsPointUndo);
575 bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy);
577 if( IsInsertGluePoint() && bUndo)
578 EndUndo();
580 delete mpCurrentSdrDragMethod;
581 mpCurrentSdrDragMethod = 0;
583 if (bEliminatePolyPoints)
584 { // IBM Special
585 if (nHdlAnzMerk!=GetMarkablePointCount())
587 UnmarkAllPoints();
591 if (bInsPolyPoint)
593 SetMarkHandles();
594 bInsPolyPoint=FALSE;
595 if( bUndo )
597 BegUndo(aInsPointUndoStr);
598 AddUndo(pInsPointUndo);
599 EndUndo();
603 eDragHdl=HDL_MOVE;
604 pDragHdl=NULL;
606 if (!bSomeObjChgdFlag)
608 // Aha, Obj hat nicht gebroadcastet (z.B. Writer FlyFrames)
609 if(!bDragHdl)
611 AdjustMarkHdl();
615 else
617 BrkDragObj();
620 bInsPolyPoint=FALSE;
621 SetInsertGluePoint(FALSE);
623 return bRet;
626 void SdrDragView::BrkDragObj()
628 if (mpCurrentSdrDragMethod)
630 mpCurrentSdrDragMethod->CancelSdrDrag();
632 delete mpCurrentSdrDragMethod;
633 mpCurrentSdrDragMethod = 0;
635 if (bInsPolyPoint)
637 pInsPointUndo->Undo(); // Den eingefuegten Punkt wieder raus
638 delete pInsPointUndo;
639 pInsPointUndo=NULL;
640 SetMarkHandles();
641 bInsPolyPoint=FALSE;
644 if (IsInsertGluePoint())
646 pInsPointUndo->Undo(); // Den eingefuegten Klebepunkt wieder raus
647 delete pInsPointUndo;
648 pInsPointUndo=NULL;
649 SetInsertGluePoint(FALSE);
652 eDragHdl=HDL_MOVE;
653 pDragHdl=NULL;
657 BOOL SdrDragView::IsInsObjPointPossible() const
659 return pMarkedObj!=NULL && pMarkedObj->IsPolyObj();
662 sal_Bool SdrDragView::ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, sal_Bool bNewObj, OutputDevice* pOut)
664 sal_Bool bRet(sal_False);
666 if(pMarkedObj && pMarkedObj->ISA(SdrPathObj))
668 SdrPathObj* pMarkedPath = (SdrPathObj*)pMarkedObj;
669 BrkAction();
670 pInsPointUndo = dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pMarkedObj) );
671 DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
673 XubString aStr(ImpGetResStr(STR_DragInsertPoint));
674 XubString aName;
675 pMarkedObj->TakeObjNameSingul(aName);
676 xub_StrLen nPos(aStr.SearchAscii("%1"));
678 if(STRING_NOTFOUND != nPos)
680 aStr.Erase(nPos, 2);
681 aStr.Insert(aName, nPos);
684 aInsPointUndoStr = aStr;
685 Point aPt(rPnt);
687 if(bNewObj)
688 aPt = GetSnapPos(aPt,pMarkedPV);
690 sal_Bool bClosed0(pMarkedPath->IsClosedObj());
692 if(bIdxZwang)
694 mnInsPointNum = pMarkedPath->NbcInsPoint(nIdx, aPt, bNewObj, sal_True);
696 else
698 mnInsPointNum = pMarkedPath->NbcInsPointOld(aPt, bNewObj, sal_True);
701 if(bClosed0 != pMarkedPath->IsClosedObj())
703 // Obj was closed implicit
704 // object changed
705 pMarkedPath->SetChanged();
706 pMarkedPath->BroadcastObjectChange();
709 if(0xffffffff != mnInsPointNum)
711 bInsPolyPoint = sal_True;
712 UnmarkAllPoints();
713 AdjustMarkHdl();
715 bRet = BegDragObj(rPnt, pOut, aHdl.GetHdl(mnInsPointNum), 0);
717 if (bRet)
719 aDragStat.SetMinMoved();
720 MovDragObj(rPnt);
723 else
725 delete pInsPointUndo;
726 pInsPointUndo = NULL;
730 return bRet;
733 BOOL SdrDragView::EndInsObjPoint(SdrCreateCmd eCmd)
735 if(IsInsObjPoint())
737 sal_uInt32 nNextPnt(mnInsPointNum);
738 Point aPnt(aDragStat.GetNow());
739 BOOL bOk=EndDragObj(FALSE);
740 if (bOk==TRUE && eCmd!=SDRCREATE_FORCEEND)
742 // Ret=True bedeutet: Action ist vorbei.
743 bOk=!(ImpBegInsObjPoint(sal_True, nNextPnt, aPnt, eCmd == SDRCREATE_NEXTOBJECT, pDragWin));
746 return bOk;
747 } else return FALSE;
750 BOOL SdrDragView::IsInsGluePointPossible() const
752 BOOL bRet=FALSE;
753 if (IsInsGluePointMode() && AreObjectsMarked())
755 if (GetMarkedObjectCount()==1)
757 // FALSE liefern, wenn 1 Objekt und dieses ein Verbinder ist.
758 const SdrObject* pObj=GetMarkedObjectByIndex(0);
759 if (!HAS_BASE(SdrEdgeObj,pObj))
761 bRet=TRUE;
764 else
766 bRet=TRUE;
769 return bRet;
772 BOOL SdrDragView::BegInsGluePoint(const Point& rPnt)
774 BOOL bRet=FALSE;
775 SdrObject* pObj;
776 SdrPageView* pPV;
777 ULONG nMarkNum;
778 if (PickMarkedObj(rPnt,pObj,pPV,&nMarkNum,SDRSEARCH_PASS2BOUND))
780 BrkAction();
781 UnmarkAllGluePoints();
782 pInsPointUndo= dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj) );
783 DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
784 XubString aStr(ImpGetResStr(STR_DragInsertGluePoint));
785 XubString aName; pObj->TakeObjNameSingul(aName);
787 aStr.SearchAndReplaceAscii("%1", aName);
789 aInsPointUndoStr=aStr;
790 SdrGluePointList* pGPL=pObj->ForceGluePointList();
791 if (pGPL!=NULL)
793 USHORT nGlueIdx=pGPL->Insert(SdrGluePoint());
794 SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
795 USHORT nGlueId=rGP.GetId();
796 rGP.SetAbsolutePos(rPnt,*pObj);
798 SdrHdl* pHdl=NULL;
799 if (MarkGluePoint(pObj,nGlueId,pPV))
801 pHdl=GetGluePointHdl(pObj,nGlueId);
803 if (pHdl!=NULL && pHdl->GetKind()==HDL_GLUE && pHdl->GetObj()==pObj && pHdl->GetObjHdlNum()==nGlueId)
805 SetInsertGluePoint(TRUE);
806 bRet=BegDragObj(rPnt,NULL,pHdl,0);
807 if (bRet)
809 aDragStat.SetMinMoved();
810 MovDragObj(rPnt);
812 else
814 SetInsertGluePoint(FALSE);
815 delete pInsPointUndo;
816 pInsPointUndo=NULL;
819 else
821 DBG_ERROR("BegInsGluePoint(): GluePoint-Handle nicht gefunden");
824 else
826 // Keine Klebepunkte moeglich bei diesem Objekt (z.B. Edge)
827 SetInsertGluePoint(FALSE);
828 delete pInsPointUndo;
829 pInsPointUndo=NULL;
833 return bRet;
836 void SdrDragView::ShowDragObj()
838 if(mpCurrentSdrDragMethod && !aDragStat.IsShown())
840 for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
842 SdrPaintWindow* pCandidate = GetPaintWindow(a);
843 sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager();
845 if(pOverlayManager)
847 mpCurrentSdrDragMethod->CreateOverlayGeometry(*pOverlayManager);
849 // #i101679# Force changed overlay to be shown
850 pOverlayManager->flush();
854 aDragStat.SetShown(TRUE);
858 void SdrDragView::HideDragObj()
860 if(mpCurrentSdrDragMethod && aDragStat.IsShown())
862 mpCurrentSdrDragMethod->destroyOverlayGeometry();
863 aDragStat.SetShown(FALSE);
867 ////////////////////////////////////////////////////////////////////////////////////////////////////
869 void SdrDragView::SetNoDragXorPolys(BOOL bOn)
871 if (IsNoDragXorPolys()!=bOn)
873 const bool bDragging(mpCurrentSdrDragMethod);
874 const bool bShown(bDragging && aDragStat.IsShown());
876 if(bShown)
878 HideDragObj();
881 bNoDragXorPolys = bOn;
883 if(bDragging)
885 // force recreation of drag content
886 mpCurrentSdrDragMethod->resetSdrDragEntries();
889 if(bShown)
891 ShowDragObj();
896 void SdrDragView::SetDragStripes(BOOL bOn)
898 if (mpCurrentSdrDragMethod && aDragStat.IsShown())
900 HideDragObj();
901 bDragStripes=bOn;
902 ShowDragObj();
904 else
906 bDragStripes=bOn;
910 BOOL SdrDragView::IsOrthoDesired() const
912 if(mpCurrentSdrDragMethod && (IS_TYPE(SdrDragObjOwn, mpCurrentSdrDragMethod) || IS_TYPE(SdrDragResize, mpCurrentSdrDragMethod)))
914 return bOrthoDesiredOnMarked;
917 return FALSE;
920 ////////////////////////////////////////////////////////////////////////////////////////////////////
922 void SdrDragView::SetRubberEdgeDragging(BOOL bOn)
924 if (bOn!=IsRubberEdgeDragging())
926 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
927 BOOL bShowHide=nAnz!=0 && IsDragObj() &&
928 (nRubberEdgeDraggingLimit>=nAnz);
929 if (bShowHide)
930 HideDragObj();
931 bRubberEdgeDragging=bOn;
932 if (bShowHide)
933 ShowDragObj();
937 void SdrDragView::SetRubberEdgeDraggingLimit(USHORT nEdgeObjAnz)
939 if (nEdgeObjAnz!=nRubberEdgeDraggingLimit)
941 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
942 BOOL bShowHide=IsRubberEdgeDragging() && nAnz!=0 && IsDragObj() &&
943 (nEdgeObjAnz>=nAnz)!=(nRubberEdgeDraggingLimit>=nAnz);
944 if (bShowHide)
945 HideDragObj();
946 nRubberEdgeDraggingLimit=nEdgeObjAnz;
947 if (bShowHide)
948 ShowDragObj();
952 void SdrDragView::SetDetailedEdgeDragging(BOOL bOn)
954 if (bOn!=IsDetailedEdgeDragging())
956 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
957 BOOL bShowHide=nAnz!=0 && IsDragObj() &&
958 (nDetailedEdgeDraggingLimit>=nAnz);
959 if (bShowHide)
960 HideDragObj();
961 bDetailedEdgeDragging=bOn;
962 if (bShowHide)
963 ShowDragObj();
967 void SdrDragView::SetDetailedEdgeDraggingLimit(USHORT nEdgeObjAnz)
969 if (nEdgeObjAnz!=nDetailedEdgeDraggingLimit)
971 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
972 BOOL bShowHide=IsDetailedEdgeDragging() && nAnz!=0 && IsDragObj() &&
973 (nEdgeObjAnz>=nAnz)!=(nDetailedEdgeDraggingLimit>=nAnz);
974 if (bShowHide)
975 HideDragObj();
976 nDetailedEdgeDraggingLimit=nEdgeObjAnz;
977 if (bShowHide)
978 ShowDragObj();
982 void SdrDragView::SetMarkHandles()
984 if( pDragHdl )
985 pDragHdl = 0;
987 SdrExchangeView::SetMarkHandles();
990 void SdrDragView::SetSolidDragging(bool bOn)
992 if((bool)mbSolidDragging != bOn)
994 mbSolidDragging = bOn;
998 bool SdrDragView::IsSolidDragging() const
1000 // allow each user to disable by having a local setting, but using AND for
1001 // checking allowance
1002 return mbSolidDragging && getOptionsDrawinglayer().IsSolidDragCreate();
1005 // eof