summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.fetch1
-rw-r--r--Repository.mk1
-rw-r--r--RepositoryExternal.mk53
-rw-r--r--config_host.mk.in3
-rw-r--r--configure.ac26
-rw-r--r--download.lst2
-rw-r--r--external/Module_external.mk1
-rw-r--r--external/libnumbertext/ExternalPackage_numbertext.mk54
-rw-r--r--external/libnumbertext/ExternalProject_libnumbertext.mk43
-rw-r--r--external/libnumbertext/Makefile7
-rw-r--r--external/libnumbertext/Module_libnumbertext.mk32
-rw-r--r--external/libnumbertext/README3
-rw-r--r--external/libnumbertext/StaticLibrary_libnumbertext.mk22
-rw-r--r--external/libnumbertext/UnpackedTarball_libnumbertext.mk16
-rw-r--r--i18npool/inc/defaultnumberingprovider.hxx2
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx47
-rw-r--r--include/editeng/svxenum.hxx5
-rw-r--r--include/unotools/pathoptions.hxx2
-rw-r--r--lingucomponent/Library_numbertext.mk34
-rw-r--r--lingucomponent/Module_lingucomponent.mk1
-rw-r--r--lingucomponent/source/numbertext/numbertext.component25
-rw-r--r--lingucomponent/source/numbertext/numbertext.cxx207
-rw-r--r--offapi/UnoApi_offapi.mk2
-rw-r--r--offapi/com/sun/star/linguistic2/NumberText.idl46
-rw-r--r--offapi/com/sun/star/linguistic2/XNumberText.idl123
-rw-r--r--offapi/com/sun/star/style/NumberingType.idl23
-rw-r--r--officecfg/Configuration_officecfg.mk2
-rw-r--r--officecfg/registry/data/org/openoffice/Office/Paths.xcu6
-rw-r--r--postprocess/CustomTarget_registry.mk6
-rw-r--r--postprocess/Rdb_services.mk1
-rw-r--r--scp2/source/ooo/directory_ooo.scp5
-rw-r--r--svx/inc/numberingtype.hrc3
-rw-r--r--sw/inc/numrule.hxx4
-rw-r--r--sw/qa/extras/odfexport/data/spellout-numberingtypes.odtbin0 -> 10093 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx26
-rw-r--r--sw/source/core/doc/number.cxx7
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx4
-rw-r--r--unotools/source/config/pathoptions.cxx8
38 files changed, 848 insertions, 5 deletions
diff --git a/Makefile.fetch b/Makefile.fetch
index 94f697ea9270..fce291d2c3ac 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -157,6 +157,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S
$(call fetch_Optional,LIBGPGERROR,LIBGPGERROR_TARBALL) \
$(call fetch_Optional,LIBLANGTAG,LANGTAGREG_TARBALL) \
$(call fetch_Optional,LIBLANGTAG,LIBLANGTAG_TARBALL) \
+ $(call fetch_Optional,LIBNUMBERTEXT,LIBNUMBERTEXT_TARBALL) \
$(call fetch_Optional,LIBPNG,LIBPNG_TARBALL) \
$(call fetch_Optional,LIBTOMMATH,LIBTOMMATH_TARBALL) \
$(call fetch_Optional,LIBXML2,LIBXML_TARBALL) \
diff --git a/Repository.mk b/Repository.mk
index e4a11d3d160f..fa62def2fc91 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -404,6 +404,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
$(call gb_Helper_optional,SCRIPTING,msforms) \
mtfrenderer \
$(call gb_Helper_optional,DBCONNECTIVITY,mysql) \
+ numbertext \
odbc \
odfflatxml \
offacc \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 514dc485a8f6..299400174d2c 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -810,6 +810,59 @@ endef
endif # SYSTEM_LIBEXTTEXTCAT
+ifneq ($(SYSTEM_LIBNUMBERTEXT),)
+
+define gb_LinkTarget__use_libnumbertext
+$(call gb_LinkTarget_set_include,$(1),\
+ $$(INCLUDE) \
+ $(LIBNUMBERTEXT_CFLAGS) \
+)
+$(call gb_LinkTarget_add_defs,$(1),\
+ -DSYSTEM_LIBNUMBERTEXT \
+)
+$(call gb_LinkTarget_add_libs,$(1),$(LIBNUMBERTEXT_LIBS))
+
+endef
+
+else # !SYSTEM_LIBNUMBERTEXT
+
+ifneq ($(ENABLE_LIBNUMBERTEXT),)
+
+define gb_LinkTarget__use_libnumbertext
+
+$(call gb_LinkTarget_set_include,$(1),\
+ -I$(call gb_UnpackedTarball_get_dir,libnumbertext/src) \
+ $$(INCLUDE) \
+)
+$(call gb_LinkTarget_add_defs,$(1),\
+ -DENABLE_LIBNUMBERTEXT \
+)
+
+ifeq ($(COM),MSC)
+$(call gb_LinkTarget_use_static_libraries,$(1),\
+ libnumbertext \
+)
+else
+
+$(call gb_LinkTarget_add_libs,$(1),\
+ $(call gb_UnpackedTarball_get_dir,libnumbertext)/src/.libs/libnumbertext-1.0.a\
+)
+$(call gb_LinkTarget_use_external_project,$(1),libnumbertext)
+
+endif
+
+endef
+
+else # !ENABLE_LIBNUMBERTEXT
+
+define gb_LinkTarget__use_libnumbertext
+endef
+
+endif # ENABLE_LIBNUMBERTEXT
+
+endif # SYSTEM_LIBNUMBERTEXT
+
+
ifneq ($(SYSTEM_LIBXML),)
define gb_LinkTarget__use_libxml2
diff --git a/config_host.mk.in b/config_host.mk.in
index 70a428378050..3085de0c4767 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -332,6 +332,9 @@ export LIBLANGTAG_CFLAGS=$(gb_SPACE)@LIBLANGTAG_CFLAGS@
export LIBLANGTAG_LIBS=$(gb_SPACE)@LIBLANGTAG_LIBS@
export LIBLAYOUT_JAR=@LIBLAYOUT_JAR@
export LIBLOADER_JAR=@LIBLOADER_JAR@
+export LIBNUMBERTEXT_CXXFLAGS=$(gb_SPACE)@LIBNUMBERTEXT_CXXFLAGS@
+export LIBNUMBERTEXT_LIBS=$(gb_SPACE)@LIBNUMBERTEXT_LIBS@
+export ENABLE_LIBNUMBERTEXT=@ENABLE_LIBNUMBERTEXT@
export LIBO_BIN_FOLDER=@LIBO_BIN_FOLDER@
export LIBO_BIN_FOLDER_FOR_BUILD=@LIBO_BIN_FOLDER_FOR_BUILD@
export LIBO_ETC_FOLDER=@LIBO_ETC_FOLDER@
diff --git a/configure.ac b/configure.ac
index e57333f7963c..15cd5bb408c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9651,6 +9651,32 @@ if test "$with_system_libexttextcat" = "yes"; then
fi
AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
+dnl ===================================================================
+dnl Checking for libnumbertext
+dnl ===================================================================
+ENABLE_LIBNUMBERTEXT=TRUE
+LIBNUMBERTEXT_CFLAGS="-DENABLE_LIBNUMBERTEXT"
+libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.0])
+if test "$with_system_libnumbertext" = "yes"; then
+ SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
+else
+ AC_LANG_PUSH([C++])
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+ AC_CHECK_HEADERS([codecvt regex])
+ AS_IF([test "x$ac_cv_header_codecvt" != xyes -o "x$ac_cv_header_regex" != xyes],
+ [ ENABLE_LIBNUMBERTEXT=''
+ LIBNUMBERTEXT_CFLAGS=''
+ AC_MSG_WARN([No system-provided libnumbertext or codecvt/regex C++11 headers (min. libstdc++ 4.9).
+ Enable libnumbertext fallback (missing number to number name conversion).])
+ ])
+ CXXFLAGS=$save_CXXFLAGS
+ AC_LANG_POP([C++])
+fi
+AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
+AC_SUBST(ENABLE_LIBNUMBERTEXT)
+AC_SUBST(LIBNUMBERTEXT_CFLAGS)
+
dnl ***************************************
dnl testing libc version for Linux...
dnl ***************************************
diff --git a/download.lst b/download.lst
index c05c99ba4dc0..5f87d7a203db 100644
--- a/download.lst
+++ b/download.lst
@@ -148,6 +148,8 @@ export LIBGPGERROR_SHA256SUM := 4f93aac6fecb7da2b92871bb9ee33032be6a87b174f54abf
export LIBGPGERROR_TARBALL := libgpg-error-1.27.tar.bz2
export LIBLANGTAG_SHA256SUM := d6242790324f1432fb0a6fae71b6851f520b2c5a87675497cf8ea14c2924d52e
export LIBLANGTAG_TARBALL := liblangtag-0.6.2.tar.bz2
+export LIBNUMBERTEXT_SHA256SUM := 46f3a5e4cb4b6c5b29f1cd340d1a6ea60e6fabc59859951f022d35e32a32a458
+export LIBNUMBERTEXT_TARBALL := libnumbertext-1.0.1-3.tar.xz
export LIBTOMMATH_SHA256SUM := 083daa92d8ee6f4af96a6143b12d7fc8fe1a547e14f862304f7281f8f7347483
export LIBTOMMATH_TARBALL := ltm-1.0.zip
export XMLSEC_SHA256SUM := 967ca83edf25ccb5b48a3c4a09ad3405a63365576503bf34290a42de1b92fcd2
diff --git a/external/Module_external.mk b/external/Module_external.mk
index 317c14d64d87..33800e8147a6 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
$(call gb_Helper_optional,LIBEXTTEXTCAT,libexttextcat) \
$(call gb_Helper_optional,LIBGPGERROR,libgpg-error) \
$(call gb_Helper_optional,LIBLANGTAG,liblangtag) \
+ $(call gb_Helper_optional,LIBNUMBERTEXT,libnumbertext) \
$(call gb_Helper_optional,LIBPNG,libpng) \
$(call gb_Helper_optional,LIBXML2,libxml2) \
$(call gb_Helper_optional,LIBXSLT,libxslt) \
diff --git a/external/libnumbertext/ExternalPackage_numbertext.mk b/external/libnumbertext/ExternalPackage_numbertext.mk
new file mode 100644
index 000000000000..e76e8d6da43d
--- /dev/null
+++ b/external/libnumbertext/ExternalPackage_numbertext.mk
@@ -0,0 +1,54 @@
+# -*- 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_ExternalPackage_ExternalPackage,libnumbertext_numbertext,libnumbertext))
+
+$(eval $(call gb_ExternalPackage_add_unpacked_files,libnumbertext_numbertext,$(LIBO_SHARE_FOLDER)/numbertext,\
+ data/af.sor \
+ data/ca.sor \
+ data/cs.sor \
+ data/da.sor \
+ data/de.sor \
+ data/el.sor \
+ data/en.sor \
+ data/eo.sor \
+ data/es.sor \
+ data/fi.sor \
+ data/fr.sor \
+ data/fr.sor \
+ data/he.sor \
+ data/hr.sor \
+ data/hu.sor \
+ data/Hung.sor \
+ data/id.sor \
+ data/it.sor \
+ data/ja.sor \
+ data/ko.sor \
+ data/lb.sor \
+ data/lt.sor \
+ data/lv.sor \
+ data/ms.sor \
+ data/nl.sor \
+ data/pl.sor \
+ data/pt.sor \
+ data/Roman.sor \
+ data/ro.sor \
+ data/ru.sor \
+ data/sh.sor \
+ data/sl.sor \
+ data/sr.sor \
+ data/Suzhou.sor \
+ data/sv.sor \
+ data/th.sor \
+ data/tr.sor \
+ data/vi.sor \
+ data/zh.sor \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/ExternalProject_libnumbertext.mk b/external/libnumbertext/ExternalProject_libnumbertext.mk
new file mode 100644
index 000000000000..04b957667ae6
--- /dev/null
+++ b/external/libnumbertext/ExternalProject_libnumbertext.mk
@@ -0,0 +1,43 @@
+# -*- 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_ExternalProject_ExternalProject,libnumbertext))
+
+$(eval $(call gb_ExternalProject_use_externals,libnumbertext, \
+))
+
+$(eval $(call gb_ExternalProject_register_targets,libnumbertext,\
+ build \
+))
+
+libnumbertext_CXXFLAGS=$(CXXFLAGS) $(CXXFLAGS_CXX11)
+
+ifneq (,$(filter ANDROID DRAGONFLY FREEBSD IOS LINUX NETBSD OPENBSD,$(OS)))
+ifneq (,$(gb_ENABLE_DBGUTIL))
+libnumbertext_CPPFLAGS+=-D_GLIBCXX_DEBUG
+endif
+endif
+
+libnumbertext_LIBS+=-L$(gb_StaticLibrary_WORKDIR)
+
+$(call gb_ExternalProject_get_state_target,libnumbertext,build):
+ $(call gb_ExternalProject_run,build,\
+ $(if $(libnumbertext_LIBS),LIBS='$(libnumbertext_LIBS)') \
+ $(if $(filter IOS MACOSX,$(OS)),ACLOCAL="aclocal -I $(SRCDIR)/m4/mac") \
+ LIBS="$(gb_STDLIBS) $(LIBS)" \
+ autoreconf && \
+ $(SHELL) ./configure --disable-shared --with-pic \
+ $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM))\
+ $(if $(filter AIX,$(OS)),CFLAGS="-D_LINUX_SOURCE_COMPAT") \
+ $(if $(libnumbertext_CPPFLAGS),CPPFLAGS='$(libnumbertext_CPPFLAGS)') \
+ CXXFLAGS="$(libnumbertext_CXXFLAGS) $(if $(ENABLE_OPTIMIZED) $(gb_COMPILEROPTFLAGS),$(gb_COMPILERNOOPTFLAGS)) $(if $(debug),$(gb_DEBUGINFO_FLAGS) $(gb_DEBUG_CXXFLAGS))" \
+ && cd src && $(MAKE) \
+ )
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/Makefile b/external/libnumbertext/Makefile
new file mode 100644
index 000000000000..e4968cf85fb6
--- /dev/null
+++ b/external/libnumbertext/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/Module_libnumbertext.mk b/external/libnumbertext/Module_libnumbertext.mk
new file mode 100644
index 000000000000..1bca2233caa8
--- /dev/null
+++ b/external/libnumbertext/Module_libnumbertext.mk
@@ -0,0 +1,32 @@
+# -*- 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_Module_Module,libnumbertext))
+
+$(eval $(call gb_Module_add_targets,libnumbertext,\
+ ExternalPackage_numbertext \
+ UnpackedTarball_libnumbertext \
+))
+ifeq ($(COM),MSC)
+$(eval $(call gb_Module_add_targets,libnumbertext,\
+ StaticLibrary_libnumbertext \
+))
+else
+
+ifeq ($(ENABLE_LIBNUMBERTEXT),TRUE)
+
+$(eval $(call gb_Module_add_targets,libnumbertext,\
+ ExternalProject_libnumbertext \
+))
+
+endif
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/README b/external/libnumbertext/README
new file mode 100644
index 000000000000..922f19df1d2e
--- /dev/null
+++ b/external/libnumbertext/README
@@ -0,0 +1,3 @@
+Number to Number Name Conversion Library
+
+It is hosted at: [https://github.com/Numbertext/libnumbertext]
diff --git a/external/libnumbertext/StaticLibrary_libnumbertext.mk b/external/libnumbertext/StaticLibrary_libnumbertext.mk
new file mode 100644
index 000000000000..838fbd4fd498
--- /dev/null
+++ b/external/libnumbertext/StaticLibrary_libnumbertext.mk
@@ -0,0 +1,22 @@
+# -*- 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_StaticLibrary_StaticLibrary,libnumbertext))
+
+$(eval $(call gb_StaticLibrary_use_unpacked,libnumbertext,libnumbertext))
+
+$(eval $(call gb_StaticLibrary_set_warnings_not_errors,libnumbertext))
+
+$(eval $(call gb_StaticLibrary_add_generated_exception_objects,libnumbertext,\
+ UnpackedTarball/libnumbertext/src/Soros \
+ UnpackedTarball/libnumbertext/src/Numbertext \
+))
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/UnpackedTarball_libnumbertext.mk b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
new file mode 100644
index 000000000000..ac2a14133205
--- /dev/null
+++ b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
@@ -0,0 +1,16 @@
+# -*- 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_UnpackedTarball_UnpackedTarball,libnumbertext))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,libnumbertext,$(LIBNUMBERTEXT_TARBALL)))
+
+$(eval $(call gb_UnpackedTarball_update_autoconf_configs,libnumbertext))
+
+# vim: set noet sw=4 ts=4:
diff --git a/i18npool/inc/defaultnumberingprovider.hxx b/i18npool/inc/defaultnumberingprovider.hxx
index 1320b7e41a73..97608c122000 100644
--- a/i18npool/inc/defaultnumberingprovider.hxx
+++ b/i18npool/inc/defaultnumberingprovider.hxx
@@ -25,6 +25,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/i18n/XTransliteration.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/i18n/CharacterClassification.hpp>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
@@ -80,6 +81,7 @@ private:
OUString makeNumberingIdentifier( sal_Int16 index );
/// @throws css::uno::RuntimeException
bool isScriptFlagEnabled(const OUString& aName );
+ mutable css::uno::Reference< css::i18n::XCharacterClassification > xCharClass;
};
}
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index e9f584a617cd..e222611a2afe 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -19,6 +19,7 @@
#include <defaultnumberingprovider.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/linguistic2/NumberText.hpp>
#include <com/sun/star/style/NumberingType.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
@@ -31,6 +32,9 @@
#include <string.h>
#include <comphelper/propertysequence.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <unordered_map>
+#include <map>
// Cyrillic upper case
#define C_CYR_A "\xD0\x90"
@@ -634,6 +638,46 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
case CHARS_LOWER_LETTER:
lcl_formatChars( lowerLetter, 26, number-1, result );
break;
+ case TEXT_NUMBER:
+ case TEXT_CARDINAL:
+ case TEXT_ORDINAL:
+ {
+ static css::uno::Reference< css::linguistic2::XNumberText > xNumberText;
+ if (!xNumberText.is())
+ xNumberText = linguistic2::NumberText::create( m_xContext );
+ OUString aLoc = LanguageTag::convertToBcp47(aLocale);
+ OUString numbertext_prefix = "";
+ if (numType == TEXT_NUMBER)
+ numbertext_prefix += "ordinal-number ";
+ else if (numType == TEXT_ORDINAL)
+ numbertext_prefix += "ordinal ";
+ // Several hundreds of headings could result typing lags because
+ // of the continuous update of the multiple number names during typing.
+ // We fix this by buffering the result of the conversion.
+ static std::unordered_map<sal_Int32,std::map<OUString, OUString> > aBuff;
+ auto aBuffItem = aBuff.find(number);
+ std::map<OUString, OUString> aItem;
+ if (aBuffItem == aBuff.end() || !aBuffItem->second.count(numbertext_prefix + aLoc))
+ {
+ OUString snumber = OUString::number(number);
+ OUString aNum =
+ xNumberText->getNumberText( numbertext_prefix + snumber, aLocale);
+ if ( !xCharClass.is() )
+ xCharClass = CharacterClassification::create( m_xContext );
+ // use number at missing number to text conversion
+ if (aNum.getLength() == 0)
+ aNum = snumber;
+ // capitalize first letter
+ aItem[numbertext_prefix + aLoc] = xCharClass->toTitle(aNum, 0, 1, aLocale) + aNum.copy(1);
+ aBuff.insert(std::make_pair(number, aItem));
+ }
+ else
+ {
+ aItem = aBuffItem->second;
+ }
+ result += aItem[numbertext_prefix + aLoc];
+ break;
+ }
case ROMAN_UPPER:
result += toRoman( number );
break;
@@ -928,6 +972,9 @@ static const Supported_NumberingType aSupportedTypes[] =
{style::NumberingType::CHAR_SPECIAL, "Bullet", LANG_ALL},
{style::NumberingType::PAGE_DESCRIPTOR, "Page", LANG_ALL},
{style::NumberingType::BITMAP, "Bitmap", LANG_ALL},
+ {style::NumberingType::TEXT_NUMBER, "1st", LANG_ALL},
+ {style::NumberingType::TEXT_CARDINAL, "One", LANG_ALL},
+ {style::NumberingType::TEXT_ORDINAL, "First", LANG_ALL},
{style::NumberingType::CHARS_UPPER_LETTER_N, "AAA", LANG_ALL},
{style::NumberingType::CHARS_LOWER_LETTER_N, "aaa", LANG_ALL},
{style::NumberingType::NATIVE_NUMBERING, "Native Numbering", LANG_CJK|LANG_CTL},
diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx
index b756aef96481..ad7a2d5053e1 100644
--- a/include/editeng/svxenum.hxx
+++ b/include/editeng/svxenum.hxx
@@ -201,7 +201,10 @@ enum SvxNumType : sal_Int16
SVX_NUM_NUMBER_HEBREW = css::style::NumberingType::NUMBER_HEBREW,
SVX_NUM_NUMBER_ARABIC_INDIC = css::style::NumberingType::NUMBER_ARABIC_INDIC,
SVX_NUM_NUMBER_EAST_ARABIC_INDIC = css::style::NumberingType::NUMBER_EAST_ARABIC_INDIC,
- SVX_NUM_NUMBER_INDIC_DEVANAGARI = css::style::NumberingType::NUMBER_INDIC_DEVANAGARI
+ SVX_NUM_NUMBER_INDIC_DEVANAGARI = css::style::NumberingType::NUMBER_INDIC_DEVANAGARI,
+ 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
};
#endif
diff --git a/include/unotools/pathoptions.hxx b/include/unotools/pathoptions.hxx
index 2334e0b56852..74a408a7c9ef 100644
--- a/include/unotools/pathoptions.hxx
+++ b/include/unotools/pathoptions.hxx
@@ -65,6 +65,7 @@ public:
PATH_CLASSIFICATION,
PATH_UICONFIG,
PATH_FINGERPRINT,
+ PATH_NUMBERTEXT,
PATH_COUNT // should always be the last element
};
@@ -96,6 +97,7 @@ public:
const OUString& GetUserConfigPath() const;
const OUString& GetWorkPath() const;
const OUString& GetFingerprintPath() const;
+ const OUString& GetNumbertextPath() const;
const OUString& GetClassificationPath() const;
// set the paths
diff --git a/lingucomponent/Library_numbertext.mk b/lingucomponent/Library_numbertext.mk
new file mode 100644
index 000000000000..68c50e209fba
--- /dev/null
+++ b/lingucomponent/Library_numbertext.mk
@@ -0,0 +1,34 @@
+# -*- 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_Library_Library,numbertext))
+
+$(eval $(call gb_Library_set_componentfile,numbertext,lingucomponent/source/numbertext/numbertext))
+
+$(eval $(call gb_Library_use_externals,numbertext,\
+ libnumbertext \
+))
+
+$(eval $(call gb_Library_use_sdk_api,numbertext))
+
+$(eval $(call gb_Library_use_libraries,numbertext,\
+ cppu \
+ cppuhelper \
+ i18nlangtag \
+ sal \
+ tl \
+ utl \
+))
+
+$(eval $(call gb_Library_add_exception_objects,numbertext,\
+ lingucomponent/source/numbertext/numbertext \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/lingucomponent/Module_lingucomponent.mk b/lingucomponent/Module_lingucomponent.mk
index 92d582cc346a..4f3d2424f992 100644
--- a/lingucomponent/Module_lingucomponent.mk
+++ b/lingucomponent/Module_lingucomponent.mk
@@ -17,6 +17,7 @@ $(eval $(call gb_Module_add_targets,lingucomponent,\
$(if $(filter MACOSX,$(OS)),Library_MacOSXSpell) \
Library_spell \
StaticLibrary_ulingu \
+ Library_numbertext \
))
# vim: set noet sw=4 ts=4:
diff --git a/lingucomponent/source/numbertext/numbertext.component b/lingucomponent/source/numbertext/numbertext.component
new file mode 100644
index 000000000000..b17cc31e0840
--- /dev/null
+++ b/lingucomponent/source/numbertext/numbertext.component
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ prefix="numbertext" xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.lingu2.NumberText">
+ <service name="com.sun.star.linguistic2.NumberText"/>
+ </implementation>
+</component>
diff --git a/lingucomponent/source/numbertext/numbertext.cxx b/lingucomponent/source/numbertext/numbertext.cxx
new file mode 100644
index 000000000000..e86278d851f4
--- /dev/null
+++ b/lingucomponent/source/numbertext/numbertext.cxx
@@ -0,0 +1,207 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <iostream>
+
+#include <osl/file.hxx>
+#include <tools/debug.hxx>
+
+#include <sal/config.h>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <i18nlangtag/languagetag.hxx>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/linguistic2/XNumberText.hpp>
+#include <unotools/pathoptions.hxx>
+#include <osl/thread.h>
+
+#include <sal/macros.h>
+
+#ifdef SYSTEM_LIBNUMBERTEXT
+#include <libnumbertext/Numbertext.hxx>
+#else
+#ifdef ENABLE_LIBNUMBERTEXT
+#include <Numbertext.hxx>
+#endif
+#endif
+
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::linguistic2;
+
+#define SERVICENAME "com.sun.star.linguistic2.NumberText"
+#define IMPLNAME "com.sun.star.lingu2.NumberText"
+
+static Sequence<OUString> getSupportedServiceNames_NumberText_Impl()
+{
+ Sequence<OUString> names{ SERVICENAME };
+ return names;
+}
+
+static OUString getImplementationName_NumberText_Impl() { return OUString(IMPLNAME); }
+
+static osl::Mutex& GetNumberTextMutex()
+{
+ static osl::Mutex aMutex;
+ return aMutex;
+}
+
+class NumberText_Impl : public ::cppu::WeakImplHelper<XNumberText, XServiceInfo>
+{
+#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+ Numbertext m_aNumberText;
+#endif
+ bool m_bInitialized;
+
+ virtual ~NumberText_Impl() override {}
+ void EnsureInitialized();
+
+public:
+ NumberText_Impl();
+ NumberText_Impl(const NumberText_Impl&) = delete;
+ NumberText_Impl& operator=(const NumberText_Impl&) = delete;
+
+ // XServiceInfo implementation
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+ static Sequence<OUString> getSupportedServiceNames_Static();
+
+ // XNumberText implementation
+ virtual OUString SAL_CALL getNumberText(const OUString& aText,
+ const ::css::lang::Locale& rLocale) override;
+ virtual css::uno::Sequence<css::lang::Locale> SAL_CALL getAvailableLanguages() override;
+};
+
+NumberText_Impl::NumberText_Impl()
+ : m_bInitialized(false)
+{
+}
+
+void NumberText_Impl::EnsureInitialized()
+{
+ if (!m_bInitialized)
+ {
+ // set this to true at the very start to prevent loops because of
+ // implicitly called functions below
+ m_bInitialized = true;
+
+ // set default numbertext path to where those get installed
+ OUString aPhysPath;
+ OUString aURL(SvtPathOptions().GetNumbertextPath());
+ osl::FileBase::getSystemPathFromFileURL(aURL, aPhysPath);
+#ifdef _WIN32
+ aPhysPath += "\\";
+#else
+ aPhysPath += "/";
+#endif
+#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+ OString path = OUStringToOString(aPhysPath, osl_getThreadTextEncoding());
+ m_aNumberText.set_prefix(path.getStr());
+#endif
+ }
+}
+
+OUString SAL_CALL NumberText_Impl::getNumberText(const OUString& rText, const Locale&
+#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+ rLocale)
+#else
+)
+#endif
+{
+ osl::MutexGuard aGuard(GetNumberTextMutex());
+ EnsureInitialized();
+#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+ // libnumbertext supports Language + Country tags (separated by "_" or "-")
+ LanguageTag aLanguageTag(rLocale);
+ OUString aCode(aLanguageTag.getLanguage());
+ OUString aCountry(aLanguageTag.getCountry());
+ if (!aCountry.isEmpty())
+ aCode += "-" + aCountry;
+ OString aLangCode(OUStringToOString(aCode, RTL_TEXTENCODING_ASCII_US));
+ OString aInput(OUStringToOString(rText, RTL_TEXTENCODING_UTF8));
+ std::wstring aResult = m_aNumberText.string2wstring(aInput.getStr());
+ bool result = m_aNumberText.numbertext(aResult, aLangCode.getStr());
+ DBG_ASSERT(result, "numbertext: false");
+ OString aResult2(m_aNumberText.wstring2string(aResult).c_str());
+ return OUString::fromUtf8(aResult2);
+#else
+ return rText;
+#endif
+}
+
+uno::Sequence<Locale> SAL_CALL NumberText_Impl::getAvailableLanguages()
+{
+ osl::MutexGuard aGuard(GetNumberTextMutex());
+ // TODO
+ Sequence<css::lang::Locale> aRes;
+ return aRes;
+}
+
+OUString SAL_CALL NumberText_Impl::getImplementationName() { return OUString(IMPLNAME); }
+
+sal_Bool SAL_CALL NumberText_Impl::supportsService(const OUString& ServiceName)
+{
+ return cppu::supportsService(this, ServiceName);
+}
+
+Sequence<OUString> SAL_CALL NumberText_Impl::getSupportedServiceNames()
+{
+ return getSupportedServiceNames_Static();
+}
+
+Sequence<OUString> NumberText_Impl::getSupportedServiceNames_Static()
+{
+ OUString aName(SERVICENAME);
+ return Sequence<OUString>(&aName, 1);
+}
+
+/**
+ * Function to create a new component instance; is needed by factory helper implementation.
+ * @param xMgr service manager to if the components needs other component instances
+ */
+Reference<XInterface> NumberText_Impl_create(Reference<XComponentContext> const&)
+{
+ return static_cast<::cppu::OWeakObject*>(new NumberText_Impl);
+}
+
+//#### EXPORTED ### functions to allow for registration and creation of the UNO component
+static const struct ::cppu::ImplementationEntry s_component_entries[]
+ = { { NumberText_Impl_create, getImplementationName_NumberText_Impl,
+ getSupportedServiceNames_NumberText_Impl, ::cppu::createSingleComponentFactory, nullptr,
+ 0 },
+ { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } };
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void* numbertext_component_getFactory(sal_Char const* implName, void* xMgr,
+ void* xRegistry)
+{
+ return ::cppu::component_getFactoryHelper(implName, xMgr, xRegistry, s_component_entries);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 2f544b327a6e..e25fc4495805 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -245,6 +245,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/linguistic2,\
LinguServiceManager \
Proofreader \
ProofreadingIterator \
+ NumberText \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/logging,\
ConsoleHandler \
@@ -2850,6 +2851,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/linguistic2,\
XLinguServiceManager \
XLinguServiceManager2 \
XMeaning \
+ XNumberText \
XPossibleHyphens \
XProofreader \
XProofreadingIterator \
diff --git a/offapi/com/sun/star/linguistic2/NumberText.idl b/offapi/com/sun/star/linguistic2/NumberText.idl
new file mode 100644
index 000000000000..67c77ceeba20
--- /dev/null
+++ b/offapi/com/sun/star/linguistic2/NumberText.idl
@@ -0,0 +1,46 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_linguistic2_NumberText_idl__
+#define __com_sun_star_linguistic2_NumberText_idl__
+
+#include <com/sun/star/linguistic2/XNumberText.idl>
+
+module com { module sun { module star { module linguistic2 {
+
+/** provides converter to spell out numbers and money amounts
+
+ <p>An implementation of this service will receive text and has to spell
+ out as cardinal, ordinal, ordinal indicator or money amounts.</p>
+
+ <p>An implementation of this service is not limited to number to number
+ conversion at all. It might also support other linguistic functions of
+ a given language, for example, spelling out years, gender and formal
+ variants or complex affixation of number names, or article selection.</p>
+
+ @since LibreOffice 6.1
+ */
+
+ service NumberText:XNumberText;
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/linguistic2/XNumberText.idl b/offapi/com/sun/star/linguistic2/XNumberText.idl
new file mode 100644
index 000000000000..4d0311323b1f
--- /dev/null
+++ b/offapi/com/sun/star/linguistic2/XNumberText.idl
@@ -0,0 +1,123 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_linguistic2_XNumberText_idl__
+#define __com_sun_star_linguistic2_XNumberText_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/lang/Locale.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+
+module com { module sun { module star { module linguistic2 {
+
+/** This interface allows to spell out numbers and money amounts
+
+ <p> The current set of supported languages is:
+ <ul>
+ <li>af : Afrikaans</li>
+ <li>ca : Catalan</li>
+ <li>cs : Czech</li>
+ <li>da : Danish</li>
+ <li>de : German</li>
+ <li>de-CH : Swiss Standard German</li>
+ <li>de-LI : Swiss Standard German</li>
+ <li>el : Greek</li>
+ <li>en : English</li>
+ <li>en-AU : Australian English</li>
+ <li>en-GB : British English</li>
+ <li>en-IE : Irish English</li>
+ <li>en-NZ : New Zealand English</li>
+ <li>eo : Esperanto</li>
+ <li>es : Spanish</li>
+ <li>fi : Finnish</li>
+ <li>fr : French</li>
+ <li>fr-BE : Belgian French</li>
+ <li>fr-CH : Swiss French</li>
+ <li>he : Hebrew</li>
+ <li>hr : Croatian</li>
+ <li>hu : Hungarian</li>
+ <li>Hung : Old Hungarian</li>
+ <li>id : Indonesian</li>
+ <li>it : Italian</li>
+ <li>ja : Japanese</li>
+ <li>ko-KP : North-Korean</li>
+ <li>ko-KR : South-Korean</li>
+ <li>lb : Luxembourgish</li>
+ <li>lt : Lithuanian</li>
+ <li>lv : Latvian</li>
+ <li>ms : Malay</li>
+ <li>nl : Dutch</li>
+ <li>pl : Polish</li>
+ <li>pt-BR : Portuguese (Brasilian)</li>
+ <li>pt-PT : Portuguese (Portugal)</li>
+ <li>ro : Romanian</li>
+ <li>Roman : Roman numbers</li>
+ <li>ru : Russian</li>
+ <li>sh : Serbian (written with latin characters)</li>
+ <li>sl : Slovenian</li>
+ <li>sr : Serbian (written with cyrillic characters) (added with OOo 3.4)</li>
+ <li>Suzhou : Suzhou numerals</li>
+ <li>sv : Swedish</li>
+ <li>th : Thai</li>
+ <li>tr : Turkish</li>
+ <li>vi : Vietnamese</li>
+ <li>zh : Chinese</li>
+ </ul>
+
+ </p>
+
+ @since LibreOffice 6.1
+ */
+interface XNumberText
+{
+ /** spell out numbers and money amounts
+
+ <p>Please note that text argument can contain prefixes separated by space,
+ for example "ordinal" for ordinal numbers, "ordinal-number" for ordinal
+ indicators and ISO 4217 currency codes.
+
+ Language modules list the supported prefixes by the input text "help".</p>
+
+ @returns
+ the result of the number name conversion.
+
+ @param aText
+ all the text including the part that should converted.
+
+ @param aLocale
+ the locale for the target language of the number name conversion.
+
+ @see com::sun::star::lang::Locale
+ */
+ string getNumberText(
+ [in] string aText,
+ [in] com::sun::star::lang::Locale aLocale )
+ raises( com::sun::star::lang::IllegalArgumentException );
+
+ /** returns a list of all supported languages.
+ */
+ sequence< com::sun::star::lang::Locale > getAvailableLanguages();
+
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index be4bb6bc2758..6bcb43f6e77a 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -458,6 +458,29 @@ published constants NumberingType
*/
const short NUMBER_INDIC_DEVANAGARI = 59;
+ /** Numbering in ordinal numbers of the language
+ of the text node
+ for example, 1st, 2nd, 3rd... in English
+
+ @since LibreOffice 6.1
+ */
+ const short TEXT_NUMBER = 60;
+
+ /** Numbering in cardinal numbers of the language
+ of the text node
+ for example, One, Two, Three... in English
+
+ @since LibreOffice 6.1
+ */
+ const short TEXT_CARDINAL = 61;
+
+ /** Numbering in ordinal numbers of the language
+ of the text node
+ for example, First, Second, Third... in English
+
+ @since LibreOffice 6.1
+ */
+ const short TEXT_ORDINAL = 62;
};
diff --git a/officecfg/Configuration_officecfg.mk b/officecfg/Configuration_officecfg.mk
index 20c7e0a2be2a..9ce55fafcc4a 100644
--- a/officecfg/Configuration_officecfg.mk
+++ b/officecfg/Configuration_officecfg.mk
@@ -99,6 +99,8 @@ $(eval $(call gb_Configuration_add_spool_modules,registry,officecfg/registry/dat
org/openoffice/Office/Paths-unixdesktop.xcu \
org/openoffice/Office/Paths-internallibexttextcatdata.xcu \
org/openoffice/Office/Paths-externallibexttextcatdata.xcu \
+ org/openoffice/Office/Paths-internallibnumbertextdata.xcu \
+ org/openoffice/Office/Paths-externallibnumbertextdata.xcu \
org/openoffice/Office/Writer-cjk.xcu \
org/openoffice/Office/Impress-ogltrans.xcu \
org/openoffice/Office/Embedding-calc.xcu \
diff --git a/officecfg/registry/data/org/openoffice/Office/Paths.xcu b/officecfg/registry/data/org/openoffice/Office/Paths.xcu
index d52e619d0445..6161b4908261 100644
--- a/officecfg/registry/data/org/openoffice/Office/Paths.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Paths.xcu
@@ -147,6 +147,12 @@
<node install:module="externallibexttextcatdata" oor:name="${SYSTEM_LIBEXTTEXTCAT_DATA}" oor:op="fuse"/>
</node>
</node>
+ <node oor:name="Numbertext" oor:op="fuse" oor:mandatory="true">
+ <node oor:name="InternalPaths">
+ <node install:module="internallibnumbertextdata" oor:name="$(insturl)/@LIBO_SHARE_FOLDER@/numbertext" oor:op="fuse"/>
+ <node install:module="externallibnumbertextdata" oor:name="${SYSTEM_LIBNUMBERTEXT_DATA}" oor:op="fuse"/>
+ </node>
+ </node>
<!-- deprecated ! -->
<node oor:name="Storage" oor:op="fuse" oor:mandatory="true">
<prop oor:name="WritePath">
diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk
index f89b0b0bd96c..b0a816efed44 100644
--- a/postprocess/CustomTarget_registry.mk
+++ b/postprocess/CustomTarget_registry.mk
@@ -347,6 +347,12 @@ else
postprocess_FILES_main += $(postprocess_MOD)/org/openoffice/Office/Paths-internallibexttextcatdata.xcu
endif
+ifneq (,$(SYSTEM_LIBNUMBERTEXT_DATA))
+postprocess_FILES_main += $(postprocess_MOD)/org/openoffice/Office/Paths-externallibnumbertextdata.xcu
+else
+postprocess_FILES_main += $(postprocess_MOD)/org/openoffice/Office/Paths-internallibnumbertextdata.xcu
+endif
+
ifneq ($(filter $(CPUNAME),POWERPC INTEL ARM HPPA GODSON M68K SPARC S390),)
postprocess_FILES_main += \
$(postprocess_MOD)/org/openoffice/Office/Common-32bit.xcu
diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk
index 1b1fb4cd3b92..20cfc6cedebf 100644
--- a/postprocess/Rdb_services.mk
+++ b/postprocess/Rdb_services.mk
@@ -52,6 +52,7 @@ $(eval $(call gb_Rdb_add_components,services,\
lingucomponent/source/languageguessing/guesslang \
lingucomponent/source/spellcheck/spell/spell \
lingucomponent/source/thesaurus/libnth/lnth \
+ lingucomponent/source/numbertext/numbertext \
linguistic/source/lng \
$(if $(ENABLE_LWP), \
lotuswordpro/util/lwpfilter \
diff --git a/scp2/source/ooo/directory_ooo.scp b/scp2/source/ooo/directory_ooo.scp
index 0f76c94ff258..60e3f842173b 100644
--- a/scp2/source/ooo/directory_ooo.scp
+++ b/scp2/source/ooo/directory_ooo.scp
@@ -359,6 +359,11 @@ Directory gid_Dir_Share_Fingerprint
DosName = "fingerprint";
End
+Directory gid_Dir_Share_Numbertext
+ ParentID = gid_Brand_Dir_Share;
+ DosName = "numbertext";
+End
+
Directory gid_Dir_Help
#if defined MACOSX
ParentID = gid_Dir_Bundle_Contents_Resources;
diff --git a/svx/inc/numberingtype.hrc b/svx/inc/numberingtype.hrc
index b37a11b8e33a..3dcf0d89655b 100644
--- a/svx/inc/numberingtype.hrc
+++ b/svx/inc/numberingtype.hrc
@@ -35,6 +35,9 @@ const std::pair<const char*, int> RID_SVXSTRARY_NUMBERINGTYPE[] =
{ NC_("RID_SVXSTRARY_NUMBERINGTYPE", "a, b, c, ...") , 1 /* SVX_NUM_CHARS_LOWER_LETTER */ },
{ NC_("RID_SVXSTRARY_NUMBERINGTYPE", "I, II, III, ...") , 2 /* SVX_NUM_ROMAN_UPPER */ },
{ NC_("RID_SVXSTRARY_NUMBERINGTYPE", "i, ii, iii, ...") , 3 /* SVX_NUM_ROMAN_LOWER */ },
+ { NC_("RID_SVXSTRARY_NUMBERINGTYPE", "1st, 2nd, 3rd, ...") , 60 /* TEXT_NUMBER */ },
+ { NC_("RID_SVXSTRARY_NUMBERINGTYPE", "One, Two, Three, ...") , 61 /* TEXT_CARDINAL */ },
+ { NC_("RID_SVXSTRARY_NUMBERINGTYPE", "First, Second, Third, ...") , 62 /* TEXT_ORDINAL */ },
{ NC_("RID_SVXSTRARY_NUMBERINGTYPE", "A, .., AA, .., AAA, ...") , 9 /* SVX_NUM_CHARS_UPPER_LETTER_N */ },
{ NC_("RID_SVXSTRARY_NUMBERINGTYPE", "a, .., aa, .., aaa, ...") , 10 /* SVX_NUM_CHARS_LOWER_LETTER_N */ },
{ NC_("RID_SVXSTRARY_NUMBERINGTYPE", "Native Numbering") , 12 /* NATIVE_NUMBERING */ },
diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx
index 7d5bc9f4a374..fe6476a93fde 100644
--- a/sw/inc/numrule.hxx
+++ b/sw/inc/numrule.hxx
@@ -22,6 +22,7 @@
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <editeng/numitem.hxx>
+#include <i18nlangtag/lang.h>
#include "swdllapi.h"
#include "swtypes.hxx"
#include "calbck.hxx"
@@ -166,7 +167,8 @@ public:
const bool bInclStrings = true,
const bool bOnlyArabic = false,
const unsigned int _nRestrictToThisLevel = MAXLEVEL,
- Extremities* pExtremities = nullptr ) const;
+ Extremities* pExtremities = nullptr,
+ LanguageType nLang = LANGUAGE_SYSTEM) const;
OUString MakeRefNumString( const SwNodeNum& rNodeNum,
const bool bInclSuperiorNumLabels,
const int nRestrictInclToThisLevel ) const;
diff --git a/sw/qa/extras/odfexport/data/spellout-numberingtypes.odt b/sw/qa/extras/odfexport/data/spellout-numberingtypes.odt
new file mode 100644
index 000000000000..194920b5d91b
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/spellout-numberingtypes.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index d1d544ea22e5..c2da82ffcaa3 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1981,6 +1981,32 @@ DECLARE_ODFEXPORT_TEST(testChapterNumberingNewLine, "chapter-number-new-line.odt
sal_Int16(SvxNumberFormat::NEWLINE), hashMap["LabelFollowedBy"].get<sal_Int16>());
}
+DECLARE_ODFEXPORT_TEST(testSpellOutNumberingTypes, "spellout-numberingtypes.odt")
+{
+ // ordinal indicator, ordinal and cardinal number numbering styles (from LibreOffice 6.1)
+ const char* aFieldTexts[] = { "1st", "First", "One" };
+ // fallback for old platforms without std::codecvt and std::regex supports
+ const char* aFieldTextFallbacks[] = { "Ordinal-number 1", "Ordinal 1", "1" };
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ // update text field content
+ uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
+
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+
+ for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(aFieldTexts); i++)
+ {
+ uno::Any aField = xFields->nextElement();
+ uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY);
+ if (xServiceInfo->supportsService("com.sun.star.text.textfield.PageNumber"))
+ {
+ uno::Reference<text::XTextContent> xField(aField, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(true, OUString::fromUtf8(aFieldTexts[i]).equals(xField->getAnchor()->getString()) ||
+ OUString::fromUtf8(aFieldTextFallbacks[i]).equals(xField->getAnchor()->getString()));
+ }
+ }
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 2b7047b57535..a4bb0ab1e7eb 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -621,7 +621,8 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto
const bool bInclStrings,
const bool bOnlyArabic,
const unsigned int _nRestrictToThisLevel,
- SwNumRule::Extremities* pExtremities ) const
+ SwNumRule::Extremities* pExtremities,
+ LanguageType nLang ) const
{
OUString aStr;
@@ -657,6 +658,8 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto
}
}
+ css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang));
+
for( ; i <= nLevel; ++i )
{
const SwNumFormat& rNFormat = Get( i );
@@ -673,7 +676,7 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto
if( bOnlyArabic )
aStr += OUString::number( rNumVector[ i ] );
else
- aStr += rNFormat.GetNumStr( rNumVector[ i ] );
+ aStr += rNFormat.GetNumStr( rNumVector[ i ], aLocale );
}
else
aStr += "0"; // all 0 level are a 0
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 3ef80bd0d93f..93f753645c41 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2779,7 +2779,9 @@ OUString SwTextNode::GetNumString( const bool _bInclPrefixAndSuffixStrings,
return pRule->MakeNumString( GetNum()->GetNumberVector(),
_bInclPrefixAndSuffixStrings,
false,
- _nRestrictToThisLevel );
+ _nRestrictToThisLevel,
+ nullptr,
+ GetLang(0));
}
}
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index 7fdf77f71b38..91a5bd078590 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -120,6 +120,7 @@ class SvtPathOptions_Impl
const OUString& GetWorkPath() { return GetPath( SvtPathOptions::PATH_WORK ); }
const OUString& GetUIConfigPath() { return GetPath( SvtPathOptions::PATH_UICONFIG ); }
const OUString& GetFingerprintPath() { return GetPath( SvtPathOptions::PATH_FINGERPRINT ); }
+ const OUString& GetNumbertextPath() { return GetPath( SvtPathOptions::PATH_NUMBERTEXT ); }
const OUString& GetClassificationPath() { return GetPath( SvtPathOptions::PATH_CLASSIFICATION ); }
// set the paths
@@ -195,6 +196,7 @@ static const PropertyStruct aPropNames[] =
{ "Work", SvtPathOptions::PATH_WORK },
{ "UIConfig", SvtPathOptions::PATH_UICONFIG },
{ "Fingerprint", SvtPathOptions::PATH_FINGERPRINT },
+ { "Numbertext", SvtPathOptions::PATH_NUMBERTEXT },
{ "Classification", SvtPathOptions::PATH_CLASSIFICATION }
};
@@ -538,6 +540,11 @@ const OUString& SvtPathOptions::GetFingerprintPath() const
return pImpl->GetFingerprintPath();
}
+const OUString& SvtPathOptions::GetNumbertextPath() const
+{
+ return pImpl->GetNumbertextPath();
+}
+
const OUString& SvtPathOptions::GetModulePath() const
{
return pImpl->GetModulePath();
@@ -783,6 +790,7 @@ bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath )
case PATH_WORK: aPath = GetWorkPath(); break;
case PATH_UICONFIG: aPath = pImpl->GetUIConfigPath(); break;
case PATH_FINGERPRINT: aPath = GetFingerprintPath(); break;
+ case PATH_NUMBERTEXT: aPath = GetNumbertextPath(); break;
case PATH_CLASSIFICATION: aPath = GetClassificationPath(); break;
// coverity[dead_error_begin] - following conditions exist to avoid compiler warning
case PATH_USERCONFIG: