Bug 149978 - ODF import: multiple automatic styles applied via text:span has non-deterministic result
Summary: ODF import: multiple automatic styles applied via text:span has non-determini...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: odf target:7.5.0 target:7.4.0.2 targe...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-13 13:17 UTC by Michael Stahl (allotropia)
Modified: 2022-07-14 21:05 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
minimized reproducer document (6.58 KB, application/vnd.oasis.opendocument.text-flat-xml)
2022-07-13 13:29 UTC, Michael Stahl (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Stahl (allotropia) 2022-07-13 13:17:47 UTC
ODF import of a document containing these automatic styles:

      <style:style style:family="text" style:name="A25" style:parent-style-name="">
        <style:text-properties fo:background-color="#d3d3d3"/>
      </style:style>
      <style:style style:family="text" style:name="A26" style:parent-style-name="">
        <style:text-properties fo:background-color="inherit" fo:color="inherit"/>
      </style:style>

applied like this:

           <text:p>foo <text:span text:style-name="A25"><text:span text:style-name="A26">bar</text:span></text:span> baz</text:p>

first, the value "inherit" is invalid and doesn't exist in ODF, but if we use a real color it would be the same problem.

on ODF import, the 2 nested applied automatic styles are handled properly in xmloff as XMLStyleHint_Impl, but inserting into Writer may order them in any order depending on random chance, so the color that's visible may be from any applied style.

this is due to an optimization in SwpHints::TryInsertHint().

LO doesn't write files like this, but probably it should be able to import them deterministically.

weirdly, i can never reproduce the bug the 1st time i load the bugdoc, but from the 2nd time the problem happens randomly.

reproduced in OOo 3.3 so ancient bug.
Comment 1 Michael Stahl (allotropia) 2022-07-13 13:29:31 UTC
Created attachment 181254 [details]
minimized reproducer document
Comment 2 Commit Notification 2022-07-14 11:51:23 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d7827f712ddd21a6c1e151f54dc6eba5c12690da

tdf#149978 sw: ODF import: fix nondeterministic automatic styles

It will be available in 7.5.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 3 Michael Stahl (allotropia) 2022-07-14 11:54:35 UTC
fixed on master
Comment 4 Commit Notification 2022-07-14 21:05:01 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/589111d34eb333196490f0bae2e3542a5e6bc13d

tdf#149978 sw: ODF import: fix nondeterministic automatic styles

It will be available in 7.4.0.2.

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 5 Commit Notification 2022-07-14 21:05:16 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/7a8f2c7e3a16dae6bdc891fb969e673527e45615

tdf#149978 sw: ODF import: fix nondeterministic automatic styles

It will be available in 7.3.6.

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.