Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / Scaling.hxx
blob6f6310933d1aa11618a391c3cb90699f309f142a
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 .
19 #pragma once
21 #include <com/sun/star/chart2/XScaling.hpp>
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/lang/XServiceName.hpp>
24 #include <cppuhelper/implbase.hxx>
26 namespace chart
29 class LogarithmicScaling final :
30 public ::cppu::WeakImplHelper<
31 css::chart2::XScaling,
32 css::lang::XServiceName,
33 css::lang::XServiceInfo
36 public:
37 /// base is 10.0
38 explicit LogarithmicScaling();
39 LogarithmicScaling( double fBase );
40 virtual ~LogarithmicScaling() override;
42 /// declare XServiceInfo methods
43 virtual OUString SAL_CALL getImplementationName() override;
44 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
45 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
47 // ____ XScaling ____
48 virtual double SAL_CALL doScaling( double value ) override;
50 virtual css::uno::Reference<
51 css::chart2::XScaling > SAL_CALL
52 getInverseScaling() override;
54 // ____ XServiceName ____
55 virtual OUString SAL_CALL getServiceName() override;
57 private:
58 const double m_fBase;
59 const double m_fLogOfBase;
62 class ExponentialScaling final :
63 public ::cppu::WeakImplHelper<
64 css::chart2::XScaling,
65 css::lang::XServiceName,
66 css::lang::XServiceInfo
69 public:
70 /// base is 10.0
71 explicit ExponentialScaling();
72 explicit ExponentialScaling( double fBase );
73 virtual ~ExponentialScaling() override;
75 /// declare XServiceInfo methods
76 virtual OUString SAL_CALL getImplementationName() override;
77 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
78 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
80 // ____ XScaling ____
81 virtual double SAL_CALL
82 doScaling( double value ) override;
84 virtual css::uno::Reference< css::chart2::XScaling > SAL_CALL
85 getInverseScaling() override;
87 // ____ XServiceName ____
88 virtual OUString SAL_CALL getServiceName() override;
90 private:
91 const double m_fBase;
94 class LinearScaling final : public ::cppu::WeakImplHelper<
95 css::chart2::XScaling,
96 css::lang::XServiceName,
97 css::lang::XServiceInfo
100 public:
101 /// y(x) = x
102 explicit LinearScaling();
103 /// y(x) = fSlope * x + fOffset
104 LinearScaling( double fSlope, double fOffset );
105 virtual ~LinearScaling() override;
107 /// declare XServiceInfo methods
108 virtual OUString SAL_CALL getImplementationName() override;
109 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
110 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
112 // ____ XScaling ____
113 virtual double SAL_CALL doScaling( double value ) override;
115 virtual css::uno::Reference< css::chart2::XScaling > SAL_CALL
116 getInverseScaling() override;
118 // ____ XServiceName ____
119 virtual OUString SAL_CALL getServiceName() override;
121 private:
122 const double m_fSlope;
123 const double m_fOffset;
126 class PowerScaling final : public ::cppu::WeakImplHelper<
127 css::chart2::XScaling,
128 css::lang::XServiceName,
129 css::lang::XServiceInfo
132 public:
133 /// exponent 10.0
134 explicit PowerScaling();
135 explicit PowerScaling( double fExponent );
136 virtual ~PowerScaling() override;
138 /// declare XServiceInfo methods
139 virtual OUString SAL_CALL getImplementationName() override;
140 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
141 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
143 // ____ XScaling ____
144 virtual double SAL_CALL
145 doScaling( double value ) override;
147 virtual css::uno::Reference< css::chart2::XScaling > SAL_CALL
148 getInverseScaling() override;
150 // ____ XServiceName ____
151 virtual OUString SAL_CALL getServiceName() override;
153 private:
154 const double m_fExponent;
157 } //namespace chart
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */