OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Accessing the View of Control Element Forms<br />
Working With Forms<br />
To access the view of a control element form, you need the associated model. The view of the control element<br />
can then be determined with the assistance of the model and using the document controller.<br />
Dim Doc As Object<br />
Dim DocCrl As Object<br />
Dim Forms As Object<br />
Dim Form As Object<br />
Dim Ctl As Object<br />
Dim CtlView As Object<br />
Dim I as Integer<br />
Doc = ThisComponent<br />
DocCrl = Doc.getCurrentController()<br />
Forms = Doc.Drawpage.Forms<br />
For I = 0 To Forms.Count - 1<br />
Form = Forms.GetbyIndex(I)<br />
If Form.HasByName("MyListBox") Then<br />
Ctl = Form.GetbyName("MyListBox")<br />
CtlView = DocCrl.GetControl(Ctl)<br />
Exit Function<br />
End If<br />
Next I<br />
The code listed in the example is very similar to the code listed in the previous example for determining a control<br />
element model. It uses not only the Doc document object but also the DocCrl document controller object which<br />
makes reference to the current document window. With the help of this controller object and the model of the<br />
control element, it then uses the GetControl method to determine the view (CtlView variable) of the control<br />
element form.<br />
Accessing the Shape Object of Control Element Forms<br />
The method for accessing the shape objects of a control element also uses the corresponding drawing level of the<br />
document. To determine a special control element, all drawing elements of the drawing level must be searched<br />
through.<br />
Dim Doc As Object<br />
Dim Shape as Object<br />
Dim I as integer<br />
Doc = ThisComponent<br />
For i = 0 to Doc.DrawPage.Count - 1<br />
Shape = Doc.DrawPage(i)<br />
If HasUnoInterfaces(Shape, "com.sun.star.drawing.XControlShape") Then<br />
If Shape.Control.Name = "MyListBox" Then<br />
Exit Function<br />
End If<br />
End If<br />
Next<br />
The example checks all drawing elements to determine whether they support the<br />
com.sun.star.drawing.XControlShape interface needed for control element forms. If this is the case, the<br />
Control.Name property then checks whether the name of the control element is MyListBox. If this is true, the<br />
function ends the search.<br />
Determining the Size and Position of Control Elements<br />
As already mentioned, the size and position of control elements can be determined using the associated shape<br />
object. The control element shape, like all other shape objects, provides the Size and Position properties for<br />
this purpose:<br />
Size (struct)<br />
size of control element (com.sun.star.awt.Size data structure)<br />
Chapter 12 · Forms 169