1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_BASEGFX_POLYGON_B2DPOLYPOLYGON_HXX
21 #define INCLUDED_BASEGFX_POLYGON_B2DPOLYPOLYGON_HXX
26 #include <sal/types.h>
27 #include <o3tl/cow_wrapper.hxx>
28 #include <basegfx/range/b2drange.hxx>
29 #include <basegfx/basegfxdllapi.h>
30 #include <basegfx/polygon/b2dpolygon.hxx>
32 class ImplB2DPolyPolygon
;
41 class BASEGFX_DLLPUBLIC B2DPolyPolygon
44 typedef o3tl::cow_wrapper
< ImplB2DPolyPolygon
> ImplType
;
47 ImplType mpPolyPolygon
;
51 B2DPolyPolygon(const B2DPolyPolygon
& rPolyPolygon
);
52 B2DPolyPolygon(B2DPolyPolygon
&& rPolyPolygon
);
53 explicit B2DPolyPolygon(const B2DPolygon
& rPolygon
);
56 // assignment operator
57 B2DPolyPolygon
& operator=(const B2DPolyPolygon
& rPolyPolygon
);
58 B2DPolyPolygon
& operator=(B2DPolyPolygon
&& rPolyPolygon
);
60 /// unshare this poly-polygon (and all included polygons) with all internally shared instances
64 bool operator==(const B2DPolyPolygon
& rPolyPolygon
) const;
65 bool operator!=(const B2DPolyPolygon
& rPolyPolygon
) const;
68 sal_uInt32
count() const;
70 B2DPolygon
const & getB2DPolygon(sal_uInt32 nIndex
) const;
71 void setB2DPolygon(sal_uInt32 nIndex
, const B2DPolygon
& rPolygon
);
74 bool areControlPointsUsed() const;
76 // insert/append single polygon
77 void insert(sal_uInt32 nIndex
, const B2DPolygon
& rPolygon
, sal_uInt32 nCount
= 1);
78 void append(const B2DPolygon
& rPolygon
, sal_uInt32 nCount
= 1);
80 /** Default adaptive subdivision access
82 For details refer to B2DPolygon::getDefaultAdaptiveSubdivision()
85 The default subdivision of this polygon
87 B2DPolyPolygon
getDefaultAdaptiveSubdivision() const;
89 /** Get the B2DRange (Rectangle dimensions) of this B2DPolyPolygon
91 For details refer to B2DPolygon::getB2DRange()
94 The outer range of the bezier curve/polygon
96 B2DRange
getB2DRange() const;
98 // insert/append multiple polygons
99 void insert(sal_uInt32 nIndex
, const B2DPolyPolygon
& rPolyPolygon
);
100 void append(const B2DPolyPolygon
& rPolyPolygon
);
103 void remove(sal_uInt32 nIndex
, sal_uInt32 nCount
= 1);
105 // reset to empty state
109 bool isClosed() const;
110 void setClosed(bool bNew
);
112 // flip polygon direction
115 // test if tools::PolyPolygon has double points
116 bool hasDoublePoints() const;
118 // remove double points, at the begin/end and follow-ups, too
119 void removeDoublePoints();
121 // apply transformation given in matrix form to the polygon
122 void transform(const basegfx::B2DHomMatrix
& rMatrix
);
124 // polygon iterators (same iterator validity conditions as for vector)
125 const B2DPolygon
* begin() const;
126 const B2DPolygon
* end() const;
130 // exclusive management op's for SystemDependentData at B2DPolygon
132 std::shared_ptr
<T
> getSystemDependentData() const
134 return std::static_pointer_cast
<T
>(getSystemDependantDataInternal(typeid(T
).hash_code()));
137 template<class T
, class... Args
>
138 std::shared_ptr
<T
> addOrReplaceSystemDependentData(SystemDependentDataManager
& manager
, Args
&&... args
) const
140 std::shared_ptr
<T
> r
= std::make_shared
<T
>(manager
, std::forward
<Args
>(args
)...);
141 basegfx::SystemDependentData_SharedPtr
r2(r
);
142 addOrReplaceSystemDependentDataInternal(r2
);
147 void addOrReplaceSystemDependentDataInternal(SystemDependentData_SharedPtr
& rData
) const;
148 SystemDependentData_SharedPtr
getSystemDependantDataInternal(size_t hash_code
) const;
151 // typedef for a vector of B2DPolyPolygons
152 typedef ::std::vector
< B2DPolyPolygon
> B2DPolyPolygonVector
;
154 template< typename charT
, typename traits
>
155 inline std::basic_ostream
<charT
, traits
> & operator <<(
156 std::basic_ostream
<charT
, traits
> & stream
, const B2DPolyPolygon
& poly
)
158 stream
<< "[" << poly
.count() << ":";
159 for (sal_uInt32 i
= 0; i
< poly
.count(); i
++)
163 stream
<< poly
.getB2DPolygon(i
);
170 } // end of namespace basegfx
172 #endif // INCLUDED_BASEGFX_POLYGON_B2DPOLYPOLYGON_HXX
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */