bump product version to 4.2.0.1
[LibreOffice.git] / include / svx / svddrgmt.hxx
blobe5f9e0d1fbfe3cb4aeb79ee50c0013009f3b680f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDDRGMT_HXX
21 #define INCLUDED_SVX_SVDDRGMT_HXX
23 #include <svx/svddrgv.hxx>
24 #include <svx/svxdllapi.h>
25 #include <svx/sdr/contact/objectcontact.hxx>
27 class SdrDragView;
28 class SdrDragStat;
30 class SVX_DLLPUBLIC SdrDragEntry
32 private:
33 // bitfield
34 unsigned mbAddToTransparent : 1;
36 protected:
37 // access for derived classes
38 void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; }
40 public:
41 SdrDragEntry();
42 virtual ~SdrDragEntry();
44 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
46 // data read access
47 bool getAddToTransparent() const { return mbAddToTransparent; }
50 //////////////////////////////////////////////////////////////////////////////
52 class SVX_DLLPUBLIC SdrDragEntryPolyPolygon : public SdrDragEntry
54 private:
55 basegfx::B2DPolyPolygon maOriginalPolyPolygon;
57 public:
58 SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
59 virtual ~SdrDragEntryPolyPolygon();
61 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
64 //////////////////////////////////////////////////////////////////////////////
66 class SdrDragEntrySdrObject : public SdrDragEntry
68 private:
69 const SdrObject& maOriginal;
70 SdrObject* mpClone;
71 sdr::contact::ObjectContact& mrObjectContact;
72 bool mbModify;
74 public:
75 SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
76 virtual ~SdrDragEntrySdrObject();
78 // #i54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
79 // added accessors to original and clone
80 void prepareCurrentState(SdrDragMethod& rDragMethod);
81 const SdrObject& getOriginal() const { return maOriginal; }
82 SdrObject* getClone() { return mpClone; }
84 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
87 //////////////////////////////////////////////////////////////////////////////
89 class SdrDragEntryPrimitive2DSequence : public SdrDragEntry
91 private:
92 drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence;
94 public:
95 SdrDragEntryPrimitive2DSequence(
96 const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
97 bool bAddToTransparent);
98 virtual ~SdrDragEntryPrimitive2DSequence();
100 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
103 //////////////////////////////////////////////////////////////////////////////
105 class SdrDragEntryPointGlueDrag : public SdrDragEntry
107 private:
108 std::vector< basegfx::B2DPoint > maPositions;
109 bool mbIsPointDrag;
111 public:
112 SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
113 virtual ~SdrDragEntryPointGlueDrag();
115 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
118 //////////////////////////////////////////////////////////////////////////////
120 class SVX_DLLPUBLIC SdrDragMethod
122 private:
123 std::vector< SdrDragEntry* > maSdrDragEntries;
124 sdr::overlay::OverlayObjectList maOverlayObjectList;
125 SdrDragView& mrSdrDragView;
127 // bitfield
128 unsigned mbMoveOnly : 1;
129 unsigned mbSolidDraggingActive : 1;
131 protected:
132 // access for derivated classes to maSdrDragEntries
133 void clearSdrDragEntries();
134 void addSdrDragEntry(SdrDragEntry* pNew);
135 virtual void createSdrDragEntries();
136 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
138 // access for derivated classes to maOverlayObjectList
139 void clearOverlayObjectList() { maOverlayObjectList.clear(); }
140 void addToOverlayObjectList(sdr::overlay::OverlayObject& rNew) { maOverlayObjectList.append(rNew); }
141 basegfx::B2DRange getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList.getBaseRange(); }
143 // access for derivated classes to mrSdrDragView
144 SdrDragView& getSdrDragView() { return mrSdrDragView; }
145 const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
147 // access for derivated classes for bools
148 void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
149 void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
151 // internal helpers for creation of standard drag entries
152 void createSdrDragEntries_SolidDrag();
153 void createSdrDragEntries_PolygonDrag();
154 void createSdrDragEntries_PointDrag();
155 void createSdrDragEntries_GlueDrag();
157 // old call forwarders to the SdrDragView
158 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, sal_uInt16 nVal=0) const;
159 SdrHdl* GetDragHdl() const { return getSdrDragView().pDragHdl; }
160 SdrHdlKind GetDragHdlKind() const { return getSdrDragView().eDragHdl; }
161 SdrDragStat& DragStat() { return getSdrDragView().aDragStat; }
162 const SdrDragStat& DragStat() const { return getSdrDragView().aDragStat; }
163 Point& Ref1() const { return mrSdrDragView.aRef1; }
164 Point& Ref2() const { return mrSdrDragView.aRef2; }
165 const SdrHdlList& GetHdlList() const { return getSdrDragView().aHdl; }
166 void AddUndo(SdrUndoAction* pUndo) { getSdrDragView().AddUndo(pUndo); }
167 bool IsDragLimit() { return getSdrDragView().bDragLimit; }
168 const Rectangle& GetDragLimitRect() { return getSdrDragView().aDragLimit; }
169 const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
170 Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); }
171 sal_uInt16 SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
172 inline const Rectangle& GetMarkedRect() const;
173 SdrPageView* GetDragPV() const;
174 SdrObject* GetDragObj() const;
175 OutputDevice* GetDragWin() const { return getSdrDragView().pDragWin; }
176 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
177 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
179 bool DoAddConnectorOverlays();
180 drawinglayer::primitive2d::Primitive2DSequence AddConnectorOverlays();
182 public:
183 TYPEINFO();
185 void resetSdrDragEntries();
186 basegfx::B2DRange getCurrentRange() const;
188 // #i58950# also moved constructor implementation to cxx
189 SdrDragMethod(SdrDragView& rNewView);
191 // #i58950# virtual destructor was missing
192 virtual ~SdrDragMethod();
194 void Show();
195 void Hide();
196 virtual void TakeSdrDragComment(OUString& rStr) 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 Pointer GetSdrDragPointer() const=0;
203 virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager);
204 void destroyOverlayGeometry();
206 virtual basegfx::B2DHomMatrix getCurrentTransformation();
207 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
208 virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
210 // data read access
211 bool getMoveOnly() const { return mbMoveOnly; }
212 bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
215 inline const Rectangle& SdrDragMethod::GetMarkedRect() const
217 return getSdrDragView().eDragHdl==HDL_POLY ? getSdrDragView().GetMarkedPointsRect() :
218 getSdrDragView().eDragHdl==HDL_GLUE ? getSdrDragView().GetMarkedGluePointsRect() :
219 getSdrDragView().GetMarkedObjRect();
222 ////////////////////////////////////////////////////////////////////////////////////////////////////
223 // SdrDragMove
225 class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod
227 private:
228 long nBestXSnap;
229 long nBestYSnap;
230 bool bXSnapped;
231 bool bYSnapped;
233 void ImpCheckSnap(const Point& rPt);
235 protected:
236 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
238 public:
239 TYPEINFO();
240 SdrDragMove(SdrDragView& rNewView);
242 virtual void TakeSdrDragComment(OUString& rStr) const;
243 virtual bool BeginSdrDrag();
244 virtual void MoveSdrDrag(const Point& rPnt);
245 virtual bool EndSdrDrag(bool bCopy);
246 virtual Pointer GetSdrDragPointer() const;
248 virtual basegfx::B2DHomMatrix getCurrentTransformation();
249 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
252 ////////////////////////////////////////////////////////////////////////////////////////////////////
253 // SdrDragResize
255 class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod
257 protected:
258 Fraction aXFact;
259 Fraction aYFact;
261 public:
262 TYPEINFO();
263 SdrDragResize(SdrDragView& rNewView);
265 virtual void TakeSdrDragComment(OUString& rStr) const;
266 virtual bool BeginSdrDrag();
267 virtual void MoveSdrDrag(const Point& rPnt);
268 virtual bool EndSdrDrag(bool bCopy);
269 virtual Pointer GetSdrDragPointer() const;
271 virtual basegfx::B2DHomMatrix getCurrentTransformation();
272 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
275 ////////////////////////////////////////////////////////////////////////////////////////////////////
276 // SdrDragObjOwn
278 class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
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 SdrObject* mpClone;
287 protected:
288 virtual void createSdrDragEntries();
290 public:
291 TYPEINFO();
292 SdrDragObjOwn(SdrDragView& rNewView);
293 virtual ~SdrDragObjOwn();
295 virtual void TakeSdrDragComment(OUString& rStr) const;
296 virtual bool BeginSdrDrag();
297 virtual void MoveSdrDrag(const Point& rPnt);
298 virtual bool EndSdrDrag(bool bCopy);
299 virtual Pointer GetSdrDragPointer() const;
302 #endif // INCLUDED_SVX_SVDDRGMT_HXX
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */