Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX
30 : : #define INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX
31 : :
32 : : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : : #include <com/sun/star/rendering/XGraphicDevice.hpp>
34 : : #include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp>
35 : : #include <cppuhelper/compbase2.hxx>
36 : : #include <comphelper/broadcasthelper.hxx>
37 : : #include <basegfx/polygon/b2dpolygon.hxx>
38 : :
39 : : #include <boost/utility.hpp>
40 : : #include <canvas/canvastoolsdllapi.h>
41 : :
42 : : namespace basegfx
43 : : {
44 : : class B2DPolygon;
45 : : class B2DHomMatrix;
46 : : }
47 : :
48 : :
49 : : /* Definition of ParametricPolyPolygon class */
50 : :
51 : : namespace canvas
52 : : {
53 : : typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XParametricPolyPolygon2D,
54 : : ::com::sun::star::lang::XServiceInfo > ParametricPolyPolygon_Base;
55 : :
56 : : class CANVASTOOLS_DLLPUBLIC ParametricPolyPolygon : public ::comphelper::OBaseMutex,
57 : : public ParametricPolyPolygon_Base,
58 : : private ::boost::noncopyable
59 : : {
60 : : public:
61 : : enum GradientType
62 : : {
63 : : GRADIENT_LINEAR,
64 : : GRADIENT_ELLIPTICAL,
65 : : GRADIENT_RECTANGULAR
66 : : };
67 : :
68 : : /** Structure of defining values for the ParametricPolyPolygon
69 : :
70 : : This is used to copy the state of the
71 : : ParametricPolyPolygon atomically.
72 : : */
73 [ # # ][ # # ]: 0 : struct Values
[ # # ][ # # ]
74 : : {
75 : 0 : Values( const ::basegfx::B2DPolygon& rGradientPoly,
76 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& rColors,
77 : : const ::com::sun::star::uno::Sequence< double >& rStops,
78 : : double nAspectRatio,
79 : : GradientType eType ) :
80 : : maGradientPoly( rGradientPoly ),
81 : : mnAspectRatio( nAspectRatio ),
82 : : maColors( rColors ),
83 : : maStops( rStops ),
84 [ # # ][ # # ]: 0 : meType( eType )
85 : : {
86 : 0 : }
87 : :
88 : : /// Polygonal gradient shape (ignored for linear and axial gradient)
89 : : const ::basegfx::B2DPolygon maGradientPoly;
90 : :
91 : : /// Aspect ratio of gradient, affects scaling of innermost gradient polygon
92 : : const double mnAspectRatio;
93 : :
94 : : /// Gradient colors
95 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > maColors;
96 : :
97 : : /// Gradient color stops
98 : : const ::com::sun::star::uno::Sequence< double > maStops;
99 : :
100 : : /// Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
101 : : const GradientType meType;
102 : : };
103 : :
104 : : static ::com::sun::star::uno::Sequence< ::rtl::OUString > getAvailableServiceNames();
105 : : static ParametricPolyPolygon* create(
106 : : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
107 : : const ::rtl::OUString& rServiceName,
108 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs );
109 : :
110 : : /// Dispose all internal references
111 : : virtual void SAL_CALL disposing();
112 : :
113 : : // XParametricPolyPolygon2D
114 : : 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);
115 : : virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getColor( double t ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
116 : : 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);
117 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace > SAL_CALL getColorSpace() throw (::com::sun::star::uno::RuntimeException);
118 : :
119 : : // XServiceInfo
120 : : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
121 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
122 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
123 : :
124 : : /// Query all defining values of this object atomically
125 : : Values getValues() const;
126 : :
127 : : protected:
128 : : ~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
129 : :
130 : : private:
131 : : static ParametricPolyPolygon* createLinearHorizontalGradient( 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 );
135 : : static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference<
136 : : ::com::sun::star::rendering::XGraphicDevice >& rDevice,
137 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
138 : : const ::com::sun::star::uno::Sequence< double >& stops,
139 : : double fAspect );
140 : : static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference<
141 : : ::com::sun::star::rendering::XGraphicDevice >& rDevice,
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 fAspect );
145 : :
146 : : /// Private, because objects can only be created from the static factories
147 : : ParametricPolyPolygon( const ::com::sun::star::uno::Reference<
148 : : ::com::sun::star::rendering::XGraphicDevice >& rDevice,
149 : : const ::basegfx::B2DPolygon& rGradientPoly,
150 : : GradientType eType,
151 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
152 : : const ::com::sun::star::uno::Sequence< double >& stops,
153 : : double nAspectRatio );
154 : : ParametricPolyPolygon( const ::com::sun::star::uno::Reference<
155 : : ::com::sun::star::rendering::XGraphicDevice >& rDevice,
156 : : GradientType eType,
157 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
158 : : const ::com::sun::star::uno::Sequence< double >& stops );
159 : :
160 : : ::com::sun::star::uno::Reference<
161 : : ::com::sun::star::rendering::XGraphicDevice > mxDevice;
162 : :
163 : : /// All defining values of this object
164 : : const Values maValues;
165 : : };
166 : : }
167 : :
168 : : #endif /* INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX */
169 : :
170 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|