diff options
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/qa/cppunit/test_defaultnumberingprovider.cxx | 26 | ||||
-rw-r--r-- | i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx | 12 |
2 files changed, 34 insertions, 4 deletions
diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx index daa464c9ac74..fee8df329520 100644 --- a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx +++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx @@ -48,6 +48,32 @@ CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero) CPPUNIT_ASSERT_EQUAL(OUString("10"), aActual); } +CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero3) +{ + // 10 -> "010" + uno::Reference<text::XNumberingFormatter> xFormatter( + text::DefaultNumberingProvider::create(mxComponentContext), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProperties = { + comphelper::makePropertyValue("NumberingType", + static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3)), + comphelper::makePropertyValue("Value", static_cast<sal_Int32>(10)), + }; + lang::Locale aLocale; + OUString aActual = xFormatter->makeNumberingString(aProperties, aLocale); + // Without the accompanying fix in place, this test would have failed with a + // lang.IllegalArgumentException, support for ARABIC_ZERO3 was missing. + CPPUNIT_ASSERT_EQUAL(OUString("010"), aActual); + + // 100 -> "100" + aProperties = { + comphelper::makePropertyValue("NumberingType", + static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3)), + comphelper::makePropertyValue("Value", static_cast<sal_Int32>(100)), + }; + aActual = xFormatter->makeNumberingString(aProperties, aLocale); + CPPUNIT_ASSERT_EQUAL(OUString("100"), aActual); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx index 890855538881..86b64a3d23ad 100644 --- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx +++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx @@ -553,11 +553,11 @@ bool should_ignore( const OUString& s ) } /** - * Turn nNumber into a string and pad the result to 2 using zero characters. + * Turn nNumber into a string and pad the result to nLimit by inserting zero characters at the + * start. */ -static OUString lcl_formatArabicZero(sal_Int32 nNumber) +static OUString lcl_formatArabicZero(sal_Int32 nNumber, sal_Int32 nLimit) { - sal_Int32 nLimit = 2; OUString aRet = OUString::number(nNumber); sal_Int32 nDiff = nLimit - aRet.getLength(); @@ -938,7 +938,11 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal break; case ARABIC_ZERO: - result += lcl_formatArabicZero(number); + result += lcl_formatArabicZero(number, 2); + break; + + case ARABIC_ZERO3: + result += lcl_formatArabicZero(number, 3); break; default: |