The problem is, that having a local variable referring the same value
as the original expression 'foo' is not the same as referencing 'foo'
itself. After 'foo' is re-assigned, the local variable still refers
to the original value, not the new one.
It seems impossible to implement the reference using existing codegen
primitives, to imitate the true reference to 'foo', not to its value.
If we implement it by changing the runtime, the bytecode won't work
identically in older versions; if we introduce a new bytecode, that
would be an incompatible change.
As a workaround, only create the local With variable, when the block
variable is created using some function (as much as known by parser).
I think that there would be cases when this would still not work as
intended: an example is a property implemented using getter function;
the parser would likely treat the property as a variable, and avoid
creation of the local variable; and the getter would be called every
time a dot access will happen (which was the essence of tdf#132064).
However, this seems a better alternative to the bug fixed here.
Change-Id: I50bf679762fd2e73f215a000fa0ab60fd6ae7453
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174564
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
An omission from commit 5ed103d2dd5f8ee2f13183263c0930f84437bdc7
(mib16: contributed bugfixes and various new symbols in VBA
compatibility implementation, 2010-06-15)
Change-Id: I1e08406eb1dcb64eeef5d925d22475f1b9f74de0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173426
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Other "WITH" blocks create the symbol that can be found by pPool->Find,
but can be not accessible at the call site.
Change-Id: I85ecc763a1bb3fd692c2c98e674047fdbde3f8f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173417
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
SbiRuntime::StepPUT, SbiRuntime::StepSET, SbiRuntime::StepVBASET call
checkUnoStructCopy eventually, which copies the UNO struct by value.
This is not what we need. On the other hand, SbiRuntime::StepPUTC only
makes the by-ref assignment, and makes the reference const; but Basic
code never assigns anything to the internal variable itself, only to
its members.
I hope that this time, I get it right.
Change-Id: I2b4a51a2dca9e7106e14e03360ef0d5a50b60079
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173305
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
In commit f3f46b5fe729876d128f63f7ab158954ab6657d7 (tdf#132064: make
With statement only evaluate its argument once, 2024-08-17), I made
a mistake, clearing the internal variable in the end of SbiParser::With
using an Erase call, which does not just clears the variable itself,
but destroys the underlying object, which is not what we need.
I don't know how to refer to a global Nothing object to assign to the
variable; so just create an own internal Nothing, and use it in the
assignment.
Change-Id: Ic8ce52e0402d8461a9b9e4ee07614c4f0a46a95e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172006
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
As required by [MS-VBAL], and actual VBA implementation.
It is a question if we also need to change it likewise in other
modes (normal, compatible) - see tdf#150460.
Change-Id: I1e83d57fe4be3bf264a64fe977909cf7684bc798
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172005
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This is implemented by creating a unique variable at entry of the
block, using it as the "with parent", and clearing afterwards. It
uses an invalid name, so can't be used by a user. The generation
of the bytecode is done in compatible way; only existing opcodes
were used (which was the reason to choose the implementation with
a variable), so compiled binaries in password-protected libraries
are expected to work with older versions.
The functional changes are:
1. The argument of With statement is evaluated immediately at the
start of the block; previously, it evaluated first time, when the
leading dot operator was used, and could even be never evaluated,
if the operator wasn't used. This is consistent with VBA, and has
a benefit that the lifetime of the object is guaranteed to cover
the whole block (might be useful if other block statements depend
on the object, similar to Python's 'with' statement contexts).
2. The primary goal of the change: it is only ever evaluated once,
no matter how many times was the dot operator used in the block.
Change-Id: I4dbd520538a57e3668ab706e8f45740db5d33393
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171980
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Intent is to cover:
- EndIf / End If equivalence
- repeating ElseIf blocks
_ nested IF statements
- IF THEN one liner
Change-Id: I667f0381529afcc82fc44ae461081f7ba84b01d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171352
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Don't execute On expression GoSub Statement; On expression GoTo
Statement if the expression lies out of range.
Change-Id: I5c1de25918b5e812d7ec82034f8d56351374d56a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165960
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
- vcl change UNO type of UnoGraphicProperty::BitsPerPixel to sal_Int8 instead of sal_uInt8 which maps to BOOLEAN causing Basic to convert
non-0 values to True
- basic add CppUnitTest since thats where the problem was occuring
Change-Id: I0111199151fb5e001b6362e1359ad90bb039f064
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163899
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Previously, BASIC CCur used a custom, single-purpose currency string
parser which did not properly accommodate the user's locale setting.
This change replaces the custom parser with SvNumberFormatter, which
does correctly respect system locale.
Change-Id: I179915eb080e876e5e550dd350fdb86d7fa2bf4c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160848
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Exponent in scientific number may use '?' as blank like in format "0.00E+?0"
This change:
- adds interpreatation of '0' and '?' in exponent
- adds "blank-exponent-digits" attribute to scientific number for import
and export to ODF
- prevents using exponent with only '?'. There must be at least one '0'
in exponent
- adds QA test of such format and test import/export/import to ODF and OOXML
- corrects one basic test
Change-Id: If52edc632a161f842270bb2fd77af535e2b978d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154986
Tested-by: Jenkins
Reviewed-by: Laurent Balland <laurent.balland@mailo.fr>
...now that warning about O[U]String vars that could be O[U]StringLiteral is no
longer useful
Change-Id: I389e72038171f28482049b41f6224257dd11f452
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157992
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Instead of returning ErrCode class everywhere, return a new
class ErrrCodeMsg, which combines an ErrCode with the other
parameters that are used to control the error reporting.
I do not change everything that uses ErrCode here, I started
from SfxBaseController/SfxMedium and worked outwards.
This change serves two purposes
(1) Replace the extremely whacky ErrorInfo mechanism we were
using to smuggle information into the error handler reporting
mechanism with a very straightforward approach of just combining it
into the error class.
(2) Allow us to capture the source location that produced the error,
which makes debugging the source of a problem soooo much easier.
Change-Id: I978b8f00c9851b41a216c7ebdef2ef94251d5519
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157440
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This properly handles null bytes that are expected
when converting between byte strings and Unicode.
It properly handles TransliterationFlags, which are
not a bitset.
In vbProperCase, it uses the correct method to
lowercase the string, working not only with ASCII.
Change-Id: I04e8cdca66ef9863a6516b15205a2a543ed97680
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149224
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Building CppunitTest_basic_macros using VS2022 failed for me reproducibly
for some time, with
make[1]: *** [C:/lo/src/core/solenv/gbuild/LinkTarget.mk:841: C:/lo/src/build/workdir/LinkTarget/CppunitTest/test_basic_macros.dll] Error 139
It is caused by linking odbccp32, and legacy_stdio_definitions required
by the latter with current versions of UCRT.
It seems to work OK for others; but being unable to find what's different
on my system, I have this workaround, using run-time loading instead.
Change-Id: Ic4094398f7510bc281dfa96f980f29f12f09d7ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147626
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
cppu::UnoType<sal_uInt8> corresponds to UNO boolean, so its use made the
unsigned values be converted to a true/false in Any; and additionally,
using such a boolean Any, even having a 'true' value, as a parameter to
a double argument would make operator >>=(const Any &, double &) return
false, giving the resulting double equal to 0.
The wrong conversion of UShorts and ULongs to cppu::UnoType<sal_uInt8>
(aka TypeClass_BOOLEAN) was introduced in commit
11f9aa4fcb2ad0a5fada8561c7041e7f25a059fc
Author Andreas Bregas <ab@openoffice.org>
Date Thu May 10 14:22:42 2001 +0000
#79615# sbxToUnoValue(): Choose smallest possible type for numeric values
Treating of unsigned Basic Byte as a signed cppu::UnoType<sal_Int8> (aka
TypeClass_BYTE) was already introduced in
commit c25ec0608a167bcf1d891043f02273761c351701
Author Jens-Heiner Rechtien <hr@openoffice.org>
Date Mon Sep 18 15:18:56 2000 +0000
initial import
Then, in commit 553cf2a834fcca17be6f7712c53e190e90e260eb
Author Andreas Bregas <ab@openoffice.org>
Date Fri Jun 08 14:59:57 2001 +0000
#87927# Map TypeClass_BYTE to SbxINTEGER instead of SbxBYTE because of signed/unsigned problem
an attempt was made to handle obviously this same problem, changing the
corresponding UNO type to TypeClass_SHORT. But it seems that it created
problems when passing arrays of Byte through UNO to COM, where it needed
to convert to a safearray, so this decision was reverted in commit
dd6ba6b64aec20d37a402bee233e742e29285e88
Author Mikhail Voytenko <mav@openoffice.org>
Date Thu Jul 08 21:33:48 2010 +0200
mib17: #162917# let basic byte use one byte, let olebridge convert sequence to safearray correctly
This change tries to avoid the problem that caused the latter revert,
by only treating Bytes as UNO shorts in getUnoTypeForSbxValue, where
scalar Byte values are considered, keeping old handling for arrays.
Change-Id: I805108743376e2fc27dd21a27c31759b76dc0d09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136526
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Moves the custom cleanup logic to overridden SbxMethod::Clear, to simplify
the cleanup code and make sure it restores empty Variant correctly.
Change-Id: I01fa0529acd9ac787ffcda60fd6836ade4afdcb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136108
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>