Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


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.
From d04ad728a0e4c7376eac28d742046dae9b10d3c3 Mon Sep 17 00:00:00 2001
From: Mohammad Elahi <ElahiMohammad@gmail.com>
Date: Sat, 27 Aug 2011 03:37:21 +0430
Subject: [PATCH] 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.
---
 .../defaultnumberingprovider.cxx                   |  110 ++++++++++++++++++++
 1 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx 
b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index e315dad..6ce448a 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -208,6 +208,56 @@ static sal_Unicode lowerLetter[] = {
     0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A 
 };
 
+// Tables used for numbering in persian words
+static sal_Unicode *table_PersianWord_decade1[]={
+    (sal_Unicode[]){0}, // 0
+    (sal_Unicode[]){0x06cc, 0x06a9, 0}, // 1
+    (sal_Unicode[]){0x062f,0x0648, 0}, // 2
+    (sal_Unicode[]){0x0633,0x0647, 0}, // 3
+    (sal_Unicode[]){0x0686,0x0647,0x0627,0x0631, 0}, // 4
+    (sal_Unicode[]){0x067e,0x0646,0x062c, 0}, // 5
+    (sal_Unicode[]){0x0634,0x0634, 0}, // 6
+    (sal_Unicode[]){0x0647,0x0641,0x062a, 0}, // 7
+    (sal_Unicode[]){0x0647,0x0634,0x062a, 0}, // 8
+    (sal_Unicode[]){0x0646,0x0647, 0}, // 9
+    (sal_Unicode[]){0x062f, 0x0647, 0}, // 10
+    (sal_Unicode[]){0x06cc, 0x0627, 0x0632, 0x062f, 0x0647, 0}, // 11
+    (sal_Unicode[]){0x062f, 0x0648, 0x0627, 0x0632, 0x062f, 0x0647, 0}, // 12
+    (sal_Unicode[]){0x0633, 0x06cc, 0x0632, 0x062f, 0x0647, 0}, // 13
+    (sal_Unicode[]){0x0686, 0x0647, 0x0627, 0x0631, 0x062f, 0x0647, 0}, // 14
+    (sal_Unicode[]){0x067e, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 15
+    (sal_Unicode[]){0x0634, 0x0627, 0x0646, 0x0632, 0x062f, 0x0647, 0}, // 16
+    (sal_Unicode[]){0x0647, 0x0641, 0x062f, 0x0647, 0}, // 17
+    (sal_Unicode[]){0x0647, 0x062c, 0x062f, 0x0647, 0}, // 18
+    (sal_Unicode[]){0x0646, 0x0648, 0x0632, 0x062f, 0x0647, 0}}; // 19
+
+static sal_Unicode *table_PersianWord_decade2[]={
+    (sal_Unicode[]){0x0628, 0x06cc, 0x0633, 0x062a, 0}, // 20
+    (sal_Unicode[]){0x0633, 0x06cc, 0}, // 30
+    (sal_Unicode[]){0x0686, 0x0647, 0x0644, 0}, // 40
+    (sal_Unicode[]){0x067e, 0x0646, 0x062c, 0x0627, 0x0647, 0}, // 50
+    (sal_Unicode[]){0x0634, 0x0635, 0x062a, 0}, // 60
+    (sal_Unicode[]){0x0647, 0x0641, 0x062a, 0x0627, 0x062f, 0}, // 70
+    (sal_Unicode[]){0x0647, 0x0634, 0x062a, 0x0627, 0x062f, 0}, // 80
+    (sal_Unicode[]){0x0646, 0x0648, 0x062f, 0}}; // 90
+
+static sal_Unicode *table_PersianWord_decade3[]={
+    (sal_Unicode[]){0x0635, 0x062f, 0}, // 100
+    (sal_Unicode[]){0x062f, 0x0648, 0x06cc, 0x0633, 0x062a, 0}, // 200
+    (sal_Unicode[]){0x0633, 0x06cc, 0x0635, 0x062f, 0}, // 300
+    (sal_Unicode[]){0x0686, 0x0647, 0x0627, 0x0631, 0x0635, 0x062f, 0}, // 400
+    (sal_Unicode[]){0x067e, 0x0627, 0x0646, 0x0635, 0x062f, 0}, // 500
+    (sal_Unicode[]){0x0634, 0x0635, 0x062f, 0}, // 600
+    (sal_Unicode[]){0x0647, 0x0641, 0x062a, 0x0635, 0x062f, 0}, // 700
+    (sal_Unicode[]){0x0647, 0x0634, 0x062a, 0x0635, 0x062f, 0}, // 800
+    (sal_Unicode[]){0x0646, 0x0647, 0x0635, 0x062f, 0}}; // 900
+
+static sal_Unicode *table_PersianWord_decadeX[]={
+    (sal_Unicode[]){0x0647, 0x0632, 0x0627, 0x0631, 0}, // 1000
+    (sal_Unicode[]){0x0645, 0x06cc, 0x0644, 0x06cc, 0x0648, 0x0646, 0}, // 1000000
+    (sal_Unicode[]){0x0645, 0x06cc, 0x0644, 0x06cc, 0x0627, 0x0631, 0x062f, 0}}; // 1000000000
+
+
 DefaultNumberingProvider::DefaultNumberingProvider( const Reference < XMultiServiceFactory >& xMSF 
) : xSMgr(xMSF),translit(NULL)
 {
         
@@ -333,6 +383,61 @@ 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 upto 999999999 */
+static
+void lcl_formatPersianWord(unsigned int aNumber, OUString& rsResult)
+{
+    // Formats numbers in persian word up to 999999999999 which is high enough for showing int
+    OUString asTemp;
+    unsigned char anDigit;
+    OUString asPersianWord_conjunction=OUString((sal_Unicode[]){0x20,0x0648,0x20,0});
+    unsigned char anSection=0;
+
+    //if(n>999999999999)
+    //    return;
+
+    while(int anPart=aNumber%1000)
+    {
+        if(anSection)
+            
asTemp=OUString(table_PersianWord_decadeX[anSection-1])+asPersianWord_conjunction+asTemp;
+
+        if((anDigit=anPart%100)<20)
+        {
+            if(!asTemp.isEmpty())
+                asTemp=OUString(0x0020)+asTemp;
+
+            asTemp=OUString(table_PersianWord_decade1[anDigit])+asTemp;
+        }
+        else
+        {
+            if((anDigit=anPart%10))
+            {
+                if(!asTemp.isEmpty())
+                    asTemp=asPersianWord_conjunction+asTemp;
+
+                asTemp=OUString(table_PersianWord_decade1[anDigit])+asTemp;
+            }
+            if((anDigit=(anPart/10)%10))
+            {
+                if(!asTemp.isEmpty())
+                    asTemp=asPersianWord_conjunction+asTemp;
+                asTemp=OUString(table_PersianWord_decade2[anDigit-2])+asTemp;
+            }
+        }
+
+        if((anDigit=anPart/100))
+        {
+            if(!asTemp.isEmpty())
+                asTemp=asPersianWord_conjunction+asTemp;
+            asTemp=OUString(table_PersianWord_decade3[anDigit-1])+asTemp;
+        }
+
+        aNumber/=1000;
+        anSection++;
+    }
+    rsResult+=asTemp;
+}
+
 // Greek Letter Numbering
 
 // KERAIA separates numerals from other text
@@ -730,6 +835,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();
@@ -814,6 +923,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},
 };
-- 
1.7.4.1

From 30b390bc90c55cc5c414bdd2bf74e6a5f163f9de Mon Sep 17 00:00:00 2001
From: Mohammad Elahi <ElahiMohammad@gmail.com>
Date: Sat, 27 Aug 2011 03:40:03 +0430
Subject: [PATCH] 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.
---
 offapi/com/sun/star/style/NumberingType.idl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/offapi/com/sun/star/style/NumberingType.idl 
b/offapi/com/sun/star/style/NumberingType.idl
index 0b4c7ca..8646709 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -485,6 +485,13 @@ published constants NumberingType
      */
     const short CHARS_GREEK_LOWER_LETTER = 53;
 
+    //-------------------------------------------------------------------------
+    /** Numbering in Persian words
+
+        @since OOo 3.5
+     */
+    const short CHARS_PERSIAN_WORD = 55;
+
 };
 
 //=============================================================================
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.