Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / basegfx / tools / unopolypolygon.hxx
blobe4a2206dada86f1f3e475fadcec8f97c1eb7836c
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 #ifndef INCLUDED_BASEGFX_TOOLS_UNOPOLYPOLYGON_HXX
21 #define INCLUDED_BASEGFX_TOOLS_UNOPOLYPOLYGON_HXX
23 #include <cppuhelper/basemutex.hxx>
24 #include <cppuhelper/compbase3.hxx>
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
34 namespace unotools
36 typedef ::cppu::WeakComponentImplHelper3<
37 css::rendering::XLinePolyPolygon2D,
38 css::rendering::XBezierPolyPolygon2D,
39 css::lang::XServiceInfo > UnoPolyPolygonBase;
41 class BASEGFX_DLLPUBLIC UnoPolyPolygon
42 : private cppu::BaseMutex
43 , public UnoPolyPolygonBase
45 public:
46 explicit UnoPolyPolygon( const B2DPolyPolygon& );
48 // XPolyPolygon2D
49 virtual void SAL_CALL addPolyPolygon( const css::geometry::RealPoint2D& position, const css::uno::Reference< css::rendering::XPolyPolygon2D >& polyPolygon ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override;
50 virtual ::sal_Int32 SAL_CALL getNumberOfPolygons( ) throw (css::uno::RuntimeException, std::exception) override;
51 virtual ::sal_Int32 SAL_CALL getNumberOfPolygonPoints( ::sal_Int32 polygon ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
52 virtual css::rendering::FillRule SAL_CALL getFillRule( ) throw (css::uno::RuntimeException, std::exception) override;
53 virtual void SAL_CALL setFillRule( css::rendering::FillRule fillRule ) throw (css::uno::RuntimeException, std::exception) override;
54 virtual sal_Bool SAL_CALL isClosed( ::sal_Int32 index ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
55 virtual void SAL_CALL setClosed( ::sal_Int32 index, sal_Bool closedState ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
57 // XLinePolyPolygon2D
58 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 ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
59 virtual void SAL_CALL setPoints( const css::uno::Sequence< css::uno::Sequence< css::geometry::RealPoint2D > >& points, ::sal_Int32 nPolygonIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
60 virtual css::geometry::RealPoint2D SAL_CALL getPoint( ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
61 virtual void SAL_CALL setPoint( const css::geometry::RealPoint2D& point, ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
63 // XBezierPolyPolygon2D
64 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 ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
65 virtual void SAL_CALL setBezierSegments( const css::uno::Sequence< css::uno::Sequence< css::geometry::RealBezierSegment2D > >& points, ::sal_Int32 nPolygonIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
66 virtual css::geometry::RealBezierSegment2D SAL_CALL getBezierSegment( ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
67 virtual void SAL_CALL setBezierSegment( const css::geometry::RealBezierSegment2D& point, ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
69 // XServiceInfo
70 virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override;
71 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception ) override;
72 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override;
74 B2DPolyPolygon getPolyPolygon() const;
76 protected:
77 /// Check whether index is a valid polygon index
78 void checkIndex( sal_Int32 nIndex ) const // throw (css::lang::IndexOutOfBoundsException);
80 if( nIndex < 0 || nIndex >= static_cast<sal_Int32>(maPolyPoly.count()) )
81 throw css::lang::IndexOutOfBoundsException();
84 B2DPolyPolygon getSubsetPolyPolygon( sal_Int32 nPolygonIndex,
85 sal_Int32 nNumberOfPolygons,
86 sal_Int32 nPointIndex,
87 sal_Int32 nNumberOfPoints ) const;
89 /// Get cow copy of internal polygon. not thread-safe outside this object.
90 const B2DPolyPolygon& getPolyPolygonUnsafe() const
92 return maPolyPoly;
95 /// Called whenever internal polypolygon gets modified
96 virtual void modifying() const {}
98 private:
99 UnoPolyPolygon(const UnoPolyPolygon&) = delete;
100 UnoPolyPolygon& operator=(const UnoPolyPolygon&) = delete;
102 B2DPolyPolygon maPolyPoly;
103 css::rendering::FillRule meFillRule;
108 #endif // INCLUDED_BASEGFX_TOOLS_UNOPOLYPOLYGON_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */