Bug 140616 - FILEOPEN DOCX: paragraph style ignores rPr nested inside pPr (hand-crafted document) and fails to override with para marker highlight
Summary: FILEOPEN DOCX: paragraph style ignores rPr nested inside pPr (hand-crafted do...
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: Justin L
URL:
Whiteboard: needs Word 2010+ target:24.8.0
Keywords: filter:docx
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2021-02-23 09:38 UTC by Justin L
Modified: 2024-04-19 22:39 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
num3f.docx: Last line should be green, size 16 font - except the numbering symbol. (9.74 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-02-23 09:38 UTC, Justin L
Details
num3f.pdf: how it looks in Word 2016 (and 2003). (76.21 KB, application/pdf)
2021-02-23 09:41 UTC, Justin L
Details
num3b.docx: the text should be in 32 pt font (from paragraph style) (11.14 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-03-28 18:50 UTC, Justin L
Details
num3g.docx: style's w:highlight properly defined in stand-alone rPr (9.83 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-04-17 22:48 UTC, Justin L
Details
num3m.docx: green highlight comes from paragraph style - word/style.xml (9.63 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-04-19 11:49 UTC, Justin L
Details
num3n.docx - yellow highlight comes from numbering.xml - overrides everything else (9.66 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-04-19 11:53 UTC, Justin L
Details
num3o.docx - no highlight comes from document.xml <pPr><rPr> - cancelling green style (9.64 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-04-19 11:55 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2021-02-23 09:38:46 UTC
Created attachment 169989 [details]
num3f.docx: Last line should be green, size 16 font - except the numbering symbol.

In the priority of applying attributes, it appears that it should be
least: direct paragraph-character properties (default run properties)
       paragraph style character properties
       char style character properties
greatest: direct char properties

This can be seen in the last paragraph of the example document.  The green and fontsize 16 from the paragraph style should override the default character run properties of no-colour and fontsize 24.

In LO, the size and highlight are taken from  the default run properties instead of the paragraph style.

This was true as far back as I could bibisect - 3.5. Assuming Inherited from OOo.

Note that the order LO handles these properties seems to be correct as far as numbering is concerned, since the bullet point is size 24 with no background. That really complicates things...
Comment 1 Justin L 2021-02-23 09:41:57 UTC
Created attachment 169990 [details]
num3f.pdf: how it looks in Word 2016 (and 2003).
Comment 2 Dieter 2021-09-11 04:24:58 UTC
I confirm it with

Version: 7.2.1.1 (x64) / LibreOffice Community
Build ID: 3cfc32d9754d2d239bd8ce2941029c12873010c1
CPU threads: 4; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: CL
Comment 3 Justin L 2023-05-12 00:19:42 UTC
repro 7.6+
Comment 4 Justin L 2024-03-28 18:50:08 UTC
Created attachment 193375 [details]
num3b.docx: the text should be in 32 pt font (from paragraph style)

(In reply to Justin L from comment #0)
> In the priority of applying attributes, it appears that it should be
> least: direct paragraph-character properties (default run properties)
Actually, the paragraph's default character properties are NEVER applied to any runs - only to the list numbering.

> This can be seen in the last paragraph of the example document.  The green
> and fontsize 16 from the paragraph style should override the default
> character run properties of no-colour and fontsize 24.
Actually, it seems like the paragraph styles' character properties are not being applied at all. They are NOT being overridden by the pPr/rPr.

The problem is simply that the highlight (and size) are not imported into the paragraph style.

OK - this is ridiculous. How can we possibly have this super basic functionality missing?
Comment 5 Justin L 2024-04-17 20:38:13 UTC
(In reply to Justin L from comment #4)
> OK - this is ridiculous. How can we possibly have this super basic
> functionality missing?
That's because this is not at all normal - it was due to a hand-crafted change.
Styles should not nest the rPr underneath pPr.

However, obviously MSO can parse and handle that, so import the character properties into the style with https://gerrit.libreoffice.org/c/core/+/166189
Comment 6 Justin L 2024-04-17 22:48:02 UTC
Created attachment 193738 [details]
num3g.docx: style's w:highlight properly defined in stand-alone rPr

The last bullet point should NOT be highlighted. It already started to become highlighted in 4.2 (probably because the whole paragraph was highlighted).

It stopped highlighting the bullet with
4.4 commit b5e60724ac73bb0e62b249145a8931fd6166bb69
Author: Zolnai Tamás on Mon Aug 4 10:57:08 2014 +0200
    tdf#80986: disable highlight DOCX import


Somewhere in 5.0 it started to become highlighted again,
with commit 8f01925d98dabdbf400c9263e08242267b2b9701
Author: Zolnai Tamás on Sat Mar 21 16:19:07 2015 +0100
    Char highlight: enable DOCX import
Comment 7 Justin L 2024-04-19 11:49:16 UTC
Created attachment 193751 [details]
num3m.docx: green highlight comes from paragraph style - word/style.xml
Comment 8 Justin L 2024-04-19 11:53:26 UTC
Created attachment 193752 [details]
num3n.docx - yellow highlight comes from numbering.xml - overrides everything else

This file shows that the paragraph marker's highlight="none" has lower priority than the numbering.xml's yellow highlight.

[In this case, pFormat->hasItem(RES_CHRATR_HIGHLIGHT), so the marker's highlight is removed from pClearedSet.]
Comment 9 Justin L 2024-04-19 11:55:22 UTC
Created attachment 193753 [details]
num3o.docx - no highlight comes from document.xml <pPr><rPr> - cancelling green style
Comment 10 Commit Notification 2024-04-19 12:21:18 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4a120f4f557b99bb8371474a4e7fdaf52b148143

tdf#140616 writerfilter: recognize style rPr under pPr

It will be available in 24.8.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 11 Justin L 2024-04-19 13:09:51 UTC
(In reply to Commit Notification from comment #10)
> tdf#140616 writerfilter: recognize style rPr under pPr
This resolves comment 5
"paragraph style ignores rPr nested inside pPr (hand-crafted document) "
Comment 12 Commit Notification 2024-04-19 22:19:20 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3b7ffa204c6d04640b5e2f4d4c6b6b4a03fd26c8

tdf#140616 ApplyParagraphMarkFormatToNumbering: including highlight

It will be available in 24.8.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 13 Justin L 2024-04-19 22:39:31 UTC
(In reply to Commit Notification from comment #12)
> tdf#140616 ApplyParagraphMarkFormatToNumbering: including highlight
This patch fixes "and fails to override with para marker highlight"

It worked earlier if there was no highlight in the style, but only in the marker (because then highlight == COL_TRANSPARENT). Now the marker will override any inherited-from-styles highlighting.