bump product version to 4.1.6.2
[LibreOffice.git] / include / svx / svddrgmt.hxx
blob3fc7fbb3816885e10f9bef42a6a4e319ed9a2970
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 _SVDDRGMT_HXX
21 #define _SVDDRGMT_HXX
23 #include <svx/svddrgv.hxx>
24 #include "svx/svxdllapi.h"
25 #include <svx/sdr/contact/objectcontact.hxx>
27 ////////////////////////////////////////////////////////////////////////////////////////////////////
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
30 // @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@@@@ @@@@@@ @@ @@ @@@@ @@@@@ @@@@
31 // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
32 // @@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@
33 // @@ @@ @@@@@ @@@@@@ @@ @@@ @@@@@@@ @@@@ @@ @@@@@@ @@ @@ @@ @@ @@@@
34 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
35 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
36 // @@@@@ @@ @@ @@ @@ @@@@@ @@ @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
38 ////////////////////////////////////////////////////////////////////////////////////////////////////
39 ////////////////////////////////////////////////////////////////////////////////////////////////////
41 class SdrDragView;
42 class SdrDragStat;
44 //////////////////////////////////////////////////////////////////////////////
46 class SVX_DLLPUBLIC SdrDragEntry
48 private:
49 // bitfield
50 unsigned mbAddToTransparent : 1;
52 protected:
53 // access for derived classes
54 void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; }
56 public:
57 SdrDragEntry();
58 virtual ~SdrDragEntry();
60 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
62 // data read access
63 bool getAddToTransparent() const { return mbAddToTransparent; }
66 //////////////////////////////////////////////////////////////////////////////
68 class SVX_DLLPUBLIC SdrDragEntryPolyPolygon : public SdrDragEntry
70 private:
71 basegfx::B2DPolyPolygon maOriginalPolyPolygon;
73 public:
74 SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
75 virtual ~SdrDragEntryPolyPolygon();
77 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
80 //////////////////////////////////////////////////////////////////////////////
82 class SdrDragEntrySdrObject : public SdrDragEntry
84 private:
85 const SdrObject& maOriginal;
86 SdrObject* mpClone;
87 sdr::contact::ObjectContact& mrObjectContact;
88 bool mbModify;
90 public:
91 SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
92 virtual ~SdrDragEntrySdrObject();
94 // #i54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
95 // added accessors to original and clone
96 void prepareCurrentState(SdrDragMethod& rDragMethod);
97 const SdrObject& getOriginal() const { return maOriginal; }
98 SdrObject* getClone() { return mpClone; }
100 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
103 //////////////////////////////////////////////////////////////////////////////
105 class SdrDragEntryPrimitive2DSequence : public SdrDragEntry
107 private:
108 drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence;
110 public:
111 SdrDragEntryPrimitive2DSequence(
112 const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
113 bool bAddToTransparent);
114 virtual ~SdrDragEntryPrimitive2DSequence();
116 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
119 //////////////////////////////////////////////////////////////////////////////
121 class SdrDragEntryPointGlueDrag : public SdrDragEntry
123 private:
124 std::vector< basegfx::B2DPoint > maPositions;
125 bool mbIsPointDrag;
127 public:
128 SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
129 virtual ~SdrDragEntryPointGlueDrag();
131 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod);
134 //////////////////////////////////////////////////////////////////////////////
136 class SVX_DLLPUBLIC SdrDragMethod
138 private:
139 std::vector< SdrDragEntry* > maSdrDragEntries;
140 sdr::overlay::OverlayObjectList maOverlayObjectList;
141 SdrDragView& mrSdrDragView;
143 // bitfield
144 unsigned mbMoveOnly : 1;
145 unsigned mbSolidDraggingActive : 1;
147 protected:
148 // access for derivated classes to maSdrDragEntries
149 void clearSdrDragEntries();
150 void addSdrDragEntry(SdrDragEntry* pNew);
151 virtual void createSdrDragEntries();
152 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
154 // access for derivated classes to maOverlayObjectList
155 void clearOverlayObjectList() { maOverlayObjectList.clear(); }
156 void addToOverlayObjectList(sdr::overlay::OverlayObject& rNew) { maOverlayObjectList.append(rNew); }
157 basegfx::B2DRange getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList.getBaseRange(); }
159 // access for derivated classes to mrSdrDragView
160 SdrDragView& getSdrDragView() { return mrSdrDragView; }
161 const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
163 // access for derivated classes for bools
164 void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
165 void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
167 // internal helpers for creation of standard drag entries
168 void createSdrDragEntries_SolidDrag();
169 void createSdrDragEntries_PolygonDrag();
170 void createSdrDragEntries_PointDrag();
171 void createSdrDragEntries_GlueDrag();
173 // old call forwarders to the SdrDragView
174 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, String& rStr, sal_uInt16 nVal=0) const;
175 SdrHdl* GetDragHdl() const { return getSdrDragView().pDragHdl; }
176 SdrHdlKind GetDragHdlKind() const { return getSdrDragView().eDragHdl; }
177 SdrDragStat& DragStat() { return getSdrDragView().aDragStat; }
178 const SdrDragStat& DragStat() const { return getSdrDragView().aDragStat; }
179 Point& Ref1() const { return mrSdrDragView.aRef1; }
180 Point& Ref2() const { return mrSdrDragView.aRef2; }
181 const SdrHdlList& GetHdlList() const { return getSdrDragView().aHdl; }
182 void AddUndo(SdrUndoAction* pUndo) { getSdrDragView().AddUndo(pUndo); }
183 bool IsDragLimit() { return getSdrDragView().bDragLimit; }
184 const Rectangle& GetDragLimitRect() { return getSdrDragView().aDragLimit; }
185 const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
186 Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); }
187 sal_uInt16 SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
188 inline const Rectangle& GetMarkedRect() const;
189 SdrPageView* GetDragPV() const;
190 SdrObject* GetDragObj() const;
191 OutputDevice* GetDragWin() const { return getSdrDragView().pDragWin; }
192 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
193 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
195 bool DoAddConnectorOverlays();
196 drawinglayer::primitive2d::Primitive2DSequence AddConnectorOverlays();
198 public:
199 TYPEINFO();
201 void resetSdrDragEntries();
202 basegfx::B2DRange getCurrentRange() const;
204 // #i58950# also moved constructor implementation to cxx
205 SdrDragMethod(SdrDragView& rNewView);
207 // #i58950# virtual destructor was missing
208 virtual ~SdrDragMethod();
210 void Show();
211 void Hide();
212 virtual void TakeSdrDragComment(String& rStr) const=0;
213 virtual bool BeginSdrDrag()=0;
214 virtual void MoveSdrDrag(const Point& rPnt)=0;
215 virtual bool EndSdrDrag(bool bCopy)=0;
216 virtual void CancelSdrDrag();
217 virtual Pointer GetSdrDragPointer() const=0;
219 virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager);
220 void destroyOverlayGeometry();
222 virtual basegfx::B2DHomMatrix getCurrentTransformation();
223 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
224 virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
226 // data read access
227 bool getMoveOnly() const { return mbMoveOnly; }
228 bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
231 inline const Rectangle& SdrDragMethod::GetMarkedRect() const
233 return getSdrDragView().eDragHdl==HDL_POLY ? getSdrDragView().GetMarkedPointsRect() :
234 getSdrDragView().eDragHdl==HDL_GLUE ? getSdrDragView().GetMarkedGluePointsRect() :
235 getSdrDragView().GetMarkedObjRect();
238 ////////////////////////////////////////////////////////////////////////////////////////////////////
239 // SdrDragMove
241 class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod
243 private:
244 long nBestXSnap;
245 long nBestYSnap;
246 bool bXSnapped;
247 bool bYSnapped;
249 void ImpCheckSnap(const Point& rPt);
251 protected:
252 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
254 public:
255 TYPEINFO();
256 SdrDragMove(SdrDragView& rNewView);
258 virtual void TakeSdrDragComment(String& rStr) const;
259 virtual bool BeginSdrDrag();
260 virtual void MoveSdrDrag(const Point& rPnt);
261 virtual bool EndSdrDrag(bool bCopy);
262 virtual Pointer GetSdrDragPointer() const;
264 virtual basegfx::B2DHomMatrix getCurrentTransformation();
265 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
268 ////////////////////////////////////////////////////////////////////////////////////////////////////
269 // SdrDragResize
271 class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod
273 protected:
274 Fraction aXFact;
275 Fraction aYFact;
277 public:
278 TYPEINFO();
279 SdrDragResize(SdrDragView& rNewView);
281 virtual void TakeSdrDragComment(String& rStr) const;
282 virtual bool BeginSdrDrag();
283 virtual void MoveSdrDrag(const Point& rPnt);
284 virtual bool EndSdrDrag(bool bCopy);
285 virtual Pointer GetSdrDragPointer() const;
287 virtual basegfx::B2DHomMatrix getCurrentTransformation();
288 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
291 ////////////////////////////////////////////////////////////////////////////////////////////////////
292 // SdrDragObjOwn
294 class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
296 private:
297 // SdrDragObjOwn always works on a clone since it has no transformation
298 // mechanism to modify wireframe visualisations, but uses the
299 // SdrObject::applySpecialDrag() method to change a clone of the
300 // SdrObject
301 SdrObject* mpClone;
303 protected:
304 virtual void createSdrDragEntries();
306 public:
307 TYPEINFO();
308 SdrDragObjOwn(SdrDragView& rNewView);
309 virtual ~SdrDragObjOwn();
311 virtual void TakeSdrDragComment(String& rStr) const;
312 virtual bool BeginSdrDrag();
313 virtual void MoveSdrDrag(const Point& rPnt);
314 virtual bool EndSdrDrag(bool bCopy);
315 virtual Pointer GetSdrDragPointer() const;
318 #endif //_SVDDRGMT_HXX
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */