[Libreoffice-commits] core.git: basic/qa basic/source
Andreas Heinisch (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 13 16:37:02 UTC 2021
basic/qa/basic_coverage/test_instr_method.vb | 17 +++++++++++------
basic/qa/vba_tests/instr.vb | 3 +++
basic/source/runtime/methods.cxx | 9 +++++++--
3 files changed, 21 insertions(+), 8 deletions(-)
New commits:
commit 7a578c06352328799c644e0399f14d58b05246f9
Author: Andreas Heinisch <andreas.heinisch at yahoo.de>
AuthorDate: Thu May 13 09:38:14 2021 +0200
Commit: Andreas Heinisch <andreas.heinisch at yahoo.de>
CommitDate: Thu May 13 18:36:20 2021 +0200
tdf#139840 - Case-insensitive operation for non-ASCII characters
Support case-insensitive operation for non-ASCII characters in the
InStr function in Basic.
Change-Id: Idb2b8e128adf3596fa49e3e86365d5724ea3e11c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115538
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch at yahoo.de>
diff --git a/basic/qa/basic_coverage/test_instr_method.vb b/basic/qa/basic_coverage/test_instr_method.vb
index 716aa215878b..47fa7a94ede1 100644
--- a/basic/qa/basic_coverage/test_instr_method.vb
+++ b/basic/qa/basic_coverage/test_instr_method.vb
@@ -6,12 +6,17 @@
'
Function doUnitTest as Integer
- dim aString as Variant
+
+ doUnitTest = 0
+
+ Dim aString As Variant
aString = "Hello"
' InStr
- If ( InStr( 1, aString, "l", 1) <> 3 ) Then
- doUnitTest = 0
- Else
- doUnitTest = 1
- End If
+ If (InStr(1, aString, "l", 1) <> 3) Then Exit Function
+
+ ' tdf#139840 - case-insensitive operation for non-ASCII characters
+ If (InStr(1, "α", "Α", 1) <> 1) Then Exit Function
+
+ doUnitTest = 1
+
End Function
diff --git a/basic/qa/vba_tests/instr.vb b/basic/qa/vba_tests/instr.vb
index 74f7e2f755d4..3ced2a07c8ca 100644
--- a/basic/qa/vba_tests/instr.vb
+++ b/basic/qa/vba_tests/instr.vb
@@ -30,6 +30,9 @@ Sub verify_testInStr()
TestUtil.AssertEqual(InStr(1, SearchString, SearchChar, 0), 9, "InStr(1, SearchString, SearchChar, 0)")
TestUtil.AssertEqual(InStr(1, SearchString, "W"), 0, "InStr(1, SearchString, ""W"")")
+ ' tdf#139840 - case-insensitive operation for non-ASCII characters
+ TestUtil.AssertEqual(InStr(1, "α", "Α", 1), 1, "InStr(1, ""α"", ""Α"", 1)")
+
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_testInStr", Err, Error$, Erl)
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 843c85b4860f..73bfe7fbc2d0 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -887,8 +887,13 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
OUString aStr1 = rPar.Get(nFirstStringPos)->GetOUString();
OUString aToken = rToken;
- aStr1 = aStr1.toAsciiUpperCase();
- aToken = aToken.toAsciiUpperCase();
+ // tdf#139840 - case-insensitive operation for non-ASCII characters
+ const css::lang::Locale& rLocale
+ = Application::GetSettings().GetLanguageTag().getLocale();
+ css::uno::Reference<i18n::XCharacterClassification> xCharClass
+ = vcl::unohelper::CreateCharacterClassification();
+ aStr1 = xCharClass->toUpper(aStr1, 0, aStr1.getLength(), rLocale);
+ aToken = xCharClass->toUpper(aToken, 0, aToken.getLength(), rLocale);
nPos = aStr1.indexOf( aToken, nStartPos-1 ) + 1;
}
More information about the Libreoffice-commits
mailing list