diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-08-17 09:06:29 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-08-17 14:52:18 +0200 |
commit | 5b7d9f21ef74601f4893dd07e8e3f2bf34427eb0 (patch) | |
tree | 3a26be852df926f5e82f66f8a0550025c59ca962 /sfx2 | |
parent | 188cff995830d52f4b04ee4d2ffcabeff5d17b27 (diff) |
tdf#156699 sfx2: Extract helper method to get char value + name
It will be reused in an upcoming commit to set the a11y
name for the `SvxCharView`.
Change-Id: Ib5938e5363571e547ee00cac8432f919b60cd97a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155756
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/charwin.cxx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index 50c7099a84a7..99fa9dbd1d3d 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -65,7 +65,7 @@ void SvxCharView::GetFocus() void SvxCharView::LoseFocus() { Invalidate(); } -OUString SvxCharView::GetCharInfoText() +bool SvxCharView::GetDecimalValueAndCharName(sal_UCS4& rDecimalValue, OUString& rCharName) { OUString charValue = GetText(); sal_UCS4 nDecimalValue = charValue.iterateCodePoints(&o3tl::temporary(sal_Int32(1)), -1); @@ -77,8 +77,22 @@ OUString SvxCharView::GetCharInfoText() u_charName(nDecimalValue, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); if (U_SUCCESS(errorCode)) { + rDecimalValue = nDecimalValue; + rCharName = OUString::createFromAscii(buffer); + return true; + } + return false; +} + +OUString SvxCharView::GetCharInfoText() +{ + sal_UCS4 nDecimalValue = 0; + OUString sCharName; + const bool bSuccess = GetDecimalValueAndCharName(nDecimalValue, sCharName); + if (bSuccess) + { OUString aHexText = OUString::number(nDecimalValue, 16).toAsciiUpperCase(); - return charValue + u" " + OUString::createFromAscii(buffer) + u" U+" + aHexText; + return GetText() + u" " + sCharName + u" U+" + aHexText; } return OUString(); } |