Wish: purge unused styles

I would like the abilty to purge unused style.

@jorendc – perhaps you can help out here?

You can use the macro posted here to accomplish this

thank you: that’s precious in writer but deleted my personal-used-styles in presenter

Well, I can’t post an answer, because the the thread is locked, so I will just comment here. I just thought of another way, if you don’t want to use the macro above.

  1. Select the whole document.
  2. Copy and paste into a new blank document.
  3. Now you have a document with only default styles and the styles you are actually using. (But the default styles will not match any customization that was done to them in the original document, and you will have no macros, etc.)
  4. Delete all the text in the original document, then display custom styles and delete them all. Keep any ones you know you will use later.
  5. Now paste all the text from the temp document back to the original. Done.

I am sure there will be some issues in certain complex documents. I know for one thing, if you have any locked content it will complain if you try to delete it or paste over it.

Currently there is no build in feature to delete unused styles at once. I was investigating to solve fdo#46719 (to add an “unused styles” filter), but I think I need to unassign me from this task due my lack of development skills.

So current status: not yet implemented.

Careful here. I also wish one could easily delete all unused custom styles at once in a document. However, here is an important distinction to make if this feature is implemented:

  • Allowing one to delete unused custom styles is generally benign and beneficial, but in many cases a lack of applied styles should ring a bell: it often means that the template on which the document was based was not correctly used (i.e. the stylistic resources were underused) and in such cases structure always suffers. The conclusion is that the application should, before purging all unused custom styles, remind the user that they should apply the following:

    • Heading styles that correspond to the ones selected as part of the document’s outline numbering;
    • Paragraph styles (distinct from heading styles in the ODF format) that semantically distinguish key parts of the document such as long quotations, asides and examples;
    • Character styles that semantically denote the status or meaning of key terms (e.g. emphasis, a term in a foreign language, an idiomatic expression, a title, the name of an author or institution etc.) and visually distinguish hyperlinks, fields and ruby annotations.
  • As for the unused default styles, the application should never allow one to delete them, because they all have a purpose and are all potentially important. For example, a subset of those default styles are used to preserve the structure of HTML documents. Furthermore, some OpenDocument Text elements, such as ruby annotations, can only be created by applying a ruby character style, even though ruby annotations are not character styles per se. Finally, the default styles are the backbone of LibreOffice’s (and OpenDocument’s) style inheritance model, a powerful system which has no direct equivalent in Microsoft Office (this is one big advantage that ODF and LibreOffice have over MS Office) In fact, this inheritance model as specified in ODF and as implemented in LibreOffice is very similar to CSS’s, and that is A Good Thing™.

In conclusion, styles in a document are always potentially a precious resource and should not be seen as pollution, even though they take up space in the style list.

Reading @CyanCG’s excellent answer gave me the idea to ask for a feature enahcnement that LibO should have filters

  • show only used styles

  • show only unused custom styles

By doing so the styles which cannot be deleted (= not customized styles) and are not used can be hidden but made visible when needed.

When importing Word files, I observe that always a long list of unused styles appear in the styles window, but only very little of these styles are used. All imported styles are customized styles, thus can be deleted However to identify which of them are used or unused is a time consuming task. Thus, being able to see only unused custom styles (they include the unused imported styles) and have the functionality to delete the unused custom styles

  • one by one

  • or as selected groups

  • or all at once

would be a very good feature. (More or less like deleting files and folders in windows)

Before I post an enhancement request, I would like to see what opinions others have and look forward to answers.

I think you’ve nailed it: I had Word documents in mind when I posted my answer, and what you describe is exactly what LibO needs in my opinion. This would e.g. allow a LibO user who is collaborating with a Word user on a document to evaluate the use of styles and their significance and account for the Word user’s intentions with respect to structure and formatting.

@CanCG - Thanks for your comment. I will wait af ew days more to allow for more comments and will then file an enhancement request.

that’s the idea, sorry I’m late

@unichan - I did not file a separate enhancement request but added a comment to the the bug fdo#46719 kindly introduce in the threat by @jorendc

Hope there will be a dev who can tackle this topic.