1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
25 #define _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
26 
27 #include <sal/types.h>
28 #include <o3tl/cow_wrapper.hxx>
29 #include <basegfx/range/b2drange.hxx>
30 #include <basegfx/basegfxdllapi.h>
31 
32 // predeclarations
33 class ImplB2DPolyPolygon;
34 
35 namespace basegfx
36 {
37 	class B2DPolygon;
38 	class B2DHomMatrix;
39 } // end of namespace basegfx
40 
41 //////////////////////////////////////////////////////////////////////////////
42 
43 namespace basegfx
44 {
45 	class BASEGFX_DLLPUBLIC B2DPolyPolygon
46 	{
47     public:
48         typedef o3tl::cow_wrapper< ImplB2DPolyPolygon > ImplType;
49 
50 	private:
51         ImplType                                        mpPolyPolygon;
52 
53 	public:
54 		B2DPolyPolygon();
55 		B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon);
56 		explicit B2DPolyPolygon(const B2DPolygon& rPolygon);
57 		~B2DPolyPolygon();
58 
59 		// assignment operator
60 		B2DPolyPolygon& operator=(const B2DPolyPolygon& rPolyPolygon);
61 
62         /// unshare this poly-polygon (and all included polygons) with all internally shared instances
63         void makeUnique();
64 
65 		// compare operators
66 		bool operator==(const B2DPolyPolygon& rPolyPolygon) const;
67 		bool operator!=(const B2DPolyPolygon& rPolyPolygon) const;
68 
69 		// polygon interface
70 		sal_uInt32 count() const;
71 
72 		B2DPolygon getB2DPolygon(sal_uInt32 nIndex) const;
73 		void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon);
74 
75 		// test for curve
76 		bool areControlPointsUsed() const;
77 
78 		// insert/append single polygon
79 		void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
80 		void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
81 
82 		/** Default adaptive subdivision access
83 
84 			For details refer to B2DPolygon::getDefaultAdaptiveSubdivision()
85 
86             @return
87 			The default subdivision of this polygon
88 		*/
89         B2DPolyPolygon getDefaultAdaptiveSubdivision() const;
90 
91         /** Get the B2DRange (Rectangle dimensions) of this B2DPolyPolygon
92 
93 			For details refer to B2DPolygon::getB2DRange()
94 
95 			@return
96 			The outer range of the bezier curve/polygon
97         */
98         B2DRange getB2DRange() const;
99 
100         // insert/append multiple polygons
101 		void insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon);
102 		void append(const B2DPolyPolygon& rPolyPolygon);
103 
104 		// remove
105 		void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
106 
107 		// reset to empty state
108 		void clear();
109 
110 		// closed state
111 		bool isClosed() const;
112 		void setClosed(bool bNew);
113 
114 		// flip polygon direction
115 		void flip();
116 
117 		// test if PolyPolygon has double points
118 		bool hasDoublePoints() const;
119 
120 		// remove double points, at the begin/end and follow-ups, too
121 		void removeDoublePoints();
122 
123 		// apply transformation given in matrix form to the polygon
124 		void transform(const basegfx::B2DHomMatrix& rMatrix);
125 
126         // polygon iterators (same iterator validity conditions as for vector)
127         const B2DPolygon* begin() const;
128         const B2DPolygon* end() const;
129         B2DPolygon* begin();
130         B2DPolygon* end();
131 	};
132 
133     // typedef for a vector of B2DPolyPolygons
134     typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector;
135 
136 } // end of namespace basegfx
137 
138 #endif /* _BGFX_POLYGON_B2DPOLYPOLYGON_HXX */
139