Documente Academic
Documente Profesional
Documente Cultură
A routine to extend Writer so that the Alt key can be used for shortcuts
How it works
When a keyHandler routine is set-up for a Writer document then any key that gets pressed can be analysed by the keyHandler. The keyHandler routine in the macros associated with this document check if the Alt key was pressed, if it wasn't pressed then the keyHandler exits allowing other routines to process the key. If the Alt key was pressed then it checks against an array to determine what action to take. Included in these macros is a dialog to assist with managing the array, it allows you to assign styles, text, commands, and macros (that are in the global BASIC libraries soffice). If there is no assignment for the key press then the keypress is passed on to any other key handlers.
Testing
This macro requires installing before you can test it.. See Installing on page 3 below, especially if you are upgrading this macro as you could lose your current Alt+Key assignments. Having installed the macro try the Alt+key assignments. E.g. Alt+1 should apply paragraph style Heading 1, Alt+M should insert an em dash, Alt+R should reset attributes (i.e same as Right click Default or Format > Default) and Alt+Control+T should give a hanging indent, and Alt+A should run the Alt key assignment macro.
Left Listbox
This list box shows the current assignments for the keys. The first character is the actual key, currently this macro only handles 0-9 and A-Z. Then there is a space and a single character which describes what sort of action to take, as per the following table: Letter P C F p n T c M Action Apply Paragraph style Apply Character style Apply Frame style Apply page style Apply numbering style Insert the following text Run the following dispatch command Run the following global macro
And lastly either the name of the style, the text to be inserted, the command to be dispatched or the macro to be run. Select an item in this listbox to assign or remove an action to the keypress. When selecting key presses without other modifiers remember that some of those key presses activate the menu e.g. Alt+F for the file menu so you probably don't want to use them.
Styles
Second drop down
This contains the different types of styles that can be applied in Writer: Paragraph, character, and Numbering. Selecting one of these style types will change the listbox below to display the corresponding styles for the current document.
Style listbox
Click on a style name in this listbox so that when you click the Assign button that this style is associated with the currently selected keypress.
Text
Type text into the text field. You may want to use the Insert Special dialog by pressing Control+Shift+S. Note that the Insert Special dialog is more limited when working in a textbox than it is when working in a Writer document in that you cannot change the font. Therefore you may want to have inserted the special character into your Writer document and copied it so that you can simply paste it in using Control+V. Then click the Assign button.
Commands
The commands listbox displays a list of Writer dispatch commands. Select a command and click the Assign button. The list of commands are those commands listed in slots.sxc, a file documenting the dispatch slots for OOo available from http://api.openoffice.org/files/documents/22/1344/slots.sxc, for Writer without any additional parameters.
Macros
Select the global library, then module and lastly macro. Click the Assign button.
Assign button
Having selected the what addition modifiers (Control and/or Shift) if any, what key press and what action, click the assign button to actually make the assignment.
Remove button
Clicking this button will remove the action from the currently selected keypress.
OK button
Click this button to actually save the changes.
Doc button
This button creates a new document with a table showing all of the Aly key assignments. If you have made changes it will ask if you wish to save the changes and close the dialog.
Cancel button
Click this button to ignore any assignments that you have just made and close the dialog. If you have made changes it will double check with you.
Installing
Adding the library
This is so that the macro will be available for use when required 1. Tools > Macros > Macro... > Organizer > Libraries 2. Ensure that sOffice is selected for Application/Document 3. Click Append... 4. Navigate to where this file is stored and select it, click Open 5. If you already have a library called AltKeySettingsDyn do not check it as you will lose all your current Alt+Key settings. If you are updating AltKeyHandler and don't have AltKeySettingsDyn then you have a very early version and don't want to lose your key assignments then you will need to install AltKeySettingsDyn and use copy and replace from the your module LoadSettings in AltKeyHandler of the key assignments between the sub and end sub (do not include the line starting with sub). Before recommencing at step 1. 6. Uncheck Standard but ensure AltKeyHandler is checked 7. If updating from an old version check Replace existing libraries 8. Ok > Close > Close
Setting up the alt key handler so that it works on all Writer documents
1. Tools > Configure... > Events 2. Make sure that OpenOffice.org is selected top right 3. In the Macros list box: Click the + next to OpenOffice.org BASIC Macros, the plus next to AltKeyHandler, then click AltKeyHandler. 4. In the listbox now labelled AltKeyHandler select SetupAltKeyHandler 5. In the top listbox click on Create Document > Assign and then Open Document Assign 6. Click OK
Indents
I have included routines for creating indents in a similar way to what Word and Word Perfect do.
IncreaseHangingIndent: Works like Control + T in Word IncreaseHangingIndent DecreaseHangingIndent: Works like Control + Shift + T in Word DecreaseHangingIndent WordPerfectIndent: Works like Indent in Word Perfect WordPerfectIndent
Copyright
Copyright 2004 Ian Laurenson Anyone may run the code associated with this document. If you wish to modify or distribute this document and or its code, then you are granted a license to do so under the terms of the Gnu Lesser General Public License. See: http://www.gnu.org/licenses/lgpl.html.
Author contact
Send comments, bug fixes, change requests etc to hillview@paradise.net.nz