Fix typo in code
[LibreOffice.git] / include / svx / svddrgmt.hxx
blob5b01852ea363a9ab6fcdf7d94df54ca7864ca6da
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>
26 #include <memory>
28 class SdrDragView;
29 class SdrDragStat;
31 class SAL_DLLPUBLIC_RTTI SdrDragEntry
33 private:
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::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
46 // data read access
47 bool getAddToTransparent() const { return mbAddToTransparent; }
51 class SVXCORE_DLLPUBLIC SdrDragEntryPolyPolygon final : public SdrDragEntry
53 private:
54 basegfx::B2DPolyPolygon maOriginalPolyPolygon;
56 public:
57 SdrDragEntryPolyPolygon(basegfx::B2DPolyPolygon aOriginalPolyPolygon);
58 virtual ~SdrDragEntryPolyPolygon() override;
60 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
64 class SdrDragEntrySdrObject final : public SdrDragEntry
66 private:
67 const SdrObject& maOriginal;
68 rtl::Reference<SdrObject> mxClone;
69 bool mbModify;
71 public:
72 SdrDragEntrySdrObject(
73 const SdrObject& rOriginal,
74 bool bModify);
75 virtual ~SdrDragEntrySdrObject() override;
77 // #i54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
78 // added accessors to original and clone
79 void prepareCurrentState(SdrDragMethod& rDragMethod);
80 const SdrObject& getOriginal() const { return maOriginal; }
81 SdrObject* getClone() { return mxClone.get(); }
83 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
87 class SdrDragEntryPrimitive2DSequence final : public SdrDragEntry
89 private:
90 drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence;
92 public:
93 SdrDragEntryPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DContainer&& rSequence);
94 virtual ~SdrDragEntryPrimitive2DSequence() override;
96 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
100 class SdrDragEntryPointGlueDrag final : public SdrDragEntry
102 private:
103 std::vector< basegfx::B2DPoint > maPositions;
104 bool mbIsPointDrag;
106 public:
107 SdrDragEntryPointGlueDrag(std::vector< basegfx::B2DPoint >&& rPositions, bool bIsPointDrag);
108 virtual ~SdrDragEntryPointGlueDrag() override;
110 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
114 class SVXCORE_DLLPUBLIC SdrDragMethod
116 private:
117 std::vector< std::unique_ptr<SdrDragEntry> > maSdrDragEntries;
118 sdr::overlay::OverlayObjectList maOverlayObjectList;
119 SdrDragView& mrSdrDragView;
121 bool mbMoveOnly : 1;
122 bool mbSolidDraggingActive : 1;
123 bool mbShiftPressed : 1;
125 protected:
126 // access for derivated classes to maSdrDragEntries
127 SAL_DLLPRIVATE void clearSdrDragEntries();
128 void addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew);
129 virtual void createSdrDragEntries();
130 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal);
132 // Helper to support inserting a new OverlayObject. It will do all
133 // necessary stuff involved with that:
134 // - add GridOffset for non-linear ViewToDevice transformation (calc)
135 // - add to OverlayManager
136 // - add to local OverlayObjectList - ownership change (!)
137 // It is centralized here (and protected) to avoid that new usages/
138 // implementations forget one of these needed steps.
139 void insertNewlyCreatedOverlayObjectForSdrDragMethod(
140 std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject,
141 const sdr::contact::ObjectContact& rObjectContact,
142 sdr::overlay::OverlayManager& rOverlayManager);
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 SAL_DLLPRIVATE void createSdrDragEntries_SolidDrag();
154 SAL_DLLPRIVATE void createSdrDragEntries_PolygonDrag();
155 SAL_DLLPRIVATE void createSdrDragEntries_PointDrag();
156 SAL_DLLPRIVATE void createSdrDragEntries_GlueDrag();
158 // old call forwarders to the SdrDragView
159 SAL_DLLPRIVATE OUString ImpGetDescriptionStr(TranslateId pStrCacheID) const;
160 SdrHdl* GetDragHdl() const { return getSdrDragView().mpDragHdl; }
161 SdrHdlKind GetDragHdlKind() const { return getSdrDragView().meDragHdl; }
162 SdrDragStat& DragStat() { return getSdrDragView().maDragStat; }
163 const SdrDragStat& DragStat() const { return getSdrDragView().maDragStat; }
164 Point& Ref1() const { return mrSdrDragView.maRef1; }
165 Point& Ref2() const { return mrSdrDragView.maRef2; }
166 const SdrHdlList& GetHdlList() const { return getSdrDragView().GetHdlList(); }
167 void AddUndo(std::unique_ptr<SdrUndoAction> pUndo) { getSdrDragView().AddUndo(std::move(pUndo)); }
168 bool IsDragLimit() { return getSdrDragView().mbDragLimit; }
169 const tools::Rectangle& GetDragLimitRect() { return getSdrDragView().maDragLimit; }
170 const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
171 Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().mpMarkedPV); }
172 SdrSnap SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().mpMarkedPV); }
173 inline const tools::Rectangle& GetMarkedRect() const;
174 SAL_DLLPRIVATE SdrPageView* GetDragPV() const;
175 SdrObject* GetDragObj() const;
176 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
177 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
179 SAL_DLLPRIVATE bool DoAddConnectorOverlays();
180 SAL_DLLPRIVATE drawinglayer::primitive2d::Primitive2DContainer AddConnectorOverlays();
182 public:
184 SAL_DLLPRIVATE void resetSdrDragEntries();
185 SAL_DLLPRIVATE basegfx::B2DRange getCurrentRange() const;
187 // #i58950# also moved constructor implementation to cxx
188 SdrDragMethod(SdrDragView& rNewView);
190 // #i58950# virtual destructor was missing
191 virtual ~SdrDragMethod();
193 void Show();
194 void Hide();
195 bool IsShiftPressed() const { return mbShiftPressed; }
196 void SetShiftPressed(bool bShiftPressed) { mbShiftPressed = bShiftPressed; }
197 virtual OUString GetSdrDragComment() const=0;
198 virtual bool BeginSdrDrag()=0;
199 virtual void MoveSdrDrag(const Point& rPnt)=0;
200 virtual bool EndSdrDrag(bool bCopy)=0;
201 virtual void CancelSdrDrag();
202 virtual PointerStyle GetSdrDragPointer() const=0;
204 virtual void CreateOverlayGeometry(
205 sdr::overlay::OverlayManager& rOverlayManager,
206 const sdr::contact::ObjectContact& rObjectContact);
207 SAL_DLLPRIVATE void destroyOverlayGeometry();
209 virtual basegfx::B2DHomMatrix getCurrentTransformation() const;
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 tools::Rectangle& SdrDragMethod::GetMarkedRect() const
220 return getSdrDragView().meDragHdl==SdrHdlKind::Poly ? getSdrDragView().GetMarkedPointsRect() :
221 getSdrDragView().meDragHdl==SdrHdlKind::Glue ? getSdrDragView().GetMarkedGluePointsRect() :
222 getSdrDragView().GetMarkedObjRect();
226 // SdrDragMove
228 class SVXCORE_DLLPUBLIC SdrDragMove : public SdrDragMethod
230 private:
231 tools::Long nBestXSnap;
232 tools::Long nBestYSnap;
233 bool bXSnapped;
234 bool bYSnapped;
236 void ImpCheckSnap(const Point& rPt);
238 protected:
239 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal) override;
241 public:
242 SdrDragMove(SdrDragView& rNewView);
244 virtual OUString GetSdrDragComment() const override;
245 virtual bool BeginSdrDrag() override;
246 virtual void MoveSdrDrag(const Point& rPnt) override;
247 virtual bool EndSdrDrag(bool bCopy) override;
248 virtual PointerStyle GetSdrDragPointer() const override;
250 virtual basegfx::B2DHomMatrix getCurrentTransformation() const override;
251 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
255 // SdrDragResize
257 class SVXCORE_DLLPUBLIC SdrDragResize : public SdrDragMethod
259 protected:
260 Fraction aXFact;
261 Fraction aYFact;
263 public:
264 SdrDragResize(SdrDragView& rNewView);
266 virtual OUString GetSdrDragComment() const override;
267 virtual bool BeginSdrDrag() override;
268 virtual void MoveSdrDrag(const Point& rPnt) override;
269 virtual bool EndSdrDrag(bool bCopy) override;
270 virtual PointerStyle GetSdrDragPointer() const override;
272 virtual basegfx::B2DHomMatrix getCurrentTransformation() const override;
273 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
277 // SdrDragObjOwn
279 class SVXCORE_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
281 private:
282 // SdrDragObjOwn always works on a clone since it has no transformation
283 // mechanism to modify wireframe visualisations, but uses the
284 // SdrObject::applySpecialDrag() method to change a clone of the
285 // SdrObject
286 rtl::Reference<SdrObject> mxClone;
288 protected:
289 virtual void createSdrDragEntries() override;
291 public:
292 SdrDragObjOwn(SdrDragView& rNewView);
293 virtual ~SdrDragObjOwn() override;
295 virtual OUString GetSdrDragComment() const override;
296 virtual bool BeginSdrDrag() override;
297 virtual void MoveSdrDrag(const Point& rPnt) override;
298 virtual bool EndSdrDrag(bool bCopy) override;
299 virtual PointerStyle GetSdrDragPointer() const override;
302 #endif // INCLUDED_SVX_SVDDRGMT_HXX
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */