Set the text of a control via macro in Libre Office Draw

259 Views Asked by At

I have designed a document in Libre Office Draw, and now need to personalize it by filling certain controls (mainly labels) with names read from a text file.

Reading from a text file was trivial, but am facing difficulties in obtaining a reference to a control placed in a Libre Office Draw document; all the functions mentioned were related to controls placed on a dialog, and did not seem applicable in this case.

This might be the first lead into reaching my goal:

document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

But then, how to find a control placed on 'document' named, say, "MyLabel1"? Once the label is filled, the document would need to be exported to PDF.

Thanks a lot!

1

There are 1 best solutions below

0
On

To export a LO Draw document to PDF from Basic you can use the following code.

Sub ExportToPDF
  sURL = convertToURL("d:\temp\lo_draw.pdf")
  dim mFileType(0)
  mFileType(0) = createUnoStruct("com.sun.star.beans.PropertyValue")
  mFileType(0).Name = "FilterName"
  mFileType(0).Value = "draw_pdf_Export"
  thisComponent.storeToURL(sURL, mFileType())
End Sub

To figure out how to get access to the "labels" please provide a sample LO Draw document.