[Libreoffice-commits] core.git: vcl/qa vcl/source

Caolán McNamara caolanm at redhat.com
Sat Jul 22 11:45:35 UTC 2017


 vcl/qa/cppunit/mnemonic.cxx    |   21 ++++++++++++++++++---
 vcl/source/window/mnemonic.cxx |    4 ++--
 2 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit dbc371c4bed118678d71dba51a0dac7f604e1874
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Jul 22 12:42:43 2017 +0100

    add test for CJK (~X) mnemonics
    
    Change-Id: I1f69c23dcde6d963ad9c3bc1f2d9178fe15eb27c

diff --git a/vcl/qa/cppunit/mnemonic.cxx b/vcl/qa/cppunit/mnemonic.cxx
index f377a2d1085a..fb8bc8c454ac 100644
--- a/vcl/qa/cppunit/mnemonic.cxx
+++ b/vcl/qa/cppunit/mnemonic.cxx
@@ -32,9 +32,24 @@ void VclMnemonicTest::testMnemonic()
 {
     MnemonicGenerator aGenerator;
 
-    const sal_Unicode TEST[] = { 0x00DF, 'a' };
-    OUString sResult = aGenerator.CreateMnemonic(OUString(TEST, SAL_N_ELEMENTS(TEST)));
-    CPPUNIT_ASSERT_EQUAL(u'~', sResult[1]);
+    {
+        const sal_Unicode TEST[] = { 0x00DF, 'a' };
+        OUString sResult = aGenerator.CreateMnemonic(OUString(TEST, SAL_N_ELEMENTS(TEST)));
+        CPPUNIT_ASSERT_EQUAL(u'~', sResult[1]);
+    }
+
+    {
+        const sal_Unicode TEST[] = { 0x4E00, 'b' };
+        OUString sResult = aGenerator.CreateMnemonic(OUString(TEST, SAL_N_ELEMENTS(TEST)));
+        CPPUNIT_ASSERT_EQUAL(u'~', sResult[1]);
+    }
+
+    {
+        const sal_Unicode TEST[] = { 0x4E00 };
+        OUString sResult = aGenerator.CreateMnemonic(OUString(TEST, SAL_N_ELEMENTS(TEST)));
+        CPPUNIT_ASSERT_EQUAL(OUString("(~C)"), sResult.copy(sResult.getLength() - 4));
+    }
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(VclMnemonicTest);
diff --git a/vcl/source/window/mnemonic.cxx b/vcl/source/window/mnemonic.cxx
index b95f372f33c3..fe26cd14c152 100644
--- a/vcl/source/window/mnemonic.cxx
+++ b/vcl/source/window/mnemonic.cxx
@@ -253,14 +253,14 @@ OUString MnemonicGenerator::CreateMnemonic( const OUString& _rKey )
         // Append Ascii Mnemonic
         for ( c = MNEMONIC_RANGE_2_START; c <= MNEMONIC_RANGE_2_END; c++ )
         {
-            nMnemonicIndex = ImplGetMnemonicIndex(sal_Unicode(rtl::toAsciiUpperCase(c)));
+            nMnemonicIndex = ImplGetMnemonicIndex(c);
             if ( nMnemonicIndex != MNEMONIC_INDEX_NOTFOUND )
             {
                 if ( maMnemonics[nMnemonicIndex] )
                 {
                     maMnemonics[nMnemonicIndex] = 0;
                     OUString aStr = OUStringBuffer().
-                        append('(').append(MNEMONIC_CHAR).append(c).
+                        append('(').append(MNEMONIC_CHAR).append(sal_Unicode(rtl::toAsciiUpperCase(c))).
                         append(')').makeStringAndClear();
                     nIndex = rKey.getLength();
                     if( nIndex >= 2 )


More information about the Libreoffice-commits mailing list