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 
30 namespace com::sun::star::rendering { class XGraphicDevice; }
31 
32 
33 /* Definition of ParametricPolyPolygon class */
34 
35 namespace canvas
36 {
37  typedef cppu::WeakComponentImplHelper< css::rendering::XParametricPolyPolygon2D,
38  css::lang::XServiceInfo > ParametricPolyPolygon_Base;
39 
41  public ParametricPolyPolygon_Base
42  {
43  public:
44  enum class GradientType
45  {
46  Linear,
47  Elliptical,
48  Rectangular
49  };
50 
56  struct Values
57  {
58  Values( const ::basegfx::B2DPolygon& rGradientPoly,
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( rGradientPoly ),
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  const OUString& rServiceName,
91  const css::uno::Sequence< css::uno::Any >& rArgs );
92 
94  virtual void SAL_CALL disposing() 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.
113  ParametricPolyPolygon& operator=( const ParametricPolyPolygon& ) = delete;
114 
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,
123  double fAspect );
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,
128  double fAspect );
129 
131  ParametricPolyPolygon( const css::uno::Reference<
132  css::rendering::XGraphicDevice >& rDevice,
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( const css::uno::Reference<
139  css::rendering::XGraphicDevice >& rDevice,
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: */
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.