191c99ff4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
391c99ff4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
491c99ff4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
591c99ff4SAndrew Rist  * distributed with this work for additional information
691c99ff4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
791c99ff4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
891c99ff4SAndrew Rist  * "License"); you may not use this file except in compliance
991c99ff4SAndrew Rist  * with the License.  You may obtain a copy of the License at
1091c99ff4SAndrew Rist  *
1191c99ff4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1291c99ff4SAndrew Rist  *
1391c99ff4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1491c99ff4SAndrew Rist  * software distributed under the License is distributed on an
1591c99ff4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1691c99ff4SAndrew Rist  * KIND, either express or implied.  See the License for the
1791c99ff4SAndrew Rist  * specific language governing permissions and limitations
1891c99ff4SAndrew Rist  * under the License.
1991c99ff4SAndrew Rist  *
2091c99ff4SAndrew Rist  *************************************************************/
2191c99ff4SAndrew Rist 
2291c99ff4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX
25cdf0e10cSrcweir #define INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
28cdf0e10cSrcweir #include <com/sun/star/rendering/XGraphicDevice.hpp>
29cdf0e10cSrcweir #include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp>
30cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
31cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
32cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <boost/utility.hpp>
35*b63233d8Sdamjan #include <canvas/canvastoolsdllapi.h>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace basegfx
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     class B2DPolygon;
40cdf0e10cSrcweir     class B2DHomMatrix;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir /* Definition of ParametricPolyPolygon class */
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace canvas
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XParametricPolyPolygon2D,
49cdf0e10cSrcweir             		   			  		      ::com::sun::star::lang::XServiceInfo > ParametricPolyPolygon_Base;
50cdf0e10cSrcweir 
51*b63233d8Sdamjan     class CANVASTOOLS_DLLPUBLIC ParametricPolyPolygon : public ::comphelper::OBaseMutex,
52cdf0e10cSrcweir                                   public ParametricPolyPolygon_Base,
53cdf0e10cSrcweir 							      private ::boost::noncopyable
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir     public:
56cdf0e10cSrcweir         enum GradientType
57cdf0e10cSrcweir         {
58cdf0e10cSrcweir             GRADIENT_LINEAR,
59cdf0e10cSrcweir             GRADIENT_ELLIPTICAL,
60cdf0e10cSrcweir             GRADIENT_RECTANGULAR
61cdf0e10cSrcweir         };
62cdf0e10cSrcweir 
63cdf0e10cSrcweir         /** Structure of defining values for the ParametricPolyPolygon
64cdf0e10cSrcweir 
65cdf0e10cSrcweir             This is used to copy the state of the
66cdf0e10cSrcweir             ParametricPolyPolygon atomically.
67cdf0e10cSrcweir          */
68cdf0e10cSrcweir         struct Values
69cdf0e10cSrcweir         {
Valuescanvas::ParametricPolyPolygon::Values70cdf0e10cSrcweir             Values( const ::basegfx::B2DPolygon&                        rGradientPoly,
71cdf0e10cSrcweir                     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >&	rColors,
72cdf0e10cSrcweir                     const ::com::sun::star::uno::Sequence< double >&	rStops,
73cdf0e10cSrcweir                     double                                              nAspectRatio,
74cdf0e10cSrcweir                     GradientType                                        eType ) :
75cdf0e10cSrcweir                 maGradientPoly( rGradientPoly ),
76cdf0e10cSrcweir                 mnAspectRatio( nAspectRatio ),
77cdf0e10cSrcweir                 maColors( rColors ),
78cdf0e10cSrcweir                 maStops( rStops ),
79cdf0e10cSrcweir                 meType( eType )
80cdf0e10cSrcweir             {
81cdf0e10cSrcweir             }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir             /// Polygonal gradient shape (ignored for linear and axial gradient)
84cdf0e10cSrcweir             const ::basegfx::B2DPolygon							maGradientPoly;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir             /// Aspect ratio of gradient, affects scaling of innermost gradient polygon
87cdf0e10cSrcweir             const double										mnAspectRatio;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir             /// Gradient colors
90cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >		maColors;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             /// Gradient color stops
93cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< double >		maStops;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir             /// Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
96cdf0e10cSrcweir             const GradientType									meType;
97cdf0e10cSrcweir         };
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         static ::com::sun::star::uno::Sequence< ::rtl::OUString > getAvailableServiceNames();
100cdf0e10cSrcweir         static ParametricPolyPolygon* create(
101cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
102cdf0e10cSrcweir             const ::rtl::OUString& rServiceName,
103cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         /// Dispose all internal references
106cdf0e10cSrcweir         virtual void SAL_CALL disposing();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         // XParametricPolyPolygon2D
109cdf0e10cSrcweir         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);
110cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getColor( double t ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir         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);
112cdf0e10cSrcweir 	    virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace > SAL_CALL getColorSpace() throw (::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         // XServiceInfo
115cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         /// Query all defining values of this object atomically
120cdf0e10cSrcweir         Values getValues() const;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     protected:
123cdf0e10cSrcweir         ~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     private:
126cdf0e10cSrcweir         static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference<
127cdf0e10cSrcweir                                                                          ::com::sun::star::rendering::XGraphicDevice >& rDevice,
128cdf0e10cSrcweir                                                                       const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
129cdf0e10cSrcweir                                                                       const ::com::sun::star::uno::Sequence< double >& stops );
130cdf0e10cSrcweir         static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference<
131cdf0e10cSrcweir                                                                    ::com::sun::star::rendering::XGraphicDevice >& rDevice,
132cdf0e10cSrcweir                                                                 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
133cdf0e10cSrcweir                                                                 const ::com::sun::star::uno::Sequence< double >& stops,
134cdf0e10cSrcweir                                                                 double fAspect );
135cdf0e10cSrcweir         static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference<
136cdf0e10cSrcweir                                                                     ::com::sun::star::rendering::XGraphicDevice >& rDevice,
137cdf0e10cSrcweir                                                                  const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
138cdf0e10cSrcweir                                                                  const ::com::sun::star::uno::Sequence< double >& stops,
139cdf0e10cSrcweir                                                                  double fAspect );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         /// Private, because objects can only be created from the static factories
142cdf0e10cSrcweir         ParametricPolyPolygon( const ::com::sun::star::uno::Reference<
143cdf0e10cSrcweir                                	::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
144cdf0e10cSrcweir                                const ::basegfx::B2DPolygon& 					rGradientPoly,
145cdf0e10cSrcweir                                GradientType	  									eType,
146cdf0e10cSrcweir                                const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& 	colors,
147cdf0e10cSrcweir                                const ::com::sun::star::uno::Sequence< double >& 	stops );
148cdf0e10cSrcweir         ParametricPolyPolygon( const ::com::sun::star::uno::Reference<
149cdf0e10cSrcweir                                	::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
150cdf0e10cSrcweir                                const ::basegfx::B2DPolygon& 					rGradientPoly,
151cdf0e10cSrcweir                                GradientType	  									eType,
152cdf0e10cSrcweir                                const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& 	colors,
153cdf0e10cSrcweir                                const ::com::sun::star::uno::Sequence< double >& 	stops,
154cdf0e10cSrcweir                                double											nAspectRatio );
155cdf0e10cSrcweir         ParametricPolyPolygon( const ::com::sun::star::uno::Reference<
156cdf0e10cSrcweir                                	::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
157cdf0e10cSrcweir                                GradientType	  									eType,
158cdf0e10cSrcweir                                const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& 	colors,
159cdf0e10cSrcweir                                const ::com::sun::star::uno::Sequence< double >& 	stops );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     	::com::sun::star::uno::Reference<
162cdf0e10cSrcweir 	        ::com::sun::star::rendering::XGraphicDevice > 	 mxDevice;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         /// All defining values of this object
165cdf0e10cSrcweir         const Values                                         maValues;
166cdf0e10cSrcweir     };
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir #endif /* INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX */
170