summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Romedenne <alain.romedenne@libreoffice.org>2021-05-25 16:22:46 +0200
committerRafael Lima <rafael.palma.lima@gmail.com>2021-06-11 14:35:35 +0200
commitab81b6bfa02cd89c244bc55148486324863844f8 (patch)
tree1ee6c25430a40004ae25550090b3c4e2a72db4ca
parenttdf#130063 Add Help page for revamped B&N dialog for Impress and Draw (diff)
downloadhelp-ab81b6bfa02cd89c244bc55148486324863844f8.tar.gz
help-ab81b6bfa02cd89c244bc55148486324863844f8.zip
sf_form(control) Python support
Change-Id: Iad14d1c5c7d353e50aba84d0cfa461e56f69f4ef Reviewed-on: https://gerrit.libreoffice.org/c/help/+/115969 Tested-by: Jenkins Reviewed-by: Rafael Lima <rafael.palma.lima@gmail.com>
-rw-r--r--source/text/sbasic/shared/03/lib_ScriptForge.xhp18
-rw-r--r--source/text/sbasic/shared/03/sf_form.xhp218
-rw-r--r--source/text/sbasic/shared/03/sf_formcontrol.xhp90
3 files changed, 206 insertions, 120 deletions
diff --git a/source/text/sbasic/shared/03/lib_ScriptForge.xhp b/source/text/sbasic/shared/03/lib_ScriptForge.xhp
index 522fb1e83..15eb73a56 100644
--- a/source/text/sbasic/shared/03/lib_ScriptForge.xhp
+++ b/source/text/sbasic/shared/03/lib_ScriptForge.xhp
@@ -18,6 +18,7 @@
<h1 id="hd_id31529004750471" xml-lang="en-US"><variable id="ScriptForge_lib"><link href="text/sbasic/shared/03/lib_ScriptForge.xhp" name="ScriptForge library">The <literal>ScriptForge</literal> Library</link></variable></h1>
<bookmark xml-lang="en-US" branch="index" id="bm_id491529070339774">
<bookmark_value>BASIC ScriptForge library</bookmark_value>
+ <bookmark_value>Python scriptforge module</bookmark_value>
</bookmark>
<section id="howtoget">
<embed href="text/sbasic/shared/00000003.xhp#basiclibhowtoget"/>
@@ -76,15 +77,13 @@
<tablecell>
<paragraph role="paragraph" localize="false" id="par_id771613836902464">
<link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Base" name="Base service">Base</link><br/>
- <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Calc" name="Calc service">Calc</link><br/>
- <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Database" name="Database service">Database</link>
+ <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Calc" name="Calc service">Calc</link>
</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id441543838858931" localize="false" role="tablecontent">
- <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Document" name="Document service">Document</link><br/>
- <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Form" name="Form service">Form</link><br/>
- <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#FormControl" name="FormControl service">FormControl</link>
+ <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Database" name="Database service">Database</link><br/>
+ <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Document" name="Document service">Document</link>
</paragraph>
</tablecell>
</tablerow>
@@ -100,7 +99,10 @@
</paragraph>
</tablecell>
<tablecell>
- <paragraph id="par_id441613885558931" localize="false" role="tablecontent"></paragraph>
+ <paragraph id="par_id441613885558931" localize="false" role="tablecontent">
+ <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Form" name="Form service">Form</link><br/>
+ <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#FormControl" name="FormControl service">FormControl</link><br/>
+ </paragraph>
</tablecell>
</tablerow>
<tablerow>
@@ -111,14 +113,14 @@
<paragraph role="tablecontent" localize="false" id="par_id461613837133275">
<link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Basic" name="Basic service">Basic</link><br/>
<link href="text/sbasic/shared/03/lib_ScriptForge.xhp#L10N" name="L10N service">L10N</link><br/>
- <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Platform" name="Platform service">Platform</link><br/>
+ <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Platform" name="Platform service">Platform</link>
</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id441613723858931" localize="false" role="tablecontent">
<link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Services" name="Services service">Services</link><br/>
<link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Session" name="Session service">Session</link><br/>
- <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Timer" name="Timer service">Timer</link><br/><br/>
+ <link href="text/sbasic/shared/03/lib_ScriptForge.xhp#Timer" name="Timer service">Timer</link>
</paragraph>
</tablecell>
</tablerow>
diff --git a/source/text/sbasic/shared/03/sf_form.xhp b/source/text/sbasic/shared/03/sf_form.xhp
index 47847b0bc..efb3fb493 100644
--- a/source/text/sbasic/shared/03/sf_form.xhp
+++ b/source/text/sbasic/shared/03/sf_form.xhp
@@ -41,10 +41,9 @@
<tip id="par_id351616768789190" xml-lang="en-US">The <literal>SFDocuments</literal>.<literal>Form</literal> service is available from %PRODUCTNAME 7.2 onwards.</tip>
<paragraph role="paragraph" id="par_id451616765867881" xml-lang="en-US">Forms are usually used in %PRODUCTNAME documents to create user interfaces connected to relational databases. Hence, the <literal>Form</literal> service provides quick access to the linked database through the <link href="text/sbasic/shared/03/sf_database.xhp" name="SFDatabases.Database"><literal>SFDatabases</literal>.<literal>Database</literal> service</link>.</paragraph>
<tip id="par_id891598188164936" xml-lang="en-US">The <literal>SFDocuments</literal>.<literal>Form</literal> service is closely related to the <link href="text/sbasic/shared/03/sf_formcontrol.xhp" name="SFDocuments.FormControl"><literal>SFDocuments</literal>.<literal>FormControl</literal> service.</link></tip>
-
<h2 id="hd_id161616766330804" xml-lang="en-US">Definitions</h2>
<h3 id="hd_id751616766382317" xml-lang="en-US" localize="false">FormDocument</h3>
- <paragraph role="paragraph" id="par_id951618172906010">Forms are usually created in Base documents, but they can be added to Writer and Calc documents as well. The way a <literal>FormDocument</literal> is handled depends on the %PRODUCTNAME component where it is stored.</paragraph>
+ <paragraph role="paragraph" id="par_id951618172906010">Forms are usually created in Base documents, but they can be added to Writer and Calc documents as well.</paragraph>
<paragraph role="paragraph" id="par_id671618173380680">In Base, each form you create using the <menuitem>Insert - Form</menuitem> functionality or through the <link href="text/shared/autopi/01090000.xhp" name="FormWizard">Form Wizard</link> is actually a <literal>FormDocument</literal> that can be handled with the <literal>Form</literal> service. Base documents can contain an unlimited number of form documents.</paragraph>
<paragraph role="paragraph" id="par_id841618177362626">Below is an example showing the hierarchy of all the elements involved in accessing forms and subforms in a Base document. Suppose you have a Base file named <literal>Employees.odb</literal> and inside it you created a form document to add new employees to the database. The form document contains a main form named <literal>EmployeeData</literal> that gives access to a table. There is also a subform <literal>WorksAtPlant</literal> that allows you to associate the new employee to one of the plants of the company.</paragraph>
<bascode>
@@ -57,54 +56,78 @@
<paragraph role="bascode" localize="false" id="bas_id291618176869942"> |-- WorksAtPlant (SubForm)</paragraph>
</bascode>
<note id="par_id221618173444457">A <literal>FormDocument</literal> can be seen as a set of forms that provide access to datasets such as database tables and queries from within %PRODUCTNAME documents. The names of forms and subforms inside a FormDocument can be accessed using the <link href="text/shared/02/01170600.xhp" name="FormNavigator">Form Navigator</link>.</note>
- <paragraph role="paragraph" id="par_id721618175731903">In Calc documents, each sheet can contain a single <literal>FormDocument</literal>. A Writer document contains only one <literal>FormDocument</literal>, which is the document itself.</paragraph>
-
<h3 id="hd_id851616767037521" xml-lang="en-US">Forms and Subforms</h3>
<paragraph role="paragraph" id="par_id681616767265034" xml-lang="en-US">A form document is composed of one or more forms which, in turn, may also contain any number of subforms. A Form is an abstract set of controls that are linked to a specified data source, which can be a database table, a query or a SQL <literal>SELECT</literal> statement.</paragraph>
<paragraph role="paragraph" id="par_id711618178831976">In Calc and Writer documents, each form can be linked to datasets located in different databases. On the other hand, in Base documents the database contained in the document is common to all forms.</paragraph>
<tip id="par_id191616837111507" xml-lang="en-US">To invoke the <literal>SFDocuments</literal>.<literal>Form</literal> service refer to the methods <literal>Forms()</literal>, <literal>FormDocuments()</literal> and <literal>OpenFormDocument()</literal> of the <link href="text/sbasic/shared/03/sf_document.xhp" name="SFDocuments"><literal>SFDocuments</literal>.<literal>Document</literal></link> service</tip>
-
<section id="serviceInvocation">
<h2 id="hd_id581582885621841" xml-lang="en-US">Service invocation</h2>
<h3 id="hd_id991618179698545">In Writer documents</h3>
- <paragraph role="paragraph" id="par_id51616767892693" xml-lang="en-US">The code snippet below shows how to access the form named <literal>Form1</literal> that is inside the single <literal>FormDocument</literal> of a Writer file:</paragraph>
+ <paragraph role="paragraph" id="par_id51616767892693" xml-lang="en-US">The code snippet below shows how to access the form named <literal>Form1</literal> that is inside a Writer file:</paragraph>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id471598171198389">Dim oDoc As Object, myForm As Object, ui as Object</paragraph>
<paragraph role="bascode" localize="false" id="bas_id561618179461775">Set ui = CreateScriptService("UI")</paragraph>
<paragraph role="bascode" localize="false" id="bas_id611598171572062">Set oDoc = ui.OpenDocument("~/Documents/MyForm.odt")</paragraph>
<paragraph role="bascode" localize="false" id="bas_id571598171205739">Set myForm = oDoc.Forms("Form1")</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id241622014444493">from scriptforge import CreateScriptService</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id391622014212514">svc = CreateScriptService('UI') </paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id891622014222625">doc = svc.OpenDocument('~/Documents/MyForm.odt')</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id931622014224129">my_form = doc.Forms('Form1')</paragraph>
+ </pycode>
<paragraph role="paragraph" id="par_id531618179517628">Forms can be accessed by their names or by their indices, as shown below:</paragraph>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id991598171277414">Set myForm = oDoc.Forms(0)</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id691622014677169">my_form = doc.Forms(0)</paragraph>
+ </pycode>
<warning id="par_id181618250546617">If you try to access a <literal>FormDocument</literal> that is currently opened in <emph>Design Mode</emph> an exception will be raised.</warning>
- <h3 id="hd_id921618179792926">In Calc documents</h3>
- <paragraph role="paragraph" id="par_id481618179851104">Each sheet in a Calc file is a single <literal>FormDocument</literal>. Hence, the <literal>Forms</literal> method requires two arguments, the first indicating the sheet name and the second specifying the form name.</paragraph>
+ <h3 id="hd_id921618179792926">In Calc documents</h3>
+ <paragraph role="paragraph" id="par_id481618179851104">A form in a Calc file must have a unique name inside its sheet. Hence, the <literal>Forms</literal> method requires two arguments, the first indicating the sheet name and the second specifying the form name.</paragraph>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id471598171198125">Dim oDoc As Object, myForm As Object, ui as Object</paragraph>
<paragraph role="bascode" localize="false" id="bas_id561618179462475">Set ui = CreateScriptService("UI")</paragraph>
<paragraph role="bascode" localize="false" id="bas_id611598170362062">Set oDoc = ui.OpenDocument("~/Documents/MyForms.ods")</paragraph>
<paragraph role="bascode" localize="false" id="bas_id571598171200339">Set myForm = oDoc.Forms("Sheet1", "Form1")</paragraph>
</bascode>
- <h3 id="hd_id201618180055756">In Base documents</h3>
- <paragraph role="paragraph" id="par_id711616768164987" xml-lang="en-US">A <literal>FormDocument</literal> inside a Base document is accessed by its name. The following example opens the form document named <literal>thisFormDocument</literal> and access the form <literal>MainForm</literal>:</paragraph>
+ <paragraph role="paragraph" id="par_id51622028165429">This is achieved identically using Python:</paragraph>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id871622021672708">svc = CreateScriptService('UI')</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id671622021672931">doc = svc.OpenDocument('~/Documents/MyForms.ods')</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id301622021673180">my_form = doc.Forms('Sheet1', 'Form1')</paragraph>
+ </pycode>
+ <h3 id="hd_id201618180055756">In Base documents</h3>
+ <paragraph role="paragraph" id="par_id711616768164987" xml-lang="en-US">A <literal>FormDocument</literal> inside a Base document is accessed by its name. The following example opens the form document named <literal>thisFormDocument</literal> and accesses the form <literal>MainForm</literal>:</paragraph>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id471598176518738">Dim oDoc As Object, myForm As Object</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id271598171282891">Set oDoc = CreateScriptService("SFDocuments.Document", ThisDatabaseDocument)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id471598176518738">Dim oDb As Object, myForm As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id271598171282891">Set oDb = CreateScriptService("SFDocuments.Document", ThisDatabaseDocument)</paragraph>
<paragraph role="bascode" id="bas_id271598171225874">' The statement below is necessary only if the form hasn't been opened yet</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id551598171288547">oDoc.OpenFormDocument("thisFormDocument")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id551598171288547">oDb.OpenFormDocument("thisFormDocument")</paragraph>
<paragraph role="bascode" localize="false" id="bas_id741598171294507">Set myForm = oDoc.Forms("thisFormDocument", "MainForm")</paragraph>
<paragraph role="bascode" id="bas_id51616768358888">' Or, alternatively, to access the form by its index ...</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id591598171300285">Set myForm = oDoc.Forms("thisFormDocument", 0)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id591598171300285">Set myForm = oDb.Forms("thisFormDocument", 0)</paragraph>
</bascode>
- <note id="par_id991618249636036">To perform any action on a form using the <literal>Form</literal> service, the <literal>FormDocument</literal> must have been opened either manually by the user or programmatically in a user script. The latter can be done in a variety of ways, such as by creating an instance of the <literal>Document</literal> service or by calling the methods <literal>OpenDocument</literal> (<literal>UI</literal> service) and <literal>OpenFormDocument</literal> (<literal>Document</literal> service).</note>
+ <note id="par_id991618249636036">To perform any action on a form using the <literal>Form</literal> service, the <literal>FormDocument</literal> must have been opened either manually by the user or programmatically in a user script. The latter can be done by calling the <literal>OpenFormDocument</literal> method of the <link href="text/sbasic/shared/03/sf_base.xhp" name="ScriptForge Base Service"><literal>Base</literal> service</link>.</note>
<paragraph role="paragraph" id="par_id11618180564274">To access a given subform of a form use the <literal>SubForms</literal> method. Note that in the example below <literal>mySubForm</literal> is a new instance of the <literal>Form</literal> service.</paragraph>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id71618182658792">Dim mySubForm As Object</paragraph>
<paragraph role="bascode" localize="false" id="bas_id681616768495330">Set mySubForm = myForm.SubForms("mySubForm")</paragraph>
</bascode>
- <h3 id="hd_id211618180379064">In Form events</h3>
+ <paragraph role="paragraph" id="par_id681622028653480">Previous examples translate in Python as:</paragraph>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id501622028742999">db = CreateScriptService('SFDocuments.Document', XSCRIPTCONTEXT.getDocument())</paragraph>
+ <paragraph role="pycode" id="pyc_id811622808499801"># The statement below is necessary only if the form hasn't been opened yet</paragraph>
+ <paragraph role="pycode" id="pyc_id671622028743191">form_doc = db.OpenFormDocument('thisFormDocument')</paragraph>
+ <paragraph role="pycode" id="pyc_id431622028743374">form = form_doc.Forms('thisFormDocument', 'MainForm')</paragraph>
+ <paragraph role="pycode" id="pyc_id511622808538351"># Or, alternatively, to access the form by its index ...</paragraph>
+ <paragraph role="pycode" id="pyc_id681622028743582">form = form_doc.Forms('thisFormDocument', 0)</paragraph>
+ <paragraph role="pycode" id="pyc_id611622028743782">sub_form = form.SubForms('mySubForm')</paragraph>
+ </pycode>
+ <h3 id="hd_id211618180379064">In Form events</h3>
<paragraph role="paragraph" id="par_id421616768529754" xml-lang="en-US">To invoke the <literal>Form</literal> service when a form event takes place:</paragraph>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id931616768628138">Sub OnEvent(ByRef poEvent As Object)</paragraph>
@@ -113,9 +136,22 @@
<paragraph role="bascode" localize="false" id="bas_id1001618180405172"> '(...)</paragraph>
<paragraph role="bascode" localize="false" id="bas_id751618180415566">End sub</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id551622022387877" localize="false">def OnEvent(event: uno):</paragraph>
+ <paragraph role="pycode" id="pyc_id081622022388165" localize="false"> form = CreateScriptService('SFDocuments.FormEvent', event)</paragraph>
+ <paragraph role="pycode" id="pyc_id641622022388397" localize="false"> pass</paragraph>
+ </pycode>
<embed href="text/sbasic/shared/03/sf_formcontrol.xhp#FormEvent_Note"/>
+ <paragraph role="paragraph" id="par_id721623150543016">It is recommended to free resources after use of the Form service.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id751681880415566">myForm.Dispose() ' using Basic</paragraph>
+ </bascode>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id551226022387877" localize="false">form.Dispose() # using Python</paragraph>
+ </pycode>
+ <paragraph role="paragraph" id="par_id221623150547406">This operation is done implicitly when a form document is closed with the <literal>CloseFormDocument()</literal> method described below.</paragraph>
</section>
-
<h2 id="hd_id651583668365757" xml-lang="en-US">Properties</h2>
<table id="tab_id381583668386455">
<tablerow>
@@ -329,7 +365,6 @@
</tablecell>
</tablerow>
</table>
-
<h2 id="hd_id421612628828054" xml-lang="en-US">Event properties</h2>
<paragraph role="paragraph" id="par_id41612629140856" xml-lang="en-US">The properties below return or set URI strings that define the script triggered by the event.</paragraph>
<table id="tab_id951612628879819">
@@ -535,7 +570,6 @@
</paragraph></tablecell>
</tablerow>
</table>
-
<section id="Activate">
<comment> Activate -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id721583933076548">
@@ -556,9 +590,7 @@
</listitem>
</list>
<h3 id="hd _id61583933076171" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id731583933076815">myForm.Activate() As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id11622536171845" localize="false"><input>svc.Activate(): bool</input></paragraph>
<h3 id="hd _id26158393307687" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<paragraph role="paragraph" id="par_id921618228229529">The following example assumes you want to activate the form named <literal>FormA</literal> located in <literal>Sheet1</literal> of the currently open Calc file. It first gets access to the document using the <literal>Document</literal> service and <literal>ThisComponent</literal> and then activates the form.</paragraph>
<bascode>
@@ -569,10 +601,14 @@
<paragraph role="bascode" id="bas_id201618228487565">'Activates the form</paragraph>
<paragraph role="bascode" localize="false" id="bas_id361598179135096">myForm.Activate()</paragraph>
</bascode>
- <paragraph role="paragraph" id="par_id661618228523419">To use the method Activate with other %PRODUCTNAME documents, read <link href="text/sbasic/shared/03/sf_form.xhp#ServiceInvocation" name="FormServiceInvocation">Service invocation</link> above.</paragraph>
- <note id="par_id81618228720782"><literal>ThisComponent</literal> is valid for Calc and Writer documents. For Base documents use <literal>ThisDataBaseDocument</literal>.</note>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id211622537233877" localize="false">doc = CreateScriptService('Document', XSCRIPTCONTEXT.getDocument())</paragraph>
+ <paragraph role="pycode" id="pyc_id181622537234494" localize="false">form = doc.Forms('Sheet1', 'FormA')</paragraph>
+ <paragraph role="pycode" id="pyc_id981622537234703" localize="false">form.Activate()</paragraph>
+ </pycode>
+ <note id="par_id81618228720782"><literal>ThisComponent</literal> applies to Calc and Writer documents. For Base documents use <literal>ThisDataBaseDocument</literal>.</note>
</section>
-
<section id="CloseFormDocument">
<comment> CloseFormDocument -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id14161686043795">
@@ -581,16 +617,17 @@
<h2 id="hd _id18161686043718" localize="false">CloseFormDocument</h2>
<paragraph role="paragraph" id="par_id501616860541195" xml-lang="en-US">Closes the form document containing the actual <literal>Form</literal> instance. The <literal>Form</literal> instance is disposed.</paragraph>
<h3 id="hd _id99161686043761" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id8161686043710">myForm.CloseFormDocument() As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id811622538068303" localize="false"><input>svc.CloseFormDocument(): bool</input></paragraph>
<h3 id="hd _id901616860437964" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id511616860437148">myForm.CloseFormDocument()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id511616860437148">myForm.CloseFormDocument() ' Basic</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id331622538021746" localize="false">form.CloseFormDocument() # Python</paragraph>
+ </pycode>
<note id="par_id611618229004669">This method only closes form documents located in Base documents. If the form is stored in a Writer or Calc document, calling <literal>CloseFormDocument</literal> will have no effect.</note>
</section>
-
<section id="Controls">
<comment> Controls -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id41584541257826">
@@ -600,27 +637,30 @@
<paragraph role="paragraph" id="par_id161584541257982">The value returned by the <literal>Controls</literal> method depends on the arguments provided:</paragraph>
<list type="unordered">
<listitem>
- <paragraph id="par_id421598179770993" role="listitem" xml-lang="en-US">If the method is called <emph>without any arguments</emph>, then it returns the list of the controls contained in the form. Beware that the returned list does not contain any subform controls.</paragraph>
+ <paragraph id="par_id421598179770993" role="listitem" xml-lang="en-US">If the method is called <emph>without arguments</emph>, then it returns the list of the controls contained in the form. Beware that the returned list does not contain any subform controls.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id81598185229301" role="listitem" xml-lang="en-US">If the optional <literal>ControlName</literal> argument is provided, the method returns a <literal>FormControl</literal> class instance referring to the specified control.</paragraph>
</listitem>
</list>
<h3 id="hd _id601584541257443" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id201584541257726">myForm.Controls([ControlName As String]) As Variant</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id471622538274231" localize="false"><input>svc.Controls(opt controlname: str): any</input></paragraph>
<h3 id="hd _id291584541257237" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
- <paragraph role="paragraph" id="par_id1001584541257789"><emph>ControlName</emph> : A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array.</paragraph>
+ <paragraph role="paragraph" id="par_id1001584541257789"><emph>controlname</emph> : A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array.</paragraph>
<h3 id="hd _id32158454125769" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id151598185478904">Dim myForm As Object, myList As Variant, myControl As Object</paragraph>
<paragraph role="bascode" localize="false" id="bas_id21598185484092">Set myForm = myDoc.Forms("myForm")</paragraph>
<paragraph role="bascode" localize="false" id="bas_id641598185489492">myList = myform.Controls()</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id921598185495193">Set myControl = myform.Controls("myTextBox")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id921598185495193">Set myControl = myform.Controls("myTextBox") ' SFDocuments.FormControl</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id711622538462214" localize="false">form = doc.Forms('myForm')</paragraph>
+ <paragraph role="pycode" id="pyc_id631622538462782" localize="false">form_names = form.Controls()</paragraph>
+ <paragraph role="pycode" id="pyc_id961622538463294" localize="false">form_control = form.Controls('myTextBox') # SFDocuments.FormControl</paragraph>
+ </pycode>
</section>
-
<section id="GetDatabase">
<comment> GetDatabase -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id941616861134691">
@@ -628,20 +668,21 @@
</bookmark>
<h2 id="hd _id141616861134554" localize="false">GetDatabase</h2>
<paragraph role="paragraph" id="par_id291616861407907" xml-lang="en-US">Return a <link href="text/sbasic/shared/03/sf_database.xhp" name="DBService"><literal>SFDatabases</literal>.<literal>Database</literal></link> instance giving access to the execution of SQL commands on the database the current form is connected to and/or that is stored in the current Base document.</paragraph>
- <paragraph role="paragraph" id="par_id991616861417207" xml-lang="en-US">Each form in a <literal>FormDocument</literal> has its own database connection, except in Base documents where they all share the same connection.</paragraph>
+ <paragraph role="paragraph" id="par_id991616861417207" xml-lang="en-US">Each form has its own database connection, except in Base documents where they all share the same connection.</paragraph>
<h3 id="hd _id431616861134316" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id251616861134409">myForm.GetDatabase([User As String], [Password As String]) As Object</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id221622547947693" localize="false"><input>svc.GetDatabase(opt user: str, opt password: str): svc</input></paragraph>
<h3 id="hd _id871616861134673" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
- <paragraph role="paragraph" id="par_id701616861134906"><emph>User, Password</emph> : The login parameters (Default = "").</paragraph>
+ <paragraph role="paragraph" id="par_id701616861134906"><emph>user, password</emph>: The login optional parameters (Default = "").</paragraph>
<h3 id="hd _id911616861134351" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id231616861134373">Dim myDb As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id231616861134373">Dim myDb As Object ' SFDatabases.Database</paragraph>
<paragraph role="bascode" localize="false" id="bas_id2316168611347">Set myDb = oForm.GetDatabase()</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id871622547824003" localize="false">db = form.GetDatabase() # SFDatabases.Database</paragraph>
+ </pycode>
</section>
-
<section id="MoveFirst">
<comment> MoveFirst -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id671616861787529">
@@ -650,15 +691,16 @@
<h2 id="hd _id591616861787279" localize="false">MoveFirst</h2>
<paragraph role="paragraph" id="par_id771616861842867" xml-lang="en-US">The form cursor is positioned on the first record. Returns <literal>True</literal> if successful.</paragraph>
<h3 id="hd _id601616861787526" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id971616861787676">myForm.MoveFirst() As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id101622549004980" localize="false"><input>svc.MoveFirst(): bool</input></paragraph>
<h3 id="hd _id51616861787314" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id191616861787635">myForm.MoveFirst()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id191616861787635">myForm.MoveFirst() ' Basic</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id421622549258920" localize="false">form.MoveFirst() # Python</paragraph>
+ </pycode>
</section>
-
<section id="MoveLast">
<comment> MoveLast -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id551616863143388">
@@ -667,15 +709,16 @@
<h2 id="hd _id831616863143434" localize="false">MoveLast</h2>
<paragraph role="paragraph" id="par_id331616863143187" xml-lang="en-US">The form cursor is positioned on the last record. Returns <literal>True</literal> if successful.</paragraph>
<h3 id="hd _id66161686314335" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id631616863143741">myForm.MoveLast() As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id931622549019307" localize="false"><input>svc.MoveLast(): bool</input></paragraph>
<h3 id="hd _id501616863143323" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id691616863143688">myForm.MoveLast()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id691616863143688">myForm.MoveLast() ' Basic</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id831622549604397" localize="false">form.MoveLast() # Python</paragraph>
+ </pycode>
</section>
-
<section id="MoveNew">
<comment> MoveNew -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id231616863143638">
@@ -684,15 +727,16 @@
<h2 id="hd _id41161686314366" localize="false">MoveNew</h2>
<paragraph role="paragraph" id="par_id361616863143954" xml-lang="en-US">The form cursor is positioned on the new record area. Returns <literal>True</literal> if successful.</paragraph>
<h3 id="hd _id461616863143572" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id8161686314375">myForm.MoveNew() As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id131622549039501" localize="false"><input>svc.MoveNew(): bool</input></paragraph>
<h3 id="hd _id311616863143737" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id401616863143757">myForm.MoveNew()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id401616863143757">myForm.MoveNew() ' Basic</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id381622549678558" localize="false">form.MoveNew() # Python</paragraph>
+ </pycode>
</section>
-
<section id="MoveNext">
<comment> MoveNext -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id171616863143921">
@@ -701,17 +745,18 @@
<h2 id="hd _id111616863143256" localize="false">MoveNext</h2>
<paragraph role="paragraph" id="par_id541616863143461" xml-lang="en-US">The form cursor is positioned on the next record. Returns <literal>True</literal> if successful.</paragraph>
<h3 id="hd _id331616863143670" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id211616863143355">myForm.MoveNext([Offset As Long]) As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id291622549045804" localize="false"><input>svc.MoveNext(opt offset: int): bool</input></paragraph>
<h3 id="hd _id261616863582793" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
- <paragraph role="paragraph" id="par_id271616863582607"><emph>Offset</emph> : The number of records to go forward (Default = 1).</paragraph>
+ <paragraph role="paragraph" id="par_id271616863582607"><emph>offset</emph>: The number of records to go forward (Default = 1).</paragraph>
<h3 id="hd _id71616863143475" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id591616863143862">myForm.MoveNext()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id591616863143862">myForm.MoveNext() ' Basic</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id361622549859524">form.MoveNext() # Python</paragraph>
+ </pycode>
</section>
-
<section id="MovePrevious">
<comment> MovePrevious -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id71161686379488">
@@ -720,17 +765,17 @@
<h2 id="hd _id371616863794447" localize="false">MovePrevious</h2>
<paragraph role="paragraph" id="par_id616168637945" xml-lang="en-US">The form cursor is positioned on the previous record. Returns <literal>True</literal> if successful.</paragraph>
<h3 id="hd _id67161686379485" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id161616863794685">myForm.MovePrevious([Offset As Long]) As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" id="par_id981622549054028" localize="false"><input>svc.MovePrevious(opt offset: int): bool</input></paragraph>
<h3 id="hd _id141616863794433" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
- <paragraph role="paragraph" id="par_id751616863794125"><emph>Offset</emph> : The number of records to go backwards (Default = 1).</paragraph>
+ <paragraph role="paragraph" id="par_id751616863794125"><emph>offset</emph>: The number of records to go backwards (Default = 1).</paragraph>
<h3 id="hd _id511616863794613" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id941616863794988">myForm.MovePrevious()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id941616863794988">myForm.MovePrevious() ' Basic</paragraph>
</bascode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id221622549920933">form.MovePrevious() # Python</paragraph>
+ </pycode>
</section>
-
<section id="Requery">
<comment> Requery -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id741616864216894">
@@ -739,15 +784,16 @@
<h2 id="hd _id551616864216705" localize="false">Requery</h2>
<paragraph role="paragraph" id="par_id811616864216529" xml-lang="en-US">Reloads the current data from the database and refreshes the form. The cursor is positioned on the first record. Returns <literal>True</literal> if successful.</paragraph>
<h3 id="hd _id51616864216609" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id561616864216636">myForm.Requery() As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" localize="false" id="par_id731622550132517">svc.Requery(): bool</paragraph>
<h3 id="hd _id411616864216103" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
- <paragraph role="bascode" localize="false" id="bas_id211616864216116">myForm.Requery()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id211616864216116">myForm.Requery() ' Basic</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id401622550186725">form.Requery() # Python</paragraph>
+ </pycode>
</section>
-
<section id="Subforms">
<comment> Subforms -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id441616864510542">
@@ -760,24 +806,28 @@
<paragraph id="par_id951616864510585" role="listitem" xml-lang="en-US">If the method is called <emph>without any arguments</emph>, then it returns the list of subforms contained in the current form or subform instance.</paragraph>
</listitem>
<listitem>
- <paragraph id="par_id591616864510445" role="listitem" xml-lang="en-US">If the optional <literal>Subform</literal> argument is provided, the method returns a new <literal>SFDocuments</literal>.<literal>Form</literal> instance based on the specified form/subform name or index.</paragraph>
+ <paragraph id="par_id591616864510445" role="listitem" xml-lang="en-US">If the optional <literal>subform</literal> argument is provided, the method returns a new <literal>SFDocuments</literal>.<literal>Form</literal> instance based on the specified form/subform name or index.</paragraph>
</listitem>
</list>
<h3 id="hd _id54161686451092" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functsyntax"/></h3>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id261616864510459">myForm.Subforms([Subform As Variant]) As Variant</paragraph>
- </bascode>
+ <paragraph role="paragraph" localize="false" id="par_id541622550497960"><input>svc.Subforms(): str[0..*]</input></paragraph>
+ <paragraph role="paragraph" localize="false" id="par_id161623413158150"><input>svc.Subforms(subform: str): svc</input></paragraph>
+ <paragraph role="paragraph" localize="false" id="par_id31623413181836"><input>svc.Subforms(subform: int): svc</input></paragraph>
<h3 id="hd _id7516168645106" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functparameters"/></h3>
- <paragraph role="paragraph" id="par_id341616864510747"><emph>Subform</emph> : A subform stored in the current <literal>Form</literal> class instance given by its name or index.</paragraph>
+ <paragraph role="paragraph" id="par_id341616864510747"><emph>subform</emph> : A subform stored in the current <literal>Form</literal> class instance given by its name or index.</paragraph>
<paragraph role="paragraph" id="par_id211618230389251">When this argument is absent, the method returns a list of available subforms as a zero-based array. If the form has a single subform, you can set <literal>Subform = 0</literal> to get access to it.</paragraph>
<h3 id="hd _id491616864510587" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#functexample"/></h3>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id821616864510402">Dim myForm As Object, myList As Variant, mySubform As Object</paragraph>
<paragraph role="bascode" localize="false" id="bas_id81616864510872">myList = myform.Subforms()</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id951616864510420">Set mySubform = myForm.Subforms("mySubform")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id951616864510420">Set mySubform = myForm.Subforms("mySubform") ' SFDocuments.Form</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id101622552303831">subform_names = form.Subforms()</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id781622552304561">subform = form.Subforms('mySubform') # SFDocuments.Form</paragraph>
+ </pycode>
</section>
-
<embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#SF_InternalUse"/>
<section id="relatedtopics">
<embed href="text/sbasic/shared/03/sf_database.xhp#DatabaseService"/>
@@ -785,4 +835,4 @@
<embed href="text/sbasic/shared/03/sf_ui.xhp#UIService"/>
</section>
</body>
-</helpdocument>
+</helpdocument> \ No newline at end of file
diff --git a/source/text/sbasic/shared/03/sf_formcontrol.xhp b/source/text/sbasic/shared/03/sf_formcontrol.xhp
index 533094e20..a082a3293 100644
--- a/source/text/sbasic/shared/03/sf_formcontrol.xhp
+++ b/source/text/sbasic/shared/03/sf_formcontrol.xhp
@@ -8,21 +8,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
-->
-
<meta>
<topic id="SF_FormControl" indexer="include" status="PUBLISH">
<title id="tit" xml-lang="en-US">SFDocuments.FormControl service</title>
<filename>/text/sbasic/shared/03/sf_formcontrol.xhp</filename>
</topic>
</meta>
-
<body>
<section id="ScriptForge-sf_formcontrol">
<bookmark localize="false" branch="index" id="bm_id41582391760252">
<bookmark_value>FormControl service</bookmark_value>
</bookmark>
</section>
-
<section id="abstract">
<h1 id="bm_id781582391760253" xml-lang="en-US"><variable id="FormControlService"><link href="text/sbasic/shared/03/sf_formcontrol.xhp" name="SFDocuments.FormControl service"><literal>SFDocuments</literal>.<literal>FormControl</literal> service</link></variable></h1>
<paragraph role="paragraph" id="par_id931583589764919" xml-lang="en-US">The <literal>FormControl</literal> service provides access to the controls that belong to a form, a subform or a table control of a <literal>FormDocument</literal>. Each instance of the <literal>FormControl</literal> service refers to a single control in the form. This service allows users to:</paragraph>
@@ -49,16 +46,25 @@
<bookmark_value>API;awt.XControl</bookmark_value>
<bookmark_value>API;awt.XControlModel</bookmark_value>
</bookmark>
-
<h2 id="hd_id581582885621841" xml-lang="en-US">Service invocation</h2>
<paragraph role="paragraph" id="par_id361598174756160" xml-lang="en-US">The <literal>FormControl</literal> service is invoked from an existing <literal>Form</literal> service instance through its <literal>Controls</literal> method.</paragraph>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id791598453192421">Dim oDoc as Object, myForm As Object, myControl As Object</paragraph>
<paragraph role="bascode" localize="false" id="bas_id351618773083772">Set oDoc = CreateScriptService("SFDocuments.Document", ThisDataBaseDocument)</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id251598453197473">Set myForm = oDoc.Forms("formDocumentName", "formName")</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id421598453203458">Set myControl = myForm.Controls("myTextBox")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id251598453197473">Set myForm = oDoc.Forms("formDocumentName", "formName") ' SFDocuments.Form</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id421598453203458">Set myControl = myForm.Controls("myTextBox") ' SFDocuments.FormControl</paragraph>
<paragraph role="bascode" localize="false" id="bas_id581598453210170">myControl.Value = "Current time = " &amp; Now()</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="paragraph" localize="false" id="par_id51622556288409">from scriptforge import CreateScriptService</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id301622557445074">from time import localtime, strftime</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id621623152215419">svc = CreateScriptService('ScriptForge.Basic')</paragraph>
+ <paragraph role="paragraph" localize="false" id="par_id851622556289184">doc = CreateScriptService('SFDocuments.Document', svc.ThisDatabaseDocument)</paragraph>
+ <paragraph role="paragraph" localize="false" id="par_id981622556289672">form = doc.Forms('formDocumentName', 'formName') # SFDocuments.Form</paragraph>
+ <paragraph role="paragraph" localize="false" id="par_id291622556290144">control = form.Controls('myTextBox') # SFDocuments.FormControl</paragraph>
+ <paragraph role="pycode" id="pyc_id721622556808773">control.Value = 'Current Time = ' + strftime("%a, %d %b %Y %H:%M:%S", localtime())</paragraph>
+ </pycode>
<tip id="par_id781618772761258">To learn more about how to open a <literal>FormDocument</literal> and get access to its forms, refer to the <link href="text/sbasic/shared/03/sf_form.xhp" name="Form service">SFDocuments.Form</link> service help page.</tip>
<paragraph role="paragraph" id="par_id951598174966322" xml-lang="en-US">Alternatively a <literal>FormControl</literal> instance can be retrieved via the <literal>SFDocuments.FormEvent</literal> service, which returns the <literal>SFDocuments.FormControl</literal> class instance that triggered the event.</paragraph>
<bascode>
@@ -69,6 +75,11 @@
<paragraph role="bascode" localize="false" id="bas_id711598175146308"> ' ...</paragraph>
<paragraph role="bascode" localize="false" id="bas_id421598175139021">End Sub</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id521622558177865">def onEvent(event: uno):</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id841622558178345"> control = CreateScriptService('SfDocuments.FormEvent', event)</paragraph>
+ </pycode>
<paragraph role="paragraph" id="par_id251598176312571" xml-lang="en-US">Note that in previous examples, the prefix <literal>"SFDocuments."</literal> may be omitted.</paragraph>
<bookmark xml-lang="en-US" branch="index" id="bm_id541618773673421" localize="false">
<bookmark_value>FormEvent service</bookmark_value>
@@ -146,7 +157,6 @@
<paragraph id="par_id661598456015339" localize="false" role="listitem">TimeField</paragraph>
</listitem>
</list>
-
<h2 id="hd_id651583668365757" xml-lang="en-US">Properties</h2>
<table id="tab_id381583668386455">
<tablerow>
@@ -594,7 +604,6 @@
</tablecell>
</tablerow>
</table>
-
<h2 id="hd_id81598540704978" xml-lang="en-US">The <variable id="ValueProperty"><literal>Value</literal> property</variable></h2>
<table id="tab_id48159854325479">
<tablerow>
@@ -785,7 +794,6 @@
</tablecell>
</tablerow>
</table>
-
<h2 id="hd_id421612628828054" xml-lang="en-US">Event properties</h2>
<paragraph role="paragraph" id="par_id41612629140856" xml-lang="en-US">The properties below return or set URI strings that define the script triggered by the event.</paragraph>
<table id="tab_id951612628879819">
@@ -1033,7 +1041,6 @@
</tablerow>
</table>
<tip id="par_id961618181634181">To learn more about URI strings, refer to the <link href="https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification" name="URI specification">Scripting Framework URI Specification</link>.</tip>
-
<table id="tab_id891606472825856">
<tablerow>
<tablecell colspan="2"><paragraph id="par_id891611613601554" role="tablehead" xml-lang="en-US">List of Methods in the FormControl Service</paragraph></tablecell>
@@ -1048,7 +1055,6 @@
</tablerow>
</table>
<embed href="text/sbasic/shared/03/avail_release.xhp#7.2.methods"/>
-
<section id="Controls">
<comment> Controls -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id41584541257826">
@@ -1059,22 +1065,26 @@
<paragraph role="paragraph" id="par_id701618777636827">If the optional argument <literal>ControlName</literal> is absent, then a zero-based Array containing the names of all controls is returned.</paragraph>
<paragraph role="paragraph" id="par_id851618777715892">On the other hand, if a <literal>ControlName</literal> is provided, the method returns a <literal>FormControl</literal> class instance corresponding to the specified control.</paragraph>
<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id201584541257726">oControl.Controls([ControlName As String]) As Variant</paragraph>
- </bascode>
+ <paragraph role="paragraph" localize="false" id="par_id181622558671497"><input>svc.Controls(): str[0..*]</input></paragraph>
+ <paragraph role="paragraph" localize="false" id="par_id531622558833434"><input>svc.Controls(controlname: str): svc</input></paragraph>
<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
- <paragraph role="paragraph" id="par_id1001584541257789"><emph>ControlName</emph> : A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array.</paragraph>
+ <paragraph role="paragraph" id="par_id1001584541257789"><emph>controlname</emph>: A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array.</paragraph>
<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id151598185478904">Dim myGrid As Object, myList As Variant, myControl As Object</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id21598185484092">Set myGrid = myForm.Controls("myTableControl")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id21598185484092">Set myGrid = myForm.Controls("myTableControl") ' SFDocuments.FormControl</paragraph>
<paragraph role="bascode" id="bas_id471618778075117">' Returns an Array with the names of all controls in "myTableControl"</paragraph>
<paragraph role="bascode" localize="false" id="bas_id641598185489492">myList = myGrid.Controls()</paragraph>
<paragraph role="paragraph" id="par_id931618778110273">' Returns a FormControl class instance corresponding to "myCheckBox"</paragraph>
<paragraph role="bascode" localize="false" id="bas_id921598185495193">Set myControl = myGrid.Controls("myCheckBox")</paragraph>
</bascode>
+ <paragraph role="paragraph" id="par_id391622559441530">Using Python:</paragraph>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id81622558961009">grid = form.Controls('myTableControl') # SFDocuments.FormControl</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id391622558961234">control_names = form.Controls()</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id571622558961435">control = grid.Controls('myCheckBox') # SFDocuments.FormControl</paragraph>
+ </pycode>
</section>
-
<section id="SetFocus">
<comment> SetFocus -------------------------------------------------------------------------------------------------------------------------- </comment>
<bookmark localize="false" branch="index" id="bm_id721583933076548">
@@ -1084,19 +1094,24 @@
<paragraph role="paragraph" id="par_id871583933076448">Sets the focus on the control. Returns <literal>True</literal> if focusing was successful.</paragraph>
<paragraph role="paragraph" id="par_id151598178880227" xml-lang="en-US">This method is often called from a form or control event.</paragraph>
<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
- <bascode>
- <paragraph role="bascode" localize="false" id="bas_id731583933076815">oControl.SetFocus() As Boolean</paragraph>
- </bascode>
+ <paragraph role="paragraph" localize="false" id="par_id991622559468457"><input>svc.SetFocus(): bool</input></paragraph>
<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id221598179105596">Dim oDoc As Object, oForm As Object, oControl As Object</paragraph>
<paragraph role="bascode" localize="false" id="bas_id171598179111121">Set oDoc = CreateScriptService("SFDocuments.Document", ThisComponent)</paragraph>
<paragraph role="bascode" localize="false" id="bas_id681598179123436">Set oForm = oDoc.Forms(0)</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id741616950370203">Set oControl = oForm.Controls("thisControl")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id741616950370203">Set oControl = oForm.Controls("thisControl") ' SFDocuments.FormControl</paragraph>
<paragraph role="bascode" localize="false" id="bas_id361598179135096">oControl.SetFocus()</paragraph>
- </bascode>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id51623154762285">ui = CreateScriptService('ScriptForge.Basic')</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id571622559687626">doc = CreateScriptService('SFDocuments.Document', ui.ThisComponent)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id231622559687813">form = doc.Forms(0)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id891622559687994">control = form.Controls('thisControl') # SFDocuments.FormControl</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id801622560297771">control.SetFocus()</paragraph>
+ </pycode>
</section>
-
<comment> Additional examples -------------------------------------------------------------------------------------------------------------------------- </comment>
<h2 id="hd_id141618777179310">Additional examples</h2>
<paragraph role="paragraph" id="par_id331618777195723">Below are two examples that illustrate the use of the <literal>FormControl</literal> service.</paragraph>
@@ -1109,6 +1124,15 @@
<paragraph role="bascode" localize="false" id="bas_id291618776467995">Dim cbCity : cbCity = myForm.Controls("comboboxCity")</paragraph>
<paragraph role="bascode" localize="false" id="bas_id611618776468297">lbCity.Caption = "Selected City: " &amp; cbCity.Value</paragraph>
</bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id991622562833004">ui = CreateScriptService('ScriptForge.Basic') # Basic-like methods</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id321622561047923">doc = CreateScriptService('SFDocuments.Document', ui.ThisDatabaseDocument)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id321622561048131">form = doc.Forms('formDocumentName', 'formName')</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id1001622561048346">lbl_city = form.Controls('labelCity')</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id151622561048563">combo_city = form.Controls('comboboxCity')</paragraph>
+ <paragraph role="pycode" id="pyc_id781622561048794">lbl_city.Caption = "Selected city: " + combo_city.Value</paragraph>
+ </pycode>
<paragraph role="paragraph" id="par_id251618776614814">The following code snippet can be used to process RadioButton controls that share the same group name. In this example, suppose there are three radio buttons with names <literal>optA</literal>, <literal>optB</literal> and <literal>optC</literal> and we wish to display the caption of the selected control.</paragraph>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id461618776931086">Dim oDoc as Object, myForm as Object</paragraph>
@@ -1119,18 +1143,28 @@
<paragraph role="bascode" localize="false" id="bas_id281618776932488">For Each opt In optNames</paragraph>
<paragraph role="bascode" localize="false" id="bas_id211618776932791"> optControl = myForm.Controls(opt)</paragraph>
<paragraph role="bascode" localize="false" id="bas_id311618776933039"> If optControl.Value = True Then</paragraph>
- <paragraph role="bascode" localize="false" id="bas_id251618776933304"> MsgBox "Selected Option: " &amp; optControl.Caption</paragraph>
+ <paragraph role="bascode" id="bas_id251618776933304"> MsgBox "Selected option: " &amp; optControl.Caption</paragraph>
<paragraph role="bascode" localize="false" id="bas_id581618776933600"> Exit For</paragraph>
<paragraph role="bascode" localize="false" id="bas_id511618776933863"> End If</paragraph>
<paragraph role="bascode" localize="false" id="bas_id31618776934159">Next opt</paragraph>
</bascode>
-
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" id="pyc_id991622562822004">ui = CreateScriptService('ScriptForge.Basic') # Basic-like methods</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id681622562079356">doc = CreateScriptService('SFDocuments.Document', ui.ThisDatabaseDocument)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id941622562079539">form = doc.Forms('formDocumentName', 'formName')</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id741622562079722">radio_buttons = ['optA', 'optB', 'optC']</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id901622562079883">for name in radio_buttons:</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id51622562080068"> control = form.controls(name)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id361622562080243"> if control.Value == True:</paragraph>
+ <paragraph role="pycode" id="pyc_id441622562080419"> ui.MsgBox('Selected option: ' + control.Caption)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id61622563076603"> break</paragraph>
+ </pycode>
<embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#SF_InternalUse"/>
-
<section id="relatedtopics">
+ <embed href="text/sbasic/shared/03/sf_basic.xhp#BasicService"/>
<embed href="text/sbasic/shared/03/sf_form.xhp#FormService"/>
<embed href="text/sbasic/shared/03/sf_document.xhp#DocumentService"/>
</section>
-
</body>
-</helpdocument>
+</helpdocument> \ No newline at end of file