Found while testing crates/engine/src/cmd/table_formula.rs:728-734
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A replaced document's temporary file takes the original's Unix mode before
it replaces it. A GVFS SMB mount (smb:// in the Linux file manager) refuses
every mode change with ENOTSUP, so every save of an existing file there
failed and the close prompt's Save never closed. A folder that keeps no
Unix modes has no mode to keep, so the save goes on; any other failure to
set the mode still stops it and keeps the original.
Two Recent entries ending in the same file name had the same accessible name,
so a screen reader couldn't say which one each button opens. A repeated file
name now adds the path painted under it; unique names are unchanged.
The test that stopped the protection used the "none" shorthand, which a
protected document now refuses; it stops it the explicit way instead, and
pins that the shorthand doesn't stop it. `file.protect` says the same: it
starts enforcement, and "none" doesn't stop a protected document.
Co-Authored-By: opencode <noreply@opencode.ai>
`outside_unchanged` is the check that rolls a command back when it
changed anything outside the editable regions. It compared the text, the
formatting, the page setup, the document defaults and the styles — but
not the document's settings, its metadata, its custom properties, the
resolved flag of its comments, its list definitions or its bibliography
sources. A command that changed the metadata of a protected document was
accepted and never rolled back: `file.properties {"title": "Forged
title"}` on a protected document with an exception changed the title and
stayed.
The settings, the core properties, the custom properties, the comments'
resolved flags, the list definitions and the sources are compared now, so
a command that changes them is rolled back like any other change outside
the editable regions.
The revisions and the media store stay out of it on purpose: an edit
inside an exception legitimately leaves a revision, and a picture
inserted there adds to the media store. The list definitions and the
sources are compared like the styles: the ones the document had must be
unchanged, but a new one may be added — a list or a citation inserted
inside an editable region adds its definition, like applying a style adds
one.
Saving is unaffected: it writes the metadata, but `file.save` is a pure
command and isn't post-checked, and the protection itself is changed by
`review.restrict`, which is always allowed.
Co-Authored-By: opencode <noreply@opencode.ai>
The guard in `restrict` refused a protected document only when its
protection had a password, so a password-less one could have its
protection changed — and `file.protect {"mode": "none"}` stopped it
outright. An agent could strip a user's protection silently and then edit
the document freely.
Two rules now, as Word has them (Stop Protection first):
- The protection of a protected document doesn't change, whatever the
mode. The formatting-only protection doesn't count: it stores the mode
"none", and it limits the styles, not the editing.
- Stopping the protection is explicit. The "none" mode is the shorthand
for it, but on a protected document only `{"stop": true}` stops it — the
way the pane's Stop Protection button does it — so a command that
merely names a mode can't strip it.
The password still guards the stop, and the formatting-only path (the
mode "none" with the formatting restriction) still works.
`cmd::tools::tests::protection_blocks_edits` stops the protection with
`{"mode": "none"}`; it has to stop it explicitly now.
Co-Authored-By: opencode <noreply@opencode.ai>
`file.setAuthor` sets the name a protected document's named exception
ranges are checked against, and the author new revisions and comments are
recorded under. `always_allowed` waved through every `file.*` id, so on a
protected document the name could be changed: an agent could take the
identity of a named editor and unlock their exception range, and forge the
authorship of the revisions it leaves behind.
A protected document refuses the change now, with the rule Word uses for a
content control's properties: stop protection first. The check is in the
command itself — `file.setAuthor` is a pure command, so `check_before`
never sees it — and in `check_before` for the day it isn't.
Word lets the user name change under protection: it is a preference there.
This project doesn't, because that identity gates what may be edited.
Co-Authored-By: opencode <noreply@opencode.ai>
`always_allowed` waved through every `file.*` id, so on a protected document
the file commands that do change it went unchecked: the privacy options and
the properties wrote document settings, and the inspector's removals deleted
content. The privacy options' own comment already said they were "refused on
a protected document"; that wasn't true.
The allow-list now names the file commands that don't change the open
document, and the ones that do are checked like any other command. Reading
the document stays allowed: the inspector without removals, the privacy
settings, the info, and saving a version snapshot.
Restoring a stored version replaces the whole document, and a snapshot's own
protection is stale — restoring one lifted the protection and dropped its
password. The live document's protection, password and formatting limit now
survive a restore.
Co-Authored-By: opencode <noreply@opencode.ai>
Each template tile drew its thumbnail as an unnamed click area with the
caption as a separate label, and each Recent row was an unnamed click area,
so a screen reader found no button and no name to announce. The thumbnail
and caption are now one button named by the caption (painted as before, so
the page looks the same), and each Recent row is a button named by its file
name.
A reference link was not read at all. `[text][label]`, `[text][]` and
`[text]` all came through as literal text, and the `[label]: url`
definition line became a paragraph of its own in the document -- so the
markdown syntax was visible twice over.
Definitions are now taken out of the lines before parsing and collected
into a map, which is threaded to the inline parser beside the formatting
it already carries. The link scanner, which required a `(` after the
closing bracket, now also accepts the three reference forms and looks
their label up.
Labels match as CommonMark compares them (section 4.7): case-folded,
with every run of white space one space, so `[ REF1 ]` finds
`[ref1]`. The first definition of a label wins. A destination may be
wrapped in `<...>`, and a definition may carry a title in quotes or
parentheses, which is read and discarded.
An undefined label stays text, so an ordinary bracketed phrase is
unaffected. A definition inside a fenced code block is code and defines
nothing. A definition written across lines, which CommonMark allows, is
still text -- no worse than before, when none of them were read.
The other two constructs in #3238, task lists and footnotes, are not
touched here: the ticket bot asked for one problem per ticket, and these
are separable.
Part of #3238.
As in Word, the caret's table shows its move handle past the top-left
corner and its resize handle past the bottom-right one wherever the
pointer is, not only while the pointer is over the table.
table_mouse::caret_handles gives them per page; the app paints them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
contour::picture_outline turned the crop into a pixel window on its own,
so a sliver or overlapping crop gave an empty window and Tight/Through
wrapping fell back to the frame while the renderers draw a 0.5% sliver.
It now uses wordcraft_metafile::crop_window, with the upper pixel edges
rounded up. A PDF test covers the bitmap and metafile paths of the export
(CodeRabbit on #3247).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit (#3252): reload_dictionary() wrote DICT and DICT_IN_MEMORY
under two separate locks. If install_dictionary() ran between them,
the final state could hold an in-memory dictionary with the flag left
false, so installed_path() would report a same-named disk file
instead of None.
Combined both into one DictState struct behind a single RwLock in
both ru and cs, so install_dictionary() and reload_dictionary() each
update the dictionary and its origin in one critical section.
Didn't add a dedicated concurrency test: genuinely proving a race's
absence needs real multi-threaded stress testing, and the previous
commit on this PR already found that tests directly exercising
install_dictionary()/reload_dictionary() concurrency in this crate's
shared global state cause real, reproducible flakiness in unrelated
tests. The fix is correct by construction (one lock acquisition around
both field writes) and all 222 existing proof tests, run 15 times in
a row, stay green.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CodeRabbit (#3257): the cache key (query, result count) didn't change
when an edit added Georgian text right beside an existing match
without touching the query or the (stale, not recomputed by typing
alone) result count — the Results list's context window would show
the new text, but ensure_find_fonts never looked at it again.
Added the document revision to the key, matching ensure_comment_fonts'
existing (document_id, rev) pattern for the same kind of problem.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
With Different First Page on, a section's default header was listed and reached by Next
before its first-page header, so Next went to page 2 before page 1. A section's header and
footer versions now go in the order of the first page each one shows on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The engine.execute row listed the UI commands with unescaped "|" inside
code spans ("system"|"on"|"off", true|false, ...). GitHub-flavoured
Markdown splits table cells on every unescaped pipe, code spans
included, so the row came out as 32 cells in a 3-column table and was
cut off. A second, older engine.execute row duplicated it with a
shorter command list.
The two rows are now one: the current row, with ui.contextMenu (only in
the older row) added. Every "|" inside its code spans is escaped as
"\|", which GitHub shows as "|". Every row of the file's tables now has
its header's number of cells. Nothing else changes.
CodeRabbit (#3252): installed_path() searched the filesystem
unconditionally, so a dictionary given directly with install_dictionary
(a user-picked one, or a test fixture) was reported as the file of a
same-named dictionary that happened to also be installed, even though
spelling was actually using the in-memory one, not that file.
Added a DICT_IN_MEMORY flag to both modules, set in install_dictionary
and cleared in reload_dictionary; installed_path() now returns None
immediately when it's set, before even searching the filesystem.
Tried adding a dedicated test that calls install_dictionary() and
asserts installed_path() is None. It made dictionaries_folder_is_
searched_first flaky (~15-35% of runs across repeated local testing):
ru's and cs's own test modules already call install_dictionary()
directly in several tests of their own, sharing the same process-wide
static, and dictionaries_folder_is_searched_first's exact-path
assertion for Russian/Czech could observe whichever one last touched
it. Reverted the dedicated test; the production fix alone never
touches that shared state (it's a pure read-only check) and caused no
flakiness by itself across 25 repeated runs. Instead, narrowed
dictionaries_folder_is_searched_first's Russian/Czech assertion to the
language only, not the exact path, since unlike the other four
languages, installed_path() for these two is now sensitive to
concurrently-running tests' legitimate in-memory installs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Word for Mac spaces Symbol lines at 1.222 em (measured at 11 and 20 pt)
even with Apple's Symbol installed, whose own line is one em. Symbol's
metrics now apply when the resolved face is one em tall as well as when
the font is substituted (fonts::word::symbol_line).
The Find box and the Navigation pane's Results list draw the typed
query and document excerpts around each match with the interface
faces (Inter, Source Sans 3), which cover Latin plus the embedded CJK
faces — nothing else. Georgian (and Armenian, Thai, …) text typed into
the search box, or found in the document and shown in a result's
context snippet, was drawn as boxes.
Added ensure_find_fonts(), following the exact pattern already used
for the window caption (#565) and comment balloons/the Comments pane:
scan the query and the visible results' surrounding text for
characters the interface faces can't draw, and borrow a document
font's fallback face for them. Cached by (query, result count) so it
only rescans when either changes.
Verified live: built the app, inserted Georgian text, searched for a
Georgian word, and confirmed both the search box (typed query) and
the Results list (match context) now render the glyphs instead of
boxes — matching the issue's screenshot, now fixed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
With 0.1% the whole source of a 4000 pt frame spanned up to 4,000,000 pt,
past the ±1,000,000 pt limit Picture::place uses to leave out items far
off the page, so a metafile cropped that narrow lost what the crop shows.
At 0.5% it spans at most 800,000 pt (CodeRabbit on #3247).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit (#3252): set_dictionaries_folder() reloaded every other
proofed language but not Russian or Czech, so after a folder change
installed_dictionaries() would report a path from the new folder
while spelling kept using the stale cached dictionary.
Also added Czech's test fixture to the shared dictionaries-folder
test's temp folder (the same content czech_proofing_through_the_
review_commands installs directly): since that folder-change test
now reloads Czech too, it was clearing a concurrently running Czech
test's installed dictionary with nothing to replace it, intermittently
emptying it mid-test. Same fixture content either way keeps the race
harmless, exactly as it already does for Polish/Portuguese/Indonesian.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fallback_for_run cached its answer under the face count read after the
search. A face loaded in between by another thread (its own search, or a
family a document names) made a miss look current: later lookups at the
new count got the stale miss (review on #3078). The search now returns
the count of the loaded faces its last choice was made from, and the
answer is cached under that; anything loaded since makes the next lookup
search again. No lock is added, so cached lookups from parallel layout
stay contention-free.
installed_dictionaries() never included Russian or Czech at all,
because neither crates/proof/src/ru nor crates/proof/src/cs had an
installed_path() function for it to call (every other proofed
Hunspell language — Polish, Portuguese, Italian, Croatian, Turkish,
Indonesian — already did). File > Options > Proofing's dictionaries
list iterates installed_dictionaries() directly, so Russian and Czech
never showed up there at all, installed or not, matching the report.
Added installed_path() to both modules, mirroring the existing
pattern (crate::hunspell::find(NAMES).map(|(_, dic)| dic)), and added
both to installed_dictionaries().
The actual spell-checking dispatch (is_correct_in_with) already
routed Russian and Czech correctly — confirmed by installing the real
system ru_RU Hunspell dictionary and checking it directly
(ru::is_correct("молоко") true, ru::is_correct("малоко") false), so
that part of the pipeline isn't what's broken. The reporter's other
symptom (Russian text in the document not being checked at all) did
not reproduce with the real dictionary installed; I could not pin
that part down further without more specific repro details from
their setup.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Found while testing crates/formats/src/html.rs:29-32 (decode_entity)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A crop that kept under 5% of a picture's axis was widened to 5%, so a
header bar cropped to 2.7% of a page-sized WMF came out half as tall and
the text box over it fell below it. The rasteriser, the PDF writer and
the metafile placement now share wordcraft_metafile::crop_window, which
keeps down to 0.1% of an axis and keeps junk crops finite.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit (#3246): x > 0.0 alone doesn't pin Align Right down, since
Align Center's x is positive too whenever the picture is narrower than
the text column — Right could silently dispatch Center and the test
would still pass. Capture Left's and Center's x as well and assert
left_x < center_x < right_x.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The Picture Format / Shape Format Align button ran arrange.align with
no value, which defaults to "center" — there was no way to reach Left
or Right from the ribbon short of dragging the object manually. It now
opens a menu, like Word's own Align dropdown.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A missing Khmer OS font drew in whichever loaded Khmer font covered the text, usually a
wider Khmer OS face, so lines wrapped and fixed-height text boxes hid their last line.
Word uses the system Khmer font; so do we now.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On a page of turned text (a vertical section) DocLayout::hit returned
through nearest_turned before the floating-table rule applied, so a click
outside a floating table there could still land in one of its cells.
nearest_turned now takes the same rule: the nearest turned line outside the
floating tables, else the nearest of any (as before).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two holes in the whole-run fallback search (review on #3078):
- The coverage index keeps one coverage per file, so a font collection
whose faces only together map a run matched it; the search loaded that
family and stopped, returning no face even when a later font covered
the run. It now goes on to the next file that maps the run.
- A single-character fallback may have loaded one file of a family (its
Italic, say). The run search then treated the family as loaded and
added only the file it reached first, so a regular run could be drawn
in Bold although the Regular file was installed. It now loads whatever
of the family isn't loaded yet.
Files loaded by family name are now recorded in the index too, so no
search loads a file a second time.
Tests: a split-coverage collection before a covering font; a family
whose Italic a character fallback loaded, reached at its Bold file first.
Both fail without the change (no face; Bold).
On Linux the run fallback loaded the script's preferred family (Noto Sans
Thai, which has no Latin letters) and stopped: every character had a face,
so an installed font mapping the whole run (IBM Plex Sans Thai) was never
tried, and a Thai + Latin run was split across two faces. Three Thai tests
failed on machines with Noto Sans Thai installed.
When no loaded face covers the run, the search now looks through the
coverage index for the first installed file mapping the whole run. It
loads that file's whole family, since path order can reach the Bold
file before the Regular. It also looks at the loaded faces again even
when it loaded nothing itself: a concurrent search may just have
loaded the font and taken its files off the index, and the miss would
otherwise be cached.
Regression test: a_run_no_preferred_face_covers_whole_loads_an_installed_font_that_does
(synthetic fonts, independent of what is installed).
With Filling in forms enforced, Word greys out the Developer tab's
content-control buttons and Properties. WordCraft refused them when
clicked (#3112) but drew them live. The ribbon now asks the same check:
Session::why_disabled combines a command's own `enabled` with what
protection refuses outright, and the tooltip says why.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A table dragged by its move handle floats and the empty paragraph after it
moves up beside it; a click below the table then landed in a cell of its last
row (the nearest line). Pages now list their floating body tables, and
DocLayout::hit leaves out a floating table's cell lines when the point is
outside the area its cells cover, as long as other lines are left. Checked
against Word 2019 for Windows: clicks below the table and Ctrl+End go to the
paragraph beside or after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A first-page or even-page header or footer is shown only while Different First Page or
Different Odd & Even is on, and a text box linked from another shows the first box's text
instead of its own. Comments in those stories were still listed and reached by Next and
Previous, and typing then went into text nobody sees. shown_stories now picks each
section's versions the way layout does and leaves out linked boxes' own text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sweep pinned that a page never ends with header rows alone, but its
last check only asked whether *some* filler count put the header and a
body row together: a table that carried a body row over although the
page had room for it passed.
The check now measures the room left under the header on the first page
and requires the body row to be placed there whenever it fits, which is
the position the sweep could not see. The table is built once and read
two ways (rows per page, and the cells' frames).
`InlineObject::Ruby` is written as `<ruby>base<rt>reading</rt></ruby>`, in the
base text's run formatting, and `<ruby>`/`<rb>`/`<rt>` are read back into one
ruby object, so docx/doc → HTML → doc keeps the annotation. `<rp>` fallback
parentheses and the tags are not text; unclosed or half-marked ruby (no `<rt>`,
empty `<rt>`, no base) is tolerated and keeps the text it held, with a block
boundary closing the element as a browser does. HTML states no alignment, size or
raise, so import uses the Phonetic Guide's defaults (centred, half the base size,
raised clear of the base text; the run's size, or 10.5 pt when none is stated).
The flow model gains `Inline::Ruby`; formats without ruby (RTF, ODT, Markdown,
LaTeX) write its base text as before. Tests: `html::tests::ruby_*` and
`tests::html_ruby_round_trip`. Docs: file-format-parity (HTML row) and
localization-parity (Japanese row).
`\ansicpg932`/`936`/`949`/`950`, a font's `\fcharset128`/`129`/`134`/`136`,
`\cpg932` and the OEM charset 255 were read one byte at a time, so Japanese,
Korean and Chinese text came out as mojibake. The reader now holds the 8-bit
text of a multibyte code page and decodes the run with encoding_rs (SHIFT_JIS,
GBK, EUC_KR/UHC, BIG5): a lead byte and its trail byte decode together, escaped
(`\'hh`) or raw. A code page switch (`\f`, `\fcharset`, `\cpg`, `\ansicpg`), a
group end and the end of the document flush what is pending; invalid sequences
read as U+FFFD, as Word writes them, and never lose the rest of the text. The
pending buffer is capped at 4096 bytes.
Single-byte code pages, `\uN?` escapes and their `\ucN` skips, the font table
and every existing test are unchanged. Tests cover Shift-JIS (escaped, raw and
through a `\fcharset128` font), CP949/CP936/CP950, a mixed Japanese/ASCII/
Cyrillic document whose code-page switch must flush, `\uN?` alongside
multibyte text, an invalid sequence and a Windows-1252 regression.
The button told assistive technology it was enabled whatever the command
could do, so the browser build -- which keeps full screen to itself and
says why -- announced a control that cannot be activated. It now reports
the command's own state, as every other ribbon control does.
Pinned by a test that makes the command unavailable the way the browser
does and checks the button is announced as disabled.
The fallback Symbol metrics applied whenever the raw family name wasn't
installed, so Symbol (PCL6) resolved to an installed Symbol still took
them. Use the resolution's substituted state instead.
Review fixes: a section starting at 40,000 was lowered to 32,767 when the
dialog was opened and accepted (the engine takes starts to 100,000), and the
non-modal dialog kept writing the numbers read from the section it opened on
into whichever section the caret moved to (the form now follows the caret, as
the Size dialog follows its object). Tests cover both.
Insert › Header & Footer › Page Number ▸ Format Page Numbers… ran a
plain `layout.pageNumberFormat` call that changed nothing and cleared
the section's Start at. The item now opens Word's dialog: the number
format (1, 2, 3 / I, II, III / i, ii, iii / A, B, C / a, b, c) and
Page numbering — Continue from previous section or Start at: n.
`layout.pageNumberFormat` keeps the section's start when `start` is
left out and numbers on from the section before for `"start": null`;
the dialog reads the section at the caret and writes through the same
command, so scripts and MCP get the same result without it. The
dialog's strings are in every interface catalogue and it joins the
untranslated-text audit. ROADMAP, docs/ui-parity.md and docs/gaps.md
get their rows.
Tests: engine (format and start, keep and continue); ui-egui (the
dialog reads the section, OK sets the format and start, continue
clears it, and a plain command call keeps the start); the i18n audit
draws the dialog's text.
`home_page` already passes "Good morning", "Good afternoon" and "Good evening"
through `tl!`, but nine catalogs had no entry, so File › Home opened in English
in German, Estonian, Japanese, Brazilian Portuguese, Serbian (Cyrillic and
Latin), Ukrainian and Chinese (Simplified and Traditional). Adds the three
greetings to each, and a test that every language has them.
Co-authored-by: CRBBeesy <CRBBeesy@users.noreply.github.com>