Transform manual formatting into styles

It happens frequently that someone who does not know how to use styles, writes a long document using solely manual formatting.

Is there a way to “scan” the document for similarly formatted text and create styles and assign style automatically to the different parts of the document?

It might be possible to write a macro, but it would not be easy. You would need to check the format of each character, paragraph, format, etc to see its style setting and then check all manual settings of that character against that style. Some of the attributes of the style are also structures or objects and its not easy to enumerate the individual properties within those.

I did write a macro to create a calc list of all styles within a document, but shows only the object or structure type if an attribute of the style is not a basic type. It might offer a starting point or at least some indication of the issues you might face.

ListDocStyles.ods

You might also find it helpful to read the answer by @ajlittoz to a previous question problems-with-styles as he gives some very helpfull advice on how to use styles.

One way, not completely automatic, is as follows: go through the document, click in a paragraph intended as a heading, note the formatting details, then open the Find/Replace dialog box (Ctrl+H), tick Other options, click Format, enter some of the formatting details of that paragraph, click Find all, close the dialog box. All text with that formatting will now be selected. Press Ctrl+M to remove all direct formatting from the selection(1), then apply the paragraph style that you want to use for those headings. Now move to the next heading paragraph not yet dealt with and repeat that procedure. Finally deal with the body text. It’s a good idea to set a font for the styles that isn’t yet used in the document while you are cleaning it up, so that any remaining text with direct formatting will be easily noticed.

I doubt that writing a macro is worth the effort - development and debugging takes a lot of time.

(1) Don’t use Ctrl+M for large blocks of text if there’s also formatting like italics or boldface of single words, because that will be lost. You can replace such formatting by character styles though - search for text in italics, then apply a character style, maybe you should make one called italics just for that purpose. Once that’s done, you can safely remove direct formatting.

I think that the solution to your initial concern (disciplining contributors) goes through the release of some “writer’s guidelines”, kind of style catalog explaining their intended usage. It is analogous to a quality manual.

Many company have a “graphical chart” which also includes recommendations for letters, documents, … Ideally, this chart should provide styles sheets or document templates to enforce it.

However, the difficulty lies is the lack of user training about styles. In LO, though, it is easy to use them: display the style pane (F11) and just double-click on the desired one. A half-page notice is sufficient to guide a newbee.

If you like to have an example of what I call a “writer’s guidelines” document, I can send one used in a project I participate in through private mail.

Disciplining contributors is very hard work, even when the contributors are paid for their work. People hate reading writing guidelines. And honestly, they should focus on content, not on formatting. So the less formatting they add, the better. Unfortunately, with so many formatting tools in word processors, everybody feels and thinks they are graphical designers.

I agree with you, that’s the hardest work. A “good” (how can we objectively define this term?) writer’s guide helps focus on content by providing strong directives on “semantic markup” instead of “formatting markup”. This is where a switch in mind is needed: authors write about significance while graphical designers develop nice-looking styles which should translate and highlight authors’ intent, not the other way round.

Unfortunately, it is very tempting to skid from meaning to appearance.