diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-03-20 13:38:45 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-04-03 19:22:18 +0200 |
commit | 409d7bba96b194080791e12ed15290b5c3adedd4 (patch) | |
tree | d6845d377d723aa41ab32992d9c957588b1217d7 | |
parent | 6ce8e5ac1425f4a5dd8e1d46d97d060a5bb4784f (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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91637
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | i18npool/qa/cppunit/test_defaultnumberingprovider.cxx | 29 | ||||
-rw-r--r-- | i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx | 4 | ||||
-rw-r--r-- | include/editeng/svxenum.hxx | 1 | ||||
-rw-r--r-- | offapi/com/sun/star/style/NumberingType.idl | 7 |
4 files changed, 41 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 85b0b55bcc00..0cb55a04b701 100644 --- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx +++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx @@ -947,6 +947,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(); diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx index eced6c884afa..b020ebd26e50 100644 --- a/include/editeng/svxenum.hxx +++ b/include/editeng/svxenum.hxx @@ -208,6 +208,7 @@ enum SvxNumType : sal_Int16 SVX_NUM_SYMBOL_CHICAGO = css::style::NumberingType::SYMBOL_CHICAGO, SVX_NUM_ARABIC_ZERO = css::style::NumberingType::ARABIC_ZERO, SVX_NUM_ARABIC_ZERO3 = css::style::NumberingType::ARABIC_ZERO3, + SVX_NUM_ARABIC_ZERO4 = css::style::NumberingType::ARABIC_ZERO4, }; #endif diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl index 2ecf03734e10..e19bd25aecd3 100644 --- a/offapi/com/sun/star/style/NumberingType.idl +++ b/offapi/com/sun/star/style/NumberingType.idl @@ -506,6 +506,13 @@ published constants NumberingType @since LibreOffice 7.0 */ const short ARABIC_ZERO3 = 65; + + /** Numbering is in Arabic numbers, padded with zero to have a length of at least four, as + "0001, 0002, ..., 1000, 1001, ...". + + @since LibreOffice 7.0 + */ + const short ARABIC_ZERO4 = 66; }; |