From e8e2b71ea5a8a7147dbb14990aa73a98f7abcb03 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann <sbergman@redhat.com> Date: Fri, 14 Oct 2016 08:58:41 +0200 Subject: Fix GetMnemonicChar For one, had a (false) occurrence of loplugin:bodynotinblock. For another, would have erroneously reported 'A' instead of 'B' for "~~A~B". Change-Id: I6b2e09ad0d0e132896a9f2802bf4355a25f2d296 Reviewed-on: https://gerrit.libreoffice.org/29808 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com> --- winaccessibility/source/UAccCOM/MAccessible.cxx | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index fe87fed6b390..a8c035fc97cd 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -593,19 +593,16 @@ STDMETHODIMP CMAccessible::get_accHelpTopic(BSTR *, VARIANT, long *) static void GetMnemonicChar( const ::rtl::OUString& aStr, WCHAR* wStr) { - int nLen = aStr.pData->length; - int i = 0; - WCHAR* text = aStr.pData->buffer; - - while ( i < nLen ) - { - if ( text[i] == L'~' ) - if ( text[i+1] != L'~' ) - { - wStr[0] = text[i+1]; - break; - } - i++; + for (sal_Int32 i = 0;; i += 2) { + i = aStr.indexOf('~', i); + if (i == -1 || i == aStr.getLength() - 1) { + break; + } + auto c = aStr[i + 1]; + if (c != '~') { + *wStr = c; + break; + } } } -- cgit