Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / svddrgmt.hxx
blob530517a3f12dc9417a1bbd091cbfd68b32a87a97
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 bool 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; }
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) SAL_OVERRIDE;
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) SAL_OVERRIDE;
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) SAL_OVERRIDE;
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) SAL_OVERRIDE;
120 class SVX_DLLPUBLIC SdrDragMethod
122 private:
123 std::vector< SdrDragEntry* > maSdrDragEntries;
124 sdr::overlay::OverlayObjectList maOverlayObjectList;
125 SdrDragView& mrSdrDragView;
127 // bitfield
128 bool mbMoveOnly : 1;
129 bool mbSolidDraggingActive : 1;
130 bool mbShiftPressed : 1;
132 protected:
133 // access for derivated classes to maSdrDragEntries
134 void clearSdrDragEntries();
135 void addSdrDragEntry(SdrDragEntry* pNew);
136 virtual void createSdrDragEntries();
137 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
139 // access for derivated classes to maOverlayObjectList
140 void clearOverlayObjectList() { maOverlayObjectList.clear(); }
141 void addToOverlayObjectList(sdr::overlay::OverlayObject& rNew) { maOverlayObjectList.append(rNew); }
142 basegfx::B2DRange getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList.getBaseRange(); }
144 // access for derivated classes to mrSdrDragView
145 SdrDragView& getSdrDragView() { return mrSdrDragView; }
146 const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
148 // access for derivated classes for bools
149 void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
150 void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
152 // internal helpers for creation of standard drag entries
153 void createSdrDragEntries_SolidDrag();
154 void createSdrDragEntries_PolygonDrag();
155 void createSdrDragEntries_PointDrag();
156 void createSdrDragEntries_GlueDrag();
158 // old call forwarders to the SdrDragView
159 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, sal_uInt16 nVal=0) const;
160 SdrHdl* GetDragHdl() const { return getSdrDragView().pDragHdl; }
161 SdrHdlKind GetDragHdlKind() const { return getSdrDragView().eDragHdl; }
162 SdrDragStat& DragStat() { return getSdrDragView().aDragStat; }
163 const SdrDragStat& DragStat() const { return getSdrDragView().aDragStat; }
164 Point& Ref1() const { return mrSdrDragView.aRef1; }
165 Point& Ref2() const { return mrSdrDragView.aRef2; }
166 const SdrHdlList& GetHdlList() const { return getSdrDragView().GetHdlList(); }
167 void AddUndo(SdrUndoAction* pUndo) { getSdrDragView().AddUndo(pUndo); }
168 bool IsDragLimit() { return getSdrDragView().bDragLimit; }
169 const Rectangle& GetDragLimitRect() { return getSdrDragView().aDragLimit; }
170 const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
171 Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); }
172 SdrSnap SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
173 inline const Rectangle& GetMarkedRect() const;
174 SdrPageView* GetDragPV() const;
175 SdrObject* GetDragObj() const;
176 OutputDevice* GetDragWin() const { return getSdrDragView().pDragWin; }
177 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
178 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
180 bool DoAddConnectorOverlays();
181 drawinglayer::primitive2d::Primitive2DSequence AddConnectorOverlays();
183 public:
184 TYPEINFO();
186 void resetSdrDragEntries();
187 basegfx::B2DRange getCurrentRange() const;
189 // #i58950# also moved constructor implementation to cxx
190 SdrDragMethod(SdrDragView& rNewView);
192 // #i58950# virtual destructor was missing
193 virtual ~SdrDragMethod();
195 void Show();
196 void Hide();
197 bool IsShiftPressed() { return mbShiftPressed; }
198 void SetShiftPressed(bool bShiftPressed) { mbShiftPressed = bShiftPressed; }
199 virtual void TakeSdrDragComment(OUString& rStr) const=0;
200 virtual bool BeginSdrDrag()=0;
201 virtual void MoveSdrDrag(const Point& rPnt)=0;
202 virtual bool EndSdrDrag(bool bCopy)=0;
203 virtual void CancelSdrDrag();
204 virtual Pointer GetSdrDragPointer() const=0;
206 virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager);
207 void destroyOverlayGeometry();
209 virtual basegfx::B2DHomMatrix getCurrentTransformation();
210 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
211 virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
213 // data read access
214 bool getMoveOnly() const { return mbMoveOnly; }
215 bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
218 inline const Rectangle& SdrDragMethod::GetMarkedRect() const
220 return getSdrDragView().eDragHdl==HDL_POLY ? getSdrDragView().GetMarkedPointsRect() :
221 getSdrDragView().eDragHdl==HDL_GLUE ? getSdrDragView().GetMarkedGluePointsRect() :
222 getSdrDragView().GetMarkedObjRect();
226 // SdrDragMove
228 class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod
230 private:
231 long nBestXSnap;
232 long nBestYSnap;
233 bool bXSnapped;
234 bool bYSnapped;
236 void ImpCheckSnap(const Point& rPt);
238 protected:
239 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify) SAL_OVERRIDE;
241 public:
242 TYPEINFO_OVERRIDE();
243 SdrDragMove(SdrDragView& rNewView);
245 virtual void TakeSdrDragComment(OUString& rStr) const SAL_OVERRIDE;
246 virtual bool BeginSdrDrag() SAL_OVERRIDE;
247 virtual void MoveSdrDrag(const Point& rPnt) SAL_OVERRIDE;
248 virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
249 virtual Pointer GetSdrDragPointer() const SAL_OVERRIDE;
251 virtual basegfx::B2DHomMatrix getCurrentTransformation() SAL_OVERRIDE;
252 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) SAL_OVERRIDE;
256 // SdrDragResize
258 class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod
260 protected:
261 Fraction aXFact;
262 Fraction aYFact;
264 public:
265 TYPEINFO_OVERRIDE();
266 SdrDragResize(SdrDragView& rNewView);
268 virtual void TakeSdrDragComment(OUString& rStr) const SAL_OVERRIDE;
269 virtual bool BeginSdrDrag() SAL_OVERRIDE;
270 virtual void MoveSdrDrag(const Point& rPnt) SAL_OVERRIDE;
271 virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
272 virtual Pointer GetSdrDragPointer() const SAL_OVERRIDE;
274 virtual basegfx::B2DHomMatrix getCurrentTransformation() SAL_OVERRIDE;
275 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) SAL_OVERRIDE;
279 // SdrDragObjOwn
281 class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
283 private:
284 // SdrDragObjOwn always works on a clone since it has no transformation
285 // mechanism to modify wireframe visualisations, but uses the
286 // SdrObject::applySpecialDrag() method to change a clone of the
287 // SdrObject
288 SdrObject* mpClone;
290 protected:
291 virtual void createSdrDragEntries() SAL_OVERRIDE;
293 public:
294 TYPEINFO_OVERRIDE();
295 SdrDragObjOwn(SdrDragView& rNewView);
296 virtual ~SdrDragObjOwn();
298 virtual void TakeSdrDragComment(OUString& rStr) const SAL_OVERRIDE;
299 virtual bool BeginSdrDrag() SAL_OVERRIDE;
300 virtual void MoveSdrDrag(const Point& rPnt) SAL_OVERRIDE;
301 virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
302 virtual Pointer GetSdrDragPointer() const SAL_OVERRIDE;
305 #endif // INCLUDED_SVX_SVDDRGMT_HXX
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */