The StrConv() VBA/BASIC function is implemented in LibreOffice but the QA test does not cover all possibilities of the arguments and parameters. The QA test is available at https://opengrok.libreoffice.org/xref/core/basic/qa/vba_tests/strconv.vb?r=b9d75dea The fix is to create a test or fix the existing QA test so that the function can be published and documented. Then bug#124066 can be fixed and closed.
A description of what is wrong with the code of the QA test can be found in Comment 3 of bug#124066.
@Raal, I thought you might be interested in this issue...
@Libreofficiant, I thought you might be interested in this issue...
Hello Olivier, Gerhard, First attempt to improve the coverage in https://gerrit.libreoffice.org/c/core/+/99260 I'm not familiar with VBA at all so comments are appreciated
StrConv in LO does not implement handling its third argument (LCID). Without that, there's no way to create useful unit tests (since everything is system-dependent, and so different on different systems). If someone wants to implement that, the code is SbRtl_StrConv in basic/source/runtime/methods.cxx; LCIDs (MS thing [1]) is represented in LO by LanguageType (include/i18nlangtag/lang.h), so it's directly usable in the SbRtl_StrConv function, that also internally uses a LanguageType value hardcoded to LANGUAGE_SYSTEM. [1] https://msdn.microsoft.com/en-us/goglobal/bb964664
Created attachment 170170 [details] Basic runtime error while running test. While running test in basic/qa/vba_tests/strconv.vb in my LO macros i am getting BASIC runtime error "TestUtil". What is the problem here ? Is this specific to my system or happening with everyone ?
(In reply to Tushar Kumar Rai from comment #6) This is not specific to your system. This is a consequence of https://gerrit.libreoffice.org/c/core/+/107860, where we added a special module pre-loaded for unit tests (to remove duplication), but that mean that the tests depend on that module present. So you need to import basic/qa/vba_tests/_test_asserts.vb as a module "TestUtil" in your LO to be able to test.
So the idea is something like this - In file basic/source/runtime/methods.cxx in function SbRtl_StrConv - Initialise OUString lcid = rPar.Get32(3)->GetOUString();(lcid will be the locale_id which is passed by the user) Then some changes in setting up the TransliterationFlags need to be done - For example in case of Hiragana to Katakana conversion - if ( (nConversion & 0x10) == 16 ) // vbKatakana { if (nArgCount == 2 && LANGUAGE_SYSTEM == LANGUAGE_JAPANESE) nType |= TransliterationFlags::HIRAGANA_KATAKANA; else if(nArgCount ==3 && lcid == "0x0411") nType |= TransliterationFlags::HIRAGANA_KATAKANA; else StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); } Basically if locale_id is not provided by user(number of arguments=2) then we need to check if the system locale id is that of Japan(because in vba strconv vbKatakana and vbHiragana applies to Japan only and cause run-time errors when used in locales where they do not apply) https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/strconv-function And if localeid is provided by user(number of arguments=3) it has to be locale_id of Japan(0x0411) Else it should throw runtime error. One thing also to note in basic/qa/vba_tests/strconv.vb is that - At line- ' Converts Hiragana characters in string to Katakana characters Module1.AssertEqual(StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana), "¥Ï¥Ê¥Á¥ã¥ó", "StrConv(""¤Ï¤Ê¤Á¤ã¤ó"", vbKatakana)") According to this line the expected output is "¥Ï¥Ê¥Á¥ã¥ó". But when i checked online convertor of Hiragana to Katakana https://en.calc-site.com/letters/convert_kana The outpot got is "¤Ï¤Ê¤Á¤ã¤ó". I have checked few other online convertors and the result is same.So I guess this needs to be changed is test file as well. This means that StrConv is working properly and there needs to be change in expected outputs in basic/qa/vba_tests/strconv.vb file. Please correct me if i am wrong at any point.
(In reply to Tushar Kumar Rai from comment #8) > So the idea is something like this - > In file basic/source/runtime/methods.cxx in function SbRtl_StrConv - > > Initialise > OUString lcid = rPar.Get32(3)->GetOUString();(lcid will be the locale_id > which is passed by the user) > > Then some changes in setting up the TransliterationFlags need to be done - > > For example in case of Hiragana to Katakana conversion - > > if ( (nConversion & 0x10) == 16 ) // vbKatakana > { > if (nArgCount == 2 && LANGUAGE_SYSTEM == LANGUAGE_JAPANESE) > nType |= TransliterationFlags::HIRAGANA_KATAKANA; > else if(nArgCount ==3 && lcid == "0x0411") > nType |= TransliterationFlags::HIRAGANA_KATAKANA; > else > StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); > } > > Basically if locale_id is not provided by user(number of arguments=2) then > we need to check if the system locale id is that of Japan(because in vba > strconv vbKatakana and vbHiragana applies to Japan only and cause run-time > errors when used in locales where they do not apply) > > https://docs.microsoft.com/en-us/office/vba/language/reference/user- > interface-help/strconv-function > > And if localeid is provided by user(number of arguments=3) it has to be > locale_id of Japan(0x0411) > > Else it should throw runtime error. > > > One thing also to note in basic/qa/vba_tests/strconv.vb is that - > > At line- > ' Converts Hiragana characters in string to Katakana characters > Module1.AssertEqual(StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana), "¥Ï¥Ê¥Á¥ã¥ó", > "StrConv(""¤Ï¤Ê¤Á¤ã¤ó"", vbKatakana)") > > According to this line the expected output is "¥Ï¥Ê¥Á¥ã¥ó". > > But when i checked online convertor of Hiragana to Katakana > > https://en.calc-site.com/letters/convert_kana > > The outpot got is "¤Ï¤Ê¤Á¤ã¤ó". > I have checked few other online convertors and the result is same.So I guess > this needs to be changed is test file as well. > > This means that StrConv is working properly and there needs to be change in > expected outputs in basic/qa/vba_tests/strconv.vb file. > > Please correct me if i am wrong at any point. Can somebody guide me through this ?
(In reply to Tushar Kumar Rai from comment #8) What you write looks reasonable. But please let's talk at a gerrit change with your proposed code. There we can discuss right at the specific lines, discussing the code in detail.
tushar committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/6fecdeac5d81a60a479195a62cdc174b919f763b tdf#124184 Fixing StrConv VBA Function It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Can someone verify the fix ?
I think you can mark it as fixed :)