summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-03-20 13:38:45 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-05-19 11:30:10 +0200
commite654b1e27eb1690104d360dfc1a7d7ef84dd220f (patch)
treeb7c6e6fb7de25edfe41614457945a2dfd1a9f75a /i18npool
parentc62f573b3ecb89cc842ea88b61e99863a33d4212 (diff)
sw pad-to-4 numbering: add doc model, UNO API and layout
This is the actual numbering the customer needed, pad-to-2 and pad-to-3 was added just for compleness (since Word has it and it's related). (cherry picked from commit fcef4857e042ff3c9dd8a6c60cf1a58e07f3224c) Change-Id: I7fdf67488955ab3ee0db169f11fffd21d9cc1e3b
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/qa/cppunit/test_defaultnumberingprovider.cxx29
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx4
2 files changed, 33 insertions, 0 deletions
diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
index 4418a283de2b..e5991ee6461d 100644
--- a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
+++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
@@ -81,6 +81,35 @@ CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero3)
CPPUNIT_ASSERT_EQUAL(OUString("100"), aActual);
}
+CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero4)
+{
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = comphelper::getComponentContext(getMultiServiceFactory());
+
+ // 100 -> "0100"
+ uno::Reference<text::XNumberingFormatter> xFormatter(
+ text::DefaultNumberingProvider::create(xComponentContext), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProperties = {
+ comphelper::makePropertyValue("NumberingType",
+ static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO4)),
+ comphelper::makePropertyValue("Value", static_cast<sal_Int32>(100)),
+ };
+ 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_ZERO4 was missing.
+ CPPUNIT_ASSERT_EQUAL(OUString("0100"), aActual);
+
+ // 1000 -> "1000"
+ aProperties = {
+ comphelper::makePropertyValue("NumberingType",
+ static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO4)),
+ comphelper::makePropertyValue("Value", static_cast<sal_Int32>(1000)),
+ };
+ aActual = xFormatter->makeNumberingString(aProperties, aLocale);
+ CPPUNIT_ASSERT_EQUAL(OUString("1000"), 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 39b7954cee7a..5f79508a6766 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -945,6 +945,10 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
result += lcl_formatArabicZero(number, 3);
break;
+ case ARABIC_ZERO4:
+ result += lcl_formatArabicZero(number, 4);
+ break;
+
default:
OSL_ASSERT(false);
throw IllegalArgumentException();