[PATCH 2/3] Use Unicode Joining_Group

Khaled Hosny khaledhosny at eglug.org
Wed Aug 31 15:25:51 PDT 2011


Instead of hard coding code points for character groups, we can use
Unicode Joining_Group that provide the same categorization.
---
 sw/source/core/text/porlay.cxx |   37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 95e638a..4b8e2ad 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -70,82 +70,79 @@ using namespace i18n::ScriptType;
 
 sal_Bool isAlefChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x622 || cCh == 0x623 || cCh == 0x625 || cCh == 0x627 ||
-           cCh == 0x622 || cCh == 0x671 || cCh == 0x672 || cCh == 0x673 || cCh == 0x675 );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_ALEF;
 }
 
 sal_Bool isWawChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x624 || cCh == 0x648 || cCh == 0x676 || cCh == 0x677 ||
-           ( cCh >= 0x6C4 &&  cCh <= 0x6CB ) || cCh == 0x6CF );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_WAW;
 }
 
 sal_Bool isDalChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x62F || cCh == 0x630 || cCh == 0x688 || cCh == 0x689 || cCh == 0x690 );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_DAL;
 }
 
 sal_Bool isRehChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x631 || cCh == 0x632 || ( cCh >= 0x691 && cCh <= 0x699 ));
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_REH;
 }
 
 sal_Bool isTehMarbutaChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x629 || cCh == 0x6C0 );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_TEH_MARBUTA;
 }
 
 sal_Bool isBaaChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x628 || cCh == 0x62A || cCh == 0x62B || cCh == 0x679 || cCh == 0x680 );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_BEH;
 }
 
 sal_Bool isYehChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x626 || cCh == 0x649 || cCh == 0x64A || cCh == 0x678 || cCh == 0x6CC ||
-       cCh == 0x6CE || cCh == 0x6D0 || cCh == 0x6D1 );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_YEH ||
+           u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_FARSI_YEH;
 }
 
 sal_Bool isSeenOrSadChar ( xub_Unicode cCh )
 {
-   return ( ( cCh >= 0x633 && cCh <= 0x636 ) || ( cCh >= 0x69A && cCh <= 0x69E )
-           || cCh == 0x6FA || cCh == 0x6FB );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_SEEN ||
+           u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_SAD;
 }
 
 sal_Bool isHahChar ( xub_Unicode cCh )
 {
-   return ( ( cCh >= 0x62C && cCh <= 0x62E ) || ( cCh >= 0x681 && cCh <= 0x687 )
-           || cCh == 0x6BF );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_HAH;
 }
 
 sal_Bool isAinChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x639 || cCh == 0x63A || cCh == 0x6A0 || cCh == 0x6FC );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_AIN;
 }
 
 sal_Bool isKafChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x643 || ( cCh >= 0x6AC && cCh <= 0x6AE ) );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_KAF;
 }
 
 sal_Bool isLamChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x644 || ( cCh >= 0x6B5 && cCh <= 0x6B8 ) );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_LAM;
 }
 
 sal_Bool isGafChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x6A9 || cCh == 0x6AB ||( cCh >= 0x6AF && cCh <= 0x6B4 ) );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_GAF;
 }
 
 sal_Bool isQafChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x642 || cCh == 0x6A7 || cCh == 0x6A8  );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_QAF;
 }
 
 sal_Bool isFeChar ( xub_Unicode cCh )
 {
-   return ( cCh == 0x641 || ( cCh >= 0x6A1 && cCh <= 0x6A6 ) );
+    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_FEH;
 }
 
 sal_Bool isTransparentChar ( xub_Unicode cCh )
-- 
1.7.0.4


--MGYHOYXEY6WxJCY8
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment; filename="0003-Replace-simple-one-line-functions-with-macros.patch"



More information about the LibreOffice mailing list