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_SVDDRGV_HXX
21 #define INCLUDED_SVX_SVDDRGV_HXX
23 #include <svx/svxdllapi.h>
24 #include <svx/svdxcgv.hxx>
28 class SVX_DLLPUBLIC SdrDragView
: public SdrExchangeView
30 friend class SdrPageView
;
31 friend class SdrDragMethod
;
35 SdrDragMethod
* mpCurrentSdrDragMethod
;
36 SdrUndoGeoObj
* mpInsPointUndo
;
37 tools::Rectangle maDragLimit
;
38 OUString maInsPointUndoStr
;
41 sal_uIntPtr mnDragXorPolyLimit
;
42 sal_uIntPtr mnDragXorPointLimit
;
43 sal_uInt16 mnDetailedEdgeDraggingLimit
;
45 bool mbFramDrag
: 1; // currently frame dragging
46 bool mbDragSpecial
: 1; // currently Special Obj-dragging
47 bool mbMarkedHitMovesAlways
: 1; // Persistent
48 bool mbDragLimit
: 1; // Limit on SnapRect instead of BoundRect
49 bool mbDragHdl
: 1; // TRUE: RefPt is slid
50 bool mbDragStripes
: 1; // Persistent
51 bool mbSolidDragging
: 1; // allow solid create/drag of objects
52 bool mbResizeAtCenter
: 1;
53 bool mbCrookAtCenter
: 1;
54 bool mbDragWithCopy
: 1;
55 bool mbInsGluePoint
: 1;
56 bool mbInsObjPointMode
: 1;
57 bool mbInsGluePointMode
: 1;
58 bool mbNoDragXorPolys
: 1;
61 SVX_DLLPRIVATE
void ImpClearVars();
64 virtual void SetMarkHandles(SfxViewShell
* pOtherShell
) override
;
67 bool ImpBegInsObjPoint(bool bIdxZwang
, const Point
& rPnt
, bool bNewObj
, OutputDevice
* pOut
);
70 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
71 SdrDragView(SdrModel
* pModel1
, OutputDevice
* pOut
);
72 virtual ~SdrDragView() override
;
75 virtual bool IsAction() const override
;
76 virtual void MovAction(const Point
& rPnt
) override
;
77 virtual void EndAction() override
;
78 virtual void BckAction() override
;
79 virtual void BrkAction() override
;
80 virtual void TakeActionRect(tools::Rectangle
& rRect
) const override
;
82 // special implementation for Writer:
83 // TakeDragObjAnchorPos() returns the position at which an object
84 // approximately ends up during dragging when it is "released"
86 // As a general rule, this is the left upper corner of the expected
87 // new SnapRect. Exception: CaptionObj. There, it is the position
89 // In case of return value 'false', the position could not be
90 // determined (e.g. point shift, multiple selection, shift of the
92 bool TakeDragObjAnchorPos(Point
& rPos
, bool bTopRight
) const;
94 // If pForcedMeth is passed, then pHdl, ... is not evaluated, but this Drag
95 // method is used. In this, the ownership of the instance passes
96 // to the View and is destroyed at the end of the dragging.
97 virtual bool BegDragObj(const Point
& rPnt
, OutputDevice
* pOut
, SdrHdl
* pHdl
, short nMinMov
=-3, SdrDragMethod
* pForcedMeth
=nullptr);
98 void MovDragObj(const Point
& rPnt
);
99 bool EndDragObj(bool bCopy
=false);
101 bool IsDragObj() const { return mpCurrentSdrDragMethod
&& !mbInsPolyPoint
&& !mbInsGluePoint
; }
102 SdrHdl
* GetDragHdl() const { return mpDragHdl
; }
103 SdrDragMethod
* GetDragMethod() const { return mpCurrentSdrDragMethod
; }
104 bool IsDraggingPoints() const { return meDragHdl
==SdrHdlKind::Poly
; }
105 bool IsDraggingGluePoints() const { return meDragHdl
==SdrHdlKind::Glue
; }
107 // If you want to define that already during BegDrag
109 // (Is reset to 'false' on each BegDrag, so set it after BegDrag.)
110 void SetDragWithCopy(bool bOn
) { mbDragWithCopy
= bOn
; }
111 bool IsDragWithCopy() const { return mbDragWithCopy
; }
113 void SetInsertGluePoint(bool bOn
) { mbInsGluePoint
= bOn
; }
114 bool IsInsertGluePoint() const { return mbInsGluePoint
; }
116 // Interactive insertion of a new point. nIdx=0 => in front of the first point
117 bool IsInsObjPointPossible() const;
118 bool BegInsObjPoint(const Point
& rPnt
, bool bNewObj
) { return ImpBegInsObjPoint(false, rPnt
, bNewObj
, nullptr); }
119 void MovInsObjPoint(const Point
& rPnt
) { MovDragObj(rPnt
); }
120 bool EndInsObjPoint(SdrCreateCmd eCmd
);
121 bool IsInsObjPoint() const { return mpCurrentSdrDragMethod
&& mbInsPolyPoint
; }
123 // For the app to manage the status. GetPreferredPointer() is
124 // possibly going to deliver a matching pointer for it.
125 void SetInsObjPointMode(bool bOn
) { mbInsObjPointMode
= bOn
; }
126 bool IsInsObjPointMode() const { return mbInsObjPointMode
; }
128 bool IsInsGluePointPossible() const;
129 bool BegInsGluePoint(const Point
& rPnt
);
130 bool IsInsGluePoint() const { return mpCurrentSdrDragMethod
&& mbInsGluePoint
; }
132 // For the app to manage the status. GetPreferredPointer() is
133 // possibly going to deliver a matching pointer for it.
134 void SetInsGluePointMode(bool bOn
) { mbInsGluePointMode
= bOn
; }
135 bool IsInsGluePointMode() const { return mbInsGluePointMode
; }
137 // border lines over the whole win persistent during the
138 // whole dragging. Default=FALSE.
139 void SetDragStripes(bool bOn
);
140 bool IsDragStripes() const { return mbDragStripes
; }
142 // As a general rule, the contours of the selected objects
143 // are displayed as Xor-polygons. If this flag is set, only one
144 // Xor-Frame is drawn (e.g. in case of multiple selection).
145 // In case of object-specific dragging (polygon points, corner radius,...),
146 // this setting has no influence.
147 // Also changeable during the dragging.
149 void SetNoDragXorPolys(bool bOn
);
150 bool IsNoDragXorPolys() const { return mbNoDragXorPolys
; }
152 // If the number of selected objects exceeds the value set here,
153 // NoDragPolys is (temporarily) activated implicitly.
154 // PolyPolygons etc. are regarded as multiple objects respectively.
156 sal_uIntPtr
GetDragXorPolyLimit() const { return mnDragXorPolyLimit
; }
158 // Like DragXorPolyLimit, but in respect to the total number of
159 // all polygons. Default=500.
160 // NoDragPolys is (temporarily) activated, if one of the limits
162 sal_uIntPtr
GetDragXorPointLimit() const { return mnDragXorPointLimit
; }
164 void SetSolidDragging(bool bOn
);
165 bool IsSolidDragging() const;
167 // Connector handling is thus as follows (when using default settings):
168 // - If at most 10 Connectors are affected, they are recalculated
169 // on each MouseMove.
170 // - If 11 to 100 Connectors are affected, the connections
171 // are shown as straight lines while dragging.
172 // - In case of more than 100 affected Connectors, nothing that refers
173 // to the Connectors is drawn while dragging.
175 // If a special drag mode like Rotate, Mirror or Crook is enabled,
176 // then a Hit on the selected object triggers exactly this dragging.
177 // If MarkedHitMovesAlways is set to 'true', a Hit on the selected
178 // object always triggers a Move, independent of the DragMode that is
179 // set. This flag is persistent and should be configurable in the app
181 void SetMarkedHitMovesAlways(bool bOn
) { mbMarkedHitMovesAlways
= bOn
; }
182 bool IsMarkedHitMovesAlways() const { return mbMarkedHitMovesAlways
; }
184 bool IsOrthoDesired() const;
186 // center as reference on Resize
188 bool IsResizeAtCenter() const { return mbResizeAtCenter
; }
189 void SetResizeAtCenter(bool bOn
) { mbResizeAtCenter
= bOn
; }
193 bool IsCrookAtCenter() const { return mbCrookAtCenter
; }
194 void SetCrookAtCenter(bool bOn
) { mbCrookAtCenter
= bOn
; }
196 // Limitation of the working area. The limitation refers to the View,
197 // not to the single PageViews. This limitation is only evaluated by
198 // the View on interactions like Dragging and Create.
199 // In case of actions controlled by the app through algorithms or
200 // UI-controlled actions (SetGeoAttr, MoveMarkedObj, ...), the
201 // app must honor this limit itself.
202 // Furthermore, this limit is to be seen as a rough limit. In certain
203 // cases (e.g. while rotating), objects cannot be dragged exactly
204 // up to this limit, objects can overlap a bit because of rounding
206 // Default=EmptyRect=no limitation
207 // only partially implemented
208 void SetWorkArea(const tools::Rectangle
& rRect
) { maMaxWorkArea
=rRect
; }
209 const tools::Rectangle
& GetWorkArea() const { return maMaxWorkArea
; }
212 // The DragLimit refers to the Page of the object.
213 // (TODO or to the View?? - must be researched...)
214 // 'false' = no limit
215 // The return Rect must contain absolute coordinates. The maximum
216 // drag area is then selected by the View in a way that the object's
217 // SnapRect is moved or resized at most up to the corner of the
218 // LimitRect. For objects like Bezier curves, rotated rectangles,
219 // it must be taken into account that because of subsequent
220 // recalculation of the SnapRect (on Resize), rounding errors can
221 // occur, because of which the LimitRect might be exceeded by a
222 // very small extent....
223 // Implemented for Move and Resize
224 virtual bool TakeDragLimit(SdrDragMode eMode
, tools::Rectangle
& rRect
) const;
227 #endif // INCLUDED_SVX_SVDDRGV_HXX
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */