<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fworking_with_forms</id>
	<title>EN/documentation/basic guide/working with forms - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fworking_with_forms"/>
	<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/working_with_forms&amp;action=history"/>
	<updated>2026-11-11T13:56:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/working_with_forms&amp;diff=16886&amp;oldid=prev</id>
		<title>Sancho: Основной текст</title>
		<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/working_with_forms&amp;diff=16886&amp;oldid=prev"/>
		<updated>2011-09-06T17:01:34Z</updated>

		<summary type="html">&lt;p&gt;Основной текст&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;Working with Forms&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}&lt;br /&gt;
&lt;br /&gt;
{{Documentation/BASICGuideTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=EN/documentation/basic_guide/forms&lt;br /&gt;
|NextPage=EN/documentation/basic_guide/control_element_forms&lt;br /&gt;
|form=block&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
{{OOo}} forms may contain text fields, list boxes, radio buttons, and a range of other control elements, which are inserted directly in a text or spreadsheet. The Form Functions Toolbar is used for editing forms.&lt;br /&gt;
&lt;br /&gt;
A {{OOo}} form may adopt one of two modes: the draft mode and the display mode. In draft mode, the position of control elements can be changed and their properties can be edited using a properties window.&lt;br /&gt;
&lt;br /&gt;
The Form Functions Toolbar is also used to switch between modes.&lt;br /&gt;
&lt;br /&gt;
== Determining Object Forms ==&lt;br /&gt;
&lt;br /&gt;
{{OOo}} positions the control elements of a form at drawing object level. The actual object form can be accessed through the Forms list at the drawing level. The objects are accessed as follows in text documents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim DrawPage As Object&lt;br /&gt;
Dim Form As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
DrawPage = Doc.DrawPage&lt;br /&gt;
Form = DrawPage.Forms.GetByIndex(0)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;GetByIndex&amp;lt;/tt&amp;gt; method returns the form with the index number 0.&lt;br /&gt;
&lt;br /&gt;
When working with spreadsheets, an intermediate stage is needed for the Sheets list because the drawing levels are not located directly in the document but in the individual sheets:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim DrawPage As Object&lt;br /&gt;
Dim Form As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets.GetByIndex(0)&lt;br /&gt;
DrawPage = Sheet.DrawPage&lt;br /&gt;
Form = DrawPage.Forms.GetByIndex(0)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As is already suggested by the &amp;lt;tt&amp;gt;GetByIndex&amp;lt;/tt&amp;gt; method name, a document may contain several forms. This is useful, for example, if the contents of different databases are displayed within one document, or if a 1:n database relationship is displayed within a form. The option of creating sub-forms is also provided for this purpose.&lt;br /&gt;
&lt;br /&gt;
== The Three Aspects of a Control Element Form ==&lt;br /&gt;
&lt;br /&gt;
A control element of a form has three aspects:&lt;br /&gt;
&lt;br /&gt;
* The '''Model''' of the control element is the key object for the {{OOo}} Basic-programmer when working with control element forms.&lt;br /&gt;
* The counterpart to this is the '''View''' of the control element, which administers the display information.&lt;br /&gt;
* Since control element forms within the documents are administered like a special drawing element, there is also a '''Shape object''' which reflects the drawing element-specific properties of the control element (in particular its position and size).&lt;br /&gt;
&lt;br /&gt;
== Accessing the Model of Control Element Forms ==&lt;br /&gt;
&lt;br /&gt;
The models of the control elements of a form are available through the &amp;lt;tt&amp;gt;GetByName&amp;lt;/tt&amp;gt; method of the Object form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Form As Object&lt;br /&gt;
Dim Ctl As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Form = Doc.DrawPage.Forms.GetByIndex(0)&lt;br /&gt;
Ctl = Form.getByName(&amp;quot;MyListBox&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example determines the model of the &amp;lt;tt&amp;gt;MyListBox&amp;lt;/tt&amp;gt; control element, which is located in the first form of the text document currently open.&lt;br /&gt;
&lt;br /&gt;
If you are not sure of the form of a control element, you can use the option for searching through all forms for the control element required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Forms As Object&lt;br /&gt;
Dim Form As Object&lt;br /&gt;
Dim Ctl As Object&lt;br /&gt;
Dim I as Integer&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Forms = Doc.Drawpage.Forms&lt;br /&gt;
&lt;br /&gt;
For I = 0 To Forms.Count - 1&lt;br /&gt;
  Form = Forms.GetbyIndex(I)&lt;br /&gt;
  If Form.HasByName(&amp;quot;MyListBox&amp;quot;) Then&lt;br /&gt;
    Ctl = Form.GetbyName(&amp;quot;MyListBox&amp;quot;)&lt;br /&gt;
    Exit Function&lt;br /&gt;
  End If&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example uses the &amp;lt;tt&amp;gt;HasByName&amp;lt;/tt&amp;gt; method to check all forms of a text document to determine whether they contain a control element model called &amp;lt;tt&amp;gt;MyListBox&amp;lt;/tt&amp;gt;. If a corresponding model is found, then a reference to this is saved in the &amp;lt;tt&amp;gt;Ctl&amp;lt;/tt&amp;gt; variable and the search is terminated. The example is shown as in-line code, for clarity; in practice, the search would be inside a function, called with the name as a string parameter, and include error processing.&lt;br /&gt;
&lt;br /&gt;
== Accessing the View of Control Element Forms ==&lt;br /&gt;
&lt;br /&gt;
To access the view of a control element form, you need the associated model. The view of the control element can then be determined with the assistance of the model and using the document controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim DocCrl As Object&lt;br /&gt;
Dim Forms As Object&lt;br /&gt;
Dim Form As Object&lt;br /&gt;
Dim Ctl As Object&lt;br /&gt;
Dim CtlView As Object&lt;br /&gt;
Dim I as Integer&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
DocCrl = Doc.getCurrentController()&lt;br /&gt;
Forms = Doc.Drawpage.Forms&lt;br /&gt;
&lt;br /&gt;
For I = 0 To Forms.Count - 1&lt;br /&gt;
  Form = Forms.GetbyIndex(I)&lt;br /&gt;
  If Form.HasByName(&amp;quot;MyListBox&amp;quot;) Then&lt;br /&gt;
    Ctl = Form.GetbyName(&amp;quot;MyListBox&amp;quot;)&lt;br /&gt;
    CtlView = DocCrl.GetControl(Ctl)&lt;br /&gt;
    Exit Function&lt;br /&gt;
  End If&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code listed in the example is very similar to the code listed in the previous example for determining a control element model. It uses not only the &amp;lt;tt&amp;gt;Doc&amp;lt;/tt&amp;gt; document object but also the &amp;lt;tt&amp;gt;DocCrl&amp;lt;/tt&amp;gt; document controller object which makes reference to the current document window. With the help of this controller object and the model of the control element, it then uses the &amp;lt;tt&amp;gt;GetControl&amp;lt;/tt&amp;gt; method to determine the view (&amp;lt;tt&amp;gt;CtlView&amp;lt;/tt&amp;gt; variable) of the control element form.&lt;br /&gt;
&lt;br /&gt;
== Accessing the Shape Object of Control Element Forms ==&lt;br /&gt;
&lt;br /&gt;
The method for accessing the shape objects of a control element also uses the corresponding drawing level of the document. To determine a special control element, all drawing elements of the drawing level must be searched through.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Shape as Object&lt;br /&gt;
Dim I as integer&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
&lt;br /&gt;
For i = 0 to Doc.DrawPage.Count - 1&lt;br /&gt;
  Shape = Doc.DrawPage(i)&lt;br /&gt;
  If HasUnoInterfaces(Shape, &amp;quot;com.sun.star.drawing.XControlShape&amp;quot;) Then&lt;br /&gt;
    If Shape.Control.Name = &amp;quot;MyListBox&amp;quot; Then&lt;br /&gt;
      Exit Function&lt;br /&gt;
    End If&lt;br /&gt;
  End If&lt;br /&gt;
Next&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example checks all drawing elements to determine whether they support the &amp;lt;idl&amp;gt;com.sun.star.drawing.XControlShape&amp;lt;/idl&amp;gt; interface needed for control element forms. If this is the case, the &amp;lt;tt&amp;gt;Control.Name&amp;lt;/tt&amp;gt; property then checks whether the name of the control element is &amp;lt;tt&amp;gt;MyListBox&amp;lt;/tt&amp;gt;. If this is true, the function ends the search.&lt;br /&gt;
&lt;br /&gt;
=== Determining the Size and Position of Control Elements ===&lt;br /&gt;
&lt;br /&gt;
As already mentioned, the size and position of control elements can be determined using the associated &amp;lt;tt&amp;gt;shape&amp;lt;/tt&amp;gt; object. The control element shape, like all other &amp;lt;tt&amp;gt;shape&amp;lt;/tt&amp;gt; objects, provides the &amp;lt;tt&amp;gt;Size&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Position&amp;lt;/tt&amp;gt; properties for this purpose:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;Size (struct)&amp;lt;/tt&amp;gt;:size of control element (&amp;lt;idl&amp;gt;com.sun.star.awt.Size&amp;lt;/idl&amp;gt; data structure)&lt;br /&gt;
;&amp;lt;tt&amp;gt;Position (struct)&amp;lt;/tt&amp;gt;:position of control element (&amp;lt;idl&amp;gt;com.sun.star.awt.Point&amp;lt;/idl&amp;gt; data structure)&lt;br /&gt;
&lt;br /&gt;
The following example shows how the position and size of a control element can be set using the associated shape object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Shape As Object&lt;br /&gt;
Dim Point As New com.sun.star.awt.Point&lt;br /&gt;
Dim Size As New com.sun.star.awt.Size&lt;br /&gt;
&lt;br /&gt;
' ... Initialize Shape object, as previously shown ...&lt;br /&gt;
&lt;br /&gt;
Point.x = 1000&lt;br /&gt;
Point.y = 1000&lt;br /&gt;
Size.Width = 10000&lt;br /&gt;
Size.Height = 10000&lt;br /&gt;
&lt;br /&gt;
Shape.Size = Size&lt;br /&gt;
Shape.Position = Point&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;shape&amp;lt;/tt&amp;gt; object of the control element must already be known if the code is to function. If this is not the case, it must be determined using the preceding code.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Sancho</name></author>
		
	</entry>
</feed>