[Libreoffice] How to discover a toolbutton callback function?

Michael Meeks michael.meeks at suse.com
Mon Jan 23 01:55:30 PST 2012

Hi Rodolfo,

On Mon, 2012-01-23 at 07:12 -0200, Rodolfo wrote:
> Given a label of a toolbuton how can I discover which method it trigger?

	That's a really good question :-)

> I can't find the "Increase Font" thing (I'd like to fix this bug
> https://bugs.freedesktop.org/show_bug.cgi?id=35862 )

	Wow - that'd be great. So - here are the steps. First you need to find
the command-name which looks like ".uno:Foo":

* Finding the command name

	If you're familiar with the layout of the menus / toolbars you can see
the XML config files that define their layout in each component eg.


<toolbar:toolbaritem xlink:href=".uno:IncrementIndent" toolbar:helpid="helpid:10462" />
 <toolbar:toolbaritem xlink:href=".uno:Grow" toolbar:helpid="helpid:20403"  toolbar:visible="false" />
 <toolbar:toolbaritem xlink:href=".uno:Shrink" toolbar:helpid="helpid:20404"  toolbar:visible="false" />

	If you only have the english string for the name, then:

	cd officecfg/
	git grep -5 -i "increase font"

registry/data/org/openoffice/Office/UI/WriterCommands.xcu-            <node oor:name=".uno:Grow" oor:op="replace">
registry/data/org/openoffice/Office/UI/WriterCommands.xcu-                <prop oor:name="Label" oor:type="xs:string">
registry/data/org/openoffice/Office/UI/WriterCommands.xcu:                    <value xml:lang="en-US">Increase Font</value>
registry/data/org/openoffice/Office/UI/WriterCommands.xcu-                </prop>
registry/data/org/openoffice/Office/UI/WriterCommands.xcu-                <prop oor:name="Properties" oor:type="xs:int">
registry/data/org/openoffice/Office/UI/WriterCommands.xcu-                    <value>1</value>
registry/data/org/openoffice/Office/UI/WriterCommands.xcu-                </prop>
registry/data/org/openoffice/Office/UI/WriterCommands.xcu-            </node>

	So this gets you to the command-name:


* Finding the SID for that command-name

	Each command has an integer associated with it for historical
reasons :-) We need to find that so, from the toplevel:

	git grep '".uno:Grow"'

svx/inc/svx/svxcommands.h:#define CMD_SID_GROW_FONT_SIZE                      ".uno:Grow"
sw/inc/swcommands.h:#define CMD_FN_GROW_FONT_SIZE                       ".uno:Grow"

	Which gives us the name of the function:

	git grep -5 'GROW_FONT_SIZE'

sw/inc/cmdid.h:#define FN_GROW_FONT_SIZE       (FN_FORMAT + 3 )

	And we start to find the hooks for this command around the place :-)

* How the string is associated with the id ...

	Ho hum, I tried to dig out how this is done; it used to be via a
structure in sfx2 that had both the integer and the string id, but I
can't see it immediately :-)

	Anyhow - hope that helps,

	All the best,


michael.meeks at suse.com  <><, Pseudo Engineer, itinerant idiot

More information about the LibreOffice mailing list