ScriptForge (Form) Fix missing attributes

When a FormControl instance is created
triggered by an event with
   fc = CreateScriptService("FormEvent", event)
a number of attributes are not
(re)-initialized in the parent Form instance.

They concern references to the form document
container and to the database connetction.

The absences prevent from scripting easily
(workarounds exist) operations on the form
document (close, print, ...) or towards the
database (read, sql, ...). In particular,
this limits the reusability of scripts
across >1 form documents.

This is a bug. It is fixed with the actual change.

Documentation may be left unchanged.
Basic and Python scripts are impacted alike.

Change-Id: I285148917174d5a046c11b15ea2a2581a23d4277
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187854
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
This commit is contained in:
Jean-Pierre Ledure
2025-07-14 11:38:07 +02:00
parent 027752fd96
commit c2a5e575e5
3 changed files with 20 additions and 15 deletions

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="SFDatabases" library:readonly="false" library:passwordprotected="false">
<library:element library:name="SF_Dataset"/>
<library:element library:name="SF_Datasheet"/>
<library:element library:name="SF_Database"/>
<library:element library:name="__License"/>
<library:element library:name="SF_Register"/>
<library:element library:name="__License"/>
<library:element library:name="SF_Database"/>
<library:element library:name="SF_Datasheet"/>
<library:element library:name="SF_Dataset"/>
</library:library>

View File

@ -1263,7 +1263,12 @@ Try:
_FormType = ISBASEFORM
&apos; Make a new SF_FormDocument instance
Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.FormDocument&quot;, oParent)
Set _FormDocument = [_Parent]._FormDocument
With [_Parent]
Set _FormDocument = ._FormDocument
_FormDocumentName = ._HierarchicalName
Set _BaseComponent = ._BaseComponent
Set _Component = ._Component
End With
ElseIf oParent.Identifier = &quot;com.sun.star.text.TextDocument&quot; Then
_FormType = ISDOCFORM
Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.Document&quot;, oParent)

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="SFDocuments" library:readonly="false" library:passwordprotected="false">
<library:element library:name="__License"/>
<library:element library:name="SF_Form"/>
<library:element library:name="SF_DocumentListener"/>
<library:element library:name="SF_Document"/>
<library:element library:name="SF_Calc"/>
<library:element library:name="SF_Writer"/>
<library:element library:name="SF_Register"/>
<library:element library:name="SF_Base"/>
<library:element library:name="SF_FormControl"/>
<library:element library:name="SF_FormDocument"/>
<library:element library:name="SF_Chart"/>
<library:element library:name="SF_FormDocument"/>
<library:element library:name="SF_FormControl"/>
<library:element library:name="SF_Base"/>
<library:element library:name="SF_Register"/>
<library:element library:name="SF_Writer"/>
<library:element library:name="SF_Calc"/>
<library:element library:name="SF_Document"/>
<library:element library:name="SF_DocumentListener"/>
<library:element library:name="SF_Form"/>
<library:element library:name="__License"/>
</library:library>