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 .
23 #include <svx/svddrgv.hxx>
24 #include "svx/svxdllapi.h"
25 #include <svx/sdr/contact/objectcontact.hxx>
27 ////////////////////////////////////////////////////////////////////////////////////////////////////
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
30 // @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@@@@ @@@@@@ @@ @@ @@@@ @@@@@ @@@@
31 // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
32 // @@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@
33 // @@ @@ @@@@@ @@@@@@ @@ @@@ @@@@@@@ @@@@ @@ @@@@@@ @@ @@ @@ @@ @@@@
34 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
35 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
36 // @@@@@ @@ @@ @@ @@ @@@@@ @@ @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
38 ////////////////////////////////////////////////////////////////////////////////////////////////////
39 ////////////////////////////////////////////////////////////////////////////////////////////////////
44 //////////////////////////////////////////////////////////////////////////////
46 class SVX_DLLPUBLIC SdrDragEntry
50 unsigned mbAddToTransparent
: 1;
53 // access for derived classes
54 void setAddToTransparent(bool bNew
) { mbAddToTransparent
= bNew
; }
58 virtual ~SdrDragEntry();
60 virtual drawinglayer::primitive2d::Primitive2DSequence
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
) = 0;
63 bool getAddToTransparent() const { return mbAddToTransparent
; }
66 //////////////////////////////////////////////////////////////////////////////
68 class SVX_DLLPUBLIC SdrDragEntryPolyPolygon
: public SdrDragEntry
71 basegfx::B2DPolyPolygon maOriginalPolyPolygon
;
74 SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon
& rOriginalPolyPolygon
);
75 virtual ~SdrDragEntryPolyPolygon();
77 virtual drawinglayer::primitive2d::Primitive2DSequence
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
);
80 //////////////////////////////////////////////////////////////////////////////
82 class SdrDragEntrySdrObject
: public SdrDragEntry
85 const SdrObject
& maOriginal
;
87 sdr::contact::ObjectContact
& mrObjectContact
;
91 SdrDragEntrySdrObject(const SdrObject
& rOriginal
, sdr::contact::ObjectContact
& rObjectContact
, bool bModify
);
92 virtual ~SdrDragEntrySdrObject();
94 // #i54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
95 // added accessors to original and clone
96 void prepareCurrentState(SdrDragMethod
& rDragMethod
);
97 const SdrObject
& getOriginal() const { return maOriginal
; }
98 SdrObject
* getClone() { return mpClone
; }
100 virtual drawinglayer::primitive2d::Primitive2DSequence
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
);
103 //////////////////////////////////////////////////////////////////////////////
105 class SdrDragEntryPrimitive2DSequence
: public SdrDragEntry
108 drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence
;
111 SdrDragEntryPrimitive2DSequence(
112 const drawinglayer::primitive2d::Primitive2DSequence
& rSequence
,
113 bool bAddToTransparent
);
114 virtual ~SdrDragEntryPrimitive2DSequence();
116 virtual drawinglayer::primitive2d::Primitive2DSequence
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
);
119 //////////////////////////////////////////////////////////////////////////////
121 class SdrDragEntryPointGlueDrag
: public SdrDragEntry
124 std::vector
< basegfx::B2DPoint
> maPositions
;
128 SdrDragEntryPointGlueDrag(const std::vector
< basegfx::B2DPoint
>& rPositions
, bool bIsPointDrag
);
129 virtual ~SdrDragEntryPointGlueDrag();
131 virtual drawinglayer::primitive2d::Primitive2DSequence
createPrimitive2DSequenceInCurrentState(SdrDragMethod
& rDragMethod
);
134 //////////////////////////////////////////////////////////////////////////////
136 class SVX_DLLPUBLIC SdrDragMethod
139 std::vector
< SdrDragEntry
* > maSdrDragEntries
;
140 sdr::overlay::OverlayObjectList maOverlayObjectList
;
141 SdrDragView
& mrSdrDragView
;
144 unsigned mbMoveOnly
: 1;
145 unsigned mbSolidDraggingActive
: 1;
148 // access for derivated classes to maSdrDragEntries
149 void clearSdrDragEntries();
150 void addSdrDragEntry(SdrDragEntry
* pNew
);
151 virtual void createSdrDragEntries();
152 virtual void createSdrDragEntryForSdrObject(const SdrObject
& rOriginal
, sdr::contact::ObjectContact
& rObjectContact
, bool bModify
);
154 // access for derivated classes to maOverlayObjectList
155 void clearOverlayObjectList() { maOverlayObjectList
.clear(); }
156 void addToOverlayObjectList(sdr::overlay::OverlayObject
& rNew
) { maOverlayObjectList
.append(rNew
); }
157 basegfx::B2DRange
getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList
.getBaseRange(); }
159 // access for derivated classes to mrSdrDragView
160 SdrDragView
& getSdrDragView() { return mrSdrDragView
; }
161 const SdrDragView
& getSdrDragView() const { return mrSdrDragView
; }
163 // access for derivated classes for bools
164 void setMoveOnly(bool bNew
) { mbMoveOnly
= bNew
; }
165 void setSolidDraggingActive(bool bNew
) { mbSolidDraggingActive
= bNew
; }
167 // internal helpers for creation of standard drag entries
168 void createSdrDragEntries_SolidDrag();
169 void createSdrDragEntries_PolygonDrag();
170 void createSdrDragEntries_PointDrag();
171 void createSdrDragEntries_GlueDrag();
173 // old call forwarders to the SdrDragView
174 void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID
, String
& rStr
, sal_uInt16 nVal
=0) const;
175 SdrHdl
* GetDragHdl() const { return getSdrDragView().pDragHdl
; }
176 SdrHdlKind
GetDragHdlKind() const { return getSdrDragView().eDragHdl
; }
177 SdrDragStat
& DragStat() { return getSdrDragView().aDragStat
; }
178 const SdrDragStat
& DragStat() const { return getSdrDragView().aDragStat
; }
179 Point
& Ref1() const { return mrSdrDragView
.aRef1
; }
180 Point
& Ref2() const { return mrSdrDragView
.aRef2
; }
181 const SdrHdlList
& GetHdlList() const { return getSdrDragView().aHdl
; }
182 void AddUndo(SdrUndoAction
* pUndo
) { getSdrDragView().AddUndo(pUndo
); }
183 bool IsDragLimit() { return getSdrDragView().bDragLimit
; }
184 const Rectangle
& GetDragLimitRect() { return getSdrDragView().aDragLimit
; }
185 const SdrMarkList
& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
186 Point
GetSnapPos(const Point
& rPt
) const { return getSdrDragView().GetSnapPos(rPt
,getSdrDragView().pMarkedPV
); }
187 sal_uInt16
SnapPos(Point
& rPt
) const { return getSdrDragView().SnapPos(rPt
,getSdrDragView().pMarkedPV
); }
188 inline const Rectangle
& GetMarkedRect() const;
189 SdrPageView
* GetDragPV() const;
190 SdrObject
* GetDragObj() const;
191 OutputDevice
* GetDragWin() const { return getSdrDragView().pDragWin
; }
192 bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); }
193 bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); }
195 bool DoAddConnectorOverlays();
196 drawinglayer::primitive2d::Primitive2DSequence
AddConnectorOverlays();
201 void resetSdrDragEntries();
202 basegfx::B2DRange
getCurrentRange() const;
204 // #i58950# also moved constructor implementation to cxx
205 SdrDragMethod(SdrDragView
& rNewView
);
207 // #i58950# virtual destructor was missing
208 virtual ~SdrDragMethod();
212 virtual void TakeSdrDragComment(String
& rStr
) const=0;
213 virtual bool BeginSdrDrag()=0;
214 virtual void MoveSdrDrag(const Point
& rPnt
)=0;
215 virtual bool EndSdrDrag(bool bCopy
)=0;
216 virtual void CancelSdrDrag();
217 virtual Pointer
GetSdrDragPointer() const=0;
219 virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager
& rOverlayManager
);
220 void destroyOverlayGeometry();
222 virtual basegfx::B2DHomMatrix
getCurrentTransformation();
223 virtual void applyCurrentTransformationToSdrObject(SdrObject
& rTarget
);
224 virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon
& rTarget
);
227 bool getMoveOnly() const { return mbMoveOnly
; }
228 bool getSolidDraggingActive() const { return mbSolidDraggingActive
; }
231 inline const Rectangle
& SdrDragMethod::GetMarkedRect() const
233 return getSdrDragView().eDragHdl
==HDL_POLY
? getSdrDragView().GetMarkedPointsRect() :
234 getSdrDragView().eDragHdl
==HDL_GLUE
? getSdrDragView().GetMarkedGluePointsRect() :
235 getSdrDragView().GetMarkedObjRect();
238 ////////////////////////////////////////////////////////////////////////////////////////////////////
241 class SVX_DLLPUBLIC SdrDragMove
: public SdrDragMethod
249 void ImpCheckSnap(const Point
& rPt
);
252 virtual void createSdrDragEntryForSdrObject(const SdrObject
& rOriginal
, sdr::contact::ObjectContact
& rObjectContact
, bool bModify
);
256 SdrDragMove(SdrDragView
& rNewView
);
258 virtual void TakeSdrDragComment(String
& rStr
) const;
259 virtual bool BeginSdrDrag();
260 virtual void MoveSdrDrag(const Point
& rPnt
);
261 virtual bool EndSdrDrag(bool bCopy
);
262 virtual Pointer
GetSdrDragPointer() const;
264 virtual basegfx::B2DHomMatrix
getCurrentTransformation();
265 virtual void applyCurrentTransformationToSdrObject(SdrObject
& rTarget
);
268 ////////////////////////////////////////////////////////////////////////////////////////////////////
271 class SVX_DLLPUBLIC SdrDragResize
: public SdrDragMethod
279 SdrDragResize(SdrDragView
& rNewView
);
281 virtual void TakeSdrDragComment(String
& rStr
) const;
282 virtual bool BeginSdrDrag();
283 virtual void MoveSdrDrag(const Point
& rPnt
);
284 virtual bool EndSdrDrag(bool bCopy
);
285 virtual Pointer
GetSdrDragPointer() const;
287 virtual basegfx::B2DHomMatrix
getCurrentTransformation();
288 virtual void applyCurrentTransformationToSdrObject(SdrObject
& rTarget
);
291 ////////////////////////////////////////////////////////////////////////////////////////////////////
294 class SVX_DLLPUBLIC SdrDragObjOwn
: public SdrDragMethod
297 // SdrDragObjOwn always works on a clone since it has no transformation
298 // mechanism to modify wireframe visualisations, but uses the
299 // SdrObject::applySpecialDrag() method to change a clone of the
304 virtual void createSdrDragEntries();
308 SdrDragObjOwn(SdrDragView
& rNewView
);
309 virtual ~SdrDragObjOwn();
311 virtual void TakeSdrDragComment(String
& rStr
) const;
312 virtual bool BeginSdrDrag();
313 virtual void MoveSdrDrag(const Point
& rPnt
);
314 virtual bool EndSdrDrag(bool bCopy
);
315 virtual Pointer
GetSdrDragPointer() const;
318 #endif //_SVDDRGMT_HXX
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */