[Libreoffice-bugs] [Bug 52601] Excel Visual Basic compatibility issue in LibreOffice Calc: If Not ... Like … Then

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Mon Jul 24 00:53:49 UTC 2017


https://bugs.documentfoundation.org/show_bug.cgi?id=52601

--- Comment #9 from himajin100000 at gmail.com ---
* Explanations are often easier to understand when we begin with easy lessons,
even if the lessons are not directly focusing the problem I'm facing.

* To begin with, let's take a look at the following code SbiExprNode*
SbiExpression::Comp()
https://opengrok.libreoffice.org/xref/core/basic/source/comp/exprtree.cxx?r=85d71244#727

* I see Cat() called in Comp(). This means string concatenation binary operator
has stronger associativity
the expression a & b < c  is interpreted as ((a & b) < c) , but not as (a & (b
< c))

* now let's move onto SbiExprNode* SbiExpression::Like()
https://opengrok.libreoffice.org/xref/core/basic/source/comp/exprtree.cxx?r=85d71244#727

* when VBASupport is 0,
https://opengrok.libreoffice.org/xref/core/basic/source/comp/exprtree.cxx?r=85d71244#754
"NOT" keyword is handled deeper callees inside Comp.

* when VBASupport is 1
"NOT" keyword is handled in VBA_not and there Comp is called later.

This two descriptions mean the following results from the same code.

in VBASupport 1

NOT 3 < 5 
=> (NOT (3 < 5))
=> (NOT (-1))
=> 0 

in VBASupport 0

((NOT 3) < 5)
(-4 < 5)
-1

Likewise we can say
-2^2 is (-2)^2 in VBASupport 0, VBASupport 1, and cell formulas in Calc and
Excel. In MS Office VBA, the expression is -(2^2)

*in both VBASuppport 0 and in VBASupport 1
as NOT has higher associativity than LIKE, the result of the following code  is
as follows

NOT "xyz" LIKE "xyz"
=>((NOT "xyz") LIKE "xyz")

but not

(NOT ("xyz" LIKE "xyz"))

Here we try to evaluate (NOT "xyz") and give up. (runtime error, not compile
error)

*If the function used returns boolean or Integer, the code runs without giving
runtime error.
the result of NOT operation seems to be converted to string and passed to LIKE
operator's first operand.

Sub Main()
        Msgbox(NOT Foo("bar") LIKE "Meaningless sample text : - NOT 13 gives
compile error when VBASupport is 1. I don't know the intention of If statement
in SbiExpression::Unary()")
End Sub

Function Foo(meaninglessparameter as string) As Integer
        Foo = 1
End Function

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20170724/c2025414/attachment.html>


More information about the Libreoffice-bugs mailing list