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:
81  SdrGluePoint(): nEscDir(SdrEscapeDirection::SMART),nId(0),nAlign(SdrAlign::NONE),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
82  SdrGluePoint(const Point& rNewPos): aPos(rNewPos),nEscDir(SdrEscapeDirection::SMART),nId(0),nAlign(SdrAlign::NONE),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
83  const Point& GetPos() const { return aPos; }
84  void SetPos(const Point& rNewPos) { aPos=rNewPos; }
85  SdrEscapeDirection GetEscDir() const { return nEscDir; }
86  void SetEscDir(SdrEscapeDirection nNewEsc) { nEscDir=nNewEsc; }
87  sal_uInt16 GetId() const { return nId; }
88  void SetId(sal_uInt16 nNewId) { nId=nNewId; }
89  bool IsPercent() const { return !bNoPercent; }
90  void SetPercent(bool bOn) { bNoPercent = !bOn; }
91  // temp for transformations on the reference object
92  void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
93 
94  // #i38892#
95  bool IsUserDefined() const { return bUserDefined; }
96  void SetUserDefined(bool bNew) { bUserDefined = bNew; }
97 
98  SdrAlign GetAlign() const { return nAlign; }
99  void SetAlign(SdrAlign nAlg) { nAlign=nAlg; }
100  SdrAlign GetHorzAlign() const { return nAlign & static_cast<SdrAlign>(0x00FF); }
101  void SetHorzAlign(SdrAlign nAlg) { assert((nAlg & static_cast<SdrAlign>(0xFF00)) == SdrAlign::NONE); nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0xFF00)) | (nAlg & static_cast<SdrAlign>(0x00FF)); }
102  SdrAlign GetVertAlign() const { return nAlign & static_cast<SdrAlign>(0xFF00); }
103  void SetVertAlign(SdrAlign nAlg) { assert((nAlg & static_cast<SdrAlign>(0x00FF)) == SdrAlign::NONE); nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0x00FF)) | (nAlg & static_cast<SdrAlign>(0xFF00)); }
104  bool IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
105  void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
106  Point GetAbsolutePos(const SdrObject& rObj) const;
107  void SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
108  Degree100 GetAlignAngle() const;
109  void SetAlignAngle(Degree100 nAngle);
110  static Degree100 EscDirToAngle(SdrEscapeDirection nEsc);
111  static SdrEscapeDirection EscAngleToDir(Degree100 nAngle);
112  void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
113  void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
114  void Shear (const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
115 };
116 
117 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
118 
120  std::vector<std::unique_ptr<SdrGluePoint>> aList;
121 public:
123  SdrGluePointList(const SdrGluePointList& rSrcList) { *this=rSrcList; }
124 
125  SdrGluePointList& operator=(const SdrGluePointList& rSrcList);
126  sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
127  // At insert, the object (GluePoint) automatically gets an ID assigned.
128  // Return value is the index of the new GluePoint in the list.
129  sal_uInt16 Insert(const SdrGluePoint& rGP);
130  void Delete(sal_uInt16 nPos)
131  {
132  aList.erase(aList.begin()+nPos);
133  }
134  SdrGluePoint& operator[](sal_uInt16 nPos) { return *aList[nPos]; }
135  const SdrGluePoint& operator[](sal_uInt16 nPos) const { return *aList[nPos]; }
136  sal_uInt16 FindGluePoint(sal_uInt16 nId) const;
137  sal_uInt16 HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
138  void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
139  // temp for transformations on the reference object
140  void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
141  void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
142  void Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
143  void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
144  void Shear (const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
145 };
146 
147 
148 #endif // INCLUDED_SVX_SVDGLUE_HXX
149 
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetId(sal_uInt16 nNewId)
Definition: svdglue.hxx:88
SdrAlign GetAlign() const
Definition: svdglue.hxx:98
const SdrGluePoint & operator[](sal_uInt16 nPos) const
Definition: svdglue.hxx:135
SdrAlign GetVertAlign() const
Definition: svdglue.hxx:102
SdrEscapeDirection
Definition: svdglue.hxx:36
void SetHorzAlign(SdrAlign nAlg)
Definition: svdglue.hxx:101
sal_uInt16 GetCount() const
Definition: svdglue.hxx:126
NONE
sal_uInt16 GetId() const
Definition: svdglue.hxx:87
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SdrAlign GetHorzAlign() const
Definition: svdglue.hxx:100
Point Rotate(const Point &rPoint, Degree10 nOrientation, const Point &rOrigin)
SdrEscapeDirection GetEscDir() const
Definition: svdglue.hxx:85
SdrAlign nAlign
Definition: svdglue.hxx:76
std::vector< std::unique_ptr< SdrGluePoint > > aList
Definition: svdglue.hxx:120
bool IsPercent() const
Definition: svdglue.hxx:89
Point aPos
Definition: svdglue.hxx:73
void SetVertAlign(SdrAlign nAlg)
Definition: svdglue.hxx:103
void SetUserDefined(bool bNew)
Definition: svdglue.hxx:96
void SetPercent(bool bOn)
Definition: svdglue.hxx:90
SdrGluePoint(const Point &rNewPos)
Definition: svdglue.hxx:82
Abstract DrawObject.
Definition: svdobj.hxx:260
void Delete(sal_uInt16 nPos)
Definition: svdglue.hxx:130
sal_uInt16 nId
Definition: svdglue.hxx:75
SdrGluePointList(const SdrGluePointList &rSrcList)
Definition: svdglue.hxx:123
SdrEscapeDirection nEscDir
Definition: svdglue.hxx:74
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
SdrGluePoint & operator[](sal_uInt16 nPos)
Definition: svdglue.hxx:134
const Point & GetPos() const
Definition: svdglue.hxx:83
void SetAlign(SdrAlign nAlg)
Definition: svdglue.hxx:99
bool IsUserDefined() const
Definition: svdglue.hxx:95
SdrAlign
Definition: svdglue.hxx:52
void SetEscDir(SdrEscapeDirection nNewEsc)
Definition: svdglue.hxx:86
void SetPos(const Point &rNewPos)
Definition: svdglue.hxx:84