LibreOffice Module canvas (master) 1
parametricpolypolygon.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <com/sun/star/lang/XServiceInfo.hpp>
23#include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp>
26
28#include <rtl/ref.hxx>
29#include <utility>
30
31namespace com::sun::star::rendering { class XGraphicDevice; }
32
33
34/* Definition of ParametricPolyPolygon class */
35
36namespace canvas
37{
38 typedef comphelper::WeakComponentImplHelper< css::rendering::XParametricPolyPolygon2D,
39 css::lang::XServiceInfo > ParametricPolyPolygon_Base;
40
42 {
43 public:
44 enum class GradientType
45 {
46 Linear,
47 Elliptical,
48 Rectangular
49 };
50
56 struct Values
57 {
59 const css::uno::Sequence< css::uno::Sequence< double > >& rColors,
60 const css::uno::Sequence< double >& rStops,
61 double nAspectRatio,
62 GradientType eType ) :
63 maGradientPoly(std::move( aGradientPoly )),
64 mnAspectRatio( nAspectRatio ),
65 maColors( rColors ),
66 maStops( rStops ),
67 meType( eType )
68 {
69 }
70
72 const ::basegfx::B2DPolygon maGradientPoly;
73
75 const double mnAspectRatio;
76
78 const css::uno::Sequence< css::uno::Sequence< double > > maColors;
79
81 const css::uno::Sequence< double > maStops;
82
85 };
86
87 static css::uno::Sequence< OUString > getAvailableServiceNames();
89 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
90 std::u16string_view rServiceName,
91 const css::uno::Sequence< css::uno::Any >& rArgs );
92
94 virtual void disposing(std::unique_lock<std::mutex>&) override;
95
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;
101
102 // XServiceInfo
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;
106
108 Values getValues() const;
109
110 private:
111 virtual ~ParametricPolyPolygon() override; // we're a ref-counted UNO class. _We_ destroy ourselves.
114
115 static rtl::Reference<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 rtl::Reference<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,
123 double fAspect );
124 static rtl::Reference<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,
128 double fAspect );
129
131 ParametricPolyPolygon( css::uno::Reference<
132 css::rendering::XGraphicDevice > xDevice,
133 const ::basegfx::B2DPolygon& rGradientPoly,
134 GradientType eType,
135 const css::uno::Sequence< css::uno::Sequence< double > >& colors,
136 const css::uno::Sequence< double >& stops,
137 double nAspectRatio );
138 ParametricPolyPolygon( css::uno::Reference<
139 css::rendering::XGraphicDevice > xDevice,
140 GradientType eType,
141 const css::uno::Sequence< css::uno::Sequence< double > >& colors,
142 const css::uno::Sequence< double >& stops );
143
144 css::uno::Reference<
145 css::rendering::XGraphicDevice > mxDevice;
146
149 };
150}
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define CANVASTOOLS_DLLPUBLIC
css::uno::Reference< css::rendering::XGraphicDevice > mxDevice
ParametricPolyPolygon(css::uno::Reference< css::rendering::XGraphicDevice > xDevice, GradientType eType, const css::uno::Sequence< css::uno::Sequence< double > > &colors, const css::uno::Sequence< double > &stops)
ParametricPolyPolygon(css::uno::Reference< css::rendering::XGraphicDevice > xDevice, const ::basegfx::B2DPolygon &rGradientPoly, GradientType eType, const css::uno::Sequence< css::uno::Sequence< double > > &colors, const css::uno::Sequence< double > &stops, double nAspectRatio)
Private, because objects can only be created from the static factories.
ParametricPolyPolygon & operator=(const ParametricPolyPolygon &)=delete
const Values maValues
All defining values of this object.
ParametricPolyPolygon(const ParametricPolyPolygon &)=delete
PrimitiveType meType
Definition: dx_9rm.cxx:182
DocumentType eType
comphelper::WeakComponentImplHelper< css::rendering::XParametricPolyPolygon2D, css::lang::XServiceInfo > ParametricPolyPolygon_Base
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
Structure of defining values for the ParametricPolyPolygon.
const css::uno::Sequence< css::uno::Sequence< double > > maColors
Gradient colors.
const GradientType meType
Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
const ::basegfx::B2DPolygon maGradientPoly
Polygonal gradient shape (ignored for linear and axial gradient)
Values(::basegfx::B2DPolygon aGradientPoly, const css::uno::Sequence< css::uno::Sequence< double > > &rColors, const css::uno::Sequence< double > &rStops, double nAspectRatio, GradientType eType)
const double mnAspectRatio
Aspect ratio of gradient, affects scaling of innermost gradient polygon.
const css::uno::Sequence< double > maStops
Gradient color stops.
unsigned char sal_Bool