Comments in a DOCX file might not import in the correct order. Steps to reproduce. 1.) Open commentsInWord.docx (attachment 193829 [details] from bug 160350) The order of the comments should look like attachment 193828 [details]. The comments were correctly ordered until LO 4.3's commit 0761f81643a6890457e9ef7d913ab5c88c2593a4 Author: Oliver-Rainer on Wed Jan 8 15:58:35 2014 +0100 123792: complete annotations on text ranges feature
The order they appear in word/comments.xml is the order in which they should appear in the document as well (at least for this example). Based on reading the 4.3 patch's writerfilter code, I don't see anything that would change the order. Indeed, it still calls PopAnnotation in this order: 0 // First coment (note that the 1 is from list numbering - which is lost in LO) 1 // 1.1 second reply. 3 // 1.2 third reply. Only reply on whole thread… 5 // 1.3 2 // 2. second comment 4 // 2.1
If I disable NS_ooxml::LN_EG_RangeMarkupElements_commentRangeEnd (so there is no range, just a single entry point) then the comments are back in the right order. So the problem is related to the fact that w:commentRangeEnd w:id="2/3/4"/> comes before <w:commentReference w:id="3"/> is inserted. Thus the remaining comments (2 and 4) try to import into SwPaM start[SwPosition (node 9, offset 10)] mark[SwPosition (node 9, offset 10)]
A wild attempt at a fix is at https://gerrit.libreoffice.org/c/core/+/166765
Justin Luth committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/7ae84ed99b133cdb4c197ecb43e2454f90b0439a tdf#160814 writerfilter: insert comment after other comments It will be available in 24.8.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.
Justin Luth committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/e7ea91a4af1242fcfa5f5ba5f04bbc6662453e28 tdf#160814 writerfilter: insert comment after other comments #2 It will be available in 24.8.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.
Created attachment 194014 [details] commentsInWordD.docx: this hand-crafted version isn't solved, but that is out of scope.