[Libreoffice-commits] core.git: editeng/source include/i18nutil include/rtl sw/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 12 14:29:16 UTC 2019


 editeng/source/editeng/impedit2.cxx |    6 +++---
 include/i18nutil/unicode.hxx        |   25 +++++++++++++++++++++++++
 include/rtl/character.hxx           |   29 -----------------------------
 sw/source/uibase/wrtsh/delete.cxx   |    5 +++--
 4 files changed, 31 insertions(+), 34 deletions(-)

New commits:
commit c1399e497191f295b9c3db95d126ff6a4fa5891d
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Jun 12 11:22:29 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Jun 12 16:27:57 2019 +0200

    Move isIVSSelector, isCJKIVSCharacter to i18nutil/unicode.hxx
    
    6a7db071c75609093fc3a9cbc297b8069726a33e "tdf#125497 allow backspace to remove
    CJK IVS" had moved these functions from sw/source/uibase/wrtsh/delete.cxx to
    rtl/character.hxx, but the latter appears to be a less than ideal home for them:
    For one, it is part of the stable URE interface, which makes it harder to
    maintain (e.g., later versions of Unicode have added CJK Extension C--F code
    blocks, which the current implementation of isCJKIVSCharacter does not reflect).
    And for another, besides details of legacy/ubiquitous ASCII, it only deals with
    the "hard" structure of Unicode (isUnicodeCodePoint, isSurrogate, etc.), not
    with any specific code blocks or character classifications (which can change
    over time).  Internal i18nutil/unicode.hxx appears to be better suited.
    
    Change-Id: I88b3e4e2488411f988c1a20f79b8a58626d93dce
    Reviewed-on: https://gerrit.libreoffice.org/73873
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 58629d811b1b..472a3d78de14 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -60,7 +60,7 @@
 #include <sot/exchange.hxx>
 #include <sot/formats.hxx>
 #include <svl/asiancfg.hxx>
-#include <rtl/character.hxx>
+#include <i18nutil/unicode.hxx>
 #include <comphelper/lok.hxx>
 #include <unotools/configmgr.hxx>
 
@@ -2308,8 +2308,8 @@ EditPaM ImpEditEngine::DeleteLeftOrRight( const EditSelection& rSel, sal_uInt8 n
             {
                 const OUString& rString = aCurPos.GetNode()->GetString();
                 sal_Int32 nCode = rString.iterateCodePoints(&nIndex, -1);
-                if (rtl::isIVSSelector(nCode) && nIndex > 0 &&
-                        rtl::isCJKIVSCharacter(rString.iterateCodePoints(&nIndex, -1)))
+                if (unicode::isIVSSelector(nCode) && nIndex > 0 &&
+                        unicode::isCJKIVSCharacter(rString.iterateCodePoints(&nIndex, -1)))
                 {
                     nCharMode = i18n::CharacterIteratorMode::SKIPCELL;
                 }
diff --git a/include/i18nutil/unicode.hxx b/include/i18nutil/unicode.hxx
index b3563e529a38..c0b20a33cba8 100644
--- a/include/i18nutil/unicode.hxx
+++ b/include/i18nutil/unicode.hxx
@@ -47,6 +47,31 @@ public:
     static bool isSpace( const sal_Unicode ch);
     static bool isWhiteSpace( const sal_Unicode ch);
 
+    /** Check for Unicode variation sequence selectors
+
+        @param nCode  A Unicode code point.
+
+        @return  True if code is an Unicode variation sequence selector.
+     */
+    static bool isIVSSelector(sal_uInt32 nCode)
+    {
+        return (nCode >= 0xFE00 && nCode <= 0xFE0F)   // Variation Selectors block
+            || (nCode >= 0xE0100 && nCode <= 0xE01EF);// Variation Selectors Supplement block
+    }
+
+    /** Check for base characters of a CJK ideographic variation sequence (IVS)
+
+        @param nCode  A Unicode code point.
+
+        @return  True if code is an Unicode base character part of CJK IVS
+     */
+    static bool isCJKIVSCharacter(sal_uInt32 nCode)
+    {
+        return (nCode >= 0x4E00 && nCode <= 0x9FFF)       // CJK Unified Ideographs
+            || (nCode >= 0x3400 && nCode <= 0x4DBF)       // CJK Unified Ideographs Extension A
+            || (nCode >= 0x20000 && nCode <= 0x2A6DF);    // CJK Unified Ideographs Extension B
+    }
+
     //Map an ISO 15924 script code to Latin/Asian/Complex/Weak
     static sal_Int16 getScriptClassFromUScriptCode(UScriptCode eScript);
 
diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx
index 102c411cb79a..a18d05d6a5e8 100644
--- a/include/rtl/character.hxx
+++ b/include/rtl/character.hxx
@@ -57,35 +57,6 @@ inline bool isAscii(sal_uInt32 code)
     return code <= 0x7F;
 }
 
-/** Check for Unicode variation sequence selectors
-
-    @param nCode  A Unicode code point.
-
-    @return  True if code is an Unicode variation sequence selector.
-
-    @since LibreOffice 6.3
- */
-inline bool isIVSSelector(sal_uInt32 nCode)
-{
-    return (nCode >= 0xFE00 && nCode <= 0xFE0F)   // Variation Selectors block
-        || (nCode >= 0xE0100 && nCode <= 0xE01EF);// Variation Selectors Supplement block
-}
-
-/** Check for base characters of a CJK ideographic variation sequence (IVS)
-
-    @param nCode  A Unicode code point.
-
-    @return  True if code is an Unicode base character part of CJK IVS
-
-    @since LibreOffice 6.3
- */
-inline bool isCJKIVSCharacter(sal_uInt32 nCode)
-{
-    return (nCode >= 0x4E00 && nCode <= 0x9FFF)       // CJK Unified Ideographs
-        || (nCode >= 0x3400 && nCode <= 0x4DBF)       // CJK Unified Ideographs Extension A
-        || (nCode >= 0x20000 && nCode <= 0x2A6DF);    // CJK Unified Ideographs Extension B
-}
-
 #if defined LIBO_INTERNAL_ONLY
 bool isAscii(char) = delete;
 bool isAscii(signed char) = delete;
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index bddd1daaa9d2..4675bcad5149 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -23,6 +23,7 @@
 #include <view.hxx>
 #include <drawbase.hxx>
 #include <unobaseclass.hxx>
+#include <i18nutil/unicode.hxx>
 #include <rtl/character.hxx>
 
 inline void SwWrtShell::OpenMark()
@@ -251,14 +252,14 @@ bool SwWrtShell::DelLeft()
                 nCode = sStr.iterateCodePoints( &nIndex );
             }
 
-            if ( rtl::isIVSSelector( nCode ) )
+            if ( unicode::isIVSSelector( nCode ) )
             {
                 SwCursorShell::Push();
                 SwCursorShell::Left(1, CRSR_SKIP_CHARS);
                 OUString sStr = GetSelText();
                 sal_Int32 nIndex = 0;
                 nCode = sStr.iterateCodePoints( &nIndex );
-                if ( rtl::isCJKIVSCharacter( nCode ) )
+                if ( unicode::isCJKIVSCharacter( nCode ) )
                     SwCursorShell::Pop( SwCursorShell::PopMode::DeleteStack );
                 else
                     SwCursorShell::Pop( SwCursorShell::PopMode::DeleteCurrent ); // For the weak script.


More information about the Libreoffice-commits mailing list