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.heinisch@yahoo.de>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user