1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include <sal/types.h>
11 #include <cppunit/TestAssert.h>
12 #include <cppunit/TestFixture.h>
13 #include <cppunit/extensions/HelperMacros.h>
14 #include <cppunit/plugin/TestPlugIn.h>
16 #include <sal/config.h>
18 #include <cppuhelper/bootstrap.hxx>
19 #include <comphelper/processfactory.hxx>
21 #include <com/sun/star/lang/XComponent.hpp>
22 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <i18nlangtag/lang.h>
30 #include <svl/numformat.hxx>
31 #include <svl/zforlist.hxx>
32 #include <svl/zformat.hxx>
33 #include <svl/sharedstringpool.hxx>
34 #include <svl/sharedstring.hxx>
35 #include <tools/color.hxx>
36 #include <unotools/syslocale.hxx>
40 #include <unicode/timezone.h>
42 using namespace ::com::sun::star
;
47 static std::ostream
& operator<<(std::ostream
& rStrm
, const SharedString
& string
)
49 return rStrm
<< "(" << static_cast<const void*>(string
.getData()) << ")" << string
.getString();
56 class Test
: public CppUnit::TestFixture
{
59 virtual ~Test() override
;
61 virtual void tearDown() override
;
63 void testNumberFormat();
64 void testSharedString();
65 void testSharedStringPool();
66 void testSharedStringPoolPurge();
67 void testSharedStringPoolPurgeBug1();
68 void testSharedStringPoolEmptyString();
73 void testIsNumberFormat();
74 void testIsNumberFormatSpecific();
75 void testUserDefinedNumberFormats();
76 void testNfEnglishKeywordsIntegrity();
77 void testStandardColorIntegrity();
78 void testColorNamesConversion();
79 void testExcelExportFormats();
81 CPPUNIT_TEST_SUITE(Test
);
82 CPPUNIT_TEST(testNumberFormat
);
83 CPPUNIT_TEST(testSharedString
);
84 CPPUNIT_TEST(testSharedStringPool
);
85 CPPUNIT_TEST(testSharedStringPoolPurge
);
86 CPPUNIT_TEST(testSharedStringPoolPurgeBug1
);
87 CPPUNIT_TEST(testSharedStringPoolEmptyString
);
88 CPPUNIT_TEST(testFdo60915
);
89 CPPUNIT_TEST(testI116701
);
90 CPPUNIT_TEST(testTdf103060
);
91 CPPUNIT_TEST(testDateInput
);
92 CPPUNIT_TEST(testIsNumberFormat
);
93 CPPUNIT_TEST(testIsNumberFormatSpecific
);
94 CPPUNIT_TEST(testUserDefinedNumberFormats
);
95 CPPUNIT_TEST(testNfEnglishKeywordsIntegrity
);
96 CPPUNIT_TEST(testStandardColorIntegrity
);
97 CPPUNIT_TEST(testColorNamesConversion
);
98 CPPUNIT_TEST(testExcelExportFormats
);
99 CPPUNIT_TEST_SUITE_END();
102 uno::Reference
< uno::XComponentContext
> m_xContext
;
103 void checkPreviewString(SvNumberFormatter
& aFormatter
,
104 const OUString
& sCode
,
105 double fPreviewNumber
,
107 OUString
const & sExpected
);
108 void checkDateInput( SvNumberFormatter
& rFormatter
, const char* pTimezone
, const char* pIsoDate
);
109 std::unique_ptr
<icu::TimeZone
> m_pDefaultTimeZone
;
112 Test::Test() : m_xContext(cppu::defaultBootstrap_InitialComponentContext())
114 uno::Reference
<lang::XMultiComponentFactory
> xFactory(m_xContext
->getServiceManager());
115 uno::Reference
<lang::XMultiServiceFactory
> xSM(xFactory
, uno::UNO_QUERY_THROW
);
117 //Without this we're crashing because callees are using
118 //getProcessServiceFactory. In general those should be removed in favour
119 //of retaining references to the root ServiceFactory as it's passed around
120 comphelper::setProcessServiceFactory(xSM
);
121 m_pDefaultTimeZone
.reset(icu::TimeZone::createDefault());
124 void Test::tearDown()
126 icu::TimeZone::setDefault(*m_pDefaultTimeZone
);
131 uno::Reference
< lang::XComponent
>(m_xContext
, uno::UNO_QUERY_THROW
)->dispose();
134 void Test::testNumberFormat()
136 LanguageType eLang
= LANGUAGE_ENGLISH_US
;
138 const char* pNumber
[] = {
148 const char* pScientific
[] = {
154 const char* pPercent
[] = {
160 const char* pFraction
[] = {
166 // Following aren't in range of NF_FRACTION_START and NF_FRACTION_END
167 // see enum NfIndexTableOffset in svl/inc/svl/zforlist.hxx
168 const char* pFractionExt
[] = {
179 const char* pCurrency
[] = {
181 "$#,##0.00;-$#,##0.00",
182 "$#,##0;[RED]-$#,##0",
183 "$#,##0.00;[RED]-$#,##0.00",
185 "$#,##0.--;[RED]-$#,##0.--",
189 const char* pDate
[] = {
214 const char* pTime
[] = {
225 const char* pDateTime
[] = {
226 "MM/DD/YY HH:MM AM/PM",
227 "MM/DD/YYYY HH:MM:SS",
231 // Following aren't in range of NF_DATETIME_START and NF_DATETIME_END
232 // see enum NfIndexTableOffset in svl/inc/svl/zforlist.hxx
233 const char* pDateTimeExt1
[] = {
234 "MM/DD/YYYY HH:MM AM/PM",
238 const char* pDateTimeExt2
[] = {
239 "YYYY-MM-DD HH:MM:SS",
240 "YYYY-MM-DD HH:MM:SS.000",
241 "YYYY-MM-DD\"T\"HH:MM:SS",
242 "YYYY-MM-DD\"T\"HH:MM:SS.000",
246 const char* pBoolean
[] = {
251 const char* pText
[] = {
257 NfIndexTableOffset eStart
;
258 NfIndexTableOffset eEnd
;
262 { NF_NUMBER_START
, NF_NUMBER_END
, 6, pNumber
},
263 { NF_SCIENTIFIC_START
, NF_SCIENTIFIC_END
, 2, pScientific
},
264 { NF_PERCENT_START
, NF_PERCENT_END
, 2, pPercent
},
265 { NF_FRACTION_START
, NF_FRACTION_END
, 2, pFraction
},
266 { NF_CURRENCY_START
, NF_CURRENCY_END
, 6, pCurrency
},
267 { NF_DATE_START
, NF_DATE_END
, 21, pDate
},
268 { NF_TIME_START
, NF_TIME_END
, 7, pTime
},
269 { NF_DATETIME_START
, NF_DATETIME_END
, 2, pDateTime
},
270 { NF_BOOLEAN
, NF_BOOLEAN
, 1, pBoolean
},
271 { NF_TEXT
, NF_TEXT
, 1, pText
},
272 { NF_DATETIME_SYS_DDMMYYYY_HHMM
, NF_DATETIME_SYS_DDMMYYYY_HHMM
, 1, pDateTimeExt1
},
273 { NF_FRACTION_3D
, NF_FRACTION_100
, 7, pFractionExt
},
274 { NF_DATETIME_ISO_YYYYMMDD_HHMMSS
, NF_DATETIME_ISO_YYYYMMDDTHHMMSS000
, 4, pDateTimeExt2
}
277 SvNumberFormatter
aFormatter(m_xContext
, eLang
);
279 for (auto const[eStart
, eEnd
, nSize
, pCodes
] : aTests
)
281 size_t nStart
= eStart
;
283 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected number of formats for this category.", nSize
,
284 (nEnd
- nStart
+ 1));
286 for (size_t j
= nStart
; j
<= nEnd
; ++j
)
289 aFormatter
.GetFormatIndex(static_cast<NfIndexTableOffset
>(j
));
290 const SvNumberformat
* p
= aFormatter
.GetEntry(nIndex
);
292 CPPUNIT_ASSERT_MESSAGE("Number format entry is expected, but doesn't exist.", p
);
293 OUString aCode
= p
->GetFormatstring();
294 CPPUNIT_ASSERT_EQUAL(OString( pCodes
[j
-nStart
]), aCode
.toUtf8());
299 SvNumFormatType nType
= SvNumFormatType::DEFINED
;
302 // Thai date format (implicit locale).
303 aCode
= "[$-1070000]d/mm/yyyy;@";
304 if (!aFormatter
.PutEntry(aCode
, nPos
, nType
, nKey
))
306 CPPUNIT_ASSERT_MESSAGE("failed to insert format code '[$-1070000]d/mm/yyyy;@'", false);
309 // Thai date format (explicit locale)
310 aCode
= "[$-107041E]d/mm/yyyy;@";
311 if (!aFormatter
.PutEntry(aCode
, nPos
, nType
, nKey
))
313 CPPUNIT_ASSERT_MESSAGE("failed to insert format code '[$-107041E]d/mm/yyyy;@'", false);
316 // Thai date format (using buddhist calendar type).
317 aCode
= "[~buddhist]D MMMM YYYY";
318 if (!aFormatter
.PutEntry(aCode
, nPos
, nType
, nKey
))
320 CPPUNIT_ASSERT_MESSAGE("failed to insert format code '[~buddhist]D MMMM YYYY'", false);
324 void Test::testSharedString()
326 // Use shared string as normal, non-shared string, which is allowed.
327 SharedString
aSS1("Test"), aSS2("Test");
328 CPPUNIT_ASSERT_MESSAGE("Equality check should return true.", bool(aSS1
== aSS2
));
329 SharedString
aSS3("test");
330 CPPUNIT_ASSERT_MESSAGE("Equality check is case sensitive.", aSS1
!= aSS3
);
333 void Test::testSharedStringPool()
335 SvtSysLocale aSysLocale
;
336 svl::SharedStringPool
aPool(aSysLocale
.GetCharClass());
338 svl::SharedString p1
, p2
;
339 p1
= aPool
.intern("Andy");
340 p2
= aPool
.intern("Andy");
341 CPPUNIT_ASSERT_EQUAL(p1
.getData(), p2
.getData());
343 p2
= aPool
.intern("Bruce");
344 CPPUNIT_ASSERT_MESSAGE("They must differ.", p1
.getData() != p2
.getData());
346 OUString
aAndy("Andy");
347 p1
= aPool
.intern("Andy");
348 p2
= aPool
.intern(aAndy
);
349 CPPUNIT_ASSERT_MESSAGE("Identifier shouldn't be NULL.", p1
.getData());
350 CPPUNIT_ASSERT_MESSAGE("Identifier shouldn't be NULL.", p2
.getData());
351 CPPUNIT_ASSERT_EQUAL(p1
.getData(), p2
.getData());
353 // Test case insensitive string ID's.
354 p1
= aPool
.intern(aAndy
);
355 p2
= aPool
.intern("andy");
356 CPPUNIT_ASSERT_MESSAGE("Failed to intern strings.", p1
.getData());
357 CPPUNIT_ASSERT_MESSAGE("Failed to intern strings.", p2
.getData());
358 CPPUNIT_ASSERT_MESSAGE("These two ID's should differ.", p1
.getData() != p2
.getData());
359 CPPUNIT_ASSERT_EQUAL_MESSAGE("These two ID's should be equal.", p2
.getDataIgnoreCase(), p1
.getDataIgnoreCase());
360 p2
= aPool
.intern("ANDY");
361 CPPUNIT_ASSERT_MESSAGE("Failed to intern string.", p2
.getData());
362 CPPUNIT_ASSERT_MESSAGE("These two ID's should differ.", p1
.getData() != p2
.getData());
363 CPPUNIT_ASSERT_EQUAL_MESSAGE("These two ID's should be equal.", p2
.getDataIgnoreCase(), p1
.getDataIgnoreCase());
366 void Test::testSharedStringPoolPurge()
368 SvtSysLocale aSysLocale
;
369 svl::SharedStringPool
aPool(aSysLocale
.GetCharClass());
370 size_t extraCount
= aPool
.getCount(); // internal items such as SharedString::getEmptyString()
371 size_t extraCountIgnoreCase
= aPool
.getCountIgnoreCase();
373 aPool
.intern("Andy");
374 aPool
.intern("andy");
375 aPool
.intern("ANDY");
377 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong string count.", 3+extraCount
, aPool
.getCount());
378 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong case insensitive string count.", 1+extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
380 // Since no string objects referencing the pooled strings exist, purging
381 // the pool should empty it (except for internal items).
383 CPPUNIT_ASSERT_EQUAL(extraCount
, aPool
.getCount());
384 CPPUNIT_ASSERT_EQUAL(extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
386 // Now, create string objects using optional so we can clear them
387 std::optional
<svl::SharedString
> pStr1
= aPool
.intern("Andy");
388 std::optional
<svl::SharedString
> pStr2
= aPool
.intern("andy");
389 std::optional
<svl::SharedString
> pStr3
= aPool
.intern("ANDY");
390 std::optional
<svl::SharedString
> pStr4
= aPool
.intern("Bruce");
392 CPPUNIT_ASSERT_EQUAL(5+extraCount
, aPool
.getCount());
393 CPPUNIT_ASSERT_EQUAL(2+extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
395 // This shouldn't purge anything.
397 CPPUNIT_ASSERT_EQUAL(5+extraCount
, aPool
.getCount());
398 CPPUNIT_ASSERT_EQUAL(2+extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
400 // Delete one heap string object, and purge. That should purge one string.
403 CPPUNIT_ASSERT_EQUAL(4+extraCount
, aPool
.getCount());
404 CPPUNIT_ASSERT_EQUAL(2+extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
406 // Nothing changes, because the upper-string is still in the map
409 CPPUNIT_ASSERT_EQUAL(4+extraCount
, aPool
.getCount());
410 CPPUNIT_ASSERT_EQUAL(2+extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
415 CPPUNIT_ASSERT_EQUAL(2+extraCount
, aPool
.getCount());
416 CPPUNIT_ASSERT_EQUAL(1+extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
418 // Delete 'Bruce' and purge.
421 CPPUNIT_ASSERT_EQUAL(extraCount
, aPool
.getCount());
422 CPPUNIT_ASSERT_EQUAL(extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
425 void Test::testSharedStringPoolPurgeBug1()
427 // We had a bug where, if we had two strings that mapped to the same uppercase string,
428 // purge() would de-reference a dangling pointer and consequently cause an ASAN failure.
429 SvtSysLocale aSysLocale
;
430 svl::SharedStringPool
aPool(aSysLocale
.GetCharClass());
431 size_t extraCount
= aPool
.getCount(); // internal items such as SharedString::getEmptyString()
432 size_t extraCountIgnoreCase
= aPool
.getCountIgnoreCase();
433 aPool
.intern("Andy");
434 aPool
.intern("andy");
436 CPPUNIT_ASSERT_EQUAL(extraCount
, aPool
.getCount());
437 CPPUNIT_ASSERT_EQUAL(extraCountIgnoreCase
, aPool
.getCountIgnoreCase());
440 void Test::testSharedStringPoolEmptyString()
442 // Make sure SharedString::getEmptyString() is in the pool and matches empty strings.
443 SvtSysLocale aSysLocale
;
444 svl::SharedStringPool
aPool(aSysLocale
.GetCharClass());
446 CPPUNIT_ASSERT_EQUAL(SharedString::getEmptyString(), aPool
.intern(""));
447 CPPUNIT_ASSERT_EQUAL(SharedString::getEmptyString(), aPool
.intern(SharedString::EMPTY_STRING
));
448 // And it should still work even after purging.
450 CPPUNIT_ASSERT_EQUAL(SharedString::getEmptyString(), aPool
.intern(SharedString::EMPTY_STRING
));
453 void Test::checkPreviewString(SvNumberFormatter
& aFormatter
,
454 const OUString
& sCode
,
455 double fPreviewNumber
,
457 OUString
const & sExpected
)
460 const Color
* pColor
= nullptr;
461 if (!aFormatter
.GetPreviewString(sCode
, fPreviewNumber
, sStr
, &pColor
, eLang
))
463 OString aMessage
= "GetPreviewString( \"" +
464 OUStringToOString( sCode
, RTL_TEXTENCODING_ASCII_US
) +
466 OString::number( fPreviewNumber
) +
468 aMessage
+= OString::number( static_cast<sal_uInt16
>(eLang
) ) +
470 CPPUNIT_FAIL( aMessage
.getStr() );
472 CPPUNIT_ASSERT_EQUAL(sExpected
, sStr
);
475 void Test::testFdo60915()
477 LanguageType eLang
= LANGUAGE_THAI
;
478 OUString sCode
, sExpected
;
479 double fPreviewNumber
= 36486; // equals 1999-11-22 (2542 B.E.)
480 SvNumberFormatter
aFormatter(m_xContext
, eLang
);
482 sCode
= "[~buddhist]D/MM/YYYY";
483 sExpected
= "22/11/2542";
484 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
487 sCode
= "[~buddhist]D/MM/YY";
488 sExpected
= "22/11/42";
489 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
492 sCode
= "[NatNum1][$-41E][~buddhist]D/MM/YYYY";
493 sal_Unicode sTemp
[] =
495 0x0E52, 0x0E52, 0x002F,
496 0x0E51, 0x0E51, 0x002F,
497 0x0E52, 0x0E55, 0x0E54, 0x0E52
499 sExpected
= OUString(sTemp
, SAL_N_ELEMENTS(sTemp
));
500 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
503 sCode
= "[NatNum1][$-41E][~buddhist]D/MM/YY";
504 sal_Unicode sTemp
[] =
506 0x0E52, 0x0E52, 0x002F,
507 0x0E51, 0x0E51, 0x002F,
510 sExpected
= OUString(sTemp
, SAL_N_ELEMENTS(sTemp
));
511 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
515 // https://bz.apache.org/ooo/show_bug.cgi?id=116701
516 void Test::testI116701()
518 LanguageType eLang
= LANGUAGE_CHINESE_TRADITIONAL
;
519 OUString sCode
, sExpected
;
520 double fPreviewNumber
= 40573; // equals 30/01/2011
521 SvNumberFormatter
aFormatter(m_xContext
, eLang
);
522 // DateFormatskey25 in i18npool/source/localedata/data/zh_TW.xml
523 sal_Unicode CODE1
[] =
525 0x0047, 0x0047, 0x0047, 0x0045, 0x0045, // GGGEE
526 0x0022, 0x5E74, 0x0022,
528 0x0022, 0x6708, 0x0022,
530 0x0022, 0x65E5, 0x0022
532 sCode
= OUString(CODE1
, SAL_N_ELEMENTS(CODE1
));
533 sal_Unicode EXPECTED
[] =
535 0x4E2D, 0x83EF, 0x6C11, 0x570B,
536 0x0031, 0x0030, 0x0030, // 100
540 0x0033, 0x0030, // 30
543 sExpected
= OUString(EXPECTED
, SAL_N_ELEMENTS(EXPECTED
));
544 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
545 sal_Unicode CODE2
[] =
547 0x0047, 0x0047, 0x0047, 0x0045, // GGGE
548 0x0022, 0x5E74, 0x0022,
550 0x0022, 0x6708, 0x0022,
552 0x0022, 0x65E5, 0x0022
554 sCode
= OUString(CODE2
, SAL_N_ELEMENTS(CODE2
));
555 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
558 void Test::testTdf103060()
560 LanguageType eLang
= LANGUAGE_JAPANESE
;
561 OUString sCode
, sExpected
;
562 double fPreviewNumber
= 42655; // equals 2016-10-12
563 SvNumberFormatter
aFormatter(m_xContext
, eLang
);
565 sExpected
= "H"; // Heisei era
566 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
568 sExpected
= u
"\u5E73"_ustr
;
569 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
571 sExpected
= u
"\u5E73\u6210"_ustr
;
572 checkPreviewString(aFormatter
, sCode
, fPreviewNumber
, eLang
, sExpected
);
575 void Test::testDateInput()
577 const char* aData
[][2] = {
578 { "Europe/Paris", "1938-10-07" }, // i#76623
579 { "Europe/Moscow", "1919-07-01" }, // i#86094
580 { "America/St_Johns", "1935-03-30" }, // i#86094 i#90627
581 { "Europe/Tallinn", "1790-03-01" }, // i#105864
582 { "Australia/Perth", "2004-04-11" }, // i#17222
583 { "America/Sao_Paulo", "1902-04-22" }, // tdf#44286
584 { "Europe/Berlin", "1790-07-27" },
585 { "US/Mountain", "1790-07-26" },
586 { "Asia/Tehran", "1999-03-22" },
588 // Data from https://bugs.documentfoundation.org/show_bug.cgi?id=63230
589 // https://bugs.documentfoundation.org/attachment.cgi?id=79051
590 // https://bugs.documentfoundation.org/show_bug.cgi?id=79663
591 { "Africa/Accra", "1800-01-01" },
592 { "Africa/Accra", "1800-04-10" },
593 { "Africa/Addis_Ababa", "1870-01-01" },
594 { "Africa/Addis_Ababa", "1936-05-05" },
595 { "Africa/Algiers", "1956-01-29" },
596 { "Africa/Algiers", "1981-05-01" },
597 { "Africa/Asmara", "1936-05-05" },
598 { "Africa/Asmera", "1936-05-05" },
599 { "Africa/Bujumbura", "1890-01-01" },
600 { "Africa/Casablanca", "1984-03-16" },
601 { "Africa/Ceuta", "1984-03-16" },
602 { "Africa/Dar_es_Salaam", "1931-01-01" },
603 { "Africa/Dar_es_Salaam", "1961-01-01" },
604 { "Africa/Djibouti", "1911-07-01" },
605 { "Africa/Douala", "1912-01-01" },
606 { "Africa/El_Aaiun", "1934-01-01" },
607 { "Africa/Freetown", "1913-06-01" },
608 { "Africa/Gaborone", "1885-01-01" },
609 { "Africa/Johannesburg", "1903-03-01" },
610 { "Africa/Kampala", "1928-07-01" },
611 { "Africa/Kampala", "1948-01-01" },
612 { "Africa/Kampala", "1957-01-01" },
613 { "Africa/Lagos", "1919-09-01" },
614 { "Africa/Libreville", "1912-01-01" },
615 { "Africa/Luanda", "1911-05-26" },
616 { "Africa/Lubumbashi", "1897-11-09" },
617 { "Africa/Lusaka", "1903-03-01" },
618 { "Africa/Malabo", "1963-12-15" },
619 { "Africa/Maseru", "1903-03-01" },
620 { "Africa/Mogadishu", "1957-01-01" },
621 { "Africa/Monrovia", "1919-03-01" },
622 { "Africa/Nairobi", "1928-07-01" },
623 { "Africa/Nairobi", "1940-01-01" },
624 { "Africa/Nairobi", "1960-01-01" },
625 { "Africa/Niamey", "1960-01-01" },
626 { "Africa/Porto-Novo", "1934-02-26" },
627 { "Africa/Tripoli", "1920-01-01" },
628 { "Africa/Tripoli", "1959-01-01" },
629 { "Africa/Tripoli", "1990-05-04" },
630 { "Africa/Tunis", "1911-03-11" },
631 { "Africa/Windhoek", "1892-02-08" },
632 { "Africa/Windhoek", "1903-03-01" },
633 { "America/Antigua", "1912-03-02" },
634 { "America/Argentina/Buenos_Aires", "1894-10-31" },
635 { "America/Argentina/Catamarca", "1991-10-20" },
636 { "America/Argentina/Catamarca", "2004-06-01" },
637 { "America/Argentina/ComodRivadavia", "1991-10-20" },
638 { "America/Argentina/ComodRivadavia", "2004-06-01" },
639 { "America/Argentina/Cordoba", "1991-10-20" },
640 { "America/Argentina/Jujuy", "1991-10-06" },
641 { "America/Argentina/La_Rioja", "2004-06-01" },
642 { "America/Argentina/Mendoza", "1992-10-18" },
643 { "America/Argentina/Mendoza", "2004-05-23" },
644 { "America/Argentina/Rio_Gallegos", "2004-06-01" },
645 { "America/Argentina/Salta", "1991-10-20" },
646 { "America/Argentina/San_Juan", "2004-05-31" },
647 { "America/Argentina/San_Luis", "2004-05-31" },
648 { "America/Argentina/San_Luis", "2008-01-21" },
649 { "America/Argentina/Tucuman", "1991-10-20" },
650 { "America/Argentina/Tucuman", "2004-06-01" },
651 { "America/Argentina/Ushuaia", "2004-05-30" },
652 { "America/Asuncion", "1931-10-10" },
653 { "America/Asuncion", "1974-04-01" },
654 { "America/Bahia", "1914-01-01" },
655 { "America/Bahia_Banderas", "1930-11-15" },
656 { "America/Bahia_Banderas", "1931-10-01" },
657 { "America/Bahia_Banderas", "1942-04-24" },
658 { "America/Bahia_Banderas", "1949-01-14" },
659 { "America/Barbados", "1932-01-01" },
660 { "America/Belize", "1912-04-01" },
661 { "America/Blanc-Sablon", "1884-01-01" },
662 { "America/Bogota", "1914-11-23" },
663 { "America/Buenos_Aires", "1894-10-31" },
664 { "America/Cambridge_Bay", "2000-11-05" },
665 { "America/Campo_Grande", "1914-01-01" },
666 { "America/Caracas", "1912-02-12" },
667 { "America/Catamarca", "1991-10-20" },
668 { "America/Catamarca", "2004-06-01" },
669 { "America/Cayenne", "1911-07-01" },
670 { "America/Chihuahua", "1930-11-15" },
671 { "America/Chihuahua", "1931-10-01" },
672 { "America/Cordoba", "1991-10-20" },
673 { "America/Costa_Rica", "1921-01-15" },
674 { "America/Cuiaba", "1914-01-01" },
675 { "America/Danmarkshavn", "1916-07-28" },
676 { "America/Detroit", "1905-01-01" },
677 { "America/Eirunepe", "1914-01-01" },
678 { "America/El_Salvador", "1921-01-01" },
679 { "America/Ensenada", "1924-01-01" },
680 { "America/Ensenada", "1930-11-15" },
681 { "America/Fortaleza", "1914-01-01" },
682 { "America/Glace_Bay", "1902-06-15" },
683 { "America/Grand_Turk", "1890-01-01" },
684 { "America/Guyana", "1991-01-01" },
685 { "America/Havana", "1890-01-01" },
686 { "America/Hermosillo", "1930-11-15" },
687 { "America/Hermosillo", "1931-10-01" },
688 { "America/Hermosillo", "1942-04-24" },
689 { "America/Hermosillo", "1949-01-14" },
690 { "America/Jujuy", "1991-10-06" },
691 { "America/Lima", "1890-01-01" },
692 { "America/Maceio", "1914-01-01" },
693 { "America/Managua", "1890-01-01" },
694 { "America/Managua", "1934-06-23" },
695 { "America/Managua", "1975-02-16" },
696 { "America/Managua", "1992-09-24" },
697 { "America/Managua", "1997-01-01" },
698 { "America/Mazatlan", "1930-11-15" },
699 { "America/Mazatlan", "1931-10-01" },
700 { "America/Mazatlan", "1942-04-24" },
701 { "America/Mazatlan", "1949-01-14" },
702 { "America/Mendoza", "1992-10-18" },
703 { "America/Mendoza", "2004-05-23" },
704 { "America/Merida", "1982-12-02" },
705 { "America/Mexico_City", "1930-11-15" },
706 { "America/Mexico_City", "1931-10-01" },
707 { "America/Miquelon", "1911-05-15" },
708 { "America/Moncton", "1883-12-09" },
709 { "America/Montevideo", "1942-12-14" },
710 { "America/Montevideo", "1974-12-22" },
711 { "America/Montreal", "1884-01-01" },
712 { "America/Ojinaga", "1930-11-15" },
713 { "America/Ojinaga", "1931-10-01" },
714 { "America/Panama", "1890-01-01" },
715 { "America/Paramaribo", "1911-01-01" },
716 { "America/Porto_Acre", "1914-01-01" },
717 { "America/Recife", "1914-01-01" },
718 { "America/Regina", "1905-09-01" },
719 { "America/Rio_Branco", "1914-01-01" },
720 { "America/Rosario", "1991-10-20" },
721 { "America/Santa_Isabel", "1924-01-01" },
722 { "America/Santa_Isabel", "1930-11-15" },
723 { "America/Santarem", "1914-01-01" },
724 { "America/Santiago", "1910-01-01" },
725 { "America/Santiago", "1919-07-01" },
726 { "America/Santo_Domingo", "1890-01-01" },
727 { "America/Scoresbysund", "1916-07-28" },
728 { "America/Scoresbysund", "1981-03-29" },
729 { "America/Tegucigalpa", "1921-04-01" },
730 { "America/Thunder_Bay", "1895-01-01" },
731 { "America/Tijuana", "1924-01-01" },
732 { "America/Tijuana", "1930-11-15" },
733 { "Antarctica/Casey", "1969-01-01" },
734 { "Antarctica/Casey", "2009-10-18" },
735 { "Antarctica/Davis", "1957-01-13" },
736 { "Antarctica/Davis", "1969-02-01" },
737 { "Antarctica/Davis", "2010-03-11" },
738 { "Antarctica/DumontDUrville", "1947-01-01" },
739 { "Antarctica/DumontDUrville", "1956-11-01" },
740 { "Antarctica/Macquarie", "1911-01-01" },
741 { "Antarctica/Mawson", "1954-02-13" },
742 { "Antarctica/McMurdo", "1956-01-01" },
743 { "Antarctica/Palmer", "1982-05-01" },
744 { "Antarctica/South_Pole", "1956-01-01" },
745 { "Antarctica/Syowa", "1957-01-29" },
746 { "Antarctica/Vostok", "1957-12-16" },
747 { "Arctic/Longyearbyen", "1895-01-01" },
748 { "Asia/Almaty", "1930-06-21" },
749 { "Asia/Anadyr", "1924-05-02" },
750 { "Asia/Anadyr", "1930-06-21" },
751 { "Asia/Anadyr", "1992-01-19" },
752 { "Asia/Anadyr", "2011-03-27" },
753 { "Asia/Aqtau", "1924-05-02" },
754 { "Asia/Aqtau", "1930-06-21" },
755 { "Asia/Aqtau", "1981-10-01" },
756 { "Asia/Aqtau", "2005-03-15" },
757 { "Asia/Aqtobe", "1924-05-02" },
758 { "Asia/Aqtobe", "1930-06-21" },
759 { "Asia/Ashgabat", "1924-05-02" },
760 { "Asia/Ashgabat", "1930-06-21" },
761 { "Asia/Ashgabat", "1992-01-19" },
762 { "Asia/Ashkhabad", "1924-05-02" },
763 { "Asia/Ashkhabad", "1930-06-21" },
764 { "Asia/Ashkhabad", "1992-01-19" },
765 { "Asia/Baghdad", "1918-01-01" },
766 { "Asia/Bahrain", "1920-01-01" },
767 { "Asia/Baku", "1957-03-01" },
768 { "Asia/Bangkok", "1920-04-01" },
769 { "Asia/Bishkek", "1924-05-02" },
770 { "Asia/Bishkek", "1930-06-21" },
771 { "Asia/Brunei", "1933-01-01" },
772 { "Asia/Calcutta", "1941-10-01" },
773 { "Asia/Choibalsan", "1978-01-01" },
774 { "Asia/Chongqing", "1980-05-01" },
775 { "Asia/Chungking", "1980-05-01" },
776 { "Asia/Colombo", "1880-01-01" },
777 { "Asia/Colombo", "1906-01-01" },
778 { "Asia/Colombo", "1942-09-01" },
779 { "Asia/Colombo", "1996-05-25" },
780 { "Asia/Dacca", "1941-10-01" },
781 { "Asia/Dacca", "1942-09-01" },
782 { "Asia/Dhaka", "1941-10-01" },
783 { "Asia/Dhaka", "1942-09-01" },
784 { "Asia/Dili", "2000-09-17" },
785 { "Asia/Dubai", "1920-01-01" },
786 { "Asia/Dushanbe", "1924-05-02" },
787 { "Asia/Dushanbe", "1930-06-21" },
788 { "Asia/Harbin", "1928-01-01" },
789 { "Asia/Harbin", "1940-01-01" },
790 { "Asia/Ho_Chi_Minh", "1912-05-01" },
791 { "Asia/Hong_Kong", "1904-10-30" },
792 { "Asia/Hong_Kong", "1941-12-25" },
793 { "Asia/Hovd", "1978-01-01" },
794 { "Asia/Irkutsk", "1920-01-25" },
795 { "Asia/Irkutsk", "1930-06-21" },
796 { "Asia/Irkutsk", "1992-01-19" },
797 { "Asia/Irkutsk", "2011-03-27" },
798 { "Asia/Istanbul", "1880-01-01" },
799 { "Asia/Istanbul", "1910-10-01" },
800 { "Asia/Istanbul", "1978-10-15" },
801 { "Asia/Jakarta", "1932-11-01" },
802 { "Asia/Jakarta", "1942-03-23" },
803 { "Asia/Jakarta", "1948-05-01" },
804 { "Asia/Jayapura", "1944-09-01" },
805 { "Asia/Kabul", "1945-01-01" },
806 { "Asia/Kamchatka", "1922-11-10" },
807 { "Asia/Kamchatka", "1930-06-21" },
808 { "Asia/Kamchatka", "1992-01-19" },
809 { "Asia/Kamchatka", "2011-03-27" },
810 { "Asia/Karachi", "1907-01-01" },
811 { "Asia/Kashgar", "1928-01-01" },
812 { "Asia/Kashgar", "1980-05-01" },
813 { "Asia/Kathmandu", "1986-01-01" },
814 { "Asia/Katmandu", "1986-01-01" },
815 { "Asia/Kolkata", "1941-10-01" },
816 { "Asia/Krasnoyarsk", "1930-06-21" },
817 { "Asia/Krasnoyarsk", "1992-01-19" },
818 { "Asia/Krasnoyarsk", "2011-03-27" },
819 { "Asia/Kuala_Lumpur", "1901-01-01" },
820 { "Asia/Kuala_Lumpur", "1905-06-01" },
821 { "Asia/Kuala_Lumpur", "1941-09-01" },
822 { "Asia/Kuala_Lumpur", "1942-02-16" },
823 { "Asia/Kuala_Lumpur", "1982-01-01" },
824 { "Asia/Kuching", "1926-03-01" },
825 { "Asia/Kuching", "1933-01-01" },
826 { "Asia/Kuching", "1942-02-16" },
827 { "Asia/Macao", "1912-01-01" },
828 { "Asia/Macau", "1912-01-01" },
829 { "Asia/Magadan", "1930-06-21" },
830 { "Asia/Magadan", "1992-01-19" },
831 { "Asia/Magadan", "2011-03-27" },
832 { "Asia/Makassar", "1932-11-01" },
833 { "Asia/Makassar", "1942-02-09" },
834 { "Asia/Manila", "1942-05-01" },
835 { "Asia/Muscat", "1920-01-01" },
836 { "Asia/Novokuznetsk", "1920-01-06" },
837 { "Asia/Novokuznetsk", "1930-06-21" },
838 { "Asia/Novokuznetsk", "1992-01-19" },
839 { "Asia/Novokuznetsk", "2011-03-27" },
840 { "Asia/Novosibirsk", "1930-06-21" },
841 { "Asia/Novosibirsk", "1992-01-19" },
842 { "Asia/Novosibirsk", "2011-03-27" },
843 { "Asia/Omsk", "1919-11-14" },
844 { "Asia/Omsk", "1930-06-21" },
845 { "Asia/Omsk", "1992-01-19" },
846 { "Asia/Omsk", "2011-03-27" },
847 { "Asia/Oral", "1924-05-02" },
848 { "Asia/Oral", "1930-06-21" },
849 { "Asia/Oral", "2005-03-15" },
850 { "Asia/Phnom_Penh", "1906-06-09" },
851 { "Asia/Phnom_Penh", "1912-05-01" },
852 { "Asia/Pontianak", "1932-11-01" },
853 { "Asia/Pontianak", "1942-01-29" },
854 { "Asia/Pontianak", "1948-05-01" },
855 { "Asia/Pontianak", "1964-01-01" },
856 { "Asia/Pyongyang", "1890-01-01" },
857 { "Asia/Pyongyang", "1904-12-01" },
858 { "Asia/Pyongyang", "1932-01-01" },
859 { "Asia/Pyongyang", "1961-08-10" },
860 { "Asia/Qatar", "1920-01-01" },
861 { "Asia/Qyzylorda", "1930-06-21" },
862 { "Asia/Qyzylorda", "1992-01-19" },
863 { "Asia/Rangoon", "1920-01-01" },
864 { "Asia/Rangoon", "1942-05-01" },
865 { "Asia/Saigon", "1912-05-01" },
866 { "Asia/Sakhalin", "1945-08-25" },
867 { "Asia/Sakhalin", "1992-01-19" },
868 { "Asia/Sakhalin", "2011-03-27" },
869 { "Asia/Samarkand", "1930-06-21" },
870 { "Asia/Seoul", "1890-01-01" },
871 { "Asia/Seoul", "1904-12-01" },
872 { "Asia/Seoul", "1932-01-01" },
873 { "Asia/Seoul", "1961-08-10" },
874 { "Asia/Seoul", "1968-10-01" },
875 { "Asia/Singapore", "1905-06-01" },
876 { "Asia/Singapore", "1941-09-01" },
877 { "Asia/Singapore", "1942-02-16" },
878 { "Asia/Singapore", "1982-01-01" },
879 { "Asia/Tashkent", "1924-05-02" },
880 { "Asia/Tashkent", "1930-06-21" },
881 { "Asia/Tbilisi", "1924-05-02" },
882 { "Asia/Tbilisi", "1957-03-01" },
883 { "Asia/Tbilisi", "2005-03-27" },
884 { "Asia/Tehran", "1946-01-01" },
885 { "Asia/Tehran", "1977-11-01" },
886 { "Asia/Thimbu", "1987-10-01" },
887 { "Asia/Thimphu", "1987-10-01" },
888 { "Asia/Ujung_Pandang", "1932-11-01" },
889 { "Asia/Ujung_Pandang", "1942-02-09" },
890 { "Asia/Ulaanbaatar", "1978-01-01" },
891 { "Asia/Ulan_Bator", "1978-01-01" },
892 { "Asia/Urumqi", "1928-01-01" },
893 { "Asia/Urumqi", "1980-05-01" },
894 { "Asia/Vientiane", "1906-06-09" },
895 { "Asia/Vientiane", "1912-05-01" },
896 { "Asia/Vladivostok", "1922-11-15" },
897 { "Asia/Vladivostok", "1930-06-21" },
898 { "Asia/Vladivostok", "1992-01-19" },
899 { "Asia/Vladivostok", "2011-03-27" },
900 { "Asia/Yakutsk", "1930-06-21" },
901 { "Asia/Yakutsk", "1992-01-19" },
902 { "Asia/Yakutsk", "2011-03-27" },
903 { "Asia/Yekaterinburg", "1930-06-21" },
904 { "Asia/Yekaterinburg", "1992-01-19" },
905 { "Asia/Yekaterinburg", "2011-03-27" },
906 { "Asia/Yerevan", "1924-05-02" },
907 { "Asia/Yerevan", "1957-03-01" },
908 { "Atlantic/Azores", "1884-01-01" },
909 { "Atlantic/Azores", "1911-05-24" },
910 { "Atlantic/Azores", "1942-04-25" },
911 { "Atlantic/Azores", "1943-04-17" },
912 { "Atlantic/Azores", "1944-04-22" },
913 { "Atlantic/Azores", "1945-04-21" },
914 { "Atlantic/Cape_Verde", "1907-01-01" },
915 { "Atlantic/Jan_Mayen", "1895-01-01" },
916 { "Atlantic/Madeira", "1942-04-25" },
917 { "Atlantic/Madeira", "1943-04-17" },
918 { "Atlantic/Madeira", "1944-04-22" },
919 { "Atlantic/Madeira", "1945-04-21" },
920 { "Atlantic/Reykjavik", "1837-01-01" },
921 { "Atlantic/Stanley", "1912-03-12" },
922 { "Australia/Adelaide", "1899-05-01" },
923 { "Australia/Broken_Hill", "1895-02-01" },
924 { "Australia/Broken_Hill", "1899-05-01" },
925 { "Australia/Currie", "1895-09-01" },
926 { "Australia/Darwin", "1895-02-01" },
927 { "Australia/Darwin", "1899-05-01" },
928 { "Australia/Eucla", "1895-12-01" },
929 { "Australia/Hobart", "1895-09-01" },
930 { "Australia/LHI", "1981-03-01" },
931 { "Australia/Lindeman", "1895-01-01" },
932 { "Australia/Lord_Howe", "1981-03-01" },
933 { "Australia/Melbourne", "1895-02-01" },
934 { "Australia/North", "1895-02-01" },
935 { "Australia/North", "1899-05-01" },
936 { "Australia/Perth", "1895-12-01" },
937 { "Australia/South", "1899-05-01" },
938 { "Australia/Tasmania", "1895-09-01" },
939 { "Australia/Victoria", "1895-02-01" },
940 { "Australia/West", "1895-12-01" },
941 { "Australia/Yancowinna", "1895-02-01" },
942 { "Australia/Yancowinna", "1899-05-01" },
943 { "Brazil/Acre", "1914-01-01" },
944 { "Canada/East-Saskatchewan", "1905-09-01" },
945 { "Canada/Saskatchewan", "1905-09-01" },
946 { "Chile/Continental", "1910-01-01" },
947 { "Chile/Continental", "1919-07-01" },
948 { "Chile/EasterIsland", "1932-09-01" },
949 { "Cuba", "1890-01-01" },
950 { "Eire", "1880-08-02" },
951 { "Europe/Amsterdam", "1937-07-01" },
952 { "Europe/Andorra", "1946-09-30" },
953 { "Europe/Athens", "1916-07-28" },
954 { "Europe/Athens", "1944-04-04" },
955 { "Europe/Berlin", "1893-04-01" },
956 { "Europe/Bratislava", "1891-10-01" },
957 { "Europe/Brussels", "1914-11-08" },
958 { "Europe/Bucharest", "1931-07-24" },
959 { "Europe/Chisinau", "1931-07-24" },
960 { "Europe/Copenhagen", "1894-01-01" },
961 { "Europe/Dublin", "1880-08-02" },
962 { "Europe/Gibraltar", "1941-05-04" },
963 { "Europe/Gibraltar", "1942-04-05" },
964 { "Europe/Gibraltar", "1943-04-04" },
965 { "Europe/Gibraltar", "1944-04-02" },
966 { "Europe/Gibraltar", "1945-04-02" },
967 { "Europe/Gibraltar", "1947-04-13" },
968 { "Europe/Helsinki", "1921-05-01" },
969 { "Europe/Istanbul", "1880-01-01" },
970 { "Europe/Istanbul", "1910-10-01" },
971 { "Europe/Istanbul", "1978-10-15" },
972 { "Europe/Kaliningrad", "1945-01-01" },
973 { "Europe/Kaliningrad", "1946-01-01" },
974 { "Europe/Kaliningrad", "2011-03-27" },
975 { "Europe/Kiev", "1930-06-21" },
976 { "Europe/Kiev", "1943-11-06" },
977 { "Europe/Luxembourg", "1904-06-01" },
978 { "Europe/Madrid", "1942-05-02" },
979 { "Europe/Madrid", "1943-04-17" },
980 { "Europe/Madrid", "1944-04-15" },
981 { "Europe/Madrid", "1945-04-14" },
982 { "Europe/Madrid", "1946-04-13" },
983 { "Europe/Malta", "1893-11-02" },
984 { "Europe/Mariehamn", "1921-05-01" },
985 { "Europe/Minsk", "1924-05-02" },
986 { "Europe/Minsk", "1930-06-21" },
987 { "Europe/Minsk", "2011-03-27" },
988 { "Europe/Monaco", "1941-05-05" },
989 { "Europe/Monaco", "1942-03-09" },
990 { "Europe/Monaco", "1943-03-29" },
991 { "Europe/Monaco", "1944-04-03" },
992 { "Europe/Monaco", "1945-04-02" },
993 { "Europe/Moscow", "1916-07-03" },
994 { "Europe/Moscow", "1919-05-31" },
995 { "Europe/Moscow", "1930-06-21" },
996 { "Europe/Moscow", "1992-01-19" },
997 { "Europe/Moscow", "2011-03-27" },
998 { "Europe/Oslo", "1895-01-01" },
999 { "Europe/Paris", "1945-04-02" },
1000 { "Europe/Prague", "1891-10-01" },
1001 { "Europe/Riga", "1926-05-11" },
1002 { "Europe/Riga", "1940-08-05" },
1003 { "Europe/Riga", "1944-10-13" },
1004 { "Europe/Rome", "1893-11-01" },
1005 { "Europe/Samara", "1930-06-21" },
1006 { "Europe/Samara", "1991-10-20" },
1007 { "Europe/Samara", "2011-03-27" },
1008 { "Europe/San_Marino", "1893-11-01" },
1009 { "Europe/Simferopol", "1930-06-21" },
1010 { "Europe/Simferopol", "1994-05-01" },
1011 { "Europe/Sofia", "1880-01-01" },
1012 { "Europe/Sofia", "1894-11-30" },
1013 { "Europe/Tallinn", "1919-07-01" },
1014 { "Europe/Tallinn", "1921-05-01" },
1015 { "Europe/Tallinn", "1940-08-06" },
1016 { "Europe/Tiraspol", "1931-07-24" },
1017 { "Europe/Uzhgorod", "1945-06-29" },
1018 { "Europe/Vaduz", "1894-06-01" },
1019 { "Europe/Vatican", "1893-11-01" },
1020 { "Europe/Vilnius", "1917-01-01" },
1021 { "Europe/Vilnius", "1920-07-12" },
1022 { "Europe/Vilnius", "1940-08-03" },
1023 { "Europe/Volgograd", "1920-01-03" },
1024 { "Europe/Volgograd", "1930-06-21" },
1025 { "Europe/Volgograd", "1991-03-31" },
1026 { "Europe/Volgograd", "2011-03-27" },
1027 { "Europe/Zaporozhye", "1930-06-21" },
1028 { "Europe/Zaporozhye", "1943-10-25" },
1029 { "Europe/Zurich", "1894-06-01" },
1030 { "Hongkong", "1904-10-30" },
1031 { "Hongkong", "1941-12-25" },
1032 { "Iceland", "1837-01-01" },
1033 { "Indian/Chagos", "1907-01-01" },
1034 { "Indian/Chagos", "1996-01-01" },
1035 { "Indian/Cocos", "1900-01-01" },
1036 { "Indian/Comoro", "1911-07-01" },
1037 { "Indian/Kerguelen", "1950-01-01" },
1038 { "Indian/Mahe", "1906-06-01" },
1039 { "Indian/Maldives", "1960-01-01" },
1040 { "Indian/Mauritius", "1907-01-01" },
1041 { "Indian/Reunion", "1911-06-01" },
1042 { "Iran", "1946-01-01" },
1043 { "Iran", "1977-11-01" },
1044 { "Libya", "1920-01-01" },
1045 { "Libya", "1959-01-01" },
1046 { "Libya", "1990-05-04" },
1047 { "Mexico/BajaNorte", "1924-01-01" },
1048 { "Mexico/BajaNorte", "1930-11-15" },
1049 { "Mexico/BajaSur", "1930-11-15" },
1050 { "Mexico/BajaSur", "1931-10-01" },
1051 { "Mexico/BajaSur", "1942-04-24" },
1052 { "Mexico/BajaSur", "1949-01-14" },
1053 { "Mexico/General", "1930-11-15" },
1054 { "Mexico/General", "1931-10-01" },
1055 { "NZ-CHAT", "1957-01-01" },
1056 { "Pacific/Apia", "1911-01-01" },
1057 { "Pacific/Apia", "2011-12-30" },
1058 { "Pacific/Chatham", "1957-01-01" },
1059 { "Pacific/Easter", "1932-09-01" },
1060 { "Pacific/Enderbury", "1901-01-01" },
1061 { "Pacific/Enderbury", "1995-01-01" },
1062 { "Pacific/Fakaofo", "2011-12-30" },
1063 { "Pacific/Fiji", "1915-10-26" },
1064 { "Pacific/Funafuti", "1901-01-01" },
1065 { "Pacific/Galapagos", "1986-01-01" },
1066 { "Pacific/Gambier", "1912-10-01" },
1067 { "Pacific/Guadalcanal", "1912-10-01" },
1068 { "Pacific/Guam", "1901-01-01" },
1069 { "Pacific/Kiritimati", "1901-01-01" },
1070 { "Pacific/Kiritimati", "1995-01-01" },
1071 { "Pacific/Kosrae", "1901-01-01" },
1072 { "Pacific/Kosrae", "1969-10-01" },
1073 { "Pacific/Kwajalein", "1993-08-20" },
1074 { "Pacific/Majuro", "1969-10-01" },
1075 { "Pacific/Marquesas", "1912-10-01" },
1076 { "Pacific/Nauru", "1921-01-15" },
1077 { "Pacific/Nauru", "1944-08-15" },
1078 { "Pacific/Nauru", "1979-05-01" },
1079 { "Pacific/Niue", "1901-01-01" },
1080 { "Pacific/Niue", "1951-01-01" },
1081 { "Pacific/Norfolk", "1901-01-01" },
1082 { "Pacific/Norfolk", "1951-01-01" },
1083 { "Pacific/Pago_Pago", "1911-01-01" },
1084 { "Pacific/Palau", "1901-01-01" },
1085 { "Pacific/Pohnpei", "1901-01-01" },
1086 { "Pacific/Ponape", "1901-01-01" },
1087 { "Pacific/Port_Moresby", "1895-01-01" },
1088 { "Pacific/Rarotonga", "1978-11-12" },
1089 { "Pacific/Saipan", "1969-10-01" },
1090 { "Pacific/Samoa", "1911-01-01" },
1091 { "Pacific/Tahiti", "1912-10-01" },
1092 { "Pacific/Tarawa", "1901-01-01" },
1093 { "Pacific/Tongatapu", "1901-01-01" },
1094 { "Pacific/Tongatapu", "1941-01-01" },
1095 { "Pacific/Wake", "1901-01-01" },
1096 { "ROK", "1890-01-01" },
1097 { "ROK", "1904-12-01" },
1098 { "ROK", "1932-01-01" },
1099 { "ROK", "1961-08-10" },
1100 { "ROK", "1968-10-01" },
1101 { "Singapore", "1905-06-01" },
1102 { "Singapore", "1941-09-01" },
1103 { "Singapore", "1942-02-16" },
1104 { "Singapore", "1982-01-01" },
1105 { "Turkey", "1880-01-01" },
1106 { "Turkey", "1910-10-01" },
1107 { "Turkey", "1978-10-15" },
1108 { "US/Michigan", "1905-01-01" },
1109 { "US/Samoa", "1911-01-01" },
1110 { "W-SU", "1916-07-03" },
1111 { "W-SU", "1930-06-21" },
1112 { "W-SU", "1992-01-19" },
1113 { "W-SU", "2011-03-27" }
1116 LanguageType eLang
= LANGUAGE_ENGLISH_US
;
1117 SvNumberFormatter
aFormatter(m_xContext
, eLang
);
1119 for (auto const& aEntry
: aData
)
1121 checkDateInput(aFormatter
, aEntry
[0], aEntry
[1]);
1125 void Test::checkDateInput( SvNumberFormatter
& rFormatter
, const char* pTimezone
, const char* pIsoDate
)
1127 icu::TimeZone::adoptDefault( icu::TimeZone::createTimeZone( pTimezone
));
1128 OUString
aDate( OUString::createFromAscii(pIsoDate
));
1129 sal_uInt32 nIndex
= 0;
1131 bool bVal
= rFormatter
.IsNumberFormat( aDate
, nIndex
, fVal
);
1132 CPPUNIT_ASSERT_MESSAGE( OString(OString::Concat("Date not recognized: ") +
1133 pTimezone
+ " " + pIsoDate
).getStr(), bVal
);
1134 CPPUNIT_ASSERT_MESSAGE("Format parsed is not date.",
1135 (rFormatter
.GetType(nIndex
) & SvNumFormatType::DATE
));
1136 OUString aOutString
;
1137 const Color
*pColor
;
1138 rFormatter
.GetOutputString( fVal
, nIndex
, aOutString
, &pColor
);
1139 CPPUNIT_ASSERT_EQUAL( aDate
, aOutString
);
1142 void Test::testIsNumberFormat()
1144 LanguageType eLang
= LANGUAGE_ENGLISH_US
;
1145 SvNumberFormatter
aFormatter(m_xContext
, eLang
);
1147 static struct NumberFormatData
1149 const char* pFormat
;
1151 } const aTests
[] = {
1155 { "Jan1", false }, // tdf#34724
1156 { "1Jan", false }, // tdf#34724
1157 { "Jan1 2000", true }, // tdf#91420
1158 { "Jan1, 2000", true }, // tdf#91420
1160 { "Sept 1", true }, //tdf#127363
1161 { "5/d", false }, //tdf#143165
1162 { "Jan 1 2000", true },
1163 { "5-12-14", false },
1164 { "005-12-14", true },
1165 { "15-10-30", true },
1166 { "2015-10-30", true },
1167 { "1999-11-23T12:34:56", true },
1168 { "1999-11-23 12:34:56", true },
1169 { "1999-11-23T12:34:56.789", true },
1170 { "1999-11-23T12:34:56,789", true }, // ISO 8601 defines both dot and comma as fractional separator
1171 { "1999-11-23 12:34:56.789", true },
1172 { "1999-11-23 12:34:56,789", false }, // comma not in en-US if 'T' separator is not present,
1173 // debatable, 'T' "may be omitted by mutual consent of those
1174 // interchanging data, if ambiguity can be avoided."
1175 { "1999-11-23T12:34:56/789", false },
1176 { "−1000", true } // unicode minus
1179 for (auto const[pFormat
, bTestIsNumber
] : aTests
)
1181 sal_uInt32 nIndex
= 0;
1183 OUString aString
= OUString::fromUtf8(pFormat
);
1184 bool bIsNumber
= aFormatter
.IsNumberFormat(aString
, nIndex
, nNumber
);
1185 CPPUNIT_ASSERT_EQUAL_MESSAGE(pFormat
, bTestIsNumber
, bIsNumber
);
1189 struct FormatInputOutput
1191 const char* mpInput
;
1192 const bool mbNumber
;
1193 const char* mpOutput
;
1194 const sal_uInt32 mnOutputIndex
;
1197 void checkSpecificNumberFormats( SvNumberFormatter
& rFormatter
,
1198 const std::vector
<FormatInputOutput
>& rVec
, const char* pName
)
1201 for (size_t i
= 0; i
< rVec
.size(); ++i
)
1203 sal_uInt32 nIndex
= 0;
1205 OUString
aString( OUString::fromUtf8( rVec
[i
].mpInput
));
1206 const bool bIsNumber
= rFormatter
.IsNumberFormat( aString
, nIndex
, fNumber
);
1207 CPPUNIT_ASSERT_EQUAL_MESSAGE( OString( pName
+ OString::Concat(" ") + OString::number(i
) +
1208 (rVec
[i
].mbNumber
? " not recognized: " : " should not be recognized: ") +
1209 OUStringToOString( aString
, RTL_TEXTENCODING_UTF8
)).getStr(), rVec
[i
].mbNumber
, bIsNumber
);
1212 if (rVec
[i
].mnOutputIndex
)
1213 nIndex
= rVec
[i
].mnOutputIndex
;
1214 const Color
* pColor
;
1215 rFormatter
.GetOutputString( fNumber
, nIndex
, aString
, &pColor
);
1216 CPPUNIT_ASSERT_EQUAL_MESSAGE( OString( pName
+ OString::Concat(" ") + OString::number(i
) + " mismatch").getStr(),
1217 OUString::fromUtf8( rVec
[i
].mpOutput
), aString
);
1222 void Test::testIsNumberFormatSpecific()
1225 // en-US uses M/D/Y format, test that a-b-c input with a<=31 and b<=12
1226 // does not lead to a/b/c date output
1227 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_ENGLISH_US
);
1229 std::vector
<FormatInputOutput
> aIO
= {
1230 { "5-12-14", false, "", 0 },
1231 { "32-12-14", true, "1932-12-14", 0 }
1234 checkSpecificNumberFormats( aFormatter
, aIO
, "[en-US] date");
1238 // de-DE uses D.M.Y format, test that a-b-c input with a<=31 and b<=12
1239 // does not lead to a.b.c date output
1240 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_GERMAN
);
1242 std::vector
<FormatInputOutput
> aIO
= {
1243 { "5-12-14", false, "", 0 },
1244 { "32-12-14", true, "1932-12-14", 0 }
1247 checkSpecificNumberFormats( aFormatter
, aIO
, "[de-DE] date");
1251 // nl-NL uses D-M-Y format, test that D-M-Y input leads to D-M-Y output
1252 // and ISO Y-M-D input leads to Y-M-D output.
1253 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_DUTCH
);
1255 std::vector
<FormatInputOutput
> aIO
= {
1256 { "22-11-1999", true, "22-11-99", 0 }, // if default YY changes to YYYY adapt this
1257 { "1999-11-22", true, "1999-11-22", 0 },
1258 { "1-2-11", true, "01-02-11", 0 }, // if default YY changes to YYYY adapt this
1259 { "99-2-11", true, "1999-02-11", 0 }
1262 checkSpecificNumberFormats( aFormatter
, aIO
, "[nl-NL] date");
1266 // en-ZA uses Y-M-D and Y/M/D format, test that either are accepted.
1267 // The default format changed from YY/MM/DD to YYYY-MM-DD.
1268 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_ENGLISH_SAFRICA
);
1270 std::vector
<FormatInputOutput
> aIO
= {
1271 { "1999/11/22", true, "1999-11-22", 0 },
1272 { "1999-11-22", true, "1999-11-22", 0 },
1273 { "11/2/1", true, "2011-02-01", 0 },
1274 { "99-2-11", true, "1999-02-11", 0 },
1275 { "22-2-11", true, "2022-02-11", 0 },
1276 { "02 Mar 2020",true, "2020-03-02", 0 }
1279 checkSpecificNumberFormats( aFormatter
, aIO
, "[en-ZA] date");
1283 // fr-FR uses D/M/Y format with additional D.M.Y and D-M-Y date
1284 // acceptance patterns, test combinations.
1285 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_FRENCH
);
1287 std::vector
<FormatInputOutput
> aIO
= {
1288 { "22/11/1999", true, "22/11/99", 0 }, // if default YY changes to YYYY adapt this
1289 { "1999-11-22", true, "1999-11-22", 0 },
1290 { "1/2/11", true, "01/02/11", 0 }, // if default YY changes to YYYY adapt this
1291 { "99-2-11", true, "1999-02-11", 0 },
1292 { "22-2-11", true, "22/02/11", 0 }, // if default YY changes to YYYY adapt this
1293 { "22.2.11", true, "22/02/11", 0 } // if default YY changes to YYYY adapt this
1296 checkSpecificNumberFormats( aFormatter
, aIO
, "[fr-FR] date");
1300 // Test Spanish "mar" short name ambiguity, day "martes" or month "marzo".
1301 // Day of week names are only parsed away, not evaluated if they actually
1302 // correspond to the date given.
1303 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_SPANISH
);
1305 const sal_uInt32 n
= aFormatter
.GetFormatIndex( NF_DATE_SYS_DDMMYYYY
, LANGUAGE_SPANISH
);
1306 std::vector
<FormatInputOutput
> aIO
= {
1307 { "22/11/1999", true, "22/11/1999", n
},
1308 { "Lun 22/11/1999", true, "22/11/1999", n
},
1309 { "Mar 22/11/1999", true, "22/11/1999", n
},
1310 { "Abr 22/11/1999", false, "", n
}, // month name AND numeric month don't go along
1311 { "Lun Mar 22/11/1999", false, "", n
}, // month name AND numeric month don't go along
1312 { "Mar Mar 22/11/1999", false, "", n
}, // month name AND numeric month don't go along
1313 { "Lun Mar 22 1999", true, "22/03/1999", n
},
1314 { "Mar Mar 22 1999", true, "22/03/1999", n
},
1315 { "Mar Lun 22 1999", false, "", n
} // day name only at the beginning (could change?)
1318 checkSpecificNumberFormats( aFormatter
, aIO
, "[es-ES] date");
1322 // Test that de-DE accepts Januar and Jänner.
1323 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_GERMAN
);
1325 const sal_uInt32 n
= aFormatter
.GetFormatIndex( NF_DATE_SYS_DDMMYYYY
, LANGUAGE_GERMAN
);
1326 std::vector
<FormatInputOutput
> aIO
= {
1327 { "23. Januar 1999", true, "23.01.1999", n
},
1328 { "23. J\xC3\xA4nner 1999", true, "23.01.1999", n
},
1329 { "23. Jan. 1999", true, "23.01.1999", n
},
1330 { "23. J\xC3\xA4n. 1999", true, "23.01.1999", n
},
1333 checkSpecificNumberFormats( aFormatter
, aIO
, "[de-DE] date January month names");
1338 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_GERMAN
);
1340 const sal_uInt32 n
= aFormatter
.GetFormatIndex( NF_DATE_SYS_DDMMYYYY
, LANGUAGE_GERMAN
);
1341 std::vector
<FormatInputOutput
> aIO
= {
1342 { "23. M\u00C4R 1999", true, "23.03.1999", n
},
1343 { "23. M\u00C4RZ 1999", true, "23.03.1999", n
},
1344 { "23. MRZ 1999", true, "23.03.1999", n
},
1347 checkSpecificNumberFormats( aFormatter
, aIO
, "[de-DE] date March month names");
1351 // Test that de-AT accepts Januar and Jänner.
1352 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_GERMAN_AUSTRIAN
);
1354 const sal_uInt32 n
= aFormatter
.GetFormatIndex( NF_DATE_SYS_DDMMYYYY
, LANGUAGE_GERMAN_AUSTRIAN
);
1355 std::vector
<FormatInputOutput
> aIO
= {
1356 { "23. Januar 1999", true, "23.01.1999", n
},
1357 { "23. J\xC3\xA4nner 1999", true, "23.01.1999", n
},
1358 { "23. Jan. 1999", true, "23.01.1999", n
},
1359 { "23. J\xC3\xA4n. 1999", true, "23.01.1999", n
},
1362 checkSpecificNumberFormats( aFormatter
, aIO
, "[de-AT] date January month names");
1366 void Test::testUserDefinedNumberFormats()
1368 LanguageType eLang
= LANGUAGE_ENGLISH_US
;
1369 OUString sCode
, sExpected
;
1370 SvNumberFormatter
aFormatter(m_xContext
, eLang
);
1371 { // tdf#97835: suppress decimal separator
1372 sCode
= "0.##\" m\"";
1374 checkPreviewString(aFormatter
, sCode
, 12.0, eLang
, sExpected
);
1376 { // tdf#61996: skip quoted text
1377 sCode
= "0.00\" ;\"";
1378 sExpected
= "-12.00 ;";
1379 checkPreviewString(aFormatter
, sCode
, -12.0, eLang
, sExpected
);
1382 sCode
= "000\" \"000/000";
1383 sExpected
= "003 016/113";
1384 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1387 sCode
= "#\" string \"?/???";
1388 sExpected
= "3 string 16/113";
1389 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1394 checkPreviewString(aFormatter
, sCode
, 2E+306, eLang
, sExpected
);
1397 sCode
= "YYYY-MM-DD";
1399 checkPreviewString(aFormatter
, sCode
, -12662108.0, eLang
, sExpected
);
1402 sCode
= "[HH]:MM:SS";
1403 sExpected
= "08:47:00";
1404 checkPreviewString(aFormatter
, sCode
, 0.365972222222222, eLang
, sExpected
);
1407 checkPreviewString(aFormatter
, sCode
, 0.365972222222222, eLang
, sExpected
);
1412 checkPreviewString(aFormatter
, sCode
, -0.5, eLang
, sExpected
);
1415 sCode
= "_($* #,##0.00_);_($* (#,##0.00);";
1417 checkPreviewString(aFormatter
, sCode
, 0.0, eLang
, sExpected
);
1419 { // tdf#95339: detect SSMM as second minute
1420 sCode
= "SS:MM:HH DD/MM/YY"; // Month not detected by Excel, but we do not follow that.
1421 sExpected
= "53:23:03 02/01/00";
1422 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1424 { // tdf#101147: detect SSMM as second month
1425 sCode
= "HH:MM:SS MM/DD";
1426 sExpected
= "03:23:53 01/02";
1427 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1430 sCode
= "HH:MM:SS.000000";
1431 sExpected
= "12:54:00.000000";
1432 checkPreviewString(aFormatter
, sCode
, 43521.5375, eLang
, sExpected
);
1434 { // tdf#101096: different detection of month/minute with Excel
1435 sCode
= "HH DD MM"; // month detected because of previous DD
1436 sExpected
= "03 02 01";
1437 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1438 sCode
= "HH:MM HH DD/MM"; // month detected because of previous DD
1439 sExpected
= "03:23 03 02/01";
1440 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1441 sCode
= "SS:DD-MM-YY SS:MM"; // 1st is month, because of previous DD; 2nd is minute as SS has not minute
1442 sExpected
= "53:02-01-00 53:23";
1443 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1445 { // tdf#99996: better algorithm for fraction representation
1447 sExpected
= "-575 540/697";
1448 checkPreviewString(aFormatter
, sCode
, -575.774749601315, eLang
, sExpected
);
1450 { // tdf#153887: integer value without integer part displayed
1453 checkPreviewString(aFormatter
, sCode
, 1.95, eLang
, sExpected
);
1454 checkPreviewString(aFormatter
, sCode
, 2.00, eLang
, sExpected
);
1455 checkPreviewString(aFormatter
, sCode
, 2.05, eLang
, sExpected
);
1458 checkPreviewString(aFormatter
, sCode
, 1.95, eLang
, sExpected
);
1459 checkPreviewString(aFormatter
, sCode
, 2.00, eLang
, sExpected
);
1460 checkPreviewString(aFormatter
, sCode
, 2.05, eLang
, sExpected
);
1462 { // tdf#102507: left alignment of denominator
1464 sExpected
= "3 1/2 ";
1465 checkPreviewString(aFormatter
, sCode
, 3.5, eLang
, sExpected
);
1467 { // tdf#100594: forced denominator
1469 sExpected
= " 6/100";
1470 checkPreviewString(aFormatter
, sCode
, 0.06, eLang
, sExpected
);
1472 { // tdf#100754: forced denominator with text after fraction
1473 sCode
= "# ?/16\" inch\"";
1474 sExpected
= "2 6/16 inch";
1475 checkPreviewString(aFormatter
, sCode
, 2.379, eLang
, sExpected
);
1477 { // tdf#100842: text before/after fraction
1478 sCode
= "\"before \"?/?\" after\"";
1479 sExpected
= "before 11/9 after";
1480 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1481 sCode
= "\"before \"# ?/?\" after\"";
1482 sExpected
= "before 1 2/9 after";
1483 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1484 sCode
= "\"before \"0.0\"inside\"0E+0\"middle\"0\" after\"";
1485 sExpected
= "before 1.2inside3E+0middle4 after";
1486 checkPreviewString(aFormatter
, sCode
, 12345.667, eLang
, sExpected
);
1488 { // tdf#106190: text after fraction bar
1490 sExpected
= "11/ 9";
1491 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1493 sExpected
= "15/ 12";
1494 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1495 sCode
= "# ?/\" divisor \"?";
1496 sExpected
= "1 2/ divisor 9";
1497 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1498 sCode
= "# ?/\"divided by \"?";
1499 sExpected
= "1 2/divided by 9";
1500 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1501 sCode
= "?/\" \"12";
1502 sExpected
= "15/ 12";
1503 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1505 sExpected
= "15/ 12";
1506 checkPreviewString(aFormatter
, sCode
, 1.2345667, eLang
, sExpected
);
1508 sExpected
= "3 1/ 2 ";
1509 checkPreviewString(aFormatter
, sCode
, 3.5, eLang
, sExpected
);
1511 { // Display 1.96 as 2 and not 1 1/1
1514 checkPreviewString(aFormatter
, sCode
, 1.96, eLang
, sExpected
);
1517 checkPreviewString(aFormatter
, sCode
, 1.96, eLang
, sExpected
);
1520 checkPreviewString(aFormatter
, sCode
, 1.96, eLang
, sExpected
);
1522 { // tdf#79399 tdf#101462 Native Number Formats
1523 sCode
= "[NatNum5][$-0404]General\\ ";
1524 // Chinese upper case number characters for 120
1525 sExpected
= u
"\u58F9\u4F70\u8CB3\u62FE "_ustr
;
1526 checkPreviewString(aFormatter
, sCode
, 120, eLang
, sExpected
);
1527 sCode
= "[DBNum2][$-0404]General\\ ";
1528 checkPreviewString(aFormatter
, sCode
, 120, eLang
, sExpected
);
1529 // tdf#115007 - cardinal/ordinal number names/indicators
1530 sCode
= "[NatNum12]0";
1531 sExpected
= "one hundred twenty-three";
1532 checkPreviewString(aFormatter
, sCode
, 123, eLang
, sExpected
);
1533 sCode
= "[NatNum12]0.00";
1534 sExpected
= "one hundred twenty-three point four five";
1535 checkPreviewString(aFormatter
, sCode
, 123.45, eLang
, sExpected
);
1536 sCode
= "[NatNum12 ordinal]0";
1537 sExpected
= "one hundred twenty-third";
1538 checkPreviewString(aFormatter
, sCode
, 123, eLang
, sExpected
);
1539 sCode
= "[NatNum12 ordinal-number]0";
1540 sExpected
= "123rd";
1541 checkPreviewString(aFormatter
, sCode
, 123, eLang
, sExpected
);
1542 sCode
= "[NatNum12 capitalize]0";
1543 sExpected
= "One hundred twenty-three";
1544 checkPreviewString(aFormatter
, sCode
, 123, eLang
, sExpected
);
1545 sCode
= "[NatNum12 title ordinal]0";
1546 sExpected
= "One Thousand Two Hundred Thirty-Fourth";
1547 checkPreviewString(aFormatter
, sCode
, 1234, eLang
, sExpected
);
1548 sCode
= "[NatNum12 upper ordinal-number]0";
1549 sExpected
= "12345TH";
1550 checkPreviewString(aFormatter
, sCode
, 12345, eLang
, sExpected
);
1551 sCode
= "[NatNum12 D=ordinal-number]D\" of \"MMMM";
1552 sExpected
= "2nd of January";
1553 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1554 sCode
= "[NatNum12 D=ordinal-number,YYYY=year]D\" of \"MMMM\", \"YYYY";
1555 sExpected
= "2nd of January, nineteen hundred";
1556 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1557 sCode
= "[NatNum12 YYYY=title year, D=capitalize ordinal]D\" of \"MMMM\", \"YYYY";
1558 sExpected
= "Second of January, Nineteen Hundred";
1559 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1560 sCode
= "[NatNum12 MMMM=upper MMM=upper MMMMM=upper]MMMM MMM MMMMM";
1561 sExpected
= "JANUARY JAN J";
1562 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1563 sCode
= "[NatNum12 DDDD=upper DDD=upper]DDDD DDD";
1564 sExpected
= "TUESDAY TUE";
1565 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1566 sCode
= "[NatNum12 NNN=upper NN=upper]NNN NN";
1567 sExpected
= "TUESDAY TUE";
1568 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1569 sCode
= "[NatNum12 MMMM=lower MMM=lower MMMMM=lower]MMMM MMM MMMMM";
1570 sExpected
= "january jan j";
1571 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1572 sCode
= "[NatNum12 DDDD=lower DDD=lower]DDDD DDD";
1573 sExpected
= "tuesday tue";
1574 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1575 sCode
= "[NatNum12 NNN=lower NN=lower]NNN NN";
1576 sExpected
= "tuesday tue";
1577 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1579 { // tdf#130193 tdf#130140 Native Number Formats mapping for Chinese (Traditional), Japanese, Korean
1580 // -- Traditional Chinese: DBNum1 -> NatNum4, DBNum2 -> NatNum5, DBnum3 -> NatNum3
1582 // DBNum1 -> NatNum4: Chinese lower case text for 123456789
1583 // 一億二千三百四十五萬六千七百八十九
1584 sExpected
= u
"\u4e00\u5104\u4e8c\u5343\u4e09\u767e\u56db\u5341\u4e94\u842c\u516d\u5343"
1585 u
"\u4e03\u767e\u516b\u5341\u4e5d "_ustr
;
1586 sCode
= "[NatNum4][$-0404]General\\ ";
1587 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1588 sCode
= "[DBNum1][$-0404]General\\ ";
1589 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1591 // DBNum2 -> NatNum5: Chinese upper case text
1592 // 壹億貳仟參佰肆拾伍萬陸仟柒佰捌拾玖
1593 sExpected
= u
"\u58f9\u5104\u8cb3\u4edf\u53c3\u4f70\u8086\u62fe\u4f0d\u842c\u9678\u4edf"
1594 u
"\u67d2\u4f70\u634c\u62fe\u7396 "_ustr
;
1595 sCode
= "[NatNum5][$-0404]General\\ ";
1596 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1597 sCode
= "[DBNum2][$-0404]General\\ ";
1598 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1600 // DBNum3 -> NatNum3: fullwidth text
1602 sExpected
= u
"\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19 "_ustr
;
1603 sCode
= "[NatNum3][$-0404]General\\ ";
1604 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1605 sCode
= "[DBNum3][$-0404]General\\ ";
1606 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1608 // -- Japanese: DBNum1 -> NatNum4, DBNum2 -> NatNum5, DBnum3 -> NatNum3
1610 // DBNum1 -> NatNum4: Japanese modern long Kanji text for 123456789
1611 // 一億二千三百四十五万六千七百八十九
1612 sExpected
= u
"\u4e00\u5104\u4e8c\u5343\u4e09\u767e\u56db\u5341\u4e94\u4e07\u516d\u5343"
1613 u
"\u4e03\u767e\u516b\u5341\u4e5d "_ustr
;
1614 sCode
= "[NatNum4][$-0411]General\\ ";
1615 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1616 sCode
= "[DBNum1][$-0411]General\\ ";
1617 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1619 // DBNum2 -> NatNum5: traditional long Kanji text
1620 // 壱億弐阡参百四拾伍萬六阡七百八拾九
1621 sExpected
= u
"\u58f1\u5104\u5f10\u9621\u53c2\u767e\u56db\u62fe\u4f0d\u842c\u516d\u9621"
1622 u
"\u4e03\u767e\u516b\u62fe\u4e5d "_ustr
;
1623 sCode
= "[NatNum5][$-0411]General\\ ";
1624 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1625 sCode
= "[DBNum2][$-0411]General\\ ";
1626 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1628 // DBNum3 -> NatNum3: fullwidth Arabic digits
1630 sExpected
= u
"\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19 "_ustr
;
1631 sCode
= "[NatNum3][$-0411]General\\ ";
1632 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1633 sCode
= "[DBNum3][$-0411]General\\ ";
1634 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1636 // -- Korean: DBNum1 -> NatNum4, DBNum2 -> NatNum5, DBNum3 -> NatNum6, DBNum4 -> NatNum10
1638 // DBNum1 -> NatNum4: Korean lower case characters
1639 // 一億二千三百四十五万六千七百八十九
1640 sExpected
= u
"\u4e00\u5104\u4e8c\u5343\u4e09\u767e\u56db\u5341\u4e94\u4e07\u516d\u5343\u4e03\u767e\u516b\u5341\u4e5d "_ustr
;
1641 sCode
= "[NatNum4][$-0412]General\\ ";
1642 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1643 sCode
= "[DBNum1][$-0412]General\\ ";
1644 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1646 // DBNum2 -> NatNum5: Korean upper case characters
1647 // 壹億貳阡參佰四拾伍萬六阡七佰八拾九
1648 sExpected
= u
"\u58f9\u5104\u8cb3\u9621\u53c3\u4f70\u56db\u62fe\u4f0d\u842c\u516d\u9621\u4e03\u4f70\u516b\u62fe\u4e5d "_ustr
;
1649 sCode
= "[NatNum5][$-0412]General\\ ";
1650 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1651 sCode
= "[DBNum2][$-0412]General\\ ";
1652 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1654 // DBNum3 -> NatNum6: fullwidth Arabic digits
1655 // 1억2천3백4십5만6천7백8십9
1656 sExpected
= u
"\uff11\uc5b5\uff12\ucc9c\uff13\ubc31\uff14\uc2ed\uff15\ub9cc\uff16\ucc9c\uff17\ubc31\uff18\uc2ed\uff19 "_ustr
;
1657 sCode
= "[NatNum6][$-0412]General\\ ";
1658 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1659 sCode
= "[DBNum3][$-0412]General\\ ";
1660 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1662 // DBNum4 -> NatNum10: Hangul characters
1663 // 일억이천삼백사십오만육천칠백팔십구
1664 sExpected
= u
"\uc77c\uc5b5\uc774\ucc9c\uc0bc\ubc31\uc0ac\uc2ed\uc624\ub9cc\uc721\ucc9c\uce60\ubc31\ud314\uc2ed\uad6c "_ustr
;
1665 sCode
= "[NatNum10][$-0412]General\\ ";
1666 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1667 sCode
= "[DBNum4][$-0412]General\\ ";
1668 checkPreviewString(aFormatter
, sCode
, 123456789, eLang
, sExpected
);
1670 { // tdf#105968 engineering format with value rounded up to next magnitude
1671 sCode
= "##0.00E+00";
1672 sExpected
= "100.00E+00";
1673 checkPreviewString(aFormatter
, sCode
, 99.995, eLang
, sExpected
);
1674 // test '1'=='1' assumption
1675 checkPreviewString(aFormatter
, sCode
, 100.0, eLang
, sExpected
);
1676 sExpected
= "199.99E+00";
1677 checkPreviewString(aFormatter
, sCode
, 199.99, eLang
, sExpected
);
1678 sExpected
= "1.00E+03";
1679 checkPreviewString(aFormatter
, sCode
, 1000.0, eLang
, sExpected
);
1680 // and another just "normally" rounded value
1681 sExpected
= "894.55E-06";
1682 checkPreviewString(aFormatter
, sCode
, 0.000894549, eLang
, sExpected
);
1683 // not expecting rounding into another magnitude
1684 sExpected
= "999.99E-06";
1685 checkPreviewString(aFormatter
, sCode
, 0.000999991, eLang
, sExpected
);
1686 // expecting rounding into another magnitude
1687 sExpected
= "1.00E-03";
1688 checkPreviewString(aFormatter
, sCode
, 0.000999999, eLang
, sExpected
);
1690 // Now the same all negative values.
1691 sExpected
= "-100.00E+00";
1692 checkPreviewString(aFormatter
, sCode
, -99.995, eLang
, sExpected
);
1693 checkPreviewString(aFormatter
, sCode
, -100.0, eLang
, sExpected
);
1694 sExpected
= "-199.99E+00";
1695 checkPreviewString(aFormatter
, sCode
, -199.99, eLang
, sExpected
);
1696 sExpected
= "-1.00E+03";
1697 checkPreviewString(aFormatter
, sCode
, -1000.0, eLang
, sExpected
);
1698 sExpected
= "-894.55E-06";
1699 checkPreviewString(aFormatter
, sCode
, -0.000894549, eLang
, sExpected
);
1700 sExpected
= "-999.99E-06";
1701 checkPreviewString(aFormatter
, sCode
, -0.000999991, eLang
, sExpected
);
1702 sExpected
= "-1.00E-03";
1703 checkPreviewString(aFormatter
, sCode
, -0.000999999, eLang
, sExpected
);
1705 { // tdf#112933 one decimal seconds fraction
1707 sExpected
= "23:53.6";
1708 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1711 sExpected
= "23:53.61";
1712 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1714 sCode
= "MM:SS.000";
1715 sExpected
= "23:53.605";
1716 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1718 // Same with date+time.
1719 sCode
= "YYYY-MM-DD MM:SS.0";
1720 sExpected
= "1900-01-02 23:53.6";
1721 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1722 sCode
= "YYYY-MM-DD MM:SS.00";
1723 sExpected
= "1900-01-02 23:53.61";
1724 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1725 sCode
= "YYYY-MM-DD MM:SS.000";
1726 sExpected
= "1900-01-02 23:53.605";
1727 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1729 { // tdf#150028 decimals of seconds fraction without truncate on overflow
1731 sExpected
= "271434";
1732 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1735 sExpected
= "271433.6";
1736 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1739 sExpected
= "271433.61";
1740 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1743 sExpected
= "271433.605";
1744 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1746 { // tdf#156449 Use '?' in exponent of scientific number
1748 sExpected
= "3.14E+ 0"; // before change it was "3.14E+00"
1749 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1750 // There should be at least one '0' in exponent
1752 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1754 { // tdf#33689 use English NfKeywords in non-English language
1755 eLang
= LANGUAGE_DUTCH
;
1756 sExpected
= "Dutch: 1900/01/02 03:23:53";
1757 sCode
= "\"Dutch:\" JJJJ/MM/DD UU:MM:SS";
1758 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1759 sCode
= "\"Dutch: \"YYYY/MM/DD HH:MM:SS";
1760 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1761 eLang
= LANGUAGE_GERMAN
;
1762 sExpected
= "German: 1900/01/02 03:23:53";
1763 sCode
= "\"German: \"JJJJ/MM/TT HH:MM:SS";
1764 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1765 sCode
= "\"German: \"YYYY/MM/DD HH:MM:SS";
1766 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1767 eLang
= LANGUAGE_FRENCH
;
1768 sExpected
= "French: 1900/01/02 03:23:53";
1769 sCode
= "\"French: \"AAAA/MM/JJ HH:MM:SS";
1770 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1771 sCode
= "\"French: \"YYYY/MM/DD HH:MM:SS";
1772 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1773 eLang
= LANGUAGE_ITALIAN
;
1774 sExpected
= "Italian: 1900/01/02 03:23:53";
1775 sCode
= "\"Italian: \"AAAA/MM/GG HH:MM:SS";
1776 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1777 sCode
= "\"Italian: \"YYYY/MM/DD HH:MM:SS";
1778 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1779 eLang
= LANGUAGE_PORTUGUESE
;
1780 sExpected
= "Portuguese: 1900/01/02 03:23:53";
1781 sCode
= "\"Portuguese: \"AAAA/MM/DD HH:MM:SS";
1782 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1783 sCode
= "\"Portuguese: \"YYYY/MM/DD HH:MM:SS";
1784 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1785 eLang
= LANGUAGE_SPANISH_MODERN
;
1786 sExpected
= "Spanish: 1900/01/02 03:23:53";
1787 sCode
= "\"Spanish: \"AAAA/MM/DD HH:MM:SS";
1788 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1789 sCode
= "\"Spanish: \"YYYY/MM/DD HH:MM:SS";
1790 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1791 eLang
= LANGUAGE_DANISH
;
1792 sExpected
= "Danish: 1900/01/02 03:23:53";
1793 sCode
= "\"Danish: \"YYYY/MM/DD TT:MM:SS";
1794 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1795 sCode
= "\"Danish: \"YYYY/MM/DD HH:MM:SS";
1796 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1797 eLang
= LANGUAGE_FINNISH
;
1798 sExpected
= "Finnish: 1900/01/02 03:23:53";
1799 sCode
= "\"Finnish: \"VVVV/KK/PP TT:MM:SS";
1800 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1801 sCode
= "\"Finnish: \"YYYY/MM/DD HH:MM:SS";
1802 checkPreviewString(aFormatter
, sCode
, M_PI
, eLang
, sExpected
);
1804 { // tdf#117819 wrong separator positions when displaying integers with
1805 // more decimals than rtl::math::doubleToUString delivers.
1806 sCode
= "#,##0.00000000000000000000";
1807 sExpected
= "117,669,030,460,994.00000000000000000000";
1808 checkPreviewString(aFormatter
, sCode
, 117669030460994.0, LANGUAGE_ENGLISH_US
, sExpected
);
1810 { // tdf#117575 treat thousand separator with '?' in integer part
1811 sCode
= "\"Value= \"?,??0.00";
1812 sExpected
= "Value= 3.14";
1813 checkPreviewString(aFormatter
, sCode
, M_PI
, LANGUAGE_ENGLISH_US
, sExpected
);
1814 sExpected
= "Value= 12.00";
1815 checkPreviewString(aFormatter
, sCode
, 12, LANGUAGE_ENGLISH_US
, sExpected
);
1816 sExpected
= "Value= 123.00";
1817 checkPreviewString(aFormatter
, sCode
, 123, LANGUAGE_ENGLISH_US
, sExpected
);
1818 sExpected
= "Value= 1,234.00";
1819 checkPreviewString(aFormatter
, sCode
, 1234, LANGUAGE_ENGLISH_US
, sExpected
);
1820 sExpected
= "Value= 12,345.00";
1821 checkPreviewString(aFormatter
, sCode
, 12345, LANGUAGE_ENGLISH_US
, sExpected
);
1825 void Test::testNfEnglishKeywordsIntegrity()
1827 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_ENGLISH_US
);
1828 const NfKeywordTable
& rEnglishKeywords
= aFormatter
.GetEnglishKeywords();
1829 const NfKeywordTable
& sKeywords
= aFormatter
.GetKeywords(0);
1830 CPPUNIT_ASSERT_EQUAL( size_t(NF_KEYWORD_ENTRIES_COUNT
), rEnglishKeywords
.size() );
1831 for (size_t i
= 0; i
< size_t(NF_KEYWORD_ENTRIES_COUNT
); ++i
)
1833 CPPUNIT_ASSERT_EQUAL( sKeywords
[i
], rEnglishKeywords
[i
] );
1835 // Check the order of sEnglishKeyword
1836 CPPUNIT_ASSERT_EQUAL( OUString("E"), rEnglishKeywords
[NF_KEY_E
] );
1837 CPPUNIT_ASSERT_EQUAL( OUString("AM/PM"), rEnglishKeywords
[NF_KEY_AMPM
] );
1838 CPPUNIT_ASSERT_EQUAL( OUString("A/P"), rEnglishKeywords
[NF_KEY_AP
] );
1839 CPPUNIT_ASSERT_EQUAL( OUString("M"), rEnglishKeywords
[NF_KEY_MI
] );
1840 CPPUNIT_ASSERT_EQUAL( OUString("MM"), rEnglishKeywords
[NF_KEY_MMI
] );
1841 CPPUNIT_ASSERT_EQUAL( OUString("M"), rEnglishKeywords
[NF_KEY_M
] );
1842 CPPUNIT_ASSERT_EQUAL( OUString("MM"), rEnglishKeywords
[NF_KEY_MM
] );
1843 CPPUNIT_ASSERT_EQUAL( OUString("MMM"), rEnglishKeywords
[NF_KEY_MMM
] );
1844 CPPUNIT_ASSERT_EQUAL( OUString("MMMM"), rEnglishKeywords
[NF_KEY_MMMM
] );
1845 CPPUNIT_ASSERT_EQUAL( OUString("H"), rEnglishKeywords
[NF_KEY_H
] );
1846 CPPUNIT_ASSERT_EQUAL( OUString("HH"), rEnglishKeywords
[NF_KEY_HH
] );
1847 CPPUNIT_ASSERT_EQUAL( OUString("S"), rEnglishKeywords
[NF_KEY_S
] );
1848 CPPUNIT_ASSERT_EQUAL( OUString("SS"), rEnglishKeywords
[NF_KEY_SS
] );
1849 CPPUNIT_ASSERT_EQUAL( OUString("Q"), rEnglishKeywords
[NF_KEY_Q
] );
1850 CPPUNIT_ASSERT_EQUAL( OUString("QQ"), rEnglishKeywords
[NF_KEY_QQ
] );
1851 CPPUNIT_ASSERT_EQUAL( OUString("D"), rEnglishKeywords
[NF_KEY_D
] );
1852 CPPUNIT_ASSERT_EQUAL( OUString("DD"), rEnglishKeywords
[NF_KEY_DD
] );
1853 CPPUNIT_ASSERT_EQUAL( OUString("DDD"), rEnglishKeywords
[NF_KEY_DDD
] );
1854 CPPUNIT_ASSERT_EQUAL( OUString("DDDD"), rEnglishKeywords
[NF_KEY_DDDD
] );
1855 CPPUNIT_ASSERT_EQUAL( OUString("YY"), rEnglishKeywords
[NF_KEY_YY
] );
1856 CPPUNIT_ASSERT_EQUAL( OUString("YYYY"), rEnglishKeywords
[NF_KEY_YYYY
] );
1857 CPPUNIT_ASSERT_EQUAL( OUString("NN"), rEnglishKeywords
[NF_KEY_NN
] );
1858 CPPUNIT_ASSERT_EQUAL( OUString("NNNN"), rEnglishKeywords
[NF_KEY_NNNN
] );
1859 CPPUNIT_ASSERT_EQUAL( OUString("CCC"), rEnglishKeywords
[NF_KEY_CCC
] );
1860 CPPUNIT_ASSERT_EQUAL( OUString("GENERAL"), rEnglishKeywords
[NF_KEY_GENERAL
] );
1861 CPPUNIT_ASSERT_EQUAL( OUString("NNN"), rEnglishKeywords
[NF_KEY_NNN
] );
1862 CPPUNIT_ASSERT_EQUAL( OUString("WW"), rEnglishKeywords
[NF_KEY_WW
] );
1863 CPPUNIT_ASSERT_EQUAL( OUString("MMMMM"), rEnglishKeywords
[NF_KEY_MMMMM
] );
1864 CPPUNIT_ASSERT_EQUAL( OUString("TRUE"), rEnglishKeywords
[NF_KEY_TRUE
] );
1865 CPPUNIT_ASSERT_EQUAL( OUString("FALSE"), rEnglishKeywords
[NF_KEY_FALSE
] );
1866 CPPUNIT_ASSERT_EQUAL( OUString("BOOLEAN"), rEnglishKeywords
[NF_KEY_BOOLEAN
] );
1867 CPPUNIT_ASSERT_EQUAL( OUString("COLOR"), rEnglishKeywords
[NF_KEY_COLOR
] );
1868 CPPUNIT_ASSERT_EQUAL( OUString("BLACK"), rEnglishKeywords
[NF_KEY_BLACK
] );
1869 CPPUNIT_ASSERT_EQUAL( OUString("BLUE"), rEnglishKeywords
[NF_KEY_BLUE
] );
1870 CPPUNIT_ASSERT_EQUAL( OUString("GREEN"), rEnglishKeywords
[NF_KEY_GREEN
] );
1871 CPPUNIT_ASSERT_EQUAL( OUString("CYAN"), rEnglishKeywords
[NF_KEY_CYAN
] );
1872 CPPUNIT_ASSERT_EQUAL( OUString("RED"), rEnglishKeywords
[NF_KEY_RED
] );
1873 CPPUNIT_ASSERT_EQUAL( OUString("MAGENTA"), rEnglishKeywords
[NF_KEY_MAGENTA
] );
1874 CPPUNIT_ASSERT_EQUAL( OUString("BROWN"), rEnglishKeywords
[NF_KEY_BROWN
] );
1875 CPPUNIT_ASSERT_EQUAL( OUString("GREY"), rEnglishKeywords
[NF_KEY_GREY
] );
1876 CPPUNIT_ASSERT_EQUAL( OUString("YELLOW"), rEnglishKeywords
[NF_KEY_YELLOW
] );
1877 CPPUNIT_ASSERT_EQUAL( OUString("WHITE"), rEnglishKeywords
[NF_KEY_WHITE
] );
1878 CPPUNIT_ASSERT_EQUAL( OUString("AAA"), rEnglishKeywords
[NF_KEY_AAA
]);
1879 CPPUNIT_ASSERT_EQUAL( OUString("AAAA"), rEnglishKeywords
[NF_KEY_AAAA
] );
1880 CPPUNIT_ASSERT_EQUAL( OUString("E"), rEnglishKeywords
[NF_KEY_EC
] );
1881 CPPUNIT_ASSERT_EQUAL( OUString("EE"), rEnglishKeywords
[NF_KEY_EEC
] );
1882 CPPUNIT_ASSERT_EQUAL( OUString("G"), rEnglishKeywords
[NF_KEY_G
] );
1883 CPPUNIT_ASSERT_EQUAL( OUString("GG"), rEnglishKeywords
[NF_KEY_GG
] );
1884 CPPUNIT_ASSERT_EQUAL( OUString("GGG"), rEnglishKeywords
[NF_KEY_GGG
] );
1885 CPPUNIT_ASSERT_EQUAL( OUString("R"), rEnglishKeywords
[NF_KEY_R
] );
1886 CPPUNIT_ASSERT_EQUAL( OUString("RR"), rEnglishKeywords
[NF_KEY_RR
] );
1887 CPPUNIT_ASSERT_EQUAL( OUString("t"), rEnglishKeywords
[NF_KEY_THAI_T
] );
1890 void Test::testStandardColorIntegrity()
1892 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_ENGLISH_US
);
1893 const ::std::vector
<Color
> & rStandardColors
= aFormatter
.GetStandardColors();
1894 const size_t nMaxDefaultColors
= aFormatter
.GetMaxDefaultColors();
1895 CPPUNIT_ASSERT_EQUAL( size_t(NF_KEY_LASTCOLOR
) - size_t(NF_KEY_FIRSTCOLOR
) + 1, nMaxDefaultColors
);
1896 CPPUNIT_ASSERT_EQUAL( nMaxDefaultColors
, rStandardColors
.size() );
1897 // Colors must follow same order as in sEnglishKeyword
1898 CPPUNIT_ASSERT_EQUAL( COL_BLACK
, rStandardColors
[0] );
1899 CPPUNIT_ASSERT_EQUAL( COL_LIGHTBLUE
, rStandardColors
[1] );
1900 CPPUNIT_ASSERT_EQUAL( COL_LIGHTGREEN
, rStandardColors
[2] );
1901 CPPUNIT_ASSERT_EQUAL( COL_LIGHTCYAN
, rStandardColors
[3] );
1902 CPPUNIT_ASSERT_EQUAL( COL_LIGHTRED
, rStandardColors
[4] );
1903 CPPUNIT_ASSERT_EQUAL( COL_LIGHTMAGENTA
, rStandardColors
[5] );
1904 CPPUNIT_ASSERT_EQUAL( COL_BROWN
, rStandardColors
[6] );
1905 CPPUNIT_ASSERT_EQUAL( COL_GRAY
, rStandardColors
[7] );
1906 CPPUNIT_ASSERT_EQUAL( COL_YELLOW
, rStandardColors
[8] );
1907 CPPUNIT_ASSERT_EQUAL( COL_WHITE
, rStandardColors
[9] );
1910 void Test::testColorNamesConversion()
1912 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_GERMAN
);
1913 const NfKeywordTable
& rEnglishKeywords
= aFormatter
.GetEnglishKeywords();
1914 const NfKeywordTable
& rKeywords
= aFormatter
.GetKeywords(0);
1916 // Holding a reference to the NfKeywordTable doesn't help if we switch
1917 // locales internally, so copy the relevant parts in advance.
1918 std::vector
<OUString
> aGermanKeywords(NF_KEYWORD_ENTRIES_COUNT
);
1919 for (size_t i
= NF_KEY_COLOR
; i
<= NF_KEY_WHITE
; ++i
)
1920 aGermanKeywords
[i
] = rKeywords
[i
];
1922 // Check that we actually have German and English keywords.
1923 CPPUNIT_ASSERT_EQUAL( OUString("FARBE"), aGermanKeywords
[NF_KEY_COLOR
]);
1924 CPPUNIT_ASSERT_EQUAL( OUString("COLOR"), rEnglishKeywords
[NF_KEY_COLOR
]);
1926 // Test each color conversion.
1927 // [FARBE1] -> [COLOR1] can't be tested because we have no color table link
1928 // set, so the scanner returns nCheckPos error.
1929 sal_Int32 nCheckPos
;
1930 SvNumFormatType nType
;
1932 OUString aFormatCode
;
1934 for (size_t i
= NF_KEY_BLACK
; i
<= NF_KEY_WHITE
; ++i
)
1936 aFormatCode
= "[" + aGermanKeywords
[i
] + "]0";
1937 aFormatter
.PutandConvertEntry( aFormatCode
, nCheckPos
, nType
, nKey
, LANGUAGE_GERMAN
, LANGUAGE_ENGLISH_US
, false);
1938 CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos
);
1939 CPPUNIT_ASSERT_EQUAL_MESSAGE("Type should be NUMBER.", SvNumFormatType::NUMBER
, nType
);
1940 CPPUNIT_ASSERT_EQUAL( OUString("[" + rEnglishKeywords
[i
] + "]0"), aFormatCode
);
1944 void Test::testExcelExportFormats()
1946 // Create a formatter with "system" locale other than the specific formats'
1947 // locale, and different from the en-US export locale.
1948 SvNumberFormatter
aFormatter( m_xContext
, LANGUAGE_ENGLISH_UK
);
1951 sal_Int32 nCheckPos
;
1952 SvNumFormatType eType
;
1953 sal_uInt32 nKey1
, nKey2
;
1956 aFormatter
.PutandConvertEntry( aCode
, nCheckPos
, eType
, nKey1
,
1957 LANGUAGE_ENGLISH_US
, LANGUAGE_ENGLISH_SAFRICA
, false);
1958 CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos
);
1959 CPPUNIT_ASSERT_MESSAGE("Key should be greater than system locale's keys.",
1960 nKey1
> SV_COUNTRY_LANGUAGE_OFFSET
);
1962 aCode
= "[$R-1C09] #,##0.0;[$R-1C09]-#,##0.0";
1963 aFormatter
.PutandConvertEntry( aCode
, nCheckPos
, eType
, nKey2
,
1964 LANGUAGE_ENGLISH_US
, LANGUAGE_ENGLISH_SAFRICA
, false);
1965 CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos
);
1966 CPPUNIT_ASSERT_MESSAGE("Key should be greater than system locale's keys.",
1967 nKey2
> SV_COUNTRY_LANGUAGE_OFFSET
);
1969 // The export formatter.
1970 SvNumberFormatter
aTempFormatter( m_xContext
, LANGUAGE_ENGLISH_US
);
1971 NfKeywordTable aKeywords
;
1972 aTempFormatter
.FillKeywordTableForExcel( aKeywords
);
1974 aCode
= aFormatter
.GetFormatStringForExcel( nKey1
, aKeywords
, aTempFormatter
);
1975 // Test that LCID is prepended.
1976 CPPUNIT_ASSERT_EQUAL( OUString("[$-1C09]00.00"), aCode
);
1978 aCode
= aFormatter
.GetFormatStringForExcel( nKey2
, aKeywords
, aTempFormatter
);
1979 // Test that LCID is not prepended. Note that literal characters are escaped.
1980 CPPUNIT_ASSERT_EQUAL( OUString("[$R-1C09]\\ #,##0.0;[$R-1C09]\\-#,##0.0"), aCode
);
1983 CPPUNIT_TEST_FIXTURE(Test
, testLanguageNone
)
1985 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_ENGLISH_US
);
1986 NfKeywordTable keywords
;
1987 aFormatter
.FillKeywordTableForExcel(keywords
);
1988 OUString
code("TT.MM.JJJJ");
1989 sal_uInt32 nKey
= aFormatter
.GetEntryKey(code
, LANGUAGE_GERMAN
);
1990 CPPUNIT_ASSERT(nKey
!= NUMBERFORMAT_ENTRY_NOT_FOUND
);
1991 SvNumberformat
const*const pFormat
= aFormatter
.GetEntry(nKey
);
1992 LocaleDataWrapper
ldw(m_xContext
, LanguageTag(pFormat
->GetLanguage()));
1993 CPPUNIT_ASSERT_EQUAL(OUString("dd.mm.yyyy"), pFormat
->GetMappedFormatstring(keywords
, ldw
));
1996 CPPUNIT_TEST_FIXTURE(Test
, testTdf160306
)
1998 // Check some cases, where the output of ROUND and of number formatter differed
1999 SvNumberFormatter
aFormatter(m_xContext
, LANGUAGE_ENGLISH_US
);
2000 sal_uInt32 format
= aFormatter
.GetEntryKey(u
"0.00", LANGUAGE_ENGLISH_US
);
2001 CPPUNIT_ASSERT(format
!= NUMBERFORMAT_ENTRY_NOT_FOUND
);
2004 aFormatter
.GetOutputString(2697.0649999999996, format
, output
, &color
);
2005 // Without the fix in place, this would fail with
2006 // - Expected: 2697.07
2007 // - Actual : 2697.06
2008 CPPUNIT_ASSERT_EQUAL(u
"2697.07"_ustr
, output
);
2009 aFormatter
.GetOutputString(57.374999999999993, format
, output
, &color
);
2010 // Without the fix in place, this would fail with
2011 // - Expected: 57.38
2013 CPPUNIT_ASSERT_EQUAL(u
"57.38"_ustr
, output
);
2016 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
2020 CPPUNIT_PLUGIN_IMPLEMENT();
2022 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */