lok: use "None" string item in the ListBox control
[LibreOffice.git] / include / svx / svddrgmt.hxx
blob43a8c7ef1ece28a3440ac6bd56a71468429b2d49
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 const maOriginalPolyPolygon;
56 public:
57 SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
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 SdrObjectUniquePtr mxClone;
69 bool const 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 const maPrimitive2DSequence;
92 public:
93 SdrDragEntryPrimitive2DSequence(
94 const drawinglayer::primitive2d::Primitive2DContainer& rSequence);
95 virtual ~SdrDragEntryPrimitive2DSequence() override;
97 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
101 class SdrDragEntryPointGlueDrag final : public SdrDragEntry
103 private:
104 std::vector< basegfx::B2DPoint > const maPositions;
105 bool const mbIsPointDrag;
107 public:
108 SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
109 virtual ~SdrDragEntryPointGlueDrag() override;
111 virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
115 class SVXCORE_DLLPUBLIC SdrDragMethod
117 private:
118 std::vector< std::unique_ptr<SdrDragEntry> > maSdrDragEntries;
119 sdr::overlay::OverlayObjectList maOverlayObjectList;
120 SdrDragView& mrSdrDragView;
122 bool mbMoveOnly : 1;
123 bool mbSolidDraggingActive : 1;
124 bool mbShiftPressed : 1;
126 protected:
127 // access for derivated classes to maSdrDragEntries
128 void clearSdrDragEntries();
129 void addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew);
130 virtual void createSdrDragEntries();
131 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal);
133 // Helper to support inserting a new OverlayObject. It will do all
134 // necessary stuff involved with that:
135 // - add GridOffset for non-linear ViewToDevice transformation (calc)
136 // - add to OverlayManager
137 // - add to local OverlayObjectList - ownership change (!)
138 // It is centralized here (and protected) to avoid that new usages/
139 // implementations forget one of these needed steps.
140 void insertNewlyCreatedOverlayObjectForSdrDragMethod(
141 std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject,
142 const sdr::contact::ObjectContact& rObjectContact,
143 sdr::overlay::OverlayManager& rOverlayManager);
145 // access for derivated classes to mrSdrDragView
146 SdrDragView& getSdrDragView() { return mrSdrDragView; }
147 const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
149 // access for derivated classes for bools
150 void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
151 void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
153 // internal helpers for creation of standard drag entries
154 void createSdrDragEntries_SolidDrag();
155 void createSdrDragEntries_PolygonDrag();
156 void createSdrDragEntries_PointDrag();
157 void createSdrDragEntries_GlueDrag();
159 // old call forwarders to the SdrDragView
160 OUString ImpGetDescriptionStr(const char* pStrCacheID) const;
161 SdrHdl* GetDragHdl() const { return getSdrDragView().mpDragHdl; }
162 SdrHdlKind GetDragHdlKind() const { return getSdrDragView().meDragHdl; }
163 SdrDragStat& DragStat() { return getSdrDragView().maDragStat; }
164 const SdrDragStat& DragStat() const { return getSdrDragView().maDragStat; }
165 Point& Ref1() const { return mrSdrDragView.maRef1; }
166 Point& Ref2() const { return mrSdrDragView.maRef2; }
167 const SdrHdlList& GetHdlList() const { return getSdrDragView().GetHdlList(); }
168 void AddUndo(std::unique_ptr<SdrUndoAction> pUndo) { getSdrDragView().AddUndo(std::move(pUndo)); }
169 bool IsDragLimit() { return getSdrDragView().mbDragLimit; }
170 const tools::Rectangle& GetDragLimitRect() { return getSdrDragView().maDragLimit; }
171 const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
172 Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().mpMarkedPV); }
173 SdrSnap SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().mpMarkedPV); }
174 inline const tools::Rectangle& GetMarkedRect() const;
175 SdrPageView* GetDragPV() const;
176 SdrObject* GetDragObj() const;
177 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
178 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
180 bool DoAddConnectorOverlays();
181 drawinglayer::primitive2d::Primitive2DContainer AddConnectorOverlays();
183 public:
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 bool IsShiftPressed() const { return mbShiftPressed; }
197 void SetShiftPressed(bool bShiftPressed) { mbShiftPressed = bShiftPressed; }
198 virtual OUString GetSdrDragComment() const=0;
199 virtual bool BeginSdrDrag()=0;
200 virtual void MoveSdrDrag(const Point& rPnt)=0;
201 virtual bool EndSdrDrag(bool bCopy)=0;
202 virtual void CancelSdrDrag();
203 virtual PointerStyle GetSdrDragPointer() const=0;
205 virtual void CreateOverlayGeometry(
206 sdr::overlay::OverlayManager& rOverlayManager,
207 const sdr::contact::ObjectContact& rObjectContact);
208 void destroyOverlayGeometry();
210 virtual basegfx::B2DHomMatrix getCurrentTransformation();
211 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
212 virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
214 // data read access
215 bool getMoveOnly() const { return mbMoveOnly; }
216 bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
219 inline const tools::Rectangle& SdrDragMethod::GetMarkedRect() const
221 return getSdrDragView().meDragHdl==SdrHdlKind::Poly ? getSdrDragView().GetMarkedPointsRect() :
222 getSdrDragView().meDragHdl==SdrHdlKind::Glue ? getSdrDragView().GetMarkedGluePointsRect() :
223 getSdrDragView().GetMarkedObjRect();
227 // SdrDragMove
229 class SVXCORE_DLLPUBLIC SdrDragMove : public SdrDragMethod
231 private:
232 long nBestXSnap;
233 long nBestYSnap;
234 bool bXSnapped;
235 bool bYSnapped;
237 void ImpCheckSnap(const Point& rPt);
239 protected:
240 virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal) override;
242 public:
243 SdrDragMove(SdrDragView& rNewView);
245 virtual OUString GetSdrDragComment() const override;
246 virtual bool BeginSdrDrag() override;
247 virtual void MoveSdrDrag(const Point& rPnt) override;
248 virtual bool EndSdrDrag(bool bCopy) override;
249 virtual PointerStyle GetSdrDragPointer() const override;
251 virtual basegfx::B2DHomMatrix getCurrentTransformation() override;
252 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
256 // SdrDragResize
258 class SVXCORE_DLLPUBLIC SdrDragResize : public SdrDragMethod
260 protected:
261 Fraction aXFact;
262 Fraction aYFact;
264 public:
265 SdrDragResize(SdrDragView& rNewView);
267 virtual OUString GetSdrDragComment() const override;
268 virtual bool BeginSdrDrag() override;
269 virtual void MoveSdrDrag(const Point& rPnt) override;
270 virtual bool EndSdrDrag(bool bCopy) override;
271 virtual PointerStyle GetSdrDragPointer() const override;
273 virtual basegfx::B2DHomMatrix getCurrentTransformation() override;
274 virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) override;
278 // SdrDragObjOwn
280 class SVXCORE_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
282 private:
283 // SdrDragObjOwn always works on a clone since it has no transformation
284 // mechanism to modify wireframe visualisations, but uses the
285 // SdrObject::applySpecialDrag() method to change a clone of the
286 // SdrObject
287 SdrObjectUniquePtr mxClone;
289 protected:
290 virtual void createSdrDragEntries() override;
292 public:
293 SdrDragObjOwn(SdrDragView& rNewView);
294 virtual ~SdrDragObjOwn() override;
296 virtual OUString GetSdrDragComment() const override;
297 virtual bool BeginSdrDrag() override;
298 virtual void MoveSdrDrag(const Point& rPnt) override;
299 virtual bool EndSdrDrag(bool bCopy) override;
300 virtual PointerStyle GetSdrDragPointer() const override;
303 #endif // INCLUDED_SVX_SVDDRGMT_HXX
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */