Images for Toolbars and Menus

From Apache OpenOffice Wiki
Jump to: navigation, search supports images in menus and toolboxes. In addition to the property ImageIdentifier, the add-ons configuration branch has a fourth set called Images that let developers define and use their own images. The image data can be integrated into the configuration either as hex encoded binary data or as references to external bitmap files. The Images set binds a command URL to user defined images.

Properties of template Images
oor:name string. The name of the configuration node. It must be unique inside the configuration branch. Therefore it is mandatory to use a schema such as org.openoffice.<developer>.<add-on name> or com.<company>.<product>.<add-on name> to avoid name conflicts. Please keep in mind that your configuration file will be merged into the Apache OpenOffice configuration branch. You do not know how many or which add-ons were installed before by the user.Please be aware that the name must begin with an ASCII letter character.
URL string. Specifies the command URL that should be bound to the defined images. Apache OpenOffice searches for images with the command URL that a menu item/toolbox item contains.
UserDefinedImages Group of properties. This optional group provides self-defined images data to Apache OpenOffice. There are two different groups of properties to define the image data. One property group provides the image data as ongoing hex values specifying an uncompressed bitmap format stream. The other property group uses URLs to external bitmap files. The names of these properties end with 'URL'.

Since version 2.0.3, images should be in png format, which supports transparency.

Legacy bitmap (bmp) format is still supported. Apache OpenOffice supports bitmap streams with 1, 4, 8, 16, 24 bit color depth. Magenta (color value red=0xffff, green=0x0000, blue=0xffff) is used as the transparent color, meaning that the background color of the display will be used instead of the image pixel color when the image is drawn.

For best quality, the size of small images should be 16x16 pixel, and for big images 26x26 pixel. Other image sizes will be scaled automatically by Apache OpenOffice. If no high contrast image data is provided, Apache OpenOffice uses the normal image for high contrast environments. Image data that is not valid will be ignored.

An Images node uses a second node called UserDefinedImages where the user defined images data are stored.

Properties of template UserDefinedImages
ImageSmall HexBinary. Used for normal menu/toolbar items, standard size is 16x16 pixel.
ImageBig HexBinary. Only toolbars can use big images. Standard size is 26x26 pixel. The user can activate large buttons with the Tools – Options – View – Large Buttons checkbox.
ImageSmallHC HexBinary. Used for high contrast environments, which means that the background color of a menu or toolbar is below a certain threshold value for the brightness.
ImageBigHC HexBinary. Only toolbars can use big images. Used for high contrast environments, which means that the background color of a toolbar is below a certain threshold value for the brightness.
ImageSmallURL string. An URL to an external image which is used for menu items and normal toolbar buttons. External user-defined images are supported using the placeholder variable %origin%, representing the folder where the component will be installed. The term %origin% will be exchanged with another placeholder, which is substituted during runtime by Apache OpenOffice to the real installation folder. Since Apache OpenOffice supports two different configuration folders ( user and share ) this mechanism is necessary to determine the installation folder of a component.

For example the URL %origin%/images will be substituted with something like$UNO_USER_PACKAGES_CACHE/uno_packages/ 

The placeholder$UNO_USER_PACKAGES_CACHE is then substituted during runtime with the real path.

Note #1: As of Apache OpenOffice 4.1.0, %origin% is substituted with something like$UNO_USER_PACKAGES_CACHE/uno_packages/svfj5eg0.tmp_/AddOn.oxt/registry/data/org/openoffice/Office/images

As a consequence, a URL to an image example.png that appears on the filesystem to be in AddOn.oxt/images/example.png must be entered as


Note #2: As of Apache OpenOffice 4.1.0, a second substitution mechanism can be used. Use the URL schema where extension-id is the ID of the extension as defined in the description/identifier tag of the file description.xml. For instance, if the ID of an extension is com.example.myproduct.MyExtension and a folder images is at the root of the OXT package, the URL to enter will be
ImageBigURL string. An URL to an external image which is used for big toolbar buttons.
ImageSmallHCURL string. An URL to an external image which is used for menu items and normal toolbar button in a high contrast environment.
ImageBigHCURL string. An URL to an external image which is used for big toolbar buttons in a high contrast environment.

The embedded image data have a higher priority when used in conjunction with the URL properties. The embedded and URL properties can be mixed without a problem.

The next example creates two user-defined images for the function org.openoffice.Office.addon.example:Function1. The normal image is defined using the embedded image data property ImageSmall and has a size of 16x16 pixel and a 4-bit color depth. The other one uses the URL property ImageSmallHCURL to reference an external bitmap file for the high contrast image. Referencing an external png image would be same, only the extension changes.

  <?xml version='1.0' encoding='UTF-8'?>
  <oor:component-data xmlns:oor="" xmlns:xs="" oor:name="Addons" oor:package="org.openoffice.Office">
      <node oor:name="AddonUI">
          <node oor:name="Images">
              <node oor:name="" oor:op="replace">
                  <prop oor:name="URL" oor:type="xs:string">
                  <node oor:name=”UserDefinedImages”>
                      <prop oor:name=”ImageSmall”>
                      <prop oor:name=”ImageSmallHCURL”>
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages