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 28 #ifndef _NUMFMUNO_HXX 29 #define _NUMFMUNO_HXX 30 31 #include <com/sun/star/util/XNumberFormatter.hpp> 32 #include <com/sun/star/util/XNumberFormatPreviewer.hpp> 33 #include <com/sun/star/util/XNumberFormats.hpp> 34 #include <com/sun/star/util/XNumberFormatTypes.hpp> 35 #include <com/sun/star/lang/XServiceInfo.hpp> 36 #include <com/sun/star/beans/XPropertyAccess.hpp> 37 #include <cppuhelper/implbase2.hxx> 38 #include <cppuhelper/implbase3.hxx> 39 #include <comphelper/sharedmutex.hxx> 40 #include <rtl/ref.hxx> 41 42 class SvNumberformat; 43 class SvNumberFormatter; 44 class SvNumberFormatsSupplierObj; 45 46 47 // SvNumberFormatterServiceObj wird global als Service angemeldet 48 49 class SvNumberFormatterServiceObj : public cppu::WeakImplHelper3< 50 com::sun::star::util::XNumberFormatter, 51 com::sun::star::util::XNumberFormatPreviewer, 52 com::sun::star::lang::XServiceInfo> 53 { 54 private: 55 ::rtl::Reference< SvNumberFormatsSupplierObj > xSupplier; 56 mutable ::comphelper::SharedMutex m_aMutex; 57 58 public: 59 SvNumberFormatterServiceObj(); 60 virtual ~SvNumberFormatterServiceObj(); 61 62 // XNumberFormatter 63 virtual void SAL_CALL attachNumberFormatsSupplier( 64 const ::com::sun::star::uno::Reference< 65 ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier ) 66 throw(::com::sun::star::uno::RuntimeException); 67 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > 68 SAL_CALL getNumberFormatsSupplier() 69 throw(::com::sun::star::uno::RuntimeException); 70 virtual sal_Int32 SAL_CALL detectNumberFormat( sal_Int32 nKey, const ::rtl::OUString& aString ) 71 throw(::com::sun::star::util::NotNumericException, 72 ::com::sun::star::uno::RuntimeException); 73 virtual double SAL_CALL convertStringToNumber( sal_Int32 nKey, const ::rtl::OUString& aString ) 74 throw(::com::sun::star::util::NotNumericException, 75 ::com::sun::star::uno::RuntimeException); 76 virtual ::rtl::OUString SAL_CALL convertNumberToString( sal_Int32 nKey, double fValue ) 77 throw(::com::sun::star::uno::RuntimeException); 78 virtual ::com::sun::star::util::Color SAL_CALL queryColorForNumber( sal_Int32 nKey, 79 double fValue, ::com::sun::star::util::Color aDefaultColor ) 80 throw(::com::sun::star::uno::RuntimeException); 81 virtual ::rtl::OUString SAL_CALL formatString( sal_Int32 nKey, const ::rtl::OUString& aString ) 82 throw(::com::sun::star::uno::RuntimeException); 83 virtual ::com::sun::star::util::Color SAL_CALL queryColorForString( sal_Int32 nKey, 84 const ::rtl::OUString& aString, 85 ::com::sun::star::util::Color aDefaultColor ) 86 throw(::com::sun::star::uno::RuntimeException); 87 virtual ::rtl::OUString SAL_CALL getInputString( sal_Int32 nKey, double fValue ) 88 throw(::com::sun::star::uno::RuntimeException); 89 90 // XNumberFormatPreviewer 91 virtual ::rtl::OUString SAL_CALL convertNumberToPreviewString( 92 const ::rtl::OUString& aFormat, double fValue, 93 const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish ) 94 throw(::com::sun::star::util::MalformedNumberFormatException, 95 ::com::sun::star::uno::RuntimeException); 96 virtual ::com::sun::star::util::Color SAL_CALL queryPreviewColorForNumber( 97 const ::rtl::OUString& aFormat, double fValue, 98 const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish, 99 ::com::sun::star::util::Color aDefaultColor ) 100 throw(::com::sun::star::util::MalformedNumberFormatException, 101 ::com::sun::star::uno::RuntimeException); 102 103 // XServiceInfo 104 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 105 throw(::com::sun::star::uno::RuntimeException); 106 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 107 throw(::com::sun::star::uno::RuntimeException); 108 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 109 throw(::com::sun::star::uno::RuntimeException); 110 }; 111 112 113 class SvNumberFormatsObj : public cppu::WeakImplHelper3< 114 com::sun::star::util::XNumberFormats, 115 com::sun::star::util::XNumberFormatTypes, 116 com::sun::star::lang::XServiceInfo> 117 { 118 private: 119 SvNumberFormatsSupplierObj& rSupplier; 120 mutable ::comphelper::SharedMutex m_aMutex; 121 122 public: 123 SvNumberFormatsObj(SvNumberFormatsSupplierObj& pParent, ::comphelper::SharedMutex& _rMutex); 124 virtual ~SvNumberFormatsObj(); 125 126 127 // XNumberFormats 128 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL 129 getByKey( sal_Int32 nKey ) throw(::com::sun::star::uno::RuntimeException); 130 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL queryKeys( sal_Int16 nType, 131 const ::com::sun::star::lang::Locale& nLocale, sal_Bool bCreate ) 132 throw(::com::sun::star::uno::RuntimeException); 133 virtual sal_Int32 SAL_CALL queryKey( const ::rtl::OUString& aFormat, 134 const ::com::sun::star::lang::Locale& nLocale, sal_Bool bScan ) 135 throw(::com::sun::star::uno::RuntimeException); 136 virtual sal_Int32 SAL_CALL addNew( const ::rtl::OUString& aFormat, 137 const ::com::sun::star::lang::Locale& nLocale ) 138 throw(::com::sun::star::util::MalformedNumberFormatException, 139 ::com::sun::star::uno::RuntimeException); 140 virtual sal_Int32 SAL_CALL addNewConverted( const ::rtl::OUString& aFormat, 141 const ::com::sun::star::lang::Locale& nLocale, 142 const ::com::sun::star::lang::Locale& nNewLocale ) 143 throw(::com::sun::star::util::MalformedNumberFormatException, 144 ::com::sun::star::uno::RuntimeException); 145 virtual void SAL_CALL removeByKey( sal_Int32 nKey ) throw(::com::sun::star::uno::RuntimeException); 146 virtual ::rtl::OUString SAL_CALL generateFormat( sal_Int32 nBaseKey, 147 const ::com::sun::star::lang::Locale& nLocale, sal_Bool bThousands, 148 sal_Bool bRed, sal_Int16 nDecimals, sal_Int16 nLeading ) 149 throw(::com::sun::star::uno::RuntimeException); 150 151 // XNumberFormatTypes 152 virtual sal_Int32 SAL_CALL getStandardIndex( const ::com::sun::star::lang::Locale& nLocale ) 153 throw(::com::sun::star::uno::RuntimeException); 154 virtual sal_Int32 SAL_CALL getStandardFormat( sal_Int16 nType, 155 const ::com::sun::star::lang::Locale& nLocale ) 156 throw(::com::sun::star::uno::RuntimeException); 157 virtual sal_Int32 SAL_CALL getFormatIndex( sal_Int16 nIndex, 158 const ::com::sun::star::lang::Locale& nLocale ) 159 throw(::com::sun::star::uno::RuntimeException); 160 virtual sal_Bool SAL_CALL isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType ) 161 throw(::com::sun::star::uno::RuntimeException); 162 virtual sal_Int32 SAL_CALL getFormatForLocale( sal_Int32 nKey, 163 const ::com::sun::star::lang::Locale& nLocale ) 164 throw(::com::sun::star::uno::RuntimeException); 165 166 // XServiceInfo 167 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 168 throw(::com::sun::star::uno::RuntimeException); 169 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 170 throw(::com::sun::star::uno::RuntimeException); 171 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 172 throw(::com::sun::star::uno::RuntimeException); 173 174 private: 175 SvNumberFormatsObj(); // never implemented 176 }; 177 178 179 class SvNumberFormatObj : public cppu::WeakImplHelper3< 180 com::sun::star::beans::XPropertySet, 181 com::sun::star::beans::XPropertyAccess, 182 com::sun::star::lang::XServiceInfo> 183 { 184 private: 185 SvNumberFormatsSupplierObj& rSupplier; 186 sal_uLong nKey; 187 mutable ::comphelper::SharedMutex m_aMutex; 188 189 public: 190 SvNumberFormatObj( SvNumberFormatsSupplierObj& rParent, sal_uLong nK, const ::comphelper::SharedMutex& _rMutex ); 191 virtual ~SvNumberFormatObj(); 192 193 // XPropertySet 194 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 195 SAL_CALL getPropertySetInfo( ) 196 throw(::com::sun::star::uno::RuntimeException); 197 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, 198 const ::com::sun::star::uno::Any& aValue ) 199 throw(::com::sun::star::beans::UnknownPropertyException, 200 ::com::sun::star::beans::PropertyVetoException, 201 ::com::sun::star::lang::IllegalArgumentException, 202 ::com::sun::star::lang::WrappedTargetException, 203 ::com::sun::star::uno::RuntimeException); 204 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 205 const ::rtl::OUString& PropertyName ) 206 throw(::com::sun::star::beans::UnknownPropertyException, 207 ::com::sun::star::lang::WrappedTargetException, 208 ::com::sun::star::uno::RuntimeException); 209 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, 210 const ::com::sun::star::uno::Reference< 211 ::com::sun::star::beans::XPropertyChangeListener >& xListener ) 212 throw(::com::sun::star::beans::UnknownPropertyException, 213 ::com::sun::star::lang::WrappedTargetException, 214 ::com::sun::star::uno::RuntimeException); 215 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, 216 const ::com::sun::star::uno::Reference< 217 ::com::sun::star::beans::XPropertyChangeListener >& aListener ) 218 throw(::com::sun::star::beans::UnknownPropertyException, 219 ::com::sun::star::lang::WrappedTargetException, 220 ::com::sun::star::uno::RuntimeException); 221 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, 222 const ::com::sun::star::uno::Reference< 223 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 224 throw(::com::sun::star::beans::UnknownPropertyException, 225 ::com::sun::star::lang::WrappedTargetException, 226 ::com::sun::star::uno::RuntimeException); 227 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, 228 const ::com::sun::star::uno::Reference< 229 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 230 throw(::com::sun::star::beans::UnknownPropertyException, 231 ::com::sun::star::lang::WrappedTargetException, 232 ::com::sun::star::uno::RuntimeException); 233 234 // XPropertyAccess 235 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL 236 getPropertyValues() throw(::com::sun::star::uno::RuntimeException); 237 virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< 238 ::com::sun::star::beans::PropertyValue >& aProps ) 239 throw(::com::sun::star::beans::UnknownPropertyException, 240 ::com::sun::star::beans::PropertyVetoException, 241 ::com::sun::star::lang::IllegalArgumentException, 242 ::com::sun::star::lang::WrappedTargetException, 243 ::com::sun::star::uno::RuntimeException); 244 245 // XServiceInfo 246 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 247 throw(::com::sun::star::uno::RuntimeException); 248 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 249 throw(::com::sun::star::uno::RuntimeException); 250 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 251 throw(::com::sun::star::uno::RuntimeException); 252 }; 253 254 255 class SvNumberFormatSettingsObj : public cppu::WeakImplHelper2< 256 com::sun::star::beans::XPropertySet, 257 com::sun::star::lang::XServiceInfo> 258 { 259 private: 260 SvNumberFormatsSupplierObj& rSupplier; 261 mutable ::comphelper::SharedMutex m_aMutex; 262 263 public: 264 SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj& rParent, const ::comphelper::SharedMutex& _rMutex); 265 virtual ~SvNumberFormatSettingsObj(); 266 267 268 // XPropertySet 269 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 270 SAL_CALL getPropertySetInfo( ) 271 throw(::com::sun::star::uno::RuntimeException); 272 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, 273 const ::com::sun::star::uno::Any& aValue ) 274 throw(::com::sun::star::beans::UnknownPropertyException, 275 ::com::sun::star::beans::PropertyVetoException, 276 ::com::sun::star::lang::IllegalArgumentException, 277 ::com::sun::star::lang::WrappedTargetException, 278 ::com::sun::star::uno::RuntimeException); 279 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 280 const ::rtl::OUString& PropertyName ) 281 throw(::com::sun::star::beans::UnknownPropertyException, 282 ::com::sun::star::lang::WrappedTargetException, 283 ::com::sun::star::uno::RuntimeException); 284 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, 285 const ::com::sun::star::uno::Reference< 286 ::com::sun::star::beans::XPropertyChangeListener >& xListener ) 287 throw(::com::sun::star::beans::UnknownPropertyException, 288 ::com::sun::star::lang::WrappedTargetException, 289 ::com::sun::star::uno::RuntimeException); 290 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, 291 const ::com::sun::star::uno::Reference< 292 ::com::sun::star::beans::XPropertyChangeListener >& aListener ) 293 throw(::com::sun::star::beans::UnknownPropertyException, 294 ::com::sun::star::lang::WrappedTargetException, 295 ::com::sun::star::uno::RuntimeException); 296 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, 297 const ::com::sun::star::uno::Reference< 298 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 299 throw(::com::sun::star::beans::UnknownPropertyException, 300 ::com::sun::star::lang::WrappedTargetException, 301 ::com::sun::star::uno::RuntimeException); 302 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, 303 const ::com::sun::star::uno::Reference< 304 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 305 throw(::com::sun::star::beans::UnknownPropertyException, 306 ::com::sun::star::lang::WrappedTargetException, 307 ::com::sun::star::uno::RuntimeException); 308 309 // XServiceInfo 310 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 311 throw(::com::sun::star::uno::RuntimeException); 312 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 313 throw(::com::sun::star::uno::RuntimeException); 314 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 315 throw(::com::sun::star::uno::RuntimeException); 316 }; 317 318 319 320 #endif 321 322