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