Skip to content

feat(document): write the seven text properties onto a run of an odf file - #895

Merged
andiwand merged 1 commit into
mainfrom
feat/set-text-style-odf
Sep 13, 2026
Merged

feat(document): write the seven text properties onto a run of an odf file#895
andiwand merged 1 commit into
mainfrom
feat/set-text-style-odf

Conversation

@andiwand

@andiwand andiwand commented Sep 13, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Step 2 of the inline formatting plan (docs/design/document-editing.md, decisions 8 to 12). Rebased onto main after #893 and #894 merged.

API. Text::set_style(const TextStyle &) states the set fields on one run and leaves the rest. A set field is written, never removed, so bold off over a bold paragraph style stays off. A background_color with alpha 0 removes a highlight. font_name, font_shadow and font_position refuse with UnsupportedOperation. The hook TextAdapter::text_set_style defaults to UnsupportedOperation, so every engine but odf refuses it.

Op. setTextStyle {id, style}, one run per op. A toggle is a bool, a colour is #rrggbb, highlight: null is none, size is a length with a fixed size (pt, px, in, cm, mm, pc). Anything else refuses. The envelope stays at version 2.

{"op": "setTextStyle", "id": 41, "style": {"bold": true, "highlight": null, "size": "14pt"}}

odf. A run shares its text:span with its siblings, so TreeEditor::isolate cuts the span before and after it, each part keeping the span's shell; a run outside a span is wrapped in a new one. The span then points at a fresh automatic style T<n> (StyleRegistry::create_text_style): a copy of the cut span's automatic style plus the delta, a child of its named style, or the delta alone for a new span. An automatic style is never written into, because it may be shared. The new style joins the registry's index.

Verified. 13 new DocumentEdit tests over inline fixtures: bare run, run alone in its span, shared automatic style, named style, off over a bold paragraph, all seven properties, highlight: null, two ops on one run, the split-then-mark shape the browser emits, save and reload, the refusals. Headless LibreOffice reopens an edited about.odt and its docx export carries every property on the marked run.

Base automatically changed from fix/text-decoration-one-declaration to main September 13, 2026 16:27
…file

`Text::set_style` states the set fields of a `TextStyle` on one run, and the
edit envelope carries it as `setTextStyle {id, style}`. A set field is
written, never removed; `background_color` with alpha 0 removes a highlight.

A run shares its `text:span` with its siblings, so the odf engine cuts the
span around it (`TreeEditor::isolate`) or wraps a bare run in a new one, and
points it at a fresh automatic style: a copy of the span's automatic style
plus the delta, or a child of its named style. The hook defaults to
`UnsupportedOperation`, so the other engines refuse it.

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-odf branch from 8841122 to 91c0702 Compare September 13, 2026 16:33
@andiwand
andiwand merged commit 5f81bba into main Sep 13, 2026
32 checks passed
@andiwand
andiwand deleted the feat/set-text-style-odf branch September 13, 2026 16:39
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