LibreOffice Module svl (master) 1
numfmuno.cxx
Go to the documentation of this file.
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 <o3tl/any.hxx>
22#include <osl/mutex.hxx>
23#include <osl/diagnose.h>
24#include <rtl/character.hxx>
25#include <rtl/ustring.hxx>
26
27#include <com/sun/star/util/Date.hpp>
28#include <com/sun/star/util/MalformedNumberFormatException.hpp>
29#include <com/sun/star/util/NotNumericException.hpp>
30#include <com/sun/star/beans/PropertyAttribute.hpp>
33
34#include "numfmuno.hxx"
35#include <svl/numformat.hxx>
36#include <svl/numuno.hxx>
37#include <svl/zforlist.hxx>
38#include <svl/zformat.hxx>
39#include <svl/itemprop.hxx>
40#include <utility>
41
42using namespace com::sun::star;
43
44constexpr OUStringLiteral PROPERTYNAME_FMTSTR = u"FormatString";
45constexpr OUStringLiteral PROPERTYNAME_LOCALE = u"Locale";
46constexpr OUStringLiteral PROPERTYNAME_TYPE = u"Type";
47constexpr OUStringLiteral PROPERTYNAME_COMMENT = u"Comment";
48constexpr OUStringLiteral PROPERTYNAME_CURREXT = u"CurrencyExtension";
49constexpr OUStringLiteral PROPERTYNAME_CURRSYM = u"CurrencySymbol";
50constexpr OUStringLiteral PROPERTYNAME_CURRABB = u"CurrencyAbbreviation";
51constexpr OUStringLiteral PROPERTYNAME_DECIMALS = u"Decimals";
52constexpr OUStringLiteral PROPERTYNAME_LEADING = u"LeadingZeros";
53constexpr OUStringLiteral PROPERTYNAME_NEGRED = u"NegativeRed";
54constexpr OUStringLiteral PROPERTYNAME_STDFORM = u"StandardFormat";
55constexpr OUStringLiteral PROPERTYNAME_THOUS = u"ThousandsSeparator";
56constexpr OUStringLiteral PROPERTYNAME_USERDEF = u"UserDefined";
57
58constexpr OUStringLiteral PROPERTYNAME_NOZERO = u"NoZero";
59constexpr OUStringLiteral PROPERTYNAME_NULLDATE = u"NullDate";
60constexpr OUStringLiteral PROPERTYNAME_STDDEC = u"StandardDecimals";
61constexpr OUStringLiteral PROPERTYNAME_TWODIGIT = u"TwoDigitDateStart";
62
63// All without a Which-ID, Map only for PropertySetInfo
64
66{
67 static const SfxItemPropertyMapEntry aNumberFormatPropertyMap_Impl[] =
68 {
69 {PROPERTYNAME_FMTSTR, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
70 {PROPERTYNAME_LOCALE, 0, cppu::UnoType<lang::Locale>::get(),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
71 {PROPERTYNAME_TYPE, 0, cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
72 {PROPERTYNAME_COMMENT, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
73 {PROPERTYNAME_CURREXT, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
74 {PROPERTYNAME_CURRSYM, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
75 {PROPERTYNAME_DECIMALS, 0, cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
76 {PROPERTYNAME_LEADING, 0, cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
77 {PROPERTYNAME_NEGRED, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
78 {PROPERTYNAME_STDFORM, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
79 {PROPERTYNAME_THOUS, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
80 {PROPERTYNAME_USERDEF, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
81 {PROPERTYNAME_CURRABB, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
82 };
83 return aNumberFormatPropertyMap_Impl;
84}
85
87{
88 static const SfxItemPropertyMapEntry aNumberSettingsPropertyMap_Impl[] =
89 {
90 {PROPERTYNAME_NOZERO, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND, 0},
91 {PROPERTYNAME_NULLDATE, 0, cppu::UnoType<util::Date>::get(), beans::PropertyAttribute::BOUND, 0},
92 {PROPERTYNAME_STDDEC, 0, cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::BOUND, 0},
93 {PROPERTYNAME_TWODIGIT, 0, cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::BOUND, 0},
94 };
95 return aNumberSettingsPropertyMap_Impl;
96}
97
98static LanguageType lcl_GetLanguage( const lang::Locale& rLocale )
99{
101 if ( eRet == LANGUAGE_NONE )
102 eRet = LANGUAGE_SYSTEM;
103
104 return eRet;
105}
106
108{
109}
110
112{
113}
114
115// XNumberFormatter
116
117void SAL_CALL SvNumberFormatterServiceObj::attachNumberFormatsSupplier( const uno::Reference<util::XNumberFormatsSupplier>& _xSupplier )
118{
120
121 // SYNCHRONIZED ->
122 {
123 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
124
125 SvNumberFormatsSupplierObj* pNew = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>( _xSupplier );
126 if (!pNew)
127 throw uno::RuntimeException(); // wrong object
128
129 xAutoReleaseOld = xSupplier;
130
131 xSupplier = pNew;
132 m_aMutex = xSupplier->getSharedMutex();
133 }
134 // <- SYNCHRONIZED
135}
136
137uno::Reference<util::XNumberFormatsSupplier> SAL_CALL SvNumberFormatterServiceObj::getNumberFormatsSupplier()
138{
139 ::osl::MutexGuard aGuard( m_aMutex );
140 return xSupplier;
141}
142
143sal_Int32 SAL_CALL SvNumberFormatterServiceObj::detectNumberFormat( sal_Int32 nKey, const OUString& aString )
144{
145 ::osl::MutexGuard aGuard( m_aMutex );
146
147 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
148 if (!pFormatter)
149 throw uno::RuntimeException();
150
151 sal_uInt32 nUKey = nKey;
152 double fValue = 0.0;
153 if ( !pFormatter->IsNumberFormat(aString, nUKey, fValue) )
154 throw util::NotNumericException();
155
156 return nUKey;
157}
158
159double SAL_CALL SvNumberFormatterServiceObj::convertStringToNumber( sal_Int32 nKey, const OUString& aString )
160{
161 ::osl::MutexGuard aGuard( m_aMutex );
162
163 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
164 if (!pFormatter)
165 throw uno::RuntimeException();
166
167 sal_uInt32 nUKey = nKey;
168 double fValue = 0.0;
169 if ( !pFormatter->IsNumberFormat(aString, nUKey, fValue) )
170 throw util::NotNumericException();
171
172 return fValue;
173}
174
175OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToString( sal_Int32 nKey, double fValue )
176{
177 ::osl::MutexGuard aGuard( m_aMutex );
178
179 OUString aRet;
180 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
181 if (!pFormatter)
182 throw uno::RuntimeException();
183
184 const Color* pColor = nullptr;
185 pFormatter->GetOutputString(fValue, nKey, aRet, &pColor);
186
187 return aRet;
188}
189
190sal_Int32 SAL_CALL SvNumberFormatterServiceObj::queryColorForNumber( sal_Int32 nKey,
191 double fValue,
192 sal_Int32 aDefaultColor )
193{
194 ::osl::MutexGuard aGuard( m_aMutex );
195
196 util::Color nRet = aDefaultColor; // color = sal_Int32
197 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
198 if (!pFormatter)
199 throw uno::RuntimeException();
200
201 OUString aStr;
202 const Color* pColor = nullptr;
203 pFormatter->GetOutputString(fValue, nKey, aStr, &pColor);
204 if (pColor)
205 nRet = sal_uInt32(*pColor);
206 // Else keep Default
207
208 return nRet;
209}
210
211OUString SAL_CALL SvNumberFormatterServiceObj::formatString( sal_Int32 nKey,
212 const OUString& aString )
213{
214 ::osl::MutexGuard aGuard( m_aMutex );
215
216 OUString aRet;
217 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
218 if (!pFormatter)
219 {
220 throw uno::RuntimeException();
221 }
222
223 const Color* pColor = nullptr;
224 pFormatter->GetOutputString(aString, nKey, aRet, &pColor);
225
226 return aRet;
227}
228
229sal_Int32 SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 nKey,
230 const OUString& aString,
231 sal_Int32 aDefaultColor )
232{
233 ::osl::MutexGuard aGuard( m_aMutex );
234
235 util::Color nRet = aDefaultColor; // color = sal_Int32
236 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
237 if (!pFormatter)
238 {
239 throw uno::RuntimeException();
240 }
241
242 OUString aStr;
243 const Color* pColor = nullptr;
244 pFormatter->GetOutputString(aString, nKey, aStr, &pColor);
245 if (pColor)
246 {
247 nRet = sal_uInt32(*pColor);
248 }
249 // Else keep Default
250
251 return nRet;
252}
253
254OUString SAL_CALL SvNumberFormatterServiceObj::getInputString( sal_Int32 nKey, double fValue )
255{
256 ::osl::MutexGuard aGuard( m_aMutex );
257
258 OUString aRet;
259 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
260 if (!pFormatter)
261 throw uno::RuntimeException();
262
263 pFormatter->GetInputLineString(fValue, nKey, aRet);
264
265 return aRet;
266}
267
268// XNumberFormatPreviewer
269
270OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToPreviewString( const OUString& aFormat,
271 double fValue,
272 const lang::Locale& nLocale,
273 sal_Bool bAllowEnglish )
274{
275 ::osl::MutexGuard aGuard( m_aMutex );
276
277 OUString aRet;
278 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
279 if (!pFormatter)
280 throw uno::RuntimeException();
281
282 LanguageType eLang = lcl_GetLanguage( nLocale );
283 const Color* pColor = nullptr;
284
285 bool bOk;
286 if ( bAllowEnglish )
287 bOk = pFormatter->GetPreviewStringGuess( aFormat, fValue, aRet, &pColor, eLang );
288 else
289 bOk = pFormatter->GetPreviewString( aFormat, fValue, aRet, &pColor, eLang );
290
291 if (!bOk)
292 throw util::MalformedNumberFormatException();
293
294 return aRet;
295}
296
297sal_Int32 SAL_CALL SvNumberFormatterServiceObj::queryPreviewColorForNumber( const OUString& aFormat,
298 double fValue,
299 const lang::Locale& nLocale,
300 sal_Bool bAllowEnglish,
301 sal_Int32 aDefaultColor )
302{
303 ::osl::MutexGuard aGuard( m_aMutex );
304
305 util::Color nRet = aDefaultColor; // color = sal_Int32
306 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : nullptr;
307 if (!pFormatter)
308 throw uno::RuntimeException();
309
310 OUString aOutString;
311 LanguageType eLang = lcl_GetLanguage( nLocale );
312 const Color* pColor = nullptr;
313
314 bool bOk;
315 if ( bAllowEnglish )
316 bOk = pFormatter->GetPreviewStringGuess( aFormat, fValue, aOutString, &pColor, eLang );
317 else
318 bOk = pFormatter->GetPreviewString( aFormat, fValue, aOutString, &pColor, eLang );
319
320 if (!bOk)
321 throw util::MalformedNumberFormatException();
322
323 if (pColor)
324 nRet = sal_uInt32(*pColor);
325 // Else keep Default
326
327 return nRet;
328}
329
330// XServiceInfo
331
333{
334 return "com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject";
335}
336
337sal_Bool SAL_CALL SvNumberFormatterServiceObj::supportsService( const OUString& ServiceName )
338{
339 return cppu::supportsService( this, ServiceName );
340}
341
343{
344 return { "com.sun.star.util.NumberFormatter" };
345}
346
348 :m_xSupplier( &_rParent )
349 ,m_aMutex(std::move( _aMutex ))
350{
351}
352
354{
355}
356
357// XNumberFormats
358
359uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsObj::getByKey( sal_Int32 nKey )
360{
361 ::osl::MutexGuard aGuard( m_aMutex );
362
363 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
364 const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : nullptr;
365 if (!pFormat)
366 throw uno::RuntimeException();
367
368 return new SvNumberFormatObj( *m_xSupplier, nKey, m_aMutex );
369}
370
371uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType,
372 const lang::Locale& nLocale,
373 sal_Bool bCreate )
374{
375 ::osl::MutexGuard aGuard( m_aMutex );
376
377 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
378 if ( !pFormatter )
379 throw uno::RuntimeException();
380
381 sal_uInt32 nIndex = 0;
382 LanguageType eLang = lcl_GetLanguage( nLocale );
383 SvNumberFormatTable& rTable = bCreate ?
384 pFormatter->ChangeCL( static_cast<SvNumFormatType>(nType), nIndex, eLang ) :
385 pFormatter->GetEntryTable( static_cast<SvNumFormatType>(nType), nIndex, eLang );
386 sal_uInt32 nCount = rTable.size();
387 uno::Sequence<sal_Int32> aSeq(nCount);
388 sal_Int32* pAry = aSeq.getArray();
389 sal_uInt32 i=0;
390 for (const auto& rEntry : rTable)
391 {
392 pAry[i] = rEntry.first;
393 ++i;
394 }
395 return aSeq;
396}
397
398sal_Int32 SAL_CALL SvNumberFormatsObj::queryKey( const OUString& aFormat,
399 const lang::Locale& nLocale,
400 sal_Bool bScan )
401{
402 ::osl::MutexGuard aGuard( m_aMutex );
403
404 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
405 if (!pFormatter)
406 throw uno::RuntimeException();
407
408 LanguageType eLang = lcl_GetLanguage( nLocale );
409 if (bScan)
410 {
412 }
413 sal_uInt32 nRet = pFormatter->GetEntryKey( aFormat, eLang );
415 {
416 // This seems to be a workaround for what maybe the bScan option was
417 // intended for? Tokenize the format code?
418
419 // The format string based search is vague and fuzzy, as it is case
420 // sensitive, but the format string is only half way cased, the
421 // keywords (except the "General" keyword) are uppercased and literals
422 // of course are not. Clients using this queryKey() and if not
423 // successful addNew() may still fail if the result of PutEntry() is
424 // false because the format actually existed, just with a different
425 // casing. The only clean way is to just use PutEntry() and ignore the
426 // duplicate case, which clients can't because the API doesn't provide
427 // the information.
428 // Try just another possibilty here, without any guarantee.
429
430 // Use only ASCII upper, because keywords are only those.
431 // Do not transliterate any quoted literals.
432 const sal_Int32 nLen = aFormat.getLength();
433 OUStringBuffer aBuf(0);
434 sal_Unicode* p = aBuf.appendUninitialized( nLen + 1);
435 memcpy( p, aFormat.getStr(), (nLen + 1) * sizeof(sal_Unicode)); // including 0-char
436 aBuf.setLength( nLen);
437 assert(p == aBuf.getStr());
438 sal_Unicode const * const pStop = p + aBuf.getLength();
439 bool bQuoted = false;
440 for ( ; p < pStop; ++p)
441 {
442 if (bQuoted)
443 {
444 // Format codes don't have embedded doubled quotes, i.e. "a""b"
445 // is two literals displayed as `ab`.
446 if (*p == '"')
447 bQuoted = false;
448 }
449 else if (*p == '"')
450 bQuoted = true;
451 else if (rtl::isAsciiLowerCase(*p))
452 *p = rtl::toAsciiUpperCase(*p);
453 else if (*p == '\\')
454 ++p; // skip escaped next char
455 // Theoretically that should cater for UTF-32 with
456 // iterateCodePoints(), but such character would not match any
457 // of [a-z\"] in its UTF-16 units.
458 }
459 nRet = pFormatter->GetEntryKey( aBuf, eLang );
460 }
461 return static_cast<sal_Int32>(nRet);
462}
463
464sal_Int32 SAL_CALL SvNumberFormatsObj::addNew( const OUString& aFormat,
465 const lang::Locale& nLocale )
466{
467 ::osl::MutexGuard aGuard( m_aMutex );
468
469 sal_Int32 nRet = 0;
470 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
471 if (!pFormatter)
472 throw uno::RuntimeException();
473
474 OUString aFormStr = aFormat;
475 LanguageType eLang = lcl_GetLanguage( nLocale );
476 sal_uInt32 nKey = 0;
477 sal_Int32 nCheckPos = 0;
479 bool bOk = pFormatter->PutEntry( aFormStr, nCheckPos, nType, nKey, eLang );
480 if (bOk)
481 nRet = nKey;
482 else if (nCheckPos)
483 {
484 throw util::MalformedNumberFormatException(); // Invalid Format
485 }
486 else if (aFormStr != aFormat)
487 {
488 // The format exists but with a different format code string, and if it
489 // was only uppercase vs lowercase keywords; but also syntax extensions
490 // are possible like resulting embedded LCIDs and what not the client
491 // doesn't know about. Silently accept instead of throwing an error.
492 nRet = nKey;
493 }
494 else
495 throw uno::RuntimeException(); // Other error (e.g. already added)
496
497 return nRet;
498}
499
500sal_Int32 SAL_CALL SvNumberFormatsObj::addNewConverted( const OUString& aFormat,
501 const lang::Locale& nLocale,
502 const lang::Locale& nNewLocale )
503{
504 ::osl::MutexGuard aGuard( m_aMutex );
505
506 sal_Int32 nRet = 0;
507 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
508 if (!pFormatter)
509 throw uno::RuntimeException();
510
511 OUString aFormStr = aFormat;
512 LanguageType eLang = lcl_GetLanguage( nLocale );
513 LanguageType eNewLang = lcl_GetLanguage( nNewLocale );
514 sal_uInt32 nKey = 0;
515 sal_Int32 nCheckPos = 0;
517 // This is used also when reading OOXML documents, there's no indicator
518 // whether to convert date particle order as well, so don't. See tdf#119013
519 bool bOk = pFormatter->PutandConvertEntry( aFormStr, nCheckPos, nType, nKey, eLang, eNewLang, false);
520 if (bOk || nKey > 0)
521 nRet = nKey;
522 else if (nCheckPos)
523 {
524 throw util::MalformedNumberFormatException(); // Invalid format
525 }
526 else
527 throw uno::RuntimeException(); // Other error (e.g. already added)
528
529 return nRet;
530}
531
532void SAL_CALL SvNumberFormatsObj::removeByKey( sal_Int32 nKey )
533{
534 ::osl::MutexGuard aGuard( m_aMutex );
535 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
536
537 if (pFormatter)
538 {
539 pFormatter->DeleteEntry(nKey);
540 }
541}
542
543OUString SAL_CALL SvNumberFormatsObj::generateFormat( sal_Int32 nBaseKey,
544 const lang::Locale& nLocale,
545 sal_Bool bThousands,
546 sal_Bool bRed, sal_Int16 nDecimals,
547 sal_Int16 nLeading )
548{
549 ::osl::MutexGuard aGuard( m_aMutex );
550
551 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
552 if (!pFormatter)
553 throw uno::RuntimeException();
554
555 LanguageType eLang = lcl_GetLanguage( nLocale );
556 OUString aRet = pFormatter->GenerateFormat(nBaseKey, eLang, bThousands, bRed, nDecimals, nLeading);
557 return aRet;
558}
559
560// XNumberFormatTypes
561
562sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardIndex( const lang::Locale& nLocale )
563{
564 ::osl::MutexGuard aGuard( m_aMutex );
565
566 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
567 if (!pFormatter)
568 throw uno::RuntimeException();
569
570 LanguageType eLang = lcl_GetLanguage( nLocale );
571 sal_Int32 nRet = pFormatter->GetStandardIndex(eLang);
572 return nRet;
573}
574
575sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardFormat( sal_Int16 nType, const lang::Locale& nLocale )
576{
577 ::osl::MutexGuard aGuard( m_aMutex );
578
579 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
580 if (!pFormatter)
581 throw uno::RuntimeException();
582
583 LanguageType eLang = lcl_GetLanguage( nLocale );
584 // Mask out "defined" bit, so type from an existing number format
585 // can directly be used for getStandardFormat
586 SvNumFormatType nType2 = static_cast<SvNumFormatType>(nType);
588 sal_Int32 nRet = pFormatter->GetStandardFormat(nType2, eLang);
589 return nRet;
590}
591
592sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatIndex( sal_Int16 nIndex, const lang::Locale& nLocale )
593{
594 ::osl::MutexGuard aGuard( m_aMutex );
595
596 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
597 if (!pFormatter)
598 throw uno::RuntimeException();
599
600 LanguageType eLang = lcl_GetLanguage( nLocale );
601 sal_Int32 nRet = pFormatter->GetFormatIndex( static_cast<NfIndexTableOffset>(nIndex), eLang );
602 return nRet;
603}
604
605sal_Bool SAL_CALL SvNumberFormatsObj::isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType )
606{
607 ::osl::MutexGuard aGuard( m_aMutex );
608
609 return SvNumberFormatter::IsCompatible( static_cast<SvNumFormatType>(nOldType), static_cast<SvNumFormatType>(nNewType) );
610}
611
612sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatForLocale( sal_Int32 nKey, const lang::Locale& nLocale )
613{
614 ::osl::MutexGuard aGuard( m_aMutex );
615
616 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
617 if (!pFormatter)
618 throw uno::RuntimeException();
619
620 LanguageType eLang = lcl_GetLanguage( nLocale );
621 sal_Int32 nRet = pFormatter->GetFormatForLanguageIfBuiltIn(nKey, eLang);
622 return nRet;
623}
624
625// XServiceInfo
626
628{
629 return "SvNumberFormatsObj";
630}
631
632sal_Bool SAL_CALL SvNumberFormatsObj::supportsService( const OUString& ServiceName )
633{
634 return cppu::supportsService( this, ServiceName );
635}
636
637uno::Sequence<OUString> SAL_CALL SvNumberFormatsObj::getSupportedServiceNames()
638{
639 return { "com.sun.star.util.NumberFormats" };
640}
641
643 :m_xSupplier( &rParent )
644 ,nKey( nK )
645 ,m_aMutex(std::move( _aMutex ))
646{
647}
648
650{
651}
652
653// XPropertySet
654
655uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatObj::getPropertySetInfo()
656{
657 static uno::Reference<beans::XPropertySetInfo> aRef =
659 return aRef;
660}
661
662void SAL_CALL SvNumberFormatObj::setPropertyValue( const OUString&,
663 const uno::Any& )
664{
665 throw beans::UnknownPropertyException(); // Everything is read-only
666}
667
668uno::Any SAL_CALL SvNumberFormatObj::getPropertyValue( const OUString& aPropertyName )
669{
670 ::osl::MutexGuard aGuard( m_aMutex );
671
672 uno::Any aRet;
673 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
674 const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : nullptr;
675 if (!pFormat)
676 throw uno::RuntimeException();
677
678 bool bThousand, bRed;
679 sal_uInt16 nDecimals, nLeading;
680
681 if (aPropertyName == PROPERTYNAME_FMTSTR)
682 {
683 aRet <<= pFormat->GetFormatstring();
684 }
685 else if (aPropertyName == PROPERTYNAME_LOCALE)
686 {
687 lang::Locale aLocale( LanguageTag::convertToLocale( pFormat->GetLanguage(), false));
688 aRet <<= aLocale;
689 }
690 else if (aPropertyName == PROPERTYNAME_TYPE)
691 {
692 aRet <<= static_cast<sal_Int16>( pFormat->GetType() );
693 }
694 else if (aPropertyName == PROPERTYNAME_COMMENT)
695 {
696 aRet <<= pFormat->GetComment();
697 }
698 else if (aPropertyName == PROPERTYNAME_STDFORM)
699 {
701 aRet <<= ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
702 }
703 else if (aPropertyName == PROPERTYNAME_USERDEF)
704 {
705 aRet <<= bool( pFormat->GetType() & SvNumFormatType::DEFINED );
706 }
707 else if (aPropertyName == PROPERTYNAME_DECIMALS)
708 {
709 pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
710 aRet <<= static_cast<sal_Int16>(nDecimals);
711 }
712 else if (aPropertyName == PROPERTYNAME_LEADING)
713 {
714 pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
715 aRet <<= static_cast<sal_Int16>(nLeading);
716 }
717 else if (aPropertyName == PROPERTYNAME_NEGRED)
718 {
719 pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
720 aRet <<= bRed;
721 }
722 else if (aPropertyName == PROPERTYNAME_THOUS)
723 {
724 pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
725 aRet <<= bThousand;
726 }
727 else if (aPropertyName == PROPERTYNAME_CURRSYM)
728 {
729 OUString aSymbol, aExt;
730 pFormat->GetNewCurrencySymbol( aSymbol, aExt );
731 aRet <<= aSymbol;
732 }
733 else if (aPropertyName == PROPERTYNAME_CURREXT)
734 {
735 OUString aSymbol, aExt;
736 pFormat->GetNewCurrencySymbol( aSymbol, aExt );
737 aRet <<= aExt;
738 }
739 else if (aPropertyName == PROPERTYNAME_CURRABB)
740 {
741 OUString aSymbol, aExt;
742 bool bBank = false;
743 pFormat->GetNewCurrencySymbol( aSymbol, aExt );
744 const NfCurrencyEntry* pCurr = SvNumberFormatter::GetCurrencyEntry( bBank,
745 aSymbol, aExt, pFormat->GetLanguage() );
746 if ( pCurr )
747 aRet <<= pCurr->GetBankSymbol();
748 else
749 aRet <<= OUString();
750 }
751 else
752 throw beans::UnknownPropertyException(aPropertyName);
753
754 return aRet;
755}
756
757void SAL_CALL SvNumberFormatObj::addPropertyChangeListener( const OUString&,
758 const uno::Reference<beans::XPropertyChangeListener>&)
759{
760 OSL_FAIL("not implemented");
761}
762
764 const uno::Reference<beans::XPropertyChangeListener>&)
765{
766 OSL_FAIL("not implemented");
767}
768
769void SAL_CALL SvNumberFormatObj::addVetoableChangeListener( const OUString&,
770 const uno::Reference<beans::XVetoableChangeListener>&)
771{
772 OSL_FAIL("not implemented");
773}
774
776 const uno::Reference<beans::XVetoableChangeListener>&)
777{
778 OSL_FAIL("not implemented");
779}
780
781// XPropertyAccess
782
783uno::Sequence<beans::PropertyValue> SAL_CALL SvNumberFormatObj::getPropertyValues()
784{
785 ::osl::MutexGuard aGuard( m_aMutex );
786
787 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
788 const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : nullptr;
789 if (!pFormat)
790 throw uno::RuntimeException();
791
792 OUString aSymbol, aExt;
793 OUString aAbb;
794 bool bBank = false;
795 pFormat->GetNewCurrencySymbol( aSymbol, aExt );
796 const NfCurrencyEntry* pCurr = SvNumberFormatter::GetCurrencyEntry( bBank,
797 aSymbol, aExt, pFormat->GetLanguage() );
798 if ( pCurr )
799 aAbb = pCurr->GetBankSymbol();
800
801 OUString aFmtStr = pFormat->GetFormatstring();
802 OUString aComment = pFormat->GetComment();
803 bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
805 bool bUserDef( pFormat->GetType() & SvNumFormatType::DEFINED );
806 bool bThousand, bRed;
807 sal_uInt16 nDecimals, nLeading;
808 pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
809 lang::Locale aLocale( LanguageTag( pFormat->GetLanguage()).getLocale());
810
811 uno::Sequence<beans::PropertyValue> aSeq( comphelper::InitPropertySequence({
812 { PROPERTYNAME_FMTSTR, uno::Any(aFmtStr) },
813 { PROPERTYNAME_LOCALE, uno::Any(aLocale) },
814 { PROPERTYNAME_TYPE, uno::Any(sal_Int16( pFormat->GetType() )) },
815 { PROPERTYNAME_COMMENT, uno::Any(aComment) },
816 { PROPERTYNAME_STDFORM, uno::Any(bStandard) },
817 { PROPERTYNAME_USERDEF, uno::Any(bUserDef) },
818 { PROPERTYNAME_DECIMALS, uno::Any(sal_Int16( nDecimals )) },
819 { PROPERTYNAME_LEADING, uno::Any(sal_Int16( nLeading )) },
820 { PROPERTYNAME_NEGRED, uno::Any(bRed) },
821 { PROPERTYNAME_THOUS, uno::Any(bThousand) },
822 { PROPERTYNAME_CURRSYM, uno::Any(aSymbol) },
825 }));
826
827 return aSeq;
828}
829
830void SAL_CALL SvNumberFormatObj::setPropertyValues( const uno::Sequence<beans::PropertyValue>& )
831{
832 throw beans::UnknownPropertyException(); // Everything is read-only
833}
834
835// XServiceInfo
836
838{
839 return "SvNumberFormatObj";
840}
841
842sal_Bool SAL_CALL SvNumberFormatObj::supportsService( const OUString& ServiceName )
843{
844 return cppu::supportsService( this, ServiceName );
845}
846
847uno::Sequence<OUString> SAL_CALL SvNumberFormatObj::getSupportedServiceNames()
848{
849 return { "com.sun.star.util.NumberFormatProperties" };
850}
851
853 :m_xSupplier( &rParent )
854 ,m_aMutex(std::move( _aMutex ))
855{
856}
857
859{
860}
861
862// XPropertySet
863
864uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatSettingsObj::getPropertySetInfo()
865{
866 static uno::Reference<beans::XPropertySetInfo> aRef =
868 return aRef;
869}
870
871void SAL_CALL SvNumberFormatSettingsObj::setPropertyValue( const OUString& aPropertyName,
872 const uno::Any& aValue )
873{
874 ::osl::MutexGuard aGuard( m_aMutex );
875
876 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
877 if (!pFormatter)
878 throw uno::RuntimeException();
879
880 if (aPropertyName == PROPERTYNAME_NOZERO)
881 {
882 // operator >>= shouldn't be used for bool (?)
883 if ( auto b = o3tl::tryAccess<bool>(aValue) )
884 pFormatter->SetNoZero( *b );
885 }
886 else if (aPropertyName == PROPERTYNAME_NULLDATE)
887 {
888 util::Date aDate;
889 if ( aValue >>= aDate )
890 pFormatter->ChangeNullDate( aDate.Day, aDate.Month, aDate.Year );
891 }
892 else if (aPropertyName == PROPERTYNAME_STDDEC)
893 {
894 sal_Int16 nInt16 = sal_Int16();
895 if ( aValue >>= nInt16 )
896 pFormatter->ChangeStandardPrec( nInt16 );
897 }
898 else if (aPropertyName == PROPERTYNAME_TWODIGIT)
899 {
900 sal_Int16 nInt16 = sal_Int16();
901 if ( aValue >>= nInt16 )
902 pFormatter->SetYear2000( nInt16 );
903 }
904 else
905 throw beans::UnknownPropertyException(aPropertyName);
906
907}
908
909uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const OUString& aPropertyName )
910{
911 ::osl::MutexGuard aGuard( m_aMutex );
912
913 uno::Any aRet;
914 SvNumberFormatter* pFormatter = m_xSupplier->GetNumberFormatter();
915 if (!pFormatter)
916 throw uno::RuntimeException();
917
918 if (aPropertyName == PROPERTYNAME_NOZERO)
919 {
920 aRet <<= pFormatter->GetNoZero();
921 }
922 else if (aPropertyName == PROPERTYNAME_NULLDATE)
923 {
924 const Date& rDate = pFormatter->GetNullDate();
925 aRet <<= rDate.GetUNODate();
926 }
927 else if (aPropertyName == PROPERTYNAME_STDDEC)
928 aRet <<= static_cast<sal_Int16>( pFormatter->GetStandardPrec() );
929 else if (aPropertyName == PROPERTYNAME_TWODIGIT)
930 aRet <<= static_cast<sal_Int16>( pFormatter->GetYear2000() );
931 else
932 throw beans::UnknownPropertyException(aPropertyName);
933
934 return aRet;
935}
936
938 const uno::Reference<beans::XPropertyChangeListener>&)
939{
940 OSL_FAIL("not implemented");
941}
942
944 const uno::Reference<beans::XPropertyChangeListener>&)
945{
946 OSL_FAIL("not implemented");
947}
948
950 const uno::Reference<beans::XVetoableChangeListener>&)
951{
952 OSL_FAIL("not implemented");
953}
954
956 const uno::Reference<beans::XVetoableChangeListener>&)
957{
958 OSL_FAIL("not implemented");
959}
960
961// XServiceInfo
962
964{
965 return "SvNumberFormatSettingsObj";
966}
967
968sal_Bool SAL_CALL SvNumberFormatSettingsObj::supportsService( const OUString& ServiceName )
969{
970 return cppu::supportsService( this, ServiceName );
971}
972
974{
975 return { "com.sun.star.util.NumberFormatSettings" };
976}
977
978
979extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
981 css::uno::Sequence<css::uno::Any> const &)
982{
983 return cppu::acquire(new SvNumberFormatterServiceObj());
984}
985
986
987/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::util::Date GetUNODate() const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
static LanguageType convertToLanguageTypeWithFallback(const OUString &rBcp47)
virtual ~SvNumberFormatObj() override
Definition: numfmuno.cxx:649
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: numfmuno.cxx:842
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: numfmuno.cxx:662
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: numfmuno.cxx:847
sal_uLong nKey
Definition: numfmuno.hxx:139
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Definition: numfmuno.cxx:830
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: numfmuno.cxx:655
SvNumberFormatObj(SvNumberFormatsSupplierObj &rParent, sal_uLong nK, ::comphelper::SharedMutex _aMutex)
Definition: numfmuno.cxx:642
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: numfmuno.cxx:775
mutable::comphelper::SharedMutex m_aMutex
Definition: numfmuno.hxx:140
rtl::Reference< SvNumberFormatsSupplierObj > m_xSupplier
Definition: numfmuno.hxx:138
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: numfmuno.cxx:668
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: numfmuno.cxx:757
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: numfmuno.cxx:769
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: numfmuno.cxx:763
virtual OUString SAL_CALL getImplementationName() override
Definition: numfmuno.cxx:837
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
Definition: numfmuno.cxx:783
mutable::comphelper::SharedMutex m_aMutex
Definition: numfmuno.hxx:186
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: numfmuno.cxx:968
virtual ~SvNumberFormatSettingsObj() override
Definition: numfmuno.cxx:858
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: numfmuno.cxx:909
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: numfmuno.cxx:864
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: numfmuno.cxx:871
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: numfmuno.cxx:937
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: numfmuno.cxx:973
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: numfmuno.cxx:955
rtl::Reference< SvNumberFormatsSupplierObj > m_xSupplier
Definition: numfmuno.hxx:185
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: numfmuno.cxx:949
SvNumberFormatSettingsObj(SvNumberFormatsSupplierObj &rParent, ::comphelper::SharedMutex _aMutex)
Definition: numfmuno.cxx:852
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: numfmuno.cxx:943
virtual OUString SAL_CALL getImplementationName() override
Definition: numfmuno.cxx:963
virtual sal_Int32 SAL_CALL getStandardIndex(const css::lang::Locale &nLocale) override
Definition: numfmuno.cxx:562
virtual void SAL_CALL removeByKey(sal_Int32 nKey) override
Definition: numfmuno.cxx:532
virtual css::uno::Sequence< sal_Int32 > SAL_CALL queryKeys(sal_Int16 nType, const css::lang::Locale &nLocale, sal_Bool bCreate) override
Definition: numfmuno.cxx:371
virtual sal_Int32 SAL_CALL getFormatIndex(sal_Int16 nIndex, const css::lang::Locale &nLocale) override
Definition: numfmuno.cxx:592
virtual OUString SAL_CALL generateFormat(sal_Int32 nBaseKey, const css::lang::Locale &nLocale, sal_Bool bThousands, sal_Bool bRed, sal_Int16 nDecimals, sal_Int16 nLeading) override
Definition: numfmuno.cxx:543
virtual sal_Int32 SAL_CALL queryKey(const OUString &aFormat, const css::lang::Locale &nLocale, sal_Bool bScan) override
Definition: numfmuno.cxx:398
virtual sal_Int32 SAL_CALL addNew(const OUString &aFormat, const css::lang::Locale &nLocale) override
Definition: numfmuno.cxx:464
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: numfmuno.cxx:637
virtual sal_Int32 SAL_CALL getStandardFormat(sal_Int16 nType, const css::lang::Locale &nLocale) override
Definition: numfmuno.cxx:575
mutable::comphelper::SharedMutex m_aMutex
Definition: numfmuno.hxx:90
virtual sal_Int32 SAL_CALL getFormatForLocale(sal_Int32 nKey, const css::lang::Locale &nLocale) override
Definition: numfmuno.cxx:612
rtl::Reference< SvNumberFormatsSupplierObj > m_xSupplier
Definition: numfmuno.hxx:89
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getByKey(sal_Int32 nKey) override
Definition: numfmuno.cxx:359
virtual sal_Bool SAL_CALL isTypeCompatible(sal_Int16 nOldType, sal_Int16 nNewType) override
Definition: numfmuno.cxx:605
virtual sal_Int32 SAL_CALL addNewConverted(const OUString &aFormat, const css::lang::Locale &nLocale, const css::lang::Locale &nNewLocale) override
Definition: numfmuno.cxx:500
SvNumberFormatsObj(SvNumberFormatsSupplierObj &pParent, ::comphelper::SharedMutex _aMutex)
Definition: numfmuno.cxx:347
virtual OUString SAL_CALL getImplementationName() override
Definition: numfmuno.cxx:627
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: numfmuno.cxx:632
virtual ~SvNumberFormatsObj() override
Definition: numfmuno.cxx:353
SvNumberFormatterServiceObj is registered globally as a Service.
Definition: numfmuno.hxx:42
virtual double SAL_CALL convertStringToNumber(sal_Int32 nKey, const OUString &aString) override
Definition: numfmuno.cxx:159
virtual css::uno::Reference< css::util::XNumberFormatsSupplier > SAL_CALL getNumberFormatsSupplier() override
Definition: numfmuno.cxx:137
virtual sal_Int32 SAL_CALL queryPreviewColorForNumber(const OUString &aFormat, double fValue, const css::lang::Locale &nLocale, sal_Bool bAllowEnglish, sal_Int32 aDefaultColor) override
Definition: numfmuno.cxx:297
::rtl::Reference< SvNumberFormatsSupplierObj > xSupplier
Definition: numfmuno.hxx:44
virtual sal_Int32 SAL_CALL queryColorForNumber(sal_Int32 nKey, double fValue, sal_Int32 aDefaultColor) override
Definition: numfmuno.cxx:190
virtual OUString SAL_CALL formatString(sal_Int32 nKey, const OUString &aString) override
Definition: numfmuno.cxx:211
virtual OUString SAL_CALL getImplementationName() override
Definition: numfmuno.cxx:332
virtual sal_Int32 SAL_CALL queryColorForString(sal_Int32 nKey, const OUString &aString, sal_Int32 aDefaultColor) override
Definition: numfmuno.cxx:229
virtual OUString SAL_CALL convertNumberToString(sal_Int32 nKey, double fValue) override
Definition: numfmuno.cxx:175
virtual void SAL_CALL attachNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier > &xSupplier) override
Definition: numfmuno.cxx:117
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: numfmuno.cxx:337
virtual OUString SAL_CALL getInputString(sal_Int32 nKey, double fValue) override
Definition: numfmuno.cxx:254
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: numfmuno.cxx:342
virtual OUString SAL_CALL convertNumberToPreviewString(const OUString &aFormat, double fValue, const css::lang::Locale &nLocale, sal_Bool bAllowEnglish) override
Definition: numfmuno.cxx:270
virtual sal_Int32 SAL_CALL detectNumberFormat(sal_Int32 nKey, const OUString &aString) override
Definition: numfmuno.cxx:143
mutable::comphelper::SharedMutex m_aMutex
Definition: numfmuno.hxx:45
virtual ~SvNumberFormatterServiceObj() override
Definition: numfmuno.cxx:111
sal_uInt32 GetStandardIndex(LanguageType eLnge=LANGUAGE_DONTKNOW)
Return the format index of the standard default number format for language/country.
Definition: zforlist.cxx:3416
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
Return the format index of the default format of a type for language/country.
Definition: zforlist.cxx:1455
bool PutEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge=LANGUAGE_DONTKNOW, bool bReplaceBooleanEquivalent=true)
Create new entry of a format code string for language/country.
Definition: zforlist.cxx:574
OUString GenerateFormat(sal_uInt32 nIndex, LanguageType eLnge=LANGUAGE_DONTKNOW, bool bThousand=false, bool IsRed=false, sal_uInt16 nPrecision=0, sal_uInt16 nLeadingCnt=1)
Create a format code string using format nIndex as a template and applying other settings (passed fro...
Definition: zforlist.cxx:3158
sal_uInt16 GetStandardPrec() const
Return the standard decimal precision.
Definition: zforlist.cxx:433
void SetNoZero(bool bNZ)
Set zero value suppression.
Definition: zforlist.cxx:427
bool GetPreviewString(const OUString &sFormatString, double fPreviewNumber, OUString &sOutString, const Color **ppColor, LanguageType eLnge, bool bUseStarFormat=false)
Format a number according to a format code string to be scanned.
Definition: zforlist.cxx:1817
void DeleteEntry(sal_uInt32 nKey)
Delete an entry including the format it is referring to.
Definition: zforlist.cxx:793
bool GetNoZero() const
Return whether zero suppression is switched on.
Definition: zforlist.cxx:439
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
Format a number according to a format index, return string and color.
Definition: zforlist.cxx:1794
bool PutandConvertEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge, LanguageType eNewLnge, bool bConvertDateOrder, bool bReplaceBooleanEquivalent=true)
Same as <method>PutEntry</method> but the format code string is considered to be of language/country ...
Definition: zforlist.cxx:642
sal_uInt32 GetEntryKey(std::u16string_view sStr, LanguageType eLnge=LANGUAGE_DONTKNOW)
Return the format index of the format code string for language/country, or NUMBERFORMAT_ENTRY_NOT_FOU...
Definition: zforlist.cxx:3404
void GetInputLineString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &rOutString, bool bFiltering=false, bool bForceSystemLocale=false)
Format a number according to the standard default format matching the given format index.
Definition: zforlist.cxx:1673
const Date & GetNullDate() const
Return the reference date.
Definition: zforlist.cxx:415
sal_uInt32 GetFormatIndex(NfIndexTableOffset, LanguageType eLnge=LANGUAGE_DONTKNOW)
Return the format index for a builtin format of a specific language.
Definition: zforlist.cxx:3570
void ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
Change the reference null date.
Definition: zforlist.cxx:406
sal_uInt16 GetYear2000() const
Definition: zforlist.cxx:3624
static const NfCurrencyEntry & GetCurrencyEntry(LanguageType)
Return a NfCurrencyEntry matching a language/country.
Definition: zforlist.cxx:3678
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
Return the format for a format index.
Definition: zforlist.cxx:2531
static bool IsCompatible(SvNumFormatType eOldType, SvNumFormatType eNewType)
Definition: zforlist.cxx:1310
void ChangeStandardPrec(short nPrec)
Change standard precision.
Definition: zforlist.cxx:421
sal_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge=LANGUAGE_DONTKNOW)
Return the format index of a builtin format for a specific language/country.
Definition: zforlist.cxx:3548
void SetYear2000(sal_uInt16 nVal)
Set TwoDigitYearStart, how the input string scanner handles a two digit year.
Definition: zforlist.cxx:3617
bool GetPreviewStringGuess(const OUString &sFormatString, double fPreviewNumber, OUString &sOutString, const Color **ppColor, LanguageType eLnge=LANGUAGE_DONTKNOW)
Same as <method>GetPreviewString</method> but the format code string may be either language/country e...
Definition: zforlist.cxx:1870
SvNumberFormatTable & GetEntryTable(SvNumFormatType eType, sal_uInt32 &FIndex, LanguageType eLnge)
Get table of formats of a specific type of a locale.
Definition: zforlist.cxx:1143
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
Analyze an input string.
Definition: zforlist.cxx:1195
SvNumberFormatTable & ChangeCL(SvNumFormatType eType, sal_uInt32 &FIndex, LanguageType eLnge)
Get table of formats of a specific type of a language/country.
Definition: zforlist.cxx:1134
LanguageType GetLanguage() const
Definition: zformat.hxx:201
const OUString & GetComment() const
Definition: zformat.hxx:424
const OUString & GetFormatstring() const
Definition: zformat.hxx:230
bool GetNewCurrencySymbol(OUString &rSymbol, OUString &rExtension) const
Definition: zformat.cxx:1977
void GetFormatSpecialInfo(bool &bThousand, bool &IsRed, sal_uInt16 &nPrecision, sal_uInt16 &nLeadingCnt) const
Definition: zformat.cxx:4889
SvNumFormatType GetType() const
Get type of format, may include css::util::NumberFormat::DEFINED bit.
Definition: zformat.hxx:187
css::uno::Type const & get()
int nCount
float u
std::mutex m_aMutex
sal_Int32 nIndex
void * p
#define LANGUAGE_SYSTEM
#define LANGUAGE_NONE
Sequence< sal_Int8 > aSeq
aStr
aBuf
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_uno_util_numbers_SvNumberFormatterServiceObject_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: numfmuno.cxx:980
constexpr OUStringLiteral PROPERTYNAME_TYPE
Definition: numfmuno.cxx:46
constexpr OUStringLiteral PROPERTYNAME_COMMENT
Definition: numfmuno.cxx:47
constexpr OUStringLiteral PROPERTYNAME_CURRABB
Definition: numfmuno.cxx:50
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetNumberFormatPropertyMap()
Definition: numfmuno.cxx:65
constexpr OUStringLiteral PROPERTYNAME_FMTSTR
Definition: numfmuno.cxx:44
constexpr OUStringLiteral PROPERTYNAME_STDFORM
Definition: numfmuno.cxx:54
constexpr OUStringLiteral PROPERTYNAME_LEADING
Definition: numfmuno.cxx:52
constexpr OUStringLiteral PROPERTYNAME_STDDEC
Definition: numfmuno.cxx:60
constexpr OUStringLiteral PROPERTYNAME_CURRSYM
Definition: numfmuno.cxx:49
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetNumberSettingsPropertyMap()
Definition: numfmuno.cxx:86
constexpr OUStringLiteral PROPERTYNAME_NOZERO
Definition: numfmuno.cxx:58
constexpr OUStringLiteral PROPERTYNAME_DECIMALS
Definition: numfmuno.cxx:51
constexpr OUStringLiteral PROPERTYNAME_USERDEF
Definition: numfmuno.cxx:56
constexpr OUStringLiteral PROPERTYNAME_CURREXT
Definition: numfmuno.cxx:48
constexpr OUStringLiteral PROPERTYNAME_TWODIGIT
Definition: numfmuno.cxx:61
constexpr OUStringLiteral PROPERTYNAME_NULLDATE
Definition: numfmuno.cxx:59
constexpr OUStringLiteral PROPERTYNAME_THOUS
Definition: numfmuno.cxx:55
constexpr OUStringLiteral PROPERTYNAME_LOCALE
Definition: numfmuno.cxx:45
constexpr OUStringLiteral PROPERTYNAME_NEGRED
Definition: numfmuno.cxx:53
static LanguageType lcl_GetLanguage(const lang::Locale &rLocale)
Definition: numfmuno.cxx:98
QPRO_FUNC_TYPE nType
sal_uIntPtr sal_uLong
map a property between beans::XPropertySet and SfxPoolItem
Definition: itemprop.hxx:38
unsigned char sal_Bool
sal_uInt16 sal_Unicode
std::map< sal_uInt32, SvNumberformat * > SvNumberFormatTable
This table is std::map because it needs to preserve insertion order, because the formats are roughly ...
Definition: zforlist.hxx:286
SvNumFormatType
MAX_ULONG.
Definition: zforlist.hxx:50
@ ALL
selects all number formats.
@ DEFINED
selects only user-defined number formats.
#define SV_COUNTRY_LANGUAGE_OFFSET
Definition: zforlist.hxx:38
NfIndexTableOffset
enum values for <method>SvNumberFormatter::GetFormatIndex</method>
Definition: zforlist.hxx:124
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
Definition: zforlist.hxx:47