diff options
author | Mark Hung <marklh9@gmail.com> | 2017-11-09 23:53:19 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2018-01-13 12:07:29 +0100 |
commit | 8c7915eb9693f7c385308ec2b76b1d5b582bceed (patch) | |
tree | 8853ac716ddcb494fe987ba82c299cfdbc1a54b2 /sw/source | |
parent | 085852e2e2779de1712cf18b5e67740cb7a4bcb6 (diff) |
tdf#113481 Let backspace delete complete CJK ideograph IVS.
If the character to be deleted is in CJK script and
is a Unicode variance selector, delete the complete IVS
if the base character is a CJK unified ideograph.
Change-Id: I5d29664d5e964fc685110333f8109b0bfa8e0955
Reviewed-on: https://gerrit.libreoffice.org/44555
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/wrtsh/delete.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index 6c2a7d04d272..2f0be3984c85 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -42,6 +42,25 @@ inline void SwWrtShell::CloseMark( bool bOkFlag ) EndAllAction(); } +namespace { + +inline bool isUnicodeVariationSequenceSelector( sal_uInt32 nCode ) +{ + return ( nCode >= 0xFE00 && nCode <= 0xFE0F ) // Variation Selectors block + || ( nCode >= 0xE0100 && nCode <= 0xE01EF );// Variation Selectors Supplement block +} + +// Return if the chracter might be a base character of a CJK ideographic varaiation sequence +inline bool isCJKIVSCharacters( 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 +} + +} + + // #i23725# bool SwWrtShell::TryRemoveIndent() { @@ -222,6 +241,29 @@ long SwWrtShell::DelLeft() OpenMark(); SwCursorShell::Left(1, CRSR_SKIP_CHARS); + if (SvtScriptType::ASIAN == GetScriptType()) + { + sal_uInt32 nCode = GetChar(false); + if ( rtl::isSurrogate( nCode ) ) + { + OUString sStr = GetSelText(); + sal_Int32 nIndex = 0; + nCode = sStr.iterateCodePoints( &nIndex ); + } + + if ( isUnicodeVariationSequenceSelector( nCode ) ) + { + SwCursorShell::Push(); + SwCursorShell::Left(1, CRSR_SKIP_CHARS); + OUString sStr = GetSelText(); + sal_Int32 nIndex = 0; + nCode = sStr.iterateCodePoints( &nIndex ); + if ( isCJKIVSCharacters( nCode ) ) + SwCursorShell::Pop( SwCursorShell::PopMode::DeleteStack ); + else + SwCursorShell::Pop( SwCursorShell::PopMode::DeleteCurrent ); // For the weak script. + } + } } long nRet = Delete(); if( !nRet && bSwap ) |