[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 4 commits - i18npool/CppunitTest_i18npool_defaultnumberingprovider.mk i18npool/Module_i18npool.mk i18npool/qa i18npool/source include/editeng offapi/com sw/qa sw/source writerfilter/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 14 09:49:42 UTC 2020
i18npool/CppunitTest_i18npool_defaultnumberingprovider.mk | 44 +++++++
i18npool/Module_i18npool.mk | 1
i18npool/qa/cppunit/test_defaultnumberingprovider.cxx | 57 ++++++++++
i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx | 29 +++++
include/editeng/svxenum.hxx | 3
offapi/com/sun/star/style/NumberingType.idl | 7 +
sw/qa/extras/odfexport/data/arabic-zero-numbering.odt |binary
sw/qa/extras/odfexport/odfexport.cxx | 13 ++
sw/qa/extras/ooxmlexport/data/arabic-zero-numbering.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 13 ++
sw/source/filter/ww8/docxattributeoutput.cxx | 1
writerfilter/source/dmapper/ConversionHelper.cxx | 4
12 files changed, 170 insertions(+), 2 deletions(-)
New commits:
commit a295ccd382cbed73e4b35a321efd53987c873981
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Mar 4 09:13:11 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu May 14 11:38:36 2020 +0200
sw padded numbering: add DOCX filter
DOCX uses <w:numFmt w:val="decimalZero"/> for this.
(cherry picked from commit 5435ea2afc5da5633a440f2f06d79265bcbb040c)
Change-Id: I12a4a88f472af42a04244d30f9e59fc0b8b4855c
diff --git a/sw/qa/extras/ooxmlexport/data/arabic-zero-numbering.docx b/sw/qa/extras/ooxmlexport/data/arabic-zero-numbering.docx
new file mode 100644
index 000000000000..f87dce364c9e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/arabic-zero-numbering.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 3df3eea38bde..fb272a618cb2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -107,6 +107,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf87569v, "tdf87569_vml.docx")
text::RelOrientation::FRAME, nValue);
}
+DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-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: 64
+ // - Actual : 4
+ // i.e. numbering type was ARABIC, not ARABIC_ZERO.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO),
+ aMap["NumberingType"].get<sal_uInt16>());
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf87569d, "tdf87569_drawingml.docx")
{
//if the original tdf87569 sample is upgraded it will have drawingml shapes...
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8c6fa174a88b..36ee2c7fb4da 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6373,6 +6373,7 @@ static OString impl_LevelNFC( sal_uInt16 nNumberingType , const SfxItemSet *pOut
case style::NumberingType::TEXT_CARDINAL: aType="cardinalText"; break;
case style::NumberingType::TEXT_ORDINAL: aType="ordinalText"; break;
case style::NumberingType::SYMBOL_CHICAGO: aType="chicago"; break;
+ case style::NumberingType::ARABIC_ZERO: aType = "decimalZero"; 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 542a3cb55ecd..81d0dce54fa9 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -586,6 +586,9 @@ sal_Int16 ConvertNumberingType(sal_Int32 nFmt)
case NS_ooxml::LN_Value_ST_NumberFormat_chicago:
nRet = style::NumberingType::SYMBOL_CHICAGO;
break;
+ case NS_ooxml::LN_Value_ST_NumberFormat_decimalZero:
+ nRet = style::NumberingType::ARABIC_ZERO;
+ break;
default: nRet = style::NumberingType::ARABIC;
}
/* TODO: Lots of additional values are available - some are supported in the I18 framework
@@ -593,7 +596,6 @@ sal_Int16 ConvertNumberingType(sal_Int32 nFmt)
NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth = 91691;
NS_ooxml::LN_Value_ST_NumberFormat_decimalHalfWidth = 91692;
NS_ooxml::LN_Value_ST_NumberFormat_japaneseDigitalTenThousand = 91694;
- NS_ooxml::LN_Value_ST_NumberFormat_decimalZero = 91699;
NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedFullstop = 91703;
NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedParen = 91704;
NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiacTraditional = 91709;
commit 7f2fc930474ecc2237d2dc0170d0dddebf7932ba
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 3 15:54:19 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu May 14 11:35:56 2020 +0200
sw padded numbering: add ODF filter
ODF allows any string as style:num-format="...", go with "01, 02, 03,
...", because that seems to be consistent with both
DefaultNumberingProvider::makeNumberingIdentifier()'s fallback mechanism
and with OOXML (which uses "001, 002, 003, ..." for the "pad to 3"
case).
(cherry picked from commit 7a8450c3ecf1a8000cb37981c981fdd55d196df4)
Conflicts:
sw/qa/extras/odfexport/odfexport.cxx
Change-Id: I5c5c7ee5bd61175afc3e682276e69344852106d5
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 372837595708..797d7360a283 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -1039,6 +1039,7 @@ static const Supported_NumberingType aSupportedTypes[] =
{style::NumberingType::CHARS_PERSIAN_WORD, nullptr, LANG_CTL},
{style::NumberingType::CHARS_GREEK_UPPER_LETTER, C_GR_A ", " C_GR_B ", ... (gr)", LANG_ALL},
{style::NumberingType::CHARS_GREEK_LOWER_LETTER, S_GR_A ", " S_GR_B ", ... (gr)", LANG_ALL},
+ {style::NumberingType::ARABIC_ZERO, "01, 02, 03, ...", LANG_ALL},
};
static const sal_Int32 nSupported_NumberingTypes = SAL_N_ELEMENTS(aSupportedTypes);
diff --git a/sw/qa/extras/odfexport/data/arabic-zero-numbering.odt b/sw/qa/extras/odfexport/data/arabic-zero-numbering.odt
new file mode 100644
index 000000000000..2a445b22748a
Binary files /dev/null and b/sw/qa/extras/odfexport/data/arabic-zero-numbering.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index cd7ec96315f4..0d5c28f07ebd 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2335,5 +2335,18 @@ DECLARE_ODFEXPORT_TEST(testPageContentBottom, "page-content-bottom.odt")
CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int16>(xShape, "VertOrientRelation"));
}
+DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-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: 64
+ // - Actual : 4
+ // i.e. numbering type was ARABIC, not ARABIC_ZERO.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO),
+ aMap["NumberingType"].get<sal_uInt16>());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2a4e767ea83e49fafb639e66e74403c2ff9270ac
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 3 09:27:01 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu May 14 11:34:47 2020 +0200
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.
(cherry picked from commit 642b7706101a991efc7e312f59dece640d8bfb60)
Change-Id: If6e5634b11616f0ac05e1387016e22f4b171bbfb
diff --git a/i18npool/CppunitTest_i18npool_defaultnumberingprovider.mk b/i18npool/CppunitTest_i18npool_defaultnumberingprovider.mk
new file mode 100644
index 000000000000..421affb90b35
--- /dev/null
+++ b/i18npool/CppunitTest_i18npool_defaultnumberingprovider.mk
@@ -0,0 +1,44 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,i18npool_defaultnumberingprovider))
+
+$(eval $(call gb_CppunitTest_use_externals,i18npool_defaultnumberingprovider,\
+ boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,i18npool_defaultnumberingprovider, \
+ i18npool/qa/cppunit/test_defaultnumberingprovider \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,i18npool_defaultnumberingprovider, \
+ comphelper \
+ cppu \
+ sal \
+ test \
+ unotest \
+ utl \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,i18npool_defaultnumberingprovider))
+
+$(eval $(call gb_CppunitTest_use_ure,i18npool_defaultnumberingprovider))
+$(eval $(call gb_CppunitTest_use_vcl,i18npool_defaultnumberingprovider))
+
+$(eval $(call gb_CppunitTest_use_rdb,i18npool_defaultnumberingprovider,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,i18npool_defaultnumberingprovider,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,i18npool_defaultnumberingprovider))
+
+# vim: set noet sw=4 ts=4:
diff --git a/i18npool/Module_i18npool.mk b/i18npool/Module_i18npool.mk
index 0e1f5e6cef72..8a770bb4f0e3 100644
--- a/i18npool/Module_i18npool.mk
+++ b/i18npool/Module_i18npool.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_Module_add_check_targets,i18npool,\
CppunitTest_i18npool_test_characterclassification \
CppunitTest_i18npool_test_ordinalsuffix \
CppunitTest_i18npool_test_textsearch \
+ CppunitTest_i18npool_defaultnumberingprovider \
))
# vim: set noet sw=4 ts=4:
diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
new file mode 100644
index 000000000000..2a1cb55502e2
--- /dev/null
+++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
@@ -0,0 +1,57 @@
+/* -*- 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/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
+
+using namespace ::com::sun::star;
+
+/// i18npool defaultnumberingprovider tests.
+class I18npoolDefaultnumberingproviderTest : public test::BootstrapFixture
+{
+};
+
+CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero)
+{
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = comphelper::getComponentContext(getMultiServiceFactory());
+
+ // 1 -> "01"
+ 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_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: */
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index a81b00143989..372837595708 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -552,6 +552,30 @@ bool should_ignore( const OUString& s )
return s == " " || (!s.isEmpty() && s[0]==0);
}
+/**
+ * Turn nNumber into a string and pad the result to 2 using zero characters.
+ */
+static OUString lcl_formatArabicZero(sal_Int32 nNumber)
+{
+ sal_Int32 nLimit = 2;
+ OUString aRet = OUString::number(nNumber);
+ sal_Int32 nDiff = nLimit - aRet.getLength();
+
+ if (nDiff <= 0)
+ {
+ return aRet;
+ }
+
+ OUStringBuffer aBuffer;
+ aBuffer.setLength(nDiff);
+ for (sal_Int32 i = 0; i < nDiff; ++i)
+ {
+ aBuffer[i] = '0';
+ }
+ aBuffer.append(aRet);
+ return aBuffer.makeStringAndClear();
+}
+
static
Any getPropertyByName( const Sequence<beans::PropertyValue>& aProperties,
const char* name, bool bRequired )
@@ -913,6 +937,10 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
lcl_formatChars1( table_Chicago, 4, number-1, result ); // *, +, |, S, **, ++, ...
break;
+ case ARABIC_ZERO:
+ result += lcl_formatArabicZero(number);
+ break;
+
default:
OSL_ASSERT(false);
throw IllegalArgumentException();
commit 2cdf69ea6412e20860d70d1ee7f0d5acb73a97e4
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 2 17:17:56 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu May 14 10:52:17 2020 +0200
sw padded numbering: add doc model and UNO API
The idea is to behave similar to Arabic numbering, but pad the result on
the left up to 2 characters. Word has this feature, so far Writer falled
back to plain Arabic numbering.
This is just the document model, not layout yet.
(cherry picked from commit 6b80bd446de4bf19df3a9b124881e1fe12402ca8)
Change-Id: I8ac90536848d00b8678129184db0849130724dee
diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx
index 3c4bbe266347..f425e97cde0c 100644
--- a/include/editeng/svxenum.hxx
+++ b/include/editeng/svxenum.hxx
@@ -205,7 +205,8 @@ enum SvxNumType : sal_Int16
SVX_NUM_TEXT_NUMBER = css::style::NumberingType::TEXT_NUMBER,
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_SYMBOL_CHICAGO = css::style::NumberingType::SYMBOL_CHICAGO,
+ SVX_NUM_ARABIC_ZERO = css::style::NumberingType::ARABIC_ZERO
};
#endif
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index 183d719c89a2..66159a818e66 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -492,6 +492,13 @@ published constants NumberingType
ASTERISK ASTERISK, DAGGER DAGGER, etc.
*/
const short SYMBOL_CHICAGO = 63;
+
+ /** Numbering is in Arabic numbers, padded with zero to have a length of at least two, as "01,
+ 02, ..., 10, 11, ...".
+
+ @since LibreOffice 7.0
+ */
+ const short ARABIC_ZERO = 64;
};
More information about the Libreoffice-commits
mailing list