Line data Source code
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 : #include <tools/color.hxx>
21 : #include <i18nlangtag/mslangid.hxx>
22 : #include <osl/mutex.hxx>
23 : #include <rtl/ustring.hxx>
24 :
25 : #include <com/sun/star/util/Date.hpp>
26 : #include <com/sun/star/beans/PropertyAttribute.hpp>
27 : #include <cppuhelper/supportsservice.hxx>
28 :
29 : #include "numfmuno.hxx"
30 : #include <svl/numuno.hxx>
31 : #include <svl/zforlist.hxx>
32 : #include <svl/zformat.hxx>
33 : #include <svl/itemprop.hxx>
34 :
35 : #include <registerservices.hxx>
36 :
37 : using namespace com::sun::star;
38 :
39 : #define PROPERTYNAME_FMTSTR "FormatString"
40 : #define PROPERTYNAME_LOCALE "Locale"
41 : #define PROPERTYNAME_TYPE "Type"
42 : #define PROPERTYNAME_COMMENT "Comment"
43 : #define PROPERTYNAME_CURREXT "CurrencyExtension"
44 : #define PROPERTYNAME_CURRSYM "CurrencySymbol"
45 : #define PROPERTYNAME_CURRABB "CurrencyAbbreviation"
46 : #define PROPERTYNAME_DECIMALS "Decimals"
47 : #define PROPERTYNAME_LEADING "LeadingZeros"
48 : #define PROPERTYNAME_NEGRED "NegativeRed"
49 : #define PROPERTYNAME_STDFORM "StandardFormat"
50 : #define PROPERTYNAME_THOUS "ThousandsSeparator"
51 : #define PROPERTYNAME_USERDEF "UserDefined"
52 :
53 : #define PROPERTYNAME_NOZERO "NoZero"
54 : #define PROPERTYNAME_NULLDATE "NullDate"
55 : #define PROPERTYNAME_STDDEC "StandardDecimals"
56 : #define PROPERTYNAME_TWODIGIT "TwoDigitDateStart"
57 :
58 : // All without a Which-ID, Map only for PropertySetInfo
59 :
60 0 : static const SfxItemPropertyMapEntry* lcl_GetNumberFormatPropertyMap()
61 : {
62 : static const SfxItemPropertyMapEntry aNumberFormatPropertyMap_Impl[] =
63 : {
64 0 : {OUString(PROPERTYNAME_FMTSTR), 0, getCppuType((OUString*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
65 0 : {OUString(PROPERTYNAME_LOCALE), 0, getCppuType((lang::Locale*)0),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
66 0 : {OUString(PROPERTYNAME_TYPE), 0, getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
67 0 : {OUString(PROPERTYNAME_COMMENT), 0, getCppuType((OUString*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
68 0 : {OUString(PROPERTYNAME_CURREXT), 0, getCppuType((OUString*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
69 0 : {OUString(PROPERTYNAME_CURRSYM), 0, getCppuType((OUString*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
70 0 : {OUString(PROPERTYNAME_DECIMALS), 0, getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
71 0 : {OUString(PROPERTYNAME_LEADING), 0, getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
72 0 : {OUString(PROPERTYNAME_NEGRED), 0, getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
73 0 : {OUString(PROPERTYNAME_STDFORM), 0, getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
74 0 : {OUString(PROPERTYNAME_THOUS), 0, getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
75 0 : {OUString(PROPERTYNAME_USERDEF), 0, getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
76 0 : {OUString(PROPERTYNAME_CURRABB), 0, getCppuType((OUString*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
77 : { OUString(), 0, css::uno::Type(), 0, 0 }
78 0 : };
79 0 : return aNumberFormatPropertyMap_Impl;
80 : }
81 :
82 0 : static const SfxItemPropertyMapEntry* lcl_GetNumberSettingsPropertyMap()
83 : {
84 : static const SfxItemPropertyMapEntry aNumberSettingsPropertyMap_Impl[] =
85 : {
86 0 : {OUString(PROPERTYNAME_NOZERO), 0, getBooleanCppuType(), beans::PropertyAttribute::BOUND, 0},
87 0 : {OUString(PROPERTYNAME_NULLDATE), 0, getCppuType((util::Date*)0), beans::PropertyAttribute::BOUND, 0},
88 0 : {OUString(PROPERTYNAME_STDDEC), 0, getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND, 0},
89 0 : {OUString(PROPERTYNAME_TWODIGIT), 0, getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND, 0},
90 : { OUString(), 0, css::uno::Type(), 0, 0 }
91 0 : };
92 0 : return aNumberSettingsPropertyMap_Impl;
93 : }
94 :
95 0 : static LanguageType lcl_GetLanguage( const lang::Locale& rLocale )
96 : {
97 : // empty language -> LANGUAGE_SYSTEM
98 0 : if ( rLocale.Language.isEmpty() )
99 0 : return LANGUAGE_SYSTEM;
100 :
101 0 : LanguageType eRet = LanguageTag::convertToLanguageType( rLocale, false);
102 0 : if ( eRet == LANGUAGE_NONE )
103 0 : eRet = LANGUAGE_SYSTEM; //! or throw an exception?
104 :
105 0 : return eRet;
106 : }
107 :
108 0 : SvNumberFormatterServiceObj::SvNumberFormatterServiceObj()
109 0 : :m_aMutex()
110 : {
111 0 : }
112 :
113 0 : SvNumberFormatterServiceObj::~SvNumberFormatterServiceObj()
114 : {
115 0 : }
116 :
117 0 : com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvNumberFormatterServiceObj_CreateInstance( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& )
118 : {
119 0 : return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new SvNumberFormatterServiceObj );
120 : }
121 :
122 : // XNumberFormatter
123 :
124 0 : void SAL_CALL SvNumberFormatterServiceObj::attachNumberFormatsSupplier( const uno::Reference<util::XNumberFormatsSupplier>& _xSupplier )
125 : throw(uno::RuntimeException, std::exception)
126 : {
127 0 : ::rtl::Reference< SvNumberFormatsSupplierObj > xAutoReleaseOld;
128 :
129 : // SYNCHRONIZED ->
130 : {
131 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
132 :
133 0 : SvNumberFormatsSupplierObj* pNew = SvNumberFormatsSupplierObj::getImplementation( _xSupplier );
134 0 : if (!pNew)
135 0 : throw uno::RuntimeException(); // wrong object
136 :
137 0 : xAutoReleaseOld = xSupplier;
138 :
139 0 : xSupplier = pNew;
140 0 : m_aMutex = xSupplier->getSharedMutex();
141 0 : }
142 : // <- SYNCHRONIZED
143 0 : }
144 :
145 0 : uno::Reference<util::XNumberFormatsSupplier> SAL_CALL SvNumberFormatterServiceObj::getNumberFormatsSupplier()
146 : throw(uno::RuntimeException, std::exception)
147 : {
148 0 : ::osl::MutexGuard aGuard( m_aMutex );
149 0 : return xSupplier.get();
150 : }
151 :
152 0 : sal_Int32 SAL_CALL SvNumberFormatterServiceObj::detectNumberFormat( sal_Int32 nKey, const OUString& aString )
153 : throw(util::NotNumericException, uno::RuntimeException, std::exception)
154 : {
155 0 : ::osl::MutexGuard aGuard( m_aMutex );
156 :
157 0 : sal_Int32 nRet = 0;
158 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
159 0 : if (pFormatter)
160 : {
161 0 : sal_uInt32 nUKey = nKey;
162 0 : double fValue = 0.0;
163 0 : if ( pFormatter->IsNumberFormat(aString, nUKey, fValue) )
164 0 : nRet = nUKey;
165 : else
166 0 : throw util::NotNumericException();
167 : }
168 : else
169 0 : throw uno::RuntimeException();
170 :
171 0 : return nRet;
172 : }
173 :
174 0 : double SAL_CALL SvNumberFormatterServiceObj::convertStringToNumber( sal_Int32 nKey, const OUString& aString )
175 : throw(util::NotNumericException, uno::RuntimeException, std::exception)
176 : {
177 0 : ::osl::MutexGuard aGuard( m_aMutex );
178 :
179 0 : double fRet = 0.0;
180 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
181 0 : if (pFormatter)
182 : {
183 0 : sal_uInt32 nUKey = nKey;
184 0 : double fValue = 0.0;
185 0 : if ( pFormatter->IsNumberFormat(aString, nUKey, fValue) )
186 0 : fRet = fValue;
187 : else
188 0 : throw util::NotNumericException();
189 : }
190 : else
191 0 : throw uno::RuntimeException();
192 :
193 0 : return fRet;
194 : }
195 :
196 0 : OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToString( sal_Int32 nKey, double fValue )
197 : throw(uno::RuntimeException, std::exception)
198 : {
199 0 : ::osl::MutexGuard aGuard( m_aMutex );
200 :
201 0 : OUString aRet;
202 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
203 0 : if (pFormatter)
204 : {
205 0 : Color* pColor = NULL;
206 0 : pFormatter->GetOutputString(fValue, nKey, aRet, &pColor);
207 : }
208 : else
209 0 : throw uno::RuntimeException();
210 :
211 0 : return aRet;
212 : }
213 :
214 0 : util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForNumber( sal_Int32 nKey,
215 : double fValue,
216 : util::Color aDefaultColor )
217 : throw(uno::RuntimeException, std::exception)
218 : {
219 0 : ::osl::MutexGuard aGuard( m_aMutex );
220 :
221 0 : util::Color nRet = aDefaultColor; // color = sal_Int32
222 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
223 0 : if (pFormatter)
224 : {
225 0 : OUString aStr;
226 0 : Color* pColor = NULL;
227 0 : pFormatter->GetOutputString(fValue, nKey, aStr, &pColor);
228 0 : if (pColor)
229 0 : nRet = pColor->GetColor();
230 : // Else keep Default
231 : }
232 : else
233 0 : throw uno::RuntimeException();
234 :
235 0 : return nRet;
236 : }
237 :
238 0 : OUString SAL_CALL SvNumberFormatterServiceObj::formatString( sal_Int32 nKey,
239 : const OUString& aString )
240 : throw(uno::RuntimeException, std::exception)
241 : {
242 0 : ::osl::MutexGuard aGuard( m_aMutex );
243 :
244 0 : OUString aRet;
245 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
246 0 : if (pFormatter)
247 : {
248 0 : Color* pColor = NULL;
249 0 : pFormatter->GetOutputString(aString, nKey, aRet, &pColor);
250 : }
251 : else
252 : {
253 0 : throw uno::RuntimeException();
254 : }
255 0 : return aRet;
256 : }
257 :
258 0 : util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 nKey,
259 : const OUString& aString,
260 : util::Color aDefaultColor )
261 : throw(uno::RuntimeException, std::exception)
262 : {
263 0 : ::osl::MutexGuard aGuard( m_aMutex );
264 :
265 0 : util::Color nRet = aDefaultColor; // color = sal_Int32
266 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
267 0 : if (pFormatter)
268 : {
269 0 : OUString aStr;
270 0 : Color* pColor = NULL;
271 0 : pFormatter->GetOutputString(aString, nKey, aStr, &pColor);
272 0 : if (pColor)
273 : {
274 0 : nRet = pColor->GetColor();
275 0 : }
276 : // Else keep Default
277 : }
278 : else
279 : {
280 0 : throw uno::RuntimeException();
281 : }
282 :
283 0 : return nRet;
284 : }
285 :
286 0 : OUString SAL_CALL SvNumberFormatterServiceObj::getInputString( sal_Int32 nKey, double fValue )
287 : throw(uno::RuntimeException, std::exception)
288 : {
289 0 : ::osl::MutexGuard aGuard( m_aMutex );
290 :
291 0 : OUString aRet;
292 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
293 0 : if (pFormatter)
294 0 : pFormatter->GetInputLineString(fValue, nKey, aRet);
295 : else
296 0 : throw uno::RuntimeException();
297 :
298 0 : return aRet;
299 : }
300 :
301 : // XNumberFormatPreviewer
302 :
303 0 : OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToPreviewString( const OUString& aFormat,
304 : double fValue,
305 : const lang::Locale& nLocale,
306 : sal_Bool bAllowEnglish )
307 : throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
308 : {
309 0 : ::osl::MutexGuard aGuard( m_aMutex );
310 :
311 0 : OUString aRet;
312 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
313 0 : if (pFormatter)
314 : {
315 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
316 0 : Color* pColor = NULL;
317 :
318 : bool bOk;
319 0 : if ( bAllowEnglish )
320 0 : bOk = pFormatter->GetPreviewStringGuess( aFormat, fValue, aRet, &pColor, eLang );
321 : else
322 0 : bOk = pFormatter->GetPreviewString( aFormat, fValue, aRet, &pColor, eLang );
323 :
324 0 : if (!bOk)
325 0 : throw util::MalformedNumberFormatException();
326 : }
327 : else
328 0 : throw uno::RuntimeException();
329 :
330 0 : return aRet;
331 : }
332 :
333 0 : util::Color SAL_CALL SvNumberFormatterServiceObj::queryPreviewColorForNumber( const OUString& aFormat,
334 : double fValue,
335 : const lang::Locale& nLocale,
336 : sal_Bool bAllowEnglish,
337 : util::Color aDefaultColor )
338 : throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
339 : {
340 0 : ::osl::MutexGuard aGuard( m_aMutex );
341 :
342 0 : util::Color nRet = aDefaultColor; // color = sal_Int32
343 0 : SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL;
344 0 : if (pFormatter)
345 : {
346 0 : OUString aOutString;
347 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
348 0 : Color* pColor = NULL;
349 :
350 : bool bOk;
351 0 : if ( bAllowEnglish )
352 0 : bOk = pFormatter->GetPreviewStringGuess( aFormat, fValue, aOutString, &pColor, eLang );
353 : else
354 0 : bOk = pFormatter->GetPreviewString( aFormat, fValue, aOutString, &pColor, eLang );
355 :
356 0 : if (bOk)
357 : {
358 0 : if (pColor)
359 0 : nRet = pColor->GetColor();
360 : // Else keep Default
361 : }
362 : else
363 0 : throw util::MalformedNumberFormatException();
364 : }
365 : else
366 0 : throw uno::RuntimeException();
367 :
368 0 : return nRet;
369 : }
370 :
371 : // XServiceInfo
372 :
373 0 : OUString SAL_CALL SvNumberFormatterServiceObj::getImplementationName()
374 : throw(uno::RuntimeException, std::exception)
375 : {
376 0 : return OUString("com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject");
377 : }
378 :
379 0 : sal_Bool SAL_CALL SvNumberFormatterServiceObj::supportsService( const OUString& ServiceName )
380 : throw(uno::RuntimeException, std::exception)
381 : {
382 0 : return cppu::supportsService( this, ServiceName );
383 : }
384 :
385 0 : uno::Sequence<OUString> SAL_CALL SvNumberFormatterServiceObj::getSupportedServiceNames()
386 : throw(uno::RuntimeException, std::exception)
387 : {
388 0 : uno::Sequence<OUString> aRet(1);
389 0 : OUString* pArray = aRet.getArray();
390 0 : pArray[0] = "com.sun.star.util.NumberFormatter";
391 0 : return aRet;
392 : }
393 :
394 0 : SvNumberFormatsObj::SvNumberFormatsObj( SvNumberFormatsSupplierObj& _rParent, ::comphelper::SharedMutex& _rMutex )
395 : :rSupplier( _rParent )
396 0 : ,m_aMutex( _rMutex )
397 : {
398 0 : rSupplier.acquire();
399 0 : }
400 :
401 0 : SvNumberFormatsObj::~SvNumberFormatsObj()
402 : {
403 0 : rSupplier.release();
404 0 : }
405 :
406 : // XNumberFormats
407 :
408 0 : uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsObj::getByKey( sal_Int32 nKey )
409 : throw(uno::RuntimeException, std::exception)
410 : {
411 0 : ::osl::MutexGuard aGuard( m_aMutex );
412 :
413 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
414 0 : const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
415 0 : if (pFormat)
416 0 : return new SvNumberFormatObj( rSupplier, nKey, m_aMutex );
417 : else
418 0 : throw uno::RuntimeException();
419 : }
420 :
421 0 : uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType,
422 : const lang::Locale& nLocale,
423 : sal_Bool bCreate )
424 : throw(uno::RuntimeException, std::exception)
425 : {
426 0 : ::osl::MutexGuard aGuard( m_aMutex );
427 :
428 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
429 0 : if ( pFormatter )
430 : {
431 0 : sal_uInt32 nIndex = 0;
432 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
433 : SvNumberFormatTable& rTable = bCreate ?
434 0 : pFormatter->ChangeCL( nType, nIndex, eLang ) :
435 0 : pFormatter->GetEntryTable( nType, nIndex, eLang );
436 0 : sal_uInt32 nCount = rTable.size();
437 0 : uno::Sequence<sal_Int32> aSeq(nCount);
438 0 : sal_Int32* pAry = aSeq.getArray();
439 0 : sal_uInt32 i=0;
440 0 : for (SvNumberFormatTable::iterator it = rTable.begin(); it != rTable.end(); ++it, ++i)
441 0 : pAry[i] = it->first;
442 :
443 0 : return aSeq;
444 : }
445 : else
446 0 : throw uno::RuntimeException();
447 : }
448 :
449 0 : sal_Int32 SAL_CALL SvNumberFormatsObj::queryKey( const OUString& aFormat,
450 : const lang::Locale& nLocale,
451 : sal_Bool bScan )
452 : throw(uno::RuntimeException, std::exception)
453 : {
454 0 : ::osl::MutexGuard aGuard( m_aMutex );
455 :
456 0 : sal_Int32 nRet = 0;
457 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
458 0 : if (pFormatter)
459 : {
460 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
461 : if (bScan)
462 : {
463 : //! FIXME: Something still needs to happen here ...
464 : }
465 0 : nRet = pFormatter->GetEntryKey( aFormat, eLang );
466 : }
467 : else
468 0 : throw uno::RuntimeException();
469 :
470 0 : return nRet;
471 : }
472 :
473 0 : sal_Int32 SAL_CALL SvNumberFormatsObj::addNew( const OUString& aFormat,
474 : const lang::Locale& nLocale )
475 : throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
476 : {
477 0 : ::osl::MutexGuard aGuard( m_aMutex );
478 :
479 0 : sal_Int32 nRet = 0;
480 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
481 0 : if (pFormatter)
482 : {
483 0 : OUString aFormStr = aFormat;
484 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
485 0 : sal_uInt32 nKey = 0;
486 0 : sal_Int32 nCheckPos = 0;
487 0 : short nType = 0;
488 0 : bool bOk = pFormatter->PutEntry( aFormStr, nCheckPos, nType, nKey, eLang );
489 0 : if (bOk)
490 0 : nRet = nKey;
491 0 : else if (nCheckPos)
492 : {
493 0 : throw util::MalformedNumberFormatException(); // Invalid Format
494 : }
495 : else
496 0 : throw uno::RuntimeException(); // Other error (e.g. already added)
497 : }
498 : else
499 0 : throw uno::RuntimeException();
500 :
501 0 : return nRet;
502 : }
503 :
504 0 : sal_Int32 SAL_CALL SvNumberFormatsObj::addNewConverted( const OUString& aFormat,
505 : const lang::Locale& nLocale,
506 : const lang::Locale& nNewLocale )
507 : throw(util::MalformedNumberFormatException, uno::RuntimeException, std::exception)
508 : {
509 0 : ::osl::MutexGuard aGuard( m_aMutex );
510 :
511 0 : sal_Int32 nRet = 0;
512 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
513 0 : if (pFormatter)
514 : {
515 0 : OUString aFormStr = aFormat;
516 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
517 0 : LanguageType eNewLang = lcl_GetLanguage( nNewLocale );
518 0 : sal_uInt32 nKey = 0;
519 0 : sal_Int32 nCheckPos = 0;
520 0 : short nType = 0;
521 0 : bool bOk = pFormatter->PutandConvertEntry( aFormStr, nCheckPos, nType, nKey, eLang, eNewLang );
522 0 : if (bOk || nKey > 0)
523 0 : nRet = nKey;
524 0 : else if (nCheckPos)
525 : {
526 0 : throw util::MalformedNumberFormatException(); // Invalid format
527 : }
528 : else
529 0 : throw uno::RuntimeException(); // Other error (e.g. already added)
530 : }
531 : else
532 0 : throw uno::RuntimeException();
533 :
534 0 : return nRet;
535 : }
536 :
537 0 : void SAL_CALL SvNumberFormatsObj::removeByKey( sal_Int32 nKey ) throw(uno::RuntimeException, std::exception)
538 : {
539 0 : ::osl::MutexGuard aGuard( m_aMutex );
540 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
541 :
542 0 : if (pFormatter)
543 : {
544 0 : pFormatter->DeleteEntry(nKey);
545 0 : rSupplier.NumberFormatDeleted(nKey); // Notification for the Document
546 0 : }
547 0 : }
548 :
549 0 : OUString SAL_CALL SvNumberFormatsObj::generateFormat( sal_Int32 nBaseKey,
550 : const lang::Locale& nLocale,
551 : sal_Bool bThousands,
552 : sal_Bool bRed, sal_Int16 nDecimals,
553 : sal_Int16 nLeading )
554 : throw(uno::RuntimeException, std::exception)
555 : {
556 0 : ::osl::MutexGuard aGuard( m_aMutex );
557 :
558 0 : OUString aRet;
559 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
560 0 : if (pFormatter)
561 : {
562 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
563 0 : aRet = pFormatter->GenerateFormat(nBaseKey, eLang, bThousands, bRed, nDecimals, nLeading);
564 : }
565 : else
566 0 : throw uno::RuntimeException();
567 :
568 0 : return aRet;
569 : }
570 :
571 : // XNumberFormatTypes
572 :
573 0 : sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardIndex( const lang::Locale& nLocale )
574 : throw(uno::RuntimeException, std::exception)
575 : {
576 0 : ::osl::MutexGuard aGuard( m_aMutex );
577 :
578 0 : sal_Int32 nRet = 0;
579 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
580 0 : if (pFormatter)
581 : {
582 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
583 0 : nRet = pFormatter->GetStandardIndex(eLang);
584 : }
585 : else
586 0 : throw uno::RuntimeException();
587 :
588 0 : return nRet;
589 : }
590 :
591 0 : sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardFormat( sal_Int16 nType, const lang::Locale& nLocale )
592 : throw(uno::RuntimeException, std::exception)
593 : {
594 0 : ::osl::MutexGuard aGuard( m_aMutex );
595 :
596 0 : sal_Int32 nRet = 0;
597 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
598 0 : if (pFormatter)
599 : {
600 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
601 : // Mask out "defined" bit, so type from an existing number format
602 : // can directly be used for getStandardFormat
603 0 : nType &= ~NUMBERFORMAT_DEFINED;
604 0 : nRet = pFormatter->GetStandardFormat(nType, eLang);
605 : }
606 : else
607 0 : throw uno::RuntimeException();
608 :
609 0 : return nRet;
610 : }
611 :
612 0 : sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatIndex( sal_Int16 nIndex, const lang::Locale& nLocale )
613 : throw(uno::RuntimeException, std::exception)
614 : {
615 0 : ::osl::MutexGuard aGuard( m_aMutex );
616 :
617 0 : sal_Int32 nRet = 0;
618 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
619 0 : if (pFormatter)
620 : {
621 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
622 0 : nRet = pFormatter->GetFormatIndex( (NfIndexTableOffset)nIndex, eLang );
623 : }
624 : else
625 0 : throw uno::RuntimeException();
626 :
627 0 : return nRet;
628 : }
629 :
630 0 : sal_Bool SAL_CALL SvNumberFormatsObj::isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType )
631 : throw(uno::RuntimeException, std::exception)
632 : {
633 0 : ::osl::MutexGuard aGuard( m_aMutex );
634 :
635 0 : bool bRet = false;
636 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
637 0 : if (pFormatter)
638 0 : bRet = pFormatter->IsCompatible( nOldType, nNewType );
639 : else
640 0 : throw uno::RuntimeException();
641 :
642 0 : return bRet;
643 : }
644 :
645 0 : sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatForLocale( sal_Int32 nKey, const lang::Locale& nLocale )
646 : throw(uno::RuntimeException, std::exception)
647 : {
648 0 : ::osl::MutexGuard aGuard( m_aMutex );
649 :
650 0 : sal_Int32 nRet = 0;
651 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
652 0 : if (pFormatter)
653 : {
654 0 : LanguageType eLang = lcl_GetLanguage( nLocale );
655 0 : nRet = pFormatter->GetFormatForLanguageIfBuiltIn(nKey, eLang);
656 : }
657 : else
658 0 : throw uno::RuntimeException();
659 :
660 0 : return nRet;
661 : }
662 :
663 : // XServiceInfo
664 :
665 0 : OUString SAL_CALL SvNumberFormatsObj::getImplementationName()
666 : throw(uno::RuntimeException, std::exception)
667 : {
668 0 : return OUString("SvNumberFormatsObj");
669 : }
670 :
671 0 : sal_Bool SAL_CALL SvNumberFormatsObj::supportsService( const OUString& ServiceName )
672 : throw(uno::RuntimeException, std::exception)
673 : {
674 0 : return cppu::supportsService( this, ServiceName );
675 : }
676 :
677 0 : uno::Sequence<OUString> SAL_CALL SvNumberFormatsObj::getSupportedServiceNames()
678 : throw(uno::RuntimeException, std::exception)
679 : {
680 0 : uno::Sequence<OUString> aRet(1);
681 0 : OUString* pArray = aRet.getArray();
682 0 : pArray[0] = "com.sun.star.util.NumberFormats";
683 0 : return aRet;
684 : }
685 :
686 0 : SvNumberFormatObj::SvNumberFormatObj( SvNumberFormatsSupplierObj& rParent, sal_uLong nK, const ::comphelper::SharedMutex& _rMutex )
687 : :rSupplier( rParent )
688 : ,nKey( nK )
689 0 : ,m_aMutex( _rMutex )
690 : {
691 0 : rSupplier.acquire();
692 0 : }
693 :
694 0 : SvNumberFormatObj::~SvNumberFormatObj()
695 : {
696 0 : rSupplier.release();
697 0 : }
698 :
699 : // XPropertySet
700 :
701 0 : uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatObj::getPropertySetInfo()
702 : throw(uno::RuntimeException, std::exception)
703 : {
704 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
705 : static uno::Reference<beans::XPropertySetInfo> aRef =
706 0 : new SfxItemPropertySetInfo( lcl_GetNumberFormatPropertyMap() );
707 0 : return aRef;
708 : }
709 :
710 0 : void SAL_CALL SvNumberFormatObj::setPropertyValue( const OUString&,
711 : const uno::Any& )
712 : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
713 : lang::IllegalArgumentException, lang::WrappedTargetException,
714 : uno::RuntimeException, std::exception)
715 : {
716 0 : throw beans::UnknownPropertyException(); // Everything is read-only
717 : }
718 :
719 0 : uno::Any SAL_CALL SvNumberFormatObj::getPropertyValue( const OUString& aPropertyName )
720 : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
721 : uno::RuntimeException, std::exception)
722 : {
723 0 : ::osl::MutexGuard aGuard( m_aMutex );
724 :
725 0 : uno::Any aRet;
726 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
727 0 : const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
728 0 : if (pFormat)
729 : {
730 : bool bThousand, bRed;
731 : sal_uInt16 nDecimals, nLeading;
732 :
733 0 : if (aPropertyName.equalsAscii( PROPERTYNAME_FMTSTR ))
734 : {
735 0 : aRet <<= OUString( pFormat->GetFormatstring() );
736 : }
737 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_LOCALE ))
738 : {
739 0 : lang::Locale aLocale( LanguageTag( pFormat->GetLanguage()).getLocale());
740 0 : aRet <<= aLocale;
741 : }
742 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_TYPE ))
743 : {
744 0 : aRet <<= (sal_Int16)( pFormat->GetType() );
745 : }
746 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_COMMENT ))
747 : {
748 0 : aRet <<= OUString( pFormat->GetComment() );
749 : }
750 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_STDFORM ))
751 : {
752 : //! Pass through SvNumberformat Member bStandard?
753 0 : sal_Bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
754 0 : aRet.setValue( &bStandard, getBooleanCppuType() );
755 : }
756 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_USERDEF ))
757 : {
758 0 : sal_Bool bUserDef = ( ( pFormat->GetType() & NUMBERFORMAT_DEFINED ) != 0 );
759 0 : aRet.setValue( &bUserDef, getBooleanCppuType() );
760 : }
761 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_DECIMALS ))
762 : {
763 0 : pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
764 0 : aRet <<= (sal_Int16)( nDecimals );
765 : }
766 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_LEADING ))
767 : {
768 0 : pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
769 0 : aRet <<= (sal_Int16)( nLeading );
770 : }
771 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_NEGRED ))
772 : {
773 0 : pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
774 0 : aRet.setValue( &bRed, getBooleanCppuType() );
775 : }
776 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_THOUS ))
777 : {
778 0 : pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
779 0 : aRet.setValue( &bThousand, getBooleanCppuType() );
780 : }
781 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_CURRSYM ))
782 : {
783 0 : OUString aSymbol, aExt;
784 0 : pFormat->GetNewCurrencySymbol( aSymbol, aExt );
785 0 : aRet <<= aSymbol;
786 : }
787 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_CURREXT ))
788 : {
789 0 : OUString aSymbol, aExt;
790 0 : pFormat->GetNewCurrencySymbol( aSymbol, aExt );
791 0 : aRet <<= aExt;
792 : }
793 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_CURRABB ))
794 : {
795 0 : OUString aSymbol, aExt;
796 0 : bool bBank = false;
797 0 : pFormat->GetNewCurrencySymbol( aSymbol, aExt );
798 : const NfCurrencyEntry* pCurr = pFormatter->GetCurrencyEntry( bBank,
799 0 : aSymbol, aExt, pFormat->GetLanguage() );
800 0 : if ( pCurr )
801 0 : aRet <<= OUString( pCurr->GetBankSymbol() );
802 : else
803 0 : aRet <<= OUString();
804 : }
805 : else
806 0 : throw beans::UnknownPropertyException();
807 : }
808 : else
809 0 : throw uno::RuntimeException();
810 :
811 0 : return aRet;
812 : }
813 :
814 0 : void SAL_CALL SvNumberFormatObj::addPropertyChangeListener( const OUString&,
815 : const uno::Reference<beans::XPropertyChangeListener>&)
816 : throw(beans::UnknownPropertyException,
817 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
818 : {
819 : OSL_FAIL("not implemented");
820 0 : }
821 :
822 0 : void SAL_CALL SvNumberFormatObj::removePropertyChangeListener( const OUString&,
823 : const uno::Reference<beans::XPropertyChangeListener>&)
824 : throw(beans::UnknownPropertyException,
825 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
826 : {
827 : OSL_FAIL("not implemented");
828 0 : }
829 :
830 0 : void SAL_CALL SvNumberFormatObj::addVetoableChangeListener( const OUString&,
831 : const uno::Reference<beans::XVetoableChangeListener>&)
832 : throw(beans::UnknownPropertyException,
833 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
834 : {
835 : OSL_FAIL("not implemented");
836 0 : }
837 :
838 0 : void SAL_CALL SvNumberFormatObj::removeVetoableChangeListener( const OUString&,
839 : const uno::Reference<beans::XVetoableChangeListener>&)
840 : throw(beans::UnknownPropertyException,
841 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
842 : {
843 : OSL_FAIL("not implemented");
844 0 : }
845 :
846 : // XPropertyAccess
847 :
848 0 : uno::Sequence<beans::PropertyValue> SAL_CALL SvNumberFormatObj::getPropertyValues()
849 : throw(uno::RuntimeException, std::exception)
850 : {
851 0 : ::osl::MutexGuard aGuard( m_aMutex );
852 :
853 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
854 0 : const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
855 0 : if (pFormat)
856 : {
857 0 : OUString aSymbol, aExt;
858 0 : OUString aAbb;
859 0 : bool bBank = false;
860 0 : pFormat->GetNewCurrencySymbol( aSymbol, aExt );
861 : const NfCurrencyEntry* pCurr = pFormatter->GetCurrencyEntry( bBank,
862 0 : aSymbol, aExt, pFormat->GetLanguage() );
863 0 : if ( pCurr )
864 0 : aAbb = pCurr->GetBankSymbol();
865 :
866 0 : OUString aFmtStr = pFormat->GetFormatstring();
867 0 : OUString aComment = pFormat->GetComment();
868 0 : sal_Bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
869 : //! Pass through SvNumberformat Member bStandard?
870 0 : sal_Bool bUserDef = ( ( pFormat->GetType() & NUMBERFORMAT_DEFINED ) != 0 );
871 : bool bThousand, bRed;
872 : sal_uInt16 nDecimals, nLeading;
873 0 : pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
874 0 : lang::Locale aLocale( LanguageTag( pFormat->GetLanguage()).getLocale());
875 :
876 0 : uno::Sequence<beans::PropertyValue> aSeq(13);
877 0 : beans::PropertyValue* pArray = aSeq.getArray();
878 :
879 0 : pArray[0].Name = PROPERTYNAME_FMTSTR;
880 0 : pArray[0].Value <<= aFmtStr;
881 0 : pArray[1].Name = PROPERTYNAME_LOCALE;
882 0 : pArray[1].Value <<= aLocale;
883 0 : pArray[2].Name = PROPERTYNAME_TYPE;
884 0 : pArray[2].Value <<= (sal_Int16)( pFormat->GetType() );
885 0 : pArray[3].Name = PROPERTYNAME_COMMENT;
886 0 : pArray[3].Value <<= aComment;
887 0 : pArray[4].Name = PROPERTYNAME_STDFORM;
888 0 : pArray[4].Value.setValue( &bStandard, getBooleanCppuType() );
889 0 : pArray[5].Name = PROPERTYNAME_USERDEF;
890 0 : pArray[5].Value.setValue( &bUserDef, getBooleanCppuType() );
891 0 : pArray[6].Name = PROPERTYNAME_DECIMALS;
892 0 : pArray[6].Value <<= (sal_Int16)( nDecimals );
893 0 : pArray[7].Name = PROPERTYNAME_LEADING;
894 0 : pArray[7].Value <<= (sal_Int16)( nLeading );
895 0 : pArray[8].Name = PROPERTYNAME_NEGRED;
896 0 : pArray[8].Value.setValue( &bRed, getBooleanCppuType() );
897 0 : pArray[9].Name = PROPERTYNAME_THOUS;
898 0 : pArray[9].Value.setValue( &bThousand, getBooleanCppuType() );
899 0 : pArray[10].Name = PROPERTYNAME_CURRSYM;
900 0 : pArray[10].Value <<= aSymbol;
901 0 : pArray[11].Name = PROPERTYNAME_CURREXT;
902 0 : pArray[11].Value <<= aExt;
903 0 : pArray[12].Name = PROPERTYNAME_CURRABB;
904 0 : pArray[12].Value <<= aAbb;
905 :
906 0 : return aSeq;
907 : }
908 : else
909 0 : throw uno::RuntimeException();
910 : }
911 :
912 0 : void SAL_CALL SvNumberFormatObj::setPropertyValues( const uno::Sequence<beans::PropertyValue>& )
913 : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
914 : lang::IllegalArgumentException, lang::WrappedTargetException,
915 : uno::RuntimeException, std::exception)
916 : {
917 0 : throw beans::UnknownPropertyException(); // Everything is read-only
918 : }
919 :
920 : // XServiceInfo
921 :
922 0 : OUString SAL_CALL SvNumberFormatObj::getImplementationName()
923 : throw(uno::RuntimeException, std::exception)
924 : {
925 0 : return OUString("SvNumberFormatObj");
926 : }
927 :
928 0 : sal_Bool SAL_CALL SvNumberFormatObj::supportsService( const OUString& ServiceName )
929 : throw(uno::RuntimeException, std::exception)
930 : {
931 0 : return cppu::supportsService( this, ServiceName );
932 : }
933 :
934 0 : uno::Sequence<OUString> SAL_CALL SvNumberFormatObj::getSupportedServiceNames()
935 : throw(uno::RuntimeException, std::exception)
936 : {
937 0 : uno::Sequence<OUString> aRet(1);
938 0 : OUString* pArray = aRet.getArray();
939 0 : pArray[0] = "com.sun.star.util.NumberFormatProperties";
940 0 : return aRet;
941 : }
942 :
943 0 : SvNumberFormatSettingsObj::SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj& rParent, const ::comphelper::SharedMutex& _rMutex )
944 : :rSupplier( rParent )
945 0 : ,m_aMutex( _rMutex )
946 : {
947 0 : rSupplier.acquire();
948 0 : }
949 :
950 0 : SvNumberFormatSettingsObj::~SvNumberFormatSettingsObj()
951 : {
952 0 : rSupplier.release();
953 0 : }
954 :
955 : // XPropertySet
956 :
957 0 : uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatSettingsObj::getPropertySetInfo()
958 : throw(uno::RuntimeException, std::exception)
959 : {
960 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
961 : static uno::Reference<beans::XPropertySetInfo> aRef =
962 0 : new SfxItemPropertySetInfo( lcl_GetNumberSettingsPropertyMap() );
963 0 : return aRef;
964 : }
965 :
966 0 : void SAL_CALL SvNumberFormatSettingsObj::setPropertyValue( const OUString& aPropertyName,
967 : const uno::Any& aValue )
968 : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
969 : lang::IllegalArgumentException, lang::WrappedTargetException,
970 : uno::RuntimeException, std::exception)
971 : {
972 0 : ::osl::MutexGuard aGuard( m_aMutex );
973 :
974 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
975 0 : if (pFormatter)
976 : {
977 0 : if (aPropertyName.equalsAscii( PROPERTYNAME_NOZERO ))
978 : {
979 : // operator >>= shouldn't be used for bool (?)
980 0 : if ( aValue.getValueTypeClass() == uno::TypeClass_BOOLEAN )
981 0 : pFormatter->SetNoZero( *(sal_Bool*)aValue.getValue() );
982 : }
983 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_NULLDATE ))
984 : {
985 0 : util::Date aDate;
986 0 : if ( aValue >>= aDate )
987 0 : pFormatter->ChangeNullDate( aDate.Day, aDate.Month, aDate.Year );
988 : }
989 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_STDDEC ))
990 : {
991 0 : sal_Int16 nInt16 = sal_Int16();
992 0 : if ( aValue >>= nInt16 )
993 0 : pFormatter->ChangeStandardPrec( nInt16 );
994 : }
995 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_TWODIGIT ))
996 : {
997 0 : sal_Int16 nInt16 = sal_Int16();
998 0 : if ( aValue >>= nInt16 )
999 0 : pFormatter->SetYear2000( nInt16 );
1000 : }
1001 : else
1002 0 : throw beans::UnknownPropertyException();
1003 :
1004 0 : rSupplier.SettingsChanged();
1005 : }
1006 : else
1007 0 : throw uno::RuntimeException();
1008 0 : }
1009 :
1010 0 : uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const OUString& aPropertyName )
1011 : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1012 : uno::RuntimeException, std::exception)
1013 : {
1014 0 : ::osl::MutexGuard aGuard( m_aMutex );
1015 :
1016 0 : uno::Any aRet;
1017 0 : SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter();
1018 0 : if (pFormatter)
1019 : {
1020 0 : if (aPropertyName.equalsAscii( PROPERTYNAME_NOZERO ))
1021 : {
1022 0 : sal_Bool bNoZero = pFormatter->GetNoZero();
1023 0 : aRet.setValue( &bNoZero, getBooleanCppuType() );
1024 : }
1025 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_NULLDATE ))
1026 : {
1027 0 : Date* pDate = pFormatter->GetNullDate();
1028 0 : if (pDate)
1029 : {
1030 0 : util::Date aUnoDate( pDate->GetDay(), pDate->GetMonth(), pDate->GetYear() );
1031 0 : aRet <<= aUnoDate;
1032 : }
1033 : }
1034 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_STDDEC ))
1035 0 : aRet <<= (sal_Int16)( pFormatter->GetStandardPrec() );
1036 0 : else if (aPropertyName.equalsAscii( PROPERTYNAME_TWODIGIT ))
1037 0 : aRet <<= (sal_Int16)( pFormatter->GetYear2000() );
1038 : else
1039 0 : throw beans::UnknownPropertyException();
1040 : }
1041 : else
1042 0 : throw uno::RuntimeException();
1043 :
1044 0 : return aRet;
1045 : }
1046 :
1047 0 : void SAL_CALL SvNumberFormatSettingsObj::addPropertyChangeListener( const OUString&,
1048 : const uno::Reference<beans::XPropertyChangeListener>&)
1049 : throw(beans::UnknownPropertyException,
1050 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
1051 : {
1052 : OSL_FAIL("not implemented");
1053 0 : }
1054 :
1055 0 : void SAL_CALL SvNumberFormatSettingsObj::removePropertyChangeListener( const OUString&,
1056 : const uno::Reference<beans::XPropertyChangeListener>&)
1057 : throw(beans::UnknownPropertyException,
1058 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
1059 : {
1060 : OSL_FAIL("not implemented");
1061 0 : }
1062 :
1063 0 : void SAL_CALL SvNumberFormatSettingsObj::addVetoableChangeListener( const OUString&,
1064 : const uno::Reference<beans::XVetoableChangeListener>&)
1065 : throw(beans::UnknownPropertyException,
1066 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
1067 : {
1068 : OSL_FAIL("not implemented");
1069 0 : }
1070 :
1071 0 : void SAL_CALL SvNumberFormatSettingsObj::removeVetoableChangeListener( const OUString&,
1072 : const uno::Reference<beans::XVetoableChangeListener>&)
1073 : throw(beans::UnknownPropertyException,
1074 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
1075 : {
1076 : OSL_FAIL("not implemented");
1077 0 : }
1078 :
1079 : // XServiceInfo
1080 :
1081 0 : OUString SAL_CALL SvNumberFormatSettingsObj::getImplementationName()
1082 : throw(uno::RuntimeException, std::exception)
1083 : {
1084 0 : return OUString("SvNumberFormatSettingsObj");
1085 : }
1086 :
1087 0 : sal_Bool SAL_CALL SvNumberFormatSettingsObj::supportsService( const OUString& ServiceName )
1088 : throw(uno::RuntimeException, std::exception)
1089 : {
1090 0 : return cppu::supportsService( this, ServiceName );
1091 : }
1092 :
1093 0 : uno::Sequence<OUString> SAL_CALL SvNumberFormatSettingsObj::getSupportedServiceNames()
1094 : throw(uno::RuntimeException, std::exception)
1095 : {
1096 0 : uno::Sequence<OUString> aRet(1);
1097 0 : OUString* pArray = aRet.getArray();
1098 0 : pArray[0] = "com.sun.star.util.NumberFormatSettings";
1099 0 : return aRet;
1100 : }
1101 :
1102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|