LibreOffice Module svx (master) 1
svddrag.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_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.
36class SdrHdl;
37class SdrView;
38class SdrPageView;
39class SdrDragMethod;
40
42{
43 virtual ~SdrDragStatUserData() = 0;
44};
45
47{
48 SdrHdl* pHdl; // The Handle for the User
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
57
63
64 bool bShown; // Xor visible?
65 sal_uInt16 nMinMov; // So much has to be minimally moved first
66 bool bMinMoved; // MinMove surpassed?
67
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;
74
76 std::unique_ptr<SdrDragStatUserData> mpUserData; // Userdata
77
78 void Clear();
79
80 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
92public:
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; }
117
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; }
122
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; }
127
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; }
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 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; }
140
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; }
148
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; }
152
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;
162
163 SdrDragMethod* GetDragMethod() const { return pDragMethod; }
164 void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; }
165
166 const tools::Rectangle& GetActionRect() const { return aActionRect; }
167 void SetActionRect(const tools::Rectangle& rR) { aActionRect=rR; }
168
169 // Also considering 1stPointAsCenter
170 void TakeCreateRect(tools::Rectangle& rRect) const;
171
172 auto& GetGlueOptions() { return mGlueOptions; }
173};
174
175#endif // INCLUDED_SVX_SVDDRAG_HXX
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetView(SdrView *pV)
Definition: svddrag.hxx:97
bool bOrtho8
Definition: svddrag.hxx:73
const Point & GetPoint(sal_Int32 nNum) const
Definition: svddrag.hxx:100
const Point & GetRef2() const
Definition: svddrag.hxx:109
SdrHdl * pHdl
Definition: svddrag.hxx:48
bool IsOrtho4Possible() const
Definition: svddrag.hxx:135
bool bVerFixed
Definition: svddrag.hxx:69
std::unique_ptr< SdrDragStatUserData > mpUserData
Definition: svddrag.hxx:76
bool mbEndDragChangesLayout
Table row drag: table will re-layout itself later.
Definition: svddrag.hxx:61
bool bEndDragChangesGeoAndAttributes
Definition: svddrag.hxx:59
void SetNow(Point const &pt)
Definition: svddrag.hxx:106
auto & GetGlueOptions()
Definition: svddrag.hxx:172
const Point & GetPos0() const
Definition: svddrag.hxx:104
Point aRef1
Definition: svddrag.hxx:52
void SetUser(std::unique_ptr< SdrDragStatUserData > pU)
Definition: svddrag.hxx:114
void SetActionRect(const tools::Rectangle &rR)
Definition: svddrag.hxx:167
void SetDragMethod(SdrDragMethod *pMth)
Definition: svddrag.hxx:164
bool bHorFixed
Definition: svddrag.hxx:68
bool bMouseIsUp
Definition: svddrag.hxx:62
sal_Int32 GetPointCount() const
Definition: svddrag.hxx:101
bool IsMinMoved() const
Definition: svddrag.hxx:118
bool IsEndDragChangesLayout() const
Definition: svddrag.hxx:146
bool IsNoSnap() const
Definition: svddrag.hxx:130
void SetRef2(const Point &pt)
Definition: svddrag.hxx:110
SdrDragStatUserData * GetUser() const
Definition: svddrag.hxx:113
bool IsHorFixed() const
Definition: svddrag.hxx:123
const Point & GetRef1() const
Definition: svddrag.hxx:107
bool bMinMoved
Definition: svddrag.hxx:66
bool IsEndDragChangesGeoAndAttributes() const
Definition: svddrag.hxx:144
bool bEndDragChangesAttributes
Definition: svddrag.hxx:58
bool bShown
Definition: svddrag.hxx:64
bool IsOrtho8Possible() const
Definition: svddrag.hxx:138
tools::Long GetDY() const
Definition: svddrag.hxx:159
std::vector< Point > mvPnts
Definition: svddrag.hxx:51
void SetOrtho4Possible(bool bOn=true)
Definition: svddrag.hxx:136
const Point & GetStart() const
Definition: svddrag.hxx:102
SdrDragMethod * GetDragMethod() const
Definition: svddrag.hxx:163
bool IsVerFixed() const
Definition: svddrag.hxx:125
SdrView * GetView() const
Definition: svddrag.hxx:96
void SetHorFixed(bool bOn)
Definition: svddrag.hxx:124
void SetMouseDown(bool bDown)
Definition: svddrag.hxx:151
void SetMinMoved()
Definition: svddrag.hxx:119
void SetEndDragChangesGeoAndAttributes(bool bOn)
Definition: svddrag.hxx:145
void SetPageView(SdrPageView *pPV)
Definition: svddrag.hxx:99
void SetVerFixed(bool bOn)
Definition: svddrag.hxx:126
const SdrHdl * GetHdl() const
Definition: svddrag.hxx:111
Point aPos0
Definition: svddrag.hxx:54
SdrView * pView
Definition: svddrag.hxx:49
const Point & GetNow() const
Definition: svddrag.hxx:105
bool bOrtho4
Definition: svddrag.hxx:72
SdrPageView * pPageView
Definition: svddrag.hxx:50
void SetNoSnap(bool bOn=true)
Definition: svddrag.hxx:131
bool IsMouseDown() const
Definition: svddrag.hxx:150
void SetOrtho8Possible(bool bOn=true)
Definition: svddrag.hxx:139
Point aRef2
Definition: svddrag.hxx:53
SdrPageView * GetPageView() const
Definition: svddrag.hxx:98
void SetEndDragChangesAttributes(bool bOn)
Definition: svddrag.hxx:143
void SetHdl(SdrHdl *pH)
Definition: svddrag.hxx:112
tools::Long GetDX() const
Definition: svddrag.hxx:158
SdrDragMethod * pDragMethod
Definition: svddrag.hxx:75
const tools::Rectangle & GetActionRect() const
Definition: svddrag.hxx:166
sal_uInt16 nMinMov
Definition: svddrag.hxx:65
sal_Int32 GetPrevPos() const
Definition: svddrag.hxx:80
const Point & GetPrev() const
Definition: svddrag.hxx:103
void SetShown(bool bOn)
Definition: svddrag.hxx:116
void ResetMinMoved()
Definition: svddrag.hxx:120
bool IsShown() const
Definition: svddrag.hxx:115
void SetMinMove(sal_uInt16 nDist)
Definition: svddrag.hxx:121
bool IsEndDragChangesAttributes() const
Definition: svddrag.hxx:142
tools::Rectangle aActionRect
Definition: svddrag.hxx:56
Point aRealNow
Definition: svddrag.hxx:55
void SetEndDragChangesLayout(bool bOn)
Definition: svddrag.hxx:147
bool bWantNoSnap
Definition: svddrag.hxx:70
void SetRef1(const Point &pt)
Definition: svddrag.hxx:108
void Clear(EHistoryType eHistory)
long Long
virtual ~SdrDragStatUserData()=0
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35