LibreOffice Module svx (master)  1
svddrgmt.hxx
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 #ifndef INCLUDED_SVX_SVDDRGMT_HXX
21 #define INCLUDED_SVX_SVDDRGMT_HXX
22 
23 #include <svx/svddrgv.hxx>
24 #include <svx/svxdllapi.h>
26 #include <memory>
27 
28 class SdrDragView;
29 class SdrDragStat;
30 
31 class SAL_DLLPUBLIC_RTTI SdrDragEntry
32 {
33 private:
34  bool mbAddToTransparent : 1;
35 
36 protected:
37  // access for derived classes
38  void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; }
39 
40 public:
41  SdrDragEntry();
42  virtual ~SdrDragEntry();
43 
44  virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
45 
46  // data read access
47  bool getAddToTransparent() const { return mbAddToTransparent; }
48 };
49 
50 
52 {
53 private:
55 
56 public:
57  SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
58  virtual ~SdrDragEntryPolyPolygon() override;
59 
61 };
62 
63 
64 class SdrDragEntrySdrObject final : public SdrDragEntry
65 {
66 private:
69  bool const mbModify;
70 
71 public:
73  const SdrObject& rOriginal,
74  bool bModify);
75  virtual ~SdrDragEntrySdrObject() override;
76 
77  // #i54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
78  // added accessors to original and clone
79  void prepareCurrentState(SdrDragMethod& rDragMethod);
80  const SdrObject& getOriginal() const { return maOriginal; }
81  SdrObject* getClone() { return mxClone.get(); }
82 
84 };
85 
86 
88 {
89 private:
91 
92 public:
95  virtual ~SdrDragEntryPrimitive2DSequence() override;
96 
98 };
99 
100 
102 {
103 private:
104  std::vector< basegfx::B2DPoint > const maPositions;
105  bool const mbIsPointDrag;
106 
107 public:
108  SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
109  virtual ~SdrDragEntryPointGlueDrag() override;
110 
112 };
113 
114 
116 {
117 private:
118  std::vector< std::unique_ptr<SdrDragEntry> > maSdrDragEntries;
121 
122  bool mbMoveOnly : 1;
123  bool mbSolidDraggingActive : 1;
124  bool mbShiftPressed : 1;
125 
126 protected:
127  // access for derivated classes to maSdrDragEntries
128  void clearSdrDragEntries();
129  void addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew);
130  virtual void createSdrDragEntries();
131  virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal);
132 
133  // Helper to support inserting a new OverlayObject. It will do all
134  // necessary stuff involved with that:
135  // - add GridOffset for non-linear ViewToDevice transformation (calc)
136  // - add to OverlayManager
137  // - add to local OverlayObjectList - ownership change (!)
138  // It is centralized here (and protected) to avoid that new usages/
139  // implementations forget one of these needed steps.
140  void insertNewlyCreatedOverlayObjectForSdrDragMethod(
141  std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject,
142  const sdr::contact::ObjectContact& rObjectContact,
143  sdr::overlay::OverlayManager& rOverlayManager);
144 
145  // access for derivated classes to mrSdrDragView
146  SdrDragView& getSdrDragView() { return mrSdrDragView; }
147  const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
148 
149  // access for derivated classes for bools
150  void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
151  void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
152 
153  // internal helpers for creation of standard drag entries
154  void createSdrDragEntries_SolidDrag();
155  void createSdrDragEntries_PolygonDrag();
156  void createSdrDragEntries_PointDrag();
157  void createSdrDragEntries_GlueDrag();
158 
159  // old call forwarders to the SdrDragView
160  OUString ImpGetDescriptionStr(const char* pStrCacheID) const;
161  SdrHdl* GetDragHdl() const { return getSdrDragView().mpDragHdl; }
162  SdrHdlKind GetDragHdlKind() const { return getSdrDragView().meDragHdl; }
163  SdrDragStat& DragStat() { return getSdrDragView().maDragStat; }
164  const SdrDragStat& DragStat() const { return getSdrDragView().maDragStat; }
165  Point& Ref1() const { return mrSdrDragView.maRef1; }
166  Point& Ref2() const { return mrSdrDragView.maRef2; }
167  const SdrHdlList& GetHdlList() const { return getSdrDragView().GetHdlList(); }
168  void AddUndo(std::unique_ptr<SdrUndoAction> pUndo) { getSdrDragView().AddUndo(std::move(pUndo)); }
169  bool IsDragLimit() { return getSdrDragView().mbDragLimit; }
170  const tools::Rectangle& GetDragLimitRect() { return getSdrDragView().maDragLimit; }
171  const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
172  Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().mpMarkedPV); }
173  SdrSnap SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().mpMarkedPV); }
174  inline const tools::Rectangle& GetMarkedRect() const;
175  SdrPageView* GetDragPV() const;
176  SdrObject* GetDragObj() const;
177  bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
178  bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
179 
180  bool DoAddConnectorOverlays();
182 
183 public:
184 
185  void resetSdrDragEntries();
186  basegfx::B2DRange getCurrentRange() const;
187 
188  // #i58950# also moved constructor implementation to cxx
189  SdrDragMethod(SdrDragView& rNewView);
190 
191  // #i58950# virtual destructor was missing
192  virtual ~SdrDragMethod();
193 
194  void Show();
195  void Hide();
196  bool IsShiftPressed() const { return mbShiftPressed; }
197  void SetShiftPressed(bool bShiftPressed) { mbShiftPressed = bShiftPressed; }
198  virtual OUString GetSdrDragComment() const=0;
199  virtual bool BeginSdrDrag()=0;
200  virtual void MoveSdrDrag(const Point& rPnt)=0;
201  virtual bool EndSdrDrag(bool bCopy)=0;
202  virtual void CancelSdrDrag();
203  virtual PointerStyle GetSdrDragPointer() const=0;
204 
205  virtual void CreateOverlayGeometry(
206  sdr::overlay::OverlayManager& rOverlayManager,
207  const sdr::contact::ObjectContact& rObjectContact);
208  void destroyOverlayGeometry();
209 
210  virtual basegfx::B2DHomMatrix getCurrentTransformation();
211  virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
212  virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
213 
214  // data read access
215  bool getMoveOnly() const { return mbMoveOnly; }
216  bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
217 };
218 
220 {
224 }
225 
226 
227 // SdrDragMove
228 
230 {
231 private:
234  bool bXSnapped;
235  bool bYSnapped;
236 
237  void ImpCheckSnap(const Point& rPt);
238 
239 protected:
240  virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal) override;
241 
242 public:
243  SdrDragMove(SdrDragView& rNewView);
244 
245  virtual OUString GetSdrDragComment() const override;
246  virtual bool BeginSdrDrag() override;
247  virtual void MoveSdrDrag(const Point& rPnt) override;
248  virtual bool EndSdrDrag(bool bCopy) override;
249  virtual PointerStyle GetSdrDragPointer() const override;
250 
252  virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
253 };
254 
255 
256 // SdrDragResize
257 
259 {
260 protected:
263 
264 public:
265  SdrDragResize(SdrDragView& rNewView);
266 
267  virtual OUString GetSdrDragComment() const override;
268  virtual bool BeginSdrDrag() override;
269  virtual void MoveSdrDrag(const Point& rPnt) override;
270  virtual bool EndSdrDrag(bool bCopy) override;
271  virtual PointerStyle GetSdrDragPointer() const override;
272 
274  virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
275 };
276 
277 
278 // SdrDragObjOwn
279 
281 {
282 private:
283  // SdrDragObjOwn always works on a clone since it has no transformation
284  // mechanism to modify wireframe visualisations, but uses the
285  // SdrObject::applySpecialDrag() method to change a clone of the
286  // SdrObject
288 
289 protected:
290  virtual void createSdrDragEntries() override;
291 
292 public:
293  SdrDragObjOwn(SdrDragView& rNewView);
294  virtual ~SdrDragObjOwn() override;
295 
296  virtual OUString GetSdrDragComment() const override;
297  virtual bool BeginSdrDrag() override;
298  virtual void MoveSdrDrag(const Point& rPnt) override;
299  virtual bool EndSdrDrag(bool bCopy) override;
300  virtual PointerStyle GetSdrDragPointer() const override;
301 };
302 
303 #endif // INCLUDED_SVX_SVDDRGMT_HXX
304 
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SdrMarkList & GetMarkedObjectList()
Definition: svddrgmt.hxx:171
SdrObjectUniquePtr mxClone
Definition: svddrgmt.hxx:287
SdrObject * getClone()
Definition: svddrgmt.hxx:81
long nBestXSnap
Definition: svddrgmt.hxx:232
SdrHdl * GetDragHdl() const
Definition: svddrgmt.hxx:161
void prepareCurrentState(SdrDragMethod &rDragMethod)
Definition: svddrgmt.cxx:156
bool bYSnapped
Definition: svddrgmt.hxx:235
void SetShiftPressed(bool bShiftPressed)
Definition: svddrgmt.hxx:197
virtual ~SdrDragEntryPointGlueDrag() override
Definition: svddrgmt.cxx:221
SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint > &rPositions, bool bIsPointDrag)
Definition: svddrgmt.cxx:213
SdrHdlKind
Definition: svdhdl.hxx:52
long nBestYSnap
Definition: svddrgmt.hxx:233
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod)=0
const tools::Rectangle & GetMarkedGluePointsRect() const
Definition: svdmrkv1.cxx:542
virtual void createSdrDragEntries()
Definition: svddrgmt.cxx:303
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod) override
Definition: svddrgmt.cxx:225
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
SdrDragStat & DragStat()
Definition: svddrgmt.hxx:163
SdrHdlKind meDragHdl
Definition: svddrgv.hxx:46
const tools::Rectangle & GetMarkedObjRect() const
Definition: svdmrkv.cxx:2365
std::vector< std::unique_ptr< SdrDragEntry > > maSdrDragEntries
Definition: svddrgmt.hxx:118
Point & Ref2() const
Definition: svddrgmt.hxx:166
virtual basegfx::B2DHomMatrix getCurrentTransformation()
Definition: svddrgmt.cxx:667
bool getMoveOnly() const
Definition: svddrgmt.hxx:215
void setSolidDraggingActive(bool bNew)
Definition: svddrgmt.hxx:151
SdrDragEntrySdrObject(const SdrObject &rOriginal, bool bModify)
Definition: svddrgmt.cxx:141
virtual void MoveSdrDrag(const Point &rPnt)=0
Point GetSnapPos(const Point &rPt) const
Definition: svddrgmt.hxx:172
virtual bool BeginSdrDrag()=0
Point maRef1
Definition: svdmrkv.hxx:101
const tools::Rectangle & GetMarkedRect() const
Definition: svddrgmt.hxx:219
Point & Ref1() const
Definition: svddrgmt.hxx:165
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod) override
Definition: svddrgmt.cxx:202
Point maRef2
Definition: svdmrkv.hxx:102
virtual bool EndSdrDrag(bool bCopy)=0
bool IsDragLimit()
Definition: svddrgmt.hxx:169
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod) override
Definition: svddrgmt.cxx:173
SdrDragView & getSdrDragView()
Definition: svddrgmt.hxx:146
sdr::overlay::OverlayObjectList maOverlayObjectList
Definition: svddrgmt.hxx:119
virtual PointerStyle GetSdrDragPointer() const =0
void setMoveOnly(bool bNew)
Definition: svddrgmt.hxx:150
Fraction aXFact
Definition: svddrgmt.hxx:261
const SdrDragStat & DragStat() const
Definition: svddrgmt.hxx:164
SdrSnap SnapPos(Point &rPt) const
Definition: svddrgmt.hxx:173
SdrSnap
Definition:
Definition: svdsnpv.hxx:71
virtual OUString GetSdrDragComment() const =0
bool bXSnapped
Definition: svddrgmt.hxx:234
SdrObjectUniquePtr mxClone
Definition: svddrgmt.hxx:68
bool IsDraggingGluePoints() const
Definition: svddrgmt.hxx:178
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget)
Definition: svddrgmt.cxx:590
bool getAddToTransparent() const
Definition: svddrgmt.hxx:47
bool getSolidDraggingActive() const
Definition: svddrgmt.hxx:216
bool IsShiftPressed() const
Definition: svddrgmt.hxx:196
Abstract DrawObject.
Definition: svdobj.hxx:312
const tools::Rectangle & GetDragLimitRect()
Definition: svddrgmt.hxx:170
void setAddToTransparent(bool bNew)
Definition: svddrgmt.hxx:38
SdrHdlKind GetDragHdlKind() const
Definition: svddrgmt.hxx:162
drawinglayer::primitive2d::Primitive2DContainer const maPrimitive2DSequence
Definition: svddrgmt.hxx:90
virtual void createSdrDragEntryForSdrObject(const SdrObject &rOriginal)
Definition: svddrgmt.cxx:329
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svddrgmt.hxx:168
const SdrObject & maOriginal
Definition: svddrgmt.hxx:67
bool const mbModify
Definition: svddrgmt.hxx:69
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
Fraction aYFact
Definition: svddrgmt.hxx:262
PointerStyle
const SdrDragView & getSdrDragView() const
Definition: svddrgmt.hxx:147
basegfx::B2DPolyPolygon const maOriginalPolyPolygon
Definition: svddrgmt.hxx:54
const SdrObject & getOriginal() const
Definition: svddrgmt.hxx:80
std::vector< basegfx::B2DPoint > const maPositions
Definition: svddrgmt.hxx:104
const tools::Rectangle & GetMarkedPointsRect() const
Definition: svdmrkv1.cxx:239
virtual ~SdrDragEntrySdrObject() override
Definition: svddrgmt.cxx:152
SdrDragEntryPrimitive2DSequence(const drawinglayer::primitive2d::Primitive2DContainer &rSequence)
Definition: svddrgmt.cxx:189
virtual ~SdrDragEntryPrimitive2DSequence() override
Definition: svddrgmt.cxx:198
SdrDragView & mrSdrDragView
Definition: svddrgmt.hxx:120
bool IsDraggingPoints() const
Definition: svddrgmt.hxx:177
const SdrHdlList & GetHdlList() const
Definition: svddrgmt.hxx:167