Skip to content

fix(odf): keep ODS pictures anchored to the sheet - #4678

Merged
dolfim-ibm merged 3 commits into
docling-project:mainfrom
usmanmateen:fix-ods-sheet-pictures
Oct 14, 2026
Merged

dolfim-ibm merged 3 commits into
docling-project:mainfrom
usmanmateen:fix-ods-sheet-pictures

Conversation

@usmanmateen

Copy link
Copy Markdown
Contributor

Resolves #4677

_find_images_in_sheet read pictures with img.get_data(), which odfdo's DrawImage doesn't have, so every picture anchored to an ODS sheet was dropped with only a debug log. This reads the pictures in <table:shapes> and builds them with _image_ref_from_odf_image, like the other ODF pictures. Pictures anchored to a cell are left to the rich cell path, so they aren't added twice.

#4557 had a similar change (it skipped pictures with a table-cell ancestor), but it was merged into a stacked branch that didn't reach main.

Checklist:

  • Documentation has been updated, if necessary. (not needed)
  • Examples have been added, if necessary. (not needed)
  • Tests have been added, if necessary.

Review evidence:

  • The reproduction from ODS: pictures anchored to the sheet are dropped #4677 prints ConversionStatus.SUCCESS 1 on main and ConversionStatus.SUCCESS 2 with this change.
  • test_ods_sheet_anchored_picture_is_kept builds a sheet with one picture in a cell and one in <table:shapes> and expects 2 pictures. It fails on main with 1 (the sheet picture is dropped). A version that reads every picture of the table fails with 3 (the cell picture is added twice).
  • pytest tests/test_backend_opendocument.py: 56 passed (55 on main plus the new test), with the same 3 warnings as main.
  • make validate: all hooks pass.

_find_images_in_sheet read pictures with img.get_data(), which odfdo's
DrawImage does not have, so every picture anchored to a sheet (stored in
<table:shapes>) was dropped with only a debug log. Pictures anchored to a
cell were not affected, since the rich cell path adds them.

Read only the pictures in <table:shapes>, so cell pictures are not added
twice, and build them with _image_ref_from_odf_image like the other ODF
pictures.

Resolves docling-project#4677

Signed-off-by: usmanmateen <usmanmateen255@gmail.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @usmanmateen, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working odf Issue related to the OpenDocument format (ODT, ODS, ODP) backend labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit e4617b89b8. The analysis read the diff only. It did not run code from this pull request.

The PR changes `_find_images_in_sheet` in the ODS backend. It now reads pictures from `<table:shapes>` and builds them with `_image_ref_from_odf_image`. Before, `img.get_data()` failed and the code dropped these pictures. The PR adds two tests.

CI safety: no concern found. A maintainer must still approve CI.

2 related pull request(s) in the same code
PR State Signal Assessment
#4666 merged also references issue #4677 related: PR 4666 is merged. It makes `_image_ref_from_odf_image` convert CMYK pictures. It does not change `_find_images_in_sheet`, so the two changes do different things and do not conflict.
#4557 merged referenced as #4557 related: PR 4557 is a broad typing and contract change. One part of it also changes `_find_images_in_sheet`. That part skips pictures with a cell ancestor and uses `_image_ref_from_odf_image`. The PR text says 4557 did not reach `main`. The base file still has the old `img.get_data()` code, so this PR does not duplicate a change on `main`.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocking issue found

This review covers the full diff at cd00e88524. It read the code only. It did not run tests or code from this pull request.

The PR fixes a bug where pictures anchored to an ODS sheet (stored in &lt;table:shapes>) were always dropped. The old code called table.get_images() which returned images across the whole table, then called .get_data() on each — a method that does not exist on DrawImage objects — so every picture was silently discarded. The fix queries only &lt;table:shapes>//draw:image and processes each image through the existing _image_ref_from_odf_image helper, which handles the data-loading and format-normalization correctly. A new test builds a sheet with one cell picture and one sheet-anchored picture and asserts that exactly two pictures appear in the converted document.

A maintainer makes the merge decision. This review never approves the pull request.

Comment thread tests/test_backend_opendocument.py
Comment thread docling/backend/opendocument_backend.py
@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 8, 2026
Signed-off-by: usmanmateen <usmanmateen255@gmail.com>
@github-actions github-actions Bot removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Oct 8, 2026
@usmanmateen

Copy link
Copy Markdown
Contributor Author

cc @PeterStaar-IBM: this is the _find_images_in_sheet follow-up from #4666. Happy to adjust anything.

@github-actions github-actions Bot added the ai:ci-safe AI triage found no CI-safety concern (advisory) label Oct 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocking issue found

This review covers the changes since cd00e88524 at 0e5f8c7edf. It read the code only. It did not run tests or code from this pull request.

This PR fixes ODS sheet-anchored pictures being silently dropped by replacing table.get_images() / img.get_data() with table.get_elements("table:shapes//draw:image") and the existing _image_ref_from_odf_image helper, matching how other ODF pictures are handled. The incremental update adds one assertion (assert all(p.image is not None for p in pictures)) to the new regression test, which directly resolves the only open finding from the previous review round. No new issues are introduced.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 8, 2026
@usmanmateen usmanmateen mentioned this pull request Oct 8, 2026
3 tasks done
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Cover the branch where a sheet-anchored picture cannot become a bitmap
(SVG): it is skipped, as pictures in cells are.

Signed-off-by: usmanmateen <74776275+usmanmateen@users.noreply.github.com>

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dolfim-ibm
dolfim-ibm merged commit f3eda5f into docling-project:main Oct 14, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working odf Issue related to the OpenDocument format (ODT, ODS, ODP) backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ODS: pictures anchored to the sheet are dropped

2 participants