Skip to content

An edit changes one subtree and nothing beside it - #12

Closed
anderix wants to merge 1 commit into
save-before-anything-can-editfrom
an-edit-changes-one-subtree
Closed

anderix wants to merge 1 commit into
save-before-anything-can-editfrom
an-edit-changes-one-subtree

Conversation

@anderix

@anderix anderix commented Sep 21, 2026

Copy link
Copy Markdown
Member

The second slice of 0.4.0, on top of #11. The core can change a document in the three ways the views will ask for, and no view asks yet; each write is tested by mutating a corpus document and comparing everything else.

Element gains a path of child indices, mutable access by that path, and attribute writes. Document::name spells a new name in the prefix the document declares for its namespace on the content root. SheetDocument::set_cell writes a value by sheet, row and column, splitting a repeated row or cell run into before, the one, and after with the counts fixed, creating a row or cell past what the document wrote with one repeated empty run filling the gap, and refusing a covered cell or a formula. Presentation::set_geometry writes a shape's four svg: attributes in the unit each was read in. odox_core::edit edits a paragraph through its flat text built from the tree: characters come out of the nodes that hold them, new text goes into the node at the range's start, every zero-length element stays, whitespace is written the way ODF requires, and a split and a join are there for slice 5.

Checked: clippy with -D warnings, fmt, the catalogue check, and the full test suite, which now includes a sweep replacing six kinds of text across a grid of ranges in every paragraph of every corpus document, compared against string arithmetic, the marker count, and a re-parse. The base is #11's branch; GitHub retargets this to main when that one merges.

🤖 Generated with Claude Code

The core can now change a document, in the three ways the views will
ask for, and no view asks yet. Each write is tested by mutating a
corpus document and comparing everything else.

`Element` gains a path of child indices to reach a node again without
holding a reference into the tree, mutable access by that path, and
attribute writes; `Document::name` spells a new name in the prefix the
document declares for its namespace, so a document that writes `t:`
for the text namespace is written its own way.

`SheetDocument::set_cell` puts a value in a cell by sheet, row and
column. A row or cell the document wrote once with a repeat count is
split into the run before, the one, and the run after, with the counts
fixed, so the one changes and its neighbours in the run keep what they
had; a row or cell past what the document wrote is created, with one
repeated empty run filling the gap. A cell under a neighbour's span or
holding a formula is refused, and nothing moves. `Value::from_input`
reads what a person typed the way a spreadsheet does, and the cached
text is the value's shortest spelling, which a spreadsheet application
reformats from the value when it next opens the file.

`Presentation::set_geometry` writes a shape's four `svg:` attributes,
each in the unit it was read in. A shape placed by `draw:transform` is
refused rather than answered wrongly.

`odox_core::edit` edits a paragraph through its flat text, built from
the tree and not from the renderer's layout. Characters are deleted
from the nodes that hold them, new text goes into the text node at the
start of the range, every element that contributes no characters — a
bookmark, a frame, a field, a note — stays where it was, and
whitespace is then written the way ODF requires. Adjacent text nodes
are joined, because the parser keeps an entity reference as a node of
its own and two left side by side would not read back as themselves. A
split carries a zero-length element at the split point to the first
half. The test replaces six kinds of text across a grid of ranges in
every paragraph of every corpus document and checks the result against
string arithmetic, the marker count, and a re-parse.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@anderix anderix mentioned this pull request Sep 21, 2026
@anderix
anderix deleted the branch save-before-anything-can-edit September 21, 2026 22:21
@anderix anderix closed this Sep 21, 2026
@anderix anderix mentioned this pull request Sep 21, 2026
@anderix

anderix commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Closed by a branch deletion during a stacked merge, not by a decision: its commits reached main through #18.

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