basic/qa/basic_coverage/test_non_ascii_names.bas            |    9 ++
 basic/qa/basic_coverage/test_non_ascii_names_compatible.bas |   45 ++++++++++++
 basic/qa/cppunit/test_vba.cxx                               |    1 
 basic/qa/vba_tests/tdf148358_non_ascii_names.vb             |   33 ++++++++
 basic/source/sbx/sbxarray.cxx                               |    5 +
 5 files changed, 92 insertions(+), 1 deletion(-)

New commits:
commit 90d33f5945336fa46b7c02f425100af794768b15
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Tue May 3 20:38:37 2022 +0200
Commit:     Andreas Heinisch <andreas.heini...@yahoo.de>
CommitDate: Sat May 7 16:00:50 2022 +0200

    tdf#148358 - Compare Non-ASCII variable names case-insensitive
    
    Change-Id: I761eb27b16c92d58df1be8e6011fc9b94db2a59c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133774
    Tested-by: Jenkins
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>

diff --git a/basic/qa/basic_coverage/test_non_ascii_names.bas 
b/basic/qa/basic_coverage/test_non_ascii_names.bas
index a9ef0f159da2..c85c9cae12cb 100644
--- a/basic/qa/basic_coverage/test_non_ascii_names.bas
+++ b/basic/qa/basic_coverage/test_non_ascii_names.bas
@@ -17,11 +17,20 @@ Function [Функция]([😁])
   [Функция] = [😁] & " and some text"
 End Function
 
+Function TestNonAsciiNative as Integer
+    Dim [Абв] as Integer
+    [Абв] = 5
+    TestNonAsciiNative = [абв]
+End Function
+
 Sub [Prüfung]
   On Error GoTo errorHandler
 
   TestUtil.AssertEqual([Функция]("Smiley"), "Smiley and some text", 
"[Функция](""Smiley"")")
 
+  ' tdf#148358 - compare Non-ASCII variable names case-insensitive
+  TestUtil.AssertEqual(TestNonAsciiNative(), 5, "TestNonAsciiNative()")
+
   Exit Sub
 errorHandler:
   TestUtil.ReportErrorHandler("Prüfung", Err, Error$, Erl)
diff --git a/basic/qa/basic_coverage/test_non_ascii_names_compatible.bas 
b/basic/qa/basic_coverage/test_non_ascii_names_compatible.bas
new file mode 100644
index 000000000000..1abc272443c5
--- /dev/null
+++ b/basic/qa/basic_coverage/test_non_ascii_names_compatible.bas
@@ -0,0 +1,45 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option Compatible
+Option Explicit
+
+Function doUnitTest as String
+  [Prüfung]
+  doUnitTest = TestUtil.GetResult()
+End Function
+
+Function [Функция]([😁])
+  [Функция] = [😁] & " and some text"
+End Function
+
+Function TestNonAscii as Integer
+    Dim Абв as Integer
+    Абв = 10
+    TestNonAscii = абв
+End Function
+
+Function TestNonAsciiNative as Integer
+    Dim [Абв] as Integer
+    [Абв] = 5
+    TestNonAsciiNative = [абв]
+End Function
+
+Sub [Prüfung]
+  On Error GoTo errorHandler
+
+  TestUtil.AssertEqual([Функция]("Smiley"), "Smiley and some text", 
"[Функция](""Smiley"")")
+
+  ' tdf#148358 - compare Non-ASCII variable names case-insensitive
+  TestUtil.AssertEqual(TestNonAscii(), 10, "TestNonAscii()")
+  TestUtil.AssertEqual(TestNonAsciiNative(), 5, "TestNonAsciiNative()")
+
+  Exit Sub
+errorHandler:
+  TestUtil.ReportErrorHandler("Prüfung Compatible", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 6ac6974fc081..07e4287e17b1 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -136,6 +136,7 @@ void VBATest::testMiscVBAFunctions()
         "strreverse.vb",
         "switch.vb",
         "tdf147089_idiv.vb",
+        "tdf148358_non_ascii_names.vb",
         "timeserial.vb",
         "timevalue.vb",
         "trim.vb",
diff --git a/basic/qa/vba_tests/tdf148358_non_ascii_names.vb 
b/basic/qa/vba_tests/tdf148358_non_ascii_names.vb
new file mode 100644
index 000000000000..95e7105407f5
--- /dev/null
+++ b/basic/qa/vba_tests/tdf148358_non_ascii_names.vb
@@ -0,0 +1,33 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest as String
+  TestUtil.TestInit
+  verify_testNonAsciiNames
+  doUnitTest = TestUtil.GetResult()
+End Function
+
+Function TestNonAscii as Integer
+    Dim Абв as Integer
+    Абв = 10
+    TestNonAscii = абв
+End Function
+
+Sub verify_testNonAsciiNames
+  On Error GoTo errorHandler
+
+  ' tdf#148358 - compare Non-ASCII variable names case-insensitive
+  TestUtil.AssertEqual(TestNonAscii(), 10, "TestNonAscii()")
+
+  Exit Sub
+errorHandler:
+  TestUtil.ReportErrorHandler("verify_testNonAsciiNames", Err, Error$, Erl)
+End Sub
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index d8f16f5891c1..5f70345e6f2a 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -277,6 +277,8 @@ SbxVariable* SbxArray::Find( const OUString& rName, 
SbxClassType t )
         return nullptr;
     bool bExtSearch = IsSet( SbxFlagBits::ExtSearch );
     sal_uInt16 nHash = SbxVariable::MakeHashCode( rName );
+    //const OUString aNameCI = SbxVariable::NameToCaseInsensitiveName(rName);
+    const OUString aNameCI = SbxVariable::NameToCaseInsensitiveName(rName);
     for (auto& rEntry : mVarEntries)
     {
         if (!rEntry.mpVar.is() || !rEntry.mpVar->IsVisible())
@@ -284,9 +286,10 @@ SbxVariable* SbxArray::Find( const OUString& rName, 
SbxClassType t )
 
         // The very secure search works as well, if there is no hashcode!
         sal_uInt16 nVarHash = rEntry.mpVar->GetHashCode();
+        // tdf#148358 - compare the names case-insensitive
         if ( (!nVarHash || nVarHash == nHash)
             && (t == SbxClassType::DontCare || rEntry.mpVar->GetClass() == t)
-            && (rEntry.mpVar->GetName().equalsIgnoreAsciiCase(rName)))
+            && (rEntry.mpVar->GetName(SbxNameType::CaseInsensitive) == 
aNameCI))
         {
             p = rEntry.mpVar.get();
             p->ResetFlag(SbxFlagBits::ExtFound);

Reply via email to