1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _CHART2_SCALING_HXX 28 #define _CHART2_SCALING_HXX 29 #include "ServiceMacros.hxx" 30 #include <com/sun/star/chart2/XScaling.hpp> 31 #include <com/sun/star/lang/XServiceInfo.hpp> 32 #include <com/sun/star/lang/XServiceName.hpp> 33 #include <com/sun/star/uno/XComponentContext.hpp> 34 #include <cppuhelper/implbase3.hxx> 35 36 //............................................................................. 37 namespace chart 38 { 39 //............................................................................. 40 41 //----------------------------------------------------------------------------- 42 /** 43 */ 44 45 class LogarithmicScaling : 46 public ::cppu::WeakImplHelper3 < 47 ::com::sun::star::chart2::XScaling, 48 ::com::sun::star::lang::XServiceName, 49 ::com::sun::star::lang::XServiceInfo 50 > 51 { 52 public: 53 /// base is 10.0 54 explicit LogarithmicScaling( 55 const ::com::sun::star::uno::Reference< 56 ::com::sun::star::uno::XComponentContext > & xContext ); 57 LogarithmicScaling( double fBase = 10.0 ); 58 virtual ~LogarithmicScaling(); 59 60 /// establish methods for factory instatiation 61 APPHELPER_SERVICE_FACTORY_HELPER( LogarithmicScaling ) 62 /// declare XServiceInfo methods 63 APPHELPER_XSERVICEINFO_DECL() 64 65 // ____ XScaling ____ 66 virtual double SAL_CALL doScaling( double value ) 67 throw (::com::sun::star::uno::RuntimeException); 68 69 virtual ::com::sun::star::uno::Reference< 70 ::com::sun::star::chart2::XScaling > SAL_CALL 71 getInverseScaling() throw (::com::sun::star::uno::RuntimeException); 72 73 // ____ XServiceName ____ 74 virtual ::rtl::OUString SAL_CALL getServiceName() 75 throw (::com::sun::star::uno::RuntimeException); 76 77 private: 78 const double m_fBase; 79 const double m_fLogOfBase; 80 81 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 82 }; 83 84 // ---------------------------------------- 85 86 class ExponentialScaling : 87 public ::cppu::WeakImplHelper3 < 88 ::com::sun::star::chart2::XScaling, 89 ::com::sun::star::lang::XServiceName, 90 ::com::sun::star::lang::XServiceInfo 91 > 92 { 93 public: 94 /// base is 10.0 95 explicit ExponentialScaling( 96 const ::com::sun::star::uno::Reference< 97 ::com::sun::star::uno::XComponentContext > & xContext ); 98 explicit ExponentialScaling( double fBase = 10.0 ); 99 virtual ~ExponentialScaling(); 100 101 /// establish methods for factory instatiation 102 APPHELPER_SERVICE_FACTORY_HELPER( ExponentialScaling ) 103 /// declare XServiceInfo methods 104 APPHELPER_XSERVICEINFO_DECL() 105 106 // ____ XScaling ____ 107 virtual double SAL_CALL 108 doScaling( double value ) 109 throw (::com::sun::star::uno::RuntimeException); 110 111 virtual ::com::sun::star::uno::Reference< 112 ::com::sun::star::chart2::XScaling > SAL_CALL 113 getInverseScaling() throw (::com::sun::star::uno::RuntimeException); 114 115 // ____ XServiceName ____ 116 virtual ::rtl::OUString SAL_CALL getServiceName() 117 throw (::com::sun::star::uno::RuntimeException); 118 119 private: 120 const double m_fBase; 121 122 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 123 }; 124 125 // ---------------------------------------- 126 127 class LinearScaling : public ::cppu::WeakImplHelper3 < 128 ::com::sun::star::chart2::XScaling, 129 ::com::sun::star::lang::XServiceName, 130 ::com::sun::star::lang::XServiceInfo 131 > 132 { 133 public: 134 /// y(x) = x 135 explicit LinearScaling( 136 const ::com::sun::star::uno::Reference< 137 ::com::sun::star::uno::XComponentContext > & xContext ); 138 /// y(x) = fSlope * x + fOffset 139 LinearScaling( double fSlope = 1.0, double fOffset = 0.0 ); 140 virtual ~LinearScaling(); 141 142 /// establish methods for factory instatiation 143 APPHELPER_SERVICE_FACTORY_HELPER( LinearScaling ) 144 /// declare XServiceInfo methods 145 APPHELPER_XSERVICEINFO_DECL() 146 147 // ____ XScaling ____ 148 virtual double SAL_CALL doScaling( double value ) 149 throw (::com::sun::star::uno::RuntimeException); 150 151 virtual ::com::sun::star::uno::Reference< 152 ::com::sun::star::chart2::XScaling > SAL_CALL 153 getInverseScaling() throw (::com::sun::star::uno::RuntimeException); 154 155 // ____ XServiceName ____ 156 virtual ::rtl::OUString SAL_CALL getServiceName() 157 throw (::com::sun::star::uno::RuntimeException); 158 159 private: 160 const double m_fSlope; 161 const double m_fOffset; 162 163 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 164 }; 165 166 // ---------------------------------------- 167 168 class PowerScaling : public ::cppu::WeakImplHelper3 < 169 ::com::sun::star::chart2::XScaling, 170 ::com::sun::star::lang::XServiceName, 171 ::com::sun::star::lang::XServiceInfo 172 > 173 { 174 public: 175 /// exponent 10.0 176 explicit PowerScaling( 177 const ::com::sun::star::uno::Reference< 178 ::com::sun::star::uno::XComponentContext > & xContext ); 179 explicit PowerScaling( double fExponent = 10.0 ); 180 virtual ~PowerScaling(); 181 182 /// establish methods for factory instatiation 183 APPHELPER_SERVICE_FACTORY_HELPER( PowerScaling ) 184 /// declare XServiceInfo methods 185 APPHELPER_XSERVICEINFO_DECL() 186 187 // ____ XScaling ____ 188 virtual double SAL_CALL 189 doScaling( double value ) 190 throw (::com::sun::star::uno::RuntimeException); 191 192 virtual ::com::sun::star::uno::Reference< 193 ::com::sun::star::chart2::XScaling > SAL_CALL 194 getInverseScaling() throw (::com::sun::star::uno::RuntimeException); 195 196 // ____ XServiceName ____ 197 virtual ::rtl::OUString SAL_CALL getServiceName() 198 throw (::com::sun::star::uno::RuntimeException); 199 200 private: 201 const double m_fExponent; 202 203 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 204 }; 205 206 //............................................................................. 207 } //namespace chart 208 //............................................................................. 209 #endif 210 211