Bump version to 21.06.18.1
[LibreOffice.git] / include / basegfx / utils / unopolypolygon.hxx
blobda95ebff2a6d3944cc5b2622931e58f07f4a82a7
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 .
20 #pragma once
22 #include <cppuhelper/basemutex.hxx>
23 #include <cppuhelper/compbase.hxx>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/rendering/FillRule.hpp>
27 #include <com/sun/star/rendering/XLinePolyPolygon2D.hpp>
28 #include <com/sun/star/rendering/XBezierPolyPolygon2D.hpp>
29 #include <basegfx/polygon/b2dpolypolygon.hxx>
30 #include <basegfx/basegfxdllapi.h>
32 namespace basegfx::unotools
34 typedef cppu::WeakComponentImplHelper<
35 css::rendering::XLinePolyPolygon2D,
36 css::rendering::XBezierPolyPolygon2D,
37 css::lang::XServiceInfo > UnoPolyPolygonBase;
39 class BASEGFX_DLLPUBLIC UnoPolyPolygon
40 : private cppu::BaseMutex
41 , public UnoPolyPolygonBase
43 public:
44 explicit UnoPolyPolygon( const B2DPolyPolygon& );
46 // XPolyPolygon2D
47 virtual void SAL_CALL addPolyPolygon( const css::geometry::RealPoint2D& position, const css::uno::Reference< css::rendering::XPolyPolygon2D >& polyPolygon ) override;
48 virtual ::sal_Int32 SAL_CALL getNumberOfPolygons( ) override;
49 virtual ::sal_Int32 SAL_CALL getNumberOfPolygonPoints( ::sal_Int32 polygon ) override;
50 virtual css::rendering::FillRule SAL_CALL getFillRule( ) override;
51 virtual void SAL_CALL setFillRule( css::rendering::FillRule fillRule ) override;
52 virtual sal_Bool SAL_CALL isClosed( ::sal_Int32 index ) override;
53 virtual void SAL_CALL setClosed( ::sal_Int32 index, sal_Bool closedState ) override;
55 // XLinePolyPolygon2D
56 virtual css::uno::Sequence< css::uno::Sequence< css::geometry::RealPoint2D > > SAL_CALL getPoints( ::sal_Int32 nPolygonIndex, ::sal_Int32 nNumberOfPolygons, ::sal_Int32 nPointIndex, ::sal_Int32 nNumberOfPoints ) override;
57 virtual void SAL_CALL setPoints( const css::uno::Sequence< css::uno::Sequence< css::geometry::RealPoint2D > >& points, ::sal_Int32 nPolygonIndex ) override;
58 virtual css::geometry::RealPoint2D SAL_CALL getPoint( ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) override;
59 virtual void SAL_CALL setPoint( const css::geometry::RealPoint2D& point, ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) override;
61 // XBezierPolyPolygon2D
62 virtual css::uno::Sequence< css::uno::Sequence< css::geometry::RealBezierSegment2D > > SAL_CALL getBezierSegments( ::sal_Int32 nPolygonIndex, ::sal_Int32 nNumberOfPolygons, ::sal_Int32 nPointIndex, ::sal_Int32 nNumberOfPoints ) override;
63 virtual void SAL_CALL setBezierSegments( const css::uno::Sequence< css::uno::Sequence< css::geometry::RealBezierSegment2D > >& points, ::sal_Int32 nPolygonIndex ) override;
64 virtual css::geometry::RealBezierSegment2D SAL_CALL getBezierSegment( ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) override;
65 virtual void SAL_CALL setBezierSegment( const css::geometry::RealBezierSegment2D& point, ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) override;
67 // XServiceInfo
68 virtual OUString SAL_CALL getImplementationName() override;
69 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
70 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
72 B2DPolyPolygon getPolyPolygon() const;
74 protected:
75 /// Check whether index is a valid polygon index
76 void checkIndex( sal_Int32 nIndex ) const // throw (css::lang::IndexOutOfBoundsException);
78 if( nIndex < 0 || nIndex >= static_cast<sal_Int32>(maPolyPoly.count()) )
79 throw css::lang::IndexOutOfBoundsException();
82 B2DPolyPolygon getSubsetPolyPolygon( sal_Int32 nPolygonIndex,
83 sal_Int32 nNumberOfPolygons,
84 sal_Int32 nPointIndex,
85 sal_Int32 nNumberOfPoints ) const;
87 /// Get cow copy of internal polygon. not thread-safe outside this object.
88 const B2DPolyPolygon& getPolyPolygonUnsafe() const
90 return maPolyPoly;
93 /// Called whenever internal polypolygon gets modified
94 virtual void modifying() const {}
96 private:
97 UnoPolyPolygon(const UnoPolyPolygon&) = delete;
98 UnoPolyPolygon& operator=(const UnoPolyPolygon&) = delete;
100 B2DPolyPolygon maPolyPoly;
101 css::rendering::FillRule meFillRule;
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */