[Libreoffice-commits] .: 2 commits - i18npool/source offapi/com

Eike Rathke erack at kemper.freedesktop.org
Sat Aug 27 15:01:32 PDT 2011


 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |  132 ++++++++++
 offapi/com/sun/star/style/NumberingType.idl                           |   15 +
 2 files changed, 147 insertions(+)

New commits:
commit b470e596db5b58aed9cf9fd6b90045ab4940c054
Author: Mohammad Elahi <ElahiMohammad at gmail.com>
Date:   Sat Aug 27 03:40:03 2011 +0430

    Add numbering type in persian word.
    
    Numbering in localized persian word is useful in some areas, at least
    for me it is necessary. Since it is not trivial a function and table
    is needed.

diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 35650d9..e2049af 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -215,6 +215,63 @@ static sal_Unicode lowerLetter[] = {
     0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
 };
 
+
+typedef sal_Unicode ArrUnicode[];
+
+// Tables used for numbering in persian words
+static sal_Unicode *table_PersianWord_decade1[]={
+    (ArrUnicode){0},                                                 // 0
+    (ArrUnicode){0x06cc, 0x06a9, 0},                                 // 1
+    (ArrUnicode){0x062f, 0x0648, 0},                                 // 2
+    (ArrUnicode){0x0633, 0x0647, 0},                                 // 3
+    (ArrUnicode){0x0686, 0x0647, 0x0627, 0x0631, 0},                 // 4
+    (ArrUnicode){0x067e, 0x0646, 0x062c, 0},                         // 5
+    (ArrUnicode){0x0634, 0x0634, 0},                                 // 6
+    (ArrUnicode){0x0647, 0x0641, 0x062a, 0},                         // 7
+    (ArrUnicode){0x0647, 0x0634, 0x062a, 0},                         // 8
+    (ArrUnicode){0x0646, 0x0647, 0},                                 // 9
+    (ArrUnicode){0x062f, 0x0647, 0},                                 // 10
+    (ArrUnicode){0x06cc, 0x0627, 0x0632, 0x062f, 0x0647, 0},         // 11
+    (ArrUnicode){0x062f, 0x0648, 0x0627, 0x0632, 0x062f, 0x0647, 0}, // 12
+    (ArrUnicode){0x0633, 0x06cc, 0x0632, 0x062f, 0x0647, 0},         // 13
+    (ArrUnicode){0x0686, 0x0647, 0x0627, 0x0631, 0x062f, 0x0647, 0}, // 14
+    (ArrUnicode){0x067e, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 15
+    (ArrUnicode){0x0634, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 16
+    (ArrUnicode){0x0647, 0x0641, 0x062f, 0x0647, 0},                 // 17
+    (ArrUnicode){0x0647, 0x062c, 0x062f, 0x0647, 0},                 // 18
+    (ArrUnicode){0x0646, 0x0648, 0x0632, 0x062f, 0x0647, 0}          // 19
+};
+
+static sal_Unicode *table_PersianWord_decade2[]={
+    (ArrUnicode){0x0628, 0x06cc, 0x0633, 0x062a, 0},                 // 20
+    (ArrUnicode){0x0633, 0x06cc, 0},                                 // 30
+    (ArrUnicode){0x0686, 0x0647, 0x0644, 0},                         // 40
+    (ArrUnicode){0x067e, 0x0646, 0x062c, 0x0627, 0x0647, 0},         // 50
+    (ArrUnicode){0x0634, 0x0635, 0x062a, 0},                         // 60
+    (ArrUnicode){0x0647, 0x0641, 0x062a, 0x0627, 0x062f, 0},         // 70
+    (ArrUnicode){0x0647, 0x0634, 0x062a, 0x0627, 0x062f, 0},         // 80
+    (ArrUnicode){0x0646, 0x0648, 0x062f, 0}                          // 90
+};
+
+static sal_Unicode *table_PersianWord_decade3[]={
+    (ArrUnicode){0x0635, 0x062f, 0},                                 // 100
+    (ArrUnicode){0x062f, 0x0648, 0x06cc, 0x0633, 0x062a, 0},         // 200
+    (ArrUnicode){0x0633, 0x06cc, 0x0635, 0x062f, 0},                 // 300
+    (ArrUnicode){0x0686, 0x0647, 0x0627, 0x0631, 0x0635, 0x062f, 0}, // 400
+    (ArrUnicode){0x067e, 0x0627, 0x0646, 0x0635, 0x062f, 0},         // 500
+    (ArrUnicode){0x0634, 0x0635, 0x062f, 0},                         // 600
+    (ArrUnicode){0x0647, 0x0641, 0x062a, 0x0635, 0x062f, 0},         // 700
+    (ArrUnicode){0x0647, 0x0634, 0x062a, 0x0635, 0x062f, 0},         // 800
+    (ArrUnicode){0x0646, 0x0647, 0x0635, 0x062f, 0}                  // 900
+};
+
+static sal_Unicode *table_PersianWord_decadeX[]={
+    (ArrUnicode){0x0647, 0x0632, 0x0627, 0x0631, 0},                        // 1000
+    (ArrUnicode){0x0645, 0x06cc, 0x0644, 0x06cc, 0x0648, 0x0646, 0},        // 1000000
+    (ArrUnicode){0x0645, 0x06cc, 0x0644, 0x06cc, 0x0627, 0x0631, 0x062f, 0} // 1000000000
+};
+
+
 DefaultNumberingProvider::DefaultNumberingProvider( const Reference < XMultiServiceFactory >& xMSF ) : xSMgr(xMSF),translit(NULL)
 {
 
@@ -340,6 +397,65 @@ void lcl_formatChars3( sal_Unicode table_capital[], sal_Unicode table_small[], i
          s += OUString::valueOf( table_small[ n%tableSize ] );
 }
 
+
+/** Returns number's representation in persian words up to 999999999999
+    respectively limited by sal_Int32 >=0.
+    The caller assures that nNumber is not negative.
+ */
+static
+void lcl_formatPersianWord( sal_Int32 nNumber, OUString& rsResult )
+    throw( IllegalArgumentException, RuntimeException )
+{
+    OUStringBuffer aTemp(64);
+    unsigned char nDigit;
+    OUString asPersianWord_conjunction( (ArrUnicode){0x20,0x0648,0x20,0});
+    unsigned char nSection = 0;
+
+    while (int nPart = nNumber % 1000)
+    {
+        if (nSection)
+        {
+            if (nSection > SAL_N_ELEMENTS( table_PersianWord_decadeX))
+                throw IllegalArgumentException();   // does not happen with sal_Int32
+            aTemp.insert( 0, asPersianWord_conjunction).insert( 0, table_PersianWord_decadeX[nSection-1]);
+        }
+
+        if ((nDigit = nPart % 100) < 20)
+        {
+            if (aTemp.getLength())
+                aTemp.insert( 0, sal_Unicode(0x0020));
+            aTemp.insert( 0, table_PersianWord_decade1[nDigit]);
+        }
+        else
+        {
+            if ((nDigit = nPart % 10))
+            {
+                if (aTemp.getLength())
+                    aTemp.insert( 0, asPersianWord_conjunction);
+                aTemp.insert( 0, table_PersianWord_decade1[nDigit]);
+            }
+            if ((nDigit = (nPart / 10) % 10))
+            {
+                if (aTemp.getLength())
+                    aTemp.insert( 0, asPersianWord_conjunction);
+                aTemp.insert( 0, table_PersianWord_decade2[nDigit-2]);
+            }
+        }
+
+        if ((nDigit = nPart / 100))
+        {
+            if (aTemp.getLength())
+                aTemp.insert( 0, asPersianWord_conjunction);
+            aTemp.insert( 0, table_PersianWord_decade3[nDigit-1]);
+        }
+
+        nNumber /= 1000;
+        nSection++;
+    }
+    rsResult += aTemp.makeStringAndClear();
+}
+
+
 // Greek Letter Numbering
 
 // KERAIA separates numerals from other text
@@ -740,6 +856,10 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
               lcl_formatChars(table_Alphabet_fa, sizeof(table_Alphabet_fa) / sizeof(sal_Unicode), number - 1, result);
               break;
 
+          case CHARS_PERSIAN_WORD:
+              lcl_formatPersianWord(number, result);
+              break;
+
           default:
                OSL_ASSERT(0);
                throw IllegalArgumentException();
@@ -825,6 +945,7 @@ static const Supported_NumberingType aSupportedTypes[] =
         {style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_SR, C_CYR_A ", " C_CYR_B ", .., " C_CYR_A S_CYR_A ", " C_CYR_B S_CYR_B ", ... (sr)", LANG_ALL},
         {style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_SR, S_CYR_A ", " S_CYR_B ", .., " S_CYR_A S_CYR_A ", " S_CYR_B S_CYR_B ", ... (sr)", LANG_ALL},
         {style::NumberingType::CHARS_PERSIAN,   NULL, LANG_CTL},
+        {style::NumberingType::CHARS_PERSIAN_WORD,   NULL, LANG_CTL},
         {style::NumberingType::CHARS_GREEK_LOWER_LETTER,   C_GR_A ", " C_GR_B ", ... (gr)", LANG_ALL},
         {style::NumberingType::CHARS_GREEK_UPPER_LETTER,   S_GR_A ", " S_GR_B ", ... (gr)", LANG_ALL},
 };
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index 39bbf2c..0c31f26 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -493,6 +493,13 @@ published constants NumberingType
      */
     const short CHARS_ARABIC_ABJAD = 54;
 
+    //-------------------------------------------------------------------------
+    /** Numbering in Persian words
+
+        @since OOo 3.5
+     */
+    const short CHARS_PERSIAN_WORD = 55;
+
 };
 
 //=============================================================================
commit 9e1b651db768667ab7f87d66a225ea008b4bd811
Author: Mohammad Elahi <ElahiMohammad at gmail.com>
Date:   Sat Aug 27 03:48:13 2011 +0430

    Add numbering type of arabic abjad sequence
    
    A localized numbering type base on arabic abjad sequence is
    added base on a table.

diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index c152ea8..35650d9 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -76,6 +76,13 @@ static sal_Unicode table_Alphabet_ar[] = {
     0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649
 };
 
+static sal_Unicode table_Alphabet_ar_abjad[] = {
+    0x0627, 0x0628, 0x062c, 0x062f, 0x0647, 0x0648, 0x0632, 0x062d,
+    0x0637, 0x064a, 0x0643, 0x0644, 0x0645, 0x0646, 0x0633, 0x0639,
+    0x0641, 0x0635, 0x0642, 0x0631, 0x0634, 0x062a, 0x062b, 0x062e,
+    0x0630, 0x0636, 0x0638, 0x063a
+};
+
 static sal_Unicode table_Alphabet_th[] = {
     0x0E01, 0x0E02, 0x0E04, 0x0E07,
     0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
@@ -630,6 +637,9 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
           case CHARS_ARABIC:
               lcl_formatChars(table_Alphabet_ar, sizeof(table_Alphabet_ar) / sizeof(sal_Unicode), number - 1, result);
               break;
+          case CHARS_ARABIC_ABJAD:
+              lcl_formatChars(table_Alphabet_ar_abjad, sizeof(table_Alphabet_ar_abjad) / sizeof(sal_Unicode), number - 1, result);
+              break;
           case CHARS_THAI:
               lcl_formatChars(table_Alphabet_th, sizeof(table_Alphabet_th) / sizeof(sal_Unicode), number - 1, result);
               break;
@@ -794,6 +804,7 @@ static const Supported_NumberingType aSupportedTypes[] =
         {style::NumberingType::HANGUL_CIRCLED_JAMO_KO,  NULL, LANG_CJK},
         {style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO,      NULL, LANG_CJK},
         {style::NumberingType::CHARS_ARABIC,    NULL, LANG_CTL},
+        {style::NumberingType::CHARS_ARABIC_ABJAD,   NULL, LANG_CTL},
         {style::NumberingType::CHARS_THAI,      NULL, LANG_CTL},
         {style::NumberingType::CHARS_HEBREW,    NULL, LANG_CTL},
         {style::NumberingType::CHARS_NEPALI,    NULL, LANG_CTL},
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index da9a986..39bbf2c 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -485,6 +485,14 @@ published constants NumberingType
      */
     const short CHARS_GREEK_LOWER_LETTER = 53;
 
+
+    //-------------------------------------------------------------------------
+    /** Numbering in Arabic alphabet using abjad sequence
+
+        @since OOo 3.5
+     */
+    const short CHARS_ARABIC_ABJAD = 54;
+
 };
 
 //=============================================================================


More information about the Libreoffice-commits mailing list