Bug 93637 - PDF export missing ToC page numbers
Summary: PDF export missing ToC page numbers
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: Other All
: highest major
Assignee: Justin L
URL:
Whiteboard: target:5.2.0 target:5.1.1 target:5.0.6
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2015-08-24 23:08 UTC by Matthew Holloway
Modified: 2017-05-18 17:28 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Source document (283.33 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2015-08-24 23:08 UTC, Matthew Holloway
Details
msword rendering of document (89.94 KB, image/png)
2015-08-24 23:09 UTC, Matthew Holloway
Details
libreoffice pdf export (36.58 KB, application/pdf)
2015-08-24 23:10 UTC, Matthew Holloway
Details
cleanroom test document with word pdf, LO pdf and LO screenshot (186.48 KB, application/force-download)
2015-10-07 13:39 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Holloway 2015-08-24 23:08:58 UTC
Created attachment 118139 [details]
Source document

Although the page numbers are visible when graphically editing the attached document they disappear in the PDF export.

This seems to be writer specific rather than a general PDF bug.
Comment 1 Matthew Holloway 2015-08-24 23:09:46 UTC
Created attachment 118140 [details]
msword rendering of document
Comment 2 Matthew Holloway 2015-08-24 23:10:14 UTC
Created attachment 118141 [details]
libreoffice pdf export
Comment 3 Pedro 2015-08-25 09:48:50 UTC
Confirmed under Win XP Pro x86 running version 5.0.1.2 x86

This is a Regression from branch 3.6 where the PDF is exported as expected

In fact this is quite easy to check: just open Print Preview. If the page numbers are not shown, it won't be on the PDF.
Comment 4 Marina Latini (SUSE) 2015-08-25 10:21:33 UTC
According to git bisect, the oldest affectd version is 4.1.0.0.alpha0+ -> version set to 4.1.0.4

--------------------------------------------------------------------------------------------------
b76709f9410f3df5da2f3357f58276b4a9126d74 is the first bad commit
commit b76709f9410f3df5da2f3357f58276b4a9126d74
Author: Bjoern Michaelsen <bjoern.michaelsen@canonical.com>
Date:   Wed Oct 16 01:34:00 2013 +0000

    source-hash-540f090a68ae4375a36d0ee6dfbb4a82f28ac704
    
    commit 540f090a68ae4375a36d0ee6dfbb4a82f28ac704
    Author:     Jan Holesovsky <kendy@suse.cz>
    AuthorDate: Fri Jan 4 22:02:34 2013 +0100
    Commit:     Jan Holesovsky <kendy@suse.cz>
    CommitDate: Fri Jan 4 22:02:53 2013 +0100
    
        Fix build on linux.
    
        Change-Id: I5753a822e9f18d1afa831ece6134e030f88ad47f

:100644 100644 7ab4acc7a2fc7af57298101431f56988b7a661ee 2168b5416b56c57e64890e7c5fb3a40c2cee2afa M	ccache.log
:100644 100644 d974d3cdb1c5702c32fae5a0bb37170b89ca1b97 b7dfd1545d9d9011e99f29c6e79ec0530141246a M	commitmsg
:100644 100644 3bda583c7407f256ca62339a2a175f968dec30e6 ce943f057445a2dda78d5d8a9c70bf75c0b0e0d9 M	dev-install.log
:100644 100644 ab1c61f521c9f8c979d099dd5c5246a35ee512ec 4e65ace6f22bb19276d96947bff11d13124d6eca M	make.log
:040000 040000 9e35ab1f56ae685848b822c585132d93ad160078 a54e176390a421ec5e6b6270e65417e3c2addb4b M	opt

-----------------------------
git bisect log
# bad: [2d379e53de53493b4a4ec81342416daa15d34b8d] source-hash-cb4e009c4539c535108021934e545194b35cad9d
# good: [65fd30f5cb4cdd37995a33420ed8273c0a29bf00] source-hash-d6cde02dbce8c28c6af836e2dc1120f8a6ef9932
git bisect start 'latest' 'oldest'
# good: [b707aa5f76c7987ca68f44805903b76153cbd3e9] source-hash-b0da54bec69f4931af0adbc15d230d3f4eea7b08
git bisect good b707aa5f76c7987ca68f44805903b76153cbd3e9
# bad: [b1b1a213b1ba3d1fe034e65d18cb794080c48863] source-hash-f62a00f32a1adb4052b05e406cb0e040c7f2360d
git bisect bad b1b1a213b1ba3d1fe034e65d18cb794080c48863
# bad: [c6c3c84acf5fbabdd25e0021eed7ab141d554551] source-hash-5da10275a7475efdbfd9de14ea58cf8f4c6c1582
git bisect bad c6c3c84acf5fbabdd25e0021eed7ab141d554551
# good: [29bb1293d06725d55c3827dacd49d5a4ddd5d432] source-hash-ce90f99a2d66c2b998ad3f9f028e2ea623a757f5
git bisect good 29bb1293d06725d55c3827dacd49d5a4ddd5d432
# good: [c14cf9a7e8d4c135a6ff146e46a59571f073909a] source-hash-db99a31c4e4e7c74d4c4bb7caa747a5752a32757
git bisect good c14cf9a7e8d4c135a6ff146e46a59571f073909a
# bad: [99b169f96f238341c1d04db63bb9f543adaa5f1d] source-hash-f340cbb6af86c7046d34202d2781a68b0d991001
git bisect bad 99b169f96f238341c1d04db63bb9f543adaa5f1d
# bad: [b76709f9410f3df5da2f3357f58276b4a9126d74] source-hash-540f090a68ae4375a36d0ee6dfbb4a82f28ac704
git bisect bad b76709f9410f3df5da2f3357f58276b4a9126d74
# good: [b0fb0d714b44cf3cb085c7eab361a06e9e20378f] source-hash-f6b4d0313dbaf1089254a1bfae9ccfbc3f413eb3
git bisect good b0fb0d714b44cf3cb085c7eab361a06e9e20378f
# first bad commit: [b76709f9410f3df5da2f3357f58276b4a9126d74] source-hash-540f090a68ae4375a36d0ee6dfbb4a82f28ac704
Comment 5 Pedro 2015-08-25 13:12:08 UTC
(In reply to Marina Latini from comment #4)
> According to git bisect, the oldest affectd version is 4.1.0.0.alpha0+ ->
> version set to 4.1.0.4

I have no idea how bisect is performed but I can guarantee that the bug is present in version 4.0.6 (maybe the commit was back-ported to branch 4.0?)

The last version I can confirm that this bug does not occur is 3.6.7
Comment 6 Marina Latini (SUSE) 2015-08-25 14:06:43 UTC
(In reply to Pedro from comment #5)
> 
> I have no idea how bisect is performed but I can guarantee that the bug is
> present in version 4.0.6 (maybe the commit was back-ported to branch 4.0?)

The first affected version seems to be: 
* Version 4.0.0.1 (Build ID: 527dba6f6e0cfbbc71bd6e7b88a52699bb48799)

This is the output after a second bisect round with "bibisect-releases" 

12aa7e702b7d1f1a9de579e5293779dc84ef42e7 is the first bad commit
commit 12aa7e702b7d1f1a9de579e5293779dc84ef42e7
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Tue Apr 14 22:41:11 2015 +0800

    libreoffice-4.0.0.1
    
    LibreOffice_4.0.0.1_Linux_x86-64_deb.tar.gz

:040000 040000 0b8580bdf174f18e74c5c861d348c2daffbe0c2c 8a71ceceb0305e0f5435bbfe47eea27e84ed1c80 M	opt

-----------------------------------------------------
git bisect log
# bad: [60af19e4996c07eaa9d1f7e1e908cfe211df368b] libreoffice-4.4.2.2
# good: [8e8988dc5e8570c931da35053245bd7da33349ea] openoffice-3.3.0
git bisect start 'latest' 'oldest'
# bad: [3586e78f6a41b42eab485f121c7bf229797af12d] libreoffice-4.1.2.2
git bisect bad 3586e78f6a41b42eab485f121c7bf229797af12d
# good: [208dc7bb206c4f313021c2fb045b165638921b9e] libreoffice-3.6.7.1
git bisect good 208dc7bb206c4f313021c2fb045b165638921b9e
# bad: [3f66624caf35f7f60577c4e0b2aaabeb01cc7fb4] libreoffice-4.0.4.1
git bisect bad 3f66624caf35f7f60577c4e0b2aaabeb01cc7fb4
# bad: [525c5fcffd736713ab88900699bd96c3b8c724a1] libreoffice-4.0.1.1
git bisect bad 525c5fcffd736713ab88900699bd96c3b8c724a1
# good: [70384e41cb98846980857d709fb50601e57709b3] libreoffice-4.0.0.0.beta2
git bisect good 70384e41cb98846980857d709fb50601e57709b3
# bad: [46fb689f1e4847c8498a60ff67e0889bf78ca9c7] libreoffice-4.0.0.2
git bisect bad 46fb689f1e4847c8498a60ff67e0889bf78ca9c7
# bad: [12aa7e702b7d1f1a9de579e5293779dc84ef42e7] libreoffice-4.0.0.1
git bisect bad 12aa7e702b7d1f1a9de579e5293779dc84ef42e7
# first bad commit: [12aa7e702b7d1f1a9de579e5293779dc84ef42e7] libreoffice-4.0.0.1
Comment 7 Joel Madero 2015-08-25 15:58:48 UTC
wow - same problem even if you convert it to an odt first so it's not really an interoperability problem but something else.

Again a simpler test case would be much appreciated here but I'm going to go ahead and prioritize this correctly:

Major - loss of data on pdf export;
Highest - regression, happens with both non open filters and odf filters

@Matthew - again you've been doing some great work and we'd love to see you in the chat. I've personally commented about your thoroughness and patience with bug reporting and those are good skills for contributors to have.

http://webchat.freenode.net/?channels=libreoffice-qa
Comment 8 Joel Madero 2015-08-25 16:08:17 UTC
And this bug has been bibisected but not bisected - updating tags.

@Marina - bibisected is what happens when you get that output that you got. Bisected is a step further and identifies the exact commit/committer that caused the regression :)
Comment 9 Justin L 2015-10-05 06:11:59 UTC
bisected and confirmed the specific commit:

author	Miklos Vajna <vmiklos@suse.cz>	2013-01-08 10:57:13 (GMT)
committer	Miklos Vajna <vmiklos@suse.cz>	2013-01-08 13:17:27 (GMT)
commit	bdfc6363d66aa079512cc8008996b633f693fed1 (patch)
tree	7704817a991ba16b2437381506a7360a2cb741cc
parent	f7623118c415581434937f31f4c56d38a9d02286 (diff)
n#793998 sw: add TabOverMargin compat mode

specifically this line from sw/source/core/text/txttab.cxx:
    const sal_uInt16 nRight = bTabOverMargin ? GetTabPos() : std::min(GetTabPos(), rInf.Width());
Comment 10 Justin L 2015-10-07 13:39:34 UTC
Created attachment 119389 [details]
cleanroom test document with word pdf, LO pdf and LO screenshot
Comment 11 Justin L 2015-10-07 13:51:14 UTC
unassigning myself because I'm not making any headway in identifying a possible solution.

vcl/source/gdi/pdfwriter_impl.cxx drawTextArray(...) function is a good place to start investigating. The full text string is given, but the invisible sections are skipped (nIndex incremented past them, nLen of the line doesn't include the invisible characters).

I'd guess that the problem is in the GDIMetaFile recording of the view.

This problem can be avoided by moving the tabstop inside the right margin.
Comment 12 Justin L 2015-10-10 06:43:44 UTC
Text past the right margin exports to PDF when sw/source/core/text/itrpaint.cxx replaces nMaxRight with rPaint.Right() in this line: 

pPor = bDrawInWindow || GetInfo().X() <= nMaxRight

Now, equating MaxRight to the right edge of the page is likely not the ideal fix, but this gives a developer a good place to begin.
Comment 13 Justin L 2015-10-28 11:27:08 UTC
https://gerrit.libreoffice.org/#/c/19635
Comment 14 testjava 2015-11-24 20:54:10 UTC
Bug confirmed on Version: 5.0.3.2
Build ID: e5f16313668ac592c1bfb310f4390624e3dbfb75
Locale: it-IT (de_DE)
Windows XP

The TOC is diplayed in Print Preview but not on PDF and the number is missing on even pages.
Comment 15 Robinson Tryon (qubit) 2015-12-13 11:13:05 UTC Comment hidden (obsolete)
Comment 16 Commit Notification 2016-01-18 04:32:33 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#93637 TAB_OVER_MARGIN support for a few more cases

It will be available in 5.2.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 17 Commit Notification 2016-01-21 08:18:49 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8c564a1fd313da29088bed6453c5e16876690d24&h=libreoffice-5-1

tdf#93637 TAB_OVER_MARGIN support for a few more cases

It will be available in 5.1.1.

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 18 Timur 2016-01-22 14:04:34 UTC
Fixed. Please comment on backport to 5.0. Thank you.
Comment 19 Commit Notification 2016-01-29 10:13:31 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-5-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7b644045bebcd70e7324beac793b5018da1c4de5&h=libreoffice-5-0

tdf#93637 TAB_OVER_MARGIN support for a few more cases

It will be available in 5.0.6.

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 Justin L 2017-01-19 04:14:16 UTC
bug 35021 added support for left/center/decimal tabs-over-margin.  PDF support adjusted to enable those also.