diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-03-03 09:27:01 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-03-03 10:19:26 +0100 |
commit | 642b7706101a991efc7e312f59dece640d8bfb60 (patch) | |
tree | c31382736ead8bd4dda39170e4a5775477392a51 /i18npool/qa | |
parent | b23183af90996395c19eea5c71c7b2f5640b838b (diff) |
sw padded numbering: add layout
lcl_formatArabicZero() looks a bit over-complicated with its hardcoded
limit of 2. Word supports limits of 3, 4 and 5 as well, so prepare for
handling them in a generic way.
Change-Id: If6e5634b11616f0ac05e1387016e22f4b171bbfb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89864
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'i18npool/qa')
-rw-r--r-- | i18npool/qa/cppunit/test_defaultnumberingprovider.cxx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx new file mode 100644 index 000000000000..daa464c9ac74 --- /dev/null +++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/bootstrapfixture.hxx> + +#include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/text/DefaultNumberingProvider.hpp> +#include <com/sun/star/text/XNumberingFormatter.hpp> + +#include <comphelper/propertyvalue.hxx> + +using namespace ::com::sun::star; + +/// i18npool defaultnumberingprovider tests. +class I18npoolDefaultnumberingproviderTest : public test::BootstrapFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero) +{ + // 1 -> "01" + 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_ZERO)), + comphelper::makePropertyValue("Value", static_cast<sal_Int32>(1)), + }; + 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_ZERO was missing. + CPPUNIT_ASSERT_EQUAL(OUString("01"), aActual); + + // 10 -> "10" + aProperties = { + comphelper::makePropertyValue("NumberingType", + static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO)), + comphelper::makePropertyValue("Value", static_cast<sal_Int32>(10)), + }; + aActual = xFormatter->makeNumberingString(aProperties, aLocale); + CPPUNIT_ASSERT_EQUAL(OUString("10"), aActual); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |