Documentation/How Tos/Edit Keyboard Configuration File

From Apache OpenOffice Wiki
< Documentation‎ | How Tos
Revision as of 14:52, 3 February 2009 by Mwaller (Talk | contribs)

Jump to: navigation, search

Template:Documentation/NeedsRework Template:Documentation/Windows

Customize Keybord by Editing a Configuration File

OpenOffice.org Version 2.0 to 3.0.1

Up to OOo3.0 it is not possible to define a shortcut key which includes the ALT-key using the Customize dialog, Issue 4756 . But you must edit the configuration file to get such a shortcut. This is a description, how to do it. It has only been tested for WinXP.

You need an editor, which preserves Unix line ends and the coding "UTF-8", and which will not set a byte order mark. I have used "PSPAD" or "jEdit" on WinXP. On WinXP neither WordPad nor NotePad is suitable. OOo itself can export in UTF-8 and Unix line ends, but sets a byte order mark, so you cannot use OOo.

On WinXP the keybord settings for the single modules are in the files

<..>\user\config\soffice.cfg\modules\<module name>\accelerator\<language code>\current.xml

and general keyboard settings are in the file

<..>\user\config\soffice.cfg\global\accelerator\<language code>\current.xml

Older versions of OOo might not have these files by default. If they are missing, go to Tool | Customize | Keyboard and change something. Then the files will be generated.

  1. Close OOo and close quickstarter.
  2. Make a copy of the file, you will work on.
  3. Open the file in an editor.
  4. Edit the file and save it.
  5. Start OOo.

If something is wrong, OOo will crash when you press a key. Do not try to restore the document and do not sent a crash report. But restore the original file with the copy you have made in step 2.

To learn more about this file, see "StarOffice 7 Administration Guide" chapter 4 [1], "StarOffice 8 Administration Guide" chapter 3 and appendix A [2], and "OpenOffice.org XML File Format 1.0 Technical Reference Manual", chapter 9.2 [3].

Let us have a deeper look at the file. You will see something like

<?xml version="1.0" encoding="UTF-8"?>
<accel:acceleratorlist xmlns:accel="http://openoffice.org/2001/accel" xmlns:xlink="http://www.w3.org/1999/xlink">
	<accel:item accel:code="KEY_Q" accel:mod1="true" xlink:href=".uno:Quit"/>
	<accel:item accel:code="KEY_N" accel:shift="true" accel:mod1="true" xlink:href=".uno:NewDoc"/>

You will notice that the lines have all the same structure.

accel:item
Each such line defines a single short cut key.
accel:code="KEY_Q"

You can use only keys which has got a name. I don't know where to find a actual list of all possible keys and which of them will work, dependent on keyboard, operating system and language. If you know something, please add the information.

Next the modifier keys are listed. You need only those, which are used, because the default value of the modifier keys is "false".

accel:mod1="true"
That is the CRTL-key.
accel:mod2="true"
That is the ALT-key.
accel:shift="true"
That is the SHIFT-key.

Instead of pressing the keys CRTL and ALT together, you can also press the key AltGr That's on a German keyboard. Would be nice, if someone corrects this for an English keyboard.

The last position describes what the shortcut should do, for example

xlink:href=".uno:Quit"
will close OOo.


Inside the quotes stands a Command URL. In older OOo versions the command URL could be build as
"slot:<number>"
but that way should not be used for newer versions, if a ".uno" form exists. Therefore always use
".uno:<command>"

You find those commands in the document [4] in the first column or in the above mentioned document "StarOFfice 8 Administration Guide".

Some of the commands need parameters. There seems to be no list of those parameters, but you can get a hint, if you record a macro and look, which parameters the dispatcher gets. For example the macro record of inserting a special character gives you the Command URL ".uno:InsertSymbol" and the parameter "Symbols" with for example the value "δ" (Greek delta). Or look at the existing lines in the configuration files. Perhaps you can alter a parameter?

Such parameters follow the command after a ?. For inserting the character "δ" the complete Command URL is ".uno:InsertSymbol?Symbols:string=δ".

Modifier keys and command URL may be exchanged.

The complete line for inserting the special character δ when pressing the keys AltGr (German) and D together is then

<accel:item accel:code="KEY_D" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertSymbol?Symbols:string=δ" />

OpenOffice.org Version 3.1

From OOo version 3.1 an xcu format is used for the keyboard configuration file. This format is common for other configurations too. The corresponding schema is defined in
...\OpenOffice.org 3\Basis\share\registry\schema\org\openoffice\Office\Accelerators.xcs
The default keyboard short cuts, which are valid for all users, are defined in the file
...\OpenOffice.org 3\Basis\share\registry\data\org\openoffice\Office\Accelerators.xcu
The personal settings are in the similar file in the user directory
..\user\registry\data\org\openoffice\Office\Accelerators.xcu

These files are common for all modules. Each module has a separate section, for example
<node oor:name="com.sun.star.text.TextDocument">. Short cut keys, which are available in all modules, are defined in the section <node oor:name="Global">.

Such configuration file is divided into two sections,
<node oor:name="PrimaryKeys"> and <node oor:name="SecondaryKeys">.
If the user defines a short cut key for a command, which has already got a short cut key, then the old setting is moved to the SecondaryKeys section and in the PrimaryKeys section the value removed is noted, for example
<node oor:name="RIGHT_SHIFT_MOD1" oor:op="remove"/></node>. You will understand the structure of the file, when you read it.

Each short cut key is represented by a node element. The above example of AltGr+d to get δ now reads

<node oor:name="D_MOD1_MOD2" oor:op="replace">
  <prop oor:name="Command">
    <value xml:lang="en-US">.uno:InsertSymbol?Symbols:string=δ</value>
  </prop>
</node>

In detail:

oor:name="D_MOD1_MOD2"
This sets the desired short cut. Write first the key identifier, then the modifiers, connected with an underscore.
oor:op="replace"
The value replace is used for new keyboard short cuts too. For further details on the OpenOffice.org registry format, see http://util.openoffice.org/common/configuration/oor-document-format.html
xml:lang="en-US"
This is not the language of the user interface, but the language of the command and therefore always "en-US".
.uno:InsertSymbol?symbol:string=δ
This is the command to be executed with the short cut key. It is no longer an attribute, but the content of the value element.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools