svx/source/dialog/cuicharmap.cxx | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-)
New commits: commit d70b25458157ae4122caf1e41f6a01680f7647ac Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Aug 4 14:38:01 2024 +0500 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Thu Aug 8 21:26:16 2024 +0200 tdf#111816: allow special characters filtering by Unicode value When the Search box starts with U+ (or u+), the rest will be treated as beginning of a Unicode value in hexadecimal notation (ignoring any leading zeroes). E.g., "U+12" would match U+0120 and U+12F90, but not U+0112. "u+012" will match exactly the same codepoints. Change-Id: Ia4a3ccc99d049dc208d556f3f2a0fb8b2ef6b689 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171458 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins (cherry picked from commit 2bb84e874bd17afcf3e417d2e4fc32aaafe841c3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171417 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> (cherry picked from commit 2e1dd8634991550865072e15e1ec4da289548642) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171531 Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/svx/source/dialog/cuicharmap.cxx b/svx/source/dialog/cuicharmap.cxx index c5f2a1b128c4..5b96f114202e 100644 --- a/svx/source/dialog/cuicharmap.cxx +++ b/svx/source/dialog/cuicharmap.cxx @@ -479,35 +479,39 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchUpdateHdl, weld::Entry&, void) if (!m_xSearchText->get_text().isEmpty()) { m_xSearchSet->ClearPreviousData(); - OUString aKeyword = m_xSearchText->get_text(); + OUString aKeyword = m_xSearchText->get_text().trim().toAsciiLowerCase(); + OUString hex_code; + if (OUString rest; aKeyword.startsWith("u+", &rest)) + if (auto n = rest.toInt32(16)) + hex_code = OUString::number(n, 16); // this removes leading zeroes toggleSearchView(true); FontCharMapRef xFontCharMap = m_xSearchSet->GetFontCharMap(); - sal_UCS4 sChar = xFontCharMap->GetFirstChar(); - while(sChar != xFontCharMap->GetLastChar()) + for (sal_UCS4 ucs4 = xFontCharMap->GetFirstChar();; ucs4 = xFontCharMap->GetNextChar(ucs4)) { + bool bAdded = false; UErrorCode errorCode = U_ZERO_ERROR; char buffer[100]; - u_charName(sChar, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); + u_charName(ucs4, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); if (U_SUCCESS(errorCode)) { OUString sName = OUString::createFromAscii(buffer); - if(!sName.isEmpty() && sName.toAsciiLowerCase().indexOf(aKeyword.toAsciiLowerCase()) >= 0) - m_xSearchSet->AppendCharToList(sChar); + if (!sName.isEmpty() && sName.toAsciiLowerCase().indexOf(aKeyword) >= 0) + { + m_xSearchSet->AppendCharToList(ucs4); + bAdded = true; + } } - sChar = xFontCharMap->GetNextChar(sChar); - } - //for last char - UErrorCode errorCode = U_ZERO_ERROR; - char buffer[100]; - u_charName(sChar, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); - if (U_SUCCESS(errorCode)) - { - OUString sName = OUString::createFromAscii(buffer); - if(!sName.isEmpty() && sName.toAsciiLowerCase().indexOf(aKeyword.toAsciiLowerCase()) >= 0) - m_xSearchSet->AppendCharToList(sChar); + if (!bAdded && !hex_code.isEmpty()) + { + OUString actual_number = OUString::number(ucs4, 16); + if (actual_number.startsWith(hex_code)) + m_xSearchSet->AppendCharToList(ucs4); + } + if (ucs4 == xFontCharMap->GetLastChar()) + break; } m_xSearchSet->UpdateScrollRange();