docling icon indicating copy to clipboard operation
docling copied to clipboard

ODP slide comments become slide body text

Open devYRPauli opened this issue 1 month ago • 4 comments

Bug

LibreOffice Impress saves a slide comment as an officeooo:annotation element. The element is the last child of the draw:page, after the shapes and presentation:notes. LibreOffice writes it in SdXMLExport::exportAnnotations (xmloff/source/draw/sdxmlexp.cxx).

OdpDocumentBackend._walk_slide skips anim:par and presentation:notes. It passes the children of every other non-frame element to _walk_textbox_children. That method adds each text:p as a text item. The comment text becomes slide body text. The backend drops the author and the date. The NOTES layer stays empty.

The PPTX backend puts slide comments in a COMMENT_SECTION group in the NOTES layer. Since #4436, the ODT backend does the same. No ODP file in tests/data/odf/sources has a slide comment.

Steps to reproduce

from docling_core.types.doc import ContentLayer
from odfdo import Document, Element, Paragraph

from docling.document_converter import DocumentConverter

source = Document("presentation")
slide = source.body.get_draw_pages()[0]
for presentation_class, text in [("title", "Q3 results"), ("subtitle", "Revenue grew 4%.")]:
    frame = slide.get_frame(presentation_class=presentation_class)
    frame.get_element("draw:text-box").append(Paragraph(text))
slide.append(
    Element.from_tag(
        '<officeooo:annotation svg:x="20cm" svg:y="1cm" svg:width="0.6cm" svg:height="0.3cm">'
        "<dc:creator>Ann Reviewer</dc:creator>"
        "<meta:creator-initials>AR</meta:creator-initials>"
        "<dc:date>2024-01-15T10:00:00</dc:date>"
        "<text:p>Check this number.</text:p>"
        "</officeooo:annotation>"
    )
)
source.save("slide_comment.odp")

document = DocumentConverter().convert("slide_comment.odp").document
for item, _ in document.iterate_items(included_content_layers=set(ContentLayer)):
    print(item.label.value, item.content_layer.value, repr(item.text))
print(document.export_to_markdown())

Output on main (8aef0891):

title body 'Q3 results'
text body 'Revenue grew 4%.'
text body 'Check this number.'
# Q3 results

Revenue grew 4%.

Check this number.

Expected: the markdown has no comment text. The comment is in a COMMENT_SECTION group in the NOTES layer, with its author and date, as in the PPTX backend.

Docling version

Docling version: 2.135.0
Docling Core version: 2.100.0
Docling IBM Models version: unknown
Docling Parse version: 7.22.2
Python: cpython-313 (3.13.14)
Platform: macOS-27.0.1-arm64-arm-64bit-Mach-O

Python version

Python 3.13.14

devYRPauli avatar Oct 07 '26 14:10 devYRPauli

Thanks for the thorough report — the LibreOffice export reference and the pointer to how the PPTX backend (and the ODT backend since #4436) handle slide comments make the expected behavior clear. I'd like to work on a fix for the ODP backend.

Kylinny avatar Oct 07 '26 15:10 Kylinny

This is a legit bug in docling's ODP backend. The _walk_slide method doesn't filter out officeooo:annotation elements, so their text:p children get treated as regular slide body text instead of comments.

Here's the fix. In docling/backend/docling_parse/doc_parser_v1/odp_document_backend.py (or wherever OdpDocumentBackend._walk_slide lives), you need to add officeooo:annotation to the skip list alongside anim:par and presentation:notes. Something like:

  1. Find the loop in _walk_slide that iterates over draw:page children. 2. Where it checks if child.tag in (ANIM_PAR, PRESENTATION_NOTES): continue, add the annotation namespace too. The tag is {urn:ooo:names:experimental:ooo-ms-interop:xmlns:field:1.0}annotation or you can match on the local name officeooo:annotation. 3. To actually capture the comment content into the NOTES layer (like PPTX and ODT do), collect the text:p, dc:creator, and dc:date children from each annotation element, then emit them as a COMMENT_SECTION group in ContentLayer.NOTES, same pattern the PPTX backend uses.

If you just want to stop the pollution right now without full comment support, the one-line fix is adding the annotation tag to the skip set. That immediately prevents comment text from leaking into body content.

For the test, create an ODP with odfdo (as your repro script does), drop it into tests/data/odf/sources, and assert that the annotation text doesn't appear in the main body items and does appear in the NOTES layer.

I'd open a PR with this, the fix is small and well-scoped.

What if every time you hit a problem like this, someone just fixed it for you right inside your document? That's exactly what ME Office AI does. Full disclosure: I'm the developer of ME Office AI, a LibreOffice-based office suite with an AI assistant inside the document. https://apps.microsoft.com/detail/9PCV4RCJCFXV?cid=gh-meoffice

radelqui avatar Oct 07 '26 15:10 radelqui

The fix is ready for review: https://github.com/docling-project/docling/pull/4653. Thank you for the detailed report — the repro script and the pointer to the PPTX/ODT comment handling made the fix straightforward.

Kylinny avatar Oct 07 '26 15:10 Kylinny

Classification labels added: priority:medium.

These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.

github-actions[bot] avatar Nov 16 '26 15:11 github-actions[bot]