include/sfx2/charwin.hxx | 1 + sfx2/source/control/charwin.cxx | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-)
New commits: commit 8c4fa83191e6df5d823386cca2adc30dbbc9e297 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Aug 17 09:34:09 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Aug 17 14:52:30 2023 +0200 tdf#156699 a11y: Set a11y name for SvxCharView Set the character name as a11y name for the `SvXCharView`. Also add a check for the string to be non-empty in `SvxCharView::GetDecimalValueAndCharName`, since `SfxCharmapContainer::updateRecentCharControl` sets the text to an empty string, and calling `OUString::iterateCodePoint` on that empts string would trigger an assert now that `SvxCharView::SetText` tries to retrieve the character name right away. This makes NVDA on Windows announce the focused character by its name in the Special Characters dialog and the Special Characters toolbar group button. Orca with the gtk3 VCL plugin now announces the focused character in the Special Characters dialog, but not yet in the toolbar group button. Change-Id: I79c8e0c2de6e817a467a405dc7d9e103cba07dfe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155757 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index 99fa9dbd1d3d..999aa2e4a95d 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -68,6 +68,9 @@ void SvxCharView::LoseFocus() { Invalidate(); } bool SvxCharView::GetDecimalValueAndCharName(sal_UCS4& rDecimalValue, OUString& rCharName) { OUString charValue = GetText(); + if (charValue.isEmpty()) + return false; + sal_UCS4 nDecimalValue = charValue.iterateCodePoints(&o3tl::temporary(sal_Int32(1)), -1); /* get the character name */ UErrorCode errorCode = U_ZERO_ERROR; @@ -313,6 +316,12 @@ void SvxCharView::SetText(const OUString& rText) { m_sText = rText; Invalidate(); + + OUString sName; + if (GetDecimalValueAndCharName(o3tl::temporary(sal_UCS4()), sName)) + SetAccessibleName(sName); + else + SetAccessibleName(OUString()); } void SvxCharView::SetHasInsert(bool bInsert) { maHasInsert = bInsert; } commit 5b7d9f21ef74601f4893dd07e8e3f2bf34427eb0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Aug 17 09:06:29 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Aug 17 14:52:18 2023 +0200 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.wegh...@posteo.de> diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx index 75a6fad12a38..f8e4d662cf7a 100644 --- a/include/sfx2/charwin.hxx +++ b/include/sfx2/charwin.hxx @@ -49,6 +49,7 @@ private: virtual bool KeyInput(const KeyEvent&) override; virtual bool Command(const CommandEvent&) override; virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + bool GetDecimalValueAndCharName(sal_UCS4& rDecimalValue, OUString& rCharName); public: SvxCharView(const VclPtr<VirtualDevice>& rVirDev); 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); @@ -76,9 +76,23 @@ OUString SvxCharView::GetCharInfoText() char buffer[100]; 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(); }