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>
24 #include <cppuhelper/compbase.hxx>
25 #include <cppuhelper/basemutex.hxx>
27 
29 #include <rtl/ref.hxx>
30 
31 namespace com::sun::star::rendering { class XGraphicDevice; }
32 
33 
34 /* Definition of ParametricPolyPolygon class */
35 
36 namespace canvas
37 {
38  typedef cppu::WeakComponentImplHelper< css::rendering::XParametricPolyPolygon2D,
39  css::lang::XServiceInfo > ParametricPolyPolygon_Base;
40 
42  public ParametricPolyPolygon_Base
43  {
44  public:
45  enum class GradientType
46  {
47  Linear,
48  Elliptical,
49  Rectangular
50  };
51 
57  struct Values
58  {
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 )
69  {
70  }
71 
73  const ::basegfx::B2DPolygon maGradientPoly;
74 
76  const double mnAspectRatio;
77 
79  const css::uno::Sequence< css::uno::Sequence< double > > maColors;
80 
82  const css::uno::Sequence< double > maStops;
83 
86  };
87 
88  static css::uno::Sequence< OUString > getAvailableServiceNames();
90  const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
91  std::u16string_view rServiceName,
92  const css::uno::Sequence< css::uno::Any >& rArgs );
93 
95  virtual void SAL_CALL disposing() override;
96 
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;
102 
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;
107 
109  Values getValues() const;
110 
111  private:
112  virtual ~ParametricPolyPolygon() override; // we're a ref-counted UNO class. _We_ destroy ourselves.
114  ParametricPolyPolygon& operator=( const ParametricPolyPolygon& ) = delete;
115 
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 );
130 
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 );
144 
145  css::uno::Reference<
146  css::rendering::XGraphicDevice > mxDevice;
147 
150  };
151 }
152 
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PrimitiveType meType
Definition: dx_9rm.cxx:182
const GradientType meType
Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly) ...
const css::uno::Sequence< css::uno::Sequence< double > > maColors
Gradient colors.
#define CANVASTOOLS_DLLPUBLIC
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
css::uno::Reference< css::rendering::XGraphicDevice > mxDevice
Values(const ::basegfx::B2DPolygon &rGradientPoly, const css::uno::Sequence< css::uno::Sequence< double > > &rColors, const css::uno::Sequence< double > &rStops, double nAspectRatio, GradientType eType)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< deployment::XPackageRegistry > create(Reference< deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, Reference< XComponentContext > const &xComponentContext)
const css::uno::Sequence< double > maStops
Gradient color stops.
cppu::WeakComponentImplHelper< css::rendering::XParametricPolyPolygon2D, css::lang::XServiceInfo > ParametricPolyPolygon_Base
unsigned char sal_Bool
const ::basegfx::B2DPolygon maGradientPoly
Polygonal gradient shape (ignored for linear and axial gradient)
const Values maValues
All defining values of this object.
Structure of defining values for the ParametricPolyPolygon.
const double mnAspectRatio
Aspect ratio of gradient, affects scaling of innermost gradient polygon.