Reveal Codes

It displays a dialog that has the “codes” of the current paragraph – I.e. 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 the default and are different from the preceding portion. As the codes are those used internally by OpenOffice.org (OOo) they maynot be immediately obvious to you. For example instead of a code for “Bold” the corresponding code is “CharWeight: 150”

Generally clicking on a button that represents a “code” will delete that code. Clicking the middle mouse button on an edit field displays the format character dialog.

At this stage this is a macro 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.

Try the demo

Have the cursor in desired paragraph then click this button .

Demo bold italic boldItalic boldedFromToolbar underlined redlining regular text 10/06/04.

That's using it at it's simplest. What follows is some detail about each of the controls on the dialog.

The controls on the dialog

There are 3 fixed controls on the dialog. The slider on the right, and below that the previous and next paragraph buttons/

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 use the slider to slide them into view.

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.

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 attributes of the paragraph and the text portions within the paragraph. A text portion is text in the paragraph with consistent formatting, or some text content such as ReferenceMarks, TextFields, Bookmarks, DocumentIndexMark, Redlines, Footnotes and Frames.

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

Buttons

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

Paragraph attribute buttons

These buttons are displayed first on the dialog and don't have any angle brackets. Clicking these buttons runs a command to reset to default that particular attribute for the entire paragraph. However, there maybe some attributes that don't reset so will need some more coding – please let me know about these.

The attributes are displayed in alphabetical order.

Starting text portion attribute buttons

These buttons have a right angle bracket at the right end “>”. Clicking these buttons runs a command to reset to default that particular attribute for the text portions between it and it's corresponding button the End text portion attribute button. You can think of clicking this button as removing the direct attribute code pair. Some codes are not removed, for example CharUnderlineColor is not removed until the attribute CharUnderline is removed.

The “ParagraphStyleName” button is a special case and it displays the style catalog dialog.

End text portion attribute button

These buttons have a left angle bracket at the left end “<”. Clicking these buttons runs a command to continue that particular attribute for the text portions between it and the next occurrence of that attribute within the paragraph, or the end of the paragraph, whichever comes first. You can think of clicking this button as removing the end of this attribute code pair.

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, with one exception - if you delete all the text in the edit box the text remains unchanged until you type the next character. You cannot, currently, delete a text portion from within this dialog.

Clicking the middle mouse button on an edit box will display the Format Character dialog. (Could someone let me know what the equivalent action for a Mac is, or if there isn’t an equivalent let me know that).

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.
TextField	Displays the “Fields” dialog.
Bookmark	Displays the “Bookmarks” dialog.
DocumentIndexMark	Displays the “Edit Index Entry” dialog
Redline	Displays the “Accpt & 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)	Displays a msgbox asking you to let Ian 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.

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.

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.

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” is 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 “RevealCodes”.

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. Also 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

Example footnote.

Ian Laurenson

2004-06-10T22:48:35