sw pad-to-3 numbering: add doc model, UNO API and layout

This is similar to the existing padded numbering, but that one padded to
2.  Another difference is pad-to-2 has more file format support:
pad-to-3 is not supported in DOC and RTF.

Change-Id: Ie2ac2691c58a89e181d24d7002cf873ebab380c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90656
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
index daa464c..fee8df3 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 8908555..86b64a3 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:
diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx
index f425e97..eced6c8 100644
--- a/include/editeng/svxenum.hxx
+++ b/include/editeng/svxenum.hxx
@@ -206,7 +206,8 @@ enum SvxNumType : sal_Int16
    SVX_NUM_TEXT_CARDINAL         = css::style::NumberingType::TEXT_CARDINAL,
    SVX_NUM_TEXT_ORDINAL          = css::style::NumberingType::TEXT_ORDINAL,
    SVX_NUM_SYMBOL_CHICAGO        = css::style::NumberingType::SYMBOL_CHICAGO,
    SVX_NUM_ARABIC_ZERO           = css::style::NumberingType::ARABIC_ZERO
    SVX_NUM_ARABIC_ZERO           = css::style::NumberingType::ARABIC_ZERO,
    SVX_NUM_ARABIC_ZERO3          = css::style::NumberingType::ARABIC_ZERO3,
};

#endif
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index 21ad4c7..ee2d27b 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -499,6 +499,13 @@ published constants NumberingType
        @since LibreOffice 7.0
     */
    const short ARABIC_ZERO = 64;

    /** Numbering is in Arabic numbers, padded with zero to have a length of at least three, as
        "001, 002, ..., 100, 101, ...".

        @since LibreOffice 7.0
     */
    const short ARABIC_ZERO3 = 65;
};