Adding numeral system

Hello list members,

I would like to add the Slavonic numeral system to LibreOffice to
support page numbering. It is now supported in CLDR:
http://unicode.org/cldr/trac/ticket/7358

Do I just have to add the code to defaultnumberingprovider.cxx or is
it more involved than this? Is it possible to simply support the RBNF
rules provided by CLDR?

Cordially,

Aleksandr

Hi Aleksandr,

I'm adding Eike in copy who will be able to answer you I think :slight_smile:
Cheers
Sophie

Hi Aleksandr,

I would like to add the Slavonic numeral system to LibreOffice to
support page numbering. It is now supported in CLDR:
http://unicode.org/cldr/trac/ticket/7358

Do I just have to add the code to defaultnumberingprovider.cxx or is
it more involved than this?

Maybe you're mixing up things (or I do :wink: defaultnumberingprovider.cxx
is for numbering of paragraphs and outline numbering, not for
implementations of numeral systems. Your case seems to be
transliteration into a different native number system, such code lives
in i18npool/source/nativenumber/nativenumbersupplier.cxx and
i18npool/source/nativenumber/data/* files, and may get used by
transliterations.

In fact the paragraph and outline numbering may use transliterations and
native number systems.

Is it possible to simply support the RBNF
rules provided by CLDR?

You can use icu::RuleBasedNumberFormat instances within the i18npool
code, but what would be "simply support"?

  Eike

Hello Eike,

Hi Aleksandr,

Maybe you're mixing up things (or I do :wink: defaultnumberingprovider.cxx
is for numbering of paragraphs and outline numbering, not for
implementations of numeral systems. Your case seems to be
transliteration into a different native number system, such code lives
in i18npool/source/nativenumber/nativenumbersupplier.cxx and
i18npool/source/nativenumber/data/* files, and may get used by
transliterations.

Ah, OK. Thank you. Now I see the implementation of Hebrew numerals in
nativenumbersupplier.cxx, so it seems like I have to create something
similar for the Slavic numerals.

You can use icu::RuleBasedNumberFormat instances within the i18npool
code, but what would be "simply support"?

My question is whether I can use the RBNF rules already created for
CLDR or if I need to write a C++ implementation for Slavic numerals.
It don't see any usage of RBNF in nativenumbersupplier.cxx, and I
can't seem to find any RBNF rules in the source code.

Thanks,

Aleksandr

Hi Aleksandr,

> You can use icu::RuleBasedNumberFormat instances within the i18npool
> code, but what would be "simply support"?
>

My question is whether I can use the RBNF rules already created for
CLDR or if I need to write a C++ implementation for Slavic numerals.
It don't see any usage of RBNF in nativenumbersupplier.cxx, and I
can't seem to find any RBNF rules in the source code.

Only one place uses it, OrdinalSuffixService::getOrdinalSuffix() in
i18npool/source/ordinalsuffix/ordinalsuffix.cxx with icu::URBNF_ORDINAL.

Note that availability of specific RBNFs depends on the ICU version
LibreOffice is built and linked against, CLDR mentioning something
doesn't necessarily mean it is implemented except maybe in the latest
and greatest ICU, if at all. You'd have to check as of which version
your specific requirement is available, and if quite new then add checks
to autoconf whether the version used to build supports that already and
disable things in code in case it does not.

  Eike

Hello Eike and list members,

I started working on the project of adding Cyrillic numerals, and I
decided that first I would add the digits and then, once I figured
that out, work on the algorithm. However, I am stuck. I've added the
digits to nativenumbersupplier.cxx (see attached), and the software
compiles, but when I attempt to format the digits in the Church Slavic
locale, I get gibberish (some kind of CJK ideographs). There must be
another place that I have to add the information for the native number
support, but I cannot find it, and I cannot find any documentation
that would guide me.

Any help would be greatly appreciated!

Aleksandr

Hi Aleksandr,

I started working on the project of adding Cyrillic numerals, and I
decided that first I would add the digits and then, once I figured
that out, work on the algorithm. However, I am stuck. I've added the
digits to nativenumbersupplier.cxx (see attached)

Btw, the attachment made it only through in my personal copy, it was
stripped on the l10n list. And please use patch attachments that are
produced by git format-patch, not just git show.

, and the software
compiles, but when I attempt to format the digits in the Church Slavic
locale, I get gibberish (some kind of CJK ideographs).

Likely because you forgot to adjust NumberChar_Count in
i18npool/source/nativenumber/data/numberchar.h and instead added
NumberChar_cu after:

--- a/i18npool/source/nativenumber/data/numberchar.h
+++ b/i18npool/source/nativenumber/data/numberchar.h
@@ -54,6 +54,7 @@ static const sal_Int16 NumberChar_he = 28;
static const sal_Int16 NumberChar_ne = 29;
static const sal_Int16 NumberChar_dz = 30;
static const sal_Int16 NumberChar_Count = 31;
+static const sal_Int16 NumberChar_cu = 32;

NumberChar_Count is used to allocate and loop over ranges, see places in
i18npool/source/nativenumber/nativenumbersupplier.cxx where
NumberChar_Count is used. If you access with NumberChar_cu beyond that
you'll get arbitrary memory.

So instead it should be

  +static const sal_Int16 NumberChar_cu = 31;
  -static const sal_Int16 NumberChar_Count = 31;
  +static const sal_Int16 NumberChar_Count = 32;

  Eike

Hello Eike,

Hi Aleksandr,

Likely because you forgot to adjust NumberChar_Count in
i18npool/source/nativenumber/data/numberchar.h and instead added
NumberChar_cu after:

Thanks, that solved the problem!

Cordially,

Aleksandr Andreev

Hello list members!

I have submitted for review a patch to add Cyrillic numerals:
https://gerrit.libreoffice.org/#/c/20013/

Some code is reused from the Hebrew numbers, and could perhaps be merged.

The native numbers work in Calc and for formatting dates, but I cannot get
the page numbering to use these numbers. Is there something else I have to
do?

Aleksandr

Hi Aleksandr,

The native numbers work in Calc and for formatting dates, but I cannot get
the page numbering to use these numbers. Is there something else I have to
do?

That's a bit weird, there is a Native Numbering option available from
the numberings, but only if CTL or Asian languages are enabled under
Tools->Options->LanguageSettings->Languages, because so far it is only
used for those.

Does that work for you if you enable CTL and have a page number or
numbering in a cu-RU attributed paragraph?

  Eike

Hello Eike,

That's a bit weird, there is a Native Numbering option available from
the numberings, but only if CTL or Asian languages are enabled under
Tools->Options->LanguageSettings->Languages, because so far it is only
used for those.

Does that work for you if you enable CTL and have a page number or
numbering in a cu-RU attributed paragraph?

Yes, I can confirm that it works. In addition to enabling CTL, I have to
set the Locale to cu-RU, and not just the Default Language for Documents.

Aleksandr