fix(xlsx): resolve drawing-only sheet anchors with the Normal-font metric - #716
Merged
Merged
Conversation
…tric empty_sheet_context() hardcoded max_digit_width_px 7.0 and dropped the workbook Normal font, so every sheet with an empty <sheetData/> laid its drawing anchors out on column_width_to_pt(8.43, 7.0) = 44.2575pt columns. The same workbooks declare Calibri 11, for which the converter's own metric says 8.0px and 50.58pt — drawing-only sheets were 12.5% narrow by the converter's own model, pictures 8% aspect-distorted, and WithDrawing's content stopped reaching the second page-column. The digit-width derivation is now one shared helper, resolve_max_digit_width_px: the Normal-font metric when styles.xml is readable, else the dominant-cell-font fallback that on an empty sheet degrades to the legacy 7px. prepare_sheet_context uses the same helper (behavior-identical extraction), and both empty_sheet_context call sites (parse and streaming parse) pass the Normal font through. Measured on WithDrawing.xlsx against a fresh local Excel-for-Mac GT export: column width solves to exactly 50.58pt from two independent anchors (was 44.2575), tomcat.png's x error shrinks from -69.5pt to -19.0pt, clock.jpg's width error from -16.5% to -4.6%. Populated-sheet golden mocks are byte-identical. The audit decomposed every residual: our 50.58pt vs GT's measured 52.95pt/col default is the #621 metric-table gap; drawing extents still never split into page-columns (#713); declared <cols> widths are still ignored on drawing-only sheets (#714); GT lays default rows out at 17pt where the file declares 15 (#715); the text-box line pitch doubling is #656. Related: #620 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sheets with an empty
<sheetData/>but drawings/text boxes/charts resolved their anchors throughempty_sheet_context(), which hardcodedmax_digit_width_px: 7.0and dropped the workbook Normal font — laying every drawing-only sheet out on 44.2575pt columns where the converter's own Calibri-11 metric says 50.58pt. Pictures were 12.5% narrow and 8% aspect-distorted.The digit-width derivation is now a single shared helper
resolve_max_digit_width_px(Normal-font metric, falling back to the dominant-cell-font path that degrades to the legacy 7px on an empty sheet with unreadable styles).prepare_sheet_contextuses the same helper — a behavior-identical extraction — so the metric cannot drift between populated and drawing-only sheets. Bothempty_sheet_contextcall sites (parse and streaming parse) pass the Normal font through.Related issue
Fixes #620
Testing
cargo test --workspace— green (new red-first tests: an in-memory drawing-only workbook whose spliced twoCellAnchor picture must resolve x/width at the 50.58pt metric with the 44.2575pt legacy negative-asserted; a triangulation test pinning Calibri-11→8px, Calibri-8→6px, None→7px so a hardcoded 8.0 cannot pass)cargo +1.97 clippy --workspace --all-targets— clean;cargo fmt --check— cleanVisual impact
Visual audit
fixassets/bugfixes/issue-620/gt.jpgassets/bugfixes/issue-620/before.jpgassets/bugfixes/issue-620/after.jpgVisual comparison
Required inspection
Deviation audit
Checklist
Signed-off-byline🤖 Generated with Claude Code