Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / svddrgmt.hxx
blobc484c873662579750477955f1820b9513b496a57
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 bool mbAddToTransparent : 1;
35 protected:
36 // access for derived classes
37 void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; }
39 public:
40 SdrDragEntry();
41 virtual ~SdrDragEntry();
43 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
45 // data read access
46 bool getAddToTransparent() const { return mbAddToTransparent; }
50 class SVX_DLLPUBLIC SdrDragEntryPolyPolygon : public SdrDragEntry
52 private:
53 basegfx::B2DPolyPolygon maOriginalPolyPolygon;
55 public:
56 SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
57 virtual ~SdrDragEntryPolyPolygon() override;
59 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
63 class SdrDragEntrySdrObject : public SdrDragEntry
65 private:
66 const SdrObject& maOriginal;
67 SdrObject* mpClone;
68 sdr::contact::ObjectContact& mrObjectContact;
69 bool mbModify;
71 public:
72 SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
73 virtual ~SdrDragEntrySdrObject() override;
75 // #i54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
76 // added accessors to original and clone
77 void prepareCurrentState(SdrDragMethod& rDragMethod);
78 const SdrObject& getOriginal() const { return maOriginal; }
79 SdrObject* getClone() { return mpClone; }
81 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
85 class SdrDragEntryPrimitive2DSequence : public SdrDragEntry
87 private:
88 drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence;
90 public:
91 SdrDragEntryPrimitive2DSequence(
92 const drawinglayer::primitive2d::Primitive2DContainer& rSequence);
93 virtual ~SdrDragEntryPrimitive2DSequence() override;
95 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
99 class SdrDragEntryPointGlueDrag : public SdrDragEntry
101 private:
102 std::vector< basegfx::B2DPoint > maPositions;
103 bool mbIsPointDrag;
105 public:
106 SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
107 virtual ~SdrDragEntryPointGlueDrag() override;
109 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
113 class SVX_DLLPUBLIC SdrDragMethod
115 private:
116 std::vector< SdrDragEntry* > maSdrDragEntries;
117 sdr::overlay::OverlayObjectList maOverlayObjectList;
118 SdrDragView& mrSdrDragView;
120 bool mbMoveOnly : 1;
121 bool mbSolidDraggingActive : 1;
122 bool mbShiftPressed : 1;
124 protected:
125 // access for derivated classes to maSdrDragEntries
126 void clearSdrDragEntries();
127 void addSdrDragEntry(SdrDragEntry* pNew);
128 virtual void createSdrDragEntries();
129 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact);
131 // access for derivated classes to maOverlayObjectList (passes ownership)
132 void addToOverlayObjectList(sdr::overlay::OverlayObject* pNew) { maOverlayObjectList.append(pNew); }
134 // access for derivated classes to mrSdrDragView
135 SdrDragView& getSdrDragView() { return mrSdrDragView; }
136 const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
138 // access for derivated classes for bools
139 void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
140 void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
142 // internal helpers for creation of standard drag entries
143 void createSdrDragEntries_SolidDrag();
144 void createSdrDragEntries_PolygonDrag();
145 void createSdrDragEntries_PointDrag();
146 void createSdrDragEntries_GlueDrag();
148 // old call forwarders to the SdrDragView
149 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr) const;
150 SdrHdl* GetDragHdl() const { return getSdrDragView().mpDragHdl; }
151 SdrHdlKind GetDragHdlKind() const { return getSdrDragView().meDragHdl; }
152 SdrDragStat& DragStat() { return getSdrDragView().maDragStat; }
153 const SdrDragStat& DragStat() const { return getSdrDragView().maDragStat; }
154 Point& Ref1() const { return mrSdrDragView.maRef1; }
155 Point& Ref2() const { return mrSdrDragView.maRef2; }
156 const SdrHdlList& GetHdlList() const { return getSdrDragView().GetHdlList(); }
157 void AddUndo(SdrUndoAction* pUndo) { getSdrDragView().AddUndo(pUndo); }
158 bool IsDragLimit() { return getSdrDragView().mbDragLimit; }
159 const tools::Rectangle& GetDragLimitRect() { return getSdrDragView().maDragLimit; }
160 const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
161 Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().mpMarkedPV); }
162 SdrSnap SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().mpMarkedPV); }
163 inline const tools::Rectangle& GetMarkedRect() const;
164 SdrPageView* GetDragPV() const;
165 SdrObject* GetDragObj() const;
166 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
167 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
169 bool DoAddConnectorOverlays();
170 drawinglayer::primitive2d::Primitive2DContainer AddConnectorOverlays();
172 public:
174 void resetSdrDragEntries();
175 basegfx::B2DRange getCurrentRange() const;
177 // #i58950# also moved constructor implementation to cxx
178 SdrDragMethod(SdrDragView& rNewView);
180 // #i58950# virtual destructor was missing
181 virtual ~SdrDragMethod();
183 void Show();
184 void Hide();
185 bool IsShiftPressed() { return mbShiftPressed; }
186 void SetShiftPressed(bool bShiftPressed) { mbShiftPressed = bShiftPressed; }
187 virtual void TakeSdrDragComment(OUString& rStr) const=0;
188 virtual bool BeginSdrDrag()=0;
189 virtual void MoveSdrDrag(const Point& rPnt)=0;
190 virtual bool EndSdrDrag(bool bCopy)=0;
191 virtual void CancelSdrDrag();
192 virtual Pointer GetSdrDragPointer() const=0;
194 virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager);
195 void destroyOverlayGeometry();
197 virtual basegfx::B2DHomMatrix getCurrentTransformation();
198 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
199 virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
201 // data read access
202 bool getMoveOnly() const { return mbMoveOnly; }
203 bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
206 inline const tools::Rectangle& SdrDragMethod::GetMarkedRect() const
208 return getSdrDragView().meDragHdl==SdrHdlKind::Poly ? getSdrDragView().GetMarkedPointsRect() :
209 getSdrDragView().meDragHdl==SdrHdlKind::Glue ? getSdrDragView().GetMarkedGluePointsRect() :
210 getSdrDragView().GetMarkedObjRect();
214 // SdrDragMove
216 class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod
218 private:
219 long nBestXSnap;
220 long nBestYSnap;
221 bool bXSnapped;
222 bool bYSnapped;
224 void ImpCheckSnap(const Point& rPt);
226 protected:
227 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact) override;
229 public:
230 SdrDragMove(SdrDragView& rNewView);
232 virtual void TakeSdrDragComment(OUString& rStr) const override;
233 virtual bool BeginSdrDrag() override;
234 virtual void MoveSdrDrag(const Point& rPnt) override;
235 virtual bool EndSdrDrag(bool bCopy) override;
236 virtual Pointer GetSdrDragPointer() const override;
238 virtual basegfx::B2DHomMatrix getCurrentTransformation() override;
239 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
243 // SdrDragResize
245 class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod
247 protected:
248 Fraction aXFact;
249 Fraction aYFact;
251 public:
252 SdrDragResize(SdrDragView& rNewView);
254 virtual void TakeSdrDragComment(OUString& rStr) const override;
255 virtual bool BeginSdrDrag() override;
256 virtual void MoveSdrDrag(const Point& rPnt) override;
257 virtual bool EndSdrDrag(bool bCopy) override;
258 virtual Pointer GetSdrDragPointer() const override;
260 virtual basegfx::B2DHomMatrix getCurrentTransformation() override;
261 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
265 // SdrDragObjOwn
267 class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
269 private:
270 // SdrDragObjOwn always works on a clone since it has no transformation
271 // mechanism to modify wireframe visualisations, but uses the
272 // SdrObject::applySpecialDrag() method to change a clone of the
273 // SdrObject
274 SdrObject* mpClone;
276 protected:
277 virtual void createSdrDragEntries() override;
279 public:
280 SdrDragObjOwn(SdrDragView& rNewView);
281 virtual ~SdrDragObjOwn() override;
283 virtual void TakeSdrDragComment(OUString& rStr) const override;
284 virtual bool BeginSdrDrag() override;
285 virtual void MoveSdrDrag(const Point& rPnt) override;
286 virtual bool EndSdrDrag(bool bCopy) override;
287 virtual Pointer GetSdrDragPointer() const override;
290 #endif // INCLUDED_SVX_SVDDRGMT_HXX
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */