https://bugs.documentfoundation.org/show_bug.cgi?id=170602

            Bug ID: 170602
           Summary: FILESAVE DOCX: corrupt document reported by MS Word
                    when content control (Sdt) ends in a bookmark
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Keywords: filter:docx
          Severity: normal
          Priority: medium
         Component: Writer
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
            Blocks: 104528

Created attachment 205360
  --> https://bugs.documentfoundation.org/attachment.cgi?id=205360&action=edit
bookmarkCorrupts_runSdt.docx: MS Word already considers this document to be
corrupt

This first comment actually describes a situation where LO current works well.
It even takes this corrupt document and round-trips it as a valid document...

MS Word easily complains that a document is corrupt, if a content control ends
in a bookmark.

A w:sdt is very particular about where a bookmarkEnd is placed. (bookmarkStart
doesn't seem to be a problem - it can start anywhere...).
Interestingly, bookmarkEnd can be placed OK in lots of strange places (inside
SdtPr, rPr), but it cannot be placed as the last item inside of the content
control.

Note that this is NOT universally true. Anywhere is fine with richText and
group. Tests as corrupt for w:text and w:checkbox.

<w:p>
  <w:sdt>
    <w:sdtContent>
      <w:r>
        <w:t> some content </w:t>
      </w:r>
      <w:r>
                 w:bookmarkEnd is OK here
        <w:t> ending content </w:t>
                 w:bookmarkEnd MUST NOT be here
      </w:r>
                 w:bookmarkEnd MUST NOT be here
    </w:sdtContent>
                 w:bookmarkEnd MUST NOT be here
  <w:sdt>
w:bookmarkEnd is OK here
</w:p>

At the moment, we seem to be OK with these paragraph-wrapped runSdt's. I think
we are outputting an empty w:r for the end marker, so our bookmark gets written
before the empty w:r. Or, if the bookmarkEnd was originally after the /w:sdt,
it gets written back to that spot again.


Referenced Bugs:

https://bugs.documentfoundation.org/show_bug.cgi?id=104528
[Bug 104528] [META] Saved DOCX files that MS Word can't open
-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to