Bug 142840 - FILESAVE DOC Hyperlinks to bookmarks break when saving to .doc
Summary: FILESAVE DOC Hyperlinks to bookmarks break when saving to .doc
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.0.0.3 release
Hardware: All All
: medium normal
Assignee: Vasily Melenchuk (CIB)
URL:
Whiteboard: target:7.4.0 target:7.3.4
Keywords: bibisected, bisected, filter:doc, regression
Depends on:
Blocks: DOC Bookmarks
  Show dependency treegraph
 
Reported: 2021-06-13 21:48 UTC by Pat Powers
Modified: 2022-05-13 09:35 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
LIbre office doc with Smashwords bookmarks (working) (19.97 KB, application/vnd.oasis.opendocument.text)
2021-06-15 03:25 UTC, Pat Powers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pat Powers 2021-06-13 21:48:46 UTC
Description:
I have been writing manuscripts for publication on Smashwords using LibreOffice 7.0.3.1 (x64) on a Windows 10 desktop computer, and a problem has cropped up with the table of contents. 

The Smashwords technique for creating a table of contents involves placing bookmarks at the beginnings of all your chapter headings (or anything else you want to show up in the table of contents) thorughout the manuscript. Then you type out your table of content listing and highlight each entry and create a hyperlink between it and the appropriate bookmark within your document.

After you do that, you can test your links by hitting control-click using the mouse. If it's set up right, you to directly to your bookmarked entry.

All that works fine, in Libre Office. But Smashwords prefers documents in Microsoft Word format. So before I upload the doc to Smashwords I convert it to a Word 97-2003 document using Save As.

I made a mistake there, I did not test my table of contents after converting it to Microsoft Word. (Possibly because I've never had a problem with it before.) But after I uploaded the file I bought a copy of the book and checked it out, and discovered that my table of contents didn't work in the Epub format. (For the record, I use Calibre for all my epub files.) 

That's when I checked my microsoft word document and discovered that the table of contents didn't work.  That's not completely true: the two table of contents entries that were on the same page as the table of contents worked fine. Everything else, when you did a Ctrl-click on the entry, nothing happened. Absolutely nothing.

 Going back to my Libre Office document (yes, I saved it, damned glad I did) I found that the table of contents worked fine. Every entry, the doc opened up right where it should be when I clicked on a tofc entry.

I then made a Microsoft Word copy of the Libre Office document again, to see if there had been some hiccough in the conversion process, and once again, the Table of Contents didn't work in the new Microsoft Word version -- and all I had done was convert it.

I figured the problem was the bookmarks and hyperlinks so I then spent a couple of merry hours deleting bookmarks and creating new bookmarks and setting up new hyperlinks to those bookmarks and testing them (always working fine in LibreOffice format, always screwed up after the doc is converted to Microsoft Word. (Also when testing an existing Microsoft word doc with new bookmarks and hyperlinks.)

I remembered that I never used to have this problem with Open Office (LibreOffice's predecessor). So I downloaded Open Office and  opened up my Libre Office doc in Open Office. It worked fine. I then saved the document in Microsoft Word format (specifically Microsoft Word 97/2000/XP format). I reopened it and the Table of contents worked just fine. So my problem is solved, I can just use Open Office to convert all my docs.

So my problem was solved (Yay!) but Libre Office still has a problem. And I'm pretty sure its the Libre Office document conversion process that's the problem, because the table of contents works fine in Libre Office format, and Open Office converts the document to Microsoft Word and the table of contents works fine.

It's only when the document is saved to Microsoft Word format in Libre Office that there's a problem with the table of contents.

On the advice of others I have downloaded and installed LibreOffice 7.1.4 and tried converting a working plain ODT document to Microsoft Word and got the same results: the table of contents does not work after conversion.

Steps to Reproduce:
1. Create a text document. It can be random gibberish, just make sure it's long enough to take up several pages -- don't create a document that's just one page long.
2. Create a series of headings in your text document (call them chapter headings if you like, like Chapter 1, 2, 3 ... etc.) Place a bookmark at the beginning of each or your headings. Make sure that at least some of your headings are not n the first page of your file.
3. Go back to the beginning of your document and create a table of contents listing, just the name of the headings (Chapter 1, 2, 3, etc. with each heading on its own line.
4. Link the entries in your table of contents to the appropriate bookmarks in your document. To do this, highlight the appropriate entry on your table of contents, then click on Insert Hyperlink under Insert menu. This will open the "Hyhperlink" window. On the left side of the window, click on "Document" and in the main portion of the window, go to "Target in Document" and click on the crosshairs to the right of the text box. This will open up the "Target in Document" window which will have a list of options inside it, one of which should be "Bookmarks" with a plus sign beside it. Click on the plus sign in front of "Bookmarks" and that should give you a list of the Bookmarks you've created in the document. Click on the appropriate bookmark, highlighting it, and then click on the "Apply" button at the bottom of the window and then click the "Close" button next to it. This will close the "Target in Document window. Now go back to the "Hyperlink" window and click on the "Apply" button at the bottom of the window and the "OK" button. This will close the Hyperlink window and you can now return to your document. Congratulations, you have now created a table of contents entry. Now do the same for every entry in your table of contents. (Tedious I know but this is how Smashwords wants tables of contents created for their Meatgrinder software.)

5. Once you have your table of contents created, test it by going to each entry in the table of contents, then holding down the control key and clicking on it with your mouse (ctrl-click) and you should immediately be sent to the heading you book marked. Repeat it for all your entries.

6. If you then save your document as a LibreOffice ODT file, close it and reopen it, then repeat the test, you should still have a functional table of contents.

7. Smashwords, however, prefers documents in Microsoft Word format, so if you save your document in Word 97-2003 format, close it and reopen it, then test the table of contents, nothing will happen if you click on the entries for the table of contents that are not on the first page. You will not go anywhere. Nothing will happen.

Actual Results:
When a table of contents is tested after its document has been converted to Microsoft Word format, nothing happens for any entries in the table that are not on the first page. You do not go to the bookmarked chapter heading.

Expected Results:
The software should have sent the user to the bookmarked location in the text corresponding to the appropriate entry in the table of contents.


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
In my text, each chapter heading that I bookmarked was in Heading 1 format, whereas the text was in "text body" format. So far as I know, this should not affect things, but hell, I'm not a software engineer.
Comment 1 Aron Budea 2021-06-14 04:47:44 UTC
To make this easier to reproduce, please attach a sample with steps 1-6. already performed. Thanks!
Comment 2 Pat Powers 2021-06-15 03:25:39 UTC
Created attachment 172879 [details]
LIbre office doc with Smashwords bookmarks (working)

I converted the sample uploaded to MsWord 97-2003 format and the table of contents did not work.
Comment 3 Buovjaga 2022-04-28 12:23:04 UTC
I reproduce this already with 6.3, but not with the latest commit in Linux 50max bibisect repository. Somebody could bibisect this - I don't have all the needed repos.

Pat: for now, you can save to the DOCX format. Hopefully Smashwords supports it. It doesn't have the problem.
Comment 4 Aron Budea 2022-04-28 20:29:16 UTC
This is a regression from the following commit, bibisected using bibisect-linux-64-6.0. Adding CC: to Vasily Melenchuk.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=aa3c0ddc61726f9e2e927e08966acd63a3fcf968
author		Vasily Melenchuk <Vasily.Melenchuk@cib.de>	2017-09-05 21:30:06 +0300
committer	Thorsten Behrens <Thorsten.Behrens@CIB.de>	2017-09-07 15:03:08 +0200

tdf#103090 replace spaces by underscore in bookmark names for DOCX.
Comment 5 Commit Notification 2022-05-12 01:28:20 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

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

tdf#142840: doc export: use BookmarkToWord() for hyperlinks

It will be available in 7.4.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 6 Commit Notification 2022-05-12 09:21:59 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

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

tdf#142840: doc export: use BookmarkToWord() for hyperlinks

It will be available in 7.3.4.

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.