List Box Add Item method not found

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Kegelschnitte
Posts: 1
Joined: Tue Jul 31, 2018 1:19 pm

List Box Add Item method not found

Post by Kegelschnitte »

Hi guys

I'm new to Basic and Open Office, so the following question may be dumb but I tried searching the web and this forum, but I didn't find an answer, so I'm asking here. I want to write some macros in OO Calc and I have the following problem:

First of all the code:

Code: Select all

Sub AnschreiberListe

  dim i as integer
  
  doc = thiscomponent
  aktSheet = Doc.Sheets (0)
  DrawPage = aktSheet.DrawPage
  Form = DrawPage.Forms.GetByName("Anschreiben")
  
  dim Anschreiber(doc.Sheets.count - 2) as string
  for i = 1 to doc.Sheets.count-1
    Anschreiber(i-1) = doc.sheets(i).getName()
	Form.L_Anschreiber.addItem (Anschreiber(i-1),i-1)  
  next i
  'Form.L_Anschreiber.stringitemlist()=(Anschreiber)
  
End Sub
As you may see I just want to fill a listbox with names of all spreadsheets starting with the second. But when I run the code it says that the method "addItem" was not found and I really don't know why, because in this link I find the method.

The line I commented works, but I rather use addItem.
Open Office 4.1.2 on Windows 10
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: List Box Add Item method not found

Post by hubert lambert »

Hello,

A form control is a view object build upon a model object. The interface com.sun.star.awt.XListBox serves for the view, while the model uses the interface com.sun.star.awt.XItemList with additional properties (see corresponding services UnoControlListBox and UnoControlListBoxModel).

The object returned by

Code: Select all

Form.L_Anschreiber
is the control model.

If you want to access the view, you may get it this way:

Code: Select all

doc.CurrentController.getControl(Form.L_Anschreiber)
Regards.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
Post Reply