Ask Your Question
0

BASIC example - get information about a selected shape on LibreOffice Draw

asked 2020-06-26 07:28:54 +0200

Bear31 gravatar image

I'm trying to use LibreOffice BASIC to link data from a LibreOffice Base database, with shapes on a LibreOffice Draw document. I've made some progress accessing the data, but need to understand how I can determine which shape has been selected in the Draw document, then read some properties of that shape. I will then use the shape property to build a SQL statement to get the right data from the Base file. I'm finding this a very steep learning curve and though there is some useful information around, there is nothing I have found (yet) that shows me how to get the selected shape and read properties of it.

Any assistance (preferably and example Sub) would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-06-26 18:36:28 +0200

Ratslinger gravatar image

updated 2020-06-26 19:00:28 +0200

Hello,

Shapes are kept on the DrawPage. You can access the selected item(s) by index and obtain the name and other information you are looking for. There can be multiple indexed items if more than one was selected. Example:

Sub Snippet2
  Dim oCurrentSelection As Variant
  Dim oObj1 As Variant
  oCurrentSelection = ThisComponent.getCurrentSelection()
  oObj1 = oCurrentSelection.getByIndex(0)
  MsgBox oObj1.Name
End Sub

You can find out how many items were selected by checking the count:

  nCount = oCurrentSelection.getCount()

Edit:

You can further examine the object using a tool such as Mri. Links for this can be found in my answer on this post -> How to Get and Put data from/to form fields with a macro

edit flag offensive delete link more

Comments

You may want to look at Open Office Macros Explained by Andrew Pitonyak. PDF here -> OOME

Ratslinger gravatar imageRatslinger ( 2020-06-26 19:31:08 +0200 )edit

Thanks @Ratslinger - that's the information I need. I have downloaded Andrew Pitonyak's resource along with a couple of others. They all have good information, but finding what I'm looking for is proving to be my biggest challenge. Easy enough to do a search - once you know the correct word to search for.

Bear31 gravatar imageBear31 ( 2020-06-27 02:12:25 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-06-26 07:28:54 +0200

Seen: 32 times

Last updated: Jun 26