fix: preserve hyperlink ranges and register comments on their anchor cells #1340
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1340"
general
weight: 0.35
skytin1004
<!--
Thanks very much for contributing to Apache Fesod (Incubating)! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
Closed: #ISSUE
Related: #ISSUE
-->
Purpose of the pull request
Fix the two remaining downstream paths of #1332: hyperlinks with an explicit range, and comments with an explicit anchor. Both lose the requested position after Fesod hands it to POI. POI rewrites the hyperlink range inside
setHyperlink, andsetCellCommentregisters the comment on the data cell instead of the anchor cell.Related: #1332
Related: #1333
Related: #1341
Why these two changes are in one PR
I originally split them into #1340 and #1341 to keep one PR to one problem. That split turns out to be worse here. Both paths depend on the same shared helper change in #1333, where
StyleUtil.getCellCoordinatestarts accepting an absolute index of0. Once that change is in main, a comment anchored atA1while writingB2is checked againstA1by POI, while the registered reference does not necessarily follow it. Landing only the hyperlink fix would leave main in a half-fixed state, with comment ownership still inconsistent between streaming and in-memory writes.These two changes are two halves of one fix for #1332, not two unrelated problems. Keeping them in one PR lets the maintainers review and land the complete change together. #1341 has been closed in favour of this PR. Please keep #1332 open until this PR lands.
What's changed?
Hyperlink range
fillHyperLinkused to hand the range to POI before attaching it:setHyperlinkthen replaced the reference with the cell it was called on, so aHyperlinkDatacoveringA1:C3collapsed onto its own cell and the requested corners were lost. The four values are now computed first and applied aftersetHyperlink. Nothing else in the method changes.Comment ownership
fillCommentended withcell.setCellComment(comment), which attaches the comment to the cell that carries the data. POI uses the anchor and the stored reference for two different things:CommentsTable.createNewCommentlooks a comment up by the top left corner of its anchorXSSFCell.setCellCommentstores the reference of the cell it is called onSo a comment anchored at
A1while writingB2was drawn atA1but stored underB2. The reference is now taken from the anchor:Comment.setAddressexists on bothXSSFCommentandHSSFComment, so the streaming and the in-memory writer go through the same line. Nothing else in the method changes. Two comments anchored at the same cell are still rejected with the sameMultiple cell commentsmessage. That rejection is intentional, and the point of this change is that the rejection now matches where the comment is drawn.Why this needs #1333
Both halves need
StyleUtil.getCellCoordinateto accept an absolute index of0. Before that change, absolute0was ignored and anA1range or anchor silently fell back to the data cell. #1333 owns that helper change. Neither of the two commits owned by this PR modifies it; theStyleUtilchange comes from #1333 and will disappear once this branch is rebased.About the commit list
This branch is still stacked on the head of #1333, so the commit list also shows
c34893a7and the merge commit45b16dabfrom that PR. The first is the author's commit from #1333, the second was created when a maintainer updated that branch withmain; both are carried here only so the two fixes can be exercised on top of them.The two commits that belong to this PR are
87f72468(hyperlink range) and12827e21(comment ownership, folded in from #1341). Once #1333 lands I will rebase ontomainand force-push, after which the diff contains only those two commits.Scope
Two production methods in
AbstractExcelWriteExecutor,fillHyperLinkandfillComment, plus two new test classes. The shared helper from #1333 is left untouched.Tests
HyperlinkRangeWriteTestruns every case on both XLSX and XLS: an explicit rangeA1:C3, no coordinates, a range away from the originC2:E4, relative offsets, a negative absolute index, and two links with different ranges in one sheet. 12 cases, green on JDK 8 and JDK 21.CommentAnchorOwnershipTestruns every case on both XLSX and XLS: no coordinate, an absolute anchor, relative offsets, a negative absolute index, two comments with different anchors, the anchor and the owner agreeing, and the duplicate case in both the in-memory and the streaming writer. 16 cases, green on JDK 8 and JDK 21.Both test classes were run before the two fixes were combined, with
spotless:checkandcheckstyle:checkpassing at that point. I will rerun them on the combined branch and report the result here.Checklist