summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-03-17 17:01:05 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-04-03 09:20:33 +0200
commita2aaf28bdd01653ea3e35ee6f965257921785b92 (patch)
treeaf485684487ee2de7393e82918d9add81dd5152b
parent140f286303118d0436efd51806e63415454424cc (diff)
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. (cherry picked from commit f4dd9ecdc21696b360dedf7fefa371c8858c1830) Change-Id: Ie2ac2691c58a89e181d24d7002cf873ebab380c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91591 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--i18npool/qa/cppunit/test_defaultnumberingprovider.cxx29
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx12
-rw-r--r--include/editeng/svxenum.hxx3
-rw-r--r--offapi/com/sun/star/style/NumberingType.idl7
4 files changed, 46 insertions, 5 deletions
diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
index 2a1cb55502e2..4418a283de2b 100644
--- a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
+++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
@@ -52,6 +52,35 @@ CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero)
CPPUNIT_ASSERT_EQUAL(OUString("10"), aActual);
}
+CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero3)
+{
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = comphelper::getComponentContext(getMultiServiceFactory());
+
+ // 10 -> "010"
+ 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_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 3b5cb977d33a..21a0eb8e7d7e 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -556,11 +556,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();
@@ -940,7 +940,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 66159a818e66..2ecf03734e10 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;
};