Parameterize lower case PRODUCTNAME in odk/config/setsdkenv_windows.bat
[LibreOffice.git] / include / svx / svdsnpv.hxx
blob373bbf1d0fbbe5feb739a3f2bc46366dc3614389
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 #pragma once
22 #include <svx/svdpntv.hxx>
23 #include <svx/svdhlpln.hxx>
24 #include <svx/svxdllapi.h>
25 #include <tools/degree.hxx>
26 #include <o3tl/typed_flags_set.hxx>
28 /**
29 * Definition:
30 * - snap something means e.g. the mouse pointer or some marked objects in drag can be snapped
31 * - snap on something means you can e.g. snap on the grid or on auxiliary lines
34 * Basically, we only catch visible elements (borders, helper lines, connectors),
35 * with the exception of the grid. Likewise, we can only catch visible elements (i.e. connectors).
36 * We only catch on the grid, if nothing else is close by (magnetic behaviour).
38 * The cursor which is used during creation of objects, while dragging polygon points
39 * etc. (i.e. the mouse cursor) is always caught on all enabled catch alternatives (max 6).
41 * This is different, when moving selected objects. Instead of one mouse cursor, there are
42 * four alternatives, which can be caught at the selected objects:
43 * 1. the logically enclosing frame of every single object
44 * 2. the logically enclosing frame of all selected objects
45 * 3. highlighted points of all selected objects (polygon points, ...)
46 * 4. the connectors of the selected objects
48 * As the first and second case exclude each other (the second is a refinement of the first one)
49 * three alternatives remain, which are independent from each other. For 6 possible values for the
50 * caught ones, we would end up with max. 18 different possible combinations!
52 * Therefore, we introduce the following simplifications:
53 * 1. Connectors only catch on connectors
55 * Only max. 2*5+1 = 11 combinations remain for MoveDrag:
56 * 1-3. enclosing frame on grid/border/helper lines
57 * 4. enclosing frame on highlighted object points
58 * 5. enclosing frame on enclosing frame
59 * 6-8. highlighted points on grid/border/helper lines
60 * 7. highlighted points on highlighted object points
61 * 8-10. highlighted points on enclosing frame
62 * 11. connectors on connectors
64 * We test for all of these possible 11 combinations in the MouseMove event in the DragMove
65 * and those with the least need of correction are carried out.
67 * In the Resize() etc. methods we only catch the logically enclosing frame of the highlighted objects.
70 /** Return value for SnapPos() method */
71 enum class SdrSnap
73 NOTSNAPPED = 0x00,
74 XSNAPPED = 0x01,
75 YSNAPPED = 0x02
77 namespace o3tl
79 template<> struct typed_flags<SdrSnap> : is_typed_flags<SdrSnap, 3> {};
82 // TODO SdrCrookMode::Stretch is not implemented yet!
83 enum class SdrCrookMode {
84 Rotate,
85 Slant,
86 Stretch
90 // #114409#-1 Migrate PageOrigin
91 class ImplPageOriginOverlay;
93 class SVXCORE_DLLPUBLIC SdrSnapView : public SdrPaintView
95 protected:
96 // #114409#-1 Migrate PageOrigin
97 class ImplPageOriginOverlay* mpPageOriginOverlay;
99 // #114409#-2 Migrate HelpLine
100 class ImplHelpLineOverlay* mpHelpLineOverlay;
102 Size maMagnSiz;
103 Fraction maSnapWdtX;
104 Fraction maSnapWdtY;
106 sal_uInt16 mnMagnSizPix;
107 Degree100 mnSnapAngle;
108 Degree100 mnEliminatePolyPointLimitAngle;
110 SdrCrookMode meCrookMode;
112 bool mbSnapEnab : 1;
113 bool mbGridSnap : 1;
114 bool mbBordSnap : 1;
115 bool mbHlplSnap : 1;
116 bool mbOFrmSnap : 1;
117 bool mbOPntSnap : 1;
118 bool mbOConSnap : 1;
119 bool mbMoveSnapOnlyTopLeft : 1; // Special for dialogeditor
120 bool mbOrtho : 1;
121 bool mbBigOrtho : 1;
122 bool mbAngleSnapEnab : 1;
123 bool mbMoveOnlyDragging : 1; // only move objects while Resize/Rotate/...
124 bool mbSlantButShear : 1; // use slant instead of shear
125 bool mbCrookNoContortion : 1; // no contorsion while Crook
126 bool mbEliminatePolyPoints : 1;
128 protected:
129 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
130 SdrSnapView(
131 SdrModel& rSdrModel,
132 OutputDevice* pOut);
134 virtual ~SdrSnapView() override;
136 public:
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;
144 void SetSnapGridWidth(const Fraction& rX, const Fraction& rY) { maSnapWdtX=rX; maSnapWdtY=rY; }
145 const Fraction& GetSnapGridWidthX() const { return maSnapWdtX; }
146 const Fraction& GetSnapGridWidthY() const { return maSnapWdtY; }
148 void SetSnapMagnetic(const Size& rSiz) { if (rSiz!=maMagnSiz) { maMagnSiz=rSiz; } }
149 void SetSnapMagneticPixel(sal_uInt16 nPix) { mnMagnSizPix=nPix; }
150 sal_uInt16 GetSnapMagneticPixel() const { return mnMagnSizPix; }
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(mnMagnSizPix,mnMagnSizPix))); }
154 void SetActualWin(const OutputDevice* pWin) { SdrPaintView::SetActualWin(pWin); if (pWin!=nullptr) RecalcLogicSnapMagnetic(*pWin); }
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;
163 // All attitudes to snap are persistent.
164 bool IsSnapEnabled() const { return mbSnapEnab; }
165 bool IsGridSnap() const { return mbGridSnap; } // Snap to grid
166 bool IsBordSnap() const { return mbBordSnap; } // Snap to border
167 bool IsHlplSnap() const { return mbHlplSnap; } // Snap to auxiliary line
168 bool IsOFrmSnap() const { return mbOFrmSnap; } // Snap to LogFram from surrounding drawing objects
169 bool IsOPntSnap() const { return mbOPntSnap; } // Snap to distinct points from surrounding drawing objects
170 bool IsOConSnap() const { return mbOConSnap; } // Snap to connectors of the drawing objects
171 void SetSnapEnabled(bool bOn) { mbSnapEnab=bOn; }
172 void SetGridSnap(bool bOn) { mbGridSnap=bOn; }
173 void SetBordSnap(bool bOn) { mbBordSnap=bOn; }
174 void SetHlplSnap(bool bOn) { mbHlplSnap=bOn; }
175 void SetOFrmSnap(bool bOn) { mbOFrmSnap=bOn; }
176 void SetOPntSnap(bool bOn) { mbOPntSnap=bOn; }
177 void SetOConSnap(bool bOn) { mbOConSnap=bOn; }
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) { mbMoveSnapOnlyTopLeft=bOn; }
183 bool IsMoveSnapOnlyTopLeft() const { return mbMoveSnapOnlyTopLeft; }
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); }
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;
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;
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); }
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) { mbAngleSnapEnab=bOn; }
222 bool IsAngleSnapEnabled() const { return mbAngleSnapEnab; }
223 void SetSnapAngle(Degree100 nAngle) { mnSnapAngle=nAngle; }
224 Degree100 GetSnapAngle() const { return mnSnapAngle; }
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) { mbOrtho=bOn; } // incomplete
246 bool IsOrtho() const { return mbOrtho; }
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) { mbBigOrtho=bOn; }
258 bool IsBigOrtho() const { return mbBigOrtho; }
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) { mbMoveOnlyDragging=bOn; }
265 bool IsMoveOnlyDragging() const { return mbMoveOnlyDragging; }
267 // Use Slant instead of Shear. persistent. Default=FALSE.
268 void SetSlantButShear(bool bOn) { mbSlantButShear=bOn; }
269 bool IsSlantButShear() const { return mbSlantButShear; }
271 // Don't contort object while Crook. persistent. Default=FALSE. (ni)
272 void SetCrookNoContortion(bool bOn) { mbCrookNoContortion=bOn; }
273 bool IsCrookNoContortion() const { return mbCrookNoContortion; }
275 // Crook-Mode. persistent. Default=SdrCrookMode::Rotate. (ni)
276 void SetCrookMode(SdrCrookMode eMode) { meCrookMode=eMode; }
277 SdrCrookMode GetCrookMode() const { return meCrookMode; }
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) { mbEliminatePolyPoints=bOn; }
282 bool IsEliminatePolyPoints() const { return mbEliminatePolyPoints; }
283 void SetEliminatePolyPointLimitAngle(Degree100 nAngle) { mnEliminatePolyPointLimitAngle=nAngle; }
284 Degree100 GetEliminatePolyPointLimitAngle() const { return mnEliminatePolyPointLimitAngle; }
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */