Framework/Article/Accelerators Configuration

    From The Document Foundation Wiki

    The accelerators configuration has been moved from XML based format to XCS/XCU based format since DEV300_m37, now we can define and install shortcuts for our extensions easily.

    Accelerators.xcs

    The configuration schema for accelerators is as following.

    <?xml version="1.0"?>
    <oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Accelerators" oor:package="org.openoffice.Office" xml:lang="en-US">
      <info>
        <desc>Configuration of Accelerators replacing the old not XCU-based configuration</desc>
      </info>
      <templates>
        <group oor:name="Key">
          <info>
            <desc>document the Key format</desc>
          </info>
          <prop oor:name="Command" oor:type="xs:string" oor:localized="true">
            <info>
              <desc>e.g..uno:About</desc>
            </info>
          </prop>
        </group>
        <set oor:name="Module" oor:node-type="Key">
          <info>
            <desc>point to a module of OOo</desc>
          </info>
        </set>
      </templates>
      <component>
        <group oor:name="PrimaryKeys">
          <info>
            <desc>contains the preferred keys</desc>
          </info>
          <set oor:name="Global" oor:node-type="Key">
            <info>
              <desc>Defined as key-values pairs</desc>
            </info>
          </set>
          <set oor:name="Modules" oor:node-type="Module">
            <info>
              <desc>containing the modules of OOo, defined as key-values pairs</desc>
            </info>
          </set>
        </group>
        <group oor:name="SecondaryKeys">
          <info>
            <desc>contains the secondary keys</desc>
          </info>
          <set oor:name="Global" oor:node-type="Key">
            <info>
              <desc>Defined as key-values pairs</desc>
            </info>
          </set>
          <set oor:name="Modules" oor:node-type="Module">
            <info>
              <desc>containing the modules of OOo, defined as key-values pairs</desc>
            </info>
          </set>
        </group>
      </component>
    </oor:component-schema>

    Meanings for the structure of this schema

    Name Description Type
    PrimaryKeys Contains the preferred shortcut keys, which are unique. If a command has more than one shortcut key, all the non-preferred ones should be part of SecondaryKeys.
    It has two entries:Global and Modules.
    group
    SecondaryKeys Contains the secondary shortcut keys. The non-preferred shortcut keys should be included here.
    It has two entries:Global and Modules.
    group
    Global Global based shortcut keys should be included here.
    It's a set of shortcut keys.
    set
    Modules It's a set of different application modules. set
    Module Module based shortcut keys should be included under the application module.
    It's a set of shortcut keys.
    set
    Key Represents a shortcut key. The string format is: "Key Identifier" + "_" + "Modifier Keys". Key Identifier, which can be be referred from the detailed Appendix, should be keys on keyboard or key functions. Modifier keys are optional and the sequence of them is SHIFT,MOD1,MOD2.
    SHIFT is mapped to Shift on all platforms.
    MOD1 is mapped to Ctrl on Windows/Linux, while it is mapped to Cmd on Mac.
    MOD2 is mapped to Alt on all platforms.
    group
    Command It's the command to be executed. Attribute xml:lang, which is mandatory here, can be used to specify commands for localized shortcut keys. string

    Accelerators.xcu

    The accelerators stored in the old XML files have been migrated to a new Accelerators.xcu, which could be found under the directory <OFFICE_INSTALL>/OpenOffice.org 3/Basis/share/registry/org/openoffice/Office/. Many default accelerators for OpenOffice.org applications have been defined in this Accelerators.xcu.

    <?xml version="1.0" encoding="UTF-8"?>
    <oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:install="http://openoffice.org/2004/installation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Accelerators" oor:package="org.openoffice.Office">
      <node oor:name="PrimaryKeys">
        <node oor:name="Global">
          <node oor:name="A_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:SelectAll</value>
            </prop>
          </node>
          <node oor:name="C_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:Copy</value>
            </prop>
          </node>
          <node oor:name="N_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:AddDirect</value>
            </prop>
          </node>
          <node oor:name="V_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:Paste</value>
            </prop>
          </node>
          <node oor:name="W_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:CloseWin</value>
            </prop>
          </node>
          <node oor:name="X_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:Cut</value>
            </prop>
          </node>
        </node>
        <node oor:name="Modules">
          <node oor:name="com.sun.star.text.TextDocument" oor:op="replace">
            <node oor:name="A_SHIFT_MOD1" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:ParaLeftToRight</value>
              </prop>
            </node>
            <node oor:name="BACKSPACE" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:SwBackspace</value>
              </prop>
            </node>
            <node oor:name="B_MOD1" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:Bold</value>
              </prop>
            </node>
            <node oor:name="F11" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:DesignerDialog</value>
              </prop>
            </node>
            <node oor:name="F5" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:Navigator</value>
              </prop>
            </node>
            <node oor:name="INSERT" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:InsertMode</value>
              </prop>
            </node>
          </node>
        </node>
      </node>
      <node oor:name="SecondaryKeys">
        <node oor:name="Global">
          <node oor:name="DELETE_SHIFT" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:Cut</value>
            </prop>
          </node>
          <node oor:name="F4_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:CloseWin</value>
            </prop>
          </node>
          <node oor:name="INSERT_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:Copy</value>
            </prop>
          </node>
          <node oor:name="INSERT_SHIFT" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:Paste</value>
            </prop>
          </node>
        </node>
        <node oor:name="Modules">
          <node oor:name="com.sun.star.text.TextDocument" oor:op="replace">
            <node oor:name="BACKSPACE_MOD2" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:Undo</value>
              </prop>
            </node>
            <node oor:name="F8_SHIFT_MOD1" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:SelectionModeBlock</value>
              </prop>
            </node>
            <node oor:name="UNDO" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:Undo</value>
              </prop>
            </node>
          </node>
        </node>
      </node>
    </oor:component-data>

    Example

    <?xml version="1.0" encoding="UTF-8"?>
    <oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:install="http://openoffice.org/2004/installation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Accelerators" oor:package="org.openoffice.Office">
      <node oor:name="PrimaryKeys">
        <node oor:name="Global">
          <node oor:name="C_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:CloseWin</value>
            </prop>
          </node>
        </node>
        <node oor:name="Modules">
          <node oor:name="com.sun.star.text.TextDocument">
            <node oor:name="F5" oor:op="replace">
              <prop oor:name="Command">
                <value xml:lang="en-US">.uno:Test</value>
              </prop>
            </node>
          </node>
        </node>
      </node>
      <node oor:name="SecondaryKeys">
        <node oor:name="Global">
          <node oor:name="L_SHIFT_MOD1" oor:op="replace">
            <prop oor:name="Command">
              <value xml:lang="en-US">.uno:CloseWin</value>
            </prop>
          </node>
        </node>
      </node>
    </oor:component-data>

    - Create a simple new Accelerators.xcu as above and package it to a new extension Accelerators.zip

    - Install Accelerators.zip via Menu: Tools->Extension Manager

    - Create a new TextDocument

    - Press Ctrl+C or Shift+Ctrl+L or F5

    - Result: you may find Ctrl+C/Shift+Ctrl+L will close the Document, and F5 will do nothing.

    Appendix: supported keys

    Key Identifier Key on keyboard
    0 0
    1 1
    2 2
    3 3
    4 4
    5 5
    6 6
    7 7
    8 8
    9 9
    A A
    B B
    C C
    D D
    E E
    F F
    G G
    H H
    I I
    J J
    K K
    L L
    M M
    N N
    O O
    P P
    Q Q
    R R
    S S
    T T
    U U
    V V
    W W
    X X
    Y Y
    Z Z
    F1 F1
    F2 F2
    F3 F3
    F4 F4
    F5 F5
    F6 F6
    F7 F7
    F8 F8
    F9 F9
    F10 F10
    F11 F11
    F12 F12
    F13
    F14
    F15
    F16
    F17
    F18
    F19
    F20
    F21
    F22
    F23
    F24
    F25
    F26
    DOWN Down
    UP Up
    LEFT Left
    RIGHT Right
    HOME Home
    END End
    PAGEUP PageUp
    PAGEDOWN PageDown
    RETURN Enter
    ESCAPE Esc
    TAB TAB
    BACKSPACE Backspace
    SPACE Space
    INSERT Insert
    DELETE Delete
    ADD +
    SUBTRACT -
    MULTIPLY *
    DIVIDE /
    POINT .
    COMMA ,
    LESS <
    GREATER >
    EQUAL =
    OPEN
    CUT
    COPY
    PASTE
    UNDO
    REPEAT
    FIND
    PROPERTIES
    FRONT
    CONTEXTMENU
    HELP
    MENU
    HANGUL_HANJA
    DECIMAL
    TILDE
    QUOTELEFT
    Apache Feather Logo.svg

    This work is licensed under the Apache License version 2.0