Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX
21 : #define INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX
22 :
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>
29 :
30 : #include <boost/utility.hpp>
31 : #include <canvas/canvastoolsdllapi.h>
32 :
33 : namespace basegfx
34 : {
35 : class B2DPolygon;
36 : class B2DHomMatrix;
37 : }
38 :
39 :
40 : /* Definition of ParametricPolyPolygon class */
41 :
42 : namespace canvas
43 : {
44 : typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XParametricPolyPolygon2D,
45 : ::com::sun::star::lang::XServiceInfo > ParametricPolyPolygon_Base;
46 :
47 : class CANVASTOOLS_DLLPUBLIC ParametricPolyPolygon : public ::comphelper::OBaseMutex,
48 : public ParametricPolyPolygon_Base,
49 : private ::boost::noncopyable
50 : {
51 : public:
52 : enum GradientType
53 : {
54 : GRADIENT_LINEAR,
55 : GRADIENT_ELLIPTICAL,
56 : GRADIENT_RECTANGULAR
57 : };
58 :
59 : /** Structure of defining values for the ParametricPolyPolygon
60 :
61 : This is used to copy the state of the
62 : ParametricPolyPolygon atomically.
63 : */
64 0 : struct Values
65 : {
66 0 : 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,
69 : double nAspectRatio,
70 : GradientType eType ) :
71 : maGradientPoly( rGradientPoly ),
72 : mnAspectRatio( nAspectRatio ),
73 : maColors( rColors ),
74 : maStops( rStops ),
75 0 : meType( eType )
76 : {
77 0 : }
78 :
79 : /// Polygonal gradient shape (ignored for linear and axial gradient)
80 : const ::basegfx::B2DPolygon maGradientPoly;
81 :
82 : /// Aspect ratio of gradient, affects scaling of innermost gradient polygon
83 : const double mnAspectRatio;
84 :
85 : /// Gradient colors
86 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > maColors;
87 :
88 : /// Gradient color stops
89 : const ::com::sun::star::uno::Sequence< double > maStops;
90 :
91 : /// Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
92 : const GradientType meType;
93 : };
94 :
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 );
100 :
101 : /// Dispose all internal references
102 : virtual void SAL_CALL disposing();
103 :
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);
109 :
110 : // XServiceInfo
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);
114 :
115 : /// Query all defining values of this object atomically
116 : Values getValues() const;
117 :
118 : protected:
119 : ~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
120 :
121 : private:
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,
130 : double fAspect );
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,
135 : double fAspect );
136 :
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,
141 : GradientType eType,
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,
147 : GradientType eType,
148 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
149 : const ::com::sun::star::uno::Sequence< double >& stops );
150 :
151 : ::com::sun::star::uno::Reference<
152 : ::com::sun::star::rendering::XGraphicDevice > mxDevice;
153 :
154 : /// All defining values of this object
155 : const Values maValues;
156 : };
157 : }
158 :
159 : #endif /* INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX */
160 :
161 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|