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>
30 class SVX_DLLPUBLIC SdrDragEntry
33 bool mbAddToTransparent
: 1;
36 // access for derived classes
37 void setAddToTransparent(bool bNew
) { mbAddToTransparent
= bNew
; }
41 virtual ~SdrDragEntry();
43 virtual drawinglayer::primitive2d::Primitive2DContainer
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
) = 0;
46 bool getAddToTransparent() const { return mbAddToTransparent
; }
50 class SVX_DLLPUBLIC SdrDragEntryPolyPolygon
: public SdrDragEntry
53 basegfx::B2DPolyPolygon maOriginalPolyPolygon
;
56 SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon
& rOriginalPolyPolygon
);
57 virtual ~SdrDragEntryPolyPolygon() override
;
59 virtual drawinglayer::primitive2d::Primitive2DContainer
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
) override
;
63 class SdrDragEntrySdrObject
: public SdrDragEntry
66 const SdrObject
& maOriginal
;
68 sdr::contact::ObjectContact
& mrObjectContact
;
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
88 drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
;
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
102 std::vector
< basegfx::B2DPoint
> maPositions
;
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
116 std::vector
< SdrDragEntry
* > maSdrDragEntries
;
117 sdr::overlay::OverlayObjectList maOverlayObjectList
;
118 SdrDragView
& mrSdrDragView
;
121 bool mbSolidDraggingActive
: 1;
122 bool mbShiftPressed
: 1;
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();
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();
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
);
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();
216 class SVX_DLLPUBLIC SdrDragMove
: public SdrDragMethod
224 void ImpCheckSnap(const Point
& rPt
);
227 virtual void createSdrDragEntryForSdrObject(const SdrObject
& rOriginal
, sdr::contact::ObjectContact
& rObjectContact
) override
;
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
;
245 class SVX_DLLPUBLIC SdrDragResize
: public SdrDragMethod
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
;
267 class SVX_DLLPUBLIC SdrDragObjOwn
: public SdrDragMethod
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
277 virtual void createSdrDragEntries() override
;
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: */