Found some info around Gallery themes here (& elsewhere):
The following doesn’t add an entry to the gallery theme.
Any idea what I miss?
(There might be an alternative, exporting all shapes by code and use insertURLByIndex - didn’t test that)
Sub Tst_InsertGrapicObject
Dim oGalleryProvider, oTheme, oShape, oGraph
Dim oSelection
Dim nRslt&
oGalleryProvider = createUnoService("com.sun.star.gallery.GalleryThemeProvider")
oTheme = oGalleryProvider.getByName("_TestTheme")
' "_TestTheme" does exist and has some elements added via the UI
oGraph = ThisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")
oSelection = ThisComponent.currentController.Selection
' selected is a simple group shape, line + circle
If IsEmpty(oSelection) then
msgBox "No selection"
Else
oGraph = ThisComponent.currentController.Selection.getByIndex(0)
nRslt = oTheme.insertDrawingByIndex (oGraph, 2)
oTheme.update() ' makes no difference
msgbox nRslt ' returns -1
' NB
' oTheme.removeByIndex(1)
' does do the expected..
End If
End Sub
Looking at the C++ didn’t make me wiser.
https://opengrok.libreoffice.org/xref/core/svx/source/unogallery/unogaltheme.cxx?r=bc91cc47#198