Repository navigation
fix(odf): keep ODS pictures anchored to the sheet - #4678
Conversation
_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>
|
✅ DCO Check Passed Thanks @usmanmateen, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit 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
The |
There was a problem hiding this comment.
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 <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 <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.
Signed-off-by: usmanmateen <usmanmateen255@gmail.com>
|
cc @PeterStaar-IBM: this is the |
There was a problem hiding this comment.
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.
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>
Resolves #4677
_find_images_in_sheetread pictures withimg.get_data(), which odfdo'sDrawImagedoesn'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:
Review evidence:
ConversionStatus.SUCCESS 1onmainandConversionStatus.SUCCESS 2with this change.test_ods_sheet_anchored_picture_is_keptbuilds a sheet with one picture in a cell and one in<table:shapes>and expects 2 pictures. It fails onmainwith 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 onmainplus the new test), with the same 3 warnings asmain.make validate: all hooks pass.