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  : SdrDragView(rSdrModel, pOut)
182  , pCurrentCreate(nullptr)
183  , pCreatePV(nullptr)
184  , mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
185  , aCurrentCreatePointer(PointerStyle::Cross)
186  , nAutoCloseDistPix(5)
187  , nFreeHandMinDistPix(10)
188  , nCurrentInvent(SdrInventor::Default)
189  , nCurrentIdent(OBJ_NONE)
190  , b1stPointAsCenter(false)
191  , bUseIncompatiblePathCreateInterface(false)
192 {
193 }
194 
196 {
198  mpCreateViewExtraData.reset();
200 }
201 
203 {
204  return SdrDragView::IsAction() || pCurrentCreate!=nullptr;
205 }
206 
207 void SdrCreateView::MovAction(const Point& rPnt)
208 {
210  if (pCurrentCreate!=nullptr) {
211  MovCreateObj(rPnt);
212  }
213 }
214 
216 {
219 }
220 
222 {
223  if (pCurrentCreate!=nullptr) BckCreateObj();
225 }
226 
228 {
230  BrkCreateObj();
231 }
232 
234 {
235  if (pCurrentCreate!=nullptr)
236  {
237  rRect=maDragStat.GetActionRect();
238  if (rRect.IsEmpty())
239  {
241  }
242  }
243  else
244  {
246  }
247 }
248 
250 {
251  if (pCurrentCreate!=nullptr)
252  {
253  // is managed by EdgeObj
255  }
256 
258  {
260  return false;
261  }
262  else
263  {
264  // sal_True, if MouseMove should check Connect
265  return !IsAction();
266  }
267 }
268 
270 {
271  SdrObject* pTargetObject = rCon.pObj;
272 
273  if(pTargetObject)
274  {
275  // if target object changes, throw away overlay object to make room for changes
276  if(mpCoMaOverlay && pTargetObject != &mpCoMaOverlay->GetTargetObject())
277  {
279  }
280 
281  if(!mpCoMaOverlay)
282  {
283  mpCoMaOverlay.reset(new ImplConnectMarkerOverlay(*this, *pTargetObject));
284  }
285  }
286  else
287  {
289  }
290 }
291 
293 {
295 }
296 
298 {
299  if(CheckEdgeMode() && pWin)
300  {
301  SdrPageView* pPV = GetSdrPageView();
302 
303  if(pPV)
304  {
305  // TODO: Change default hit tolerance at IsMarkedHit() some time!
306  Point aPos(pWin->PixelToLogic(rMEvt.GetPosPixel()));
307  bool bMarkHit=PickHandle(aPos)!=nullptr || IsMarkedObjHit(aPos);
308  SdrObjConnection aCon;
309  if (!bMarkHit) SdrEdgeObj::ImpFindConnector(aPos,*pPV,aCon,nullptr,pWin);
310  SetConnectMarker(aCon);
311  }
312  }
313  return SdrDragView::MouseMove(rMEvt,pWin);
314 }
315 
317 {
319 }
320 
322 {
324 }
325 
327 {
329 }
330 
331 void SdrCreateView::SetCurrentObj(sal_uInt16 nIdent, SdrInventor nInvent)
332 {
333  if (nCurrentInvent!=nInvent || nCurrentIdent!=nIdent)
334  {
335  nCurrentInvent=nInvent;
336  nCurrentIdent=nIdent;
337  SdrObject * pObj = (nIdent == OBJ_NONE) ? nullptr :
339  *GetModel(),
340  nInvent,
341  nIdent);
342 
343  if(pObj)
344  {
345  // Using text tool, mouse cursor is usually I-Beam,
346  // crosshairs with tiny I-Beam appears only on MouseButtonDown.
347  if(IsTextTool())
348  {
349  // Here the correct pointer needs to be used
350  // if the default is set to vertical writing
351  aCurrentCreatePointer = PointerStyle::Text;
352  }
353  else
355 
356  SdrObject::Free( pObj );
357  }
358  else
359  {
360  aCurrentCreatePointer = PointerStyle::Cross;
361  }
362  }
363 
364  CheckEdgeMode();
366 }
367 
368 bool SdrCreateView::ImpBegCreateObj(SdrInventor nInvent, sal_uInt16 nIdent, const Point& rPnt, OutputDevice* pOut,
369  sal_Int16 nMinMov, const tools::Rectangle& rLogRect, SdrObject* pPreparedFactoryObject)
370 {
371  bool bRet=false;
372  UnmarkAllObj();
373  BrkAction();
374 
376 
378 
379  if (pCreatePV!=nullptr)
380  { // otherwise no side registered!
381  OUString aLay(maActualLayer);
382 
383  if(nInvent == SdrInventor::Default && nIdent == OBJ_MEASURE && !maMeasureLayer.isEmpty())
384  {
385  aLay = maMeasureLayer;
386  }
387 
389  if (nLayer==SDRLAYER_NOTFOUND) nLayer = SdrLayerID(0);
390  if (!pCreatePV->GetLockedLayers().IsSet(nLayer) && pCreatePV->GetVisibleLayers().IsSet(nLayer))
391  {
392  if(pPreparedFactoryObject)
393  {
394  pCurrentCreate = pPreparedFactoryObject;
395  }
396  else
397  {
399  *mpModel,
400  nInvent,
401  nIdent);
402  }
403 
404  Point aPnt(rPnt);
406  nCurrentIdent!=sal_uInt16(OBJ_FREELINE) &&
407  nCurrentIdent!=sal_uInt16(OBJ_FREEFILL) )) { // no snapping for Edge and Freehand
408  aPnt=GetSnapPos(aPnt,pCreatePV);
409  }
410  if (pCurrentCreate!=nullptr)
411  {
413 
414  // SW uses a naked SdrObject for frame construction. Normally, such an
415  // object should not be created. Since it is possible to use it as a helper
416  // object (e.g. in letting the user define an area with the interactive
417  // construction) at least no items should be set at that object.
418  if(nInvent != SdrInventor::Default || nIdent != OBJ_NONE)
419  {
421  }
422 
423  if (mpModel && dynamic_cast<const SdrCaptionObj *>(pCurrentCreate) != nullptr)
424  {
425  SfxItemSet aSet(mpModel->GetItemPool());
426  aSet.Put(XFillColorItem(OUString(),COL_WHITE)); // in case someone turns on Solid
427  aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
428 
430  }
431  if (mpModel && nInvent==SdrInventor::Default && (nIdent==OBJ_TEXT ||
432  nIdent==OBJ_TITLETEXT || nIdent==OBJ_OUTLINETEXT))
433  {
434  // default for all text frames: no background, no border
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  aSet.Put(XLineColorItem(OUString(),COL_BLACK)); // in case someone turns on Solid
439  aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
440 
442  }
443  if (!rLogRect.IsEmpty()) pCurrentCreate->NbcSetLogicRect(rLogRect);
444 
445  // make sure drag start point is inside WorkArea
446  const tools::Rectangle& rWorkArea = GetWorkArea();
447 
448  if(!rWorkArea.IsEmpty())
449  {
450  if(aPnt.X() < rWorkArea.Left())
451  {
452  aPnt.setX( rWorkArea.Left() );
453  }
454 
455  if(aPnt.X() > rWorkArea.Right())
456  {
457  aPnt.setX( rWorkArea.Right() );
458  }
459 
460  if(aPnt.Y() < rWorkArea.Top())
461  {
462  aPnt.setY( rWorkArea.Top() );
463  }
464 
465  if(aPnt.Y() > rWorkArea.Bottom())
466  {
467  aPnt.setY( rWorkArea.Bottom() );
468  }
469  }
470 
471  maDragStat.Reset(aPnt);
472  maDragStat.SetView(static_cast<SdrView*>(this));
474  maDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
475  mpDragWin=pOut;
477  {
478  ShowCreateObj(/*pOut,sal_True*/);
479  bRet=true;
480  }
481  else
482  {
484  pCurrentCreate=nullptr;
485  pCreatePV=nullptr;
486  }
487  }
488  }
489  }
490  return bRet;
491 }
492 
493 bool SdrCreateView::BegCreateObj(const Point& rPnt, OutputDevice* pOut, short nMinMov)
494 {
495  return ImpBegCreateObj(nCurrentInvent,nCurrentIdent,rPnt,pOut,nMinMov,tools::Rectangle(), nullptr);
496 }
497 
498 bool SdrCreateView::BegCreatePreparedObject(const Point& rPnt, sal_Int16 nMinMov, SdrObject* pPreparedFactoryObject)
499 {
500  SdrInventor nInvent(nCurrentInvent);
501  sal_uInt16 nIdent(nCurrentIdent);
502 
503  if(pPreparedFactoryObject)
504  {
505  nInvent = pPreparedFactoryObject->GetObjInventor();
506  nIdent = pPreparedFactoryObject->GetObjIdentifier();
507  }
508 
509  return ImpBegCreateObj(nInvent, nIdent, rPnt, nullptr, nMinMov, tools::Rectangle(), pPreparedFactoryObject);
510 }
511 
512 bool SdrCreateView::BegCreateCaptionObj(const Point& rPnt, const Size& rObjSiz,
513  OutputDevice* pOut, short nMinMov)
514 {
515  return ImpBegCreateObj(SdrInventor::Default,OBJ_CAPTION,rPnt,pOut,nMinMov,
516  tools::Rectangle(rPnt,Size(rObjSiz.Width()+1,rObjSiz.Height()+1)), nullptr);
517 }
518 
519 void SdrCreateView::MovCreateObj(const Point& rPnt)
520 {
521  if (pCurrentCreate==nullptr)
522  return;
523 
524  Point aPnt(rPnt);
525  if (!maDragStat.IsNoSnap())
526  {
527  aPnt=GetSnapPos(aPnt,pCreatePV);
528  }
529  if (IsOrtho())
530  {
533  }
534 
535  // If the drag point was limited and Ortho is active, do
536  // the small ortho correction (reduction) -> last parameter to FALSE.
537  bool bDidLimit(ImpLimitToWorkArea(aPnt));
538  if(bDidLimit && IsOrtho())
539  {
541  OrthoDistance8(maDragStat.GetPrev(), aPnt, false);
542  else if(maDragStat.IsOrtho4Possible())
543  OrthoDistance4(maDragStat.GetPrev(), aPnt, false);
544  }
545 
546  if (aPnt==maDragStat.GetNow()) return;
547  bool bIsMinMoved(maDragStat.IsMinMoved());
548  if (!maDragStat.CheckMinMoved(aPnt))
549  return;
550 
551  if (!bIsMinMoved) maDragStat.NextPoint();
552  maDragStat.NextMove(aPnt);
554 
555  // MovCreate changes the object, so use ActionChanged() on it
557 
558  // replace for DrawCreateObjDiff
559  HideCreateObj();
560  ShowCreateObj();
561 }
562 
563 void SdrCreateView::SetupObjLayer(const SdrPageView* pPageView, const OUString& aActiveLayer, SdrObject* pObj)
564 {
565  const SdrLayerAdmin& rAd = pPageView->GetPage()->GetLayerAdmin();
566  SdrLayerID nLayer(0);
567 
568  // #i72535#
569  if(dynamic_cast<const FmFormObj*>( pObj) != nullptr)
570  {
571  // for FormControls, force to form layer
572  nLayer = rAd.GetLayerID(rAd.GetControlLayerName());
573  }
574  else
575  {
576  nLayer = rAd.GetLayerID(aActiveLayer);
577  }
578 
579  if(SDRLAYER_NOTFOUND == nLayer)
580  {
581  nLayer = SdrLayerID(0);
582  }
583 
584  pObj->SetLayer(nLayer);
585 }
586 
588 {
589  bool bRet=false;
590  SdrObject* pObjCreated=pCurrentCreate;
591 
592  if (pCurrentCreate!=nullptr)
593  {
594  sal_uInt32 nCount=maDragStat.GetPointCount();
595 
596  if (nCount<=1 && eCmd==SdrCreateCmd::ForceEnd)
597  {
598  BrkCreateObj(); // objects with only a single point don't exist (at least today)
599  return false; // sal_False = event not interpreted
600  }
601 
602  bool bPntsEq=nCount>1;
603  sal_uInt32 i=1;
604  Point aP0=maDragStat.GetPoint(0);
605  while (bPntsEq && i<nCount) { bPntsEq=aP0==maDragStat.GetPoint(i); i++; }
606 
608  {
609  HideCreateObj();
610 
611  if (!bPntsEq)
612  {
613  // otherwise Brk, because all points are equal
615  pCurrentCreate=nullptr;
616 
618 
619  // recognize creation of a new 3D object inside a 3D scene
620  bool bSceneIntoScene(false);
621 
622  E3dScene* pObjScene = dynamic_cast<E3dScene*>(pObjCreated);
623  E3dScene* pCurrentScene = pObjScene ? dynamic_cast<E3dScene*>(pCreatePV->GetCurrentGroup()) : nullptr;
624  if (pCurrentScene)
625  {
626  bool bDidInsert = static_cast<E3dView*>(this)->ImpCloneAll3DObjectsToDestScene(
627  pObjScene, pCurrentScene, Point(0, 0));
628 
629  if(bDidInsert)
630  {
631  // delete object, its content is cloned and inserted
632  SdrObject::Free( pObjCreated );
633  pObjCreated = nullptr;
634  bSceneIntoScene = true;
635  }
636  }
637 
638  if(!bSceneIntoScene)
639  {
640  // Here an interactively created SdrObject gets added, so
641  // take into account that interaction created an object in
642  // model coordinates. If we have e.g. a GirdOffset, this is a
643  // little bit tricky - we have an object in model coordinates,
644  // so the fetched offset is at the wrong point in principle
645  // since we need to 'substract' the offset here to get to
646  // 'real' model coordinates. But we have nothing better here,
647  // so go for it.
648  // The 2nd a little tricky thing is that this will early-create
649  // a ViewObjectContact for the new SdrObject, but these VOCs
650  // are anyways layouted for being create-on-demand. This will
651  // be adapted/replaced correctly later on.
652  // This *should* be the right place for getting all interactively
653  // created objects, see InsertObjectAtView below that calls
654  // CreateUndoNewObject.
655  basegfx::B2DVector aGridOffset(0.0, 0.0);
656  if(getPossibleGridOffsetForSdrObject(aGridOffset, pObj, pCreatePV))
657  {
658  const Size aOffset(
659  basegfx::fround(-aGridOffset.getX()),
660  basegfx::fround(-aGridOffset.getY()));
661 
662  pObj->NbcMove(aOffset);
663  }
664 
665  // do the same as before
667  }
668 
669  pCreatePV=nullptr;
670  bRet=true; // sal_True = event interpreted
671  }
672  else
673  {
674  BrkCreateObj();
675  }
676  }
677  else
678  { // more points
679  if (eCmd==SdrCreateCmd::ForceEnd || // nothing there -- force ending
680  nCount==0 || // no existing points (should never happen)
681  (nCount<=1 && !maDragStat.IsMinMoved())) { // MinMove not met
682  BrkCreateObj();
683  }
684  else
685  {
686  // replace for DrawCreateObjDiff
687  HideCreateObj();
688  ShowCreateObj();
689  maDragStat.ResetMinMoved(); // NextPoint is at MovCreateObj()
690  bRet=true;
691  }
692  }
693  }
694  return bRet;
695 }
696 
698 {
699  if (pCurrentCreate==nullptr)
700  return;
701 
702  if (maDragStat.GetPointCount()<=2 )
703  {
704  BrkCreateObj();
705  }
706  else
707  {
708  HideCreateObj();
711  {
712  ShowCreateObj();
713  }
714  else
715  {
716  BrkCreateObj();
717  }
718  }
719 }
720 
722 {
723  if (pCurrentCreate!=nullptr)
724  {
725  HideCreateObj();
728  pCurrentCreate=nullptr;
729  pCreatePV=nullptr;
730  }
731 }
732 
733 void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
734 {
735  if(!IsCreateObj() || maDragStat.IsShown())
736  return;
737 
738  if(pCurrentCreate)
739  {
740  // for migration from XOR, replace DrawDragObj here to create
741  // overlay objects instead.
742  bool bUseSolidDragging(IsSolidDragging());
743 
744  // #i101648# check if dragged object is a naked SdrObject (not
745  // a derivation). This is e.g. used in SW Frame construction
746  // as placeholder. Do not use SolidDragging for naked SdrObjects,
747  // they cannot have a valid optical representation
748  if(bUseSolidDragging && OBJ_NONE == pCurrentCreate->GetObjIdentifier())
749  {
750  bUseSolidDragging = false;
751  }
752 
753  // check for objects with no fill and no line
754  if(bUseSolidDragging)
755  {
756  const SfxItemSet& rSet = pCurrentCreate->GetMergedItemSet();
757  const drawing::FillStyle eFill(rSet.Get(XATTR_FILLSTYLE).GetValue());
758  const drawing::LineStyle eLine(rSet.Get(XATTR_LINESTYLE).GetValue());
759 
760  if(drawing::LineStyle_NONE == eLine && drawing::FillStyle_NONE == eFill)
761  {
762  bUseSolidDragging = false;
763  }
764  }
765 
766  // check for form controls
767  if(bUseSolidDragging)
768  {
769  if(dynamic_cast<const SdrUnoObj*>( pCurrentCreate) != nullptr)
770  {
771  bUseSolidDragging = false;
772  }
773  }
774 
775  // #i101781# force to non-solid dragging when not creating a full circle
776  if(bUseSolidDragging)
777  {
778  SdrCircObj* pCircObj = dynamic_cast< SdrCircObj* >(pCurrentCreate);
779 
780  if(pCircObj && OBJ_CIRC != pCircObj->GetObjIdentifier())
781  {
782  // #i103058# Allow SolidDragging with four points
783  if(maDragStat.GetPointCount() < 4)
784  {
785  bUseSolidDragging = false;
786  }
787  }
788  }
789 
790  if(bUseSolidDragging)
791  {
792  basegfx::B2DPolyPolygon aDragPolyPolygon;
793 
794  if(dynamic_cast<const SdrRectObj*>( pCurrentCreate) != nullptr)
795  {
796  // ensure object has some size, necessary for SdrTextObj because
797  // there are still untested divisions by that sizes
798  tools::Rectangle aCurrentSnapRect(pCurrentCreate->GetSnapRect());
799 
800  if(aCurrentSnapRect.GetWidth() <= 1 || aCurrentSnapRect.GetHeight() <= 1)
801  {
803  pCurrentCreate->NbcSetSnapRect(aNewRect);
804  }
805  }
806 
807  if(dynamic_cast<const SdrPathObj*>( pCurrentCreate) != nullptr)
808  {
809  // The up-to-now created path needs to be set at the object to have something
810  // that can be visualized
811  SdrPathObj& rPathObj(static_cast<SdrPathObj&>(*pCurrentCreate));
812  const basegfx::B2DPolyPolygon aCurrentPolyPolygon(rPathObj.getObjectPolyPolygon(maDragStat));
813 
814  if(aCurrentPolyPolygon.count())
815  {
816  rPathObj.NbcSetPathPoly(aCurrentPolyPolygon);
817  }
818 
819  aDragPolyPolygon = rPathObj.getDragPolyPolygon(maDragStat);
820  }
821 
822  // use the SdrObject directly for overlay
823  mpCreateViewExtraData->CreateAndShowOverlay(*this, pCurrentCreate, aDragPolyPolygon);
824  }
825  else
826  {
827  const ::basegfx::B2DPolyPolygon aPoly(pCurrentCreate->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(pCurrentCreate)
865  {
866  rTargetSet.Put(pCurrentCreate->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(pCurrentCreate)
877  {
878  pCurrentCreate->SetMergedItemSetAndBroadcast(rSet, bReplaceAll);
879 
880  return true;
881  }
882  else
883  {
884  return SdrDragView::SetAttributes(rSet,bReplaceAll);
885  }
886 }
887 
889 {
890  if (pCurrentCreate!=nullptr)
891  {
892  return pCurrentCreate->GetStyleSheet();
893  }
894  else
895  {
897  }
898 }
899 
900 void SdrCreateView::SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr)
901 {
902  if (pCurrentCreate!=nullptr)
903  {
904  pCurrentCreate->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
905  }
906  else
907  {
908  SdrDragView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
909  }
910 }
911 
912 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 nCurrentIdent
Definition: svdcrtv.hxx:53
void UnmarkAllObj(SdrPageView const *pPV=nullptr)
Definition: svdmrkv.cxx:2332
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:587
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:67
virtual sal_uInt16 GetObjIdentifier() const override
Definition: svdocirc.cxx:170
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
void BckCreateObj()
Definition: svdcrtv.cxx:697
virtual void TakeActionRect(tools::Rectangle &rRect) const override
Definition: svddrgv.cxx:102
bool IsShown() const
Definition: svddrag.hxx:105
bool BegCreateObj(const Point &rPnt, OutputDevice *pOut=nullptr, short nMinMov=-3)
Definition: svdcrtv.cxx:493
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:498
SfxStyleSheet * GetStyleSheet() const
Definition: svdedxv.cxx:2266
periodic cubic Spline (ni)
Definition: svdobj.hxx:134
bool IsEdgeTool() const
Definition: svdcrtv.cxx:321
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
double getY() const
SdrDragStat maDragStat
Definition: svdpntv.hxx:141
bool CheckEdgeMode()
Definition: svdcrtv.cxx:249
SdrInventor
Definition: svdobj.hxx:153
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
const Point & GetPoint(sal_Int32 nNum) const
Definition: svddrag.hxx:90
OLE object.
Definition: svdobj.hxx:139
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:1903
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:396
open free-hand line
Definition: svdobj.hxx:131
bool IsMeasureTool() const
Definition: svdcrtv.cxx:326
sal_uInt16 ImpGetMinMovLogic(short nMinMov, const OutputDevice *pOut) const
Definition: svdpntv.cxx:300
object that represents a SdrPage
Definition: svdobj.hxx:144
bool IsOrtho8Possible() const
Definition: svddrag.hxx:128
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
Definition: svdedtv.cxx:981
VclPtr< OutputDevice > mpDragWin
Definition: svdpntv.hxx:128
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:245
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:90
static void SetupObjLayer(const SdrPageView *pPageView, const OUString &aActiveLayer, SdrObject *pObj)
Setup layer (eg. foreground / background) of the given object.
Definition: svdcrtv.cxx:563
SdrPageView * pCreatePV
Definition: svdcrtv.hxx:41
virtual void BrkCreate(SdrDragStat &rStat)
Definition: svdobj.cxx:1348
virtual ~SdrCreateView() override
Definition: svdcrtv.cxx:195
virtual void MovAction(const Point &rPnt) override
Definition: svddrgv.cxx:72
connector object
Definition: svdobj.hxx:140
bool IsOrtho() const
Definition: svdsnpv.hxx:246
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd)
Definition: svdobj.cxx:1340
tools::Long Left() const
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:848
int nCount
tools::Long Bottom() const
bool ImpBegCreateObj(SdrInventor nInvent, sal_uInt16 nIdent, const Point &rPnt, OutputDevice *pOut, sal_Int16 nMinMov, const tools::Rectangle &rLogRect, SdrObject *pPreparedFactoryObject)
Definition: svdcrtv.cxx:368
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:519
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:81
void BrkCreateObj()
Definition: svdcrtv.cxx:721
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:297
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:239
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:1684
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:733
SdrObject * pCurrentCreate
Definition: svdcrtv.hxx:40
tools::Long Width() const
SdrCreateView(SdrModel &rSdrModel, OutputDevice *pOut)
Definition: svdcrtv.cxx:180
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:1695
void OrthoDistance8(const Point &rPt0, Point &rPt, bool bBigOrtho)
Definition: svdtrans.cxx:529
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:900
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
tools::Long Top() const
bool IsTextTool() const
Definition: svdcrtv.cxx:316
Abstract DrawObject.
Definition: svdobj.hxx:313
bool IsCreateMode() const
Definition: svdmrkv.hxx:230
bool getPossibleGridOffsetForSdrObject(basegfx::B2DVector &rOffset, const SdrObject *pObj, const SdrPageView *pPV) const
Definition: svdmrkv.cxx:1989
virtual SdrInventor GetObjInventor() const
Definition: svdobj.cxx:553
const Point & GetPrev() const
Definition: svddrag.hxx:93
bool IsCreateObj() const
Definition: svdcrtv.hxx:115
Point PixelToLogic(const Point &rDevicePt) const
const SdrLayerIDSet & GetLockedLayers() const
Definition: svdpagv.hxx:219
virtual bool IsAction() const override
Definition: svdcrtv.cxx:202
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:66
closed Bezier-curve
Definition: svdobj.hxx:130
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:136
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:331
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
virtual void NbcMove(const Size &rSiz)
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdobj.cxx:1374
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
bool IsSolidDragging() const
Definition: svddrgv.cxx:904
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:874
tools::Long Height() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const Point & GetPosPixel() const
const Point & GetNow() const
Definition: svddrag.hxx:95
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:303
virtual void BrkAction() override
Definition: svddrgv.cxx:96
virtual void TakeActionRect(tools::Rectangle &rRect) const override
Definition: svdcrtv.cxx:233
void SetConnectMarker(const SdrObjConnection &rCon)
Definition: svdcrtv.cxx:269
void PrevPoint()
Definition: svddrag.cxx:78
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll)
Definition: svdedxv.cxx:2121
bool BegCreateCaptionObj(const Point &rPnt, const Size &rObjSiz, OutputDevice *pOut=nullptr, short nMinMov=-3)
Definition: svdcrtv.cxx:512
void SetShown(bool bOn)
Definition: svddrag.hxx:106
virtual void MovAction(const Point &rPnt) override
Definition: svdcrtv.cxx:207
std::unique_ptr< ImpSdrCreateViewExtraData > mpCreateViewExtraData
Definition: svdcrtv.hxx:46
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:313
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:227
virtual void NbcSetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr)
Definition: svdobj.cxx:2159
void SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr)
Definition: svdedxv.cxx:2287
SdrCreateCmd
Definition: svdtypes.hxx:27
bool IsBigOrtho() const
Definition: svdsnpv.hxx:258
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr) const
Definition: svdedxv.cxx:2084
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:264
const SdrObject & GetTargetObject() const
Definition: svdcrtv.cxx:60
SfxItemSet maDefaultAttr
Definition: svdpntv.hxx:143
virtual void BckAction() override
Definition: svdcrtv.cxx:221
bool IsNoSnap() const
Definition: svddrag.hxx:120
const tools::Rectangle & GetWorkArea() const
Definition: svddrgv.hxx:210
text object
Definition: svdobj.hxx:135
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
tools::Long Right() const
void HideConnectMarker()
Definition: svdcrtv.cxx:292
SdrObject * pObj
Definition: svdoedge.hxx:45
virtual void EndAction() override
Definition: svdcrtv.cxx:215
rectangle (round corners optional)
Definition: svdobj.hxx:122
SdrObject * GetCurrentGroup() const
Return current Group.
Definition: svdpagv.hxx:177