Kaydet (Commit) 6a7db071 authored tarafından Mark Hung's avatar Mark Hung

tdf#125497 allow backspace to remove CJK IVS.

Japanese users prefer to remove a CJK IVS character
when pressing the backspace instead of removing
the selector part of IVS.

Change-Id: I4313d69ed52d82c5a7e4e4823b1da06f1d90bdad
Reviewed-on: https://gerrit.libreoffice.org/72971
Tested-by: Jenkins
Reviewed-by: 's avatarMark Hung <marklh9@gmail.com>
üst 799dac2e
......@@ -60,6 +60,7 @@
#include <sot/exchange.hxx>
#include <sot/formats.hxx>
#include <svl/asiancfg.hxx>
#include <rtl/character.hxx>
#include <comphelper/lok.hxx>
#include <unotools/configmgr.hxx>
......@@ -2300,7 +2301,20 @@ EditPaM ImpEditEngine::DeleteLeftOrRight( const EditSelection& rSel, sal_uInt8 n
{
if ( nDelMode == DeleteMode::Simple )
{
aDelStart = CursorLeft( aCurPos, i18n::CharacterIteratorMode::SKIPCHARACTER );
sal_uInt16 nCharMode = i18n::CharacterIteratorMode::SKIPCHARACTER;
// Check if we are deleting a CJK ideograph variance sequence (IVS).
sal_Int32 nIndex = aCurPos.GetIndex();
if (nIndex > 0)
{
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)))
{
nCharMode = i18n::CharacterIteratorMode::SKIPCELL;
}
}
aDelStart = CursorLeft(aCurPos, nCharMode);
}
else if ( nDelMode == DeleteMode::RestOfWord )
{
......
......@@ -57,6 +57,35 @@ inline bool isAscii(sal_uInt32 code)
return code <= 0x7F;
}
/** Check for Unicode variation sequence selectors
@param code 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 code 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;
......
......@@ -44,23 +44,6 @@ inline void SwWrtShell::CloseMark( bool bOkFlag )
EndAllAction();
}
namespace {
bool isUnicodeVariationSequenceSelector( sal_uInt32 nCode )
{
return ( nCode >= 0xFE00 && nCode <= 0xFE0F ) // Variation Selectors block
|| ( nCode >= 0xE0100 && nCode <= 0xE01EF );// Variation Selectors Supplement block
}
// Return if the character might be a base character of a CJK ideographic variation sequence
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#
......@@ -268,14 +251,14 @@ bool SwWrtShell::DelLeft()
nCode = sStr.iterateCodePoints( &nIndex );
}
if ( isUnicodeVariationSequenceSelector( nCode ) )
if ( rtl::isIVSSelector( nCode ) )
{
SwCursorShell::Push();
SwCursorShell::Left(1, CRSR_SKIP_CHARS);
OUString sStr = GetSelText();
sal_Int32 nIndex = 0;
nCode = sStr.iterateCodePoints( &nIndex );
if ( isCJKIVSCharacters( nCode ) )
if ( rtl::isCJKIVSCharacter( nCode ) )
SwCursorShell::Pop( SwCursorShell::PopMode::DeleteStack );
else
SwCursorShell::Pop( SwCursorShell::PopMode::DeleteCurrent ); // For the weak script.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment