Bug 147141 - Calc header/footer not backwards compatible (ODF 1.3 > 1.2) (note comment 17)
Summary: Calc header/footer not backwards compatible (ODF 1.3 > 1.2) (note comment 17)
Status: REOPENED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.5.2 release
Hardware: All All
: low minor
Assignee: Eike Rathke
URL:
Whiteboard: target:7.5.0 target:7.4.3
Keywords: filter:odf
Depends on:
Blocks: Calc-Header-Footer
  Show dependency treegraph
 
Reported: 2022-02-02 15:47 UTC by Wittich
Modified: 2024-05-25 19:33 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Test file created with LO 7.2 (7.72 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-02-03 13:51 UTC, Wittich
Details
Test in LO 7.4+ opens OK (9.09 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-02-04 11:44 UTC, Timur
Details
Test file created with LO 7.3 with first and rest H/F actived (8.40 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-02-04 16:58 UTC, Wittich
Details
ODS LO 24.8 alpha ODF 1.3 Extended (8.20 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-05-24 18:13 UTC, ady
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wittich 2022-02-02 15:47:10 UTC
Description:
Calc disables header/footer when open an under office version 1.3 saved document with an older version

Steps to Reproduce:
1. Open Calc (Version > 7.2.5.2)
2. Type into A1 cell any data, like 1111
3. Make sure Header and Footer checkboxes are enabled in Format-Page dialog on its tabs
4. Save file as ODS and close it
5. Open the file with an older program version like 6.4.7.2 (default Ubuntu 20.04) 
6. Look at header and Footer tabs in Format-Page dialog => the both options are disabled

Actual Results:
Calc disables header/footer when open a spreadsheet in an older software version

Expected Results:
Calc shows header/footer state when reopen with any software version


Reproducible: Always


User Profile Reset: No



Additional Info:
Document saved under:

Version: 7.2.5.2.0+ / LibreOffice Community
Build ID: 711f8d38e9451cd2fd39b6963d2a3fc166f04cb1
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

and 

Version: 7.3.0.3 / LibreOffice Community
Build ID: f4d11761603c82fae6474d6e0e1cb32d39b86e4b
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
but not in 7.1.0.3 => regression

Spreedshed open under:

Version: 6.4.7.2
Build-ID: 1:6.4.7-0ubuntu0.20.04.2
CPU-Threads: 8; BS: Linux 5.4; UI-Render: Standard; VCL: gtk3; 
Gebietsschema: de-DE (en_US.UTF-8); UI-Sprache: de-DE
Calc: threaded

Related Bug: Bug 144940 
https://bugs.documentfoundation.org/show_bug.cgi?id=144940
Comment 1 Wittich 2022-02-02 16:22:56 UTC Comment hidden (obsolete)
Comment 2 Wittich 2022-02-02 16:57:09 UTC
(In reply to Wittich from comment #1)
> A quick analyze of the difference of a document which works (version 1.2)
> and one which doesn't work (version 1.3) shows that the only main difference
> concerning the header and footer of these documents are the lines 
> 
> <office:master-styles>
>     <style:master-page style:name="Default" style:page-layout-name="Mpm1">
>         [...]
>         <style:header-first style:display="false"/>
>         [...]
>         <style:footer-first style:display="false"/>
>         [...]
>     </style:master-page>
> </office:master-styles>
> 
> So if I remove this header-first and the footer-first style, everything
> works as it should.
> 
> Hope that helps to solve the issue.

Here is a way to fix corrupted files so that they show the header/footer correctly with an old calc installation:

1. unzip -p file.ods styles.xml > styles.xml
2. sed -i -r 's/<style\:(footer|header)\-first style\:display="false"\/>//g2' styles.xml
3. zip file.ods styles.xml 

This works for me as I get regularly ODS which are saved as office version 1.3 and I lose the header and footer at the moment.
Comment 3 Timur 2022-02-03 12:42:27 UTC
I don't reproduce. Tried with saving in LO 7.4+ in Windows as 1.3 extended and opening LO 6.4 in Linux and Windows. HF are enabled .
Comment 4 Wittich 2022-02-03 13:48:24 UTC
I can reproduce it also on a Windows 10 system:

Version: 6.2.5.2 (x64)
Build ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; 
Locale: en-US (en_DE); UI-Language: en-GB
Calc: threaded

Not only the HF is disabled but, if I reactivate it, the content is "lost".

I will attach a test file.
Comment 5 Wittich 2022-02-03 13:51:05 UTC
Created attachment 178018 [details]
Test file created with LO 7.2

Test file has an activated HF with a custom content:

- Header Center area: Test Sheet 1
- Footer Center area: Test Footer
Comment 6 Timur 2022-02-03 15:25:32 UTC Comment hidden (obsolete)
Comment 7 Wittich 2022-02-03 17:08:32 UTC
(In reply to Timur from comment #6)
> I reproduce with that sample. Not clear why not from scratch.

Can you compare the styles.xml from my sample with your file? Just rename the *.ods file into *.zip then you can have a look into it (I used xmllint to format the file pretty/readable: `cat styles.xml | xmllint --format - > styles2.xml`). 

Also, you wrote that you created the file with LO 7.4+, I have only reproduced it with 7.2 and 7.3.
Comment 8 Timur 2022-02-04 11:37:23 UTC Comment hidden (obsolete)
Comment 9 Timur 2022-02-04 11:44:41 UTC
Created attachment 178047 [details]
Test in LO 7.4+ opens OK

Seems like there may be 2 issues:
- opening ODS with empty H/F in older LO makes them disabled, which makes no damage and is WontFix
- opening attached ODS, not all, in older LO looses H/F, which is a problem, but not clear what exactly makes it - and it doesn't exist with new LO.

Here is ODS from master 7.4+.
Comment 10 Wittich 2022-02-04 16:58:28 UTC
Created attachment 178071 [details]
Test file created with LO 7.3 with first and rest H/F actived

As I wrote above, you can fix the second issue with removing the header-first and footer-first style... so that got me thinking what is this option *-first, so with LO 7.2* you have this option "Same content on first page" when you uncheck it you can enter two different H/F. One called H/F (first) and one H/F (rest). Now if you fill out both the first and the rest it works in LO 6.4.

So if I got this right, LO 6.4 read the first as main H/F as it doesn't know about a second H/F (rest). 

No clue how to fix this...

For me, works at the moment the following commands as a fix:

file='147141 test 74 13e.ods'
unzip -p "$file" styles.xml > styles.xml
sed -i -r 's/<style\:(footer|header)\-first style\:display="false"\/>//g2' styles.xml
unzip -p "$file" styles.xml > styles.xml

Et voilà!
Comment 11 Wittich 2022-02-04 23:58:34 UTC
I search a little on the OASIS Open page and as far I understand the OpenDocument schema 1.2 and 1.3 the h/f-first style is only valid in office version 1.3. From this standpoint, LO 6.4 and before don't have correctly implemented OpenDocument 1.2. 

I guess there is no fix as long it's not fixed in LO 6.4.

Here are the details from 1.3 schema:

> The <style:header-first> element represents the content of a header for a first page, if different from the left/right page in a <style:master-page> element.
> 
> The term "first page" means the first page to which the page style is applied, regardless of any numbering. If a different page style is applied in between two applications of a page style that has the <style:header-first> element, each of the applications of the page style has its own first page.

Source: https://docs.oasis-open.org/office/OpenDocument/v1.3/cs01/part3-schema/OpenDocument-v1.3-cs01-part3-schema.html#a_16_10__style_header_

In the 1.2 schema, this style element doesn't exits: https://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#a16_10_style_header_
Comment 12 Timur 2022-02-05 06:54:45 UTC
hi Regina, please see if you can.
Comment 13 Wittich 2022-03-05 21:14:22 UTC
Any updates, further thoughts on this topic?
Comment 14 Wittich 2022-04-02 16:04:57 UTC
... still running at least once a month over that issue!
Comment 15 Eike Rathke 2022-10-31 17:42:16 UTC
The proper way out it seems would be to save the *first only when saving to >=1.3 but not <1.3 (1.2 or 1.2-extended).
Comment 16 Eike Rathke 2022-10-31 19:14:43 UTC
Or maybe 1.2-extended would be ok when using the lo-ext namespace.
Comment 17 Eike Rathke 2022-11-01 22:58:03 UTC
With the fix following, for reading with LO versions <7.2.5 ODF 1.2 needs to be written. Versions >=7.2.5 that have the fix of bug 144940 understand both ODF 1.3 and ODF 1.2-extended. But if those versions also need to write for earlier versions then versions having this fix here will have to write ODF 1.2 already because 7.2.x and 7.3.x versions without this fix do not write ODF 1.2 correctly if the file already contained the *-first elements.
Comment 18 Commit Notification 2022-11-02 00:08:42 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/71081a2a79a7b5a1eefec60fc687c533a95d190d

Resolves: tdf#147141 style:header-first/footer-first only ODF 1.3|1.2-extended

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 19 Eike Rathke 2022-11-02 00:10:10 UTC
Pending review https://gerrit.libreoffice.org/c/core/+/142140 for 7-4
Comment 20 Commit Notification 2022-11-02 08:35:20 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

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

Resolves: tdf#147141 style:header-first/footer-first only ODF 1.3|1.2-extended

It will be available in 7.4.3.

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 21 Wittich 2024-05-24 08:44:13 UTC
I revisited the issue and can still reproduce the behavior.

Steps to reproduce:

1) Save a document using a freshly downloaded version on an Apple Silicon machine.
2) Open the same document on a main system running version 6.4.7.2.


Additional Info:
Document saved under:

Version: 24.2.3.2 (AARCH64) / LibreOffice Community
Build ID: 433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba
CPU threads: 8; OS: macOS 13.6.6; UI render: Skia/Metal; VCL: osx
Locale: de-DE (en_GB.UTF-8); UI: en-US
Calc: threaded

and 

Version: 24.2.3.2 (X86_64) / LibreOffice Community
Build ID: 4f88f79086d18691a72ac668802d5bc5b5a88122
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Spreedshed open under:

Version: 6.4.7.2
Build-ID: 1:6.4.7-0ubuntu0.20.04.9
CPU-Threads: 8; BS: Linux 5.4; UI-Render: Standard; VCL: gtk3; 
Gebietsschema: de-DE (en_US.UTF-8); UI-Sprache: de-DE
Calc: threaded
Comment 22 ady 2024-05-24 11:06:53 UTC
(In reply to Wittich from comment #21)
> I revisited the issue and can still reproduce the behavior.
> 
> Steps to reproduce:
> 
> 1) Save a document using a freshly downloaded version on an Apple Silicon
> machine.
> 2) Open the same document on a main system running version 6.4.7.2.

FWIW...

I tested with the steps in comment 0, using a recent 24.8 alpha, and then opening the file with AOO 4.1.15 on MS Windows. I see both header and footer when opening with AOO, which uses ODF 1.2 Extended.

I am not sure whether this reflects the original problem (and the solution), or maybe there is some detail that I am missing.
Comment 23 Wittich 2024-05-24 14:10:58 UTC
Hi @ady,

Thanks for testing it. Could you please provide the test file you mentioned in comment 22? I would like to test it with LibreOffice 6.4.
Comment 24 ady 2024-05-24 18:13:05 UTC
Created attachment 194337 [details]
ODS LO 24.8 alpha ODF 1.3 Extended

(In reply to Wittich from comment #23)

I created this in a recent LO Dev 24.8 alpha with ODF 1.3 Extended. With Print Preview, I see both Header and Footer. Saved the file and closed LO.

Opening the file with AOO 4.1.15 (supporting ODF 1.2 Extended), Print Preview also shows both Header and Footer.
Comment 25 ady 2024-05-24 18:30:16 UTC
(In reply to Wittich from comment #23)

> I would like to test it with LibreOffice 6.4.

I doubt it will work correctly in LO 6.4.

IIUC, you claim that the problem is in the (current) creation of the file, and not in those older LO versions. Am I understanding you correctly?

If you want it to be correctly read in older versions, shouldn't the file be saved with ODF 1.2 (Extended) instead of using ODF 1.3 (Extended)?

Maybe I am not understanding the real-world situation.
Comment 26 Wittich 2024-05-25 19:22:00 UTC
In a real-world scenario is, I created a file with a footer on the main system running LibreOffice 6.4. However, after editing and saving this file on a second computer using LO >7.2, the file becomes unusable on my main system without running my script (see comment 10). The frustrating part is that the missing footer often goes unnoticed until you print or export the document in LibreOffice 6.4.