summaryrefslogtreecommitdiff
path: root/winaccessibility
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-10-14 08:58:41 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-10-14 07:47:30 +0000
commite8e2b71ea5a8a7147dbb14990aa73a98f7abcb03 (patch)
tree765dbd54e732c7fc4df1ba4b1e7db5b50d29f180 /winaccessibility
parent808d95075e557107987468f8701d67d92d2be824 (diff)
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>
Diffstat (limited to 'winaccessibility')
-rw-r--r--winaccessibility/source/UAccCOM/MAccessible.cxx23
1 files 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;
+ }
}
}