/src/libreoffice/include/svx/svddrag.hxx
Line | Count | Source |
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_SVDDRAG_HXX |
21 | | #define INCLUDED_SVX_SVDDRAG_HXX |
22 | | |
23 | | |
24 | | #include <tools/gen.hxx> |
25 | | #include <tools/fract.hxx> |
26 | | #include <svx/svxdllapi.h> |
27 | | |
28 | | #include <memory> |
29 | | #include <vector> |
30 | | |
31 | | // Status information for specialized object dragging. In order for the model |
32 | | // to stay status free, the status data is kept on the View |
33 | | // and handed over to the object at the appropriate time as a parameter. |
34 | | // This also includes the status of the operation and Interactive |
35 | | // Object creation. In this case, pHdl is null. |
36 | | class SdrHdl; |
37 | | class SdrView; |
38 | | class SdrPageView; |
39 | | class SdrDragMethod; |
40 | | |
41 | | struct SdrDragStatUserData |
42 | | { |
43 | | virtual ~SdrDragStatUserData() = 0; |
44 | | }; |
45 | | |
46 | | class SVXCORE_DLLPUBLIC SdrDragStat final |
47 | | { |
48 | | SdrHdl* m_pHdl; // The Handle for the User |
49 | | SdrView* m_pView; |
50 | | SdrPageView* m_pPageView; |
51 | | std::vector<Point> mvPnts; // All previous Points: [0]=Start, [Count()-2]=Prev |
52 | | Point m_aRef1; // Referencepoint: Resize fixed point, (axis of rotation, |
53 | | Point m_aRef2; // axis of reflection, ...) |
54 | | Point m_aPos0; // Position at the last Event |
55 | | Point m_aRealNow; // Current dragging position without Snap, Ortho and Limit |
56 | | tools::Rectangle m_aActionRect; |
57 | | |
58 | | bool m_bEndDragChangesAttributes; |
59 | | bool m_bEndDragChangesGeoAndAttributes; |
60 | | /// Table row drag: table will re-layout itself later. |
61 | | bool mbEndDragChangesLayout; |
62 | | bool m_bMouseIsUp; |
63 | | |
64 | | bool m_bShown; // Xor visible? |
65 | | sal_uInt16 m_nMinMov; // So much has to be minimally moved first |
66 | | bool m_bMinMoved; // MinMove surpassed? |
67 | | |
68 | | bool m_bHorFixed; // Dragging only vertical |
69 | | bool m_bVerFixed; // Dragging only horizontal |
70 | | bool m_bWantNoSnap; // To decide if pObj-> MovCreate () should use NoSnapPos or not. |
71 | | // Therefore, NoSnapPos is written into the buffer. |
72 | | bool m_bOrtho4; |
73 | | bool m_bOrtho8; |
74 | | |
75 | | SdrDragMethod* m_pDragMethod; |
76 | | std::unique_ptr<SdrDragStatUserData> mpUserData; // Userdata |
77 | | |
78 | | SAL_DLLPRIVATE void Clear(); |
79 | | |
80 | 0 | sal_Int32 GetPrevPos() const { return mvPnts.size()-(mvPnts.size()>1 ? 2 : 1); } |
81 | | |
82 | | // This is passed all the way through to ApplySpecialDrag of the Edge Object |
83 | | // For LOK, we cannot really specify which gluepoint to select by default |
84 | | // It selects the nearest gluepoints after DragEnd event. |
85 | | // When multiple objects are on top of each other or somehow their gluepoints |
86 | | // collide, the gluepoint is selected from the lowest order numbered object |
87 | | // We can pass the ord number information inside the draginfo and choose the correct shape |
88 | | struct { |
89 | | sal_Int32 objectOrdNum = -1; |
90 | | } mGlueOptions; |
91 | | |
92 | | public: |
93 | 436k | SdrDragStat() { Reset(); } |
94 | | SAL_DLLPRIVATE ~SdrDragStat(); |
95 | | void Reset(); |
96 | 0 | SdrView* GetView() const { return m_pView; } |
97 | 0 | void SetView(SdrView* pV) { m_pView=pV; } |
98 | 0 | SdrPageView* GetPageView() const { return m_pPageView; } |
99 | 0 | void SetPageView(SdrPageView* pPV) { m_pPageView=pPV; } |
100 | 0 | const Point& GetPoint(sal_Int32 nNum) const { return mvPnts[nNum]; } |
101 | 0 | sal_Int32 GetPointCount() const { return mvPnts.size(); } |
102 | 0 | const Point& GetStart() const { return mvPnts[0]; } |
103 | 0 | const Point& GetPrev() const { return mvPnts[GetPrevPos()]; } |
104 | 0 | const Point& GetPos0() const { return m_aPos0; } |
105 | 0 | const Point& GetNow() const { return mvPnts.back(); } |
106 | 0 | void SetNow(Point const &pt) { mvPnts.back() = pt; } |
107 | 0 | const Point& GetRef1() const { return m_aRef1; } |
108 | 0 | void SetRef1(const Point &pt) { m_aRef1 = pt; } |
109 | 0 | const Point& GetRef2() const { return m_aRef2; } |
110 | 0 | void SetRef2(const Point &pt) { m_aRef2 = pt; } |
111 | 0 | const SdrHdl* GetHdl() const { return m_pHdl; } |
112 | 0 | void SetHdl(SdrHdl* pH) { m_pHdl=pH; } |
113 | 0 | SdrDragStatUserData* GetUser() const { return mpUserData.get(); } |
114 | 0 | void SetUser(std::unique_ptr<SdrDragStatUserData> pU) { mpUserData = std::move(pU); } |
115 | 0 | bool IsShown() const { return m_bShown; } |
116 | 0 | void SetShown(bool bOn) { m_bShown=bOn; } |
117 | | |
118 | 0 | bool IsMinMoved() const { return m_bMinMoved; } |
119 | 0 | void SetMinMoved() { m_bMinMoved=true; } |
120 | 0 | void ResetMinMoved() { m_bMinMoved=false; } |
121 | 0 | void SetMinMove(sal_uInt16 nDist) { m_nMinMov=nDist; if (m_nMinMov<1) m_nMinMov=1; } |
122 | | |
123 | 0 | bool IsHorFixed() const { return m_bHorFixed; } |
124 | 0 | void SetHorFixed(bool bOn) { m_bHorFixed=bOn; } |
125 | 0 | bool IsVerFixed() const { return m_bVerFixed; } |
126 | 0 | void SetVerFixed(bool bOn) { m_bVerFixed=bOn; } |
127 | | |
128 | | // Here, the object can say: "I do not want to snap to coordinates!" |
129 | | // for example, the angle of the arc ... |
130 | 0 | bool IsNoSnap() const { return m_bWantNoSnap; } |
131 | 0 | void SetNoSnap(bool bOn = true) { m_bWantNoSnap=bOn; } |
132 | | |
133 | | // And here the Obj say which Ortho (if there is one) can be usefully applied to him. |
134 | | // Ortho4 means Ortho in four directions (for Rect and CIRT) |
135 | 0 | bool IsOrtho4Possible() const { return m_bOrtho4; } |
136 | 0 | void SetOrtho4Possible(bool bOn = true) { m_bOrtho4=bOn; } |
137 | | // Ortho8 means Ortho in 8 directions (for lines) |
138 | 0 | bool IsOrtho8Possible() const { return m_bOrtho8; } |
139 | 0 | void SetOrtho8Possible(bool bOn = true) { m_bOrtho8=bOn; } |
140 | | |
141 | | // Is set by an object that was dragged. |
142 | 0 | bool IsEndDragChangesAttributes() const { return m_bEndDragChangesAttributes; } |
143 | 0 | void SetEndDragChangesAttributes(bool bOn) { m_bEndDragChangesAttributes=bOn; } |
144 | 0 | bool IsEndDragChangesGeoAndAttributes() const { return m_bEndDragChangesGeoAndAttributes; } |
145 | 0 | void SetEndDragChangesGeoAndAttributes(bool bOn) { m_bEndDragChangesGeoAndAttributes=bOn; } |
146 | 0 | bool IsEndDragChangesLayout() const { return mbEndDragChangesLayout; } |
147 | 0 | void SetEndDragChangesLayout(bool bOn) { mbEndDragChangesLayout=bOn; } |
148 | | |
149 | | // Is set by the view and can be evaluated by Obj |
150 | 0 | bool IsMouseDown() const { return !m_bMouseIsUp; } |
151 | 0 | void SetMouseDown(bool bDown) { m_bMouseIsUp=!bDown; } |
152 | | |
153 | | SAL_DLLPRIVATE void Reset(const Point& rPnt); |
154 | | void NextMove(const Point& rPnt); |
155 | | SAL_DLLPRIVATE void NextPoint(); |
156 | | SAL_DLLPRIVATE void PrevPoint(); |
157 | | bool CheckMinMoved(const Point& rPnt); |
158 | 0 | tools::Long GetDX() const { return GetNow().X()-GetPrev().X(); } |
159 | 0 | tools::Long GetDY() const { return GetNow().Y()-GetPrev().Y(); } |
160 | | Fraction GetXFact() const; |
161 | | Fraction GetYFact() const; |
162 | | |
163 | 0 | SdrDragMethod* GetDragMethod() const { return m_pDragMethod; } |
164 | 0 | void SetDragMethod(SdrDragMethod* pMth) { m_pDragMethod=pMth; } |
165 | | |
166 | 0 | const tools::Rectangle& GetActionRect() const { return m_aActionRect; } |
167 | 0 | void SetActionRect(const tools::Rectangle& rR) { m_aActionRect=rR; } |
168 | | |
169 | | // Also considering 1stPointAsCenter |
170 | | SAL_DLLPRIVATE void TakeCreateRect(tools::Rectangle& rRect) const; |
171 | | |
172 | 0 | auto& GetGlueOptions() { return mGlueOptions; } |
173 | | }; |
174 | | |
175 | | #endif // INCLUDED_SVX_SVDDRAG_HXX |
176 | | |
177 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |