LibreOffice Module svx (master)  1
xpoly.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 #ifndef INCLUDED_SVX_XPOLY_HXX
20 #define INCLUDED_SVX_XPOLY_HXX
21 
23 #include <svx/svxdllapi.h>
24 #include <o3tl/cow_wrapper.hxx>
25 #include <tools/poly.hxx>
26 
27 class Point;
28 namespace tools { class Rectangle; }
29 class SvStream;
30 namespace tools {
31  class Polygon;
32  class PolyPolygon;
33 }
34 class OutputDevice;
35 
36 #define XPOLYPOLY_APPEND 0xFFFF
37 #define XPOLY_APPEND 0xFFFF
38 
39 
40 // Class XPolygon has a point-array and a flag-array, which contains information about a particular point
41 
42 class ImpXPolygon;
43 
45 {
47 
48  // auxiliary functions for Bezier conversion
49  void SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT);
50  void GenBezArc(const Point& rCenter, long nRx, long nRy,
51  long nXHdl, long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd,
52  sal_uInt16 nQuad, sal_uInt16 nFirst);
53  static bool CheckAngles(sal_uInt16& nStart, sal_uInt16 nEnd, sal_uInt16& nA1, sal_uInt16& nA2);
54 
55 public:
56  XPolygon( sal_uInt16 nSize=16 );
57  XPolygon( const XPolygon& );
58  XPolygon( XPolygon&& );
59  XPolygon( const tools::Polygon& rPoly );
60  XPolygon( const tools::Rectangle& rRect, long nRx = 0, long nRy = 0 );
61  XPolygon( const Point& rCenter, long nRx, long nRy,
62  sal_uInt16 nStartAngle = 0, sal_uInt16 nEndAngle = 3600,
63  bool bClose = true );
64 
65  ~XPolygon();
66 
67  sal_uInt16 GetSize() const;
68 
69  void SetPointCount( sal_uInt16 nPoints );
70  sal_uInt16 GetPointCount() const;
71 
72  void Insert( sal_uInt16 nPos, const Point& rPt, PolyFlags eFlags );
73  void Insert( sal_uInt16 nPos, const XPolygon& rXPoly );
74  void Remove( sal_uInt16 nPos, sal_uInt16 nCount );
75  void Move( long nHorzMove, long nVertMove );
76  tools::Rectangle GetBoundRect() const;
77 
78  const Point& operator[]( sal_uInt16 nPos ) const;
79  Point& operator[]( sal_uInt16 nPos );
80  XPolygon& operator=( const XPolygon& );
81  XPolygon& operator=( XPolygon&& );
82  bool operator==( const XPolygon& rXPoly ) const;
83 
84  PolyFlags GetFlags( sal_uInt16 nPos ) const;
85  void SetFlags( sal_uInt16 nPos, PolyFlags eFlags );
86  bool IsControl(sal_uInt16 nPos) const;
87  bool IsSmooth(sal_uInt16 nPos) const;
88 
89  // distance between two points
90  double CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2);
91 
92  // Bezier conversion
93  void CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt);
94  void CalcTangent(sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext);
95  void PointsToBezier(sal_uInt16 nFirst);
96 
97  // transformations
98  void Scale(double fSx, double fSy);
99  void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect);
100 
101  // #116512# convert to basegfx::B2DPolygon and return
102  basegfx::B2DPolygon getB2DPolygon() const;
103 
104  // #116512# constructor to convert from basegfx::B2DPolygon
105  // #i76339# made explicit
106  explicit XPolygon(const basegfx::B2DPolygon& rPolygon);
107 };
108 
109 // Class XPolyPolygon; like PolyPolygon, composed of XPolygons instead of Polygons
110 
111 class ImpXPolyPolygon;
112 
113 class XPolyPolygon final
114 {
116 
117 public:
118  XPolyPolygon();
119  XPolyPolygon( const XPolyPolygon& );
121 
122  ~XPolyPolygon();
123 
124  void Insert( XPolygon&& rXPoly );
125  void Insert( const XPolyPolygon& rXPoly );
126  void Remove( sal_uInt16 nPos );
127  const XPolygon& GetObject( sal_uInt16 nPos ) const;
128 
129  void Clear();
130  sal_uInt16 Count() const;
131 
133 
134  const XPolygon& operator[]( sal_uInt16 nPos ) const
135  { return GetObject( nPos ); }
136  XPolygon& operator[]( sal_uInt16 nPos );
137 
140 
141  // transformations
142  void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect);
143 
144  // #116512# convert to basegfx::B2DPolyPolygon and return
146 
147  // #116512# constructor to convert from basegfx::B2DPolyPolygon
148  // #i76339# made explicit
149  explicit XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
150 };
151 
152 #endif // INCLUDED_SVX_XPOLY_HXX
153 
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Insert(XPolygon &&rXPoly)
Definition: _xpoly.cxx:866
sal_uInt16 Count() const
Definition: _xpoly.cxx:895
o3tl::cow_wrapper< ImpXPolyPolygon > pImpXPolyPolygon
Definition: xpoly.hxx:115
basegfx::B2DPolyPolygon getB2DPolyPolygon() const
Definition: _xpoly.cxx:940
const XPolygon & operator[](sal_uInt16 nPos) const
Definition: xpoly.hxx:134
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
const XPolygon & GetObject(sal_uInt16 nPos) const
Definition: _xpoly.cxx:885
long Scale(long nVal, long nMult, long nDiv)
void Clear()
Definition: _xpoly.cxx:890
o3tl::cow_wrapper< ImpXPolygon > pImpXPolygon
Definition: xpoly.hxx:46
XPolyPolygon & operator=(const XPolyPolygon &)
void SetFlags(EVControlBits &rBits, EVControlBits nMask, bool bOn)
void Remove(sal_uInt16 nPos)
Definition: _xpoly.cxx:880
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
tools::Rectangle GetBoundRect() const
Definition: _xpoly.cxx:900
void Distort(const tools::Rectangle &rRefRect, const XPolygon &rDistortedRect)
Distort a polygon by scaling its coordinates relative to a reference rectangle into an arbitrary rect...
Definition: _xpoly.cxx:933
PolyFlags