Bug 167082 - Filesave DOCX: heading style changes to default
Summary: Filesave DOCX: heading style changes to default
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0 target:25.8.0.0.beta2
Keywords: bibisected, bisected
Depends on:
Blocks: DOCX-Track-Changes
  Show dependency treegraph
 
Reported: 2025-06-18 14:59 UTC by Timur
Modified: 2025-07-09 12:57 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
sample DOCX (29.42 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-06-18 14:59 UTC, Timur
Details
A comparison of effects of the amount of deletion of the *previous* paragraph on the partially deleted next (14.26 KB, application/vnd.oasis.opendocument.text)
2025-07-03 06:08 UTC, Mike Kaganski
Details
A DOCX showing the different handling depending how much of *previous* paragraph is deleted (13.25 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-07-03 06:18 UTC, Mike Kaganski
Details
And here only deletion of the paragraph mark of the previous paragraph is shown (13.39 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-07-03 06:40 UTC, Mike Kaganski
Details
Attachment from i#75463 (52.58 KB, application/vnd.oasis.opendocument.text)
2025-07-03 07:39 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timur 2025-06-18 14:59:36 UTC
Created attachment 201346 [details]
sample DOCX

Open sample DOCX that has ToC and tracked changes. 
See word Einleitung as Heading style. 
Save and reopen, see that Einleitung is Default style.

Seems regression in 6.4:
commit e76fcb8f169acac3d81bdaf9b126cc4c98e2eb8e	[log]
author	Mike Kaganski <mike.kaganski@collabora.com>	Fri Dec 13 09:36:39 2019 +0300
committer	Andras Timar <andras.timar@collabora.com>	Thu Jan 09 08:19:01 2020 +0100
tdf#129353, tdf#129402: fix node creation on index import
Comment 1 Timur 2025-06-18 15:05:16 UTC
Actually, before referened commit file would not properly open, that one fixed opening. So that saving is spoiled seems a consequence, not a regression.
I would rather call this missing feature of handling complex format.
Comment 2 Gabor Kelemen (allotropia) 2025-07-01 03:58:02 UTC
Confirming, this is very similar to my bug 167196 (also from the same customer doc, but slightly more complicated example file - let's keep it open to be sure).
Comment 3 Commit Notification 2025-07-03 04:28:34 UTC
Gülşah Köse committed a patch related to this issue.
It has been pushed to "master":

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

tdf#167082 Fix the missing style

It will be available in 26.2.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 4 Mike Kaganski 2025-07-03 06:08:07 UTC
Created attachment 201617 [details]
A comparison of effects of the amount of deletion of the *previous* paragraph on the partially deleted next
Comment 5 Mike Kaganski 2025-07-03 06:10:47 UTC
Oh, we seem to have even larger problem here, and my document suffered from it: it already lost the formatting of para 2 when recording redlines in ODT.
Comment 6 Mike Kaganski 2025-07-03 06:18:06 UTC
Created attachment 201618 [details]
A DOCX showing the different handling depending how much of *previous* paragraph is deleted
Comment 7 Mike Kaganski 2025-07-03 06:40:11 UTC
Created attachment 201622 [details]
And here only deletion of the paragraph mark of the previous paragraph is shown

Check in Word, how the resulting merged paragraph is shown in case of removed paragraph mark.

We have some problems around redlines both in ODF export, and endline deletion handling (at least with Word compatibility). Maybe my doubt is caused not by the fix specifically, but by the general state of the feature.
Comment 8 Mike Kaganski 2025-07-03 07:35:44 UTC
Heh, both https://bz.apache.org/ooo/show_bug.cgi?id=75463 and my new bug 167360 seem related. The function lcl_getFormatCollection was introduced in the OOo bug, to handle the incorrect handling of the style in "Åbne filer" paragraph, which *expected* to have OOoHeading1 style. And it had that paragraph in the bugdoc, until we broke it somewhere in version 7.4. Which is yet another bug.

Sorry to put it all together here; but it looks like we are keeping piling workarounds over hacks in the redlines area, and that needs some integral overview to proceed reasonably.
Comment 9 Mike Kaganski 2025-07-03 07:39:57 UTC
Created attachment 201627 [details]
Attachment from i#75463

AOO Issuezilla seems to have spam influx, so they limited access to registered users; so here is the bugdoc from it, as well as the description:

> export attached document to WW8 format, open in MS Word -> paragraph "Abne
> filer" is no more a heading paragraph, got default style. When accepting all
> tracked changes before exporting, Dok will look good in Word.

...

> Investigations reveals the following:
> The change tracking contains a merge of paragraphs.
> OOo Writer and Microsoft Word have a different handling on merging paragraphs:
> - In OOo Writer the paragraph style of the first paragraph is kept.
> - In Microsoft Word the paragraph style of the second paragraph is kept.
> Thus, in case the paragraph styles are different at the two merged paragraphs,
> the result differs in OOo Writer and Microsoft Word. This different behavior
> causes the described defect.

The fixing commit was 39e43369ffb0339b2d33d54dc16725a9450ae055
Comment 10 Mike Kaganski 2025-07-03 07:49:19 UTC
Reading the OOo bug analysis, bug 167360 comment 1, and comment 8 mentioning a change in 7.4, I suspect that in 7.4, we made a breaking change to follow what Word does (incompletely). My suggestion would be to find that change in 7.4, see if that breaking change makes sense, and if so, then maybe simply remove lcl_getFormatCollection as a whole - because likely, we now don't need it anymore?
Comment 11 Commit Notification 2025-07-03 10:57:23 UTC
Gülşah Köse committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

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

tdf#167082 Fix the missing style

It will be available in 25.8.0.0.beta2.

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 12 Timur 2025-07-03 13:53:37 UTC
Escuse me Mike, maybe it should be obvious but can you clarfiy change in 7.4, is it original bugdoc attachment 201346 [details], where is that style in "Åbne filer" paragraph, GUI or XML, not seeing that.
Comment 13 Mike Kaganski 2025-07-03 14:02:22 UTC
(In reply to Mike Kaganski from comment #10)

It was commit 81273c65dd9cec5acd9464b9041f452a5481e10e (for bug 134759).
And I believe, that that was a correct change.

Deleting a paragraph in change tracking mode must result in the same formatting as in normal mode. Before that change, there was a difference how these two cases behaved; and what's even more interesting, it only appeared on save (i.e., user would see the result as expected when pressing Delete button).

(In reply to Timur from comment #12)
> Escuse me Mike, maybe it should be obvious but can you clarfiy change in
> 7.4, is it original bugdoc attachment 201346 [details],

No, that was the bugdoc from i#75463 (attachment 201627 [details]).
Comment 14 Gabor Kelemen (allotropia) 2025-07-09 12:57:07 UTC
Verified in 

Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 36a55369a6ac72ae985cf31405b7f52686665d84
CPU threads: 14; OS: Windows 10 X86_64 (build 19045); UI render: Skia/Raster; VCL: win
Locale: de-DE (hu_HU); UI: en-US
Calc: threaded

After save and reload the Heading style of the Einleitung paragraph is retained.