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

Creating a macro - Writing a Script - Using the API

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

Postby JeJe » Mon Jan 29, 2018 8:17 pm

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

https://forum.openoffice.org/en/forum/viewtopic.php?f=44&t=6591

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

https://www.openoffice.org/api/docs/common/ref/com/sun/star/graphic/MediaProperties.html


Code: Select all   Expand viewCollapse view


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]
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 552
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby hubert lambert » Mon Jan 29, 2018 10:57 pm

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   Expand viewCollapse view
   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
hubert lambert
 
Posts: 129
Joined: Mon Jun 13, 2016 10:50 am

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

Postby JeJe » Mon Jan 29, 2018 11:22 pm

Brilliant thanks - that's exactly what I wanted.

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

http://people.canonical.com/~doko/ooicons/index_all.html
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 552
Joined: Wed Mar 09, 2016 2:40 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests