Bump version to 21.06.18.1
[LibreOffice.git] / include / svx / svddrag.hxx
blob6718e5f36b5dc5fc248f7878f47091b76638b1e3
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_SVDDRAG_HXX
21 #define INCLUDED_SVX_SVDDRAG_HXX
24 #include <tools/gen.hxx>
25 #include <tools/fract.hxx>
26 #include <svx/svxdllapi.h>
28 #include <memory>
29 #include <vector>
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;
41 struct SdrDragStatUserData
43 virtual ~SdrDragStatUserData() = 0;
46 class SVXCORE_DLLPUBLIC SdrDragStat final
48 SdrHdl* pHdl; // The Handle for the User
49 SdrView* pView;
50 SdrPageView* pPageView;
51 std::vector<Point> mvPnts; // All previous Points: [0]=Start, [Count()-2]=Prev
52 Point aRef1; // Referencepoint: Resize fixed point, (axis of rotation,
53 Point aRef2; // axis of reflection, ...)
54 Point aPos0; // Position at the last Event
55 Point aRealNow; // Current dragging position without Snap, Ortho and Limit
56 tools::Rectangle aActionRect;
58 bool bEndDragChangesAttributes;
59 bool bEndDragChangesGeoAndAttributes;
60 /// Table row drag: table will re-layout itself later.
61 bool mbEndDragChangesLayout;
62 bool bMouseIsUp;
64 bool bShown; // Xor visible?
65 sal_uInt16 nMinMov; // So much has to be minimally moved first
66 bool bMinMoved; // MinMove surpassed?
68 bool bHorFixed; // Dragging only vertical
69 bool bVerFixed; // Dragging only horizontal
70 bool bWantNoSnap; // To decide if pObj-> MovCreate () should use NoSnapPos or not.
71 // Therefore, NoSnapPos is written into the buffer.
72 bool bOrtho4;
73 bool bOrtho8;
75 SdrDragMethod* pDragMethod;
76 std::unique_ptr<SdrDragStatUserData> mpUserData; // Userdata
78 void Clear();
80 sal_Int32 GetPrevPos() const { return mvPnts.size()-(mvPnts.size()>1 ? 2 : 1); }
82 // This is passed all the way through to ApplySpecialDrag of the Edge Object
83 // For LOK, we cannot really specify which glue point to select by default
84 // It selects the nearest glue points after DragEnd event.
85 // When multiple objects are on top of each other or somehow their glue points
86 // collide, the glue point 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;
92 public:
93 SdrDragStat() { Reset(); }
94 ~SdrDragStat();
95 void Reset();
96 SdrView* GetView() const { return pView; }
97 void SetView(SdrView* pV) { pView=pV; }
98 SdrPageView* GetPageView() const { return pPageView; }
99 void SetPageView(SdrPageView* pPV) { pPageView=pPV; }
100 const Point& GetPoint(sal_Int32 nNum) const { return mvPnts[nNum]; }
101 sal_Int32 GetPointCount() const { return mvPnts.size(); }
102 const Point& GetStart() const { return mvPnts[0]; }
103 const Point& GetPrev() const { return mvPnts[GetPrevPos()]; }
104 const Point& GetPos0() const { return aPos0; }
105 const Point& GetNow() const { return mvPnts.back(); }
106 void SetNow(Point const &pt) { mvPnts.back() = pt; }
107 const Point& GetRef1() const { return aRef1; }
108 void SetRef1(const Point &pt) { aRef1 = pt; }
109 const Point& GetRef2() const { return aRef2; }
110 void SetRef2(const Point &pt) { aRef2 = pt; }
111 const SdrHdl* GetHdl() const { return pHdl; }
112 void SetHdl(SdrHdl* pH) { pHdl=pH; }
113 SdrDragStatUserData* GetUser() const { return mpUserData.get(); }
114 void SetUser(std::unique_ptr<SdrDragStatUserData> pU) { mpUserData = std::move(pU); }
115 bool IsShown() const { return bShown; }
116 void SetShown(bool bOn) { bShown=bOn; }
118 bool IsMinMoved() const { return bMinMoved; }
119 void SetMinMoved() { bMinMoved=true; }
120 void ResetMinMoved() { bMinMoved=false; }
121 void SetMinMove(sal_uInt16 nDist) { nMinMov=nDist; if (nMinMov<1) nMinMov=1; }
123 bool IsHorFixed() const { return bHorFixed; }
124 void SetHorFixed(bool bOn) { bHorFixed=bOn; }
125 bool IsVerFixed() const { return bVerFixed; }
126 void SetVerFixed(bool bOn) { bVerFixed=bOn; }
128 // Here, the object can say: "I do not want to snap to coordinates!"
129 // for example, the angle of the arc ...
130 bool IsNoSnap() const { return bWantNoSnap; }
131 void SetNoSnap(bool bOn = true) { bWantNoSnap=bOn; }
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 bool IsOrtho4Possible() const { return bOrtho4; }
136 void SetOrtho4Possible(bool bOn = true) { bOrtho4=bOn; }
137 // Ortho8 means Ortho in 8 directions (for lines)
138 bool IsOrtho8Possible() const { return bOrtho8; }
139 void SetOrtho8Possible(bool bOn = true) { bOrtho8=bOn; }
141 // Is set by an object that was dragged.
142 bool IsEndDragChangesAttributes() const { return bEndDragChangesAttributes; }
143 void SetEndDragChangesAttributes(bool bOn) { bEndDragChangesAttributes=bOn; }
144 bool IsEndDragChangesGeoAndAttributes() const { return bEndDragChangesGeoAndAttributes; }
145 void SetEndDragChangesGeoAndAttributes(bool bOn) { bEndDragChangesGeoAndAttributes=bOn; }
146 bool IsEndDragChangesLayout() const { return mbEndDragChangesLayout; }
147 void SetEndDragChangesLayout(bool bOn) { mbEndDragChangesLayout=bOn; }
149 // Is set by the view and can be evaluated by Obj
150 bool IsMouseDown() const { return !bMouseIsUp; }
151 void SetMouseDown(bool bDown) { bMouseIsUp=!bDown; }
153 void Reset(const Point& rPnt);
154 void NextMove(const Point& rPnt);
155 void NextPoint();
156 void PrevPoint();
157 bool CheckMinMoved(const Point& rPnt);
158 tools::Long GetDX() const { return GetNow().X()-GetPrev().X(); }
159 tools::Long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
160 Fraction GetXFact() const;
161 Fraction GetYFact() const;
163 SdrDragMethod* GetDragMethod() const { return pDragMethod; }
164 void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; }
166 const tools::Rectangle& GetActionRect() const { return aActionRect; }
167 void SetActionRect(const tools::Rectangle& rR) { aActionRect=rR; }
169 // Also considering 1stPointAsCenter
170 void TakeCreateRect(tools::Rectangle& rRect) const;
172 auto& GetGlueOptions() { return mGlueOptions; }
175 #endif // INCLUDED_SVX_SVDDRAG_HXX
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */