Bug 136472 - FILEOPEN DOCX: be like DOC - import bTitlePage into Default Page Style (as separate first header), not First Page style
Summary: FILEOPEN DOCX: be like DOC - import bTitlePage into Default Page Style (as se...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:24.2.0
Keywords:
: 91296 141225 (view as bug list)
Depends on: 145317
Blocks: DOCX-Header-Footer Writer-Styles-Page-Odd-Even
  Show dependency treegraph
 
Reported: 2020-09-04 18:26 UTC by Telesto
Modified: 2024-03-22 13:37 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of the original document and its docx version in Writer - First Page Header settings (98.15 KB, image/png)
2021-02-03 11:14 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document and its docx version in Writer - Left Page Header settings (85.94 KB, image/png)
2021-02-03 11:18 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document and its docx version in Writer - Right Page Header settings (98.82 KB, image/png)
2021-02-03 11:21 UTC, NISZ LibreOffice Team
Details
patch_136472.diff: my mostly working attempt to import as first-header. (25.95 KB, patch)
2021-11-06 17:00 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2020-09-04 18:26:04 UTC
Description:
Same content on left/right pages/ Same content on first page checked on file open DOCX

Steps to Reproduce:
1. Open attachment 165014 [details] 
2. Go top say page 5
3. Format Header bar -> take a look at settings (top and bottom checkbox checked; rest unchecked)
4. Cancel
5. Save as DOCX
6. File reload
7. Repeat 3 -> All checkboxes checked. This isn't the case on DOC export

Actual Results:
Also checked: 
Same content on left/right pages
Same content on first page 

Expected Results:
Not so?


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.1.0.0.alpha0+ (x64)
Build ID: e8b8e7be0b2ad693224cd94062a55610eb69df7e
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: CL
Comment 1 Telesto 2020-09-04 18:36:42 UTC
@Justin
They area of DOCX import/export + compability differences is a mystery to me. They only thing I observe that checkbox are checked for they header which isn't they case in the source ODT nor when doing a DOC export. 

So if DOC has been implemented correctly this must be a bug; because I assume DOCX being more or less DOC except XML and all the additions made to it in the recent years.. But that only guessing 

Same content on left/right page doesn't get checked with 3.5.0
They "Same content on first page" is being checked by default with LibO 4.0 export. "Same content on left/right page" is not being checked.

So even 2 bugs maybe?
Comment 2 Justin L 2020-09-07 09:47:01 UTC
The big difference is that two page styles are involved in import. The first header moves into a separate page style for DOCX (not DOC since 4.1). So not really a bug since emulation provides the same look as the original document.

This was a good exercise for me to go through - to review the order of support for separate first header/footer.

-3.5 (Dec 2011): already had left/right headers and footers, but no first page. So the whole idea of a "next page style" looks like the original concept of LibreOffice. The other stuff (first/left/right headers/footers) was probably added for compatibility with MSWord purposes. At this point, both DOC and DOCX successfully emulate this kind of file on import as a First Page / Default page-style combination.

-4.0 UI for first page header/footer added with
author	Miklos Vajna on 2012-10-05 17:20:01 +0200
commit 751dacec8e0947c2d85187342995822e6dc62912
SvxHFPage: add UI for style::PageProperties::FirstIsShared

-4.1: support added to import "default with first" DOC and export to DOC/DOCX.
linux bibisect41max commit f1e99f38d537693ab8d73d721421f43d82b365b2
    commit 1e113cb7604e1509e7d598a9be329f1f7b6e9322
    Author:     Luke Deller on Mon Feb 11 10:41:05 2013 +0000
        import different first page header/footer from doc

and in the prior commit 532e25f8b0ef1daeca1f9f84c7084812b72841d5
    Author:     Luke Deller on Mon Feb 11 10:26:34 2013 +0000
        export different first page header/footer to doc/docx

So, it looks like DOCX was never modified to use the new capability of a separate first page header/footer. So I think this is a legitimate enhancement report - although it is a rather dangerous area to mess around in. But it is also a fairly problematic area, so there should be lots of unit tests related to this to help catch re-implementation errors.
Comment 3 Justin L 2020-12-14 11:02:44 UTC
*** Bug 91296 has been marked as a duplicate of this bug. ***
Comment 4 NISZ LibreOffice Team 2021-02-03 11:14:21 UTC
Created attachment 169420 [details]
Screenshot of the original document and its docx version in Writer - First Page Header settings
Comment 5 NISZ LibreOffice Team 2021-02-03 11:18:38 UTC
Created attachment 169421 [details]
Screenshot of the original document and its docx version in Writer - Left Page Header settings
Comment 6 NISZ LibreOffice Team 2021-02-03 11:21:31 UTC
Created attachment 169422 [details]
Screenshot of the original document and its docx version in Writer - Right Page Header settings
Comment 7 Dániel Arató (NISZ) 2021-05-13 08:59:04 UTC
This should be solved by the patch for bug #69635:
https://bugs.documentfoundation.org/show_bug.cgi?id=69635#c8
Comment 8 BogdanB 2021-05-19 17:58:11 UTC
Not yet solved in Version: 7.2.0.0.alpha1+ / LibreOffice Community
Build ID: b238522ca121ca8f863fe4d3394ade088a65ad01
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: en-US (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 9 NISZ LibreOffice Team 2021-06-25 09:15:59 UTC
(In reply to BogdanB from comment #8)
> Not yet solved in Version: 7.2.0.0.alpha1+ / LibreOffice Community
> Build ID: b238522ca121ca8f863fe4d3394ade088a65ad01
> CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
> Locale: en-US (ro_RO.UTF-8); UI: en-US
> Calc: threaded

Yes. To summarize the problem:

Currently Writer imports the "Different first page" setting from DOCX as a First Page page style (see in the Navigator - Styles - Page Styles) with the "Same content on first page" enabled (and Same content on left and right pages too, but that does not make a difference), 
and the "Even-odd different" setting as a "Default Page Style" with "Same content on left and right pages" enabled (and "Same content on first page" enabled but that does not make a difference either).

While from doc, as implemented in 
https://cgit.freedesktop.org/libreoffice/core/commit/?id=1e113cb7604e1509e7d598a9be329f1f7b6e9322
all is imported as Default Page Style with "Same content on first page" and "Same content on first page" disabled, since that's how it makes sense.

The task is to implement this import as "Default Page Style" in docx.
Comment 10 Justin L 2021-10-30 15:47:01 UTC
I'm going to try to do this for first headers in 7.4. I have a patch that passes almost all of the ooxml unit tests. RTF might be a bigger problem because it doesn't seem to export properly yet, so that will need to be fixed first.
Comment 11 Commit Notification 2021-11-03 05:58:30 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1891061f0b99c8a7c5d9983b925efcf401c958fd

prelim tdf#136472: remove implementation specific unit tests

It will be available in 7.3.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 12 Commit Notification 2021-11-04 05:24:53 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

prelim tdf#136472: adjust implementation specific unit tests

It will be available in 7.3.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 2021-11-05 13:32:48 UTC
I don't have enough compelling evidence to actually propose this patch, but it does seem to be working. So I will at least post it here for reference at minimum.

http://gerrit.libreoffice.org/c/core/+/124755
Comment 14 Commit Notification 2021-11-06 07:45:28 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0ce586e1e50deeaf2ba210acc4fea08058f8b15c

related tdf#136472 writerfilter: only copy even pages if used

It will be available in 7.3.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 15 Justin L 2021-11-06 17:00:25 UTC
Created attachment 176135 [details]
patch_136472.diff: my mostly working attempt to import as first-header.

(In reply to Justin L from comment #13)
Because a web link can disappear too easily, I'm attaching the code diff.
Comment 16 Justin L 2022-09-06 21:10:08 UTC
*** Bug 141225 has been marked as a duplicate of this bug. ***
Comment 17 Commit Notification 2023-12-01 07:27:17 UTC
Tomaž Vajngerl committed a patch related to this issue.
It has been pushed to "master":

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

tdf#136472 adjust ooxml import to handle first header/footer

It will be available in 24.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.