Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVDDRGMT_HXX
30 : : #define _SVDDRGMT_HXX
31 : :
32 : : #include <svx/svddrgv.hxx>
33 : : #include "svx/svxdllapi.h"
34 : : #include <svx/sdr/contact/objectcontact.hxx>
35 : :
36 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
37 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
38 : : //
39 : : // @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@@@@ @@@@@@ @@ @@ @@@@ @@@@@ @@@@
40 : : // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
41 : : // @@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@
42 : : // @@ @@ @@@@@ @@@@@@ @@ @@@ @@@@@@@ @@@@ @@ @@@@@@ @@ @@ @@ @@ @@@@
43 : : // @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
44 : : // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
45 : : // @@@@@ @@ @@ @@ @@ @@@@@ @@ @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
46 : : //
47 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
48 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
49 : :
50 : : class SdrDragView;
51 : : class SdrDragStat;
52 : :
53 : : //////////////////////////////////////////////////////////////////////////////
54 : :
55 : : class SVX_DLLPUBLIC SdrDragEntry
56 : : {
57 : : private:
58 : : // bitfield
59 : : unsigned mbAddToTransparent : 1;
60 : :
61 : : protected:
62 : : // access for derived classes
63 : : void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; }
64 : :
65 : : public:
66 : : SdrDragEntry();
67 : : virtual ~SdrDragEntry();
68 : :
69 : : virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
70 : :
71 : : // data read access
72 : : bool getAddToTransparent() const { return mbAddToTransparent; }
73 : : };
74 : :
75 : : //////////////////////////////////////////////////////////////////////////////
76 : :
77 : : class SVX_DLLPUBLIC SdrDragEntryPolyPolygon : public SdrDragEntry
78 : : {
79 : : private:
80 : : basegfx::B2DPolyPolygon maOriginalPolyPolygon;
81 : :
82 : : public:
83 : : SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
84 : : virtual ~SdrDragEntryPolyPolygon();
85 : :
86 : : virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
87 : : };
88 : :
89 : : //////////////////////////////////////////////////////////////////////////////
90 : :
91 : : class SdrDragEntrySdrObject : public SdrDragEntry
92 : : {
93 : : private:
94 : : const SdrObject& maOriginal;
95 : : SdrObject* mpClone;
96 : : sdr::contact::ObjectContact& mrObjectContact;
97 : : bool mbModify;
98 : :
99 : : public:
100 : : SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
101 : : virtual ~SdrDragEntrySdrObject();
102 : :
103 : : virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
104 : : };
105 : :
106 : : //////////////////////////////////////////////////////////////////////////////
107 : :
108 : : class SdrDragEntryPrimitive2DSequence : public SdrDragEntry
109 : : {
110 : : private:
111 : : drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence;
112 : :
113 : : public:
114 : : SdrDragEntryPrimitive2DSequence(
115 : : const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
116 : : bool bAddToTransparent);
117 : : virtual ~SdrDragEntryPrimitive2DSequence();
118 : :
119 : : virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
120 : : };
121 : :
122 : : //////////////////////////////////////////////////////////////////////////////
123 : :
124 : : class SdrDragEntryPointGlueDrag : public SdrDragEntry
125 : : {
126 : : private:
127 : : std::vector< basegfx::B2DPoint > maPositions;
128 : : bool mbIsPointDrag;
129 : :
130 : : public:
131 : : SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
132 : : virtual ~SdrDragEntryPointGlueDrag();
133 : :
134 : : virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
135 : : };
136 : :
137 : : //////////////////////////////////////////////////////////////////////////////
138 : :
139 : : class SVX_DLLPUBLIC SdrDragMethod
140 : : {
141 : : private:
142 : : std::vector< SdrDragEntry* > maSdrDragEntries;
143 : : sdr::overlay::OverlayObjectList maOverlayObjectList;
144 : : SdrDragView& mrSdrDragView;
145 : :
146 : : // bitfield
147 : : unsigned mbMoveOnly : 1;
148 : : unsigned mbSolidDraggingActive : 1;
149 : :
150 : : protected:
151 : : // access for derivated classes to maSdrDragEntries
152 : : void clearSdrDragEntries() { for(sal_uInt32 a(0); a < maSdrDragEntries.size(); a++) { delete maSdrDragEntries[a]; } maSdrDragEntries.clear(); }
153 [ # # ]: 0 : void addSdrDragEntry(SdrDragEntry* pNew) { if(pNew) { maSdrDragEntries.push_back(pNew); }}
154 : : virtual void createSdrDragEntries();
155 : : virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
156 : :
157 : : // access for derivated classes to maOverlayObjectList
158 : : void clearOverlayObjectList() { maOverlayObjectList.clear(); }
159 : 0 : void addToOverlayObjectList(sdr::overlay::OverlayObject& rNew) { maOverlayObjectList.append(rNew); }
160 : : basegfx::B2DRange getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList.getBaseRange(); }
161 : :
162 : : // access for derivated classes to mrSdrDragView
163 : 0 : SdrDragView& getSdrDragView() { return mrSdrDragView; }
164 : 0 : const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
165 : :
166 : : // access for derivated classes for bools
167 : 0 : void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
168 : : void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
169 : :
170 : : // internal helpers for creation of standard drag entries
171 : : void createSdrDragEntries_SolidDrag();
172 : : void createSdrDragEntries_PolygonDrag();
173 : : void createSdrDragEntries_PointDrag();
174 : : void createSdrDragEntries_GlueDrag();
175 : :
176 : : // old call forwarders to the SdrDragView
177 : : void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, String& rStr, sal_uInt16 nVal=0) const;
178 : 0 : SdrHdl* GetDragHdl() const { return getSdrDragView().pDragHdl; }
179 : : SdrHdlKind GetDragHdlKind() const { return getSdrDragView().eDragHdl; }
180 : 0 : SdrDragStat& DragStat() { return getSdrDragView().aDragStat; }
181 : : const SdrDragStat& DragStat() const { return getSdrDragView().aDragStat; }
182 : : Point& Ref1() const { return mrSdrDragView.aRef1; }
183 : : Point& Ref2() const { return mrSdrDragView.aRef2; }
184 : : const SdrHdlList& GetHdlList() const { return getSdrDragView().aHdl; }
185 : : void AddUndo(SdrUndoAction* pUndo) { getSdrDragView().AddUndo(pUndo); }
186 : : bool IsDragLimit() { return getSdrDragView().bDragLimit; }
187 : : const Rectangle& GetDragLimitRect() { return getSdrDragView().aDragLimit; }
188 : : const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
189 : : Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); }
190 : : sal_uInt16 SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
191 : : inline const Rectangle& GetMarkedRect() const;
192 : : SdrPageView* GetDragPV() const;
193 : : SdrObject* GetDragObj() const;
194 : : OutputDevice* GetDragWin() const { return getSdrDragView().pDragWin; }
195 : 0 : bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
196 : 0 : bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
197 : :
198 : : bool DoAddConnectorOverlays();
199 : : drawinglayer::primitive2d::Primitive2DSequence AddConnectorOverlays();
200 : :
201 : : public:
202 : : TYPEINFO();
203 : :
204 : : void resetSdrDragEntries();
205 : : basegfx::B2DRange getCurrentRange() const;
206 : :
207 : : // #i58950# also moved constructor implementation to cxx
208 : : SdrDragMethod(SdrDragView& rNewView);
209 : :
210 : : // #i58950# virtual destructor was missing
211 : : virtual ~SdrDragMethod();
212 : :
213 : : void Show();
214 : : void Hide();
215 : : virtual void TakeSdrDragComment(String& rStr) const=0;
216 : : virtual bool BeginSdrDrag()=0;
217 : : virtual void MoveSdrDrag(const Point& rPnt)=0;
218 : : virtual bool EndSdrDrag(bool bCopy)=0;
219 : : virtual void CancelSdrDrag();
220 : : virtual Pointer GetSdrDragPointer() const=0;
221 : :
222 : : virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager);
223 : : void destroyOverlayGeometry();
224 : :
225 : : virtual basegfx::B2DHomMatrix getCurrentTransformation();
226 : : virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
227 : : virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
228 : :
229 : : // data read access
230 : 0 : bool getMoveOnly() const { return mbMoveOnly; }
231 : : bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
232 : : };
233 : :
234 : : inline const Rectangle& SdrDragMethod::GetMarkedRect() const
235 : : {
236 : : return getSdrDragView().eDragHdl==HDL_POLY ? getSdrDragView().GetMarkedPointsRect() :
237 : : getSdrDragView().eDragHdl==HDL_GLUE ? getSdrDragView().GetMarkedGluePointsRect() :
238 : : getSdrDragView().GetMarkedObjRect();
239 : : }
240 : :
241 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
242 : : // SdrDragMove
243 : :
244 [ # # ]: 0 : class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod
245 : : {
246 : : private:
247 : : long nBestXSnap;
248 : : long nBestYSnap;
249 : : bool bXSnapped;
250 : : bool bYSnapped;
251 : :
252 : : void ImpCheckSnap(const Point& rPt);
253 : :
254 : : protected:
255 : : virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
256 : :
257 : : public:
258 : : TYPEINFO();
259 : : SdrDragMove(SdrDragView& rNewView);
260 : :
261 : : virtual void TakeSdrDragComment(String& rStr) const;
262 : : virtual bool BeginSdrDrag();
263 : : virtual void MoveSdrDrag(const Point& rPnt);
264 : : virtual bool EndSdrDrag(bool bCopy);
265 : : virtual Pointer GetSdrDragPointer() const;
266 : :
267 : : virtual basegfx::B2DHomMatrix getCurrentTransformation();
268 : : virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
269 : : };
270 : :
271 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
272 : : // SdrDragResize
273 : :
274 [ # # ]: 0 : class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod
275 : : {
276 : : protected:
277 : : Fraction aXFact;
278 : : Fraction aYFact;
279 : :
280 : : public:
281 : : TYPEINFO();
282 : : SdrDragResize(SdrDragView& rNewView);
283 : :
284 : : virtual void TakeSdrDragComment(String& rStr) const;
285 : : virtual bool BeginSdrDrag();
286 : : virtual void MoveSdrDrag(const Point& rPnt);
287 : : virtual bool EndSdrDrag(bool bCopy);
288 : : virtual Pointer GetSdrDragPointer() const;
289 : :
290 : : virtual basegfx::B2DHomMatrix getCurrentTransformation();
291 : : virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
292 : : };
293 : :
294 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
295 : : // SdrDragObjOwn
296 : :
297 : : class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
298 : : {
299 : : private:
300 : : // SdrDragObjOwn always works on a clone since it has no transformation
301 : : // mechanism to modify wireframe visualisations, but uses the
302 : : // SdrObject::applySpecialDrag() method to change a clone of the
303 : : // SdrObject
304 : : SdrObject* mpClone;
305 : :
306 : : protected:
307 : : virtual void createSdrDragEntries();
308 : :
309 : : public:
310 : : TYPEINFO();
311 : : SdrDragObjOwn(SdrDragView& rNewView);
312 : : virtual ~SdrDragObjOwn();
313 : :
314 : : virtual void TakeSdrDragComment(String& rStr) const;
315 : : virtual bool BeginSdrDrag();
316 : : virtual void MoveSdrDrag(const Point& rPnt);
317 : : virtual bool EndSdrDrag(bool bCopy);
318 : : virtual Pointer GetSdrDragPointer() const;
319 : : };
320 : :
321 : : #endif //_SVDDRGMT_HXX
322 : :
323 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|