User:Rvojta/Multiplatform shortcuts

From Apache OpenOffice Wiki
< User:Rvojta
Revision as of 07:40, 26 February 2009 by Rvojta (Talk | contribs)

Jump to: navigation, search

OpenOffice.org violates many shortcuts on Mac OS X platform. There was an effort (accelerators01 CWS) to define all shortcuts in one place, but there isn't possibility to easily define multiplatform shortcuts. Because of these reasons macshortcuts01 CWS was introduced to fix all these issues and provide fixes for small amount of Mac OS X shortcuts to show how it can be done.

Many thanks to Stephan Bergmann, Eric Bachard, Philipp Lohmann, Carsten Driesner and others. I can't remember all people who helped me and if I missed you, I'm sorry. Feel free to drop me a note and I'll fix it.

Current State

Shortcuts Configuration

There's new shortcuts configuration approach since DEV300_m37. You can read framework's article Accelerators Configuration to have idea what was changed. But even with this new approach, it's not possible to easily define multiplatform shortcuts. There are some limitations.

What's possible

Simple shortcut definition. Example below defines F11 key as a shortcut for .uno:DesignerDialog (Stylist window).

<node oor:name="F11" oor:op="replace">
  <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
    <value xml:lang="en-US">.uno:DesignerDialog</value>
  </prop>
</node>

You can add attribute install:module to node, prop or value to make platform dependent configuration.

What's not possible

It's not possible to have two nodes, props or values with the same oor:name, different xml:lang and different install:module. Let's say you want to change F11 shortcut to Cmd-T on Mac OS X only. For the F11 key, it's quite easy. You can add install:module="unxwnt" to value, prop or node. This entry will be assigned to unxwnt module only. Example:

<node oor:name="F11" oor:op="replace">
  <prop oor:name="Command" install:module="unxwnt"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
    <value xml:lang="en-US">.uno:DesignerDialog</value>
  </prop>
</node>

But Cmd-T is already used in Accelerators.xcu file and is defined as:

<node oor:name="T_MOD1" oor:op="replace">
 <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
  <value xml:lang="de">.uno:SubScript</value>
  <value xml:lang="es">.uno:AlignHorizontalCenter</value>
 </prop>
</node>

It's possible to add new <value> pair.

  <value xml:lang="en-US">.uno:DesignerDialog</value>

But it's possible to sort this shortcut by modules? No, it's not possible. Because current limitations are:

  • you can't have more <value> pairs with xml:lang and install:module attributes,
  • you can't have more <prop> pairs with the same oor:name, but width different install:module value,
  • you can't have more <node> pairs with the same oor:name, but width different install:module values.
  • you can't have <value> pairs with and without install:module attribute (applies to x-no-translate).

You can easily define shortcuts, but you can't sort them to modules now.

Modifiers Support

Currently, OpenOffice.org supports three modifiers only - SHIFT, MOD1 and MOD2. You can see this in API reference of the KeyModifier constant group.

These modifiers are assigned to different keys on different platforms.

Modifier Platform Key
SHIFT All Shift
MOD1 Windows, UNIX Ctrl
Mac OS X Cmd
"MOD2" All Alt (Option)

There's no support for Ctrl on Mac OS X and for Windows (Meta) on Windows, Unix.

Enhancement

Shortcuts Definition

We propose to have possibility to use install:module with more than one <value> pair and xml:lang defined. It's possible now and you can define multiplatform shortcut in this way:

<node oor:name="F11" oor:op="replace">
 <prop oor:name="Command"><value xml:lang="x-no-translate" install:module="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
  <value xml:lang="en-US" install:module="unxwnt">.uno:DesignerDialog</value>
 </prop>
</node>

Example above defines F11 key as a shortcut for .uno:DesignerDialog on Unix and Windows platforms. Where and how is unxwnt install:module value defined / handled is described below.

As you can see, there's also special install:module value x-no-translate. You have to use it for <value> pair with xml:lang="x-no-translate" attribute if you use install:module because it's not possible to have <value> pairs with and without install:module attribute in one property (<prop>).

Example below shows how to define multiplatform shortcut actions for Ctrl-T (Cmd-T on Mac OS X). Cmd-T is used to display/hide stylist window on Mac OS X for all languages. Ctrl-T is used for subscript on Unix, Windows platform (DE language only). Ctrl-T is used for centering horizontal alignment on Unix, Windows platforms (ES language only).

<node oor:name="T_MOD1" oor:op="replace">
 <prop oor:name="Command"><value xml:lang="x-no-translate" install:module="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
   <value xml:lang="de" install:module="unxwnt">.uno:SubScript</value>
   <value xml:lang="es" install:module="unxwnt">.uno:AlignHorizontalCenter</value>
   <value xml:lang="en-US" install:module="macosx">.uno:DesignerDialog</value>
  </prop>
</node>

As you can see, you can define shortcuts for multiple platforms (modules) and for different languages. You can find more example in Accelerators.xcu file.

Now, we have defined multiplatform shortcuts and two modules: unxwnt, macosx. We have to edit makefile.mk and add our shortcuts and modules there.

Accelerators.xcu must be added to XCUFILES and LOCALIZEDFILES. Module files are generated automatically during build process and they have names Accelerators-unxwnt.xcu and Accelerators-macosx.xcu. Both files must be added to MODULEFILES. Example below:

XCUFILES = Accelerators \
  ...
 
MODULEFILES = Accelerators-macosx.xcu \
  Accelerators-unxwnt.xcu \
  ...
 
LOCALIZEDFILES = Accelerators.xcu \
  ...

We have define directory where we want to see our modules XCU files. This is defined in directory_ooo.scp file.

Directory gid_Dir_Share_Registry_Modules_Oo_Office_Accelerators
    ParentID = gid_Dir_Share_Registry_Modules_Oo_Office;
    HostName = "Accelerators";
End

We have defined shortcuts, build system, directory for our modules and the only thing we need to do is to select proper modules for platforms. It's done in file_ooo.scp file.

File gid_File_Registry_Spool_Oo_Accelerators_System_Xcu
    TXT_FILE_BODY;
    Styles = (PACKED);
    Dir = gid_Dir_Share_Registry_Modules_Oo_Office_Accelerators;
#ifdef QUARTZ
    Name = "/registry/spool/org/openoffice/Office/Accelerators-macosx.xcu";
#else
    Name = "/registry/spool/org/openoffice/Office/Accelerators-unxwnt.xcu";
#endif
End

Here's an example how to make selection based on your platform.

#ifdef WNT
    Platform = "Windows";
#elif defined QUARTZ
    Platform = "Mac OS X";
#else
    Platform = "Unix";
#endif

That's all. This is the way how to define multiplatform shortcuts. Most things mentioned here are done. It's enough to modify Accelerators.xcu file if you do want to provide shortcuts for Mac OS X (macosx) or for Windows/Linux (unxwnt) platforms.

Modifiers Support

This enhancement introduces MOD3 modifier in KeyModifier.idl. For now, OpenOffice.org supports SHIFT, MOD1, MOD2, MOD3. Platform specific usage:

Modifier Platform Key
SHIFT All Shift
MOD1 Unix, Windows Ctrl
Mac OS X Cmd
MOD2 All Alt (Option)
MOD3 Unix, Windows Windows (meta)
Mac OS X Ctrl

You can combine all these modifiers in Accelerators.xcu file. For example T_MOD2_MOD1 for Cmd-Option-T (Mac OS X), Ctrl-Alt-T (Unix, Windows), etc.

References

CWS

Name: macshortcuts01 (diff)

Content:

  • Introduced MOD3 modifier (including changes in lot of modules to support it)
    • Modules: dbaccess, sfx2, vcl, sc, sd, toolkit, offapi, framework, accessibility, svx, forms, svtools
  • Possibility to have multiple <value> pairs with xml:lang and install:module attributes
    • Modules: officecfg, scp2 (for unxwnt and macosx modules)
  • Cmd-Y to Cmd-Shift-Z for Redo on Mac OS X
    • Modules: officecfg
  • Cmd-M to minimize current windows on Mac OS X
    • Modules: vcl
  • Cmd-Option-M to minimize all application windows on Mac OS X
    • Modules: vcl
  • Cmd-M to Ctrl-M for Default formatting on Mac OS X
    • Modules: officecfg
  • F11 to Cmd-T for Stylist window on Mac OS X
    • Modules: officecfg

What's missing to be marked ready for QA:

  • review Cmd-T shortcut for ES language
  • review Cmd-T shortcut for DE language (thanks to Andre Schnabel)

Issues

Credits

Eric Bachard for initial help. Stephan Bergmann, Carsten Driesner and Philipp Lohmann for helping me with remaining issues.

Personal tools