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_CANVAS_PARAMETRICPOLYPOLYGON_HXX
21 #define INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/rendering/XGraphicDevice.hpp>
25 #include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp>
26 #include <cppuhelper/compbase2.hxx>
27 #include <comphelper/broadcasthelper.hxx>
28 #include <basegfx/polygon/b2dpolygon.hxx>
30 #include <boost/utility.hpp>
31 #include <canvas/canvastoolsdllapi.h>
40 /* Definition of ParametricPolyPolygon class */
44 typedef ::cppu::WeakComponentImplHelper2
< ::com::sun::star::rendering::XParametricPolyPolygon2D
,
45 ::com::sun::star::lang::XServiceInfo
> ParametricPolyPolygon_Base
;
47 class CANVASTOOLS_DLLPUBLIC ParametricPolyPolygon
: public ::comphelper::OBaseMutex
,
48 public ParametricPolyPolygon_Base
,
49 private ::boost::noncopyable
59 /** Structure of defining values for the ParametricPolyPolygon
61 This is used to copy the state of the
62 ParametricPolyPolygon atomically.
66 Values( const ::basegfx::B2DPolygon
& rGradientPoly
,
67 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > >& rColors
,
68 const ::com::sun::star::uno::Sequence
< double >& rStops
,
70 GradientType eType
) :
71 maGradientPoly( rGradientPoly
),
72 mnAspectRatio( nAspectRatio
),
79 /// Polygonal gradient shape (ignored for linear and axial gradient)
80 const ::basegfx::B2DPolygon maGradientPoly
;
82 /// Aspect ratio of gradient, affects scaling of innermost gradient polygon
83 const double mnAspectRatio
;
86 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > > maColors
;
88 /// Gradient color stops
89 const ::com::sun::star::uno::Sequence
< double > maStops
;
91 /// Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
92 const GradientType meType
;
95 static ::com::sun::star::uno::Sequence
< OUString
> getAvailableServiceNames();
96 static ParametricPolyPolygon
* create(
97 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
98 const OUString
& rServiceName
,
99 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& rArgs
);
101 /// Dispose all internal references
102 virtual void SAL_CALL
disposing();
104 // XParametricPolyPolygon2D
105 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XPolyPolygon2D
> SAL_CALL
getOutline( double t
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
106 virtual ::com::sun::star::uno::Sequence
< double > SAL_CALL
getColor( double t
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
107 virtual ::com::sun::star::uno::Sequence
< double > SAL_CALL
getPointColor( const ::com::sun::star::geometry::RealPoint2D
& point
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
108 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XColorSpace
> SAL_CALL
getColorSpace() throw (::com::sun::star::uno::RuntimeException
);
111 virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
);
112 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
);
113 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
);
115 /// Query all defining values of this object atomically
116 Values
getValues() const;
119 ~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
122 static ParametricPolyPolygon
* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
124 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > >& colors
,
125 const ::com::sun::star::uno::Sequence
< double >& stops
);
126 static ParametricPolyPolygon
* createEllipticalGradient( const ::com::sun::star::uno::Reference
<
127 ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
128 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > >& colors
,
129 const ::com::sun::star::uno::Sequence
< double >& stops
,
131 static ParametricPolyPolygon
* createRectangularGradient( const ::com::sun::star::uno::Reference
<
132 ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
133 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > >& colors
,
134 const ::com::sun::star::uno::Sequence
< double >& stops
,
137 /// Private, because objects can only be created from the static factories
138 ParametricPolyPolygon( const ::com::sun::star::uno::Reference
<
139 ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
140 const ::basegfx::B2DPolygon
& rGradientPoly
,
142 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > >& colors
,
143 const ::com::sun::star::uno::Sequence
< double >& stops
,
144 double nAspectRatio
);
145 ParametricPolyPolygon( const ::com::sun::star::uno::Reference
<
146 ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
148 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > >& colors
,
149 const ::com::sun::star::uno::Sequence
< double >& stops
);
151 ::com::sun::star::uno::Reference
<
152 ::com::sun::star::rendering::XGraphicDevice
> mxDevice
;
154 /// All defining values of this object
155 const Values maValues
;
159 #endif /* INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX */
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */