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