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