Bug 157672 - SFDocument.Form.Controls("ControlName") method fails in Calc document when control name given and Containing Sheet is NOT active
Summary: SFDocument.Form.Controls("ControlName") method fails in Calc document when co...
Status: RESOLVED INSUFFICIENTDATA
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.6.2.1 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-09 19:32 UTC by brad@lanier.ws
Modified: 2024-04-16 12:19 UTC (History)
3 users (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 brad@lanier.ws 2023-10-09 19:32:35 UTC
Description:
In the SourceForge Macro Library, SFDocument.Form.Controls("ControlName") method fails in a Calc document when a control name parameter is given and the sheet that the control is on is NOT the active sheet. Note that the method works properly when no Control name is given. Also note thet the Subforms("SubFormName") method works fine whether or not the containing sheet is active.

Steps to Reproduce:
1. In a calc sheet, create DB Form with controls and a subform
2. Retrieve the SF Form object
3. Ensure a different sheet is Active
4. Execute the SFDocument.Form.Controls("ControlName") method, naming the control
5. Observe the failure

Actual Results:
SFDocument.Form.Controls("ControlName") method fails with the following MessageBox contents:

Library :   SFDocuments
Service :   Form
Method :    Controls


The ScriptForge library has crashed. The reason is unknown.
Maybe a bug that could be reported on
    https://bugs.documentfoundation.org/

More details : 

Location : SFDocuments.Form.Controls/637
An exception occurred 
Type: com.sun.star.container.NoSuchElementException
Message: .


THE EXECUTION IS CANCELLED.

Expected Results:
Normal execution, whether or not the containing sheet is active


Reproducible: Always


User Profile Reset: No

Additional Info:
1. SFDocument.Form.Controls("") works and returne the full control list, whether or not the containing sheet is active.
2. SFDocument.Form.Subforms("SubFormName") works and returns the SubForm Object, whether or not the containing sheet is Active.
3. SFDocument.Form.Controls("ControlName") works if the containing sheet is first made active.
Comment 1 brad@lanier.ws 2023-10-09 20:03:21 UTC
In the deacription section, the first line reading "In the SourceForge Macro Library.....". That should read "In the ScriptForge Macro Library....."
Comment 2 Xisco Faulí 2023-10-10 10:19:40 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 3 Rafael Lima 2024-01-12 13:36:46 UTC
I am unable to reproduce this bug.

I created a Calc file and added a Table control to Sheet1. Then I added 2 more sheets and from Sheet3 I called the following macro:

Sub TestForm
  GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
  oDoc = CreateScriptService("Document", ThisComponent)
  oForm = oDoc.Forms("Sheet1", "Form")
  oControl = oForm.Controls("Table1")
  MsgBox oControl.Name
End Sub

The macro worked fine. Can you please confirm that the bug persists?

System info

Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 16; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Ubuntu package version: 4:7.6.4-0ubuntu0.23.10.1
Calc: threaded
Comment 4 Rafael Lima 2024-04-16 12:19:00 UTC
This bug has been in NEEDINFO for 3 months now. I'm closing this due to insufficient data.

Fell free to reopen if you have anything new to add.