mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-10 12:20:12 -06:00
## What changed Word stores paragraph indents (`w:ind` left/start, right/end, hanging, firstLine) in 16 signed bits and paragraph spacing (`w:spacing` before/after) in 16 unsigned bits. A file that writes a larger plain integer is read by Word modulo 2^16: `w:left="66256"` is a 720-twip (0.5") indent in Word. We read the full value, so such a paragraph was indented by about 46 inches and its text was pushed off the page. - `crates/docx/src/units.rs`: new `tw_i16` / `tw_u16` readers. A plain integer keeps its low 16 bits (two's complement for indents, so 66256 -> 720 and 65535 -> -1); values with a unit or a fraction read as before. - `crates/docx/src/read/props.rs` and `read/styles.rs` use them for `w:ind` and `w:spacing` before/after, in direct and style formatting. - In-range values read exactly as before. ## Testing - `crates/docx/tests/it/twips_wrap.rs`: synthetic documents with out-of-range indents and spacing in paragraph and style properties check the wrapped values; in-range values and values with units are unchanged. - Unit tests for the two readers; `cargo xtask ci` passes. Found by a real-file corpus comparison against Word's own PDFs: a file whose indents exceed 16 bits shows its text on the page in Word and off the page here. Co-authored-by: tpawley2001 <268951182+tpawley2001@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Martin Ball <martin.ball@ucscaregroup.co.uk>
48 lines
941 B
Rust
48 lines
941 B
Rust
mod alt_chunks;
|
|
mod bidi;
|
|
mod bidi_runs;
|
|
mod border_lines;
|
|
mod cell_margin_inheritance;
|
|
mod char_units;
|
|
mod citations;
|
|
mod comment_save_cost;
|
|
mod complex_script_inheritance;
|
|
mod content_control_save_cost;
|
|
mod content_controls;
|
|
mod custom_xml;
|
|
mod default_size;
|
|
mod drawing_payload;
|
|
mod east_asian_lang;
|
|
mod east_asian_layout;
|
|
mod emphasis_marks;
|
|
mod fixtures;
|
|
mod glossary;
|
|
mod heading_levels;
|
|
mod legacy_forms;
|
|
mod ligatures;
|
|
mod malformed;
|
|
mod nested_block_controls;
|
|
mod note_comments;
|
|
mod passthrough;
|
|
mod picture_links;
|
|
mod positional_tabs;
|
|
mod privacy;
|
|
mod roundtrip;
|
|
mod row_property_exceptions;
|
|
mod run_props;
|
|
mod section_form_protection;
|
|
mod section_metadata_preservation;
|
|
mod section_page_number_type;
|
|
mod section_text_direction;
|
|
mod section_valign;
|
|
mod settings_merge;
|
|
mod strict_drawings;
|
|
mod text_alignment;
|
|
mod text_boxes;
|
|
mod toc_ranges;
|
|
mod twips_wrap;
|
|
mod undefined_style;
|
|
mod vml_shapes;
|
|
mod word_xml;
|
|
mod wordml2003_write;
|