tdf#124162: Crash when trying to accept changes
[LibreOffice.git] / include / canvas / parametricpolypolygon.hxx
blob960f27c084b10ac2418c0daddf27a4e0e4a8ec25
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/XParametricPolyPolygon2D.hpp>
25 #include <cppuhelper/compbase.hxx>
26 #include <cppuhelper/basemutex.hxx>
27 #include <basegfx/polygon/b2dpolygon.hxx>
29 #include <canvas/canvastoolsdllapi.h>
31 namespace com::sun::star::rendering { class XGraphicDevice; }
34 /* Definition of ParametricPolyPolygon class */
36 namespace canvas
38 typedef cppu::WeakComponentImplHelper< css::rendering::XParametricPolyPolygon2D,
39 css::lang::XServiceInfo > ParametricPolyPolygon_Base;
41 class CANVASTOOLS_DLLPUBLIC ParametricPolyPolygon final : public ::cppu::BaseMutex,
42 public ParametricPolyPolygon_Base
44 public:
45 enum class GradientType
47 Linear,
48 Elliptical,
49 Rectangular
52 /** Structure of defining values for the ParametricPolyPolygon
54 This is used to copy the state of the
55 ParametricPolyPolygon atomically.
57 struct Values
59 Values( const ::basegfx::B2DPolygon& rGradientPoly,
60 const css::uno::Sequence< css::uno::Sequence< double > >& rColors,
61 const css::uno::Sequence< double >& rStops,
62 double nAspectRatio,
63 GradientType eType ) :
64 maGradientPoly( rGradientPoly ),
65 mnAspectRatio( nAspectRatio ),
66 maColors( rColors ),
67 maStops( rStops ),
68 meType( eType )
72 /// Polygonal gradient shape (ignored for linear and axial gradient)
73 const ::basegfx::B2DPolygon maGradientPoly;
75 /// Aspect ratio of gradient, affects scaling of innermost gradient polygon
76 const double mnAspectRatio;
78 /// Gradient colors
79 const css::uno::Sequence< css::uno::Sequence< double > > maColors;
81 /// Gradient color stops
82 const css::uno::Sequence< double > maStops;
84 /// Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
85 const GradientType meType;
88 static css::uno::Sequence< OUString > getAvailableServiceNames();
89 static ParametricPolyPolygon* create(
90 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
91 const OUString& rServiceName,
92 const css::uno::Sequence< css::uno::Any >& rArgs );
94 /// Dispose all internal references
95 virtual void SAL_CALL disposing() override;
97 // XParametricPolyPolygon2D
98 virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL getOutline( double t ) override;
99 virtual css::uno::Sequence< double > SAL_CALL getColor( double t ) override;
100 virtual css::uno::Sequence< double > SAL_CALL getPointColor( const css::geometry::RealPoint2D& point ) override;
101 virtual css::uno::Reference< css::rendering::XColorSpace > SAL_CALL getColorSpace() override;
103 // XServiceInfo
104 virtual OUString SAL_CALL getImplementationName( ) override;
105 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
106 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
108 /// Query all defining values of this object atomically
109 Values getValues() const;
111 private:
112 virtual ~ParametricPolyPolygon() override; // we're a ref-counted UNO class. _We_ destroy ourselves.
113 ParametricPolyPolygon(const ParametricPolyPolygon&) = delete;
114 ParametricPolyPolygon& operator=( const ParametricPolyPolygon& ) = delete;
116 static ParametricPolyPolygon* createLinearHorizontalGradient( const css::uno::Reference<
117 css::rendering::XGraphicDevice >& rDevice,
118 const css::uno::Sequence< css::uno::Sequence< double > >& colors,
119 const css::uno::Sequence< double >& stops );
120 static ParametricPolyPolygon* createEllipticalGradient( const css::uno::Reference<
121 css::rendering::XGraphicDevice >& rDevice,
122 const css::uno::Sequence< css::uno::Sequence< double > >& colors,
123 const css::uno::Sequence< double >& stops,
124 double fAspect );
125 static ParametricPolyPolygon* createRectangularGradient( const css::uno::Reference<
126 css::rendering::XGraphicDevice >& rDevice,
127 const css::uno::Sequence< css::uno::Sequence< double > >& colors,
128 const css::uno::Sequence< double >& stops,
129 double fAspect );
131 /// Private, because objects can only be created from the static factories
132 ParametricPolyPolygon( const css::uno::Reference<
133 css::rendering::XGraphicDevice >& rDevice,
134 const ::basegfx::B2DPolygon& rGradientPoly,
135 GradientType eType,
136 const css::uno::Sequence< css::uno::Sequence< double > >& colors,
137 const css::uno::Sequence< double >& stops,
138 double nAspectRatio );
139 ParametricPolyPolygon( const css::uno::Reference<
140 css::rendering::XGraphicDevice >& rDevice,
141 GradientType eType,
142 const css::uno::Sequence< css::uno::Sequence< double > >& colors,
143 const css::uno::Sequence< double >& stops );
145 css::uno::Reference<
146 css::rendering::XGraphicDevice > mxDevice;
148 /// All defining values of this object
149 const Values maValues;
153 #endif /* INCLUDED_CANVAS_PARAMETRICPOLYPOLYGON_HXX */
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */