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