Created attachment 160748 [details]
Example file from Word
Attached artificial document (improved version of attachment #147857 [details] from bug #122342) has a few numbered paragraphs formatted with custom style and sublevels.
If the paragraphs are in a list of multiple items, the sublevel paragraphs lose their indent. If they are in a single item list, the sublevel paragraphs appear fine.
Steps to reproduce:
1. Open attached document
Sublevel paragraphs from multiple item lists are not indented from left as in Word.
Same appearance as in Word.
Version: 22.214.171.124.alpha1+ (x64)
Build ID: f9790da286f2d2fa47f1748f8cfa6172c6622ca3
CPU szálak: 4; OS: Windows 6.3 Build 9600; Felületmegjelenítés: Skia/Raster; VCL: win;
Locale: hu-HU (hu_HU); UI: hu-HU
Bibisected using bibisect-win64-6.5 to:
author Justin Luth <firstname.lastname@example.org> 2020-04-11 12:05:03 +0300
committer Miklos Vajna <email@example.com> 2020-04-14 09:46:52 +0200
tdf#131321 writerfilter: ApplyNumberingStyleNameToParaStyles()
Adding CC to: Justin Luth
Created attachment 160749 [details]
Screenshot of the original document side by side in Word and Writer
Build ID: 1ffe59ef31186e36ad0aa7bbcdd32e407ee8d26c
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3;
Locale: en-US (en_US.UTF-8); UI: en-US
Adding Cc to: Miklos Vajna
Notice that it is only indenting that is wrong - the numbering itself is correct (as described in Comment 0, but I just want to emphasize that). Also, this only affects WWNum1, and if those lines are selected, changed to WWNum2, and then back to WWNum1, then the indenting is correct. So the problem is somewhere with direct formatting.
My patch had nothing to do with indenting, so this must have exposed some other problem. (Oh great.) Prior to my patch, CustomStyle had no idea that it was specifying a numbering. Now it shows that it is connected to WWNum1, and applies the numbering to new paragraphs that are marked as CustomStyle - like it should.
It looks like the Style's indenting is being (dynamically - as a style) applied INSTEAD OF the numbering's indenting on the sublevels. In other words, the sublevels must not be splattering direct formatting onto the paragraph itself like they normally do.
<w:style w:type="paragraph" w:customStyle="1" w:styleId="CustomStyle">
<w:ind w:left="714" w:hanging="357"/>
Adding Vasily to CC, since he has recently done lots of work here, and should at least be aware of other work happening in numbering.
I'm am guessing that RES_PARATR_NUMRULES is being swallowed up because the paragraph style specifies the same list - so the direct formatting is lost. [Turn off numbering style in CustomStyle paragraph style - the sublevels (which had direct list formatting) are no longer numbered, but the first level (which inherited from the style) are still numbered. Go figure.]
There is something funny about the way that the numbering is applied, because if you simply remove and re-add WWNum1 to CustomStyle numbering, then it looks fine.
The problem does NOT seem to be with direct formatting of indenting, because changing the indenting of CustomStyle affects the indenting of the sublevels - indicating that they are inheriting. So for some reason, the paragraph style overrides the numbering formatting, even though Writer supposedly prioritizes the list-style over the para-style. [probably because the list-style itself is not actually applied, just one specific numbering?]
This "hack" fixes the problem for this specific document.
if( !IsStyleSheetImport() )
uno::Any aRules = uno::makeAny( pList->GetNumberingRules( ) );
rContext->Insert( PROP_NUMBERING_RULES, aRules );
+ rContext->Insert( PROP_NUMBERING_STYLE_NAME, pList->GetStyleName());
proposed fix at https://gerrit.libreoffice.org/c/core/+/94365.
Probably it would be better to find the root cause in SW, but doing it this way also takes care of the "swallowing up of the numbering rule" problem that I noted in comment 5. Now that the style is hard-coded, it isn't lost if the para-style changes its numbering.
Justin Luth committed a patch related to this issue.
It has been pushed to "master":
tdf#133000 writerfilter: apply non-contradictory num-style
It will be available in 7.0.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:
Affected users are encouraged to test the fix and report feedback.