Am 19.10.2010 14:10, schrieb Cor Nouws:
Hi *,

A question related to an old thread.
I first quote the useful piece of code form Carsten, so that is clear
where I talk about.

Carsten Driesner wrote (29-10-09 10:50)

REM ***** BASIC *****

REM *** This example creates a new basic macro toolbar button on
REM *** the Writer standard bar. It doesn't add the button twice.
REM *** It uses the Writer image manager to set an external image
REM *** for the macro toolbar button.

Sub Main
REM *** String to reference toolbar
sToolbar = "private:resource/toolbar/standardbar"
REM *** Macro command to add
sMyToolbarCmdId = "macro:///Standard.Module1.Test()"

REM *** Retrieve the module configuration manager from central module
configuration manager supplier
oModuleCfgMgrSupplier =

REM *** Retrieve the module configuration manager with module identifier
REM *** See for more information
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(
"" )
oImageMgr = oModuleCfgMgr.getImageManager()

oToolbarSettings = oModuleCfgMgr.getSettings( sToolbar, true )

REM *** Look for our button. Can be identified by the CommandURL
bHasAlreadyButton = false
nCount = oToolbarSettings.getCount()
for i = 0 to nCount-1
oToolbarButton() = oToolbarSettings.getByIndex( i )
nToolbarButtonCount = ubound(oToolbarButton())
for j = 0 to nToolbarButtonCount
if oToolbarButton(j).Name = "CommandURL" then
if oToolbarButton(j).Value = sMyToolbarCmdId then
bHasAlreadyButton = true
end if
next j
next i

Dim oImageCmds(0)
Dim oImages(0)
REM *** Check if image has already been added
if not oImageMgr.hasImage( 0, sMyToolbarCmdId ) then

REM *** Try to load the image from the file URL
oImage = GetImageFromURL( "file:///c:/test.bmp" )
if not isNull( oImage ) then

REM *** Insert new image into the Writer image manager
oImageCmds(0) = sMyToolbarCmdId
oImages(0) = oImage
oImageMgr.insertImages( 0, oImageCmds(), oImages() )
end if
end if

if not bHasAlreadyButton then
sString = "My Macro's"
oToolbarItem = CreateToolbarItem( sMyToolbarCmdId,
"Standard.Module1.Test" )

Further on in this thread, Jan Hols Jensen posted a solution for his
case, using the following

 > For J = 0 To UBound(ToolbarButtonProps())
 > If ToolbarButtonProps(J).Name = "CommandURL" Then
 > ToolbarButtonProps(J).Value = NewURL
 > End If
 > Next

to change an existing button.
This works, however I find no way to keep the tool tip. which I guess is
the HelpID.

Found this issue in IssueTracker, happening to offer a patch too:

Could this indeed be a bug?
Hi Cor,

From my point of view this is not a bug. A function in a toolbar or menu item contains a CommandURL which describe what command will be processed on activation. As the CommandURL is a unique identier for the function it can also be used for the help. The "HelpID" property was used for backward compatibility. Currently OOo normally uses the CommandURL to retrieve the tooltip/help content. It's possible for an implementation to change the tooltip text (e.g. look at the undo function which shows the latest undo step as tooltip). This can only be done by the responsible DispatchProvider implementation using a full-featured UNO language (Java, C/C++, Python). I don't know a way to do it with Basic. The dispatch object must send a and put a string object into the "State" member.


To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to