Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / svdraw / svddrgv.cxx
blob8b9567c20be0beddc6910871d76497572884d43d
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 <osl/diagnose.h>
22 #include <tools/debug.hxx>
23 #include <svx/svddrgv.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/svdundo.hxx>
26 #include <svx/svdocapt.hxx>
27 #include <svx/svdpagv.hxx>
28 #include <svx/svdopath.hxx>
29 #include <svx/svdoedge.hxx>
30 #include <svx/strings.hrc>
31 #include <svx/dialmgr.hxx>
32 #include "svddrgm1.hxx"
33 #include <svx/obj3d.hxx>
34 #include <svx/svdoashp.hxx>
35 #include <svx/sdrpaintwindow.hxx>
36 #include <basegfx/matrix/b2dhommatrix.hxx>
37 #include <svtools/optionsdrawinglayer.hxx>
38 #include <svx/sdr/overlay/overlaymanager.hxx>
39 #include <svx/sdrpagewindow.hxx>
40 #include <unotools/configmgr.hxx>
41 #include <comphelper/lok.hxx>
43 using namespace sdr;
45 SdrDragView::SdrDragView(SdrModel& rSdrModel, OutputDevice* pOut)
46 : SdrExchangeView(rSdrModel, pOut)
47 , mpDragHdl(nullptr)
48 , mpInsPointUndo(nullptr)
49 , meDragHdl(SdrHdlKind::Move)
50 , mnDragThresholdPixels(6)
51 , mbFramDrag(false)
52 , mbMarkedHitMovesAlways(false)
53 , mbDragLimit(false)
54 , mbDragHdl(false)
55 , mbDragStripes(false)
56 , mbSolidDragging(utl::ConfigManager::IsFuzzing() || SvtOptionsDrawinglayer::IsSolidDragCreate())
57 , mbResizeAtCenter(false)
58 , mbCrookAtCenter(false)
59 , mbDragWithCopy(false)
60 , mbInsGluePoint(false)
61 , mbInsObjPointMode(false)
62 , mbInsGluePointMode(false)
63 , mbNoDragXorPolys(false)
65 meDragMode = SdrDragMode::Move;
68 SdrDragView::~SdrDragView()
72 bool SdrDragView::IsAction() const
74 return (mpCurrentSdrDragMethod || SdrExchangeView::IsAction());
77 void SdrDragView::MovAction(const Point& rPnt)
79 SdrExchangeView::MovAction(rPnt);
80 if (mpCurrentSdrDragMethod)
82 MovDragObj(rPnt);
86 void SdrDragView::EndAction()
88 if (mpCurrentSdrDragMethod)
90 EndDragObj();
92 SdrExchangeView::EndAction();
95 void SdrDragView::BckAction()
97 SdrExchangeView::BckAction();
98 BrkDragObj();
101 void SdrDragView::BrkAction()
103 SdrExchangeView::BrkAction();
104 BrkDragObj();
107 void SdrDragView::TakeActionRect(tools::Rectangle& rRect) const
109 if (mpCurrentSdrDragMethod)
111 rRect=maDragStat.GetActionRect();
112 if (rRect.IsEmpty())
114 SdrPageView* pPV = GetSdrPageView();
116 if(pPV&& pPV->HasMarkedObjPageView())
118 // #i95646# is this used..?
119 const basegfx::B2DRange aBoundRange(mpCurrentSdrDragMethod->getCurrentRange());
120 if (aBoundRange.isEmpty())
122 rRect.SetEmpty();
124 else
126 rRect = tools::Rectangle(
127 basegfx::fround(aBoundRange.getMinX()), basegfx::fround(aBoundRange.getMinY()),
128 basegfx::fround(aBoundRange.getMaxX()), basegfx::fround(aBoundRange.getMaxY()));
132 if (rRect.IsEmpty())
134 rRect=tools::Rectangle(maDragStat.GetNow(),maDragStat.GetNow());
137 else
139 SdrExchangeView::TakeActionRect(rRect);
143 bool SdrDragView::TakeDragObjAnchorPos(Point& rPos, bool bTR ) const
145 tools::Rectangle aR;
146 TakeActionRect(aR);
147 rPos = bTR ? aR.TopRight() : aR.TopLeft();
148 if (GetMarkedObjectCount()==1 && IsDragObj() && // only on single selection
149 !IsDraggingPoints() && !IsDraggingGluePoints() && // not when moving points
150 dynamic_cast<const SdrDragMovHdl*>( mpCurrentSdrDragMethod.get() ) == nullptr) // not when moving handles
152 SdrObject* pObj=GetMarkedObjectByIndex(0);
153 if (auto pCaptionObj = dynamic_cast<SdrCaptionObj*>(pObj))
155 Point aPt(pCaptionObj->GetTailPos());
156 bool bTail=meDragHdl==SdrHdlKind::Poly; // drag tail
157 bool bOwn=dynamic_cast<const SdrDragObjOwn*>( mpCurrentSdrDragMethod.get() ) != nullptr; // specific to object
158 if (!bTail)
159 { // for bTail, TakeActionRect already does the right thing
160 if (bOwn)
161 { // bOwn may be MoveTextFrame, ResizeTextFrame, but may not (any more) be DragTail
162 rPos=aPt;
164 else
166 // drag the whole Object (Move, Resize, ...)
167 const basegfx::B2DPoint aTransformed(mpCurrentSdrDragMethod->getCurrentTransformation() * basegfx::B2DPoint(aPt.X(), aPt.Y()));
168 rPos.setX( basegfx::fround(aTransformed.getX()) );
169 rPos.setY( basegfx::fround(aTransformed.getY()) );
173 return true;
175 return false;
179 bool SdrDragView::TakeDragLimit(SdrDragMode /*eMode*/, tools::Rectangle& /*rRect*/) const
181 return false;
184 bool SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl, short nMinMov, SdrDragMethod* _pForcedMeth)
186 BrkAction();
188 // so we don't leak the object on early return
189 std::unique_ptr<SdrDragMethod> pForcedMeth(_pForcedMeth);
191 bool bRet=false;
193 SetDragWithCopy(false);
194 //TODO: aAni.Reset();
195 mpCurrentSdrDragMethod=nullptr;
196 SdrDragMode eTmpMode=meDragMode;
197 if (eTmpMode==SdrDragMode::Move && pHdl!=nullptr && pHdl->GetKind()!=SdrHdlKind::Move) {
198 eTmpMode=SdrDragMode::Resize;
200 mbDragLimit=TakeDragLimit(eTmpMode,maDragLimit);
201 mbFramDrag=ImpIsFrameHandles();
202 if (!mbFramDrag &&
203 (mpMarkedObj==nullptr || !mpMarkedObj->hasSpecialDrag()) &&
204 (pHdl==nullptr || pHdl->GetObj()==nullptr)) {
205 mbFramDrag=true;
208 Point aPnt(rPnt);
209 basegfx::B2DVector aGridOffset(0.0, 0.0);
211 // Coordinate maybe affected by GridOffset, so we may need to
212 // adapt to Model-coordinates here
213 if((comphelper::LibreOfficeKit::isActive() && mpMarkedObj
214 && getPossibleGridOffsetForSdrObject(aGridOffset, GetMarkedObjectByIndex(0), GetSdrPageView()))
215 || (getPossibleGridOffsetForPosition(
216 aGridOffset,
217 basegfx::B2DPoint(aPnt.X(), aPnt.Y()),
218 GetSdrPageView())))
220 aPnt.AdjustX(basegfx::fround(-aGridOffset.getX()));
221 aPnt.AdjustY(basegfx::fround(-aGridOffset.getY()));
224 if(pHdl == nullptr
225 || pHdl->GetKind() == SdrHdlKind::Move
226 || pHdl->GetKind() == SdrHdlKind::MirrorAxis
227 || pHdl->GetKind() == SdrHdlKind::Transparence
228 || pHdl->GetKind() == SdrHdlKind::Gradient)
230 maDragStat.Reset(aPnt);
232 else
234 maDragStat.Reset(pHdl->GetPos());
237 maDragStat.SetView(static_cast<SdrView*>(this));
238 maDragStat.SetPageView(mpMarkedPV); // <<-- DragPV has to go here!!!
239 maDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
240 maDragStat.SetHdl(pHdl);
241 maDragStat.NextPoint();
242 mpDragWin=pOut;
243 mpDragHdl=pHdl;
244 meDragHdl= pHdl==nullptr ? SdrHdlKind::Move : pHdl->GetKind();
245 mbDragHdl=meDragHdl==SdrHdlKind::Ref1 || meDragHdl==SdrHdlKind::Ref2 || meDragHdl==SdrHdlKind::MirrorAxis;
247 // Expand test for SdrHdlKind::Anchor_TR
248 bool bNotDraggable = (SdrHdlKind::Anchor == meDragHdl || SdrHdlKind::Anchor_TR == meDragHdl);
250 if(pHdl && (pHdl->GetKind() == SdrHdlKind::SmartTag) && pForcedMeth )
252 // just use the forced method for smart tags
254 else if(mbDragHdl)
256 mpCurrentSdrDragMethod.reset(new SdrDragMovHdl(*this));
258 else if(!bNotDraggable)
260 switch (meDragMode)
262 case SdrDragMode::Rotate: case SdrDragMode::Shear:
264 switch (meDragHdl)
266 case SdrHdlKind::Left: case SdrHdlKind::Right:
267 case SdrHdlKind::Upper: case SdrHdlKind::Lower:
269 // are 3D objects selected?
270 bool b3DObjSelected = false;
271 for(size_t a=0; !b3DObjSelected && a<GetMarkedObjectCount(); ++a)
273 SdrObject* pObj = GetMarkedObjectByIndex(a);
274 if(DynCastE3dObject(pObj))
275 b3DObjSelected = true;
277 // If yes, allow shear even when !IsShearAllowed,
278 // because 3D objects are limited rotations
279 if (!b3DObjSelected && !IsShearAllowed())
280 return false;
281 mpCurrentSdrDragMethod.reset(new SdrDragShear(*this,meDragMode==SdrDragMode::Rotate));
282 } break;
283 case SdrHdlKind::UpperLeft: case SdrHdlKind::UpperRight:
284 case SdrHdlKind::LowerLeft: case SdrHdlKind::LowerRight:
286 if (meDragMode==SdrDragMode::Shear)
288 if (!IsDistortAllowed(true) && !IsDistortAllowed()) return false;
289 mpCurrentSdrDragMethod.reset(new SdrDragDistort(*this));
291 else
293 if (!IsRotateAllowed(true)) return false;
294 mpCurrentSdrDragMethod.reset(new SdrDragRotate(*this));
296 } break;
297 default:
299 if (IsMarkedHitMovesAlways() && meDragHdl==SdrHdlKind::Move)
300 { // SdrHdlKind::Move is true, even if Obj is hit directly
301 if (!IsMoveAllowed()) return false;
302 mpCurrentSdrDragMethod.reset(new SdrDragMove(*this));
304 else
306 if (!IsRotateAllowed(true)) return false;
307 mpCurrentSdrDragMethod.reset(new SdrDragRotate(*this));
311 } break;
312 case SdrDragMode::Mirror:
314 if (meDragHdl==SdrHdlKind::Move && IsMarkedHitMovesAlways())
316 if (!IsMoveAllowed()) return false;
317 mpCurrentSdrDragMethod.reset(new SdrDragMove(*this));
319 else
321 if (!IsMirrorAllowed(true,true)) return false;
322 mpCurrentSdrDragMethod.reset(new SdrDragMirror(*this));
324 } break;
326 case SdrDragMode::Crop:
328 if (meDragHdl==SdrHdlKind::Move && IsMarkedHitMovesAlways())
330 if (!IsMoveAllowed())
331 return false;
332 mpCurrentSdrDragMethod.reset(new SdrDragMove(*this));
334 else
336 if (!IsCropAllowed())
337 return false;
338 mpCurrentSdrDragMethod.reset(new SdrDragCrop(*this));
341 break;
343 case SdrDragMode::Transparence:
345 if(meDragHdl == SdrHdlKind::Move && IsMarkedHitMovesAlways())
347 if(!IsMoveAllowed())
348 return false;
349 mpCurrentSdrDragMethod.reset(new SdrDragMove(*this));
351 else
353 if(!IsTransparenceAllowed())
354 return false;
356 mpCurrentSdrDragMethod.reset(new SdrDragGradient(*this, false));
358 break;
360 case SdrDragMode::Gradient:
362 if(meDragHdl == SdrHdlKind::Move && IsMarkedHitMovesAlways())
364 if(!IsMoveAllowed())
365 return false;
366 mpCurrentSdrDragMethod.reset(new SdrDragMove(*this));
368 else
370 if(!IsGradientAllowed())
371 return false;
373 mpCurrentSdrDragMethod.reset(new SdrDragGradient(*this));
375 break;
378 case SdrDragMode::Crook :
380 if (meDragHdl==SdrHdlKind::Move && IsMarkedHitMovesAlways())
382 if (!IsMoveAllowed()) return false;
383 mpCurrentSdrDragMethod.reset( new SdrDragMove(*this) );
385 else
387 if (!IsCrookAllowed(true) && !IsCrookAllowed()) return false;
388 mpCurrentSdrDragMethod.reset( new SdrDragCrook(*this) );
390 } break;
392 default:
394 // SdrDragMode::Move
395 if((meDragHdl == SdrHdlKind::Move) && !IsMoveAllowed())
397 return false;
399 else if(meDragHdl == SdrHdlKind::Glue)
401 mpCurrentSdrDragMethod.reset( new SdrDragMove(*this) );
403 else
405 if(mbFramDrag)
407 if(meDragHdl == SdrHdlKind::Move)
409 mpCurrentSdrDragMethod.reset( new SdrDragMove(*this) );
411 else
413 if(!IsResizeAllowed(true))
415 return false;
418 bool bSingleTextObjMark = false; // SJ: #i100490#
419 if ( GetMarkedObjectCount() == 1 )
421 mpMarkedObj=GetMarkedObjectByIndex(0);
422 if ( mpMarkedObj &&
423 DynCastSdrTextObj( mpMarkedObj) != nullptr &&
424 static_cast<SdrTextObj*>(mpMarkedObj)->IsTextFrame() )
425 bSingleTextObjMark = true;
427 if ( bSingleTextObjMark )
428 mpCurrentSdrDragMethod.reset( new SdrDragObjOwn(*this) );
429 else
430 mpCurrentSdrDragMethod.reset( new SdrDragResize(*this) );
433 else
435 if(SdrHdlKind::Move == meDragHdl)
437 const bool bCustomShapeSelected(1 == GetMarkedObjectCount() && dynamic_cast<const SdrObjCustomShape*>(GetMarkedObjectByIndex(0)) != nullptr);
439 if(bCustomShapeSelected)
441 mpCurrentSdrDragMethod.reset( new SdrDragMove( *this ) );
444 else if(SdrHdlKind::Poly == meDragHdl)
446 const bool bConnectorSelected(1 == GetMarkedObjectCount() && dynamic_cast<const SdrEdgeObj*>(GetMarkedObjectByIndex(0)) != nullptr);
448 if(bConnectorSelected)
450 // #i97784#
451 // fallback to old behaviour for connectors (see
452 // text in task description for more details)
454 else if(!IsMoveAllowed() || !IsResizeAllowed())
456 // #i77187#
457 // do not allow move of polygon points if object is move or size protected
458 return false;
462 if(!mpCurrentSdrDragMethod)
464 // fallback to DragSpecial if no interaction defined
465 mpCurrentSdrDragMethod.reset( new SdrDragObjOwn(*this) );
472 if (pForcedMeth)
474 mpCurrentSdrDragMethod = std::move(pForcedMeth);
476 maDragStat.SetDragMethod(mpCurrentSdrDragMethod.get());
477 if (mpCurrentSdrDragMethod)
479 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
480 if (!bRet)
482 if (pHdl==nullptr && dynamic_cast< const SdrDragObjOwn* >(mpCurrentSdrDragMethod.get()) != nullptr)
484 // Obj may not Move SpecialDrag, so try with MoveFrameDrag
485 mpCurrentSdrDragMethod.reset();
487 if (!IsMoveAllowed())
488 return false;
490 mbFramDrag=true;
491 mpCurrentSdrDragMethod.reset( new SdrDragMove(*this) );
492 maDragStat.SetDragMethod(mpCurrentSdrDragMethod.get());
493 bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
496 if (!bRet)
498 mpCurrentSdrDragMethod.reset();
499 maDragStat.SetDragMethod(mpCurrentSdrDragMethod.get());
504 return bRet;
507 void SdrDragView::MovDragObj(const Point& rPnt)
509 if (!mpCurrentSdrDragMethod)
510 return;
512 Point aPnt(rPnt);
513 basegfx::B2DVector aGridOffset(0.0, 0.0);
515 // Coordinate maybe affected by GridOffset, so we may need to
516 // adapt to Model-coordinates here
517 if((comphelper::LibreOfficeKit::isActive() && mpMarkedObj
518 && getPossibleGridOffsetForSdrObject(aGridOffset, GetMarkedObjectByIndex(0), GetSdrPageView()))
519 || (getPossibleGridOffsetForPosition(
520 aGridOffset,
521 basegfx::B2DPoint(aPnt.X(), aPnt.Y()),
522 GetSdrPageView())))
524 aPnt.AdjustX(basegfx::fround(-aGridOffset.getX()));
525 aPnt.AdjustY(basegfx::fround(-aGridOffset.getY()));
528 ImpLimitToWorkArea(aPnt);
529 mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination
532 bool SdrDragView::EndDragObj(bool bCopy)
534 bool bRet(false);
536 // #i73341# If inserting GluePoint, do not insist on last points being different
537 if(mpCurrentSdrDragMethod && maDragStat.IsMinMoved() && (IsInsertGluePoint() || maDragStat.GetNow() != maDragStat.GetPrev()))
539 sal_Int32 nSavedHdlCount=0;
541 if (bEliminatePolyPoints)
543 nSavedHdlCount=GetMarkablePointCount();
546 const bool bUndo = IsUndoEnabled();
547 if (IsInsertGluePoint() && bUndo)
549 BegUndo(maInsPointUndoStr);
550 AddUndo(std::unique_ptr<SdrUndoAction>(mpInsPointUndo));
553 bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy);
555 if( IsInsertGluePoint() && bUndo)
556 EndUndo();
558 mpCurrentSdrDragMethod.reset();
560 if (bEliminatePolyPoints)
562 if (nSavedHdlCount!=GetMarkablePointCount())
564 UnmarkAllPoints();
568 if (mbInsPolyPoint)
570 SetMarkHandles(nullptr);
571 mbInsPolyPoint=false;
572 if( bUndo )
574 BegUndo(maInsPointUndoStr);
575 AddUndo(std::unique_ptr<SdrUndoAction>(mpInsPointUndo));
576 EndUndo();
580 meDragHdl=SdrHdlKind::Move;
581 mpDragHdl=nullptr;
583 if (!mbSomeObjChgdFlag)
585 // Obj did not broadcast (e. g. Writer FlyFrames)
586 if(!mbDragHdl)
588 AdjustMarkHdl();
592 else
594 BrkDragObj();
597 mbInsPolyPoint=false;
598 SetInsertGluePoint(false);
600 return bRet;
603 void SdrDragView::BrkDragObj()
605 if (!mpCurrentSdrDragMethod)
606 return;
608 mpCurrentSdrDragMethod->CancelSdrDrag();
610 mpCurrentSdrDragMethod.reset();
612 if (mbInsPolyPoint)
614 mpInsPointUndo->Undo(); // delete inserted point again
615 delete mpInsPointUndo;
616 mpInsPointUndo=nullptr;
617 SetMarkHandles(nullptr);
618 mbInsPolyPoint=false;
621 if (IsInsertGluePoint())
623 mpInsPointUndo->Undo(); // delete inserted gluepoint again
624 delete mpInsPointUndo;
625 mpInsPointUndo=nullptr;
626 SetInsertGluePoint(false);
629 meDragHdl=SdrHdlKind::Move;
630 mpDragHdl=nullptr;
633 bool SdrDragView::IsInsObjPointPossible() const
635 return mpMarkedObj!=nullptr && mpMarkedObj->IsPolyObj();
638 bool SdrDragView::ImpBegInsObjPoint(bool bIdxZwang, const Point& rPnt, bool bNewObj, OutputDevice* pOut)
640 bool bRet(false);
642 if(auto pMarkedPath = dynamic_cast<SdrPathObj*>( mpMarkedObj))
644 BrkAction();
645 mpInsPointUndo = dynamic_cast<SdrUndoGeoObj*>(GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*mpMarkedObj).release());
646 DBG_ASSERT( mpInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
648 OUString aStr(SvxResId(STR_DragInsertPoint));
650 maInsPointUndoStr = aStr.replaceFirst("%1", mpMarkedObj->TakeObjNameSingul() );
652 Point aPt(rPnt);
654 if(bNewObj)
655 aPt = GetSnapPos(aPt,mpMarkedPV);
657 bool bClosed0 = pMarkedPath->IsClosedObj();
659 const sal_uInt32 nInsPointNum { bIdxZwang
660 ? pMarkedPath->NbcInsPoint(aPt, bNewObj)
661 : pMarkedPath->NbcInsPointOld(aPt, bNewObj)
664 if(bClosed0 != pMarkedPath->IsClosedObj())
666 // Obj was closed implicitly
667 // object changed
668 pMarkedPath->SetChanged();
669 pMarkedPath->BroadcastObjectChange();
672 if (nInsPointNum != SAL_MAX_UINT32)
674 mbInsPolyPoint = true;
675 UnmarkAllPoints();
676 AdjustMarkHdl();
678 bRet = BegDragObj(rPnt, pOut, maHdlList.GetHdl(nInsPointNum), 0);
680 if (bRet)
682 maDragStat.SetMinMoved();
683 MovDragObj(rPnt);
686 else
688 delete mpInsPointUndo;
689 mpInsPointUndo = nullptr;
693 return bRet;
696 bool SdrDragView::EndInsObjPoint(SdrCreateCmd eCmd)
698 if(IsInsObjPoint())
700 Point aPnt(maDragStat.GetNow());
701 bool bOk=EndDragObj();
702 if (bOk && eCmd!=SdrCreateCmd::ForceEnd)
704 // Ret=True means: Action is over.
705 bOk = ! ImpBegInsObjPoint(true, aPnt, eCmd == SdrCreateCmd::NextObject, mpDragWin);
708 return bOk;
709 } else return false;
712 bool SdrDragView::IsInsGluePointPossible() const
714 bool bRet=false;
715 if (IsInsGluePointMode() && AreObjectsMarked())
717 if (GetMarkedObjectCount()==1)
719 // return sal_False, if only 1 object which is a connector.
720 const SdrObject* pObj=GetMarkedObjectByIndex(0);
721 if (dynamic_cast<const SdrEdgeObj *>(pObj) == nullptr)
723 bRet=true;
726 else
728 bRet=true;
731 return bRet;
734 bool SdrDragView::BegInsGluePoint(const Point& rPnt)
736 bool bRet=false;
737 SdrObject* pObj;
738 SdrPageView* pPV;
739 if (PickMarkedObj(rPnt,pObj,pPV,SdrSearchOptions::PASS2BOUND))
741 BrkAction();
742 UnmarkAllGluePoints();
743 mpInsPointUndo = dynamic_cast<SdrUndoGeoObj*>(GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pObj).release());
744 DBG_ASSERT( mpInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
745 OUString aStr(SvxResId(STR_DragInsertGluePoint));
747 maInsPointUndoStr = aStr.replaceFirst("%1", pObj->TakeObjNameSingul() );
749 SdrGluePointList* pGPL=pObj->ForceGluePointList();
750 if (pGPL!=nullptr)
752 sal_uInt16 nGlueIdx=pGPL->Insert(SdrGluePoint());
753 SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
754 sal_uInt16 nGlueId=rGP.GetId();
755 rGP.SetAbsolutePos(rPnt,*pObj);
757 SdrHdl* pHdl=nullptr;
758 if (MarkGluePoint(pObj,nGlueId,false))
760 pHdl=GetGluePointHdl(pObj,nGlueId);
762 if (pHdl!=nullptr && pHdl->GetKind()==SdrHdlKind::Glue && pHdl->GetObj()==pObj && pHdl->GetObjHdlNum()==nGlueId)
764 SetInsertGluePoint(true);
765 bRet=BegDragObj(rPnt,nullptr,pHdl,0);
766 if (bRet)
768 maDragStat.SetMinMoved();
769 MovDragObj(rPnt);
771 else
773 SetInsertGluePoint(false);
774 delete mpInsPointUndo;
775 mpInsPointUndo=nullptr;
778 else
780 OSL_FAIL("BegInsGluePoint(): GluePoint handle not found.");
783 else
785 // no gluepoints possible for this object (e. g. Edge)
786 SetInsertGluePoint(false);
787 delete mpInsPointUndo;
788 mpInsPointUndo=nullptr;
792 return bRet;
795 void SdrDragView::ShowDragObj()
797 if(!mpCurrentSdrDragMethod || maDragStat.IsShown())
798 return;
800 // Changed for the GridOffset stuff: No longer iterate over
801 // SdrPaintWindow(s), but now over SdrPageWindow(s), so doing the
802 // same as the SdrHdl visualizations (see ::CreateB2dIAObject) do.
803 // This is needed to get access to an ObjectContact which is needed
804 // to evtl. process that GridOffset in CreateOverlayGeometry
805 SdrPageView* pPageView(GetSdrPageView());
807 if(nullptr != pPageView)
809 for(sal_uInt32 a(0); a < pPageView->PageWindowCount(); a++)
811 const SdrPageWindow& rPageWindow(*pPageView->GetPageWindow(a));
812 const SdrPaintWindow& rPaintWindow(rPageWindow.GetPaintWindow());
814 if(rPaintWindow.OutputToWindow())
816 const rtl::Reference<sdr::overlay::OverlayManager>& xOverlayManager(
817 rPaintWindow.GetOverlayManager());
819 if(xOverlayManager.is())
821 mpCurrentSdrDragMethod->CreateOverlayGeometry(
822 *xOverlayManager,
823 rPageWindow.GetObjectContact());
825 // #i101679# Force changed overlay to be shown
826 xOverlayManager->flush();
832 maDragStat.SetShown(true);
835 void SdrDragView::HideDragObj()
837 if(mpCurrentSdrDragMethod && maDragStat.IsShown())
839 mpCurrentSdrDragMethod->destroyOverlayGeometry();
840 maDragStat.SetShown(false);
845 void SdrDragView::SetNoDragXorPolys(bool bOn)
847 if (IsNoDragXorPolys()==bOn)
848 return;
850 const bool bDragging(mpCurrentSdrDragMethod);
851 const bool bShown(bDragging && maDragStat.IsShown());
853 if(bShown)
855 HideDragObj();
858 mbNoDragXorPolys = bOn;
860 if(bDragging)
862 // force recreation of drag content
863 mpCurrentSdrDragMethod->resetSdrDragEntries();
866 if(bShown)
868 ShowDragObj();
872 void SdrDragView::SetDragStripes(bool bOn)
874 if (mpCurrentSdrDragMethod && maDragStat.IsShown())
876 HideDragObj();
877 mbDragStripes=bOn;
878 ShowDragObj();
880 else
882 mbDragStripes=bOn;
886 bool SdrDragView::IsOrthoDesired() const
888 if( dynamic_cast< const SdrDragObjOwn* >( mpCurrentSdrDragMethod.get() )
889 || dynamic_cast< const SdrDragResize* >(mpCurrentSdrDragMethod.get() ))
891 return m_bOrthoDesiredOnMarked;
894 return false;
897 void SdrDragView::SetMarkHandles(SfxViewShell* pOtherShell)
899 if( mpDragHdl )
900 mpDragHdl = nullptr;
902 SdrExchangeView::SetMarkHandles(pOtherShell);
905 void SdrDragView::SetSolidDragging(bool bOn)
907 if(mbSolidDragging != bOn)
909 mbSolidDragging = bOn;
913 bool SdrDragView::IsSolidDragging() const
915 // allow each user to disable by having a local setting, but using AND for
916 // checking allowance
917 return mbSolidDragging && SvtOptionsDrawinglayer::IsSolidDragCreate();
920 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */