1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _SVDDRGMT_HXX
25 #define _SVDDRGMT_HXX
26
27 #include <svx/svddrgv.hxx>
28 #include "svx/svxdllapi.h"
29 #include <svx/sdr/contact/objectcontact.hxx>
30
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
32 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 //
34 // @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@@@@ @@@@@@ @@ @@ @@@@ @@@@@ @@@@
35 // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
36 // @@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@
37 // @@ @@ @@@@@ @@@@@@ @@ @@@ @@@@@@@ @@@@ @@ @@@@@@ @@ @@ @@ @@ @@@@
38 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
39 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
40 // @@@@@ @@ @@ @@ @@ @@@@@ @@ @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
41 //
42 ////////////////////////////////////////////////////////////////////////////////////////////////////
43 ////////////////////////////////////////////////////////////////////////////////////////////////////
44
45 class SdrDragView;
46 class SdrDragStat;
47
48 //////////////////////////////////////////////////////////////////////////////
49
50 class SdrDragEntry
51 {
52 private:
53 // bitfield
54 unsigned mbAddToTransparent : 1;
55
56 protected:
57 // access for derived classes
setAddToTransparent(bool bNew)58 void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; }
59
60 public:
61 SdrDragEntry();
62 virtual ~SdrDragEntry();
63
64 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
65
66 // data read access
getAddToTransparent() const67 bool getAddToTransparent() const { return mbAddToTransparent; }
68 };
69
70 //////////////////////////////////////////////////////////////////////////////
71
72 class SVX_DLLPUBLIC SdrDragEntryPolyPolygon : public SdrDragEntry
73 {
74 private:
75 basegfx::B2DPolyPolygon maOriginalPolyPolygon;
76
77 public:
78 SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
79 virtual ~SdrDragEntryPolyPolygon();
80
81 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
82 };
83
84 //////////////////////////////////////////////////////////////////////////////
85
86 class SdrDragEntrySdrObject : public SdrDragEntry
87 {
88 private:
89 const SdrObject& maOriginal;
90 SdrObject* mpClone;
91 sdr::contact::ObjectContact& mrObjectContact;
92 bool mbModify;
93
94 public:
95 SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
96 virtual ~SdrDragEntrySdrObject();
97
98 // #54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
99 // added accessors to original and clone
100 void prepareCurrentState(SdrDragMethod& rDragMethod);
getOriginal() const101 const SdrObject& getOriginal() const { return maOriginal; }
getClone()102 SdrObject* getClone() { return mpClone; }
103
104 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
105 };
106
107 //////////////////////////////////////////////////////////////////////////////
108
109 class SdrDragEntryPrimitive2DSequence : public SdrDragEntry
110 {
111 private:
112 drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence;
113
114 public:
115 SdrDragEntryPrimitive2DSequence(
116 const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
117 bool bAddToTransparent);
118 virtual ~SdrDragEntryPrimitive2DSequence();
119
120 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
121 };
122
123 //////////////////////////////////////////////////////////////////////////////
124
125 class SdrDragEntryPointGlueDrag : public SdrDragEntry
126 {
127 private:
128 std::vector< basegfx::B2DPoint > maPositions;
129 bool mbIsPointDrag;
130
131 public:
132 SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
133 virtual ~SdrDragEntryPointGlueDrag();
134
135 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
136 };
137
138 //////////////////////////////////////////////////////////////////////////////
139
140 class SVX_DLLPUBLIC SdrDragMethod
141 {
142 private:
143 std::vector< SdrDragEntry* > maSdrDragEntries;
144 sdr::overlay::OverlayObjectList maOverlayObjectList;
145 SdrDragView& mrSdrDragView;
146
147 // bitfield
148 unsigned mbMoveOnly : 1;
149 unsigned mbSolidDraggingActive : 1;
150
151 protected:
152 // access for derivated classes to maSdrDragEntries
153 void clearSdrDragEntries();
154 void addSdrDragEntry(SdrDragEntry* pNew);
155 virtual void createSdrDragEntries();
156 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
157
158 // access for derivated classes to maOverlayObjectList
clearOverlayObjectList()159 void clearOverlayObjectList() { maOverlayObjectList.clear(); }
addToOverlayObjectList(sdr::overlay::OverlayObject & rNew)160 void addToOverlayObjectList(sdr::overlay::OverlayObject& rNew) { maOverlayObjectList.append(rNew); }
getB2DRangeFromOverlayObjectList() const161 basegfx::B2DRange getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList.getBaseRange(); }
162
163 // access for derivated classes to mrSdrDragView
getSdrDragView()164 SdrDragView& getSdrDragView() { return mrSdrDragView; }
getSdrDragView() const165 const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
166
167 // access for derivated classes for bools
setMoveOnly(bool bNew)168 void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
setSolidDraggingActive(bool bNew)169 void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
170
171 // internal helpers for creation of standard drag entries
172 void createSdrDragEntries_SolidDrag();
173 void createSdrDragEntries_PolygonDrag();
174 void createSdrDragEntries_PointDrag();
175 void createSdrDragEntries_GlueDrag();
176
177 // old call forwarders to the SdrDragView
178 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, String& rStr, sal_uInt16 nVal=0) const;
GetDragHdl() const179 SdrHdl* GetDragHdl() const { return getSdrDragView().pDragHdl; }
GetDragHdlKind() const180 SdrHdlKind GetDragHdlKind() const { return getSdrDragView().eDragHdl; }
DragStat()181 SdrDragStat& DragStat() { return getSdrDragView().aDragStat; }
DragStat() const182 const SdrDragStat& DragStat() const { return getSdrDragView().aDragStat; }
Ref1() const183 Point& Ref1() const { return mrSdrDragView.aRef1; }
Ref2() const184 Point& Ref2() const { return mrSdrDragView.aRef2; }
GetHdlList() const185 const SdrHdlList& GetHdlList() const { return getSdrDragView().aHdl; }
AddUndo(SdrUndoAction * pUndo)186 void AddUndo(SdrUndoAction* pUndo) { getSdrDragView().AddUndo(pUndo); }
IsDragLimit()187 bool IsDragLimit() { return getSdrDragView().bDragLimit; }
GetDragLimitRect()188 const Rectangle& GetDragLimitRect() { return getSdrDragView().aDragLimit; }
GetMarkedObjectList()189 const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
GetSnapPos(const Point & rPt) const190 Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); }
SnapPos(Point & rPt) const191 sal_uInt16 SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
192 inline const Rectangle& GetMarkedRect() const;
193 SdrPageView* GetDragPV() const;
194 SdrObject* GetDragObj() const;
GetDragWin() const195 OutputDevice* GetDragWin() const { return getSdrDragView().pDragWin; }
IsDraggingPoints() const196 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
IsDraggingGluePoints() const197 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
198
199 bool DoAddConnectorOverlays();
200 drawinglayer::primitive2d::Primitive2DSequence AddConnectorOverlays();
201
202 public:
203 TYPEINFO();
204
205 void resetSdrDragEntries();
206 basegfx::B2DRange getCurrentRange() const;
207
208 // #i58950# also moved constructor implementation to cxx
209 SdrDragMethod(SdrDragView& rNewView);
210
211 // #i58950# virtual destructor was missing
212 virtual ~SdrDragMethod();
213
214 void Show();
215 void Hide();
216 virtual void TakeSdrDragComment(String& rStr) const=0;
217 virtual bool BeginSdrDrag()=0;
218 virtual void MoveSdrDrag(const Point& rPnt)=0;
219 virtual bool EndSdrDrag(bool bCopy)=0;
220 virtual void CancelSdrDrag();
221 virtual Pointer GetSdrDragPointer() const=0;
222
223 virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager);
224 void destroyOverlayGeometry();
225
226 virtual basegfx::B2DHomMatrix getCurrentTransformation();
227 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
228 virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
229
230 // data read access
getMoveOnly() const231 bool getMoveOnly() const { return mbMoveOnly; }
getSolidDraggingActive() const232 bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
233 };
234
GetMarkedRect() const235 inline const Rectangle& SdrDragMethod::GetMarkedRect() const
236 {
237 return getSdrDragView().eDragHdl==HDL_POLY ? getSdrDragView().GetMarkedPointsRect() :
238 getSdrDragView().eDragHdl==HDL_GLUE ? getSdrDragView().GetMarkedGluePointsRect() :
239 getSdrDragView().GetMarkedObjRect();
240 }
241
242 ////////////////////////////////////////////////////////////////////////////////////////////////////
243 // SdrDragMove
244
245 class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod
246 {
247 private:
248 long nBestXSnap;
249 long nBestYSnap;
250 bool bXSnapped;
251 bool bYSnapped;
252
253 void ImpCheckSnap(const Point& rPt);
254
255 protected:
256 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
257
258 public:
259 TYPEINFO();
260 SdrDragMove(SdrDragView& rNewView);
261
262 virtual void TakeSdrDragComment(String& rStr) const;
263 virtual bool BeginSdrDrag();
264 virtual void MoveSdrDrag(const Point& rPnt);
265 virtual bool EndSdrDrag(bool bCopy);
266 virtual Pointer GetSdrDragPointer() const;
267
268 virtual basegfx::B2DHomMatrix getCurrentTransformation();
269 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
270 };
271
272 ////////////////////////////////////////////////////////////////////////////////////////////////////
273 // SdrDragResize
274
275 class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod
276 {
277 protected:
278 Fraction aXFact;
279 Fraction aYFact;
280
281 public:
282 TYPEINFO();
283 SdrDragResize(SdrDragView& rNewView);
284
285 virtual void TakeSdrDragComment(String& rStr) const;
286 virtual bool BeginSdrDrag();
287 virtual void MoveSdrDrag(const Point& rPnt);
288 virtual bool EndSdrDrag(bool bCopy);
289 virtual Pointer GetSdrDragPointer() const;
290
291 virtual basegfx::B2DHomMatrix getCurrentTransformation();
292 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
293 };
294
295 ////////////////////////////////////////////////////////////////////////////////////////////////////
296 // SdrDragObjOwn
297
298 class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
299 {
300 private:
301 // SdrDragObjOwn always works on a clone since it has no transformation
302 // mechanism to modify wireframe visualisations, but uses the
303 // SdrObject::applySpecialDrag() method to change a clone of the
304 // SdrObject
305 SdrObject* mpClone;
306
307 protected:
308 virtual void createSdrDragEntries();
309
310 public:
311 TYPEINFO();
312 SdrDragObjOwn(SdrDragView& rNewView);
313 virtual ~SdrDragObjOwn();
314
315 virtual void TakeSdrDragComment(String& rStr) const;
316 virtual bool BeginSdrDrag();
317 virtual void MoveSdrDrag(const Point& rPnt);
318 virtual bool EndSdrDrag(bool bCopy);
319 virtual Pointer GetSdrDragPointer() const;
320 };
321
322
323 ////////////////////////////////////////////////////////////////////////////////////////////////////
324 #endif //_SVDDRGMT_HXX
325
326 // eof
327