1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
31 class SAL_DLLPUBLIC_RTTI SdrDragEntry
34 bool mbAddToTransparent
: 1;
37 // access for derived classes
38 void setAddToTransparent(bool bNew
) { mbAddToTransparent
= bNew
; }
42 virtual ~SdrDragEntry();
44 virtual drawinglayer::primitive2d::Primitive2DContainer
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
) = 0;
47 bool getAddToTransparent() const { return mbAddToTransparent
; }
51 class SVX_DLLPUBLIC SdrDragEntryPolyPolygon final
: public SdrDragEntry
54 basegfx::B2DPolyPolygon
const maOriginalPolyPolygon
;
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
67 const SdrObject
& maOriginal
;
68 SdrObjectUniquePtr mxClone
;
72 SdrDragEntrySdrObject(
73 const SdrObject
& rOriginal
,
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
90 drawinglayer::primitive2d::Primitive2DContainer
const maPrimitive2DSequence
;
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
104 std::vector
< basegfx::B2DPoint
> const maPositions
;
105 bool const mbIsPointDrag
;
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 SVX_DLLPUBLIC SdrDragMethod
118 std::vector
< std::unique_ptr
<SdrDragEntry
> > maSdrDragEntries
;
119 sdr::overlay::OverlayObjectList maOverlayObjectList
;
120 SdrDragView
& mrSdrDragView
;
123 bool mbSolidDraggingActive
: 1;
124 bool mbShiftPressed
: 1;
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();
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();
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
);
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();
229 class SVX_DLLPUBLIC SdrDragMove
: public SdrDragMethod
237 void ImpCheckSnap(const Point
& rPt
);
240 virtual void createSdrDragEntryForSdrObject(const SdrObject
& rOriginal
) override
;
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
;
258 class SVX_DLLPUBLIC SdrDragResize
: public SdrDragMethod
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
;
280 class SVX_DLLPUBLIC SdrDragObjOwn
: public SdrDragMethod
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
287 SdrObjectUniquePtr mxClone
;
290 virtual void createSdrDragEntries() override
;
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: */