[Libreoffice-commits] core.git: winaccessibility/source

Stephan Bergmann sbergman at redhat.com
Fri Oct 14 07:50:47 UTC 2016


 winaccessibility/source/UAccCOM/MAccessible.cxx |   23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

New commits:
commit e8e2b71ea5a8a7147dbb14990aa73a98f7abcb03
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 14 08:58:41 2016 +0200

    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 at redhat.com>
    Tested-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx
index fe87fed6..a8c035f 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;
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list