Bug 147571 - DefObj in conflict with elements predefinded structures
Summary: DefObj in conflict with elements predefinded structures
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-21 11:04 UTC by profagrzanka
Modified: 2024-02-23 03:14 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description profagrzanka 2022-02-21 11:04:56 UTC
Repeated after my post https://ask.libreoffice.org/t/defobj-in-conflict-with-elements-predefinded-structures/74331

I am using the DefObj o statement. Unexpectedly, this declaration is applied also to elements of predefined structures. The example below fails with an error.

DefObj o
Sub Main
  oSheet = ThisComponent.Sheets(0)
'...
  Dim Constraints(1) as new com.sun.star.sheet.SolverConstraint
  With Constraints(0)
    .Left = oSheet.getCellRangeByName("G15").CellAddress
    .Operator = com.sun.star.sheet.SolverConstraintOperator.LESS_EQUAL
    .Right = 1.5
  End With
'...
End Sub

The error is that the .Operator element is interpreted as an object. After removing the statement DefObj everything is OK.
Is this behavior consistent with the intention to use the DefObj statement?
Comment 1 Mike Kaganski 2022-02-21 11:34:17 UTC
Repro using Version: 7.3.1.1 (x64) / LibreOffice Community
Build ID: 349cd3ad57dce98d6b54b76f8e9f456ac7d7edb7
CPU threads: 12; OS: Windows 10.0 Build 19044; UI render: default; VCL: win
Locale: en-US (ru_RU); UI: en-US
Calc: CL

and also using OOo 3.2.0.

An even simpler reproducer could be

  DefObj o
  Sub test
    o = 1 ' gives "Object variable not set." runtime error
  End Sub
Comment 2 Mike Kaganski 2022-02-21 11:41:47 UTC
(In reply to Mike Kaganski from comment #1)
> An even simpler reproducer could be
> 
>   DefObj o
>   Sub test
>     o = 1 ' gives "Object variable not set." runtime error
>   End Sub

Oh, please scrap that piece - of course, it's a thinko. The original code from comment 0 is relevant.
Comment 3 profagrzanka 2022-02-21 15:51:08 UTC
Hi Mike,

You have inspired me to check it out:

DefObj o
Sub Main
  Dim o As Integer
  o = 1
End Sub

The above declaration precedence is OK. Can't we apply this principle to predefined structures like in my example?

Antoni
Comment 4 profagrzanka 2022-02-21 16:36:39 UTC
One more example that partially contradicts my previous comment.

DefObj o
Sub Test
  Dim Constraints As New com.sun.star.sheet.SolverConstraint
  MsgBox(TypeName(Constraints.Operator))
  Constraints.Operator = 1
End Sub

Whether we apply the DefObj declaration or not, TypeName reports the type as Long according to expectation. However, setting a value of 1 to the Operator element stops working only in case when declaring DefObj.
Comment 5 QA Administrators 2024-02-23 03:14:53 UTC
Dear profagrzanka,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug