LibreOffice Module svx (master)  1
svdcrtv.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
21 #include <svx/svdcrtv.hxx>
22 #include <svx/xlnclit.hxx>
23 #include <svx/svdocapt.hxx>
24 #include <svx/svdoedge.hxx>
25 #include <svx/svdpagv.hxx>
26 #include <svx/svdpage.hxx>
27 #include <svx/scene3d.hxx>
28 #include <svx/view3d.hxx>
29 #include <svx/xfillit0.hxx>
30 #include <svx/xflclit.hxx>
31 #include <svx/xlineit0.hxx>
32 #include <svx/svdouno.hxx>
33 #include <svx/svdopath.hxx>
36 #include <svx/sdrpaintwindow.hxx>
37 #include <fmobj.hxx>
38 #include <svx/svdocirc.hxx>
41 #include <vcl/ptrstyle.hxx>
42 
43 using namespace com::sun::star;
44 
46 {
47  // The OverlayObjects
49 
50  // The remembered target object
52 
53 public:
54  ImplConnectMarkerOverlay(const SdrCreateView& rView, SdrObject const & rObject);
55 
56  // The OverlayObjects are cleared using the destructor of OverlayObjectList.
57  // That destructor calls clear() at the list which removes all objects from the
58  // OverlayManager and deletes them.
59 
60  const SdrObject& GetTargetObject() const { return mrObject; }
61 };
62 
64 : mrObject(rObject)
65 {
66  basegfx::B2DPolyPolygon aB2DPolyPolygon(rObject.TakeXorPoly());
67 
68  for(sal_uInt32 a(0); a < rView.PaintWindowCount(); a++)
69  {
70  SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
71  const rtl::Reference< sdr::overlay::OverlayManager >& xTargetOverlay = pCandidate->GetOverlayManager();
72 
73  if(xTargetOverlay.is())
74  {
75  float fScalingFactor = xTargetOverlay->getOutputDevice().GetDPIScaleFactor();
76  Size aHalfLogicSize(xTargetOverlay->getOutputDevice().PixelToLogic(Size(4 * fScalingFactor, 4 * fScalingFactor)));
77 
78  // object
79  std::unique_ptr<sdr::overlay::OverlayPolyPolygonStripedAndFilled> pNew(new sdr::overlay::OverlayPolyPolygonStripedAndFilled(
80  aB2DPolyPolygon));
81  xTargetOverlay->add(*pNew);
82  maObjects.append(std::move(pNew));
83 
84  // gluepoints
85  for(sal_uInt16 i(0); i < 4; i++)
86  {
87  SdrGluePoint aGluePoint(rObject.GetVertexGluePoint(i));
88  const Point& rPosition = aGluePoint.GetAbsolutePos(rObject);
89 
90  basegfx::B2DPoint aTopLeft(rPosition.X() - aHalfLogicSize.Width(), rPosition.Y() - aHalfLogicSize.Height());
91  basegfx::B2DPoint aBottomRight(rPosition.X() + aHalfLogicSize.Width(), rPosition.Y() + aHalfLogicSize.Height());
92 
93  basegfx::B2DPolygon aTempPoly;
94  aTempPoly.append(aTopLeft);
95  aTempPoly.append(basegfx::B2DPoint(aBottomRight.getX(), aTopLeft.getY()));
96  aTempPoly.append(aBottomRight);
97  aTempPoly.append(basegfx::B2DPoint(aTopLeft.getX(), aBottomRight.getY()));
98  aTempPoly.setClosed(true);
99 
100  basegfx::B2DPolyPolygon aTempPolyPoly;
101  aTempPolyPoly.append(aTempPoly);
102 
103  std::unique_ptr<sdr::overlay::OverlayPolyPolygonStripedAndFilled> pNew2(new sdr::overlay::OverlayPolyPolygonStripedAndFilled(
104  aTempPolyPoly));
105  xTargetOverlay->add(*pNew2);
106  maObjects.append(std::move(pNew2));
107  }
108  }
109  }
110 }
111 
113 {
114  // The OverlayObjects for XOR replacement
116 
117 public:
120 
121  void CreateAndShowOverlay(const SdrCreateView& rView, const SdrObject* pObject, const basegfx::B2DPolyPolygon& rPolyPoly);
122  void HideOverlay();
123 };
124 
126 {
127 }
128 
130 {
131  HideOverlay();
132 }
133 
135 {
136  for(sal_uInt32 a(0); a < rView.PaintWindowCount(); a++)
137  {
138  SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
139  const rtl::Reference<sdr::overlay::OverlayManager>& xOverlayManager = pCandidate->GetOverlayManager();
140 
141  if (xOverlayManager.is())
142  {
143  if(pObject)
144  {
145  const sdr::contact::ViewContact& rVC = pObject->GetViewContact();
148  std::unique_ptr<sdr::overlay::OverlayObject> pNew(new sdr::overlay::OverlayPrimitive2DSequenceObject(std::move(aSequence)));
149 
150  xOverlayManager->add(*pNew);
151  maObjects.append(std::move(pNew));
152  }
153 
154  if(rPolyPoly.count())
155  {
156  std::unique_ptr<sdr::overlay::OverlayPolyPolygonStripedAndFilled> pNew(new sdr::overlay::OverlayPolyPolygonStripedAndFilled(
157  rPolyPoly));
158  xOverlayManager->add(*pNew);
159  maObjects.append(std::move(pNew));
160  }
161  }
162  }
163 }
164 
166 {
167  // the clear() call of the list removes all objects from the
168  // OverlayManager and deletes them.
169  maObjects.clear();
170 }
171 
172 
173 // CreateView
174 
175 
177 {
178  mpCoMaOverlay.reset();
179 }
180 
182  : SdrDragView(rSdrModel, pOut)
183  , mpCurrentCreate(nullptr)
184  , mpCreatePV(nullptr)
185  , mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
186  , maCurrentCreatePointer(PointerStyle::Cross)
187  , mnAutoCloseDistPix(5)
188  , mnFreeHandMinDistPix(10)
189  , mnCurrentInvent(SdrInventor::Default)
190  , mnCurrentIdent(OBJ_NONE)
191  , mb1stPointAsCenter(false)
192  , mbUseIncompatiblePathCreateInterface(false)
193 {
194 }
195 
197 {
199  mpCreateViewExtraData.reset();
201 }
202 
204 {
205  return SdrDragView::IsAction() || mpCurrentCreate!=nullptr;
206 }
207 
208 void SdrCreateView::MovAction(const Point& rPnt)
209 {
211  if (mpCurrentCreate != nullptr) {
212  MovCreateObj(rPnt);
213  }
214 }
215 
217 {
220 }
221 
223 {
224  if (mpCurrentCreate != nullptr) BckCreateObj();
226 }
227 
229 {
231  BrkCreateObj();
232 }
233 
235 {
236  if (mpCurrentCreate != nullptr)
237  {
238  rRect=maDragStat.GetActionRect();
239  if (rRect.IsEmpty())
240  {
242  }
243  }
244  else
245  {
247  }
248 }
249 
251 {
252  if (mpCurrentCreate != nullptr)
253  {
254  // is managed by EdgeObj
256  }
257 
259  {
261  return false;
262  }
263  else
264  {
265  // sal_True, if MouseMove should check Connect
266  return !IsAction();
267  }
268 }
269 
271 {
272  SdrObject* pTargetObject = rCon.pObj;
273 
274  if(pTargetObject)
275  {
276  // if target object changes, throw away overlay object to make room for changes
277  if(mpCoMaOverlay && pTargetObject != &mpCoMaOverlay->GetTargetObject())
278  {
280  }
281 
282  if(!mpCoMaOverlay)
283  {
284  mpCoMaOverlay.reset(new ImplConnectMarkerOverlay(*this, *pTargetObject));
285  }
286  }
287  else
288  {
290  }
291 }
292 
294 {
296 }
297 
299 {
300  if(CheckEdgeMode() && pWin)
301  {
302  SdrPageView* pPV = GetSdrPageView();
303 
304  if(pPV)
305  {
306  // TODO: Change default hit tolerance at IsMarkedHit() some time!
307  Point aPos(pWin->PixelToLogic(rMEvt.GetPosPixel()));
308  bool bMarkHit=PickHandle(aPos)!=nullptr || IsMarkedObjHit(aPos);
309  SdrObjConnection aCon;
310  if (!bMarkHit) SdrEdgeObj::ImpFindConnector(aPos,*pPV,aCon,nullptr,pWin);
311  SetConnectMarker(aCon);
312  }
313  }
314  return SdrDragView::MouseMove(rMEvt,pWin);
315 }
316 
318 {
320 }
321 
323 {
325 }
326 
328 {
330 }
331 
333 {
334  if (mnCurrentInvent!=nInvent || mnCurrentIdent!=nIdent)
335  {
336  mnCurrentInvent=nInvent;
337  mnCurrentIdent=nIdent;
338  SdrObject * pObj = (nIdent == OBJ_NONE) ? nullptr :
340  *GetModel(),
341  nInvent,
342  nIdent);
343 
344  if(pObj)
345  {
346  // Using text tool, mouse cursor is usually I-Beam,
347  // crosshairs with tiny I-Beam appears only on MouseButtonDown.
348  if(IsTextTool())
349  {
350  // Here the correct pointer needs to be used
351  // if the default is set to vertical writing
352  maCurrentCreatePointer = PointerStyle::Text;
353  }
354  else
356 
357  SdrObject::Free( pObj );
358  }
359  else
360  {
361  maCurrentCreatePointer = PointerStyle::Cross;
362  }
363  }
364 
365  CheckEdgeMode();
367 }
368 
369 bool SdrCreateView::ImpBegCreateObj(SdrInventor nInvent, SdrObjKind nIdent, const Point& rPnt, OutputDevice* pOut,
370  sal_Int16 nMinMov, const tools::Rectangle& rLogRect, SdrObject* pPreparedFactoryObject)
371 {
372  bool bRet=false;
373  UnmarkAllObj();
374  BrkAction();
375 
377 
379 
380  if (mpCreatePV != nullptr)
381  { // otherwise no side registered!
382  OUString aLay(maActualLayer);
383 
384  if(nInvent == SdrInventor::Default && nIdent == OBJ_MEASURE && !maMeasureLayer.isEmpty())
385  {
386  aLay = maMeasureLayer;
387  }
388 
390  if (nLayer==SDRLAYER_NOTFOUND) nLayer = SdrLayerID(0);
391  if (!mpCreatePV->GetLockedLayers().IsSet(nLayer) && mpCreatePV->GetVisibleLayers().IsSet(nLayer))
392  {
393  if(pPreparedFactoryObject)
394  {
395  mpCurrentCreate = pPreparedFactoryObject;
396  }
397  else
398  {
400  *mpModel,
401  nInvent,
402  nIdent);
403  }
404 
405  Point aPnt(rPnt);
407  mnCurrentIdent!=sal_uInt16(OBJ_FREELINE) &&
408  mnCurrentIdent!=sal_uInt16(OBJ_FREEFILL) )) { // no snapping for Edge and Freehand
409  aPnt=GetSnapPos(aPnt, mpCreatePV);
410  }
411  if (mpCurrentCreate!=nullptr)
412  {
414 
415  // SW uses a naked SdrObject for frame construction. Normally, such an
416  // object should not be created. Since it is possible to use it as a helper
417  // object (e.g. in letting the user define an area with the interactive
418  // construction) at least no items should be set at that object.
419  if(nInvent != SdrInventor::Default || nIdent != OBJ_NONE)
420  {
422  }
423 
424  if (mpModel && dynamic_cast<const SdrCaptionObj *>(mpCurrentCreate) != nullptr)
425  {
426  SfxItemSet aSet(mpModel->GetItemPool());
427  aSet.Put(XFillColorItem(OUString(),COL_WHITE)); // in case someone turns on Solid
428  aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
429 
431  }
432  if (mpModel && nInvent==SdrInventor::Default && (nIdent==OBJ_TEXT ||
433  nIdent==OBJ_TITLETEXT || nIdent==OBJ_OUTLINETEXT))
434  {
435  // default for all text frames: no background, no border
436  SfxItemSet aSet(mpModel->GetItemPool());
437  aSet.Put(XFillColorItem(OUString(),COL_WHITE)); // in case someone turns on Solid
438  aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
439  aSet.Put(XLineColorItem(OUString(),COL_BLACK)); // in case someone turns on Solid
440  aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
441 
443  }
444  if (!rLogRect.IsEmpty()) mpCurrentCreate->NbcSetLogicRect(rLogRect);
445 
446  // make sure drag start point is inside WorkArea
447  const tools::Rectangle& rWorkArea = GetWorkArea();
448 
449  if(!rWorkArea.IsEmpty())
450  {
451  if(aPnt.X() < rWorkArea.Left())
452  {
453  aPnt.setX( rWorkArea.Left() );
454  }
455 
456  if(aPnt.X() > rWorkArea.Right())
457  {
458  aPnt.setX( rWorkArea.Right() );
459  }
460 
461  if(aPnt.Y() < rWorkArea.Top())
462  {
463  aPnt.setY( rWorkArea.Top() );
464  }
465 
466  if(aPnt.Y() > rWorkArea.Bottom())
467  {
468  aPnt.setY( rWorkArea.Bottom() );
469  }
470  }
471 
472  maDragStat.Reset(aPnt);
473  maDragStat.SetView(static_cast<SdrView*>(this));
475  maDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
476  mpDragWin=pOut;
478  {
479  ShowCreateObj(/*pOut,sal_True*/);
480  bRet=true;
481  }
482  else
483  {
485  mpCurrentCreate = nullptr;
486  mpCreatePV = nullptr;
487  }
488  }
489  }
490  }
491  return bRet;
492 }
493 
494 bool SdrCreateView::BegCreateObj(const Point& rPnt, OutputDevice* pOut, short nMinMov)
495 {
496  return ImpBegCreateObj(mnCurrentInvent,mnCurrentIdent,rPnt,pOut,nMinMov,tools::Rectangle(), nullptr);
497 }
498 
499 bool SdrCreateView::BegCreatePreparedObject(const Point& rPnt, sal_Int16 nMinMov, SdrObject* pPreparedFactoryObject)
500 {
501  SdrInventor nInvent(mnCurrentInvent);
502  SdrObjKind nIdent(mnCurrentIdent);
503 
504  if(pPreparedFactoryObject)
505  {
506  nInvent = pPreparedFactoryObject->GetObjInventor();
507  nIdent = pPreparedFactoryObject->GetObjIdentifier();
508  }
509 
510  return ImpBegCreateObj(nInvent, nIdent, rPnt, nullptr, nMinMov, tools::Rectangle(), pPreparedFactoryObject);
511 }
512 
513 bool SdrCreateView::BegCreateCaptionObj(const Point& rPnt, const Size& rObjSiz,
514  OutputDevice* pOut, short nMinMov)
515 {
516  return ImpBegCreateObj(SdrInventor::Default,OBJ_CAPTION,rPnt,pOut,nMinMov,
517  tools::Rectangle(rPnt,Size(rObjSiz.Width()+1,rObjSiz.Height()+1)), nullptr);
518 }
519 
520 void SdrCreateView::MovCreateObj(const Point& rPnt)
521 {
522  if (mpCurrentCreate==nullptr)
523  return;
524 
525  Point aPnt(rPnt);
526  if (!maDragStat.IsNoSnap())
527  {
528  aPnt=GetSnapPos(aPnt, mpCreatePV);
529  }
530  if (IsOrtho())
531  {
534  }
535 
536  // If the drag point was limited and Ortho is active, do
537  // the small ortho correction (reduction) -> last parameter to FALSE.
538  bool bDidLimit(ImpLimitToWorkArea(aPnt));
539  if(bDidLimit && IsOrtho())
540  {
542  OrthoDistance8(maDragStat.GetPrev(), aPnt, false);
543  else if(maDragStat.IsOrtho4Possible())
544  OrthoDistance4(maDragStat.GetPrev(), aPnt, false);
545  }
546 
547  if (aPnt==maDragStat.GetNow()) return;
548  bool bIsMinMoved(maDragStat.IsMinMoved());
549  if (!maDragStat.CheckMinMoved(aPnt))
550  return;
551 
552  if (!bIsMinMoved) maDragStat.NextPoint();
553  maDragStat.NextMove(aPnt);
555 
556  // MovCreate changes the object, so use ActionChanged() on it
558 
559  // replace for DrawCreateObjDiff
560  HideCreateObj();
561  ShowCreateObj();
562 }
563 
564 void SdrCreateView::SetupObjLayer(const SdrPageView* pPageView, const OUString& aActiveLayer, SdrObject* pObj)
565 {
566  const SdrLayerAdmin& rAd = pPageView->GetPage()->GetLayerAdmin();
567  SdrLayerID nLayer(0);
568 
569  // #i72535#
570  if(dynamic_cast<const FmFormObj*>( pObj) != nullptr)
571  {
572  // for FormControls, force to form layer
573  nLayer = rAd.GetLayerID(rAd.GetControlLayerName());
574  }
575  else
576  {
577  nLayer = rAd.GetLayerID(aActiveLayer);
578  }
579 
580  if(SDRLAYER_NOTFOUND == nLayer)
581  {
582  nLayer = SdrLayerID(0);
583  }
584 
585  pObj->SetLayer(nLayer);
586 }
587 
589 {
590  bool bRet=false;
591  SdrObject* pObjCreated=mpCurrentCreate;
592 
593  if (mpCurrentCreate!=nullptr)
594  {
595  sal_uInt32 nCount=maDragStat.GetPointCount();
596 
597  if (nCount<=1 && eCmd==SdrCreateCmd::ForceEnd)
598  {
599  BrkCreateObj(); // objects with only a single point don't exist (at least today)
600  return false; // sal_False = event not interpreted
601  }
602 
603  bool bPntsEq=nCount>1;
604  sal_uInt32 i=1;
605  Point aP0=maDragStat.GetPoint(0);
606  while (bPntsEq && i<nCount) { bPntsEq=aP0==maDragStat.GetPoint(i); i++; }
607 
609  {
610  HideCreateObj();
611 
612  if (!bPntsEq)
613  {
614  // otherwise Brk, because all points are equal
616  mpCurrentCreate=nullptr;
617 
619 
620  // recognize creation of a new 3D object inside a 3D scene
621  bool bSceneIntoScene(false);
622 
623  E3dScene* pObjScene = dynamic_cast<E3dScene*>(pObjCreated);
624  E3dScene* pCurrentScene = pObjScene ? dynamic_cast<E3dScene*>(mpCreatePV->GetCurrentGroup()) : nullptr;
625  if (pCurrentScene)
626  {
627  bool bDidInsert = static_cast<E3dView*>(this)->ImpCloneAll3DObjectsToDestScene(
628  pObjScene, pCurrentScene, Point(0, 0));
629 
630  if(bDidInsert)
631  {
632  // delete object, its content is cloned and inserted
633  SdrObject::Free( pObjCreated );
634  pObjCreated = nullptr;
635  bSceneIntoScene = true;
636  }
637  }
638 
639  if(!bSceneIntoScene)
640  {
641  // Here an interactively created SdrObject gets added, so
642  // take into account that interaction created an object in
643  // model coordinates. If we have e.g. a GirdOffset, this is a
644  // little bit tricky - we have an object in model coordinates,
645  // so the fetched offset is at the wrong point in principle
646  // since we need to 'substract' the offset here to get to
647  // 'real' model coordinates. But we have nothing better here,
648  // so go for it.
649  // The 2nd a little tricky thing is that this will early-create
650  // a ViewObjectContact for the new SdrObject, but these VOCs
651  // are anyways layouted for being create-on-demand. This will
652  // be adapted/replaced correctly later on.
653  // This *should* be the right place for getting all interactively
654  // created objects, see InsertObjectAtView below that calls
655  // CreateUndoNewObject.
656  basegfx::B2DVector aGridOffset(0.0, 0.0);
657  if(getPossibleGridOffsetForSdrObject(aGridOffset, pObj, mpCreatePV))
658  {
659  const Size aOffset(
660  basegfx::fround(-aGridOffset.getX()),
661  basegfx::fround(-aGridOffset.getY()));
662 
663  pObj->NbcMove(aOffset);
664  }
665 
666  // do the same as before
668  }
669 
670  mpCreatePV = nullptr;
671  bRet=true; // sal_True = event interpreted
672  }
673  else
674  {
675  BrkCreateObj();
676  }
677  }
678  else
679  { // more points
680  if (eCmd==SdrCreateCmd::ForceEnd || // nothing there -- force ending
681  nCount==0 || // no existing points (should never happen)
682  (nCount<=1 && !maDragStat.IsMinMoved())) { // MinMove not met
683  BrkCreateObj();
684  }
685  else
686  {
687  // replace for DrawCreateObjDiff
688  HideCreateObj();
689  ShowCreateObj();
690  maDragStat.ResetMinMoved(); // NextPoint is at MovCreateObj()
691  bRet=true;
692  }
693  }
694  }
695  return bRet;
696 }
697 
699 {
700  if (mpCurrentCreate==nullptr)
701  return;
702 
703  if (maDragStat.GetPointCount()<=2 )
704  {
705  BrkCreateObj();
706  }
707  else
708  {
709  HideCreateObj();
712  {
713  ShowCreateObj();
714  }
715  else
716  {
717  BrkCreateObj();
718  }
719  }
720 }
721 
723 {
724  if (mpCurrentCreate!=nullptr)
725  {
726  HideCreateObj();
729  mpCurrentCreate = nullptr;
730  mpCreatePV = nullptr;
731  }
732 }
733 
734 void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
735 {
736  if(!IsCreateObj() || maDragStat.IsShown())
737  return;
738 
739  if (mpCurrentCreate)
740  {
741  // for migration from XOR, replace DrawDragObj here to create
742  // overlay objects instead.
743  bool bUseSolidDragging(IsSolidDragging());
744 
745  // #i101648# check if dragged object is a naked SdrObject (not
746  // a derivation). This is e.g. used in SW Frame construction
747  // as placeholder. Do not use SolidDragging for naked SdrObjects,
748  // they cannot have a valid optical representation
749  if(bUseSolidDragging && OBJ_NONE == mpCurrentCreate->GetObjIdentifier())
750  {
751  bUseSolidDragging = false;
752  }
753 
754  // check for objects with no fill and no line
755  if(bUseSolidDragging)
756  {
758  const drawing::FillStyle eFill(rSet.Get(XATTR_FILLSTYLE).GetValue());
759  const drawing::LineStyle eLine(rSet.Get(XATTR_LINESTYLE).GetValue());
760 
761  if(drawing::LineStyle_NONE == eLine && drawing::FillStyle_NONE == eFill)
762  {
763  bUseSolidDragging = false;
764  }
765  }
766 
767  // check for form controls
768  if(bUseSolidDragging)
769  {
770  if (dynamic_cast<const SdrUnoObj*>(mpCurrentCreate) != nullptr)
771  {
772  bUseSolidDragging = false;
773  }
774  }
775 
776  // #i101781# force to non-solid dragging when not creating a full circle
777  if(bUseSolidDragging)
778  {
779  SdrCircObj* pCircObj = dynamic_cast<SdrCircObj*>(mpCurrentCreate);
780 
781  if(pCircObj && OBJ_CIRC != pCircObj->GetObjIdentifier())
782  {
783  // #i103058# Allow SolidDragging with four points
784  if(maDragStat.GetPointCount() < 4)
785  {
786  bUseSolidDragging = false;
787  }
788  }
789  }
790 
791  if(bUseSolidDragging)
792  {
793  basegfx::B2DPolyPolygon aDragPolyPolygon;
794 
795  if (dynamic_cast<const SdrRectObj*>(mpCurrentCreate) != nullptr)
796  {
797  // ensure object has some size, necessary for SdrTextObj because
798  // there are still untested divisions by that sizes
799  tools::Rectangle aCurrentSnapRect(mpCurrentCreate->GetSnapRect());
800 
801  if(aCurrentSnapRect.GetWidth() <= 1 || aCurrentSnapRect.GetHeight() <= 1)
802  {
804  mpCurrentCreate->NbcSetSnapRect(aNewRect);
805  }
806  }
807 
808  if (auto pPathObj = dynamic_cast<SdrPathObj*>(mpCurrentCreate))
809  {
810  // The up-to-now created path needs to be set at the object to have something
811  // that can be visualized
812  const basegfx::B2DPolyPolygon aCurrentPolyPolygon(pPathObj->getObjectPolyPolygon(maDragStat));
813 
814  if(aCurrentPolyPolygon.count())
815  {
816  pPathObj->NbcSetPathPoly(aCurrentPolyPolygon);
817  }
818 
819  aDragPolyPolygon = pPathObj->getDragPolyPolygon(maDragStat);
820  }
821 
822  // use the SdrObject directly for overlay
823  mpCreateViewExtraData->CreateAndShowOverlay(*this, mpCurrentCreate, aDragPolyPolygon);
824  }
825  else
826  {
827  const ::basegfx::B2DPolyPolygon aPoly(mpCurrentCreate->TakeCreatePoly(maDragStat));
828 
829  mpCreateViewExtraData->CreateAndShowOverlay(*this, nullptr, aPoly);
830  }
831 
832  // #i101679# Force changed overlay to be shown
833  for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
834  {
835  SdrPaintWindow* pCandidate = GetPaintWindow(a);
836  const rtl::Reference<sdr::overlay::OverlayManager>& xOverlayManager = pCandidate->GetOverlayManager();
837 
838  if (xOverlayManager.is())
839  {
840  xOverlayManager->flush();
841  }
842  }
843  }
844 
845  maDragStat.SetShown(true);
846 }
847 
849 {
850  if(IsCreateObj() && maDragStat.IsShown())
851  {
852  // for migration from XOR, replace DrawDragObj here to create
853  // overlay objects instead.
854  mpCreateViewExtraData->HideOverlay();
855 
856  //DrawCreateObj(pOut,bFull);
857  maDragStat.SetShown(false);
858  }
859 }
860 
861 
862 void SdrCreateView::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const
863 {
864  if (mpCurrentCreate)
865  {
866  rTargetSet.Put(mpCurrentCreate->GetMergedItemSet());
867  }
868  else
869  {
870  SdrDragView::GetAttributes(rTargetSet, bOnlyHardAttr);
871  }
872 }
873 
874 bool SdrCreateView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
875 {
876  if (mpCurrentCreate)
877  {
878  mpCurrentCreate->SetMergedItemSetAndBroadcast(rSet, bReplaceAll);
879 
880  return true;
881  }
882  else
883  {
884  return SdrDragView::SetAttributes(rSet,bReplaceAll);
885  }
886 }
887 
889 {
890  if (mpCurrentCreate != nullptr)
891  {
892  return mpCurrentCreate->GetStyleSheet();
893  }
894  else
895  {
897  }
898 }
899 
900 void SdrCreateView::SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr)
901 {
902  if (mpCurrentCreate != nullptr)
903  {
904  mpCurrentCreate->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
905  }
906  else
907  {
908  SdrDragView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
909  }
910 }
911 
912 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void UnmarkAllObj(SdrPageView const *pPV=nullptr)
Definition: svdmrkv.cxx:2518
virtual bool BckCreate(SdrDragStat &rStat)
Definition: svdobj.cxx:1413
double getY() const
virtual basegfx::B2DPolyPolygon TakeXorPoly() const
The Xor-Polygon is required by the View to drag the object.
Definition: svdobj.cxx:1127
std::unique_ptr< ImplConnectMarkerOverlay > mpCoMaOverlay
Definition: svdcrtv.hxx:42
void SetMinMove(sal_uInt16 nDist)
Definition: svddrag.hxx:121
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void Reset()
Definition: svddrag.cxx:36
Utility class SdrObjConnection.
Definition: svdoedge.hxx:39
bool EndCreateObj(SdrCreateCmd eCmd)
Definition: svdcrtv.cxx:588
virtual bool BegCreate(SdrDragStat &rStat)
Every object must be able to create itself interactively.
Definition: svdobj.cxx:1382
virtual bool IsAction() const override
Definition: svddrgv.cxx:71
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
void BckCreateObj()
Definition: svdcrtv.cxx:698
virtual void TakeActionRect(tools::Rectangle &rRect) const override
Definition: svddrgv.cxx:106
bool IsShown() const
Definition: svddrag.hxx:115
bool BegCreateObj(const Point &rPnt, OutputDevice *pOut=nullptr, short nMinMov=-3)
Definition: svdcrtv.cxx:494
constexpr tools::Long Left() const
const Point & GetStart() const
Definition: svddrag.hxx:102
void ImpClearConnectMarker()
Definition: svdcrtv.cxx:176
rectangle (round corners optional)
Definition: svdobjkind.hxx:30
bool BegCreatePreparedObject(const Point &rPnt, sal_Int16 nMinMov, SdrObject *pPreparedFactoryObject)
Definition: svdcrtv.cxx:499
SfxStyleSheet * GetStyleSheet() const
Definition: svdedxv.cxx:2295
bool IsEdgeTool() const
Definition: svdcrtv.cxx:322
bool CheckMinMoved(const Point &rPnt)
Definition: svddrag.cxx:86
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
OUString maMeasureLayer
Definition: svdpntv.hxx:131
void SetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr)
Definition: svdobj.cxx:2232
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
Definition: svdobj.cxx:3169
SdrDragStat maDragStat
Definition: svdpntv.hxx:140
bool CheckEdgeMode()
Definition: svdcrtv.cxx:250
SdrInventor
Definition: svdobj.hxx:100
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
const Point & GetPoint(sal_Int32 nNum) const
Definition: svddrag.hxx:100
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const
Definition: svdcrtv.cxx:862
void append(std::unique_ptr< OverlayObject > pOverlayObject)
SfxStyleSheet * GetStyleSheet() const
Definition: svdcrtv.cxx:888
virtual bool MouseMove(const MouseEvent &rMEvt, OutputDevice *pWin) override
handle mouse over effects for handles
Definition: svdedxv.cxx:1926
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:471
virtual SdrObjKind GetObjIdentifier() const
Definition: svdobj.cxx:659
static bool ImpFindConnector(const Point &rPt, const SdrPageView &rPV, SdrObjConnection &rCon, const SdrEdgeObj *pThis, OutputDevice *pOut=nullptr, SdrDragStat *pDragStat=nullptr)
Definition: svdoedge.cxx:2130
bool IsMeasureTool() const
Definition: svdcrtv.cxx:327
sal_uInt16 ImpGetMinMovLogic(short nMinMov, const OutputDevice *pOut) const
Definition: svdpntv.cxx:302
SdrObjKind
Definition: svdobjkind.hxx:24
bool IsOrtho8Possible() const
Definition: svddrag.hxx:138
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
Definition: svdedtv.cxx:983
VclPtr< OutputDevice > mpDragWin
Definition: svdpntv.hxx:127
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:251
virtual const tools::Rectangle & GetSnapRect() const
Definition: svdobj.cxx:1668
SdrModel * mpModel
Definition: svdpntv.hxx:125
constexpr tools::Long Width() const
void ResetMinMoved()
Definition: svddrag.hxx:120
virtual void BckAction() override
Definition: svddrgv.cxx:94
static void SetupObjLayer(const SdrPageView *pPageView, const OUString &aActiveLayer, SdrObject *pObj)
Setup layer (eg. foreground / background) of the given object.
Definition: svdcrtv.cxx:564
virtual void BrkCreate(SdrDragStat &rStat)
Definition: svdobj.cxx:1409
virtual ~SdrCreateView() override
Definition: svdcrtv.cxx:196
virtual void MovAction(const Point &rPnt) override
Definition: svddrgv.cxx:76
bool IsOrtho() const
Definition: svdsnpv.hxx:246
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd)
Definition: svdobj.cxx:1401
virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const
Definition: svdobj.cxx:2253
sdr::overlay::OverlayObjectList maObjects
Definition: svdcrtv.cxx:48
Point GetSnapPos(const Point &rPnt, const SdrPageView *pPV) const
Definition: svdsnpv.cxx:254
void HideCreateObj()
Definition: svdcrtv.cxx:848
int nCount
SfxStyleSheet * GetStyleSheet() const
Definition: svdobj.cxx:2227
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
Definition: svdobj.cxx:2005
void MovCreateObj(const Point &rPnt)
Definition: svdcrtv.cxx:520
PointerStyle maCurrentCreatePointer
Definition: svdcrtv.hxx:48
constexpr SdrLayerID SDRLAYER_NOTFOUND(0xff)
o3tl::strong_int< sal_uInt8, struct SdrLayerIDTag > SdrLayerID
Definition: svdtypes.hxx:56
B2IRange fround(const B2DRange &rRange)
bool IsMinMoved() const
Definition: svddrag.hxx:118
SdrInventor mnCurrentInvent
Definition: svdcrtv.hxx:52
constexpr bool IsEmpty() const
sal_uInt32 PaintWindowCount() const
Definition: svdpntv.hxx:218
virtual void EndAction() override
Definition: svddrgv.cxx:85
void BrkCreateObj()
Definition: svdcrtv.cxx:722
bool ImpLimitToWorkArea(Point &rPt) const
Definition: svdxcgv.cxx:61
virtual bool MouseMove(const MouseEvent &rMEvt, OutputDevice *pWin) override
handle mouse over effects for handles
Definition: svdcrtv.cxx:298
virtual bool MovCreate(SdrDragStat &rStat)
Definition: svdobj.cxx:1392
SfxStyleSheet * mpDefaultStyleSheet
Definition: svdpntv.hxx:128
const SdrLayerIDSet & GetVisibleLayers() const
Definition: svdpagv.hxx:210
virtual void SetLayer(SdrLayerID nLayer)
Definition: svdobj.cxx:700
void ImpSetGlueVisible3(bool bOn)
Definition: svdpntv.hxx:235
const OUString & GetControlLayerName() const
Definition: svdlayer.hxx:149
int i
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdocirc.cxx:178
uno_Any a
bool ImpBegCreateObj(SdrInventor nInvent, SdrObjKind nIdent, const Point &rPnt, OutputDevice *pOut, sal_Int16 nMinMov, const tools::Rectangle &rLogRect, SdrObject *pPreparedFactoryObject)
Definition: svdcrtv.cxx:369
bool IsMarkedObjHit(const Point &rPnt, short nTol=-2) const
Definition: svdmrkv.cxx:1869
const tools::Rectangle & GetActionRect() const
Definition: svddrag.hxx:166
connector object
Definition: svdobjkind.hxx:48
sal_Int32 GetPointCount() const
Definition: svddrag.hxx:101
void ActionChanged() const
Definition: svdobj.cxx:263
void ShowCreateObj()
Definition: svdcrtv.cxx:734
constexpr tools::Long Right() const
SdrCreateView(SdrModel &rSdrModel, OutputDevice *pOut)
Definition: svdcrtv.cxx:181
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
Definition: svdobj.cxx:2020
open free-hand line
Definition: svdobjkind.hxx:39
SdrHdl * PickHandle(const Point &rPnt) const
Definition: svdmrkv.cxx:1880
void OrthoDistance8(const Point &rPt0, Point &rPt, bool bBigOrtho)
Definition: svdtrans.cxx:530
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
Definition: svdcrtv.cxx:332
closed Bezier-curve
Definition: svdobjkind.hxx:38
constexpr tools::Long Top() const
const SdrLayerAdmin & GetLayerAdmin() const
changing the layers does not set the modified-flag!
Definition: svdpage.cxx:1724
void NextMove(const Point &rPnt)
Definition: svddrag.cxx:66
void SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr)
Definition: svdcrtv.cxx:900
SdrPageView * mpCreatePV
Definition: svdcrtv.hxx:41
void NextPoint()
Definition: svddrag.cxx:73
OUString maActualLayer
Definition: svdpntv.hxx:130
bool IsTextTool() const
Definition: svdcrtv.cxx:317
Abstract DrawObject.
Definition: svdobj.hxx:260
bool IsCreateMode() const
Definition: svdmrkv.hxx:231
bool getPossibleGridOffsetForSdrObject(basegfx::B2DVector &rOffset, const SdrObject *pObj, const SdrPageView *pPV) const
Definition: svdmrkv.cxx:2174
virtual SdrInventor GetObjInventor() const
Definition: svdobj.cxx:654
const Point & GetPrev() const
Definition: svddrag.hxx:103
constexpr tools::Long Bottom() const
bool IsCreateObj() const
Definition: svdcrtv.hxx:119
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
const SdrLayerIDSet & GetLockedLayers() const
Definition: svdpagv.hxx:214
virtual bool IsAction() const override
Definition: svdcrtv.cxx:203
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:64
SdrViewEditMode meEditMode
Definition: svdmrkv.hxx:119
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SdrObject * mpCurrentCreate
Definition: svdcrtv.hxx:40
sdr::overlay::OverlayObjectList maObjects
Definition: svdcrtv.cxx:115
Derived class of SdrView to edit 3D objects.
Definition: view3d.hxx:41
sal_uInt32 count() const
void getViewIndependentPrimitive2DContainer(drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual void NbcSetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1673
constexpr tools::Long Height() const
virtual void NbcSetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1683
SdrPage * GetPage() const
Definition: svdpagv.hxx:166
const SdrObject & mrObject
Definition: svdcrtv.cxx:51
object that represents a SdrPage
Definition: svdobjkind.hxx:52
virtual void NbcMove(const Size &rSiz)
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdobj.cxx:1435
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
bool IsSolidDragging() const
Definition: svddrgv.cxx:912
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1980
virtual PointerStyle GetCreatePointer() const
get the cursor/pointer that signals creating this object
Definition: svdobj.cxx:1429
bool IsOrtho4Possible() const
Definition: svddrag.hxx:135
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll)
Definition: svdcrtv.cxx:874
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const Point & GetPosPixel() const
const Point & GetNow() const
Definition: svddrag.hxx:105
PointerStyle
void CreateAndShowOverlay(const SdrCreateView &rView, const SdrObject *pObject, const basegfx::B2DPolyPolygon &rPolyPoly)
Definition: svdcrtv.cxx:134
text object
Definition: svdobjkind.hxx:43
void SetView(SdrView *pV)
Definition: svddrag.hxx:97
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:299
virtual void BrkAction() override
Definition: svddrgv.cxx:100
virtual void TakeActionRect(tools::Rectangle &rRect) const override
Definition: svdcrtv.cxx:234
void SetConnectMarker(const SdrObjConnection &rCon)
Definition: svdcrtv.cxx:270
void PrevPoint()
Definition: svddrag.cxx:78
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll)
Definition: svdedxv.cxx:2147
bool BegCreateCaptionObj(const Point &rPnt, const Size &rObjSiz, OutputDevice *pOut=nullptr, short nMinMov=-3)
Definition: svdcrtv.cxx:513
void SetShown(bool bOn)
Definition: svddrag.hxx:116
virtual void MovAction(const Point &rPnt) override
Definition: svdcrtv.cxx:208
std::unique_ptr< ImpSdrCreateViewExtraData > mpCreateViewExtraData
Definition: svdcrtv.hxx:46
double getX() const
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:316
void SetPageView(SdrPageView *pPV)
Definition: svddrag.hxx:99
OLE object.
Definition: svdobjkind.hxx:47
ImplConnectMarkerOverlay(const SdrCreateView &rView, SdrObject const &rObject)
Definition: svdcrtv.cxx:63
virtual void BrkAction() override
Definition: svdcrtv.cxx:228
virtual void NbcSetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr)
Definition: svdobj.cxx:2245
void SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr)
Definition: svdedxv.cxx:2316
SdrCreateCmd
Definition: svdtypes.hxx:26
bool IsBigOrtho() const
Definition: svdsnpv.hxx:258
TitleText, special text object for StarDraw.
Definition: svdobjkind.hxx:44
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const
Definition: svdedxv.cxx:2110
SdrLayerID GetLayerID(const OUString &rName) const
Definition: svdlayer.cxx:230
periodic cubic Spline (ni)
Definition: svdobjkind.hxx:42
SdrObjKind mnCurrentIdent
Definition: svdcrtv.hxx:53
void OrthoDistance4(const Point &rPt0, Point &rPt, bool bBigOrtho)
Definition: svdtrans.cxx:546
SdrModel * GetModel() const
Definition: svdpntv.hxx:260
const SdrObject & GetTargetObject() const
Definition: svdcrtv.cxx:60
SfxItemSet maDefaultAttr
Definition: svdpntv.hxx:142
virtual void BckAction() override
Definition: svdcrtv.cxx:222
bool IsNoSnap() const
Definition: svddrag.hxx:130
const tools::Rectangle & GetWorkArea() const
Definition: svddrgv.hxx:210
SdrPaintWindow * GetPaintWindow(sal_uInt32 nIndex) const
Definition: svdpntv.cxx:73
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const
Polygon dragged by the user when creating the object.
Definition: svdobj.cxx:1418
void HideConnectMarker()
Definition: svdcrtv.cxx:293
SdrObject * pObj
Definition: svdoedge.hxx:46
virtual void EndAction() override
Definition: svdcrtv.cxx:216
SdrObject * GetCurrentGroup() const
Return current Group.
Definition: svdpagv.hxx:172