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