[Solved] Can I use OO inbuilt icons as a picture in a popup?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

[Solved] Can I use OO inbuilt icons as a picture in a popup?

Post by JeJe »

I've found/worked out the code for showing an icon from a file in a popup menu item as below. What I'd like to do is use OO's own icons,
such as the icons for cut, copy, paste etc. Can this be done - if so how do I find the URLs for the icons I want?

This old thread seemed to asked something similar and I've tried ".uno:Cut" and "ImageIdentifier" as the property name but don't get an icon

viewtopic.php?f=44&t=6591

I've also found this which might be part of the solution?

https://www.openoffice.org/api/docs/com ... rties.html

Code: Select all



sub showpopup()
	dim arect,oPopup,i
	dim dlg
	
	oLib = DialogLibraries.GetByName("Standard")
	dlg =  CreateUnoDialog(oLib.GetByName("Dialog1"))
	
	aRect = CreateUnoStruct("com.sun.star.awt.Rectangle")
	oPopup = CreateUnoService("stardiv.vcl.PopupMenu")
	oPopup.insertItem(1, "Cut",0, 1)

	Dim oGraphicProvider
	Dim aProp(1) as new com.sun.star.beans.PropertyValue
	oGraphicProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
	aProp(0).Name  = "URL"
	aProp(0).Value = convertToUrl("c:\a\untitled.bmp")

	oPopup.setItemImage 1,oGraphicProvider.queryGraphic(aProp()),true
	oPopup.setCommand(1, "Cut")
	n = oPopup.execute(dlg.getpeer, aRect, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT)

end sub

Last edited by robleyd on Tue Jan 30, 2018 12:29 am, edited 3 times in total.
Reason: Tagged [Solved] [robleyd, Moderator]
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: Can I use OO's inbuilt icons as a picture in a popup men

Post by hubert lambert »

Hello,

You can point to any AOO's image using the uri protocol "private:graphicrepository", which refers to <install folder>/openoffice4/share/config/images.zip.
Try it by changing your code this way :

Code: Select all

   aProp(0).Name  = "URL"
   aProp(0).Value = "private:graphicrepository/res/commandimagelist/sc_cut.png"
Regards
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: Can I use OO inbuilt icons as a picture in a popup?(solv

Post by JeJe »

Brilliant thanks - that's exactly what I wanted.

A list of them all is here (warning: huge webpage)

http://people.canonical.com/~doko/ooico ... x_all.html
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply