LibreOffice Module svx (master)  1
svdglue.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_SVDGLUE_HXX
21 #define INCLUDED_SVX_SVDGLUE_HXX
22 
23 #include <tools/gen.hxx>
24 #include <tools/degree.hxx>
25 #include <svx/svxdllapi.h>
26 #include <memory>
27 #include <vector>
28 #include <o3tl/typed_flags_set.hxx>
29 
30 namespace vcl { class Window; }
31 class OutputDevice;
32 class SvStream;
33 class SdrObject;
34 
35 
37 {
38  SMART = 0x0000,
39  LEFT = 0x0001,
40  RIGHT = 0x0002,
41  TOP = 0x0004,
42  BOTTOM = 0x0008,
43  HORZ = LEFT | RIGHT,
44  VERT = TOP | BOTTOM,
45  ALL = 0x00ff,
46 };
47 namespace o3tl
48 {
49  template<> struct typed_flags<SdrEscapeDirection> : is_typed_flags<SdrEscapeDirection, 0x00ff> {};
50 }
51 
52 enum class SdrAlign
53 {
54  NONE = 0x0000,
55  HORZ_CENTER = 0x0000,
56  HORZ_LEFT = 0x0001,
57  HORZ_RIGHT = 0x0002,
58  HORZ_DONTCARE = 0x0010,
59  VERT_CENTER = 0x0000,
60  VERT_TOP = 0x0100,
61  VERT_BOTTOM = 0x0200,
62  VERT_DONTCARE = 0x1000,
63 };
64 namespace o3tl
65 {
66  template<> struct typed_flags<SdrAlign> : is_typed_flags<SdrAlign, 0x1313> {};
67 }
68 
70  // Reference Point is SdrObject::GetSnapRect().Center()
71  // bNoPercent=false: position is -5000..5000 (1/100)% or 0..10000 (depending on align)
72  // bNoPercent=true : position is in log unit, relative to the reference point
75  sal_uInt16 nId;
77  bool bNoPercent:1;
78  bool bReallyAbsolute:1; // temp for transformations on the reference object
79  bool bUserDefined:1; // #i38892#
80 public:
82  : nEscDir(SdrEscapeDirection::SMART)
83  , nId(0)
84  , nAlign(SdrAlign::NONE)
85  , bNoPercent(false)
86  , bReallyAbsolute(false)
87  , bUserDefined(true)
88  {}
89  SdrGluePoint(const Point& rNewPos)
90  : aPos(rNewPos)
91  , nEscDir(SdrEscapeDirection::SMART)
92  , nId(0)
93  , nAlign(SdrAlign::NONE)
94  , bNoPercent(false)
95  , bReallyAbsolute(false)
96  , bUserDefined(true)
97  {}
98  const Point& GetPos() const
99  {
100  return aPos;
101  }
102  void SetPos(const Point& rNewPos)
103  {
104  aPos = rNewPos;
105  }
107  {
108  return nEscDir;
109  }
111  {
112  nEscDir = nNewEsc;
113  }
114  sal_uInt16 GetId() const
115  {
116  return nId;
117  }
118  void SetId(sal_uInt16 nNewId)
119  {
120  nId = nNewId;
121  }
122  bool IsPercent() const
123  {
124  return !bNoPercent;
125  }
126  void SetPercent(bool bOn)
127  {
128  bNoPercent = !bOn;
129  }
130  // temp for transformations on the reference object
131  void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
132 
133  // #i38892#
134  bool IsUserDefined() const
135  {
136  return bUserDefined;
137  }
138  void SetUserDefined(bool bNew)
139  {
140  bUserDefined = bNew;
141  }
142 
144  {
145  return nAlign;
146  }
147  void SetAlign(SdrAlign nAlg)
148  {
149  nAlign = nAlg;
150  }
152  {
153  return nAlign & static_cast<SdrAlign>(0x00FF);
154  }
156  {
157  assert((nAlg & static_cast<SdrAlign>(0xFF00)) == SdrAlign::NONE);
158  nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0xFF00)) | (nAlg & static_cast<SdrAlign>(0x00FF));
159  }
161  {
162  return nAlign & static_cast<SdrAlign>(0xFF00);
163  }
165  {
166  assert((nAlg & static_cast<SdrAlign>(0x00FF)) == SdrAlign::NONE);
167  nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0x00FF)) | (nAlg & static_cast<SdrAlign>(0xFF00));
168  }
169 
170  bool IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
171  void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
172  Point GetAbsolutePos(const SdrObject& rObj) const;
173  void SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
174  Degree100 GetAlignAngle() const;
175  void SetAlignAngle(Degree100 nAngle);
176  static Degree100 EscDirToAngle(SdrEscapeDirection nEsc);
177  static SdrEscapeDirection EscAngleToDir(Degree100 nAngle);
178  void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
179  void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
180  void Shear (const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
181 };
182 
183 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
184 
186 {
187  std::vector<SdrGluePoint> aList;
188 public:
191  {
192  *this = rSrcList;
193  }
194 
195  SdrGluePointList& operator=(const SdrGluePointList& rSrcList);
196  sal_uInt16 GetCount() const
197  {
198  return sal_uInt16(aList.size());
199  }
200  // At insert, the object (GluePoint) automatically gets an ID assigned.
201  // Return value is the index of the new GluePoint in the list.
202  sal_uInt16 Insert(const SdrGluePoint& rGP);
203  void Delete(sal_uInt16 nPos)
204  {
205  aList.erase(aList.begin() + nPos);
206  }
207  SdrGluePoint& operator[](sal_uInt16 nPos)
208  {
209  return aList[nPos];
210  }
211  const SdrGluePoint& operator[](sal_uInt16 nPos) const
212  {
213  return aList[nPos];
214  }
215  sal_uInt16 FindGluePoint(sal_uInt16 nId) const;
216  sal_uInt16 HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
217  void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
218 
219  // temp for transformations on the reference object
220  void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
221  void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
222  void Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
223  void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
224  void Shear(const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
225 };
226 
227 
228 #endif // INCLUDED_SVX_SVDGLUE_HXX
229 
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetId(sal_uInt16 nNewId)
Definition: svdglue.hxx:118
SdrAlign GetAlign() const
Definition: svdglue.hxx:143
const SdrGluePoint & operator[](sal_uInt16 nPos) const
Definition: svdglue.hxx:211
SdrAlign GetVertAlign() const
Definition: svdglue.hxx:160
SdrEscapeDirection
Definition: svdglue.hxx:36
void SetHorzAlign(SdrAlign nAlg)
Definition: svdglue.hxx:155
sal_uInt16 GetCount() const
Definition: svdglue.hxx:196
std::vector< SdrGluePoint > aList
Definition: svdglue.hxx:187
NONE
sal_uInt16 GetId() const
Definition: svdglue.hxx:114
SdrAlign GetHorzAlign() const
Definition: svdglue.hxx:151
Point Rotate(const Point &rPoint, Degree10 nOrientation, const Point &rOrigin)
SdrEscapeDirection GetEscDir() const
Definition: svdglue.hxx:106
SdrAlign nAlign
Definition: svdglue.hxx:76
bool IsPercent() const
Definition: svdglue.hxx:122
Point aPos
Definition: svdglue.hxx:73
void SetVertAlign(SdrAlign nAlg)
Definition: svdglue.hxx:164
void SetUserDefined(bool bNew)
Definition: svdglue.hxx:138
void SetPercent(bool bOn)
Definition: svdglue.hxx:126
SdrGluePoint(const Point &rNewPos)
Definition: svdglue.hxx:89
Abstract DrawObject.
Definition: svdobj.hxx:259
void Delete(sal_uInt16 nPos)
Definition: svdglue.hxx:203
sal_uInt16 nId
Definition: svdglue.hxx:75
SdrGluePointList(const SdrGluePointList &rSrcList)
Definition: svdglue.hxx:190
SdrEscapeDirection nEscDir
Definition: svdglue.hxx:74
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
SdrGluePoint & operator[](sal_uInt16 nPos)
Definition: svdglue.hxx:207
const Point & GetPos() const
Definition: svdglue.hxx:98
void SetAlign(SdrAlign nAlg)
Definition: svdglue.hxx:147
bool IsUserDefined() const
Definition: svdglue.hxx:134
SdrAlign
Definition: svdglue.hxx:52
void SetEscDir(SdrEscapeDirection nNewEsc)
Definition: svdglue.hxx:110
void SetPos(const Point &rNewPos)
Definition: svdglue.hxx:102