Bug 96147 - ODF export: CharHighlight property causes duplicate fo:background-color attributes on text/paragraph styles
Summary: ODF export: CharHighlight property causes duplicate fo:background-color attri...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.0.0.5 release
Hardware: All Windows (All)
: highest critical
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: odf target:5.2.0 target:5.0.5 target:...
Keywords: dataLoss, regression
: 96323 97360 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-30 03:02 UTC by dstrzele
Modified: 2016-10-25 19:03 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
odt file (1.33 MB, application/vnd.oasis.opendocument.text)
2015-12-03 22:03 UTC, dstrzele
Details
Document template and macro (21.71 KB, application/zip)
2015-12-10 21:44 UTC, Paolo Meozzi
Details
previously saved document (1.67 MB, application/zip)
2015-12-21 22:39 UTC, dstrzele
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dstrzele 2015-11-30 03:02:40 UTC
Read-Error.
Format error discovered in the file in sub-document content.xml at 2,168126(row,col).
Comment 1 tommy27 2015-11-30 11:30:08 UTC
please upload test file
then tell your LibO version and O/S

status NEEDINFO
revert it to UNCONFIRMED when you answer these questions
Comment 2 dstrzele 2015-12-03 22:03:38 UTC
Created attachment 121001 [details]
odt file
Comment 3 Maxim Monastirsky 2015-12-08 09:23:11 UTC
*** Bug 96323 has been marked as a duplicate of this bug. ***
Comment 4 Maxim Monastirsky 2015-12-08 09:29:05 UTC
dstrzele/Paolo: Any chance of getting a version of the document one step before the corruption happens, so we can reproduce the buggy saving? This will help us a lot in fixing this. Thanks.
Comment 5 Paolo Meozzi 2015-12-08 17:31:51 UTC
Maxim Monastirsky, i'm sorry, but I have no chance: the bug occurs randomly. Today I changed the document three times: twice it went well, once was corrupt.

I suspect that my document has problems, because the frequency with which it is corrupt is unacceptable.
(With Writer: Version 3 <-> 4 I never had problems)
Comment 6 Maxim Monastirsky 2015-12-09 12:01:02 UTC
(In reply to Paolo Meozzi from comment #5)
> i'm sorry, but I have no chance: the bug occurs randomly.
That's unfortunate. Adding Michael to CC. Maybe he has an idea why is this duplicate fo:background-color="transparent" added to styles.
Comment 7 Paolo Meozzi 2015-12-10 21:44:59 UTC
Created attachment 121213 [details]
Document template and macro
Comment 8 Paolo Meozzi 2015-12-10 21:45:47 UTC
I found a pattern! But I do not know how useful.
The problem happens when I paste code fragment from Visual Studio (2013), but only when using a particular document template.
Since version 4.x (I think), the pasted code from VS maintains the white background and thus change the background that I have assigned to the style "code" in my documents.
For this reason I created a macro that applies the style and sets the background transparent the selected text.
Everything works fine except in one case:
1) I paste a snippet of code from VS (OK)
2) applying macro (OK)
3) paste the new fragment of VS within the code already formatted. (OK)
4) apply the macro again (only) to the fragment just pasted (oh oh!)
Save to disk ... and the document is corrupt: the background is set twice, transparent and white.

I added the document templates and macros that format text.
Comment 9 Maxim Monastirsky 2015-12-10 23:58:01 UTC
(In reply to Paolo Meozzi from comment #8)
> I found a pattern! But I do not know how useful.
Very useful! I reproduced exactly with your steps (but with VS 2015).

Version: 5.2.0.0.alpha0+
Build ID: 6fd3f3caad1a559165dc9332249cbd0d84930775
Threads 1; Ver: Windows 6.1; Render: default; 

TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2015-12-08_23:31:11
Comment 10 dstrzele 2015-12-21 22:39:33 UTC
Created attachment 121484 [details]
previously saved document

Does this help?
Comment 11 Maxim Monastirsky 2016-01-25 12:30:24 UTC
*** Bug 97360 has been marked as a duplicate of this bug. ***
Comment 12 Maxim Monastirsky 2016-01-25 13:35:58 UTC Comment hidden (obsolete)
Comment 13 Michael Stahl (allotropia) 2016-02-01 22:25:49 UTC
i can't reproduce the problem... but i'm highly suspicious of this commit:


commit f880962f5bf26bfaef06bd3f9e67e2d901a2e74c
Author:     Zolnai Tamás <zolnaitamas2000@gmail.com>
AuthorDate: Wed Mar 18 10:25:05 2015 +0100

    Char highlight: ODT filters
    
    Export merges the two background attribute.


... which adds another property that exports to the offending fo:background-color attribute, and was added in LO 5.0... that's
just too much of a coincidence...


... alright this reproduces the problem from scratch:

Sub Main

c = ThisComponent.Text.createTextCursor()

c.setString("foo bar baz")

c.goRight(4, false)
c.goRight(3, true)

msgbox(c.getString())

c.CharBackColor = 0
c.CharHighlight = 0
c.CharBackTransparent = 1

End Sub
Comment 14 Michael Stahl (allotropia) 2016-02-02 14:02:19 UTC
fixed on master
Comment 15 Commit Notification 2016-02-02 14:04:04 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8dadefc35f8b33648fb6adbdaca75ea52b2705db

xmloff: tdf#96147: ODF export: fix duplicate fo:background-color

It will be available in 5.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 16 Commit Notification 2016-02-02 15:20:59 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e92dcab1407fa26fc5ee68d0b626b87bc04f1b3b&h=libreoffice-5-0

xmloff: tdf#96147: ODF export: fix duplicate fo:background-color

It will be available in 5.0.6.

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

Affected users are encouraged to test the fix and report feedback.
Comment 17 Commit Notification 2016-02-02 23:28:06 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-0-5":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=89aa74dd903a7919b33982bc2efc74c8ec902fdc&h=libreoffice-5-0-5

xmloff: tdf#96147: ODF export: fix duplicate fo:background-color

It will be available in 5.0.5.

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

Affected users are encouraged to test the fix and report feedback.
Comment 18 Commit Notification 2016-02-05 15:34:28 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e2383402d4cab93f4003e03912700a00525b7d4c&h=libreoffice-5-1

xmloff: tdf#96147: ODF export: fix duplicate fo:background-color

It will be available in 5.1.1.

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

Affected users are encouraged to test the fix and report feedback.