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