summaryrefslogtreecommitdiff
path: root/basic
AgeCommit message (Collapse)Author
2021-07-07tdf#142922 fixes Round to follow half-to-even roundingbaltasarq
The LibreOffice's Basic Round function does not return values that are compatible with VBA's Round. This can be easily fixed using rtl/round, which has a flag parameter called rtl_math_RoundingMode_HalfEven which rounds real numbers exactly in the expected way. Change-Id: I2215f08427e5777fc2d35f054b635dfa6247af8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118444 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 0eacbfa75132724faaeeb9ea22a1c3e44eefb515) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118493 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2021-07-01tdf#143081: fix Basic Replace() function crashes LOJulien Nabet
0x00007f19c0aa6e57 in rtl::OUStringBuffer::append(char16_t const*, int) (this=0x7fff100d0748, str=0x6f6f46a u"晦饖香©", len=-1) at include/rtl/ustrbuf.hxx:659 0x00007f19c0c3c8a8 in SbRtl_Replace(StarBASIC*, SbxArray&, bool) (rPar=...) at basic/source/runtime/methods.cxx:1321 see bt here: https://bugs.documentfoundation.org/attachment.cgi?id=173298 Calling xCharClass->toUpper may change words, eg: "Straße" becomes "Strasse" so the length of the word increases. In brief, we want to use the length of aSrcStr not aExpStr Change-Id: Ia291d47a2021efc7dd9162ca5cc72b7940fdd71e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118202 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 4a0b40f1be9f6773c8ebc5331c257911a76a5cee) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118178 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2021-06-28tdf#142460: properly handle boolean values in string poolbaltasarq
This makes sure that results of comparison of literals have proper boolean type, and that this type is properly stored to/read from the string pool. This introduces a new non-standard "type" character used in the pool: 'b'. It is not a proper type character used in Basic (unlike '%'/'&'/'!'/'@'), but we have to use this trick locally, because we need to pass the type that has no own type character. The change should be backward-compatible: older versions reading the value should just ignore the 'b', and read the value as double. Change-Id: Ibd4a70b366331342346eb171c8ed3c7026279596 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117655 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 5eedb3beeaeed88de0d1ebd041a9f15ceea7e78c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117862 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2021-06-01loplugin:stringview (clang-cl)Stephan Bergmann
Change-Id: Id1f8f24fec638efcdf5a04ca7253e6f401afd2fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116548 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-24fix leak in dbaccessNoel Grandin
when loading form controls Change-Id: Ifa731ca1c7bc16579ce03d256691a50ccfbeb82b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116050 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-23tdf#142180 Swapped comparison operators for static stringsJoshua Williams
It seems that, for some reason, the comparison operators for strings in basic were swapped in the code that evaluates string comparisons at compile-time. This is what caused bug #142180. This commit simply swaps the operators and should fix the bug. Change-Id: I14f90db8598f2f7f8b709e26902986e1f64af576 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115983 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-05-14Improve loplugin:stringviewStephan Bergmann
Issue the "instead of O[U]String, pass [u16]string_view" diagnostic also for operator call arguments. (The "rather than copy, pass subView()" diagnostic is already part of handleSubExprThatCouldBeView, so no need to repeat it explicitly for operator call arguments.) (And many call sites don't even require an explicit [u16]string_view, esp. with the recent ad48b2b02f83eed41fb1eb8d16de7e804156fcf1 "Optimized OString operator += overloads". Just some test code in sal/qa/ that explicitly tests the O[U]String functionality had to be excluded.) Change-Id: I8d55ba5a7fa16a563f5ffe43d245125c88c793bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115589 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-13tdf#132389 - Case-insensitive operation for non-ASCII charactersAndreas Heinisch
The replace function should depend on the application locale, instead of the UI language. Change-Id: I1582db07a1560da9ea87c0b127cf92611c8544bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115540 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
2021-05-13tdf#139840 - Case-insensitive operation for non-ASCII charactersAndreas Heinisch
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@yahoo.de>
2021-05-10fix some leaks in basicNoel Grandin
Change-Id: I52c10cdbe9661974c908ee052336c779a40de402 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115323 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-07cid#1474072 silence Untrusted loop boundCaolán McNamara
Change-Id: I2f966440b59c61bfd692c0e63bdffc37eafdb7a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115229 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-05-06Change en_GB calendar StartDayOfWeek to Monday and MinimalDaysInFirstWeek to 4Eike Rathke
Inherit day, month and era names from en_US but with proper values. See https://lh.2xlibre.net/locale/en_GB/ - Week definition (week) - First day of week (first_weekday) or % LC_TIME=en_US locale -k LC_TIME week-ndays=7 week-1stday=19971130 week-1stweek=1 first_weekday=1 first_workday=2 % LC_TIME=en_GB locale -k LC_TIME week-ndays=7 week-1stday=19971130 week-1stweek=4 first_weekday=2 first_workday=2 This makes it necessary to adapt basic/qa/vba_tests/weekdayname.vb because basic/qa/cppunit/test_vba.cxx sets LANGUAGE_ENGLISH_UK Change-Id: I752bf0e59396f0cbd601beb596c07e77e4e4cfaf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115160 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2021-05-05loplugin:constmethodNoel Grandin
Change-Id: I7913fd8144d521b8293ac43036d0fad82e457cd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115145 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-02throw() -> noexcept, part 2/3: Automatic loplugin:noexcept rewriteStephan Bergmann
Change-Id: I076f16d0536b534abf0ced4d76051eadb4c0e033 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-01tdf#124184 Fixing StrConv VBA Functiontushar
* vbUnicode/vbFromUnicode considers optional third LCID argument. * LCID is also used for other conversions. * The encoding is decided based on the language defined in LCID, or on program locale when LCID is omitted, using MS default ACP mapping for languages. * Unit testis for vbWide / vbNarrow are changed and enabled. * Unit tests for vbKatakana / vbHiragana are changed and enabled. * Unit test for vbFromUnicode / vbUnicode is changed to rely on en-US locale used in testing, and is enabled. Change-Id: Iabd4153db311cd02c3f3e7247f9fc71ad9f5f682 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112539 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-04-28use string_view in INetURLObject::encodeNoel Grandin
Change-Id: Ib686c6872388b02c8939d3b65f6bd25cda348bc8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114754 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-27loplugin:stringadd convert chained append to +Noel Grandin
which can use the more efficient *StringConcat Also fix a crash in stringview plugin which started happening while I working on this. Change-Id: I91a5b9b7707d1594d27d80b73930f5afac8ae608 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114568 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-27use more string_view in tools/streamNoel Grandin
Change-Id: I2a957cd72d71fea717734488cdb3670e0bcdd6f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114657 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-22no need makeStringAndClear() when appending to bufferNoel Grandin
it just creates an unnecessary temporary Change-Id: Ide3cd99b2ac4f2a621e5d55ce4bdc95d05430709 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114467 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-20use OUString::Concat here, not OUStringLiteralNoel Grandin
Change-Id: Ia2172bcab60f32c9d9d4f6ca0230484343eef69b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114321 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-08update PCHsLuboš Luňák
Change-Id: Ia9d04447f927e270a55500e7f35723a729bc01dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113801 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2021-04-07Updated README.md files to represent current code / use Markdown formatHossein
Previously, all of the README files have been renamed to README.md and now, the contents of these files were changed to use Markdown format. Other than format inconsistency, some README.md files lacked information about modules, or were out of date. By using LibreOffice / OpenOffice wiki and other documentation websites, these files were updated. Now every README.md file has a title, and some description. The top-level README.md file is changed to add links to the modules. The result of processing the Markdown format README.md files can be seen at: https://docs.libreoffice.org/ Change-Id: Ic3b0c3c064a2498d6a435253b041df010cd7797a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113424 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
2021-04-05tdf#141201 - Round MOD literals to Integer valuesAndreas Heinisch
(regression from commit I8dbfdf4bb2eceac0b5afbddd3f35e1dcde2db68b "tdf#84435: Mod operator does not deal with decimals as described in help"). Change-Id: I74b231d3814148579a3be0a92b7602fa4387281f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113571 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
2021-04-02Simplify some static variable initializationsMike Kaganski
Change-Id: I6cdd44aa66b9597ccc51fc3fd69b57485ccb3230 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113515 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-04-01cid#1473732 Untrusted loop boundCaolán McNamara
and cid#1474044 Untrusted loop bound Change-Id: If30dc454d60adca11fd1a53ecf472555e328bd42 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113441 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-03-30fix some --disable-scripting warningsCaolán McNamara
Change-Id: I0fa5ec5e0fc7a08f5558f013ec75fd7d4fe5c1a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113379 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-03-30cid#1474044 Untrusted loop boundCaolán McNamara
Change-Id: I9f060fe0b56905def7b81a9b7da0b504367eb36c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113337 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-03-29TypeName, VarType, TypeLen Basic QA test casesAlain Romedenne
1- exhibiting array type names 2- highlighting supplemental libO Basic constants 3- precising data types internal representations I intend to document in help: 1- primitive data types array names: Boolean(), Byte(), … as IsArray() function does not provide such info 2- Publish extra Basic constants for already published values: - V_OBJECT=9, V_BOOLEAN=11, V_VARIANT=12, V_BYTE=17 - not necessarily V_ARRAY=8192, V_ERROR=10 The latter is conditioned to the creation of an enhancement request. FYI, published Vartype() values and constants for VBA and other Basic-like languages: https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/vartype-function https://docs.xojo.com/VarType https://help.hcltechsw.com/dom_designer/9.0.1/appdev/LSAZ_DATATYPE_FUNCTION.html Change-Id: I51bac3caf555d94e91de7c6d624b3fca9e73a673 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111042 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-03-29cid#1474044 Untrusted loop boundCaolán McNamara
Change-Id: Ibb20ffc2219c25add421cd4803e80b15b131c93b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113306 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-03-26loplugin:flattenNoel
Change-Id: Ib7a895fba66f8dc9b6501e61631c02694053b7fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113157 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-03-25const OUString -> const OUStringLiteralMike Kaganski
Mostly automated rewrite Change-Id: Ie020a083f898bc126b8fb039d4ecb2e687172da1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112965 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-03-24Using .md extension/Markdown syntax for modules READMEHossein
Renaming all README files for all top level modules to README.md, applying no content change at this stage to be able to track history of the files. These files should be edited to use correct Markdown syntax later. Change-Id: I542fa3f3d32072156f16eaad2211a397cc212665 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112977 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2021-03-21tdf#88442 SBasic: Don't double-initialize a Global ... As New ...John
"As New" variables use lazy instantiation, but that should not re-apply each time one re-enters the module. If the object is still there, don't replace it. Change-Id: Ic568a56b93db9bc9139d434d97a4a4deb05840df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112018 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-03-20tdf#141050 Accept CCur with negative stringsarpit1912
the ImpStringToCurrency now increment the pointer on finding a '+' or '-' in sbxcurr.cxx file Change-Id: I4a1093ae0b4e52b6a61dc412bd5e7b95b1309e7a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112734 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
2021-03-15tdf#141045 - fixed copy paste error in the replace functionAndreas Heinisch
Change-Id: Id68670fed89e4cc700c5eea395139914bebdb657 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112509 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
2021-03-14check for quit when calling Yield in loopNoel Grandin
so we don't get stuck threads when the main application quits Change-Id: Id36e99267ceb4154873b6ef8ef494622fff6c19a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112409 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2021-03-09Drop "32" from names of SbxArray methods taking 32-bit indicesMike Kaganski
... a leftover from times when there were methods for 16-bit as well as for 32-bit indices. 16-bit indices were removed in commit 62f3f3d92aa204eaaa063b30d7ade44df501b997. Change-Id: Idf8b1160e68e8b303cf75ea79dd7dbb3bd00275d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112187 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-03-09Make sal/config.h the first in pchMike Kaganski
By convention, it should be the first include in C/CXX files; so use of pch should not break that. Change-Id: Ic329c5f39e8f48ad1778724368e262e48972342b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112123 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-03-08tdf#42982: improve UNO API error reportingViKrAm-Bais
Change-Id: I20080d81e0b08e6e0dcd421bd75cb7d796e97ea7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112149 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-03-07BASIC : use standard mutex from std.Arnaud Versini
Change-Id: Ie9abb32124b8718bbfde076f090180794c64f90e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108629 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-02-26loplugin:refcounting in basicNoel
Change-Id: Idbee5b35215f794e6785925dafb6f160caa24a22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111541 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-02-22loplugin:refcounting in basicNoel
Change-Id: I0c1e41436ddae176695a90c120303727aa3bc2ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111306 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-02-17tdf#130677 Write new tests for literalsshubham656
Change-Id: I22607fdcaab840ca1512abf534712d36d4b5ee9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109964 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de> Tested-by: Jenkins
2021-02-17tdf#42982 updated RunTimeException with 2nd argument(pointer)vipbuoy
Change-Id: I52dd9b9808e5fd61d07d4f8a6642124230ede23f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110971 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-02-16loplugin:referencecasting in basctl..binaryurpNoel
Change-Id: I3fbc287cf76e453e2c464837d2431ff19501fde3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110968 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-02-08update pchesCaolán McNamara
Change-Id: Icf55ddda055d11b649e7607c2cdd8b6d6ddfefbc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110483 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-02-05Revert "Fix typo in code"Stephan Bergmann
This reverts commit 3ed9bba283a6a67864c0928186e277240be0d9ba. osl_Pos_Absolut (include/osl/file.h) is part of the stable URE interface; it must not be changed. Change-Id: I1f49923a9351e4be5aee39b10720d38b424feb9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110435 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-04Fix typo in codeAndrea Gelmini
Change-Id: Ib8b306a27d25a34e784aeeb72708b0d5d1511f3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110394 Tested-by: Jenkins Reviewed-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2021-02-01basic : remove useless class pre declarationArnaud Versini
Change-Id: Iba78fb4d28651b298ed6ec5e53b30b2afebb28a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110203 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-01-29loplugin:stringviewparam extend to new..Noel
O[U]StringBuffer methods Change-Id: I0ffbc33d54ae7c98b5652434f3370ee4f819f6f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110090 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>