[Solved]How are objects on a dialog accessed as a collection

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

[Solved]How are objects on a dialog accessed as a collection

Post by grnhorn »

Welcome beginner. Please answer all of the questions below which may provide information necessary to answer your question.
-----------------------------------------------------------------------------------------------------------
Which version of OpenOffice.org are you using? 2.4.1
What Operating System (version) are you using? XP
What is your question or comment?

I am creating a dialog with several TextField boxes and I want to be able to scan through them and get the data from each one in turn. In VBA this would be a 'collection of objects' that would be accessed as:

For each t in TextBox REM enumerate textboxes
a(n) = t.Text REM Put data int an array
n+=1 REM increment array element
next t REM next textbox

How can this be translated into OO BASIC?

Thanks...
Last edited by grnhorn on Sun Jul 13, 2008 9:00 pm, edited 1 time in total.
OOo 2.4.X on Ms Windows XP
User avatar
squenson
Volunteer
Posts: 1885
Joined: Wed Jan 30, 2008 9:21 pm
Location: Lausanne, Switzerland

Re: How are objects on a dialog accessed as a collection?

Post by squenson »

From the excellent document written by Andrew Pitonyak (http://www.pitonyak.org/AndrewMacro.odt):

Code: Select all

  x = oDlg.getControls()
  For ii=LBound(x) To UBound(x)
    Print x(ii).getImplementationName()
  Next
LibreOffice 4.2.3.3. on Ubuntu 14.04
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: How are objects on a dialog accessed as a collection?

Post by grnhorn »

Thanks squenson for the reply and the code worked and returned all of the control names. What I am trying to do is return the Text from the TextFields only. VBA gives the ability to enumerate through a control collection by position and return the property that is needed. In other words, VBA places the control into an array based upon when it is placed on the dialog. If all the TextBoxes are place on the dialog at one time, then they are consecutive in the array. This ID is part of VBA'a properties. This is where I am lost in OO. I have looked through Andrew's macros, along with hours on the internet, and the answer did not jump out at me.

Thanks...
OOo 2.4.X on Ms Windows XP
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

[Solved] How are objects on a dialog accessed as a collectio

Post by grnhorn »

Solution:

x = oDlg.getControls()
For ii=LBound(x) To UBound(x)
If x(ii).getImplementationName() = "stardiv.Toolkit.UnoButtonControl" Then Print x(ii).AccessibleContext.AccessibleName
Next

This will return the control name based upon an index number (ii) and type of control ("stardiv.Toolkit.UnoButtonControl"). Link to get the "Uno____Control" http://docs.sun.com/app/docs/doc/819-0439/faaji?a=view.
OOo 2.4.X on Ms Windows XP
Post Reply