Bug 107696 - Export to XHTML incorrectly exports Heading style numbers
Summary: Export to XHTML incorrectly exports Heading style numbers
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.3.2.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.4.0 target:5.3.4 target:7.0.0
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-08 07:18 UTC by grofaty
Modified: 2020-04-16 12:33 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
LibreOffice_screencast_of_export_to_XHTML_heading_style_numbering_problem.gif (2.08 MB, image/gif)
2017-05-08 07:18 UTC, grofaty
Details
Second_simplified_sample_screencast.gif (259.15 KB, image/gif)
2017-05-08 07:39 UTC, grofaty
Details
Solution_1_change_install_body_xsl_config_file.gif (1.01 MB, image/gif)
2017-05-08 12:44 UTC, grofaty
Details
usual numbering without removing numbers (10.35 KB, application/vnd.oasis.opendocument.text)
2017-05-08 20:28 UTC, Regina Henschel
Details
Header without number on level 2 (10.86 KB, application/vnd.oasis.opendocument.text)
2017-05-16 21:39 UTC, Regina Henschel
Details
Numbering with 1 "number" on all levels (11.29 KB, application/vnd.oasis.opendocument.text)
2017-05-16 22:41 UTC, Regina Henschel
Details
Same kind of numbering, but for lists (10.98 KB, application/vnd.oasis.opendocument.text)
2017-05-16 22:42 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description grofaty 2017-05-08 07:18:50 UTC
Created attachment 133151 [details]
LibreOffice_screencast_of_export_to_XHTML_heading_style_numbering_problem.gif

Hi,
using the following LibreOffice on Windows 7:
======================
Version: 5.3.2.2
Build ID: 6cd4f1ef626f15116896b1d8e1398b56da0d0ee1
CPU Threads: 3; OS Version: Windows 6.1; UI Render: default; Layout Engine: new; 
Locale: sl-SI (sl_SI); Calc: group
======================

1. I renamed profile to make sure this is not my environment special problem related to profile.
2. I created two lines of text and both of them created with "Heading 1" style.
3. Created Insert | Page Break (probably cause of the problem).
4. Created Table of Content.
5. LibreOffice works fine. First heading is numbered "1 First heading" and second heading is correctly numbered "2 Second headign". Now export content of LibreOffice Writer document to XHTML.
6. Now look into browser and there is correct numbering for "1 First heading", but wrong numbering with "3 Second heading".
7. If going back to LibreOffice we can see under the Table of Content it is new line with "Heading 1" style that has zero effect in LibreOffice document, but when exported to XHTML then it has effect on numbering.
8. Changing this dummy line style from "Heading 1" style to "Default" style and re-exporting the file and problem is fixed.

It looks like export to XHTML has some bug when exporting.

I have recorded the screencast (gif file video). Open the file in gif viewer like web browser to see the screencast. If you will open file in Firefox I suggest to press F11 to display browser in full screen mode.

ADDITIONAL TEST (not seen on screencast) - EXPORT TO PDF
1. Set in dummy line style back to "Heading 1".
2. Export to PDF and numbering of "2 Second heading" is correct.
This indicate that source of the problem may be the XHTML export.

Thanks
Comment 1 grofaty 2017-05-08 07:38:22 UTC
Hi,
I have found out another simpler way to reproduce a problem without Table of Content, just free lines of text and "Heading 1" styles. It looks export to XHTML has some problems with unnumbered heading styles. See screencast for details.

Regards
Comment 2 grofaty 2017-05-08 07:39:05 UTC
Created attachment 133155 [details]
Second_simplified_sample_screencast.gif
Comment 3 Julien Nabet 2017-05-08 10:30:09 UTC
On pc Debian x86-64 with master sources updated some days ago, I could reproduce this. 

I made some tests and found that a slight change made work your second example.
The problem is I don't know xsl and am not sure.

Would you have some time to give a try after changing instdir/share/xslt/export/xhtml/body.xsl ? (in your LO directory profile, see https://wiki.documentfoundation.org/UserProfile#Windows)
Line 1424, change this line:
<xsl:with-param name="i" select="$i + 1"/>

into
<xsl:with-param name="i" select="$i + 2"/>
Comment 4 grofaty 2017-05-08 12:43:55 UTC
Hi,
I have changed the setting 1 to 2 in body.xls file as suggested in your reply and it looks this solves the problem. I have recorded screencast with this solution.

I have also tested PDF export and see it has zero effect on it (as expected).

I suggest to apply this fix to LibreOffice source code (if there is no other side effect). I hate to have some special setting in my installation files that are different then all other installations on the world. If some problem appers I will forget about this special settings and it would be almost impossible to diagnose the problem.
Regards
Comment 5 grofaty 2017-05-08 12:44:48 UTC
Created attachment 133159 [details]
Solution_1_change_install_body_xsl_config_file.gif
Comment 6 Julien Nabet 2017-05-08 12:56:31 UTC
I submitted the patch for review here:
https://gerrit.libreoffice.org/#/c/37391
Comment 7 Regina Henschel 2017-05-08 20:28:13 UTC
Created attachment 133166 [details]
usual numbering without removing numbers

The attached file has a usual numbering, here 1  2  3  4  4.1  4.2  5  5.1  5.2.
With your change applied it exports to 1  2  2  3  2.1  2.2  3  3.1  3.3
So totally broken.

The reason of the wrong numbering is different. When the number is removed by delete, this is reflected in the ODF source by the attribute text:is-list-header="true". But that attribute is not evaluated for pure headings by the XSLT, but only for lists.
Comment 8 Julien Nabet 2017-05-09 20:40:24 UTC
Sorry, I don't understand xsl/xpath logic.
I'm quite sure someone who knows a minimum about this, will do this in less than 1 minute with Regina's comment.
Comment 9 Julien Nabet 2017-05-15 20:06:25 UTC
I spent more time to understand and so give a new try with:
https://gerrit.libreoffice.org/#/c/37655/

It works with example of reporter+Regina's example.
Comment 10 Commit Notification 2017-05-16 07:11:11 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d67747c59c22e0346e13560810b9f3bf6c698428

tdf#107696: fix exports Heading style numbers

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Regina Henschel 2017-05-16 21:39:50 UTC
Created attachment 133364 [details]
Header without number on level 2

Continuing of numbers is correct with the patch; but the header, where the number is removed, still gets a number in xhtml.

But there are two more bugs with chapter numbering:
(1) There are always the numbering of all levels shown, although the text document has set to only show the inner one level.
(2) The type of number is taken from the inner level. But in the text document each lever has its own type.
Comment 12 Commit Notification 2017-05-16 22:19:43 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=296c2296f5565556eea9fab51563050f28bbcafc

Related tdf#107696: deal with non empty header without number

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Julien Nabet 2017-05-16 22:20:50 UTC
(In reply to Regina Henschel from comment #11)
> Created attachment 133364 [details]
> Header without number on level 2
> 
> Continuing of numbers is correct with the patch; but the header, where the
> number is removed, still gets a number in xhtml.
> 
> But there are two more bugs with chapter numbering:
> (1) There are always the numbering of all levels shown, although the text
> document has set to only show the inner one level.
> (2) The type of number is taken from the inner level. But in the text
> document each lever has its own type.


As you may have seen, I submitted a new patch to deal with your last attachment.

To test more quickly, could you attach an example for your 2 other bugs?
Comment 14 Regina Henschel 2017-05-16 22:41:39 UTC
Created attachment 133366 [details]
Numbering with 1 "number" on all levels

The attached file has
A heading
1 subheading
(a) subsubheading

That works better with lists. Perhaps you can take some ideas from that section?
Comment 15 Regina Henschel 2017-05-16 22:42:50 UTC
Created attachment 133367 [details]
Same kind of numbering, but for lists
Comment 16 Julien Nabet 2017-05-17 20:55:58 UTC
Regina: I think we should test if style of the header contains style:default-outline-level and depending on this value, adding the last prefix digit/alpha only or the whole hierarchy.
Anyway, I don't think I could achieve this so prefer unassign myself on this.

Now, I don't know if
1) we should backport the 2 patches on 5.3 branch
2) do you prefer we let this bugtracker opened or do you prefer close this one and open a brand new one
Comment 17 Regina Henschel 2017-05-18 22:07:34 UTC
Julien: Wrong handling of "show sublevel" is now in bug 107940.
Wrong handling of different styles on levels is now in bug 107941.

We can keep this for the problems related to unnumbered heading because of attribute text:is-list-header="true".

The two patches solve the problem of the unnumbered heading, so why not backport them to the 5.3 branch? If someone provides a solution to the entire "numbered heading" problems, it can then be changed where necessary.
Comment 18 Julien Nabet 2017-05-18 22:14:39 UTC
Regina:
Thank you for your feedback.
I submitted the 2 patches for backport in 5.3
https://gerrit.libreoffice.org/#/c/37661/
https://gerrit.libreoffice.org/#/c/37792/

Let's put this one to FIXED then.
Comment 19 Commit Notification 2017-05-26 10:54:31 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9b4c1e9d85445f4ddfb45359ad661d4826fe6a3c&h=libreoffice-5-3

tdf#107696: fix exports Heading style numbers

It will be available in 5.3.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 20 Commit Notification 2017-05-26 10:54:37 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6ee4771aff5d756f45014b88aebbcfb25b5cadfe&h=libreoffice-5-3

Related tdf#107696: deal with non empty header without number

It will be available in 5.3.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 21 Commit Notification 2020-04-16 12:33:13 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

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

tdf#107696, tdf#111492: xhtml: Add unittest

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:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.