LibreOffice Module svx (master) 1
svdsnpv.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#pragma once
21
22#include <svx/svdpntv.hxx>
23#include <svx/svdhlpln.hxx>
24#include <svx/svxdllapi.h>
25#include <tools/degree.hxx>
27
71enum class SdrSnap
72{
73 NOTSNAPPED = 0x00,
74 XSNAPPED = 0x01,
75 YSNAPPED = 0x02
76};
77namespace o3tl
78{
79 template<> struct typed_flags<SdrSnap> : is_typed_flags<SdrSnap, 3> {};
80}
81
82// TODO SdrCrookMode::Stretch is not implemented yet!
83enum class SdrCrookMode {
84 Rotate,
85 Slant,
87};
88
89
90// #114409#-1 Migrate PageOrigin
92
94{
95protected:
96 // #114409#-1 Migrate PageOrigin
98
99 // #114409#-2 Migrate HelpLine
101
105
106 sal_uInt16 nMagnSizPix;
109
111
112 bool bSnapEnab : 1;
113 bool bGridSnap : 1;
114 bool bBordSnap : 1;
115 bool bHlplSnap : 1;
116 bool bOFrmSnap : 1;
117 bool bOPntSnap : 1;
118 bool bOConSnap : 1;
119 bool bMoveSnapOnlyTopLeft : 1; // Special for dialogeditor
120 bool bOrtho : 1;
121 bool bBigOrtho : 1;
123 bool bMoveOnlyDragging : 1; // only move objects while Resize/Rotate/...
124 bool bSlantButShear : 1; // use slant instead of shear
125 bool bCrookNoContortion : 1; // no contorsion while Crook
127
128protected:
129 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
131 SdrModel& rSdrModel,
132 OutputDevice* pOut);
133
134 virtual ~SdrSnapView() override;
135
136public:
137 virtual bool IsAction() const override;
138 virtual void MovAction(const Point& rPnt) override;
139 virtual void EndAction() override;
140 virtual void BckAction() override;
141 virtual void BrkAction() override; // break actions for derived classes e.g. interrupt dragging.
142 virtual void TakeActionRect(tools::Rectangle& rRect) const override;
143
144 void SetSnapGridWidth(const Fraction& rX, const Fraction& rY) { aSnapWdtX=rX; aSnapWdtY=rY; }
145 const Fraction& GetSnapGridWidthX() const { return aSnapWdtX; }
146 const Fraction& GetSnapGridWidthY() const { return aSnapWdtY; }
147
148 void SetSnapMagnetic(const Size& rSiz) { if (rSiz!=aMagnSiz) { aMagnSiz=rSiz; } }
149 void SetSnapMagneticPixel(sal_uInt16 nPix) { nMagnSizPix=nPix; }
150 sal_uInt16 GetSnapMagneticPixel() const { return nMagnSizPix; }
151
152 // RecalcLogicSnapMagnetic has to be called for every change of OutputDevices and every change of the MapMode!
153 void RecalcLogicSnapMagnetic(const OutputDevice& rOut) { SetSnapMagnetic(rOut.PixelToLogic(Size(nMagnSizPix,nMagnSizPix))); }
154 void SetActualWin(const OutputDevice* pWin) { SdrPaintView::SetActualWin(pWin); if (pWin!=nullptr) RecalcLogicSnapMagnetic(*pWin); }
155
156 // Coordinates referred to the view!
157 // Returnvalues are SdrSnap::NOTSNAPPED,SdrSnap::XSNAPPED,
158 // SdrSnap::YSNAPPED or SdrSnap::XYSNAPPED
159 SdrSnap SnapPos(Point& rPnt, const SdrPageView* pPV) const;
160 Point GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const;
161 void CheckSnap(const Point& rPt, tools::Long& nBestXSnap, tools::Long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const;
162
163 // All attitudes to snap are persistent.
164 bool IsSnapEnabled() const { return bSnapEnab; }
165 bool IsGridSnap() const { return bGridSnap; } // Snap to grid
166 bool IsBordSnap() const { return bBordSnap; } // Snap to border
167 bool IsHlplSnap() const { return bHlplSnap; } // Snap to auxiliary line
168 bool IsOFrmSnap() const { return bOFrmSnap; } // Snap to LogFram from surrounding drawing objects
169 bool IsOPntSnap() const { return bOPntSnap; } // Snap to distinct points from surrounding drawing objects
170 bool IsOConSnap() const { return bOConSnap; } // Snap to connectors of the drawing objects
171 void SetSnapEnabled(bool bOn) { bSnapEnab=bOn; }
172 void SetGridSnap(bool bOn) { bGridSnap=bOn; }
173 void SetBordSnap(bool bOn) { bBordSnap=bOn; }
174 void SetHlplSnap(bool bOn) { bHlplSnap=bOn; }
175 void SetOFrmSnap(bool bOn) { bOFrmSnap=bOn; }
176 void SetOPntSnap(bool bOn) { bOPntSnap=bOn; }
177 void SetOConSnap(bool bOn) { bOConSnap=bOn; }
178
179 // Usually every 4 corners of Object-SnapRects are snapped for Move-Dragging.
180 // The following attitudes e.g. if you only want to snap the left corner on the top (e.g. DialogEditor)
181 // persistent, Default=FALSE.
182 void SetMoveSnapOnlyTopLeft(bool bOn) { bMoveSnapOnlyTopLeft=bOn; }
183 bool IsMoveSnapOnlyTopLeft() const { return bMoveSnapOnlyTopLeft; }
184
185 // #114409#-1 Migrate PageOrigin
186 void BegSetPageOrg(const Point& rPnt);
187 void MovSetPageOrg(const Point& rPnt);
188 void EndSetPageOrg();
189 void BrkSetPageOrg();
190 bool IsSetPageOrg() const { return (nullptr != mpPageOriginOverlay); }
191
192 // HitTest. If sal_True, in rnHelpLineNum is the number of the auxiliary line and in rpPv
193 // the appended PageView.
194 bool PickHelpLine(const Point& rPnt, short nTol, const OutputDevice& rOut, sal_uInt16& rnHelpLineNum, SdrPageView*& rpPV) const;
195
196 // Move of an available auxiliary line. Use nHelpLineNum and pPV from PickHelpLine.
197 bool BegDragHelpLine(sal_uInt16 nHelpLineNum, SdrPageView* pPV);
198 // interactive insertion of a new auxiliary line
199 void BegDragHelpLine(const Point& rPnt, SdrHelpLineKind eNewKind);
200 PointerStyle GetDraggedHelpLinePointer() const;
201
202 // change the type of auxiliary line while dragging
203 // void SetDraggedHelpLineKind(SdrHelpLineKind eNewKind);
204 void MovDragHelpLine(const Point& rPnt);
205 bool EndDragHelpLine();
206 void BrkDragHelpLine();
207 bool IsDragHelpLine() const { return (nullptr != mpHelpLineOverlay); }
208
209 // SnapAngle is for angles in circle, RotateDragging, ...
210 // The snapping of an angle is beared down, if it is switched off
211 // with SetAngleSnapEnabled(sal_False)
212 // The snapping angles is independent of snapping coordinates
213 // and so independent of the attitude IsSnapEnabled()
214 // Only values should be specified for them is applied:
215 // 36000 modulo nAngle = 0
216 // Implemented for:
217 // - Rotate (Dragging)
218 // - Shear (Dragging)
219 // - circular arc/-sector/-section angle (Create and Dragging)
220 // persistent.
221 void SetAngleSnapEnabled(bool bOn) { bAngleSnapEnab=bOn; }
222 bool IsAngleSnapEnabled() const { return bAngleSnapEnab; }
223 void SetSnapAngle(Degree100 nAngle) { nSnapAngle=nAngle; }
224 Degree100 GetSnapAngle() const { return nSnapAngle; }
225
226 // different effects from Ortho (depending on the context):
227 // - Create
228 // - only lines in 45deg grid
229 // - instead of rectangles squares are created
230 // - instead of ellipse circles are created
231 // - Dragging
232 // - general Dragging
233 // - Move only horizontal, vertical or 45deg
234 // - Resize proportional
235 // - Mirror: nothing
236 // - Shear without Resize
237 // - Crook without Resize
238 // - move handles
239 // - mirror axis only 45deg grid
240 // - object-specific Dragging
241 // - rectangle corner radius: nothing
242 // - circle object angle: nothing
243 // - line keeps while Dragging the angle and is only stretched/ contracted
244 // Default value for Ortho is off. persistent.
245 void SetOrtho(bool bOn) { bOrtho=bOn; } // incomplete
246 bool IsOrtho() const { return bOrtho; }
247
248 // BigOrtho is only relevant if Ortho is switched on.
249 // Example: rectangle is created and ortho is switched on (--> square)
250 // and the Mouse was dragged from zero to the coordinates
251 // (80,30). Now there are 2 alternatives to determine the edge length
252 // of the square: 30 and 80.
253 // The standard Ortho-Function took 30 (every time the smaller length)
254 // If BigOrtho is switched on, you get a square with edge length of 80.
255 // The same also applies to Resize.
256 // Default value for BigOrtho is on. persistent.
257 void SetBigOrtho(bool bOn) { bBigOrtho=bOn; }
258 bool IsBigOrtho() const { return bBigOrtho; }
259
260 // If MoveOnlyDragging=sal_True only the center of the marked objects is
261 // transformed when Resize/Rotate/Shear/Mirror/Crook is executed.
262 // Size, form and rotation angle of the objects are conserved only their positions
263 // are changed. persistent. Default=FALSE. (ni)
264 void SetMoveOnlyDragging(bool bOn) { bMoveOnlyDragging=bOn; }
265 bool IsMoveOnlyDragging() const { return bMoveOnlyDragging; }
266
267 // Use Slant instead of Shear. persistent. Default=FALSE.
268 void SetSlantButShear(bool bOn) { bSlantButShear=bOn; }
269 bool IsSlantButShear() const { return bSlantButShear; }
270
271 // Don't contort objecte while Crook. persistent. Default=FALSE. (ni)
272 void SetCrookNoContortion(bool bOn) { bCrookNoContortion=bOn; }
273 bool IsCrookNoContortion() const { return bCrookNoContortion; }
274
275 // Crook-Mode. persistent. Default=SdrCrookMode::Rotate. (ni)
276 void SetCrookMode(SdrCrookMode eMode) { eCrookMode=eMode; }
277 SdrCrookMode GetCrookMode() const { return eCrookMode; }
278
279 // Special for IBM: While Dragging of a traverse station, it is deleted
280 // if its adjacent lines are almost a solid line.
281 void SetEliminatePolyPoints(bool bOn) { bEliminatePolyPoints=bOn; }
282 bool IsEliminatePolyPoints() const { return bEliminatePolyPoints; }
283 void SetEliminatePolyPointLimitAngle(Degree100 nAngle) { nEliminatePolyPointLimitAngle=nAngle; }
284 Degree100 GetEliminatePolyPointLimitAngle() const { return nEliminatePolyPointLimitAngle; }
285};
286
287/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
virtual void MovAction(const Point &rPnt)
Definition: svdpntv.cxx:277
virtual void BrkAction()
Definition: svdpntv.cxx:289
virtual void BckAction()
Definition: svdpntv.cxx:285
virtual void EndAction()
Definition: svdpntv.cxx:281
virtual void TakeActionRect(tools::Rectangle &rRect) const
Definition: svdpntv.cxx:293
virtual bool IsAction() const
Definition: svdpntv.cxx:272
void SetActualWin(const OutputDevice *pWin)
Definition: svdpntv.cxx:340
Size aMagnSiz
Definition: svdsnpv.hxx:102
bool IsCrookNoContortion() const
Definition: svdsnpv.hxx:273
void SetOFrmSnap(bool bOn)
Definition: svdsnpv.hxx:175
Degree100 GetEliminatePolyPointLimitAngle() const
Definition: svdsnpv.hxx:284
bool bSlantButShear
Definition: svdsnpv.hxx:124
bool bOConSnap
Definition: svdsnpv.hxx:118
bool IsBigOrtho() const
Definition: svdsnpv.hxx:258
void SetSnapGridWidth(const Fraction &rX, const Fraction &rY)
Definition: svdsnpv.hxx:144
void SetOPntSnap(bool bOn)
Definition: svdsnpv.hxx:176
void SetSnapMagneticPixel(sal_uInt16 nPix)
Definition: svdsnpv.hxx:149
bool IsSetPageOrg() const
Definition: svdsnpv.hxx:190
class ImplPageOriginOverlay * mpPageOriginOverlay
Definition: svdsnpv.hxx:97
void SetHlplSnap(bool bOn)
Definition: svdsnpv.hxx:174
bool bBordSnap
Definition: svdsnpv.hxx:114
Fraction aSnapWdtX
Definition: svdsnpv.hxx:103
bool bOFrmSnap
Definition: svdsnpv.hxx:116
bool IsMoveSnapOnlyTopLeft() const
Definition: svdsnpv.hxx:183
bool IsOrtho() const
Definition: svdsnpv.hxx:246
const Fraction & GetSnapGridWidthY() const
Definition: svdsnpv.hxx:146
void SetBordSnap(bool bOn)
Definition: svdsnpv.hxx:173
void SetGridSnap(bool bOn)
Definition: svdsnpv.hxx:172
void SetSnapAngle(Degree100 nAngle)
Definition: svdsnpv.hxx:223
void SetOrtho(bool bOn)
Definition: svdsnpv.hxx:245
void SetSnapEnabled(bool bOn)
Definition: svdsnpv.hxx:171
class ImplHelpLineOverlay * mpHelpLineOverlay
Definition: svdsnpv.hxx:100
bool IsHlplSnap() const
Definition: svdsnpv.hxx:167
bool bOrtho
Definition: svdsnpv.hxx:120
void SetAngleSnapEnabled(bool bOn)
Definition: svdsnpv.hxx:221
bool IsAngleSnapEnabled() const
Definition: svdsnpv.hxx:222
bool IsSnapEnabled() const
Definition: svdsnpv.hxx:164
bool bEliminatePolyPoints
Definition: svdsnpv.hxx:126
bool IsOFrmSnap() const
Definition: svdsnpv.hxx:168
Degree100 GetSnapAngle() const
Definition: svdsnpv.hxx:224
bool IsGridSnap() const
Definition: svdsnpv.hxx:165
bool IsOPntSnap() const
Definition: svdsnpv.hxx:169
void SetBigOrtho(bool bOn)
Definition: svdsnpv.hxx:257
void SetMoveOnlyDragging(bool bOn)
Definition: svdsnpv.hxx:264
bool bOPntSnap
Definition: svdsnpv.hxx:117
void SetEliminatePolyPointLimitAngle(Degree100 nAngle)
Definition: svdsnpv.hxx:283
void SetMoveSnapOnlyTopLeft(bool bOn)
Definition: svdsnpv.hxx:182
bool IsMoveOnlyDragging() const
Definition: svdsnpv.hxx:265
bool IsOConSnap() const
Definition: svdsnpv.hxx:170
bool IsDragHelpLine() const
Definition: svdsnpv.hxx:207
Fraction aSnapWdtY
Definition: svdsnpv.hxx:104
const Fraction & GetSnapGridWidthX() const
Definition: svdsnpv.hxx:145
void SetEliminatePolyPoints(bool bOn)
Definition: svdsnpv.hxx:281
bool IsBordSnap() const
Definition: svdsnpv.hxx:166
void SetOConSnap(bool bOn)
Definition: svdsnpv.hxx:177
bool bBigOrtho
Definition: svdsnpv.hxx:121
SdrCrookMode GetCrookMode() const
Definition: svdsnpv.hxx:277
SdrCrookMode eCrookMode
Definition: svdsnpv.hxx:110
bool bSnapEnab
Definition: svdsnpv.hxx:112
bool bCrookNoContortion
Definition: svdsnpv.hxx:125
sal_uInt16 nMagnSizPix
Definition: svdsnpv.hxx:106
void SetCrookNoContortion(bool bOn)
Definition: svdsnpv.hxx:272
bool bGridSnap
Definition: svdsnpv.hxx:113
void SetSnapMagnetic(const Size &rSiz)
Definition: svdsnpv.hxx:148
sal_uInt16 GetSnapMagneticPixel() const
Definition: svdsnpv.hxx:150
void SetActualWin(const OutputDevice *pWin)
Definition: svdsnpv.hxx:154
bool bAngleSnapEnab
Definition: svdsnpv.hxx:122
Degree100 nSnapAngle
Definition: svdsnpv.hxx:107
Degree100 nEliminatePolyPointLimitAngle
Definition: svdsnpv.hxx:108
bool IsSlantButShear() const
Definition: svdsnpv.hxx:269
void RecalcLogicSnapMagnetic(const OutputDevice &rOut)
Definition: svdsnpv.hxx:153
bool IsEliminatePolyPoints() const
Definition: svdsnpv.hxx:282
bool bMoveSnapOnlyTopLeft
Definition: svdsnpv.hxx:119
void SetSlantButShear(bool bOn)
Definition: svdsnpv.hxx:268
bool bMoveOnlyDragging
Definition: svdsnpv.hxx:123
bool bHlplSnap
Definition: svdsnpv.hxx:115
void SetCrookMode(SdrCrookMode eMode)
Definition: svdsnpv.hxx:276
Mode eMode
long Long
PointerStyle
SdrHelpLineKind
Definition: svdhlpln.hxx:34
SdrSnap
Definition:
Definition: svdsnpv.hxx:72
SdrCrookMode
Definition: svdsnpv.hxx:83
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35