Skip to content

feat(ooxml): write the seven text properties onto a run of a docx or pptx - #896

Merged
andiwand merged 2 commits into
mainfrom
feat/set-text-style-ooxml
Sep 13, 2026
Merged

feat(ooxml): write the seven text properties onto a run of a docx or pptx#896
andiwand merged 2 commits into
mainfrom
feat/set-text-style-ooxml

Conversation

@andiwand

@andiwand andiwand commented Sep 13, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Step 3 of the inline formatting plan (docs/design/document-editing.md, decisions 11, 13 and 14). Rebased onto main after #895 merged.

The cut. A w:t and an a:t share their w:r / a:r with their siblings, so text_set_style cuts the run around the text with TreeEditor::isolate, each part keeping its w:rPr / a:rPr, and writes the delta into the part that holds the text.

docx. CT_RPr is a sequence Word enforces, so each property lands at its rank (run_property_order) and replaces an existing one whole, since a stale w:themeColor would win over a new w:val. w:bCs, w:iCs and w:szCs follow their siblings. A highlight is w:highlight for one of Word's sixteen names and a w:shd w:val="clear" w:fill shading otherwise; only one of the two stays. A test pins the saved w:rPr byte for byte between the w:rFonts and the w:lang the fixture had.

The reader learns w:shd on a run where no highlight names a colour, so a saved shading renders on reopen. Four corpus files carry one, and their reference pages are regenerated and pinned here: sample1 now shows its "inverse video" run white on black where it was white on white; 15KB, 23KB and physics carry white fills on runs, which Word paints too, and move one anti-aliased pixel column at most.

pptx. The toggles and the size are a:rPr attributes, the colour an a:solidFill and the highlight an a:highlight, each at its place in the CT_TextCharacterProperties sequence. A run without an a:rPr gets one ahead of its a:t; a highlight taken away removes the element, since there is no none.

Shared. ooxml_util gains insert_in_sequence, hex_color, highlight_name and points, over the one sixteen-name table read_color_attribute also reads.

Verified. 11 new DocumentEdit tests over inline docx and pptx packages and one reader test for the shading; 443 tests of the document, odf, ooxml and html suites pass; the touched sources are clean under Homebrew clang -Wall -Wextra -Werror. Headless LibreOffice reopens an edited style-various-1.docx and .pptx and reads every property back, the #123456 shading included.

@andiwand
andiwand force-pushed the feat/set-text-style-odf branch from 8841122 to 91c0702 Compare September 13, 2026 16:33
Base automatically changed from feat/set-text-style-odf to main September 13, 2026 16:39
…pptx

A `w:t` and an `a:t` share their `w:r` / `a:r` with their siblings, so
`text_set_style` cuts the run around the text with `TreeEditor::isolate`,
each part keeping its properties, and writes into the part that holds it.

`CT_RPr` is a sequence Word enforces, so each docx property lands at its
rank and replaces an existing one whole. A highlight is `w:highlight` for
one of Word's sixteen names and a `w:shd` shading otherwise; the reader now
takes `w:shd` where no highlight names a colour, which moves the reference
pages of four corpus files. In pptx the toggles and the size are `a:rPr`
attributes, the colour an `a:solidFill` and the highlight an `a:highlight`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137vd79NGaB8nfLsdPoghM4
@andiwand
andiwand force-pushed the feat/set-text-style-ooxml branch from 1454edb to dfafb19 Compare September 13, 2026 16:42
Four docx pages gain the run shading the reader now takes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137vd79NGaB8nfLsdPoghM4
@andiwand
andiwand force-pushed the feat/set-text-style-ooxml branch from 5f72729 to fc0a876 Compare September 13, 2026 16:48
@andiwand
andiwand merged commit 15acefa into main Sep 13, 2026
27 checks passed
@andiwand
andiwand deleted the feat/set-text-style-ooxml branch September 13, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant