[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - i18npool/qa i18npool/source include/editeng offapi/com sw/qa sw/source writerfilter/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 6 11:47:16 UTC 2020
i18npool/qa/cppunit/test_defaultnumberingprovider.cxx | 29 ++++++++++
i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx | 5 +
include/editeng/svxenum.hxx | 1
offapi/com/sun/star/style/NumberingType.idl | 7 ++
sw/qa/extras/odfexport/data/arabic-zero5-numbering.odt |binary
sw/qa/extras/odfexport/odfexport.cxx | 13 ++++
sw/qa/extras/ooxmlexport/data/arabic-zero5-numbering.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 13 ++++
sw/source/filter/ww8/docxattributeoutput.cxx | 4 +
writerfilter/source/dmapper/ConversionHelper.cxx | 4 +
10 files changed, 76 insertions(+)
New commits:
commit 3982bb872ec39d47b41cd530784d6d3639e8d196
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 23 13:37:25 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Apr 6 13:46:45 2020 +0200
sw: add pad-to-5 numbering
This is the last padded numbering type that is supported by Word but was
not supported by Writer.
(cherry picked from commit 8540c7b18bae9c9b46e6feb7658198a7fc62e811)
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
Change-Id: Ica1a0843897c61a4b569105fd21e5bfe7b5012cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91640
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
index e5991ee6461d..b3d3b42963a8 100644
--- a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
+++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
@@ -110,6 +110,35 @@ CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero4)
CPPUNIT_ASSERT_EQUAL(OUString("1000"), aActual);
}
+CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero5)
+{
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = comphelper::getComponentContext(getMultiServiceFactory());
+
+ // 1000 -> "01000"
+ 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_ZERO5)),
+ comphelper::makePropertyValue("Value", static_cast<sal_Int32>(1000)),
+ };
+ 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_ZERO5 was missing.
+ CPPUNIT_ASSERT_EQUAL(OUString("01000"), aActual);
+
+ // 10000 -> "10000"
+ aProperties = {
+ comphelper::makePropertyValue("NumberingType",
+ static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO5)),
+ comphelper::makePropertyValue("Value", static_cast<sal_Int32>(10000)),
+ };
+ aActual = xFormatter->makeNumberingString(aProperties, aLocale);
+ CPPUNIT_ASSERT_EQUAL(OUString("10000"), 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 5a13c6c8f054..3895dec8ca1f 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -951,6 +951,10 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
result += lcl_formatArabicZero(number, 4);
break;
+ case ARABIC_ZERO5:
+ result += lcl_formatArabicZero(number, 5);
+ break;
+
default:
OSL_ASSERT(false);
throw IllegalArgumentException();
@@ -1051,6 +1055,7 @@ static const Supported_NumberingType aSupportedTypes[] =
{style::NumberingType::ARABIC_ZERO, "01, 02, 03, ...", LANG_ALL},
{style::NumberingType::ARABIC_ZERO3, "001, 002, 003, ...", LANG_ALL},
{style::NumberingType::ARABIC_ZERO4, "0001, 0002, 0003, ...", LANG_ALL},
+ {style::NumberingType::ARABIC_ZERO5, "00001, 00002, 00003, ...", LANG_ALL},
};
static const sal_Int32 nSupported_NumberingTypes = SAL_N_ELEMENTS(aSupportedTypes);
diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx
index b020ebd26e50..fb614738366e 100644
--- a/include/editeng/svxenum.hxx
+++ b/include/editeng/svxenum.hxx
@@ -209,6 +209,7 @@ enum SvxNumType : sal_Int16
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,
+ SVX_NUM_ARABIC_ZERO5 = css::style::NumberingType::ARABIC_ZERO5,
};
#endif
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index e19bd25aecd3..be00efc3cfd0 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -513,6 +513,13 @@ published constants NumberingType
@since LibreOffice 7.0
*/
const short ARABIC_ZERO4 = 66;
+
+ /** Numbering is in Arabic numbers, padded with zero to have a length of at least five, as
+ "00001, 00002, ..., 10000, 10001, ...".
+
+ @since LibreOffice 7.0
+ */
+ const short ARABIC_ZERO5 = 67;
};
diff --git a/sw/qa/extras/odfexport/data/arabic-zero5-numbering.odt b/sw/qa/extras/odfexport/data/arabic-zero5-numbering.odt
new file mode 100644
index 000000000000..3526ee8d7086
Binary files /dev/null and b/sw/qa/extras/odfexport/data/arabic-zero5-numbering.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index da4005697099..280f12e1c100 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2267,6 +2267,19 @@ DECLARE_ODFEXPORT_TEST(testArabicZero4Numbering, "arabic-zero4-numbering.odt")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO4),
aMap["NumberingType"].get<sal_uInt16>());
}
+
+DECLARE_ODFEXPORT_TEST(testArabicZero5Numbering, "arabic-zero5-numbering.odt")
+{
+ auto xNumberingRules
+ = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), "NumberingRules");
+ comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 67
+ // - Actual : 4
+ // i.e. numbering type was ARABIC, not ARABIC_ZERO5.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO5),
+ aMap["NumberingType"].get<sal_uInt16>());
+}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlexport/data/arabic-zero5-numbering.docx b/sw/qa/extras/ooxmlexport/data/arabic-zero5-numbering.docx
new file mode 100644
index 000000000000..f7df2c5267fe
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/arabic-zero5-numbering.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index e43d5f5cb8c2..d65e0038ca62 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -639,6 +639,19 @@ DECLARE_ODFEXPORT_TEST(testArabicZero4Numbering, "arabic-zero4-numbering.docx")
aMap["NumberingType"].get<sal_uInt16>());
}
+DECLARE_ODFEXPORT_TEST(testArabicZero5Numbering, "arabic-zero5-numbering.docx")
+{
+ auto xNumberingRules
+ = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), "NumberingRules");
+ comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 67
+ // - Actual : 4
+ // i.e. numbering type was ARABIC, not ARABIC_ZERO5.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO5),
+ aMap["NumberingType"].get<sal_uInt16>());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 126f366943ff..91aad561d3db 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6500,6 +6500,10 @@ static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSe
aType = "custom";
rFormat = "0001, 0002, 0003, ...";
break;
+ case style::NumberingType::ARABIC_ZERO5:
+ aType = "custom";
+ rFormat = "00001, 00002, 00003, ...";
+ break;
/*
Fallback the rest to decimal.
case style::NumberingType::NATIVE_NUMBERING:
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index ad8c5190d882..ad8d6d44f20c 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -626,6 +626,10 @@ sal_Int16 ConvertCustomNumberFormat(const OUString& rFormat)
{
nRet = style::NumberingType::ARABIC_ZERO4;
}
+ else if (rFormat == "00001, 00002, 00003, ...")
+ {
+ nRet = style::NumberingType::ARABIC_ZERO5;
+ }
return nRet;
}
More information about the Libreoffice-commits
mailing list