summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2019-05-26 14:32:09 +0800
committerMark Hung <marklh9@gmail.com>2019-05-30 10:58:33 +0200
commit6a7db071c75609093fc3a9cbc297b8069726a33e (patch)
tree58a7f32e63bcfbb9c1351b1c7bfa9c400f458cde
parenttdf#125372 writer, file with lots of hints very slow to open, part5 (diff)
downloadcore-6a7db071c75609093fc3a9cbc297b8069726a33e.tar.gz
core-6a7db071c75609093fc3a9cbc297b8069726a33e.zip
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: Mark Hung <marklh9@gmail.com>
-rw-r--r--editeng/source/editeng/impedit2.cxx16
-rw-r--r--include/rtl/character.hxx29
-rw-r--r--sw/source/uibase/wrtsh/delete.cxx21
3 files changed, 46 insertions, 20 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 8764b097e698..58629d811b1b 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -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 )
{
diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx
index a18d05d6a5e8..2a8933668964 100644
--- a/include/rtl/character.hxx
+++ b/include/rtl/character.hxx
@@ -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;
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index d15a46db78b3..bddd1daaa9d2 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -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.