xref: /aoo42x/main/chart2/source/inc/Scaling.hxx (revision de7b3f82)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CHART2_SCALING_HXX
24 #define _CHART2_SCALING_HXX
25 #include "ServiceMacros.hxx"
26 #include <com/sun/star/chart2/XScaling.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/XServiceName.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <cppuhelper/implbase3.hxx>
31 
32 //.............................................................................
33 namespace chart
34 {
35 //.............................................................................
36 
37 //-----------------------------------------------------------------------------
38 /**
39 */
40 
41 class LogarithmicScaling :
42         public ::cppu::WeakImplHelper3 <
43         ::com::sun::star::chart2::XScaling,
44         ::com::sun::star::lang::XServiceName,
45         ::com::sun::star::lang::XServiceInfo
46         >
47 {
48 public:
49     /// base is 10.0
50     explicit LogarithmicScaling(
51         const ::com::sun::star::uno::Reference<
52             ::com::sun::star::uno::XComponentContext > & xContext );
53     LogarithmicScaling( double fBase = 10.0 );
54     virtual ~LogarithmicScaling();
55 
56     /// establish methods for factory instatiation
57 	APPHELPER_SERVICE_FACTORY_HELPER( LogarithmicScaling )
58     /// declare XServiceInfo methods
59     APPHELPER_XSERVICEINFO_DECL()
60 
61     // ____ XScaling ____
62     virtual double SAL_CALL doScaling( double value )
63         throw (::com::sun::star::uno::RuntimeException);
64 
65     virtual ::com::sun::star::uno::Reference<
66         ::com::sun::star::chart2::XScaling > SAL_CALL
67         getInverseScaling() throw (::com::sun::star::uno::RuntimeException);
68 
69     // ____ XServiceName ____
70     virtual ::rtl::OUString SAL_CALL getServiceName()
71         throw (::com::sun::star::uno::RuntimeException);
72 
73 private:
74     const double m_fBase;
75     const double m_fLogOfBase;
76 
77     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >      m_xContext;
78 };
79 
80 // ----------------------------------------
81 
82 class ExponentialScaling :
83         public ::cppu::WeakImplHelper3 <
84         ::com::sun::star::chart2::XScaling,
85         ::com::sun::star::lang::XServiceName,
86         ::com::sun::star::lang::XServiceInfo
87         >
88 {
89 public:
90     /// base is 10.0
91     explicit ExponentialScaling(
92         const ::com::sun::star::uno::Reference<
93             ::com::sun::star::uno::XComponentContext > & xContext );
94     explicit ExponentialScaling( double fBase = 10.0 );
95     virtual ~ExponentialScaling();
96 
97     /// establish methods for factory instatiation
98 	APPHELPER_SERVICE_FACTORY_HELPER( ExponentialScaling )
99     /// declare XServiceInfo methods
100     APPHELPER_XSERVICEINFO_DECL()
101 
102     // ____ XScaling ____
103         virtual double SAL_CALL
104     doScaling( double value )
105         throw (::com::sun::star::uno::RuntimeException);
106 
107         virtual ::com::sun::star::uno::Reference<
108         ::com::sun::star::chart2::XScaling > SAL_CALL
109     getInverseScaling() throw (::com::sun::star::uno::RuntimeException);
110 
111     // ____ XServiceName ____
112     virtual ::rtl::OUString SAL_CALL getServiceName()
113         throw (::com::sun::star::uno::RuntimeException);
114 
115 private:
116     const double m_fBase;
117 
118     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >      m_xContext;
119 };
120 
121 // ----------------------------------------
122 
123 class LinearScaling : public ::cppu::WeakImplHelper3 <
124         ::com::sun::star::chart2::XScaling,
125         ::com::sun::star::lang::XServiceName,
126         ::com::sun::star::lang::XServiceInfo
127         >
128 {
129 public:
130     /// y(x) = x
131     explicit LinearScaling(
132         const ::com::sun::star::uno::Reference<
133             ::com::sun::star::uno::XComponentContext > & xContext );
134     /// y(x) = fSlope * x + fOffset
135     LinearScaling( double fSlope = 1.0, double fOffset = 0.0 );
136     virtual ~LinearScaling();
137 
138     /// establish methods for factory instatiation
139 	APPHELPER_SERVICE_FACTORY_HELPER( LinearScaling )
140     /// declare XServiceInfo methods
141     APPHELPER_XSERVICEINFO_DECL()
142 
143     // ____ XScaling ____
144     virtual double SAL_CALL doScaling( double value )
145         throw (::com::sun::star::uno::RuntimeException);
146 
147     virtual ::com::sun::star::uno::Reference<
148         ::com::sun::star::chart2::XScaling > SAL_CALL
149         getInverseScaling() throw (::com::sun::star::uno::RuntimeException);
150 
151     // ____ XServiceName ____
152     virtual ::rtl::OUString SAL_CALL getServiceName()
153         throw (::com::sun::star::uno::RuntimeException);
154 
155 private:
156     const double m_fSlope;
157     const double m_fOffset;
158 
159     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >      m_xContext;
160 };
161 
162 // ----------------------------------------
163 
164 class PowerScaling : public ::cppu::WeakImplHelper3 <
165         ::com::sun::star::chart2::XScaling,
166         ::com::sun::star::lang::XServiceName,
167         ::com::sun::star::lang::XServiceInfo
168         >
169 {
170 public:
171     /// exponent 10.0
172     explicit PowerScaling(
173         const ::com::sun::star::uno::Reference<
174             ::com::sun::star::uno::XComponentContext > & xContext );
175     explicit PowerScaling( double fExponent = 10.0 );
176     virtual ~PowerScaling();
177 
178     /// establish methods for factory instatiation
179 	APPHELPER_SERVICE_FACTORY_HELPER( PowerScaling )
180     /// declare XServiceInfo methods
181     APPHELPER_XSERVICEINFO_DECL()
182 
183     // ____ XScaling ____
184         virtual double SAL_CALL
185     doScaling( double value )
186         throw (::com::sun::star::uno::RuntimeException);
187 
188         virtual ::com::sun::star::uno::Reference<
189         ::com::sun::star::chart2::XScaling > SAL_CALL
190     getInverseScaling() throw (::com::sun::star::uno::RuntimeException);
191 
192     // ____ XServiceName ____
193     virtual ::rtl::OUString SAL_CALL getServiceName()
194         throw (::com::sun::star::uno::RuntimeException);
195 
196 private:
197     const double m_fExponent;
198 
199     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >      m_xContext;
200 };
201 
202 //.............................................................................
203 } //namespace chart
204 //.............................................................................
205 #endif
206 
207