I tried to use com.sun.star.gallery.GalleryThemeProvider > oTheme.insertDrawingByIndex to add drawings, selected on a drawpage, to the gallery. It doesn't work. See details and discussion here: https://ask.libreoffice.org/t/this-code-to-insertdrawingbyindex-in-gallery-theme-doesnt-work/109647 API ref: https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1gallery_1_1XGalleryTheme.html#a8d3d81e2d23ab00b6a762b38ee0c8e5c Me thinks the implementation is either unfinished or for some other reason not usable. (version ... metusalem upto Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 8843081f91e206b4749b83b186caaceaf1f8c4e3 CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3 Locale: en-US (en_US.UTF-8); UI: en-US Calc: threaded
1. In the Sidebar, create a new gallery theme called _TestTheme 2. Create a line and a circle and group them (select both, right-click, group) 3. Create a new BASIC macro and run it: 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 I reproduce that nothing happens. Arch Linux 64-bit Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 3b267b65d24616fe49ca1410b123d186a59541d0 CPU threads: 8; OS: Linux 6.11; UI render: default; VCL: kf6 (cairo+wayland) Locale: fi-FI (fi_FI.UTF-8); UI: en-US Calc: CL threaded Built on 14 November 2024