[PATCH 3/3] Replace simple one line functions with macros

Khaled Hosny khaledhosny at eglug.org
Wed Aug 31 16:21:12 PDT 2011


---
 sw/source/core/text/porlay.cxx |   94 +++++++--------------------------------
 1 files changed, 17 insertions(+), 77 deletions(-)

diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 4b8e2ad..05e48f5 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -68,82 +68,22 @@ using namespace i18n::ScriptType;
 #include <unicode/ubidi.h>
 #include <i18nutil/unicode.hxx>  //unicode::getUnicodeScriptType
 
-sal_Bool isAlefChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_ALEF;
-}
-
-sal_Bool isWawChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_WAW;
-}
-
-sal_Bool isDalChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_DAL;
-}
-
-sal_Bool isRehChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_REH;
-}
-
-sal_Bool isTehMarbutaChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_TEH_MARBUTA;
-}
-
-sal_Bool isBaaChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_BEH;
-}
-
-sal_Bool isYehChar ( xub_Unicode cCh )
-{
-    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 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 u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_HAH;
-}
-
-sal_Bool isAinChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_AIN;
-}
-
-sal_Bool isKafChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_KAF;
-}
-
-sal_Bool isLamChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_LAM;
-}
-
-sal_Bool isGafChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_GAF;
-}
-
-sal_Bool isQafChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_QAF;
-}
-
-sal_Bool isFeChar ( xub_Unicode cCh )
-{
-    return u_getIntPropertyValue( cCh, UCHAR_JOINING_GROUP ) == U_JG_FEH;
-}
+#define IS_JOINING_GROUP(c, g) ( u_getIntPropertyValue( c, UCHAR_JOINING_GROUP ) == U_JG_##g )
+#define isAinChar(c)        IS_JOINING_GROUP(c, AIN)
+#define isAlefChar(c)       IS_JOINING_GROUP(c, ALEF)
+#define isBaaChar(c)        IS_JOINING_GROUP(c, BEH)
+#define isDalChar(c)        IS_JOINING_GROUP(c, DAL)
+#define isFehChar(c)        IS_JOINING_GROUP(c, FEH)
+#define isGafChar(c)        IS_JOINING_GROUP(c, GAF)
+#define isHahChar(c)        IS_JOINING_GROUP(c, HAH)
+#define isKafChar(c)        IS_JOINING_GROUP(c, KAF)
+#define isLamChar(c)        IS_JOINING_GROUP(c, LAM)
+#define isQafChar(c)        IS_JOINING_GROUP(c, QAF)
+#define isRehChar(c)        IS_JOINING_GROUP(c, REH)
+#define isTehMarbutaChar(c) IS_JOINING_GROUP(c, TEH_MARBUTA)
+#define isWawChar(c)        IS_JOINING_GROUP(c, WAW)
+#define isYehChar(c)        (IS_JOINING_GROUP(c, YEH) || IS_JOINING_GROUP(c, FARSI_YEH))
+#define isSeenOrSadChar(c)  (IS_JOINING_GROUP(c, SAD) || IS_JOINING_GROUP(c, SEEN))
 
 sal_Bool isTransparentChar ( xub_Unicode cCh )
 {
@@ -1185,7 +1125,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
                                                     // final form may appear in the middle of word
                              (( isAinChar ( cCh ) ||  // Ain (dual joining)
                                 isQafChar ( cCh ) ||  // Qaf (dual joining)
-                                isFeChar  ( cCh ) )   // Feh (dual joining)
+                                isFehChar ( cCh ) )   // Feh (dual joining)
                                 && nIdx == nWordLen - 1))  // only at end of word
                         {
                             OSL_ENSURE( 0 != cPrevCh, "No previous character" );
-- 
1.7.0.4


--MGYHOYXEY6WxJCY8--


More information about the LibreOffice mailing list