[Libreoffice-commits] core.git: i18npool/qa i18npool/source include/editeng offapi/com

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 17 16:59:51 UTC 2020


 i18npool/qa/cppunit/test_defaultnumberingprovider.cxx                 |   26 ++++++++++
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |   12 +++-
 include/editeng/svxenum.hxx                                           |    3 -
 offapi/com/sun/star/style/NumberingType.idl                           |    7 ++
 4 files changed, 43 insertions(+), 5 deletions(-)

New commits:
commit f4dd9ecdc21696b360dedf7fefa371c8858c1830
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 17 17:01:05 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Mar 17 17:59:14 2020 +0100

    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 at collabora.com>
    Tested-by: Jenkins

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:
diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx
index f425e97cde0c..eced6c884afa 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 21ad4c73c3a4..ee2d27bd47b0 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;
 };
 
 


More information about the Libreoffice-commits mailing list