Bug 47471 - Clear Direct Formatting damages the document's styles
Summary: Clear Direct Formatting damages the document's styles
Status: RESOLVED DUPLICATE of bug 73483
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: high major
Assignee: Justin L
URL:
Whiteboard: target:6.3.0
Keywords:
Depends on:
Blocks: Clear-Formatting Writer-Styles ODF-export-invalid Formatting-Text-Diverse
  Show dependency treegraph
 
Reported: 2012-03-18 01:33 UTC by jmkopy
Modified: 2023-05-31 06:39 UTC (History)
17 users (show)

See Also:
Crash report or crash signature:


Attachments
File with distorted styles (20.08 KB, application/vnd.oasis.opendocument.text)
2012-03-18 01:33 UTC, jmkopy
Details
File before distorting styles (20.23 KB, application/vnd.oasis.opendocument.text)
2012-03-18 01:35 UTC, jmkopy
Details
Another file before styles are distorted (63.67 KB, application/vnd.oasis.opendocument.text)
2012-03-25 12:05 UTC, jmkopy
Details
Another file after styles are distorted (63.17 KB, application/vnd.oasis.opendocument.text)
2012-03-25 12:07 UTC, jmkopy
Details
Another file after style is distorted for one paragraph (63.65 KB, application/vnd.oasis.opendocument.text)
2012-03-25 12:12 UTC, jmkopy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jmkopy 2012-03-18 01:33:53 UTC
Created attachment 58634 [details]
File with distorted styles

I assign a style to a paragraph, mark the paragraph and apply "Ctrl + M" (thus clearing direct formatting) and save the file. After opening the file all styles have been substituted by the "Default" style.
See the attached files.
Comment 1 jmkopy 2012-03-18 01:35:50 UTC
Created attachment 58635 [details]
File before distorting styles
Comment 2 Rainer Bielefeld Retired 2012-03-18 22:47:43 UTC
I can't reproduce the problem, but the report is much to rare.

@jmkopy@gmx.net
Please contribute a precise step by step instruction containing every mouse click and every key press.
Comment 3 m_a_riosv 2012-03-19 16:28:53 UTC
ONLY with this file I can reproduce on LibreOffice 3.5.1 and OOo-dev 3.4.

Two confident folks from OOo.org forum have tried with equals results. Only with this file have found the problem.
Comment 4 Christopher Yeleighton 2012-03-24 11:24:46 UTC
Does the bug occur when your document has only one paragraph?
Comment 5 jmkopy 2012-03-25 12:03:58 UTC
I have to describe exactly how it happens:
I mark the whole document:
Ctrl + A (one paragraph marked)
Ctrl + A (all paragraphs marked, or the whole document for that matter)
Ctrl + M (clearing direct formatting)
Saving the document
Closing the document
Opening the document --> All assigned styles are removed.

When I do mark only one paragraph and apply the steps mentioned above then the same happens only for the tackled paragraph.
See the new attached files.
Comment 6 jmkopy 2012-03-25 12:05:50 UTC
Created attachment 59015 [details]
Another file before styles are distorted
Comment 7 jmkopy 2012-03-25 12:07:17 UTC
Created attachment 59016 [details]
Another file after styles are distorted
Comment 8 jmkopy 2012-03-25 12:12:13 UTC
Created attachment 59017 [details]
Another file after style is distorted for one paragraph
Comment 9 jmkopy 2012-03-25 12:31:26 UTC
(In reply to comment #4)
> Does the bug occur when your document has only one paragraph?

I tried it, the bug does occur once. When I assign a style again and repeat the steps mentioned above the styles are retained. The same is true for many paragraphs document. 
Actually it is true also for the attached documents above. Well, it looks that after a second "round" of assigning the styles the problem is almost gone. 
Having a long document it is a "nice" job to reassign the styles again. Having many documents it is even "nicer" so.
I tried it again, with one of the above files. And some styles are persistently being removed and some remain. Hmmm? Even after reassigning the the styles many times.
Comment 10 sasha.libreoffice 2012-08-20 09:14:13 UTC
I saved 3-th attachment as fodt and viewed as text. 
And found there this line:
<style:style style:name="_5f_Heading_5f_00" style:display-name="_Heading_00"
It means that style's internal name is different from name we see. I can not produce such style by my own. IMHO LibreOffice can not deal with such styles correctly.
How to produced this document? May be from template that already has such corruption. Or by opening file, created by another program? Or copy-pasting.
Comment 11 Joel Madero 2013-05-28 15:37:52 UTC Comment hidden (obsolete)
Comment 12 sasha.libreoffice 2013-05-29 11:12:05 UTC
reproduced in 4.0.3 on Fedora (RFR) 64 bit 
using 3-th attachment (Another_file_before_distorting_styles.odt) and steps from comment 5
Comment 13 Robert Großkopf 2014-01-09 16:56:31 UTC
Could it be this bug is the same as https://bugs.freedesktop.org/show_bug.cgi?id=73411 ?
Haven't found this bug before, but the loosing of styles has something to do with numbering and bullet, so I searched for bullets and found nothing.
Comment 14 sasha.libreoffice 2014-01-10 07:41:33 UTC
IMHO bug is the same
I just tried my idea from comment 10 on attachment from Bug 73411. I saved it as fodt format and manually removed style:display-name . But it not helps. Bug still reproducible. Therefore style:display-name is not a source of problem.
Comment 15 Fiable.biz 2014-09-26 10:55:22 UTC
See also bug #61956, which might be a duplicate of this one.
Comment 16 QA Administrators 2015-10-14 19:57:54 UTC Comment hidden (obsolete)
Comment 17 Buovjaga 2015-11-15 15:37:50 UTC
*** Bug 95752 has been marked as a duplicate of this bug. ***
Comment 18 QA Administrators 2017-01-03 19:36:47 UTC Comment hidden (obsolete)
Comment 19 Thomas Lendo 2017-04-25 11:53:10 UTC
I can reproduce this bug with attachment 59017 [details] and with my own test file.

Version: 5.3.2.2
Build ID: 6cd4f1ef626f15116896b1d8e1398b56da0d0ee1
CPU Threads: 8; OS Version: Windows 6.2; UI Render: default; Layout Engine: new; 
Locale: de-DE (de_DE); Calc: CL

Steps to reproduce:
1. Create a Writer file.
2. Write some text.
3. Apply a paragraph style to the whole text (different than "Default style", e.g. Ctrl + A and select "Text Body").
4. Select some text and do some direct PARAGRAPH formatting (e.g. open context menu "Paragraph..." > Area > Color > select red color > OK -- applying a yellow highlight color from the toolbar is not enough).
5. Select all text with Ctrl + A.
6. Type Ctrl + M.
7. Save the file.
8. Open the file again.

Actual result:
The text which was changed with direct formatting is assigned to "Default style".

Expected result:
Styles shouldn't change.

My assumption:

When changing text with direct formatting, LibO creates a new style in the content.xml (P1, P2, etc for paragraphs; T1, T2, etc. for character styles). This new style includes the direct formatting (e.g. background color) and a link to the parent style.
When activating the "Clear Direct Formatting" command, LibO deletes the direct formatting. But LibO doesn't delete the new style (e.g. P1) completely AND doesn't assign the original parent style to the text.

Example of content.xml before doing Clear Direct Formatting:

<office:automatic-styles>
 <style:style style:name="P1" style:parent-style-name="Endnote" style:family="paragraph">
  <loext:graphic-properties draw:fill-color="#ff0000" draw:fill="solid"/>
  <style:paragraph-properties style:writing-mode="page" fo:background-color="#ff0000"/>
 </style:style>
</office:automatic-styles>

<office:body>
 <office:text>
  <text:p text:style-name="Endnote">Ich bin ein Text.</text:p>
  <text:p text:style-name="P1">Ich bin ein Text.</text:p>
  <text:p text:style-name="Endnote">Ich bin ein Text.</text:p>
 </office:text>
</office:body>

Example of content.xml after doing Clear Direct Formatting:

<office:automatic-styles>
 <style:style style:name="P1" style:family="paragraph">
  <loext:graphic-properties draw:fill-color="#ff0000" draw:fill="solid"/>
  <style:paragraph-properties style:writing-mode="page" fo:background-color="#ff0000"/>
 </style:style>
</office:automatic-styles>

<office:body>
 <office:text>
  <text:p text:style-name="Endnote">Ich bin ein Text.</text:p>
  <text:p>Ich bin ein Text.</text:p>
  <text:p text:style-name="Endnote">Ich bin ein Text.</text:p>
 </office:text>
</office:body>

Suggestion:

When activating the "Clear Direct Formatting" command, LibO should assign the parent style to the paragraph (in the example above: text:style-name="Endnote" instead of text:style-name="P1") and then LibO should delete P1 as much as it includes direct formatting.
Comment 20 Yousuf Philips (jay) (retired) 2017-05-30 17:05:25 UTC
So this is a regression introduce in 3.5 as not present in 3.4. Lets see if it can be bibisected.
Comment 21 Regina Henschel 2017-05-30 18:46:29 UTC
(In reply to Yousuf Philips (jay) from comment #20)
> So this is a regression introduce in 3.5 as not present in 3.4. Lets see if
> it can be bibisected.

I do not get such results.

The last good version for me is Version: 4.4.0.0.alpha0+
Build ID: aa453de65b8b44f9c1e6012caaeef11df9ff65fc
TinderBox: Win-x86@39, Branch:master, Time: 2014-05-24_13:45:34

The first bad version is Version: 4.4.0.0.alpha0+
Build ID: 86a3fe47a66950e26d23d7d7f2680fa7d4fb0839
TinderBox: Win-x86@39, Branch:master, Time: 2014-10-05_02:45:20

I haven't got versions between to test.
Comment 22 Yousuf Philips (jay) (retired) 2017-05-30 21:11:14 UTC
(In reply to Regina Henschel from comment #21)
> I do not get such results.

Not sure how i got those results as well.

> The last good version for me is Version: 4.4.0.0.alpha0+
> Build ID: aa453de65b8b44f9c1e6012caaeef11df9ff65fc
> TinderBox: Win-x86@39, Branch:master, Time: 2014-05-24_13:45:34
> 
> The first bad version is Version: 4.4.0.0.alpha0+
> Build ID: 86a3fe47a66950e26d23d7d7f2680fa7d4fb0839
> TinderBox: Win-x86@39, Branch:master, Time: 2014-10-05_02:45:20
> 
> I haven't got versions between to test.

If this is where the regression happened, then it must be like the bug i just filed, bug 108248.
Comment 23 Regina Henschel 2017-05-30 22:32:19 UTC
I think, it is the same.
Comment 24 Buovjaga 2018-05-25 12:45:12 UTC
With attachment 58635 [details], the losing of styles happens already with LibreOffice 3.3.0.
Same with attachment 59017 [details]

Even bug 73411 which is said to be a dupe of this is "Inherited".

Arch Linux 64-bit
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 25 Buovjaga 2018-10-15 14:35:38 UTC
*** Bug 104988 has been marked as a duplicate of this bug. ***
Comment 26 Thomas Lendo 2018-10-15 18:14:34 UTC
*** Bug 111002 has been marked as a duplicate of this bug. ***
Comment 27 Thomas Lendo 2018-10-15 18:19:31 UTC
For more examples and steps to reproduce see the other issues bug 111002 and bug
104988.
Comment 28 Timur Davletshin 2018-11-07 06:34:50 UTC
Reproducible in recent 6.2.0.0.alpha1 build.
Comment 29 Commit Notification 2018-12-27 05:15:51 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/7934d9085eeaf5903fee494195ed2d0c6fb74fbb%5E%21

related tdf#47471 textframe: use stylename if autostyle missing

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 30 Justin L 2018-12-27 05:23:57 UTC
easy fix proposed at https://gerrit.libreoffice.org/65616.

A couple of related areas will have the same fix applied. Those will land earlier than the main fix because the unit test verification document is shared with bug 99573.
Comment 31 Commit Notification 2018-12-28 05:43:52 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/fa1354861fffa69da2a1d1613f979f2f26242d24%5E%21

related tdf#47471 textgraphic: use stylename if autostyle missing

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 32 Commit Notification 2018-12-29 04:11:57 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/43836a58ffe943e2fc65be638f9a7d343102cb07%5E%21

tdf#47471 odfexport: use stylename if autostyle missing.

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 33 BogdanB 2019-01-02 14:30:28 UTC
Solved. 

Verified on
Version: 6.3.0.0.alpha0+
Build ID: be8897d9c63a77b223a9c0aed1d2eb689e0e0082
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2019-01-02_04:49:04
Locale: ro-RO (ro_RO.UTF-8); UI-Language: en-US
Calc: threaded
Comment 34 Timur 2019-01-03 08:43:38 UTC
*** Bug 73411 has been marked as a duplicate of this bug. ***
Comment 35 Thomas Lendo 2019-03-28 11:53:39 UTC
Thank you very, very much, Justin Luth, for fixing this!
Comment 36 NISZ LibreOffice Team 2020-11-25 14:03:05 UTC
*** Bug 92352 has been marked as a duplicate of this bug. ***
Comment 37 Mike Kaganski 2023-05-31 06:28:23 UTC

*** This bug has been marked as a duplicate of bug 73483 ***