editeng/source/editeng/impedit2.cxx |    8 +++-----
 include/i18nutil/unicode.hxx        |   13 -------------
 sw/qa/extras/uiwriter/uiwriter6.cxx |   18 +++++++-----------
 sw/source/uibase/wrtsh/delete.cxx   |   31 +++++++++++++------------------
 4 files changed, 23 insertions(+), 47 deletions(-)

New commits:
commit 97aff867f519d7bcb530486208faec68671190a9
Author:     Khaled Hosny <[email protected]>
AuthorDate: Thu Jun 22 11:39:00 2023 +0300
Commit:     خالد حسني <[email protected]>
CommitDate: Fri Jun 23 04:58:22 2023 +0200

    Remove recently unused unicode::isCJKIVSCharacter()
    
    Change-Id: I7d41657e2611aa66303f9315ff6e36a8e08d8688
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153453
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <[email protected]>

diff --git a/include/i18nutil/unicode.hxx b/include/i18nutil/unicode.hxx
index 3b8091db0c24..69e3e9d6e267 100644
--- a/include/i18nutil/unicode.hxx
+++ b/include/i18nutil/unicode.hxx
@@ -61,19 +61,6 @@ public:
         return u_getIntPropertyValue(nCode, UCHAR_VARIATION_SELECTOR) != 0;
     }
 
-    /** Check for base characters of a CJK ideographic variation sequence (IVS)
-
-        @param nCode  A Unicode code point.
-
-        @return  True if code is a 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);
 
commit 96964547dc40b9d6396aad40c29709bb83070fee
Author:     Khaled Hosny <[email protected]>
AuthorDate: Thu Jun 22 11:34:50 2023 +0300
Commit:     خالد حسني <[email protected]>
CommitDate: Fri Jun 23 04:58:13 2023 +0200

    Make backscpace always delete whole variation sequences
    
    We don’t want to limit this to CJK chars, since variation selectors can
    be used with Emoji, mathematical symbol, and possibly more in the
    future, and in all these cases the character + variation selector is
    considered one unit.
    
    Change-Id: Ifc41183ec27a9e3715058cc0b5865a5bd4fcaa69
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153452
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <[email protected]>

diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 1ce5f87e0593..664c8f5d18f0 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2361,17 +2361,15 @@ EditPaM ImpEditEngine::DeleteLeftOrRight( const 
EditSelection& rSel, sal_uInt8 n
         if ( nDelMode == DeleteMode::Simple )
         {
             sal_uInt16 nCharMode = i18n::CharacterIteratorMode::SKIPCHARACTER;
-            // Check if we are deleting a CJK ideograph variance sequence 
(IVS).
+            // If we are deleting a variation selector, we want to delete the
+            // whole sequence (cell).
             sal_Int32 nIndex = aCurPos.GetIndex();
             if (nIndex > 0)
             {
                 const OUString& rString = aCurPos.GetNode()->GetString();
                 sal_Int32 nCode = rString.iterateCodePoints(&nIndex, -1);
-                if (unicode::isVariationSelector(nCode) && nIndex > 0 &&
-                        
unicode::isCJKIVSCharacter(rString.iterateCodePoints(&nIndex, -1)))
-                {
+                if (unicode::isVariationSelector(nCode))
                     nCharMode = i18n::CharacterIteratorMode::SKIPCELL;
-                }
             }
             aDelStart = CursorLeft(aCurPos, nCharMode);
         }
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 3c7f616a5be3..78b5e9ac5ec1 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -695,26 +695,22 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf113481)
     const uno::Reference<text::XTextRange> xPara1 = getParagraph(1);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xPara1->getString().getLength());
 
-    // In case that weak script is treated as CJK script, remove one character.
+    // Also variation sequence of weak characters that are treated as CJK 
script
     pWrtShell->Down(false);
     pWrtShell->EndPara();
     // Before: U+4E2D U+2205 U+FE00. After: U+4E2D U+2205
-    if (pWrtShell->GetScriptType() == SvtScriptType::ASIAN)
-    {
-        pWrtShell->DelLeft();
-        const uno::Reference<text::XTextRange> xPara2 = getParagraph(2);
-        CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xPara2->getString().getLength());
-        CPPUNIT_ASSERT_EQUAL(u'\x2205', xPara2->getString()[1]);
-    }
+    pWrtShell->DelLeft();
+    const uno::Reference<text::XTextRange> xPara2 = getParagraph(2);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPara2->getString().getLength());
+    CPPUNIT_ASSERT_EQUAL(u'\x4E2D', xPara2->getString()[0]);
 
-    // Characters of other scripts, remove one character.
+    // Also variation sequence of other scripts
     pWrtShell->Down(false);
     pWrtShell->EndPara();
     // Before: U+1820 U+180B. After: U+1820
     pWrtShell->DelLeft();
     const uno::Reference<text::XTextRange> xPara3 = getParagraph(3);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPara3->getString().getLength());
-    CPPUNIT_ASSERT_EQUAL(u'\x1820', xPara3->getString()[0]);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xPara3->getString().getLength());
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf115013)
diff --git a/sw/source/uibase/wrtsh/delete.cxx 
b/sw/source/uibase/wrtsh/delete.cxx
index 8c21b35bc12d..e7a09d016587 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -257,26 +257,21 @@ bool SwWrtShell::DelLeft()
 
         OpenMark();
         SwCursorShell::Left(1, SwCursorSkipMode::Chars);
-        if (SvtScriptType::ASIAN == GetScriptType())
+
+        // If we are deleting a variation selector, we want to delete the
+        // whole sequence.
+        sal_uInt32 nCode = GetChar(false);
+        if ( rtl::isSurrogate( nCode ) )
         {
-            sal_uInt32 nCode = GetChar(false);
-            if ( rtl::isSurrogate( nCode ) )
-            {
-                OUString sStr = GetSelText();
-                nCode = sStr.iterateCodePoints( &o3tl::temporary(sal_Int32(0)) 
);
-            }
+            OUString sStr = GetSelText();
+            nCode = sStr.iterateCodePoints( &o3tl::temporary(sal_Int32(0)) );
+        }
 
-            if ( unicode::isVariationSelector( nCode ) )
-            {
-                SwCursorShell::Push();
-                SwCursorShell::Left(1, SwCursorSkipMode::Chars);
-                OUString sStr = GetSelText();
-                nCode = sStr.iterateCodePoints( &o3tl::temporary(sal_Int32(0)) 
);
-                if ( unicode::isCJKIVSCharacter( nCode ) )
-                    SwCursorShell::Pop( SwCursorShell::PopMode::DeleteStack );
-                else
-                    SwCursorShell::Pop( SwCursorShell::PopMode::DeleteCurrent 
); // For the weak script.
-            }
+        if ( unicode::isVariationSelector( nCode ) )
+        {
+            SwCursorShell::Push();
+            SwCursorShell::Left(1, SwCursorSkipMode::Chars);
+            SwCursorShell::Pop( SwCursorShell::PopMode::DeleteStack );
         }
     }
     bool bRet = Delete(true);

Reply via email to