Reveal Codes 3

The macro associated with this document is for displaying a dialog that has the “codes” of the current paragraph – that is the paragraph that contains the insertion point.

The “codes” are the properties of the paragraph and the properties of the portions within the paragraph, where those properties are different from default and are different from the preceding portion. As the codes are those used internally by OpenOffice.org (OOo) they may not be immediately obvious to you. For example instead of a code for “Bold” the corresponding code is “CharWeight: 150”. It is now possible to view all the property codes via the macro – see 2.1 The “C” / “P” toggle button below.

In this version the buttons for the properties are configurable (the controls for text portions are not yet configurable). To configure a button hold down Control and then click on the button. More detail below. The basic idea is that when a button for a property is clicked or Shift + clicked then either the property is deleted or a OOo dialog is displayed.

At this stage this macro is getting closer to being a fully working macro but it is still primarily to see what people want and to get some constructive discussion going. It is not yet complete! So please give feedback either to me directly (e-mail address at bottom) or preferably via the forum thread http://www.oooforum.org/forum/viewtopic.php?p=36976.

The macro has been run on OOo1.1.1 to Ooo1.1.3 for Linux. It should work for Windows, and I have made a requested change for Mac users – so I think it works for Macs. I don’t know how it works in non english versions of OOo but I have reports of the editboxes looking funny for text going right to left. It would require a minor change for the developer releases (Ooo1.9.x).

Demo

Unfortunately this version needs to be installed to be able to work (see 5 Installing below). For a demo of the basic concept you could look at Reveal Codes 2. See Figure 1 for a screen capture.

Figure 1 A screen capture of an example reveal codes dialog. What follows is some detail about each of the controls on the dialog.

The controls on the dialog

There are 4 fixed controls on the dialog. These controls should be at the right edge of the dialog. In previous versions there was a bug (may still be there) that these controls were not visible on some systems. The dialog should be displayed at the same width as the window from which it was called and be positioned at the top.

The “C” / “P” toggle button

This button in the top right of the dialog toggles between seeing all possible property buttons and the properties of the current paragraph. The idea behind seeing all the possible controls is so that it is possible to customise what happens when a particular property button is clicked without having to construct a paragraph with that property. It also shows the colours of the different property buttons. The “C” stands for “Configure” and “P” for paragraph.

Cancel will lose all changes. Changes to styles that have been “saved” by clicking the “Save style” button will be in effect for this session of reveal codes only. OK saves all changes. The controls in this region are for setting the colour of the buttons background and text. Default colours are the system colours (typically grey background, black text). Listbox for selecting a style. Direct means that the button isn’t using a style but has it’s own properties. If a corresponding listbox above shows “Default” then the command in these listboxes will come into effect. Listboxes for selecting what command happens for the different types of buttons when clicked or Shift+Clicked. These edit boxes are to set what gets displayed in the text portion edit boxes for non displaying characters. Name of the property and shows current colours Figure 2 The configure dialog. If you click on the “C” button and then click on a property button you should see a dialog like that in Figure 2.

Some notes about the concepts used in configuring a button follow:

Button types

There are three different types of property buttons. When configuring a property button you are configuring all three types. The different types of property buttons are:

Paragraph: these properties apply to the whole paragraph and are displayed first without angle brackets

Open Property: these are displayed before a text portion to say that this property starts here. These are displayed with a right angle bracket at the right end “>”.

Close Property: these are displayed after a text portion to say that this property ends here. These are displayed with a left angle bracket at the left end “<”.

Attributes

A button can either have “direct” attributes or a style. The attributes of a button or style are its:

Style name. (If the name is “Direct” then the button has no style.)

Background colour

Text colour

Commands for click and Shift+Click for each of the 3 different types of property button.

Commands

To add your own commands simply write or record a sub in module modButtonCommands in library RevealCodes. See comments at the top of the module for more information. Currently these are the commands available:

CloseToOpenPropertyToDefault: If the property is able to to be reset then this command resets the property from the close property button to the corresponding open property button. In effect it is like the property has been deleted for the text portions between the buttons. This command should only be assigned to Close property buttons.

DeleteReference: Removes set references without removing the text or its formatting (but if set references are nested it will delete the nested references as well).

EditStyle: Displays the dialog to edit the style of the current paragraph.

ExtendPropertyRightOnePortion: This command only works for those properties with a simple type (a simple type being a single value like a single number or a string as opposed to an array or structure). This command applies the same property value to the next text portion to the right. In effect this is like moving the close button one text portion to the right. This command should only be assigned to Close property buttons.

ExtendPropertyRightToSameProperty: This command only works for those properties with a simple type (a simple type being a single value like a single number or a string as opposed to an array or structure). This command applies the same property value to text portions to the right, until a text portion has the property value. In effect this is like deleting the close button only. This command should only be assigned to Close property buttons.

FontDialog: Displays the format Character dialog.

NoPageBreak: Removes manual page breaks. Typically applied to the property “BreakType”. But, it doesn’t always work properly.

NumberingBulletsDialog: Displays the numbering and bullets dialog.

NumberingLevel: Displays an input box so that a single digit can be entered for the numbering level.

NumeringRestartToggle: For numbered paragraphs toggles between restarting the numbering and not.

OpenToClosePropertyToDefault: If the property is able to to be reset then this command resets the property from the open property button to the corresponding close property button. In effect it is like the property has been deleted for the text portions between the buttons. This command should only be assigned to Open property buttons.

ParagraphDialog: Displays the format Paragraph Dialog.

ParaPropertyToDefault: If the property is able to to be reset then this command resets the property for the entire paragraph. In effect it is like the property has been deleted for the entire paragraph.

RemoveNumbering: Removes automatic numbering.

ShrinkProperty: If the property is able to to be reset then this command resets the property for the current text portion. In effect it is like the property has been moved right for open properties and left for close properties. This command should only be assigned to Open and Close property buttons.

StyleCatalog: Displays the style catalog dialog. Unfortunately I can’t find a way of specifying that it consistently show paragraph styles (or character styles) so it displays the type of style that it displayed the last time that it was closed.

Styles

A style is just a quick way of applying and changing attributes to a button.

A “style name” of “Direct” means that the settings are just for the current button. For example the buttons to do with the property ParaStyleName are shipped with direct attributes.

The style “Default” can not be deleted. As “shipped” most buttons have the style “Default”. Also shipped with the macro is a style called “Numbering” this is to demonstrate the concept of styles. There are several properties to do with numbering, and they are all inter-related and can not be set to default (i.e. removed directly). Thus most of the buttons that relate to the various numbering properties have the same action for click (remove numbering) and shift+click (Numbering and bullets dialog), and have a blue background with white text. If you don’t like the colour scheme or the assigned commands it is possible to change the colour scheme for the style and all the buttons with that style will also change.

Default Commands

When a button or style has a command of “Default” then the actual command that gets issued is the corresponding command in the defaults area. The idea behind this is that most buttons can work identically, but as a user you may want to change the default behaviour. Rather than having to change each style and each button, you can simply change the defaults.

Space, Tab and LineBreak edit boxes

Here you can specify what character(s) will be used to represent these non displaying “characters” in the edit boxes. Be warned that there are no checks on what you put into here. If the characters in these edit boxes are in a text portion you edit with a corresponding text portion edit box they will be replaced with the non displaying character. Really these belong on a separate dialog as they aren't to do with configuring a particular button but I was too lazy to do so.

The slider at the right edge of the dialog

This control simply shifts the “codes” on the dialog so that where there are more codes than can be displayed on the dialog you can use the slider to slide them into view. When the slider has been moved the fixed controls are temporarily disabled – this is to prevent a problem that occurs when controls are clicked again before the routine has finished. When the slider is at the bottom, the last row of controls will be at the top of the dialog.

Previous Paragraph button labelled with “^” bottom right

Displays the “codes” of the previous paragraph. Currently I have been lazy in my coding and so it isn't disabled when the first paragraph is selected. Clicking this button when on the first paragraph simply redisplays the first paragraph.

Next Paragraph button labelled with “V” bottom right

Similar to previous paragraph but displays the codes of the next paragraph.

Dynamic controls

The remainder of the controls are dynamically put onto the dialog, based on the properties of the paragraph and the text portions within the paragraph. A text portion is text in the paragraph with consistent formatting (which has a text edit box on the dialog), or some text content such as ReferenceMarks, TextFields, Bookmarks, DocumentIndexMark, Redlines, Footnotes and Frames (currently non-customisable buttons).

What follows is some more information on each of the different button types.

Buttons

The buttons represent paragraph and text portion directly applied properties and paragraph portions other than normal text.

To customise a button for a particular property, either:

Hold down Control when clicking on a property button, or

Click on the “C” in the top right then click on the desired property, then click on a property button.

Each button can have a command associated for clicking and control+clicking.

See 2.1 The “C” / “P” toggle button above.

Paragraph Portions

I have divided text portions into two categories, text and others. The text is displayed in text field edit boxes and the others as buttons.

Edit portion edit boxes

These edit boxes display the text of the text portion. The edit boxes are limited in width so that they fit within the dialog and currently are only one line high, so you may not be able to see all the text at one time. When typing into these edit boxes the size of the edit box remains static and the text scrolls within it. You can see the changes that you are making in the edit box directly in the main document. You cannot, currently, delete a text portion from within this dialog.

Shift + Clicking the left mouse button on an edit box will display the Format Character dialog.

When the corresponding text portion is large. This is not only very slow but if you type fast enough it starts to get it wrong! In this case just pause for a moment and then make a change and hopefully everything will come right. I haven’t worked out how to overcome this issue.

Other portion buttons

The other portion buttons are displayed without angle brackets (except for “ReferenceMark Name:” as these have a start and end). Currently clicking these buttons act according to the following table:

Button Name	Action
ReferenceMark Name: xxx	Deletes the reference mark named xxx, but leaves the original text and its formatting behind (but will remove any nested set references).
TextField	Displays the “Fields” dialog.
Bookmark	Displays the “Bookmarks” dialog.
DocumentIndexMark	Displays the “Edit Index Entry” dialog
Redline	Displays the “Accept & Reject” tracked changes dialog. Click “Ok” on the “Done” msgbox when finished. There is probably a better way of doing this but haven’t spent time investigating it yet.
Footnote	Displays the “Edit Footnote” dialog.
Frame	Deletes the frame. I would have liked it to display the “Graphics” dialog but in Ooo1.1.1 when exiting the “graphics” dialog OOo crashes.
(Anything else if there is anything else)	Displays a msgbox asking you to let me know what you would like to have happen when you click this button.

Close

To close the dialog click the X in the top right of the dialog window (or press Esc or whatever key press on your operating system usually shuts dialogs).

Speed issues

The more text portions there are the slower the macro is at displaying the codes. I haven't figured out how to speed this up (although I hope it is now faster than previous versions even though it is doing more).

See 2.5.2.1 Edit portion edit boxes above for an important speed issue.

Dialog versus docked/dockable window

Ideally this macro would be better implemented as either a docked or dockable window. I do not know how to create a dockable window using OOo BASIC. I have experimented with creating a window that has a writer component at the top and an equivalent to this dialog at the bottom. My experimentation is not far enough along to post (it crashes OOo regularly). The other issue is that displaying the codes is quite slow and so having this window update real-time while working in the main Writer window would just be too slow! So, at this stage, I probably won't implement this as a docked window.

Installing

This macro, while still in development, can be useful for diagnosing problems and as such it maybe worth installing. To be able to test this macro it must be installed.

Adding the library

This is so that the macro will be available for use when required.

Tools > Macros > Macro... > Organizer > Libraries.

Ensure that sOffice is selected for Application/Document.

Click Append....

Navigate to where this file is stored and select it, click Open.

Uncheck “Standard” but ensure “RevealCodes” and “RevealCodesSettingsDyn” are checked.

If updating from an old version check “Replace existing libraries”.

OK > Close > Close.

Adding a menu entry

This is so that the macro integrates with OpenOffice.org Writer so that it appears seamlessly a part of it.

Tools > Configure... > Menu.

Select desired location in the top list box (“~Nonprinting Characters” is probably a good place).

In the category list box: Click the + next to “OpenOffice.org BASIC Macros” (towards bottom of list), the plus next to “RevealCodes”, then click “modRevealCodes”.

In the function list box: Click “IannzRevealCodes”.

Click the New button (top right of dialog).

Click OK.

Thanks

My thanks go to Danny Brewer and his many useful postings on the forums without which this macro would not have been possible. Thanks also to Bernard Marcelly for the OOo Xray macro – a truly invaluable tool. Also thanks to Tom Lambert for revising some code. However, any mistakes or gross programming style is entirely mine.

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 or better yet http://www.oooforum.org/forum/viewtopic.php?p=36976.

Page 7 of 7

2004-06-10T22:48:35