Saving some Writer files to MS Word 97-2003 (DOC) format mangles the comments. See the attached ODT file, where the comments are in order
Original comment 1 + Reply to this
In the saved DOC file, when opened in MS Word, the order is:
Original comment 1 + Reply to this
Another copy of Original comment 1
The others have disappeared, and Comment 2 is attached to the wrong text.
Actually, the comments are still in the file, because when the DOC file is opened in LibreOffice, it looks OK. So there is a problem is the export code that is compensated by the same error in the import code.
When saving this file as DOCX or RTF it opens correctly in MS Word.
Created attachment 113414 [details]
Original ODT file
Created attachment 113415 [details]
Saved DOC file that is corrupted
I found that Apache OpenOffice 4.0.1 does it right. Both the file I attached to this bug report and my original, much bigger file.
Confirming with test file on Word for Mac 2011
Confirming that AOO 411 exports the comments to DOC in correct order.
Comments can be attached to a range of text or to a single position in the text.
I found that the comments get mangled when there is a mixture of comments on ranges and on positions. When all comments in a document are on ranges, or all on positions then they are saved properly.
Also AOO does not support comments on ranges, so that is the reason that AOO doesn't have this bug.
I compared the AOO code with the LibreOffice code (it is in sw/source/filter/ww8/wrtw8sty.cxx) and found that the code there constructed a wrong datastructure in the mixed case mentioned above. I have not yet found what the proper way is – for that I have to do some more study of the specification of the Word binary format. One option would be to treat positions as a range with the same begin and end points. I have tried that and it solves the problem, but I think it also changes the semantics. Therefore I am currently looking for a better solution.
Created attachment 113911 [details]
Patch for this problem
Here a patch for this problem. It solves the problem and also some other problems with exporting comments to a .doc (MS Word 97-200) file that I encountered during testing.
I have tested this patch in LO 22.214.171.124.
That should have been:
(In reply to Piet van Oostrum from comment #8)
> I have tested this patch in LO 126.96.36.199.
That should have been LO 188.8.131.52
Summary of the problems this patch solves:
1) when there is a mixture of comments on ranges and comments on a point, the comments get mixed up
2) when there are nested and overlapping comments the begin and end points can get mixed up
3) when two or more comments are on ranges that have the same starting point (e.g. when one is a reply to an other one), only one keeps its starting point and the others only keep their end points
Created attachment 114053 [details]
Comprehensive ODT document
This file has all three cases in it that cause problems. The problems are only visible if the files is saved as .doc and then viewed in MS Word.
Buggy behaviour also reproducible with LO 184.108.40.206, Win 8.1
"Original comment 1" is shown two times as a comment box
"Comment 2" from Piet is missing
"Comment 3" and "Comment 5" seems to be interchanged
"Original comment 1" seems also to cover almost the whole text from paragraph 2 to the last paragraph
"Comment 6" and "Comment 7" from Piet are missing
Piet van Oostrum committed a patch related to this issue.
It has been pushed to "master":
tdf#89405 DOC export: fix corrupted comment order
It will be available in 4.5.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:
Affected users are encouraged to test the fix and report feedback.
Thank you for writing about the possibility of backporting to 4.3. and 4.4.
Both 4.4 and 4.3 EOL - removing request.