tdf#143526 fix and add Korean numbering

fix Korean NumberFormat, compare with MS Word
change mapping of style::NumberingType::NUMBER_HANGUL_KO,
from "koreanLegal" to "koreanCounting"
"koreanDigital" add new reserved words "일, 일영, 일영영, etc"
- style::NumberingType::NUMBER_DIGITAL_KO
"koreanLegal" is new reserved words "하나, 둘, 셋, 넷, 다섯, 여섯, 일곱, 여덟, 아홉, 열"
- style::NumberingType::NUMBER_LEGAL_KO
"koreanDigital2" is new reserved words "一, 一零, 一零零, etc"
 - style::NumberingType::NUMBER_DIGITAL2_KO

Reference:
1: "[MS-OE376]: Office Implementation Information for ECMA-376 Standards Support"
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-oe376/a5deef83-bb01-410f-bde0-9c35abe4ca52
2.1.350 Part 4 Section 2.13.5.30, numberingChange (Previous Paragraph Numbering Properties)

2: "[MS-DOCX]: Word Extensions to the Office Open XML (.docx) File Format" shows example of not only Korean Numbering also others Numbering examples.
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-docx/b839fe1f-e1ca-4fa6-8c26-5954d0abbccd
2.4 numFmt Extensions
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-docx/a1bb5809-e361-4e49-8e16-7f1a67da4121

Change-Id: I535b2aa3cf4111d86b9b7b788afe4aa64e8e4545
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119518
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index dadfc13..b7ee64c 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -288,6 +288,29 @@ const sal_Unicode table_PersianWord_decadeX[][8]={
    {0x0645, 0x06cc, 0x0644, 0x06cc, 0x0627, 0x0631, 0x062f, 0} // 1000000000
};

const sal_Unicode table_KoreanLegalWord_decade1[][3] = {
    {0xd558, 0xb098, 0}, // 1
    {0xb458, 0},         // 2
    {0xc14b, 0},         // 3
    {0xb137, 0},         // 4
    {0xb2e4, 0xc12f, 0}, // 5
    {0xc5ec, 0xc12f, 0}, // 6
    {0xc77c, 0xacf1, 0}, // 7
    {0xc5ec, 0xb35f, 0}, // 8
    {0xc544, 0xd649, 0}  // 9
};

const sal_Unicode table_KoreanLegalWord_decade2[][3] = {
    {0xc5f4, 0},          // 10
    {0xc2a4, 0xbb3c, 0},  // 20
    {0xc11c, 0xb978, 0},  // 30
    {0xb9c8, 0xd754, 0},  // 40
    {0xc270, 0},          // 50
    {0xc608, 0xc21c, 0},  // 60
    {0xc77c, 0xd754, 0},  // 70
    {0xc5ec, 0xb4e0, 0},  // 80
    {0xc544, 0xd754, 0}   // 90
};

DefaultNumberingProvider::DefaultNumberingProvider( const Reference < XComponentContext >& rxContext ) : m_xContext(rxContext)
{
@@ -468,6 +491,16 @@ void lcl_formatPersianWord( sal_Int32 nNumber, OUString& rsResult )
    rsResult += aTemp;
}

static void lcl_formatKoreanLegalWord(sal_Int32 nNumber, OUString& rsResult) {
    OUStringBuffer aTemp(64);
    int digit1 = nNumber % 10;
    int digit2 = nNumber / 10;
    if (digit1 > 0)
        aTemp.insert(0, (table_KoreanLegalWord_decade1[digit1 - 1]));
    if (digit2 > 0)
        aTemp.insert(0, (table_KoreanLegalWord_decade2[digit2 - 1]));
    rsResult += aTemp.makeStringAndClear();
}

// Greek Letter Numbering

@@ -743,6 +776,25 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
                natNum = NativeNumberMode::NATNUM11;
                locale.Language = "ko";
                break;
          case NUMBER_DIGITAL_KO:
              natNum = NativeNumberMode::NATNUM9;
              locale.Language = "ko";
              break;
          case NUMBER_DIGITAL2_KO:
              natNum = NativeNumberMode::NATNUM1;
              locale.Language = "ko";
              break;
          case NUMBER_LEGAL_KO:
              if (number < 1 || number >= 100)
              {
                  natNum = NativeNumberMode::NATNUM11;
                  locale.Language = "ko";
              }
              else
              {
                  lcl_formatKoreanLegalWord(number, result);
              }
              break;

          case CIRCLE_NUMBER:
              table = table_CircledNumber;
@@ -1016,6 +1068,9 @@ const Supported_NumberingType aSupportedTypes[] =
        {style::NumberingType::HANGUL_SYLLABLE_KO,      nullptr, LANG_CJK},
        {style::NumberingType::HANGUL_CIRCLED_JAMO_KO,  nullptr, LANG_CJK},
        {style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO,      nullptr, LANG_CJK},
        {style::NumberingType::NUMBER_LEGAL_KO,         nullptr, LANG_CJK},
        {style::NumberingType::NUMBER_DIGITAL_KO,       nullptr, LANG_CJK},
        {style::NumberingType::NUMBER_DIGITAL2_KO,      nullptr, LANG_CJK},
        {style::NumberingType::CHARS_ARABIC,    nullptr, LANG_CTL},
        {style::NumberingType::CHARS_ARABIC_ABJAD,   nullptr, LANG_CTL},
        {style::NumberingType::NUMBER_ARABIC_INDIC,    S_AR_ONE ", " S_AR_TWO ", " S_AR_THREE ", ...", LANG_CTL},
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index fd19e08..57e98fc 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -526,6 +526,28 @@ published constants NumberingType
        @since LibreOffice 7.1
     */
    const short SZEKELY_ROVAS = 68;

    /** Numbering is in Korean Digital number as
        "일,이,삼,...,일영,일영영, ..."

        @since LibreOffice 7.3
     */
    const short NUMBER_DIGITAL_KO = 69;

    /** Numbering is in Korean Digital Number, reserved "koreanDigital2", as
        "一,二,三,...,一零,一零零, ..."

        @since LibreOffice 7.3
     */
    const short NUMBER_DIGITAL2_KO = 70;

    /** Numbering is in Korean Legal Number, reserved "koreanLegal", as
        "하나,둘,셋,..."

        @since LibreOffice 7.3
     */
    const short NUMBER_LEGAL_KO = 71;

};


diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 46876df..9995afe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -696,7 +696,7 @@ DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist35, "cjklist35.docx")
DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist44, "cjklist44.docx")
{
    sal_Int16   numFormat = getNumberingTypeOfParagraph(1);
    CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_HANGUL_KO, numFormat);
    CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_DIGITAL2_KO, numFormat);
}

DECLARE_OOXMLEXPORT_TEST(testOoxmlTextNumberList, "text_number_list.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index bb8334b..5f325ea 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6992,8 +6992,10 @@ static OString lcl_ConvertNumberingType(sal_Int16 nNumberingType, const SfxItemS
        case style::NumberingType::IROHA_HALFWIDTH_JA: aType="irohaFullWidth";break;
        case style::NumberingType::HANGUL_SYLLABLE_KO: aType="ganada";break;
        case style::NumberingType::HANGUL_JAMO_KO: aType="chosung";break;
        case style::NumberingType::NUMBER_HANGUL_KO: aType="koreanDigital";break;
        case style::NumberingType::NUMBER_UPPER_KO: aType="koreanLegal"; break;
        case style::NumberingType::NUMBER_HANGUL_KO: aType="koreanCounting"; break;
        case style::NumberingType::NUMBER_LEGAL_KO: aType = "koreanLegal"; break;
        case style::NumberingType::NUMBER_DIGITAL_KO: aType = "koreanDigital"; break;
        case style::NumberingType::NUMBER_DIGITAL2_KO: aType = "koreanDigital2"; break;
        case style::NumberingType::CIRCLE_NUMBER: aType="decimalEnclosedCircle"; break;
        case style::NumberingType::CHARS_ARABIC: aType="arabicAlpha"; break;
        case style::NumberingType::CHARS_ARABIC_ABJAD: aType="arabicAbjad"; break;
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 0323b5a..5b93db4 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1561,10 +1561,16 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
            nVal = 25;
            break;
        case style::NumberingType::NUMBER_HANGUL_KO:
            nVal = 41;
            nVal = 42;
            break; // koreanCounting
        case style::NumberingType::NUMBER_DIGITAL_KO:
            nVal = 41; // koreanDigital
            break;
        case style::NumberingType::NUMBER_UPPER_KO:
            nVal = 44;
        case style::NumberingType::NUMBER_DIGITAL2_KO:
            nVal = 44; // koreanDigital2
            break;
        case style::NumberingType::NUMBER_LEGAL_KO:
            nVal = 43; // koreanLegal
            break;

        case SVX_NUM_BITMAP:
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 2d90488..7fe5a33 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -756,8 +756,10 @@ sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
    case style::NumberingType::DI_ZI_ZH: nRet = 31; break;
    case style::NumberingType::NUMBER_UPPER_ZH_TW: nRet = 34;break;
    case style::NumberingType::NUMBER_UPPER_ZH: nRet = 38; break;
    case style::NumberingType::NUMBER_HANGUL_KO: nRet = 41; break;
    case style::NumberingType::NUMBER_UPPER_KO: nRet = 44; break;
    case style::NumberingType::NUMBER_DIGITAL_KO: nRet = 41; break;
    case style::NumberingType::NUMBER_HANGUL_KO: nRet = 42; break;
    case style::NumberingType::NUMBER_LEGAL_KO: nRet = 43; break;
    case style::NumberingType::NUMBER_DIGITAL2_KO: nRet = 44; break;
    case style::NumberingType::NUMBER_HEBREW: nRet = 45; break;
    case style::NumberingType::CHARS_ARABIC: nRet = 46; break;
    case style::NumberingType::CHARS_HEBREW: nRet = 47; break;
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index 6cb238b..307da49 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -562,11 +562,17 @@ sal_Int16 ConvertNumberingType(const sal_Int32 nFmt, const sal_Int16 nDefault)
            nRet = style::NumberingType::HANGUL_JAMO_KO;
            break;
        case NS_ooxml::LN_Value_ST_NumberFormat_koreanLegal:
            nRet = style::NumberingType::NUMBER_LEGAL_KO;
            break;
        case NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital:
            nRet = style::NumberingType::NUMBER_DIGITAL_KO;
            break;
        case NS_ooxml::LN_Value_ST_NumberFormat_koreanCounting:
        case NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital2:
            nRet = style::NumberingType::NUMBER_HANGUL_KO;
            break;
        case NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital2:
            nRet = style::NumberingType::NUMBER_DIGITAL2_KO;
            break;
        case NS_ooxml::LN_Value_ST_NumberFormat_ideographLegalTraditional:
            nRet = style::NumberingType::NUMBER_UPPER_ZH_TW;
            break;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d0bf42c..c5bfed9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3826,6 +3826,12 @@ static sal_Int16 lcl_ParseNumberingType( const OUString& rCommand )
//            ,{"CHINESENUM3", style::NumberingType::}
            ,{"ArabicAlpha", style::NumberingType::CHARS_ARABIC}
            ,{"ArabicAbjad", style::NumberingType::FULLWIDTH_ARABIC}
            ,{"Ganada", style::NumberingType::HANGUL_JAMO_KO}
            ,{"Chosung", style::NumberingType::HANGUL_SYLLABLE_KO}
            ,{"KoreanCounting", style::NumberingType::NUMBER_HANGUL_KO}
            ,{"KoreanLegal", style::NumberingType::NUMBER_LEGAL_KO}
            ,{"KoreanDigital", style::NumberingType::NUMBER_DIGITAL_KO}
            ,{"KoreanDigital2", style::NumberingType::NUMBER_DIGITAL2_KO}
/* possible values:
style::NumberingType::