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