Repository navigation
fix(odf): attach comments in picture-only paragraphs to the picture - #4650
devYRPauli wants to merge 3 commits into
Conversation
_add_odf_paragraph returned early for a paragraph that makes only an image or a chart. The comment threads of that paragraph then reached attach_rest and landed at the document root. The paragraph now attaches its threads to its first picture: a COMMENT_SECTION group in the NOTES layer, with a FineRef back-link. _add_odf_images and _add_odf_charts return the pictures they add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yash Raj Pandey <yashpn62@gmail.com>
The test now has a paragraph with two images, so it fails when the threads go to the last picture. It also has a paragraph with text and a chart. That paragraph keeps the comment on its text item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yash Raj Pandey <yashpn62@gmail.com>
|
✅ DCO Check Passed Thanks @devYRPauli, 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/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
AI triage (advisory)Checked commit The PR fixes ODT comment placement for paragraphs that make only pictures. Topic labels added: CI safety: no concern found. A maintainer must still approve CI. 1 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 71e6a5cf4b. It read the code and did not run it.
I found no defect. The change makes the early return in _add_odf_paragraph attach comment threads to the first picture. I checked the code paths and the regression test for it, and I did not run them.
A maintainer makes the merge decision. This review never approves the pull request.
Follow-up to #4436.
_add_odf_paragraphreturns early when a paragraph makes only pictures: an image with no other text, or a chart with only its replacement text. The return comes beforecomments.attach. The comment threads of that paragraph then reachattach_rest, and their groups land at the document root with noFineRef.The fix:
_add_odf_imagesand_add_odf_chartsreturn thePictureItemobjects they add, not a count.COMMENT_SECTIONgroup in theNOTESlayer under thePictureItem, and the picture gets aFineRefincomments. This is the contract of the other items since fix(odf): keep ODT comments out of the body text #4436.Checklist:
Review evidence:
Base
8aef0891(main) and head9a8b1475, on the ODT of the new test. The ODT has four paragraphs, and each paragraph has one comment.main#/body, noFineRef#/pictures/0,FineRefon the chart#/body, noFineRef#/pictures/1(the first image),FineRefon that image#/body, noFineRef#/pictures/3(the chart),FineRefon the chartFineRefon the text itemExports:
export_to_markdown(),export_to_html()andexport_to_text()do not change. They exclude theNOTESlayer.export_to_doctags()includes all layers. Onmainit prints the 4 comments. On this branch it prints only the comment of the text paragraph. A markdown or HTML export with theNOTESlayer changes in the same way.iterate_items(). It skips the children of aPictureItem, except captions, unlesstraverse_pictures=True. Withtraverse_pictures=Truein the serializer params, the markdown and DocTags serializers print all 4 comments, each right after its item.PictureItem, as the review of fix(odf): keep ODT comments out of the body text #4436 asks. To keep the comments in exports with default parameters, the group can be a sibling after the picture instead. TheFineRefon the picture stays the same.Tests and checks:
test_odt_annotation_in_picture_paragraph_goes_to_picturebuilds the ODT in code from the chart and image frames oftext_document_02.odt. Sotests/datadoes not change. The test checks which pictures are charts and the parent and text of each comment group. It also checks thecommentsof each picture and of the text item.main, the new test fails:[*charts, *pictures][-1]and(charts or pictures)[-1](pictures or charts)[0]and(charts or pictures[::-1])[0]chartstests/test_backend_opendocument.py: 52 passed onmain, 53 passed on this branch. This includes the ground-truth testtest_e2e_odf_conversions, with no reference-data change.prek run --fileson the two changed files, which is whatmake validateruns: all hooks pass, with no edits.tyreports 39 warnings onopendocument_backend.py, onmainand on this branch.test_cli.pyandtest_input_doc.pyalso use ODF files, but they only check format selection and do not convert.Not covered: a comment in a paragraph inside a text box. That thread still goes to the document root, as on
main. #4436 lists this case.