LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / canvas / inc / parametricpolypolygon.hxx
blob089c42e76f5727fb3f373687cda406f3db3c875a
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 #pragma once
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>
29 #include <rtl/ref.hxx>
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 rtl::Reference<ParametricPolyPolygon> create(
90 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
91 std::u16string_view 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 rtl::Reference<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 rtl::Reference<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 rtl::Reference<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 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */