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 .
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp>
24 #include <cppuhelper/compbase.hxx>
25 #include <cppuhelper/basemutex.hxx>
26 #include <basegfx/polygon/b2dpolygon.hxx>
28 #include <canvas/canvastoolsdllapi.h>
30 namespace com::sun::star::rendering
{ class XGraphicDevice
; }
33 /* Definition of ParametricPolyPolygon class */
37 typedef cppu::WeakComponentImplHelper
< css::rendering::XParametricPolyPolygon2D
,
38 css::lang::XServiceInfo
> ParametricPolyPolygon_Base
;
40 class CANVASTOOLS_DLLPUBLIC ParametricPolyPolygon final
: public ::cppu::BaseMutex
,
41 public ParametricPolyPolygon_Base
44 enum class GradientType
51 /** Structure of defining values for the ParametricPolyPolygon
53 This is used to copy the state of the
54 ParametricPolyPolygon atomically.
58 Values( const ::basegfx::B2DPolygon
& rGradientPoly
,
59 const css::uno::Sequence
< css::uno::Sequence
< double > >& rColors
,
60 const css::uno::Sequence
< double >& rStops
,
62 GradientType eType
) :
63 maGradientPoly( rGradientPoly
),
64 mnAspectRatio( nAspectRatio
),
71 /// Polygonal gradient shape (ignored for linear and axial gradient)
72 const ::basegfx::B2DPolygon maGradientPoly
;
74 /// Aspect ratio of gradient, affects scaling of innermost gradient polygon
75 const double mnAspectRatio
;
78 const css::uno::Sequence
< css::uno::Sequence
< double > > maColors
;
80 /// Gradient color stops
81 const css::uno::Sequence
< double > maStops
;
83 /// Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
84 const GradientType meType
;
87 static css::uno::Sequence
< OUString
> getAvailableServiceNames();
88 static ParametricPolyPolygon
* create(
89 const css::uno::Reference
< css::rendering::XGraphicDevice
>& rDevice
,
90 const OUString
& rServiceName
,
91 const css::uno::Sequence
< css::uno::Any
>& rArgs
);
93 /// Dispose all internal references
94 virtual void SAL_CALL
disposing() override
;
96 // XParametricPolyPolygon2D
97 virtual css::uno::Reference
< css::rendering::XPolyPolygon2D
> SAL_CALL
getOutline( double t
) override
;
98 virtual css::uno::Sequence
< double > SAL_CALL
getColor( double t
) override
;
99 virtual css::uno::Sequence
< double > SAL_CALL
getPointColor( const css::geometry::RealPoint2D
& point
) override
;
100 virtual css::uno::Reference
< css::rendering::XColorSpace
> SAL_CALL
getColorSpace() override
;
103 virtual OUString SAL_CALL
getImplementationName( ) override
;
104 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
105 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
107 /// Query all defining values of this object atomically
108 Values
getValues() const;
111 virtual ~ParametricPolyPolygon() override
; // we're a ref-counted UNO class. _We_ destroy ourselves.
112 ParametricPolyPolygon(const ParametricPolyPolygon
&) = delete;
113 ParametricPolyPolygon
& operator=( const ParametricPolyPolygon
& ) = delete;
115 static ParametricPolyPolygon
* createLinearHorizontalGradient( const css::uno::Reference
<
116 css::rendering::XGraphicDevice
>& rDevice
,
117 const css::uno::Sequence
< css::uno::Sequence
< double > >& colors
,
118 const css::uno::Sequence
< double >& stops
);
119 static ParametricPolyPolygon
* createEllipticalGradient( const css::uno::Reference
<
120 css::rendering::XGraphicDevice
>& rDevice
,
121 const css::uno::Sequence
< css::uno::Sequence
< double > >& colors
,
122 const css::uno::Sequence
< double >& stops
,
124 static ParametricPolyPolygon
* createRectangularGradient( const css::uno::Reference
<
125 css::rendering::XGraphicDevice
>& rDevice
,
126 const css::uno::Sequence
< css::uno::Sequence
< double > >& colors
,
127 const css::uno::Sequence
< double >& stops
,
130 /// Private, because objects can only be created from the static factories
131 ParametricPolyPolygon( const css::uno::Reference
<
132 css::rendering::XGraphicDevice
>& rDevice
,
133 const ::basegfx::B2DPolygon
& rGradientPoly
,
135 const css::uno::Sequence
< css::uno::Sequence
< double > >& colors
,
136 const css::uno::Sequence
< double >& stops
,
137 double nAspectRatio
);
138 ParametricPolyPolygon( const css::uno::Reference
<
139 css::rendering::XGraphicDevice
>& rDevice
,
141 const css::uno::Sequence
< css::uno::Sequence
< double > >& colors
,
142 const css::uno::Sequence
< double >& stops
);
145 css::rendering::XGraphicDevice
> mxDevice
;
147 /// All defining values of this object
148 const Values maValues
;
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */