merge the formfield patch from ooo-build
[ooovba.git] / svx / source / svdraw / svddrgv.cxx
blob7c653e828ef02be972f734eb0f245289cf395122
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(pHdl && (pHdl->GetKind() == HDL_SMARTTAG) && pForcedMeth )
287 // just use the forced method for smart tags
289 else if(bDragHdl)
291 mpCurrentSdrDragMethod = new SdrDragMovHdl(*this);
293 else if(!bNotDraggable)
295 switch (eDragMode)
297 case SDRDRAG_ROTATE: case SDRDRAG_SHEAR: case SDRDRAG_DISTORT:
299 switch (eDragHdl)
301 case HDL_LEFT: case HDL_RIGHT:
302 case HDL_UPPER: case HDL_LOWER:
304 // Sind 3D-Objekte selektiert?
305 BOOL b3DObjSelected = FALSE;
306 for(UINT32 a=0;!b3DObjSelected && a<GetMarkedObjectCount();a++)
308 SdrObject* pObj = GetMarkedObjectByIndex(a);
309 if(pObj && pObj->ISA(E3dObject))
310 b3DObjSelected = TRUE;
312 // Falls ja, Shear auch bei !IsShearAllowed zulassen,
313 // da es sich bei 3D-Objekten um eingeschraenkte
314 // Rotationen handelt
315 if (!b3DObjSelected && !IsShearAllowed())
316 return FALSE;
317 mpCurrentSdrDragMethod = new SdrDragShear(*this,eDragMode==SDRDRAG_ROTATE);
318 } break;
319 case HDL_UPLFT: case HDL_UPRGT:
320 case HDL_LWLFT: case HDL_LWRGT:
322 if (eDragMode==SDRDRAG_SHEAR || eDragMode==SDRDRAG_DISTORT)
324 if (!IsDistortAllowed(TRUE) && !IsDistortAllowed(FALSE)) return FALSE;
325 mpCurrentSdrDragMethod = new SdrDragDistort(*this);
327 else
329 if (!IsRotateAllowed(TRUE)) return FALSE;
330 mpCurrentSdrDragMethod = new SdrDragRotate(*this);
332 } break;
333 default:
335 if (IsMarkedHitMovesAlways() && eDragHdl==HDL_MOVE)
336 { // HDL_MOVE ist auch wenn Obj direkt getroffen
337 if (!IsMoveAllowed()) return FALSE;
338 mpCurrentSdrDragMethod = new SdrDragMove(*this);
340 else
342 if (!IsRotateAllowed(TRUE)) return FALSE;
343 mpCurrentSdrDragMethod = new SdrDragRotate(*this);
347 } break;
348 case SDRDRAG_MIRROR:
350 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
352 if (!IsMoveAllowed()) return FALSE;
353 mpCurrentSdrDragMethod = new SdrDragMove(*this);
355 else
357 if (!IsMirrorAllowed(TRUE,TRUE)) return FALSE;
358 mpCurrentSdrDragMethod = new SdrDragMirror(*this);
360 } break;
362 case SDRDRAG_CROP:
364 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
366 if (!IsMoveAllowed())
367 return FALSE;
368 mpCurrentSdrDragMethod = new SdrDragMove(*this);
370 else
372 if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE))
373 return FALSE;
374 mpCurrentSdrDragMethod = new SdrDragCrop(*this);
377 break;
379 case SDRDRAG_TRANSPARENCE:
381 if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
383 if(!IsMoveAllowed())
384 return FALSE;
385 mpCurrentSdrDragMethod = new SdrDragMove(*this);
387 else
389 if(!IsTransparenceAllowed())
390 return FALSE;
392 mpCurrentSdrDragMethod = new SdrDragGradient(*this, FALSE);
394 break;
396 case SDRDRAG_GRADIENT:
398 if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
400 if(!IsMoveAllowed())
401 return FALSE;
402 mpCurrentSdrDragMethod = new SdrDragMove(*this);
404 else
406 if(!IsGradientAllowed())
407 return FALSE;
409 mpCurrentSdrDragMethod = new SdrDragGradient(*this);
411 break;
414 case SDRDRAG_CROOK :
416 if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
418 if (!IsMoveAllowed()) return FALSE;
419 mpCurrentSdrDragMethod = new SdrDragMove(*this);
421 else
423 if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE)) return FALSE;
424 mpCurrentSdrDragMethod = new SdrDragCrook(*this);
426 } break;
428 default:
430 // SDRDRAG_MOVE
431 if((eDragHdl == HDL_MOVE) && !IsMoveAllowed())
433 return FALSE;
435 else if(eDragHdl == HDL_GLUE)
437 mpCurrentSdrDragMethod = new SdrDragMove(*this);
439 else
441 if(bFramDrag)
443 if(eDragHdl == HDL_MOVE)
445 mpCurrentSdrDragMethod = new SdrDragMove(*this);
447 else
449 if(!IsResizeAllowed(TRUE))
451 return FALSE;
454 sal_Bool bSingleTextObjMark = sal_False; // SJ: #i100490#
455 if ( GetMarkedObjectCount() == 1 )
457 pMarkedObj=GetMarkedObjectByIndex(0);
458 if ( pMarkedObj &&
459 pMarkedObj->ISA( SdrTextObj ) &&
460 static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame() )
461 bSingleTextObjMark = sal_True;
463 if ( bSingleTextObjMark )
464 mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
465 else
466 mpCurrentSdrDragMethod = new SdrDragResize(*this);
469 else
471 if(HDL_MOVE == eDragHdl)
473 const bool bCustomShapeSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrObjCustomShape));
475 if(bCustomShapeSelected)
477 mpCurrentSdrDragMethod = new SdrDragMove( *this );
480 else if(HDL_POLY == eDragHdl)
482 const bool bConnectorSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrEdgeObj));
484 if(bConnectorSelected)
486 // #i97784#
487 // fallback to old behaviour for connectors (see
488 // text in task description for more details)
490 else if(!IsMoveAllowed() || !IsResizeAllowed())
492 // #i77187#
493 // do not allow move of polygon points if object is move or size protected
494 return FALSE;
498 if(!mpCurrentSdrDragMethod)
500 // fallback to DragSpecial if no interaction defined
501 bDragSpecial = TRUE;
502 mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
509 if (pForcedMeth!=NULL)
511 delete mpCurrentSdrDragMethod;
512 mpCurrentSdrDragMethod = pForcedMeth;
514 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
515 if (mpCurrentSdrDragMethod)
517 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
518 if (!bRet)
520 if (pHdl==NULL && IS_TYPE(SdrDragObjOwn,mpCurrentSdrDragMethod))
522 // Aha, Obj kann nicht Move SpecialDrag, also MoveFrameDrag versuchen
523 delete mpCurrentSdrDragMethod;
524 mpCurrentSdrDragMethod = 0;
525 bDragSpecial=FALSE;
527 if (!IsMoveAllowed())
528 return FALSE;
530 bFramDrag=TRUE;
531 mpCurrentSdrDragMethod = new SdrDragMove(*this);
532 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
533 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
536 if (!bRet)
538 delete mpCurrentSdrDragMethod;
539 mpCurrentSdrDragMethod = 0;
540 aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
545 return bRet;
548 void SdrDragView::MovDragObj(const Point& rPnt)
550 if (mpCurrentSdrDragMethod)
552 Point aPnt(rPnt);
553 ImpLimitToWorkArea(aPnt);
554 mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination
558 BOOL SdrDragView::EndDragObj(BOOL bCopy)
560 bool bRet(false);
562 // #i73341# If insert GluePoint, do not insist on last points being different
563 if(mpCurrentSdrDragMethod && aDragStat.IsMinMoved() && (IsInsertGluePoint() || aDragStat.GetNow() != aDragStat.GetPrev()))
565 ULONG nHdlAnzMerk=0;
567 if (bEliminatePolyPoints)
568 { // IBM Special
569 nHdlAnzMerk=GetMarkablePointCount();
572 const bool bUndo = IsUndoEnabled();
573 if (IsInsertGluePoint() && bUndo)
575 BegUndo(aInsPointUndoStr);
576 AddUndo(pInsPointUndo);
579 bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy);
581 if( IsInsertGluePoint() && bUndo)
582 EndUndo();
584 delete mpCurrentSdrDragMethod;
585 mpCurrentSdrDragMethod = 0;
587 if (bEliminatePolyPoints)
588 { // IBM Special
589 if (nHdlAnzMerk!=GetMarkablePointCount())
591 UnmarkAllPoints();
595 if (bInsPolyPoint)
597 SetMarkHandles();
598 bInsPolyPoint=FALSE;
599 if( bUndo )
601 BegUndo(aInsPointUndoStr);
602 AddUndo(pInsPointUndo);
603 EndUndo();
607 eDragHdl=HDL_MOVE;
608 pDragHdl=NULL;
610 if (!bSomeObjChgdFlag)
612 // Aha, Obj hat nicht gebroadcastet (z.B. Writer FlyFrames)
613 if(!bDragHdl)
615 AdjustMarkHdl();
619 else
621 BrkDragObj();
624 bInsPolyPoint=FALSE;
625 SetInsertGluePoint(FALSE);
627 return bRet;
630 void SdrDragView::BrkDragObj()
632 if (mpCurrentSdrDragMethod)
634 mpCurrentSdrDragMethod->CancelSdrDrag();
636 delete mpCurrentSdrDragMethod;
637 mpCurrentSdrDragMethod = 0;
639 if (bInsPolyPoint)
641 pInsPointUndo->Undo(); // Den eingefuegten Punkt wieder raus
642 delete pInsPointUndo;
643 pInsPointUndo=NULL;
644 SetMarkHandles();
645 bInsPolyPoint=FALSE;
648 if (IsInsertGluePoint())
650 pInsPointUndo->Undo(); // Den eingefuegten Klebepunkt wieder raus
651 delete pInsPointUndo;
652 pInsPointUndo=NULL;
653 SetInsertGluePoint(FALSE);
656 eDragHdl=HDL_MOVE;
657 pDragHdl=NULL;
661 BOOL SdrDragView::IsInsObjPointPossible() const
663 return pMarkedObj!=NULL && pMarkedObj->IsPolyObj();
666 sal_Bool SdrDragView::ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, sal_Bool bNewObj, OutputDevice* pOut)
668 sal_Bool bRet(sal_False);
670 if(pMarkedObj && pMarkedObj->ISA(SdrPathObj))
672 SdrPathObj* pMarkedPath = (SdrPathObj*)pMarkedObj;
673 BrkAction();
674 pInsPointUndo = dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pMarkedObj) );
675 DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
677 XubString aStr(ImpGetResStr(STR_DragInsertPoint));
678 XubString aName;
679 pMarkedObj->TakeObjNameSingul(aName);
680 xub_StrLen nPos(aStr.SearchAscii("%1"));
682 if(STRING_NOTFOUND != nPos)
684 aStr.Erase(nPos, 2);
685 aStr.Insert(aName, nPos);
688 aInsPointUndoStr = aStr;
689 Point aPt(rPnt);
691 if(bNewObj)
692 aPt = GetSnapPos(aPt,pMarkedPV);
694 sal_Bool bClosed0(pMarkedPath->IsClosedObj());
696 if(bIdxZwang)
698 mnInsPointNum = pMarkedPath->NbcInsPoint(nIdx, aPt, bNewObj, sal_True);
700 else
702 mnInsPointNum = pMarkedPath->NbcInsPointOld(aPt, bNewObj, sal_True);
705 if(bClosed0 != pMarkedPath->IsClosedObj())
707 // Obj was closed implicit
708 // object changed
709 pMarkedPath->SetChanged();
710 pMarkedPath->BroadcastObjectChange();
713 if(0xffffffff != mnInsPointNum)
715 bInsPolyPoint = sal_True;
716 UnmarkAllPoints();
717 AdjustMarkHdl();
719 bRet = BegDragObj(rPnt, pOut, aHdl.GetHdl(mnInsPointNum), 0);
721 if (bRet)
723 aDragStat.SetMinMoved();
724 MovDragObj(rPnt);
727 else
729 delete pInsPointUndo;
730 pInsPointUndo = NULL;
734 return bRet;
737 BOOL SdrDragView::EndInsObjPoint(SdrCreateCmd eCmd)
739 if(IsInsObjPoint())
741 sal_uInt32 nNextPnt(mnInsPointNum);
742 Point aPnt(aDragStat.GetNow());
743 BOOL bOk=EndDragObj(FALSE);
744 if (bOk==TRUE && eCmd!=SDRCREATE_FORCEEND)
746 // Ret=True bedeutet: Action ist vorbei.
747 bOk=!(ImpBegInsObjPoint(sal_True, nNextPnt, aPnt, eCmd == SDRCREATE_NEXTOBJECT, pDragWin));
750 return bOk;
751 } else return FALSE;
754 BOOL SdrDragView::IsInsGluePointPossible() const
756 BOOL bRet=FALSE;
757 if (IsInsGluePointMode() && AreObjectsMarked())
759 if (GetMarkedObjectCount()==1)
761 // FALSE liefern, wenn 1 Objekt und dieses ein Verbinder ist.
762 const SdrObject* pObj=GetMarkedObjectByIndex(0);
763 if (!HAS_BASE(SdrEdgeObj,pObj))
765 bRet=TRUE;
768 else
770 bRet=TRUE;
773 return bRet;
776 BOOL SdrDragView::BegInsGluePoint(const Point& rPnt)
778 BOOL bRet=FALSE;
779 SdrObject* pObj;
780 SdrPageView* pPV;
781 ULONG nMarkNum;
782 if (PickMarkedObj(rPnt,pObj,pPV,&nMarkNum,SDRSEARCH_PASS2BOUND))
784 BrkAction();
785 UnmarkAllGluePoints();
786 pInsPointUndo= dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj) );
787 DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
788 XubString aStr(ImpGetResStr(STR_DragInsertGluePoint));
789 XubString aName; pObj->TakeObjNameSingul(aName);
791 aStr.SearchAndReplaceAscii("%1", aName);
793 aInsPointUndoStr=aStr;
794 SdrGluePointList* pGPL=pObj->ForceGluePointList();
795 if (pGPL!=NULL)
797 USHORT nGlueIdx=pGPL->Insert(SdrGluePoint());
798 SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
799 USHORT nGlueId=rGP.GetId();
800 rGP.SetAbsolutePos(rPnt,*pObj);
802 SdrHdl* pHdl=NULL;
803 if (MarkGluePoint(pObj,nGlueId,pPV))
805 pHdl=GetGluePointHdl(pObj,nGlueId);
807 if (pHdl!=NULL && pHdl->GetKind()==HDL_GLUE && pHdl->GetObj()==pObj && pHdl->GetObjHdlNum()==nGlueId)
809 SetInsertGluePoint(TRUE);
810 bRet=BegDragObj(rPnt,NULL,pHdl,0);
811 if (bRet)
813 aDragStat.SetMinMoved();
814 MovDragObj(rPnt);
816 else
818 SetInsertGluePoint(FALSE);
819 delete pInsPointUndo;
820 pInsPointUndo=NULL;
823 else
825 DBG_ERROR("BegInsGluePoint(): GluePoint-Handle nicht gefunden");
828 else
830 // Keine Klebepunkte moeglich bei diesem Objekt (z.B. Edge)
831 SetInsertGluePoint(FALSE);
832 delete pInsPointUndo;
833 pInsPointUndo=NULL;
837 return bRet;
840 void SdrDragView::ShowDragObj()
842 if(mpCurrentSdrDragMethod && !aDragStat.IsShown())
844 for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
846 SdrPaintWindow* pCandidate = GetPaintWindow(a);
847 sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager();
849 if(pOverlayManager)
851 mpCurrentSdrDragMethod->CreateOverlayGeometry(*pOverlayManager);
853 // #i101679# Force changed overlay to be shown
854 pOverlayManager->flush();
858 aDragStat.SetShown(TRUE);
862 void SdrDragView::HideDragObj()
864 if(mpCurrentSdrDragMethod && aDragStat.IsShown())
866 mpCurrentSdrDragMethod->destroyOverlayGeometry();
867 aDragStat.SetShown(FALSE);
871 ////////////////////////////////////////////////////////////////////////////////////////////////////
873 void SdrDragView::SetNoDragXorPolys(BOOL bOn)
875 if (IsNoDragXorPolys()!=bOn)
877 const bool bDragging(mpCurrentSdrDragMethod);
878 const bool bShown(bDragging && aDragStat.IsShown());
880 if(bShown)
882 HideDragObj();
885 bNoDragXorPolys = bOn;
887 if(bDragging)
889 // force recreation of drag content
890 mpCurrentSdrDragMethod->resetSdrDragEntries();
893 if(bShown)
895 ShowDragObj();
900 void SdrDragView::SetDragStripes(BOOL bOn)
902 if (mpCurrentSdrDragMethod && aDragStat.IsShown())
904 HideDragObj();
905 bDragStripes=bOn;
906 ShowDragObj();
908 else
910 bDragStripes=bOn;
914 BOOL SdrDragView::IsOrthoDesired() const
916 if(mpCurrentSdrDragMethod && (IS_TYPE(SdrDragObjOwn, mpCurrentSdrDragMethod) || IS_TYPE(SdrDragResize, mpCurrentSdrDragMethod)))
918 return bOrthoDesiredOnMarked;
921 return FALSE;
924 ////////////////////////////////////////////////////////////////////////////////////////////////////
926 void SdrDragView::SetRubberEdgeDragging(BOOL bOn)
928 if (bOn!=IsRubberEdgeDragging())
930 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
931 BOOL bShowHide=nAnz!=0 && IsDragObj() &&
932 (nRubberEdgeDraggingLimit>=nAnz);
933 if (bShowHide)
934 HideDragObj();
935 bRubberEdgeDragging=bOn;
936 if (bShowHide)
937 ShowDragObj();
941 void SdrDragView::SetRubberEdgeDraggingLimit(USHORT nEdgeObjAnz)
943 if (nEdgeObjAnz!=nRubberEdgeDraggingLimit)
945 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
946 BOOL bShowHide=IsRubberEdgeDragging() && nAnz!=0 && IsDragObj() &&
947 (nEdgeObjAnz>=nAnz)!=(nRubberEdgeDraggingLimit>=nAnz);
948 if (bShowHide)
949 HideDragObj();
950 nRubberEdgeDraggingLimit=nEdgeObjAnz;
951 if (bShowHide)
952 ShowDragObj();
956 void SdrDragView::SetDetailedEdgeDragging(BOOL bOn)
958 if (bOn!=IsDetailedEdgeDragging())
960 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
961 BOOL bShowHide=nAnz!=0 && IsDragObj() &&
962 (nDetailedEdgeDraggingLimit>=nAnz);
963 if (bShowHide)
964 HideDragObj();
965 bDetailedEdgeDragging=bOn;
966 if (bShowHide)
967 ShowDragObj();
971 void SdrDragView::SetDetailedEdgeDraggingLimit(USHORT nEdgeObjAnz)
973 if (nEdgeObjAnz!=nDetailedEdgeDraggingLimit)
975 ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
976 BOOL bShowHide=IsDetailedEdgeDragging() && nAnz!=0 && IsDragObj() &&
977 (nEdgeObjAnz>=nAnz)!=(nDetailedEdgeDraggingLimit>=nAnz);
978 if (bShowHide)
979 HideDragObj();
980 nDetailedEdgeDraggingLimit=nEdgeObjAnz;
981 if (bShowHide)
982 ShowDragObj();
986 void SdrDragView::SetMarkHandles()
988 if( pDragHdl )
989 pDragHdl = 0;
991 SdrExchangeView::SetMarkHandles();
994 void SdrDragView::SetSolidDragging(bool bOn)
996 if((bool)mbSolidDragging != bOn)
998 mbSolidDragging = bOn;
1002 bool SdrDragView::IsSolidDragging() const
1004 // allow each user to disable by having a local setting, but using AND for
1005 // checking allowance
1006 return mbSolidDragging && getOptionsDrawinglayer().IsSolidDragCreate();
1009 // eof