Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / xpoly.hxx
blobac5dbd8ac8122030e538c271539d1b57c512aae0
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 .
19 #ifndef INCLUDED_SVX_XPOLY_HXX
20 #define INCLUDED_SVX_XPOLY_HXX
22 #include <basegfx/polygon/b2dpolypolygon.hxx>
23 #include <svx/svxdllapi.h>
24 #include <o3tl/cow_wrapper.hxx>
25 #include <tools/poly.hxx>
27 class Point;
28 namespace tools { class Rectangle; }
29 class SvStream;
30 namespace tools {
31 class Polygon;
32 class PolyPolygon;
34 class OutputDevice;
36 #define XPOLYPOLY_APPEND 0xFFFF
37 #define XPOLY_APPEND 0xFFFF
40 // Class XPolygon has a point-array and a flag-array, which contains information about a particular point
42 class ImpXPolygon;
44 class SVX_DLLPUBLIC XPolygon
46 protected:
47 o3tl::cow_wrapper< ImpXPolygon > pImpXPolygon;
49 // auxiliary functions for Bezier conversion
50 void SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT);
51 void GenBezArc(const Point& rCenter, long nRx, long nRy,
52 long nXHdl, long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd,
53 sal_uInt16 nQuad, sal_uInt16 nFirst);
54 static bool CheckAngles(sal_uInt16& nStart, sal_uInt16 nEnd, sal_uInt16& nA1, sal_uInt16& nA2);
56 public:
57 XPolygon( sal_uInt16 nSize=16 );
58 XPolygon( const XPolygon& rXPoly );
59 XPolygon( XPolygon&& rXPoly );
60 XPolygon( const tools::Polygon& rPoly );
61 XPolygon( const tools::Rectangle& rRect, long nRx = 0, long nRy = 0 );
62 XPolygon( const Point& rCenter, long nRx, long nRy,
63 sal_uInt16 nStartAngle = 0, sal_uInt16 nEndAngle = 3600,
64 bool bClose = true );
66 ~XPolygon();
68 sal_uInt16 GetSize() const;
70 void SetPointCount( sal_uInt16 nPoints );
71 sal_uInt16 GetPointCount() const;
73 void Insert( sal_uInt16 nPos, const Point& rPt, PolyFlags eFlags );
74 void Insert( sal_uInt16 nPos, const XPolygon& rXPoly );
75 void Remove( sal_uInt16 nPos, sal_uInt16 nCount );
76 void Move( long nHorzMove, long nVertMove );
77 tools::Rectangle GetBoundRect() const;
79 const Point& operator[]( sal_uInt16 nPos ) const;
80 Point& operator[]( sal_uInt16 nPos );
81 XPolygon& operator=( const XPolygon& rXPoly );
82 XPolygon& operator=( XPolygon&& rXPoly );
83 bool operator==( const XPolygon& rXPoly ) const;
85 PolyFlags GetFlags( sal_uInt16 nPos ) const;
86 void SetFlags( sal_uInt16 nPos, PolyFlags eFlags );
87 bool IsControl(sal_uInt16 nPos) const;
88 bool IsSmooth(sal_uInt16 nPos) const;
90 // distance between two points
91 double CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2);
93 // Bezier conversion
94 void CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt);
95 void CalcTangent(sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext);
96 void PointsToBezier(sal_uInt16 nFirst);
98 // transformations
99 void Scale(double fSx, double fSy);
100 void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect);
102 // #116512# convert to basegfx::B2DPolygon and return
103 basegfx::B2DPolygon getB2DPolygon() const;
105 // #116512# constructor to convert from basegfx::B2DPolygon
106 // #i76339# made explicit
107 explicit XPolygon(const basegfx::B2DPolygon& rPolygon);
110 // Class XPolyPolygon; like PolyPolygon, composed of XPolygons instead of Polygons
112 class ImpXPolyPolygon;
114 class SVX_DLLPUBLIC XPolyPolygon
116 protected:
117 o3tl::cow_wrapper< ImpXPolyPolygon > pImpXPolyPolygon;
119 public:
120 XPolyPolygon();
121 XPolyPolygon( const XPolyPolygon& rXPolyPoly );
122 XPolyPolygon( XPolyPolygon&& rXPolyPoly );
124 ~XPolyPolygon();
126 void Insert( const XPolygon& rXPoly );
127 void Insert( const XPolyPolygon& rXPoly );
128 XPolygon Remove( sal_uInt16 nPos );
129 const XPolygon& GetObject( sal_uInt16 nPos ) const;
131 void Clear();
132 sal_uInt16 Count() const;
134 tools::Rectangle GetBoundRect() const;
136 const XPolygon& operator[]( sal_uInt16 nPos ) const
137 { return GetObject( nPos ); }
138 XPolygon& operator[]( sal_uInt16 nPos );
140 XPolyPolygon& operator=( const XPolyPolygon& rXPolyPoly );
141 XPolyPolygon& operator=( XPolyPolygon&& rXPolyPoly );
143 // transformations
144 void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect);
146 // #116512# convert to basegfx::B2DPolyPolygon and return
147 basegfx::B2DPolyPolygon getB2DPolyPolygon() const;
149 // #116512# constructor to convert from basegfx::B2DPolyPolygon
150 // #i76339# made explicit
151 explicit XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
154 #endif // INCLUDED_SVX_XPOLY_HXX
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */