Bug 107095 - FORMATTING: Means to convert direct formatting into styles
Summary: FORMATTING: Means to convert direct formatting into styles
Status: RESOLVED MOVED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Extensions (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsUXEval
Depends on:
Blocks: UNO-Command-New Styles
  Show dependency treegraph
 
Reported: 2017-04-11 15:34 UTC by Thomas Lendo
Modified: 2020-06-30 15:50 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments
Concept of sidebar menu and optional prefix/suffix dialog (43.80 KB, image/png)
2017-04-11 15:34 UTC, Thomas Lendo
Details
Test file with direct paragraph and text formatting (see content.xml) (9.75 KB, text/odt)
2017-04-12 09:14 UTC, Thomas Lendo
Details
File manualy changed as described in the workaround (9.79 KB, application/vnd.oasis.opendocument.text)
2017-04-12 09:36 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Lendo 2017-04-11 15:34:22 UTC
Created attachment 132479 [details]
Concept of sidebar menu and optional prefix/suffix dialog

Because the UI of LibreOffice is enforcing the user to use direct formatting (aka hard formatting) instead of styles, it would be useful to convert all direct formatting in a document with a mouse click into styles.

This is useful for LibO users
* who want solely working with styles and
* who are working with others who don't use styles but direct formatting.

Example request: https://ask.libreoffice.org/en/question/80619/transform-manual-formatting-into-styles/

Conceptual steps:

- User clicks a menu entry or sidebar button named "Convert Formatting" (see attached concept image).
- With that function all formatting information which is not part of an existing style in the document will be saved as new style (paragraph formatting will be saved as paragraph style, word and character formatting as character style, table formatting as table style, etc.).
- Either the style names are completely pre-defined by LibO or the user has a choice for example for a prefix/suffix to style names.
- All direct formatting that was converted to styles should be cleared.
- The new styles will be listed in the appropriate Style and Formatting sidebar panel where the user can work with them like the other styles.

Pre-defined names for the new styles could be "Paragraph style 1" or "Paragraph style red" (if the name is influenced by detected style attributes, e.g. the paragraph font color is red) and "Character style 1" or "Character style red" (if a single word is colored or highlighted red).
Comment 1 m_a_riosv 2017-04-11 22:14:38 UTC
Do you know there is a button to create a new style from selection? The button to the right on 'Styles and formatting'.

Create all at once I think would be a very complicate issue on what to create, paragraphs or character styles, how they should be applied, inheritances. Having a lot of styles without a meaning name to know what it does, to be reapplied. 

Sorry but for me only a way to find a lot of issues.
Comment 2 Thomas Lendo 2017-04-12 09:14:41 UTC
Created attachment 132505 [details]
Test file with direct paragraph and text formatting (see content.xml)

m.a.riosv, thanks, your concerns are valid.

Creating a new style from selection is not a workaround for this bug because you don't know where in the document direct formatted content is lurking. It's not an option for a 50 pages long document.

It's clear that--for such a complex task--the user has to do manual rework after converting. For example, inheritances can't be set automatically, correct. But in my PoV that's not a problem. A user, who is only working with styles, wants to rework the result after converting anyway. From my own experience i can say that uncontrolled growth of direct formatting in a document goes hand in hand with too many formatting variants. With Find & Replace the user can replace "converted styles" with existing styles which makes the whole process of unifying and reworking much easier than today without having all formatting "canalized" in styles. Lot of styles without a meaning name are OK because then the user can edit/reapply/exchange it style after style within this nice styles list in the sidebar.

It shouldn't be impossible to find direct formatting and assign them a (new) style on xml level. In content.xml, direct formatting of paragraphs is assigned with the attributes style:name="Px" and style:family="paragraph". Character formatting has the attributes style:name="Tx" and style:family="text". (Style tags with only internal attributes like officeooo:paragraph-rsid or officeooo:rsid can be ignored.)
Then for example the formatting attribute fo:background-color="#ffff00" in a paragraph style tag can be moved to a new paragraph style tag with the same attribute and a new paragraph style name.
Comment 3 Regina Henschel 2017-04-12 09:36:04 UTC
Created attachment 132508 [details]
File manualy changed as described in the workaround

Hi Thomas, here is a workaround: Open file using 7-Zip. Edit content.xml so that you exchange the tag name office:automatic-style to office:style (in start and end tag as well, but my 'XML Notepad 2007' does that automatically). Save and close editor. Confirm changing in 7-Zip. Close 7-zip. All former hard paragraph and text formatting will now be listed in the UI with there automatic names P1, P2, ... and T1, T2, ... respectively. Do it not in the flat fodt format, because there the page styles are inside the office:automatic-style too, and for page-styles this workaround does not work.
Comment 4 Thomas Lendo 2017-04-13 15:33:04 UTC
Regina, you are wonderful! Seems to be a simple solution but has some disadvantages which should be fixed by a developer.

In my complex test documents this workaround makes visible
* styles for elements with only LibO-internal attributes (like officeooo:paragraph-rsid/officeooo:rsid),
* styles that aren't used in the document anymore (which should be ignored or deleted automatically),
* styles without any attribute (which should be ignored or deleted automatically),
* styles without any practical meaning but were created sometime in the document's lifetime (e.g. <style:style style:name="P15" style:family="paragraph" style:parent-style-name="Text_20_body"><style:text-properties fo:background-color="transparent"/></style:style> which gives transparency to already transparent text paragraph - I think that the text was for example highlighted sometime in the past and LibO hasn't deleted this internal styles - it's an old document anyway),
* character styles for every comment (shouldn't that be a style of its own? maybe there is alredy a bug for it),
* paragraph styles for every index content level (with parent style "Contents 1", "Contents 2", etc. - I don't know for what that's good).
Comment 5 m_a_riosv 2017-04-14 00:38:45 UTC
Perhaps you can be interested in this bug:

https://bugs.documentfoundation.org/show_bug.cgi?id=106556
Comment 6 Thomas Lendo 2017-04-17 18:18:57 UTC
(In reply to m.a.riosv from comment #5)
> Perhaps you can be interested in this bug:
> https://bugs.documentfoundation.org/show_bug.cgi?id=106556
I know this bug and added it as See Also one day before your comment. As described in previous comments, only a marking is not being helpful in case of long documents or nested styles (e.g. lists with list styles, paragraph styles and character styles).
Comment 7 Yousuf Philips (jay) (retired) 2017-05-21 00:57:32 UTC
Definitely would be a useful feature to have and would propose it be in the Styles menu in Writer and Format > Styles menu in Calc, if also implemented there.

Regarding the workflow, i presume some users would prefer to have it automated, while others would prefer to do it step by step so they could name things to their exact liking as well as to ignore changes they dont want to make.
Comment 8 Heiko Tietze 2017-05-21 07:00:48 UTC
Isn't the batch mode for "new style from selection" - to give the request a different name - a perfect example what should go into an extension?
Comment 9 Yousuf Philips (jay) (retired) 2017-05-25 03:08:17 UTC
(In reply to Heiko Tietze from comment #8)
> Isn't the batch mode for "new style from selection" - to give the request a
> different name - a perfect example what should go into an extension?

Definitely could be an extension, but if LO wants to promote the usage of styles, then it has to make it easy for users to convert their direct formatting documents to styles.
Comment 10 Thomas Lendo 2017-06-19 19:41:27 UTC
In the following Google docs document some ideas are written down similar to this bug report: https://docs.google.com/document/d/1onHj7GLNs-x9jMJBRsYaRLv_xsN3UJhP13P690L6ci8

Some cites:

Convert Direct Formatting to Styles - This command would skim through a document for direct formatting combinations and provide an easy means of creating it to a new style or set that particular combination to an existing style.

Style cleaning
The goal is to get a document with zero direct formatting.
    Req1 : the tool crawls the entire document.
    Req2: as soon as a paragraph with direct formatting applied to all the paragraph is found, if the combination existing style (style1) + direct formatting already exists under name style2, then the style of the paragraph is replaced by style2.
    Req3: as soon as a paragraph with direct formatting applied to all the paragraph is found, if the combination existing style (style1) + direct formatting does not exist, the text is selected, ensured visible. A popup is proposed where the user is asked. ...
    Req 4: same as Req 2 for Character styles
    Req 5: same as Req 3 for Character styles
    Req 6: at the end of the crawl, a popup asks what to do with unused styles.
Comment 11 Cor Nouws 2017-08-12 08:44:48 UTC
Hi,

(In reply to Thomas Lendo from comment #0)

> Because the UI of LibreOffice is enforcing the user to use direct formatting

which is not true

> (aka hard formatting) instead of styles, it would be useful to convert all
> direct formatting in a document with a mouse click into styles.

which is questionable. Because direct formatting, applied in larger amounts than just two or three kinds, possibly means that people hardly know what they do. And then suggesting 'meaningful names' for elements that have formatting that may or may not be well thought about, creates a smelly soup.

IMO a slippery path, not to spend time and create even more options in the UI.
Comment 12 Heiko Tietze 2020-06-30 15:28:26 UTC
Repeating my comment 8, let's do it as extension. What's your opinion, Mike?
Comment 13 Mike Kaganski 2020-06-30 15:37:33 UTC
No objections against any extensions. But I highly doubt practical usefulness of this; all concerns in comment 1 are valid; and everything mentioned e.g. in comment 4 (e.g., styles with transparent paragraph background) might turn out to be useful. Also same formatting would become same style, while in practice, it's often that several different styles have the same formatting, and serve as logical tags.

I seriously propose to spend more time instead in a concept of UI that would address the preamble in comment 0:

> Because the UI of LibreOffice is enforcing the user to use direct formatting
> (aka hard formatting) instead of styles

... I want to continue the phrase: "It would be useful to have a Muffin mode that doesn't suffer from this".
Comment 14 Heiko Tietze 2020-06-30 15:40:48 UTC
So up to be implemented by a kind extension developer.