Created attachment 183902 [details] tableComment.docx: two comments spanning table border / cell borders MS Word allows a comment span to start and end pretty much anywhere. LibreOffice doesn't let it span across a table boundary. Perhaps a bit of intelligence can figure out whether it is better to span the comment outside or inside the table. At the moment the comment is just an anchor without any span. Steps to reproduce: 1.) open the file. The first comment should cover the text before the table and the contents A1. The second comment should cover 2, C2, D. Also note that the rest of the text in D2 is missing, and lost on a round-trip.
Created attachment 183903 [details] tableComment_mso2010.pdf: how it looks in Word
P.S. DOC format doesn't lose any text. It drops both spans and just has the anchor.
xCur = xTextRange->getText( )->createTextCursor( ); xCur->gotoEnd(false); xCur->goLeft(1, false); uno::Reference<text::XTextCursor> xCur2 = xTextRange->getText()->createTextCursorByRange(xCur); SAL_DEBUG("next line is our exception"); uno::Reference<text::XParagraphCursor> xParaCursor(xCur2, uno::UNO_QUERY_THROW); xParaCursor->gotoStartOfParagraph(false); The exception happens for both A1 and D2. This UNO mumbo-jumbo won't be easy to figure out. Low priority - this was a hand-modified example. Not so easy to create in the wild, but inspired by a client's example.
Created attachment 183917 [details] tableComment.docx: two comments spanning table border / cell borders The part about losing text is somewhat bogus. I accidentally crafted an invalid document. This one doesn't lose the cell text...
I don't see any way to resolve this (short of completely changing the LO model to accept comments that span table borders). Oh, sure, for a specific document with a comment at the very beginning of the table you could edge-case that as ending before the table, but that is a whole lot of complication for very little benefit. WONTFIX.
Justin Luth committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/61b5835fc81f1dec9c9e334a9f886f35997d1b56 related tdf#152305 writerfilter: avoid comment-related exceptions It will be available in 7.5.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.