Compare commits

..
Author SHA1 Message Date
autocraft-bot[bot] 43f636055e Merge pull request #8798
With AutoCraft's conflict resolution e7b9c769.
2026-12-04 19:46:28 +00:00
autocraft-bot[bot] 76e76b7697 Merge pull request #8789
With AutoCraft's conflict resolution 367694e5.
2026-12-04 19:46:28 +00:00
autocraft-bot[bot] 4c467c1485 Merge pull request #8766
With AutoCraft's conflict resolution 2541c1f4.
2026-12-04 19:46:28 +00:00
autocraft-bot[bot] f9b8b60873 Merge pull request #7955 2026-12-04 19:46:28 +00:00
autocraft-bot[bot] 259870a313 Merge pull request #7197 2026-12-04 19:46:28 +00:00
autocraft-bot[bot] b864439f5c The cause is in the PR's new test, not the app. The test takes the picke
The cause is in the PR's new test, not the app. The test takes the picker's Close button as the first node labelled "Close" inside the picker. The Add a language dialog has two: one in its title bar, at y0=208 in a 1440x900 frame, and the footer's at y0=670. Which one comes first in the accessibility tree depends on node ids. On macOS in the batch it picked the title-bar one, so the test computed the list's visible bottom as 208, above its top of 275. That is the `(reason, top, bottom)` of `Some((… y0: 390 …), 275.0, 208.0)` in the log, so the fit assertion at line 1744 failed. I did not run it on macOS. On Linux the test passed before and after the change, and I printed the nodes there to confirm the title-bar Close at y0=208. The fix is in the test helper in `crates/ui-egui/src/language_packs.rs`. It now collects every Close inside the picker. It keeps only those below the Search field and takes the topmost, which is the footer's. The test is no looser: it still checks that the whole reason fits in the list's visible area. `cargo fmt --check` is clean. Clippy is clean with `-D warnings`. All 18 `language_packs` tests pass.
2026-12-04 19:46:28 +00:00
autocraft-bot[bot] 85dd661854 Merge pull request #7856
With AutoCraft's conflict resolution 61f8e8d7.
2026-12-04 17:53:43 +00:00
autocraft-bot[bot] 62ff8ba0c2 Merge pull request #8722
With AutoCraft's conflict resolution f72513fa.
2026-12-04 17:53:43 +00:00
autocraft-bot[bot] 4680b9a270 Merge pull request #7067
With AutoCraft's conflict resolution 1c87a92b.
2026-12-04 17:53:43 +00:00
autocraft-bot[bot] cd7c14e776 Merge pull request #8865 2026-12-04 17:53:43 +00:00
Dylan M. Taylor b7f512d037 Merge pull request #8864 from storytold/docs/freebsd-15-release-requirement
docs: specify the FreeBSD release requirement
2026-12-04 12:53:43 -05:00
skylar taylorandskylartaylor 29c67c62d7 Release: bump WordCraft to v0.20.1 (#8889)
Co-authored-by: skylartaylor <[email protected]>
2026-12-04 11:37:41 -06:00
autocraft-bot[bot] 0866c5bfaa Merge pull request #8870 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 68680e0665 Merge pull request #8867 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 78d6825d3b Merge pull request #8873 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] be1f9c0a1f Merge pull request #8866 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] f329ff6e81 Merge pull request #8863 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 8f330f5e26 Merge pull request #8862 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] a6ee9f22a4 Merge pull request #8858 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] cf95e5a37a Merge pull request #8845 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 1469c44e81 Merge pull request #8844 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] d184ccbfb4 Merge pull request #8833 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 0adadeed56 Merge pull request #8826 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] b3dbe51f1a Merge pull request #8817 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] b1a17b688f Merge pull request #8816 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 3adb7b5055 Merge pull request #8815 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 92c65bc00b Merge pull request #8807 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 61b83a4927 Merge pull request #8806 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 84d46c47f4 Merge pull request #8804 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] ae760626cf Merge pull request #8803 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] c2d2e93500 Merge pull request #8802 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 995746d24e Merge pull request #8688
With AutoCraft's conflict resolution 10509511.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 21671b9b66 Merge pull request #1259
With AutoCraft's conflict resolution 198d76f0.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] e2079632f3 Merge pull request #8003
With AutoCraft's conflict resolution e89186d1.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 22f774fb9f Merge pull request #6974
With AutoCraft's conflict resolution 504e41b8.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] d847fa225e Merge pull request #6525
With AutoCraft's conflict resolution 3e473b5a.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 6a91bc63f6 Merge pull request #4582
With AutoCraft's conflict resolution 5a6712e2.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] a8628f3969 Merge pull request #4322
With AutoCraft's conflict resolution 9f1ca725.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] d46178a145 Merge pull request #5954
With AutoCraft's conflict resolution ffbe0065.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 489d61cd10 Merge pull request #4995
With AutoCraft's conflict resolution f4a74773.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] f71bf017a7 Merge pull request #3089
With AutoCraft's conflict resolution 199d64f9.
2026-12-04 16:37:24 +00:00
autocraft-bot[bot] da8845c810 Merge pull request #8797 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 7605fd3c8a Merge pull request #8796 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 51b1933480 Merge pull request #8794 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] d0fc72a7ba Merge pull request #8788 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] e4950a63b5 Merge pull request #8781 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 7b7e2a7ff6 Merge pull request #8765 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 1f57c527a2 Merge pull request #8762 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 450938fe00 Merge pull request #8764 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] a9917af050 Merge pull request #8761 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 9757882dda Merge pull request #8760 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] e85e15ee14 Merge pull request #8757 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 5abe5745ce Merge pull request #8754 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 522597264c Merge pull request #8753 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 78bec40359 Merge pull request #8748 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] d3508c9d18 Merge pull request #8724 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 366ecb731e Merge pull request #8713 2026-12-04 16:37:24 +00:00
autocraft-bot[bot] 0dac42909e Merge pull request #8712 2026-12-04 16:37:24 +00:00
Martin BallandClaude Opus 5.5 3f33f90f31 #8838: a document window can be maximized and taken full screen again on Windows (#8871)
* #8838: a document window can be maximized and taken full screen again on Windows

Repin craft-libs from 5299d8d9 to ad10c35a: 5299d8d9 plus one fix
(storytold/craft-libs#5339). Since v0.20.0 a document is a child window,
and the runtime sent a maximized window its saved normal place on the word
of facts the root's input listed passes late; winit on Windows takes a
moved window out of the maximized state, so the maximize button, Win+Up
and snapping to the top shook the window and left it at its normal size,
and View > Full Screen slid it off to the side. The window's own pass now
notes its state with its place, and nothing is sent while it is maximized,
full screen or minimized.

Closes #8838, closes #8861

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* #8838: progress log and parity docs for the Windows maximize fix

ROADMAP progress log, hardware parity (windows row: maximize and full
screen, #8838) and UI parity (View > Window > Full Screen), each with its
status line and revision history.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-04 10:37:24 -06:00
Dylan M. Taylor e7dc3bf319 docs: list the published FreeBSD ARM archive 2026-12-04 11:24:19 -05:00
autocraft-bot[bot] 34cc9214d9 Part 1: in recent_paths_inside_home_contract_and_expand (crates/ui-egu
Part 1: in `recent_paths_inside_home_contract_and_expand` (crates/ui-egui/src/prefs/tests.rs), the round-trip half now gets its home folder from `super::home_dir()`. It no longer reads HOME with a USERPROFILE fallback, so on Windows it uses USERPROFILE like the code it checks. `cargo fmt --check` and `cargo clippy --offline -p wordcraft-ui-egui --all-targets -- -D warnings` passed. I did not see the `prefs` tests run: the test build was still compiling after about 80 minutes, so I stopped it.
2026-12-04 16:17:21 +00:00
Luis ad958edfce #8562: a TIME field without a picture shows the 24-hour clock in German documents 2026-12-04 16:02:26 +01:00
Luis a3ee0d1ae2 #8507: perf_probe --synthetic stops when a build step fails 2026-12-04 15:52:32 +01:00
Luis f0ab199fa3 #8379: the Multilevel List's Change to Level items are translated 2026-12-04 15:41:45 +01:00
Luis 8ef485cb08 #8421: ui.inspect lists recent documents as full paths again 2026-12-04 15:38:40 +01:00
Luis 7417fbbb0f #8458: on Windows, the recent list's home folder is USERPROFILE, not HOME 2026-12-04 15:18:05 +01:00
Dylan M. Taylor e1fccab746 docs: specify the FreeBSD release requirement 2026-12-04 09:11:37 -05:00
Max MittelstädtandGPT-6-Luna 0081098f4f Preserve exact table row heights below four points
Fixes #8860

Co-Authored-By: GPT-6-Luna <[email protected]>
2026-12-04 13:44:09 +00:00
Max MittelstädtandGPT-6.1-SOL 99917717fd Select the document with Ctrl+A inside tables
Fixes #8857

Co-Authored-By: GPT-6.1-SOL <[email protected]>
2026-12-04 13:20:14 +00:00
autocraft-bot[bot] 87dc3b203e CI failed in wordcraft-validate tests because existing fixtures used orp
CI failed in wordcraft-validate tests because existing fixtures used orphan parts that the PR's reachability requirement no longer gives story roles. Locally 5 unit tests and 26 integration tests failed; CI had stopped at the first. I fixed one real defect: check_commentex in the no-root fallback scope treated an unreachable comments part as an empty contributor and claimed 'no paragraph'; it now marks that set incomplete with a note (contract updated, register regenerated). I fixed the wrong test fixtures by linking the parts via relationships (new Doc::link_main/link_package/add_linked helpers in tests/common/mod.rs) and kept their assertions. The one assertion I changed: compat_counts_unknown_settings_incomplete and compat_flag_in_malformed_settings_is_unknown now expect Fail with XML-MALFORMED (reachable malformed settings is an Error that outranks Incomplete), and the second also asserts the compatibility-limits note. fmt, clippy -D warnings, generate.py --check and the full wordcraft-validate tests pass (218 unit, 510 integration). A wordcraft-cli test run was attempted but the build pod hung; its only validate use is a CT-UNDECLARED check that this change does not touch.
2026-12-04 13:06:14 +00:00
Max MittelstädtandGPT-6.1-SOL cbe03ab801 Tolerate noncanonical field character spellings in validation
Fixes #8850

Co-Authored-By: GPT-6.1-SOL <[email protected]>
2026-12-04 12:48:54 +00:00
autocraft-bot[bot] a969c01e57 Declared field.reachable*2 in the story_roles contract. Gave report_unkn
Declared field.reachable*2 in the story_roles contract. Gave report_unknown_story_reachability its own observation_contract (field.content_types*1, field.entries*1, field.reachable*1). Added that function's pkg.reachable membership to the structural_membership allowlist in observations/generate.py, like report_malformed. Regenerated observation-contracts.md. generate.py --check passes, fmt and clippy are clean, and the contract unit test passes. Five other wordcraft-validate tests still fail, which is outside this part.
2026-12-04 11:27:44 +00:00
Max MittelstädtandGPT-6.1-SOL b1eb5ffb5e Require package reachability before assigning story roles
Fixes #8839

Co-Authored-By: GPT-6.1-SOL <[email protected]>
2026-12-04 10:55:45 +00:00
Max MittelstädtandGPT-6-Luna 2dd637028a Prefer image pixels for browser title and srcset clipboard text
Fixes #8814

Co-Authored-By: GPT-6-Luna <[email protected]>
Co-Authored-By: GPT-6.1-SOL <[email protected]>
2026-12-04 09:39:29 +00:00
pakiatandClaude Opus 5.5 ab0dcf391c Tables: a right-to-left table's floating offset and its nested fit match Word
Follow-ups to #6941, which stopped mirroring cell margins in a right-to-left table.

#8441: fitting a column of a table nested in a right-to-left cell stopped at that cell's
left margin, which #6941 left on the cell's left; it now stops at its right margin, as
the layout draws it.

#8517: a floating right-to-left table placed by an offset has its left edge at the
offset in every mode (measured in Word for Windows): before Word 2013 Word moves it by
neither its first cell's left margin nor w:tblInd, and from it not in by half its left
border. An inline one still moves out by that margin before Word 2013, as Word does;
a comment at start_offset says so.

Fixes #8441. Fixes #8517.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-04 16:23:21 +07:00
yoriswind f4ac3b9ef5 fix(cli): surface command result warnings in run 2026-12-04 00:09:45 -08:00
autocraft-bot[bot] 51359bf825 Part 1: the save.autosave setter in crates/ui-egui/src/options.rs now cl
Part 1: the save.autosave setter in crates/ui-egui/src/options.rs now clears autosave_choice only when it is Some(false), so an opened-only file keeps its switch approval across an Options untick and re-tick. I added the test autosave_option_retick_keeps_the_switch_approval_of_an_opened_file in options/tests.rs. cargo fmt --check passed. Clippy did not finish because the harfbuzz C++ dependency compile ate the session's shell time; its log shows no errors. The tests, including the new one, were not run.
2026-12-04 07:47:17 +00:00
yoriswind 571473749e Font dialog: Show the resolved East Asian theme font 2026-12-03 22:15:21 -08:00
Max MittelstädtandGPT-6-Luna 6fc57857c8 Report wasm test crates accurately
Fixes #8799

Co-Authored-By: GPT-6-Luna <[email protected]>
2026-12-04 06:06:08 +00:00
Max MittelstädtandGPT-6-Luna 9621688eae Insert mid-document TOCs before paragraphs at offset zero
Fixes #8768

Co-Authored-By: GPT-6-Luna <[email protected]>
Co-Authored-By: GPT-6.1-SOL <[email protected]>
2026-12-04 05:10:34 +00:00
yoriswind 3ced0353e1 OpenDocument: Report fallback page conversion errors 2026-12-03 19:28:24 -08:00
batistalucasv 7e402c7529 fix(macos): allow ui.quit while a modal dialog is open (#8792) 2026-12-04 00:16:25 -03:00
batistalucasv ea7fe218ea fix(options): reflect document AutoSave opt-out in Save checkbox (#8795) 2026-12-04 00:14:59 -03:00
batistalucasv eb3ae58fd4 Control: refuse programmatic ui.quit with unsaved work unless forced (#8793) 2026-12-04 00:14:08 -03:00
batistalucasv bd7c07aea1 Tests: check block count and middle paragraph text after compare (#8769) 2026-12-03 23:51:34 -03:00
batistalucasv 4876dc7fbd test(widgets): assert font_box warning advice, Add Font… position, and font.add action (#8778) 2026-12-03 23:43:08 -03:00
batistalucasv 6985800d23 docs(layout-parity): mark continuous-section run-over case as inferred (#8779) 2026-12-03 23:13:30 -03:00
batistalucasv 320af8dbe1 Tests: cover neighbouring table cells carrying the same link (#8657) 2026-12-03 22:43:21 -03:00
batistalucasv 8725caa4a3 docs(layout-parity): document turned text wrapping for at-least and merged rows (#8391) 2026-12-03 22:00:42 -03:00
yoriswind 8633e63909 Review: format the middle paragraph regression cases 2026-12-03 11:42:51 -08:00
yoriswind 91a75c8103 Review: keep selection on surviving text after middle paragraph removal 2026-12-03 11:30:16 -08:00
autocraft-bot[bot] 1b8c2047dd Made drop_direct_indents reachable from the text module (pub(in crate::c
Made drop_direct_indents reachable from the text module (pub(in crate::cmd) in para/format.rs, re-exported from para.rs) and called it, only when the level actually changes, in tab, indent_by_tab (line-start, style-numbered case) and back_tab in enter_tab.rs. Extended changing_a_list_level_drops_a_direct_indent with text.tab (caret at item start) and text.backTab cases comparing a dragged item to a fresh one. fmt and lib clippy are clean; the typing tests pass. The full engine suite timed out in this workspace, so I ran only the tests matching changing_a_list_level, tab and list, plus the typing tests. A preexisting needless_range_loop clippy error in a test in cmd/table_draw.rs (not my change) stops --all-targets clippy. The indent_by_tab path has no new test.
2026-12-02 19:25:01 +00:00
MaheshDesu b95bfbbb37 test(ui): pin the exact painted cursor over the font size box (#7757)
Signed-off-by: MaheshDesu <[email protected]>
2026-11-30 18:09:37 +05:30
MaheshDesu 3383d8a9f1 fix(ui): keep the ribbon font cursor visible on Windows (#7757)
Signed-off-by: MaheshDesu <[email protected]>
2026-11-30 18:09:37 +05:30
MaheshDesu be96af974d test(ui): pin the ribbon font fields' Windows cursor (#7757)
Signed-off-by: MaheshDesu <[email protected]>
2026-11-30 18:09:07 +05:30
batistalucasv a1dae5ad32 fix(ui): check pointer before command match in colors::current_of 2026-11-29 17:59:05 -03:00
batistalucasv 654e1745f9 Format Shape: apply More Colors to solid fills and gradient stops (#7954) 2026-11-29 16:54:00 -03:00
554159685b fix(engine): resolve and reopen a comment's whole thread, replies included
review.resolveComment changed only the addressed comment's resolved flag, so
resolving a discussion left its replies open, and acting on a reply left its
parent and siblings unchanged.

The command now walks up to the thread root (cycle-safe, ignoring a missing
parent) and reuses the existing descendant walk, so the root, its replies and
replies to replies change together in one undo step. An omitted value still
toggles from the addressed comment's own state, so a card's Resolve or Reopen
button does what it says even in a file with mixed flags. Other discussions,
comment text and anchors are untouched.

Co-Authored-By: GPT-6.2 Astra <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-28 10:52:10 +10:00
Mauro MazzieriandClaude Opus 5.5 ee3ec16a52 Merge main into fix/small-caps-spaces-and-line-height (#7062, #7063)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-21 18:52:40 +01:00
Neil Cawse 509bfce556 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-21 17:07:02 +00:00
Neil Cawse b9e2eaf05c Merge remote-tracking branch 'fork/fix/fonts-fallback-coverage' into fix/fonts-fallback-coverage 2026-11-20 21:12:18 +00:00
Neil Cawse 007970517b fonts: check circle fallback coverage, clear caches on rescan, and keep Supplemental Arrows-C text-style 2026-11-20 21:12:18 +00:00
mmazzieriandClaude Opus 5.5 82325753a8 Layout: small capitals at 80% of the size rounded to the half point, as in Word (#7062)
Word sets small capitals, and Small Caps spaces, at 80% of the run's size rounded to the half point (Times New Roman: 10 pt -> 8, 11 -> 9, 12 -> 9.5, 14 -> 11, 16 -> 13), as it does for superscript. With the exact 80% a 16 pt Small Caps heading was narrower than in Word.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 14:01:18 +01:00
mmazzieriandClaude Opus 5.5 048f21dc77 docs: layout parity for Small Caps spaces and line height (#7062, #7063)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 13:39:13 +01:00
mmazzieriandClaude Opus 5.5 f718a26338 Layout: Small Caps spaces at the small-caps size, Small Caps lines at the full height (#7062, #7063)
Word draws a space (U+0020) and an ideographic space (U+3000) in a Small Caps
run at the small-caps size, like a lowercase letter; a no-break space, the
other Unicode spaces, digits and punctuation keep the full size, and All Caps
wins over Small Caps (measured in Word for Microsoft 365, modes 14 and 15).
WordCraft kept the space at the full size, so Small Caps lines were wider and
broke earlier (#7062).

A small-caps piece is drawn at 80%, but its line is measured at the full size,
as in Word: a line of lowercase Small Caps was shorter than without Small Caps
(#7063).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 13:21:03 +01:00
Hamza a3758cd90c Merge remote-tracking branch 'origin/main' into reproducible-saved-dates
# Conflicts:
#	crates/engine/src/io_ext.rs
2026-11-18 15:32:14 +05:00
Neil Cawse 74345b2e25 fix(fonts): invalidate cached file coverage when a font is replaced in place 2026-11-18 03:47:59 +00:00
Neil Cawse 0759433433 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-18 03:44:40 +00:00
jayzed80 c158887d9a #6899: Compare clears a foreign del from an inserted paragraph's mark
A whole paragraph inserted by compare took only the compare's ins on its
mark, but kept a del the revised document's mark already carried (a
pending deletion by another author). On accept, resolve_para took the
deletion branch and removed or joined away the inserted paragraph,
losing the inserted break. mark_block now takes a mark-only step, and
the revised side clears del on every paragraph mark it stamps,
including inside table cells; run-level revisions are left alone.
2026-11-17 23:49:12 +00:00
Neil Cawse fa3eb9f303 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-17 13:00:58 +00:00
Martin Ball d6e7695538 Merge branch 'main' into fix/autofit-stale-grid 2026-11-17 13:42:47 +01:00
Neil Cawse a5f3120d59 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-17 03:22:04 +00:00
Neil Cawse fadbfdf0e6 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-14 18:04:36 +00:00
Neil Cawse 12a29586d0 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-13 22:55:33 +00:00
Neil Cawse ace0cc6a10 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-13 19:46:00 +00:00
Neil Cawse 832462d0cf Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-13 19:00:46 +00:00
Fin Warman 925ec333cf Autofit tables take complete point-width rows over a stale grid
When an autofit table's stated width differs from its tblGrid total but
matches complete point-width rows (spans allowed), columns take the cell
widths.
2026-11-12 16:07:16 +00:00
Neil Cawse 02bcba5f71 Merge remote-tracking branch 'upstream/main' into fix/fonts-fallback-coverage 2026-11-11 18:35:52 +00:00
Neil Cawse 2d986748df test(fonts): use drop guards for temp files and dirs in fontdb tests 2026-11-11 02:17:33 +00:00
Neil Cawse c80709b51e Merge remote-tracking branch 'origin/main' into fix/fonts-fallback-coverage 2026-11-11 02:15:33 +00:00
Neil Cawse 78126b013a test(fonts): remove temporary TTC file before assertions 2026-11-09 22:39:06 +00:00
Neil Cawse d7ec5e2ed2 Merge remote-tracking branch 'origin/main' into fix/fonts-fallback-coverage 2026-11-09 22:38:15 +00:00
Neil Cawse d593088a31 refactor(fonts): share compact/MAX_FACES/MAX_RANGES in fallback_data and test sys.tried rescan 2026-11-09 14:21:05 +00:00
Neil Cawse 525a6a8f89 refactor(fonts): deduplicate TTC cmap reads, preserve coverage index across rescan, and test fallback skip/rescan 2026-11-08 13:34:26 +00:00
Neil Cawse 6102a64112 refactor(fonts): deduplicate coverage index sync and test >40 MiB TTC coverage 2026-11-08 13:34:26 +00:00
Neil Cawse 477bda7726 fonts: check family cmap coverage before loading fallback fonts and clear caches on rescan 2026-11-08 13:34:26 +00:00
Hamza 531a0d1f1d Merge remote-tracking branch 'origin/main' into reproducible-saved-dates
# Conflicts:
#	apps/wordcraft-cli/src/main.rs
#	crates/engine/src/cmd.rs
#	crates/engine/src/print.rs
2026-11-05 15:09:39 +05:00
Harrison Booth ae0f30fa23 Document emphasis round-trip test 2026-11-04 20:04:50 -06:00
Harrison Booth 55da823f01 Make emphasis dot test value explicit 2026-11-04 19:47:14 -06:00
Harrison Booth f7eadd7781 Resolve duplicate emphasis in DOCX fixture 2026-11-04 19:30:43 -06:00
Harrison Booth ecab532500 Merge latest main into East Asian emphasis marks 2026-11-04 19:24:24 -06:00
Dhruv 2973a2f4f3 A list item that changes level takes the new level's indents and drops a direct indent (#4287) 2026-11-04 10:30:11 -06:00
Harrison Booth 1121b3146c Merge origin/main into DOCX emphasis branch 2026-11-04 07:59:32 -06:00
Harrison Booth 36a64b39c4 Merge origin/main into wc-docx-emphasis 2026-11-04 06:38:59 -06:00
Harrison Booth 64e9f2d24f DOCX: retain emphasis test assertions through save cycles 2026-11-04 06:38:52 -06:00
Harrison Booth 52773d2f7b Merge remote-tracking branch 'origin/main' into wc-harfrust 2026-11-03 22:04:02 -06:00
Harrison Booth 3ecc43c062 Merge remote-tracking branch 'origin/main' into wc-harfrust 2026-11-03 17:58:55 -06:00
Harrison Booth 2be939832b Document East Asian emphasis preservation 2026-11-03 17:20:16 -06:00
Hamza 2525eaee12 SOURCE_DATE_EPOCH: warn when it is set and unusable, and show it dates the file, not the edits in it 2026-11-03 17:39:39 +05:00
Hamza ed14477f19 A creation date the PDF writer cannot read is pinned too
`pdf_document` stood in for the date only when `core.created` was empty, but the
.docx reader takes that property as it finds it, so a file can arrive holding
something like `not-a-date`. `metadata` cannot put that in a PDF and falls back
to the clock, so two exports of one document differed although SOURCE_DATE_EPOCH
was set -- the one thing it is there to stop (noted in review).

The question asked is now the writer's own. `wordcraft_pdf::reads_as_date` wraps
the parser the writer uses, so the two cannot drift apart: whatever `metadata`
would reject is what gets stood in for. A date it accepts is still kept.

Also a flake in this test harness, which the added iterations made likely rather
than introduced: the temporary directory was named from the pid and `as_nanos`,
and `as_nanos` carries microsecond granularity on macOS, so two of these tests
starting in the same microsecond took the same directory and overwrote each
other's input. It takes a sequence number as well now, and `create_dir` rather
than `create_dir_all`, so a name that does repeat fails there instead of quietly
sharing. Eight consecutive runs of the file: 3 failures before, 0 after.
2026-11-02 15:51:32 +05:00
Harrison Booth 53e520e805 DOCX: merge main into East Asian emphasis marks 2026-10-30 13:46:38 -05:00
Harrison Booth 01a6084673 DOCX: preserve East Asian emphasis marks 2026-10-29 08:00:54 -05:00
Harrison Booth a848e90b3a DOCX: preserve run grid and web-hidden properties 2026-10-29 07:34:21 -05:00
Hamza 77af00b4e5 Saving and exporting: SOURCE_DATE_EPOCH stands in for the clock
A saved document recorded the second it was saved in, and a PDF export
recorded the second it was exported in, so saving or exporting one document
twice gave different bytes although the content matched.

SOURCE_DATE_EPOCH stands in for the clock where no date is given, as the
reproducible-builds specification defines it. A value the document's date
format cannot hold is ignored rather than refusing the save. An existing
creation date is still kept, so only the parts that really are "now" move.

Rebased onto main, 785 commits on: engine's cmd/mod.rs is cmd.rs now, and
`stamp_save` moved to session/history.rs, so `saved_iso` is applied there.
Upstream has since added a `numeral` option to the PDF export, which is kept
alongside this PR's change to the document the exporter is given.
2026-10-28 20:29:14 +05:00
Harrison Booth 999f0c0973 Fonts: a run the shaper could not finish falls back to the cmap, run by run 2026-10-27 19:09:43 -05:00
Harrison Booth 6117f95e1c Merge origin/main into wc-harfrust 2026-10-27 19:07:31 -05:00
Harrison Booth 6c8a6bd6f7 Merge remote-tracking branch 'origin/main' into wc-merge-4582
# Conflicts:
#	crates/fonts/src/lib.rs
2026-10-27 14:27:11 -05:00
Harrison Booth fe2b22792d deps: harfrust 0.15 (Font, ShaperFont and Buffer replace FontRef, ShaperData and UnicodeBuffer) 2026-10-27 08:44:30 -05:00
ahutsunshin e3db9896fb security: use explicit u64 literal for 2 GB file size limit
Change '2 << 30' to '2u64 << 30'. While Rust's type inference handles the
comparison with meta.len() (u64), making the type explicit documents intent
and guards against potential debug-mode overflow traps if the constant is
ever increased past the i32 boundary.
2026-10-14 12:34:49 +08:00
95 changed files with 2659 additions and 626 deletions
Generated
+129 -116
View File
@@ -1173,7 +1173,7 @@ dependencies = [
[[package]]
name = "craft"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-automation",
"craft-behavior",
@@ -1214,7 +1214,7 @@ dependencies = [
[[package]]
name = "craft-appkit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"block2 0.6.2",
"objc2 0.6.5",
@@ -1226,7 +1226,7 @@ dependencies = [
[[package]]
name = "craft-atomic"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"rustix 1.1.6",
]
@@ -1234,7 +1234,7 @@ dependencies = [
[[package]]
name = "craft-automation"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"base64 0.23.1",
"craft-behavior",
@@ -1259,7 +1259,7 @@ dependencies = [
[[package]]
name = "craft-behavior"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"accesskit",
"bitflags 2.13.2",
@@ -1277,7 +1277,7 @@ dependencies = [
[[package]]
name = "craft-browse"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-docpath",
@@ -1295,12 +1295,12 @@ dependencies = [
[[package]]
name = "craft-cfb"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
[[package]]
name = "craft-cloud-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"egui",
]
@@ -1308,7 +1308,7 @@ dependencies = [
[[package]]
name = "craft-cms"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"md-5",
"rayon",
@@ -1317,12 +1317,12 @@ dependencies = [
[[package]]
name = "craft-codepage"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
[[package]]
name = "craft-color"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"serde",
]
@@ -1330,7 +1330,7 @@ dependencies = [
[[package]]
name = "craft-color-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-cms",
@@ -1350,7 +1350,7 @@ dependencies = [
[[package]]
name = "craft-control"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-control-protocol",
"craft-platform",
@@ -1361,7 +1361,7 @@ dependencies = [
[[package]]
name = "craft-control-protocol"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"getrandom 0.3.4",
"serde_json",
@@ -1371,7 +1371,7 @@ dependencies = [
[[package]]
name = "craft-dds"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"rayon",
]
@@ -1379,7 +1379,7 @@ dependencies = [
[[package]]
name = "craft-dialogs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"block2 0.6.2",
"craft-appkit",
@@ -1405,7 +1405,7 @@ dependencies = [
[[package]]
name = "craft-doc-binary"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"chrono",
"craft-cfb",
@@ -1422,7 +1422,7 @@ dependencies = [
[[package]]
name = "craft-docpath"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"serde",
]
@@ -1430,7 +1430,7 @@ dependencies = [
[[package]]
name = "craft-docx"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"base64 0.23.1",
"chrono",
@@ -1450,7 +1450,7 @@ dependencies = [
[[package]]
name = "craft-draw"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1469,7 +1469,7 @@ dependencies = [
[[package]]
name = "craft-drawingml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"chrono",
"craft-xml",
@@ -1481,7 +1481,7 @@ dependencies = [
[[package]]
name = "craft-flow"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-wordmodel",
"image",
@@ -1491,7 +1491,7 @@ dependencies = [
[[package]]
name = "craft-font-catalog"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"fontique",
"harfrust 0.13.3",
@@ -1506,7 +1506,7 @@ dependencies = [
[[package]]
name = "craft-font-manager"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-font-catalog",
@@ -1525,7 +1525,7 @@ dependencies = [
[[package]]
name = "craft-font-os-windows"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"windows-registry",
"windows-sys 0.61.2",
@@ -1534,7 +1534,7 @@ dependencies = [
[[package]]
name = "craft-font-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"cap-primitives",
"craft-atomic",
@@ -1557,7 +1557,7 @@ dependencies = [
[[package]]
name = "craft-font-subset"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"brotli 9.1.3",
"harfbuzz-subset-sys",
@@ -1570,7 +1570,7 @@ dependencies = [
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-font-subset",
]
@@ -1578,7 +1578,7 @@ dependencies = [
[[package]]
name = "craft-gpu"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"egui-wgpu",
"log",
@@ -1590,7 +1590,7 @@ dependencies = [
[[package]]
name = "craft-host"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"bitflags 2.13.2",
"craft-i18n",
@@ -1603,7 +1603,7 @@ dependencies = [
[[package]]
name = "craft-html"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-codepage",
"craft-flow",
@@ -1616,7 +1616,7 @@ dependencies = [
[[package]]
name = "craft-i18n"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"brotli 9.1.3",
"brotli-decompressor 6.3.1",
@@ -1646,7 +1646,7 @@ dependencies = [
[[package]]
name = "craft-image-codecs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-dds",
"craft-jpeg",
@@ -1673,7 +1673,7 @@ dependencies = [
[[package]]
name = "craft-imaging"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1691,7 +1691,7 @@ dependencies = [
[[package]]
name = "craft-jpeg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"thiserror 2.0.21",
]
@@ -1699,7 +1699,7 @@ dependencies = [
[[package]]
name = "craft-keymap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-host",
"craft-i18n",
@@ -1714,7 +1714,7 @@ dependencies = [
[[package]]
name = "craft-latex"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-flow",
"craft-math",
@@ -1725,7 +1725,7 @@ dependencies = [
[[package]]
name = "craft-markdown"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-flow",
"craft-html",
@@ -1735,7 +1735,7 @@ dependencies = [
[[package]]
name = "craft-math"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-xml",
"roxmltree",
@@ -1745,7 +1745,7 @@ dependencies = [
[[package]]
name = "craft-mcp-server"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"serde_json",
]
@@ -1753,7 +1753,7 @@ dependencies = [
[[package]]
name = "craft-menu"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -1771,7 +1771,7 @@ dependencies = [
[[package]]
name = "craft-metadata"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"brotli-decompressor 6.3.1",
"chrono",
@@ -1783,7 +1783,7 @@ dependencies = [
[[package]]
name = "craft-metafile"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"encoding_rs",
"image",
@@ -1794,7 +1794,7 @@ dependencies = [
[[package]]
name = "craft-mime"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"chardetng",
"chrono",
@@ -1805,7 +1805,7 @@ dependencies = [
[[package]]
name = "craft-nightly"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"uds_windows",
"winsafe",
@@ -1814,7 +1814,7 @@ dependencies = [
[[package]]
name = "craft-odf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"aes",
"base64 0.23.1",
@@ -1840,7 +1840,7 @@ dependencies = [
[[package]]
name = "craft-ods"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-odf",
"craft-sheet",
@@ -1851,7 +1851,7 @@ dependencies = [
[[package]]
name = "craft-offcrypto"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"aes",
"base64 0.23.1",
@@ -1868,7 +1868,7 @@ dependencies = [
[[package]]
name = "craft-opc"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1879,7 +1879,7 @@ dependencies = [
[[package]]
name = "craft-pages"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -1895,7 +1895,7 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"krilla",
"serde",
@@ -1905,7 +1905,7 @@ dependencies = [
[[package]]
name = "craft-platform"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"arboard",
"async-channel",
@@ -1943,7 +1943,7 @@ dependencies = [
[[package]]
name = "craft-print"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -1967,7 +1967,7 @@ dependencies = [
[[package]]
name = "craft-proof"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"log",
"miniz_oxide 0.9.1",
@@ -1978,7 +1978,7 @@ dependencies = [
[[package]]
name = "craft-quit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"dispatch2",
"egui",
@@ -1991,7 +1991,7 @@ dependencies = [
[[package]]
name = "craft-review"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"base64 0.23.1",
"craft-behavior",
@@ -2010,7 +2010,7 @@ dependencies = [
[[package]]
name = "craft-rtf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-codepage",
"craft-flow",
@@ -2023,7 +2023,7 @@ dependencies = [
[[package]]
name = "craft-settings"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-atomic",
"craft-host",
@@ -2040,17 +2040,17 @@ dependencies = [
[[package]]
name = "craft-sheet"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
[[package]]
name = "craft-ssip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
[[package]]
name = "craft-svg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-xml",
"flate2",
@@ -2067,7 +2067,7 @@ dependencies = [
[[package]]
name = "craft-table"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2079,7 +2079,7 @@ dependencies = [
[[package]]
name = "craft-text"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2103,7 +2103,7 @@ dependencies = [
[[package]]
name = "craft-theme"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"bitflags 2.13.2",
"craft-tracked",
@@ -2118,7 +2118,7 @@ dependencies = [
[[package]]
name = "craft-theme-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-atomic",
"craft-behavior",
@@ -2133,7 +2133,7 @@ dependencies = [
[[package]]
name = "craft-tiff"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2143,7 +2143,7 @@ dependencies = [
[[package]]
name = "craft-time"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2152,7 +2152,7 @@ dependencies = [
[[package]]
name = "craft-timeline"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2167,12 +2167,12 @@ dependencies = [
[[package]]
name = "craft-tracked"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
[[package]]
name = "craft-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-cloud-ui",
"craft-ui-canvas",
@@ -2186,7 +2186,7 @@ dependencies = [
[[package]]
name = "craft-ui-canvas"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-font-catalog",
@@ -2203,7 +2203,7 @@ dependencies = [
[[package]]
name = "craft-ui-contract"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"accesskit",
"craft-behavior",
@@ -2241,7 +2241,7 @@ dependencies = [
[[package]]
name = "craft-ui-macros"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -2252,7 +2252,7 @@ dependencies = [
[[package]]
name = "craft-ui-panels"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2270,7 +2270,7 @@ dependencies = [
[[package]]
name = "craft-ui-patterns"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2291,7 +2291,7 @@ dependencies = [
[[package]]
name = "craft-ui-shell"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2312,7 +2312,7 @@ dependencies = [
[[package]]
name = "craft-ui-test-kit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2323,7 +2323,7 @@ dependencies = [
[[package]]
name = "craft-ui-widgets"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2342,7 +2342,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"base64 0.22.1",
"chrono",
@@ -2374,7 +2374,7 @@ dependencies = [
[[package]]
name = "craft-web-api"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"js-sys",
"serde_json",
@@ -2385,7 +2385,7 @@ dependencies = [
[[package]]
name = "craft-web-host"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-host",
"craft-platform",
@@ -2397,7 +2397,7 @@ dependencies = [
[[package]]
name = "craft-win32"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"winsafe",
]
@@ -2405,7 +2405,7 @@ dependencies = [
[[package]]
name = "craft-window"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-appkit",
"craft-atomic",
@@ -2437,7 +2437,7 @@ dependencies = [
[[package]]
name = "craft-wordmodel"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"base64 0.23.1",
"craft-math",
@@ -2451,7 +2451,7 @@ dependencies = [
[[package]]
name = "craft-xls"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-cfb",
"craft-sheet",
@@ -2464,7 +2464,7 @@ dependencies = [
[[package]]
name = "craft-xlsx"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"craft-drawingml",
"craft-opc",
@@ -2476,7 +2476,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"quick-xml 0.41.0",
"serde",
@@ -2486,7 +2486,7 @@ dependencies = [
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -3828,6 +3828,19 @@ dependencies = [
"smallvec",
]
[[package]]
name = "harfrust"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "865dcc4105d51c323d8fedbb2d75b5e9c8ecddf5613f74c82f851d0afbc97114"
dependencies = [
"bitflags 2.13.2",
"bytemuck",
"read-fonts 0.46.0",
"smallvec",
"yoke",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
@@ -3866,7 +3879,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
[[package]]
name = "hayro-cmap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"brotli 8.0.4",
"hayro-postscript",
@@ -3875,7 +3888,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.7.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@ -3893,7 +3906,7 @@ dependencies = [
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@ -3911,12 +3924,12 @@ dependencies = [
[[package]]
name = "hayro-postscript"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"flate2",
"hayro-ccitt",
@@ -4645,7 +4658,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.8.2"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"base64 0.22.1",
"bumpalo",
@@ -4784,7 +4797,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
[[package]]
name = "linesweeper"
version = "0.5.0"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
dependencies = [
"arrayvec",
"kurbo",
@@ -9118,7 +9131,7 @@ dependencies = [
[[package]]
name = "wordcraft"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft",
"craft-nightly",
@@ -9145,7 +9158,7 @@ dependencies = [
[[package]]
name = "wordcraft-cli"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft-zip",
"image",
@@ -9163,11 +9176,11 @@ dependencies = [
[[package]]
name = "wordcraft-control-key"
version = "0.20.0"
version = "0.20.1"
[[package]]
name = "wordcraft-doc"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"base64 0.23.1",
"craft-codepage",
@@ -9183,7 +9196,7 @@ dependencies = [
[[package]]
name = "wordcraft-docbin"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"cfb",
"craft-doc-binary",
@@ -9195,7 +9208,7 @@ dependencies = [
[[package]]
name = "wordcraft-docx"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"base64 0.23.1",
"cfb",
@@ -9214,7 +9227,7 @@ dependencies = [
[[package]]
name = "wordcraft-engine"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"cfb",
"chrono",
@@ -9252,10 +9265,10 @@ dependencies = [
[[package]]
name = "wordcraft-fonts"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"brotli-decompressor 5.0.3",
"harfrust 0.13.3",
"harfrust 0.15.0",
"kurbo",
"log",
"serde_json",
@@ -9267,7 +9280,7 @@ dependencies = [
[[package]]
name = "wordcraft-formats"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"chardetng",
"chrono",
@@ -9297,7 +9310,7 @@ dependencies = [
[[package]]
name = "wordcraft-geom"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft-image-codecs",
"craft-tiff",
@@ -9307,7 +9320,7 @@ dependencies = [
[[package]]
name = "wordcraft-layout"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft-metafile",
"craft-proof",
@@ -9328,7 +9341,7 @@ dependencies = [
[[package]]
name = "wordcraft-mcp"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft",
"craft-mcp-server",
@@ -9342,7 +9355,7 @@ dependencies = [
[[package]]
name = "wordcraft-pdf"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"chrono",
"craft-metafile",
@@ -9363,7 +9376,7 @@ dependencies = [
[[package]]
name = "wordcraft-render"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft-metafile",
"image",
@@ -9377,7 +9390,7 @@ dependencies = [
[[package]]
name = "wordcraft-ui-egui"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"cfb",
"chrono",
@@ -9411,7 +9424,7 @@ dependencies = [
[[package]]
name = "wordcraft-validate"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft-image-codecs",
"craft-tiff",
@@ -9426,7 +9439,7 @@ dependencies = [
[[package]]
name = "wordcraft-web"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"craft",
"eframe",
@@ -9446,7 +9459,7 @@ dependencies = [
[[package]]
name = "wordcraft-zotero"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"log",
"proptest",
@@ -9664,7 +9677,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee"
[[package]]
name = "xtask"
version = "0.20.0"
version = "0.20.1"
dependencies = [
"serde",
"serde_json",
@@ -10054,4 +10067,4 @@ source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f
[[patch.unused]]
name = "hayro"
version = "0.7.1"
source = "git+https://github.com/storytold/craft-libs?rev=5299d8d97dc04648dff735d1bd6f60bd18f10b35#5299d8d97dc04648dff735d1bd6f60bd18f10b35"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
+41 -41
View File
@@ -13,7 +13,7 @@ run_slots = 3
test_threads = 4
[workspace.package]
version = "0.20.0"
version = "0.20.1"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
@@ -37,22 +37,22 @@ wordcraft-pdf = { path = "crates/pdf" }
# reads the ca-valencia pack), #589 (French elision suggestions first), #497 (flag-based
# compounding), #496 (review follow-ups, en-AU) and the merged #482–#490/#495 stack; the font
# store's `language-pack` kind is #486 (CP4.1).
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
wordcraft-engine = { path = "crates/engine" }
wordcraft-mcp = { path = "crates/mcp" }
wordcraft-zotero = { path = "crates/zotero" }
wordcraft-control-key = { path = "crates/control-key" }
wordcraft-ui-egui = { path = "crates/ui-egui" }
wordcraft-validate = { path = "crates/validate" }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0", default-features = false }
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", default-features = false }
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
# foundation
kurbo = { version = "0.13", features = ["serde"] }
@@ -75,7 +75,7 @@ regex-automata = { version = "0.4", default-features = false, features = ["std",
# text / rendering / formats
skrifa = "0.47"
harfrust = "0.13"
harfrust = "0.15"
# WOFF / WOFF2 web fonts added by the user (#582): pure Rust (MIT); its brotli and zlib decoders
# (brotli-decompressor, flate2) are already in the tree.
wuff = "0.2.9"
@@ -85,28 +85,28 @@ wuff = "0.2.9"
brotli-decompressor = "5"
vello_cpu = "0.2"
image = { version = "0.25", default-features = false }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0", default-features = false, features = ["write"] }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", default-features = false, features = ["write"] }
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0", features = ["doc"] }
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0", features = ["text"] }
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0", features = ["flow"] }
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0", features = ["detect"] }
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", version = "=0.1.0" }
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["doc"] }
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["text"] }
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["flow"] }
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["detect"] }
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
# zlib streams (compressed metafile pictures in `.doc` drawings); already in the lock as a dependency of other crates.
miniz_oxide = "0.9"
cfb = "0.15"
@@ -174,14 +174,14 @@ debug = 0
# The framework's patches, which Cargo does not carry over to dependents: its vendored crates from craft-libs,
# and the egui and winit forks it builds with.
[patch.crates-io]
krilla = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
hayro = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
krilla = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
emath = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
+3
View File
@@ -386,9 +386,12 @@ emerge --ask app-office/wordcraft-bin
### FreeBSD
Prebuilt FreeBSD release archives target FreeBSD 15.1 or newer; FreeBSD 14.x is not supported by these builds.
| Build | File |
|---|---|
| x86_64 | `wordcraft-<ver>-freebsd-x86_64.tar.gz` |
| aarch64 | `wordcraft-<ver>-freebsd-aarch64.tar.gz` |
### Web (WebAssembly)
+4 -1
View File
File diff suppressed because one or more lines are too long
+18 -6
View File
@@ -563,6 +563,17 @@ fn run_source_paths(rest: &[String], script: Option<&script::Script>) -> (Option
(from_file, from_template)
}
/// Show a successful command's result, or its warning when results aren't printed.
fn report_run_result(id: &str, result: &Value, print: bool) -> Result<(), Failure> {
if print {
return write_stdout(|o| writeln!(o, "{id}: {result}"));
}
if let Some(warning) = result.get("warning").and_then(Value::as_str) {
let _ = writeln!(std::io::stderr().lock(), "wordcraft-cli: warning: {}", escape_text(warning, false));
}
Ok(())
}
/// Run the subcommand named by `args` (the command line after the program name). Files named
/// there are opened by their real names, which may not be valid Unicode.
fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
@@ -666,9 +677,7 @@ fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
let print = rest.iter().any(|a| a == "--print");
for (n, (id, params)) in script.iter().flat_map(|c| c.commands.iter()).enumerate() {
let r = s.run(id, params).map_err(|e| engine_error(format!("command {} ({id}): {e}", n + 1)))?;
if print {
write_stdout(|o| writeln!(o, "{id}: {r}"))?;
}
report_run_result(id, &r, print)?;
}
let mut i = 0;
while i < rest.len() {
@@ -681,9 +690,7 @@ fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
None => (spec.clone(), json!({})),
};
let r = s.run(&id, &params).map_err(|e| engine_error(format!("{id}: {e}")))?;
if print {
write_stdout(|o| writeln!(o, "{id}: {r}"))?;
}
report_run_result(&id, &r, print)?;
i += 2;
} else {
i += 1;
@@ -1063,6 +1070,11 @@ fn main() -> ExitCode {
eprintln!("wordcraft-cli: --launch-profile and --profile-root are the desktop app's Nightly bootstrap, not a CLI option");
return ExitCode::from(2);
}
// The engine logs this, but the command line installs no logger, and it is where a
// reproducible build runs.
if let Some(problem) = wordcraft_engine::cmd::source_date_epoch_problem() {
eprintln!("wordcraft-cli: warning: {problem}");
}
// Language packs installed in the suite's font store are used; `proof.installPack` installs
// only while the person has turned downloading on in the app.
wordcraft_engine::packs::use_font_store(false);
+64
View File
@@ -710,6 +710,70 @@ fn script_reads_from_a_stream_and_caps_its_size() {
assert!(script::load_from(&b"{"[..], "-", None).is_err());
}
#[test]
fn run_result_warnings_use_stderr_without_print() {
use std::process::Command;
const CHILD_ARGS: &str = "WORDCRAFT_CLI_WARNING_TEST_ARGS";
const STORE: &str = "WORDCRAFT_CLI_WARNING_TEST_STORE";
const WARNING: &str = "added for this session only: couldn't store it";
if let Ok(argv) = std::env::var(CHILD_ARGS) {
let store = PathBuf::from(std::env::var_os(STORE).unwrap());
wordcraft_fonts::FontDb::global().load_user_fonts(&store);
run(&serde_json::from_str::<Vec<String>>(&argv).unwrap()).unwrap();
// Bypass the test harness summary so the parent sees only the same header and the CLI's
// output. Each child has its own font database and never configures a real user store.
std::process::exit(0);
}
let dir = script_dir("run-warnings");
let store = dir.join("not-a-directory");
std::fs::write(&store, b"blocked font store").unwrap();
// Like the engine's font.add fixture, rename the bundled JetBrains Mono family in memory
// so it is treated as a new face. No additional font asset is used.
let mut font = include_bytes!("../../../assets/fonts/JetBrainsMono-Regular.ttf").to_vec();
let utf16 = |name: &str| name.encode_utf16().flat_map(u16::to_be_bytes).collect::<Vec<u8>>();
for (old, new) in [(b"JetBrains Mono".to_vec(), b"Cli Fixture 42".to_vec()), (utf16("JetBrains Mono"), utf16("Cli Fixture 42"))] {
let mut start = 0;
while let Some(at) = font[start..].windows(old.len()).position(|bytes| bytes == old) {
let range = start + at..start + at + old.len();
start = range.end;
font[range].copy_from_slice(&new);
}
}
let path = dir.join("fixture.ttf");
std::fs::write(&path, font).unwrap();
let params = json!({"path": path.to_string_lossy()});
let spec = format!("font.add={params}");
let script = write_script(&dir, &json!({"commands": [{"command": "font.add", "params": params}]}).to_string());
let child = |argv: &[&str]| {
let out = Command::new(std::env::current_exe().unwrap())
.args(["--exact", "tests::run_result_warnings_use_stderr_without_print", "--nocapture"])
.env(CHILD_ARGS, json!(argv).to_string())
.env(STORE, &store)
.output()
.unwrap();
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
(String::from_utf8(out.stdout).unwrap(), String::from_utf8(out.stderr).unwrap())
};
let (header, quiet_stderr) = child(&["run", "--cmd", "caret.docEnd"]);
assert!(quiet_stderr.is_empty(), "{quiet_stderr}");
for argv in [["run", "--cmd", &spec], ["run", "--script", &script]] {
let (stdout, stderr) = child(&argv);
assert_eq!(stdout, header);
assert!(stderr.starts_with(&format!("wordcraft-cli: warning: {WARNING}")), "{stderr}");
assert_eq!(stderr.lines().count(), 1, "{stderr}");
let (stdout, stderr) = child(&[argv[0], argv[1], argv[2], "--print"]);
assert!(stderr.is_empty(), "{stderr}");
let result = stdout.strip_prefix(&header).unwrap().strip_prefix("font.add: ").unwrap();
let result: Value = serde_json::from_str(result).unwrap();
let warning = result["warning"].as_str().unwrap();
assert!(warning.starts_with(WARNING), "{result}");
}
}
#[test]
fn script_commands_run_before_cmd_flags() {
let dir = script_dir("order");
+17
View File
@@ -37,3 +37,20 @@ fn run_saves_the_document_opened_last() {
let stdout = String::from_utf8_lossy(&listed.stdout);
assert_eq!(stdout.matches("\"id\"").count(), 1, "{stdout}");
}
#[test]
fn failed_run_commands_still_exit_with_an_error() {
let script = std::env::temp_dir().join(format!("wordcraft-cli-run-error-{}.json", std::process::id()));
std::fs::write(&script, r#"{"commands":["no.such.command"]}"#).unwrap();
let script_path = script.to_string_lossy();
let cases = [(["run", "--cmd", "no.such.command"], "no.such.command:"), (["run", "--script", &script_path], "command 1 (no.such.command):")];
for (args, expected) in cases {
let out = Command::new(env!("CARGO_BIN_EXE_wordcraft-cli")).args(args).output().unwrap();
assert_eq!(out.status.code(), Some(1));
assert!(out.stdout.is_empty(), "{out:?}");
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(stderr.starts_with("wordcraft-cli: ") && stderr.contains(expected), "{stderr}");
assert!(!stderr.contains("wordcraft-cli: warning:"), "{stderr}");
}
std::fs::remove_file(script).unwrap();
}
@@ -0,0 +1,127 @@
//! Direct PDF exports use the saved timestamp without changing the source document.
use std::process::Command;
#[test]
fn direct_pdf_exports_use_the_pinned_epoch() {
check_creation_date("", "20261005140300");
}
#[test]
fn direct_pdf_exports_preserve_an_existing_creation_date() {
check_creation_date("2000-01-01T00:00:00Z", "20000101000000");
}
/// A .docx records `dcterms:created` as text and the reader takes it as it finds it, so a
/// document can arrive holding something that is not a date at all. The PDF writer cannot put
/// that in a document and fell back to the clock, so two exports of the same file differed even
/// with `SOURCE_DATE_EPOCH` set -- the one thing it is there to stop (noted in review).
#[test]
fn direct_pdf_exports_use_the_pinned_epoch_when_the_existing_date_is_unreadable() {
for created in ["not-a-date", "", " ", "2000-13-01T00:00:00Z", "2000-01-32T00:00:00Z", "99-01-01", "today"] {
check_creation_date(created, "20261005140300");
}
}
fn check_creation_date(created: &str, expected: &str) {
// A sequence number, not the clock alone: `as_nanos` carries microsecond granularity on
// macOS, so two of these tests starting in the same microsecond took the same directory,
// wrote each other's `input.json` and failed the preservation assertion below -- a flake in
// this harness, not in the export. `create_dir` rather than `create_dir_all` so that if a
// name ever does repeat it fails here instead of quietly sharing a directory again.
static NEXT: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
let seq = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
let unique = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();
let dir = std::env::temp_dir().join(format!("wordcraft-pdf-date-{}-{unique}-{seq}", std::process::id()));
std::fs::create_dir(&dir).unwrap_or_else(|e| panic!("{}: {e}", dir.display()));
let mut doc = wordcraft_doc::Document::from_text("Original reproducible PDF check.");
doc.core.created = created.into();
let input = dir.join("input.json");
let source = serde_json::to_vec(&doc).unwrap();
std::fs::write(&input, &source).unwrap();
for command in ["file.exportPdf", "file.printPdf"] {
let output = dir.join(format!("{command}.pdf"));
let params = serde_json::json!({"path": output});
let run = Command::new(env!("CARGO_BIN_EXE_wordcraft-cli"))
.arg("run")
.arg("--file")
.arg(&input)
.arg("--cmd")
.arg(format!("{command}={params}"))
.env("SOURCE_DATE_EPOCH", "1791208980")
.output()
.unwrap();
assert!(run.status.success(), "{command}: {}", String::from_utf8_lossy(&run.stderr));
let bytes = std::fs::read(output).unwrap();
let date = format!("/CreationDate(D:{expected}");
assert!(bytes.windows(date.len()).any(|part| part == date.as_bytes()), "{command} must use {expected}");
assert_eq!(std::fs::read(&input).unwrap(), source, "export must preserve its source file");
}
}
/// A fresh directory for one test's files.
fn scratch(name: &str) -> std::path::PathBuf {
let unique = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();
let dir = std::env::temp_dir().join(format!("wordcraft-{name}-{}-{unique}", std::process::id()));
std::fs::create_dir(&dir).unwrap_or_else(|e| panic!("{}: {e}", dir.display()));
dir
}
fn cli(env: &str, cmds: &[String]) -> std::process::Output {
let mut run = Command::new(env!("CARGO_BIN_EXE_wordcraft-cli"));
run.arg("run").env("SOURCE_DATE_EPOCH", env);
for c in cmds {
run.arg("--cmd").arg(c);
}
run.output().unwrap()
}
/// The pinned date is the file's, not the edits': a comment and a tracked change made in the
/// same run keep the time they were made, so a pinned epoch cannot back-date them (noted in
/// review). Saved as flat XML, which holds both in plain text.
#[test]
fn a_pinned_epoch_dates_the_file_and_not_the_edits_in_it() {
let out = scratch("pinned-edits").join("edits.xml");
let before = wordcraft_engine::cmd::now_iso();
let run = cli(
"1791208980",
&[
r#"review.trackChanges={"value": true}"#.to_string(),
r#"text.insert={"text": "tracked"}"#.to_string(),
r#"review.newComment={"text": "note"}"#.to_string(),
format!("file.saveAs={}", serde_json::json!({"path": out})),
],
);
let after = wordcraft_engine::cmd::now_iso();
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
let xml = std::fs::read_to_string(&out).unwrap();
assert!(xml.contains(r#"<dcterms:modified xsi:type="dcterms:W3CDTF">2026-10-05T14:03:00Z</dcterms:modified>"#), "the file's date is pinned");
let dates: Vec<&str> = xml.split(r#"w:date=""#).skip(1).filter_map(|rest| rest.split('"').next()).collect();
assert!(xml.contains("<w:ins ") && xml.contains("<w:comment "), "a tracked insertion and a comment were saved");
assert!(dates.len() >= 2, "both carry a date: {dates:?}");
for date in dates {
assert!((before.as_str()..=after.as_str()).contains(&date), "{date} is the clock's, between {before} and {after}");
}
}
/// A value that is set and cannot be used is said out loud, and the run still succeeds: the
/// files take the clock's date, as they would with the variable unset (noted in review).
#[test]
fn an_unusable_epoch_is_reported_on_stderr() {
let dir = scratch("epoch-warning");
let save = |name: &str| format!("file.exportPdf={}", serde_json::json!({"path": dir.join(name)}));
let run = cli("later", &[save("later.pdf")]);
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
let stderr = String::from_utf8_lossy(&run.stderr);
assert!(stderr.contains(r#"warning: SOURCE_DATE_EPOCH="later" is not a whole number of seconds"#), "{stderr}");
let pdf = std::fs::read(dir.join("later.pdf")).unwrap();
let pinned = b"/CreationDate(D:20261005140300";
assert!(pdf.windows(b"/CreationDate(D:".len()).any(|w| w == b"/CreationDate(D:"), "the export has a creation date");
assert!(!pdf.windows(pinned.len()).any(|w| w == pinned), "and it is the clock's, not a pinned one");
for quiet in ["1791208980", ""] {
let run = cli(quiet, &[save("quiet.pdf")]);
assert!(run.status.success());
assert!(!String::from_utf8_lossy(&run.stderr).contains("SOURCE_DATE_EPOCH"), "{quiet:?} says nothing");
}
}
+48
View File
@@ -1271,6 +1271,54 @@ mod smoke {
assert!(run.app.app.dialog_host_mut().is_empty(), "Escape dismisses About");
assert_eq!(run.app.app.session.doc.plain_text(wordcraft_doc::StoryRef::Body), before);
}
/// With a modal dialog open, Quit stays enabled and ⌘Q / menu Quit still run `ui.quit`:
/// a clean document quits and a modified one opens Save Changes (#8792).
#[cfg(target_os = "macos")]
#[test]
fn native_quit_works_while_a_modal_dialog_is_open() {
use craft::menu::{ItemRole, NativeMenu};
let mut clean = Run::new();
let fake = native_menu::FakeBackend::default();
let synced = fake.synced.clone();
let events = fake.events.clone();
let dispatch_cell = fake.dispatch.clone();
clean.app.native_menu = Some(NativeMenu::new(Box::new(fake)));
clean.app.app.run("ui.dialog", json!({"name": "about"})).unwrap();
clean.settle();
assert!(clean.app.app.dialog_host_mut().shows_modal());
let quit = {
let bars = synced.borrow();
let bar = bars.last().unwrap();
let about = bar.items().into_iter().find(|item| item.role == Some(ItemRole::About)).unwrap();
let quit = bar.items().into_iter().find(|item| item.role == Some(ItemRole::Quit)).unwrap();
assert!(!about.enabled, "About is greyed while About is open");
assert!(quit.enabled, "Quit stays enabled while About is open");
quit.clone()
};
let dispatch = dispatch_cell.borrow().as_ref().unwrap().clone();
let cmd_q = quit.shortcut.unwrap();
events.borrow_mut().push(dispatch.chosen(&quit.command, Some(&cmd_q), quit.layout_shortcut, true, cmd_q.mods, None));
clean.settle();
assert!(clean.app.app.quit_requested, "Cmd+Q quits a clean document while About is open");
let mut dirty = Run::new();
let fake = native_menu::FakeBackend::default();
let events = fake.events.clone();
let dispatch_cell = fake.dispatch.clone();
dirty.app.native_menu = Some(NativeMenu::new(Box::new(fake)));
dirty.app.app.run("text.insert", json!({"text": "unsaved"})).unwrap();
dirty.app.app.run("ui.dialog", json!({"name": "paragraph"})).unwrap();
dirty.settle();
assert!(dirty.app.app.dialog_host_mut().shows_modal());
let dispatch = dispatch_cell.borrow().as_ref().unwrap().clone();
events.borrow_mut().push(dispatch.chosen(&quit.command, Some(&cmd_q), quit.layout_shortcut, false, Default::default(), None));
dirty.settle();
assert!(!dirty.app.app.quit_requested, "Quit asks Save Changes first for a modified document");
dirty.app.app.run("ui.saveChanges", json!({"answer": "dontSave"})).unwrap();
assert!(dirty.app.app.quit_requested, "Don't Save completes the quit");
}
}
#[cfg(test)]
+68 -3
View File
@@ -1,6 +1,6 @@
//! The macOS application menu uses the same About dialog as File › About.
use craft::menu::{CommandRef, Gate, Item, ItemRole, Layout, LayoutOptions, Menu, MenuBar, MenuRole, NativeMenu, mac_layout};
use craft::menu::{CommandRef, Gate, Item, ItemRole, Layout, LayoutOptions, Menu, MenuBar, MenuRole, ModalRules, NativeMenu, mac_layout};
use serde_json::json;
use wordcraft_ui_egui::{WordApp, i18n};
@@ -36,15 +36,24 @@ fn layout_in(lang: i18n::Lang) -> Layout {
layout(&|s| i18n::tr(lang, s).to_owned())
}
/// Commands that still run from the application menu while a modal dialog is open: `ui.quit` asks
/// about unsaved documents through `WordApp::quit`, matching the built-in Quit item and the Dock.
fn modal_rules() -> ModalRules {
ModalRules::default().in_dialogs(["ui.quit"])
}
pub(super) fn install(ctx: &egui::Context, app: &WordApp) -> Option<NativeMenu> {
let menu = craft::menu::mac::install(ctx, &layout_in(lang(app)).bar);
if menu.is_none() {
let mut menu = craft::menu::mac::install(ctx, &layout_in(lang(app)).bar);
if let Some(menu) = &mut menu {
menu.set_modal_rules(modal_rules());
} else {
log::warn!("the WordCraft application menu could not be installed");
}
menu
}
pub(super) fn update(menu: &mut NativeMenu, app: &mut WordApp, ctx: &egui::Context) {
menu.set_modal_rules(modal_rules());
menu.set_gate(Gate::default().modal(app.dialog_host_mut().shows_modal()));
for command in menu.take_clicks(ctx) {
if let Err(error) = app.run(&command.id, command.params) {
@@ -58,6 +67,29 @@ pub(super) fn update(menu: &mut NativeMenu, app: &mut WordApp, ctx: &egui::Conte
}
}
#[cfg(test)]
#[derive(Default)]
pub(super) struct FakeBackend {
pub(super) synced: std::rc::Rc<std::cell::RefCell<Vec<MenuBar>>>,
pub(super) events: std::rc::Rc<std::cell::RefCell<Vec<craft::menu::Event>>>,
pub(super) dispatch: std::rc::Rc<std::cell::RefCell<Option<craft::menu::Dispatch>>>,
}
#[cfg(test)]
impl craft::menu::Backend for FakeBackend {
fn sync(&mut self, bar: &MenuBar) {
self.synced.borrow_mut().push(bar.clone());
}
fn attach(&mut self, dispatch: craft::menu::Dispatch) {
*self.dispatch.borrow_mut() = Some(dispatch);
}
fn drain(&mut self) -> Vec<craft::menu::Event> {
std::mem::take(&mut *self.events.borrow_mut())
}
}
#[cfg(test)]
mod tests {
use super::*;
@@ -78,4 +110,37 @@ mod tests {
let quit = layout.bar.items().into_iter().find(|item| item.role == Some(ItemRole::Quit)).unwrap();
assert_eq!(quit.command.id, "ui.quit");
}
/// Quit stays enabled while a modal dialog is open, and both a menu click and ⌘Q pass the gate (#8792).
#[test]
fn quit_stays_enabled_and_runs_under_modal_rules() {
let fake = FakeBackend::default();
let synced = fake.synced.clone();
let events = fake.events.clone();
let dispatch_cell = fake.dispatch.clone();
let mut menu = NativeMenu::new(Box::new(fake));
menu.set_modal_rules(modal_rules());
menu.set_gate(Gate::default().modal(true));
let ctx = egui::Context::default();
menu.sync_with("en", || layout(&|s| s.to_owned()));
let bar = synced.borrow();
let last = bar.last().unwrap();
let about = last.items().into_iter().find(|item| item.role == Some(ItemRole::About)).unwrap().clone();
let quit = last.items().into_iter().find(|item| item.role == Some(ItemRole::Quit)).unwrap().clone();
drop(bar);
assert!(!about.enabled, "About is greyed while a modal dialog is open");
assert!(quit.enabled, "Quit stays enabled while a modal dialog is open");
let dispatch = dispatch_cell.borrow().as_ref().unwrap().clone();
let cmd_q = quit.shortcut.unwrap();
events.borrow_mut().extend([
dispatch.chosen(&about.command, about.shortcut.as_ref(), about.layout_shortcut, false, Default::default(), None),
dispatch.chosen(&quit.command, Some(&cmd_q), quit.layout_shortcut, false, Default::default(), None),
dispatch.chosen(&quit.command, Some(&cmd_q), quit.layout_shortcut, true, cmd_q.mods, None),
]);
menu.poll(&ctx);
assert_eq!(menu.take_clicks(&ctx), vec![quit.command.clone(), quit.command]);
}
}
+77
View File
@@ -93,6 +93,83 @@ fn run_and_style_snap_to_grid_and_web_hidden_survive_two_saves() {
}
}
/// Keeps run and style emphasis values intact across repeated DOCX saves.
#[test]
fn run_and_style_emphasis_marks_survive_two_saves() {
use wordcraft_doc::props::EmphasisMark;
let styles = r#"
<w:style w:type="character" w:styleId="Dot"><w:rPr><w:em w:val="dot"/></w:rPr></w:style>
<w:style w:type="character" w:styleId="Comma"><w:rPr><w:em w:val="comma"/></w:rPr></w:style>
<w:style w:type="character" w:styleId="Circle"><w:rPr><w:em w:val="circle"/></w:rPr></w:style>
<w:style w:type="character" w:styleId="UnderDot"><w:rPr><w:em w:val="underDot"/></w:rPr></w:style>
<w:style w:type="character" w:styleId="NoMark"><w:rPr><w:em w:val="none"/></w:rPr></w:style>
"#;
let body = r#"
<w:p>
<w:r><w:rPr><w:rStyle w:val="Dot"/></w:rPr><w:t>default dot</w:t></w:r>
<w:r><w:rPr><w:rStyle w:val="Comma"/></w:rPr><w:t>comma</w:t></w:r>
<w:r><w:rPr><w:rStyle w:val="Circle"/></w:rPr><w:t>circle</w:t></w:r>
<w:r><w:rPr><w:rStyle w:val="UnderDot"/></w:rPr><w:t>under dot</w:t></w:r>
<w:r><w:rPr><w:rStyle w:val="Dot"/><w:em w:val="none"/></w:rPr><w:t>explicit none</w:t></w:r>
<w:r><w:rPr><w:rStyle w:val="NoMark"/></w:rPr><w:t>style none</w:t></w:r>
<w:r><w:rPr><w:em w:val="dot"/></w:rPr><w:t>run dot</w:t></w:r>
<w:r><w:rPr><w:em w:val="comma"/></w:rPr><w:t>run comma</w:t></w:r>
<w:r><w:rPr><w:em w:val="circle"/></w:rPr><w:t>run circle</w:t></w:r>
<w:r><w:rPr><w:em w:val="underDot"/></w:rPr><w:t>run under dot</w:t></w:r>
<w:r><w:rPr><w:em w:val="none"/></w:rPr><w:t>run none</w:t></w:r>
<w:r><w:t>inherit absent</w:t></w:r>
</w:p>
"#;
let mut doc = wordcraft_docx::read(&docx(body, styles)).unwrap();
let p = doc.body.iter().find_map(|b| b.as_para()).unwrap();
let expected_styles = [
("Dot", Some(EmphasisMark::Dot)),
("Comma", Some(EmphasisMark::Comma)),
("Circle", Some(EmphasisMark::Circle)),
("UnderDot", Some(EmphasisMark::UnderDot)),
("NoMark", Some(EmphasisMark::None)),
];
for (id, mark) in expected_styles {
assert_eq!(doc.styles.get(id).and_then(|style| style.chr.emphasis), mark);
}
assert_eq!(p.runs[4].props.emphasis, Some(EmphasisMark::None));
let expected_runs = [
Some(EmphasisMark::Dot),
Some(EmphasisMark::Comma),
Some(EmphasisMark::Circle),
Some(EmphasisMark::UnderDot),
Some(EmphasisMark::None),
None,
];
for (run, mark) in p.runs.iter().skip(6).zip(expected_runs) {
assert_eq!(run.props.emphasis, mark);
}
for pass in 0..2 {
let out = wordcraft_docx::write(&doc).unwrap();
let style_xml = part(&out, "word/styles.xml");
for value in ["dot", "comma", "circle", "underDot", "none"] {
assert!(style_xml.contains(&format!(r#"<w:em w:val="{value}"/>"#)), "pass {pass}: {style_xml}");
}
let document_xml = part(&out, "word/document.xml");
assert!(document_xml.contains(r#"<w:em w:val="none"/>"#), "pass {pass}: {document_xml}");
assert!(document_xml.contains("default dot"));
doc = wordcraft_docx::read(&out).unwrap();
for (id, mark) in expected_styles {
assert_eq!(doc.styles.get(id).and_then(|style| style.chr.emphasis), mark, "pass {pass}");
}
let p = doc.body.iter().find_map(|b| b.as_para()).unwrap();
for index in [0, 1, 2, 3, 5] {
assert_eq!(p.runs[index].props.emphasis, None, "pass {pass}: run {index}");
}
assert_eq!(p.runs[4].props.emphasis, Some(EmphasisMark::None), "pass {pass}: run 4",);
for (run, mark) in p.runs.iter().skip(6).zip(expected_runs) {
assert_eq!(run.props.emphasis, mark, "pass {pass}");
}
}
}
#[test]
fn style_paragraph_and_run_changes_keep_independent_authors() {
let styles = r#"
+108 -1
View File
@@ -580,11 +580,65 @@ pub fn now_unix() -> u64 {
}
}
/// ISO-8601 timestamp (UTC, seconds).
/// ISO-8601 timestamp (UTC, seconds): the clock, for an event that happened now -- a comment, a
/// tracked change, a version. Not for what a saved or exported file records: see [`saved_iso`].
pub fn now_iso() -> String {
iso_from_unix_secs(now_unix())
}
/// The timestamp a saved or exported file records (its created and modified properties):
/// `SOURCE_DATE_EPOCH` when it holds a non-negative whole number of seconds, else the clock. With
/// it set, separate conversions of unchanged input can produce the same bytes. Repeated saves
/// of one session still advance the document revision
/// (<https://reproducible-builds.org/specs/source-date-epoch/>).
///
/// The clock stays in [`now_iso`]: an editing event's time is not the file's, and pinning it would
/// misdate comments and tracked changes.
///
/// A value that is set but not one of those is ignored with a warning, so a build that meant to
/// pin its dates hears that it did not.
pub fn saved_iso() -> String {
let raw = std::env::var("SOURCE_DATE_EPOCH").ok();
if let Some(problem) = epoch_problem(raw.as_deref()) {
log::warn!("{problem}");
}
iso_from_unix_secs(pinned_or(|_| raw.clone(), now_unix))
}
/// Why `SOURCE_DATE_EPOCH` is set and still not used, for a caller with no logger to say so (the
/// command line). `None` when it is unset, empty, or a value [`saved_iso`] takes.
pub fn source_date_epoch_problem() -> Option<String> {
epoch_problem(std::env::var("SOURCE_DATE_EPOCH").ok().as_deref())
}
/// An empty value counts as unset, as a CI file's `SOURCE_DATE_EPOCH=` with nothing after it
/// means; anything else that does not pin a date is worth a warning.
fn epoch_problem(value: Option<&str>) -> Option<String> {
let v = value?;
if v.trim().is_empty() || pinned(v).is_some() {
return None;
}
Some(format!(
"SOURCE_DATE_EPOCH={v:?} is not a whole number of seconds from 1970 to 9999-12-31, so saved and exported files take the clock's date"
))
}
/// The seconds a `SOURCE_DATE_EPOCH` value pins, if it pins any.
fn pinned(v: &str) -> Option<u64> {
v.trim().parse::<u64>().ok().filter(|secs| *secs <= LAST_DATE)
}
/// [`saved_iso`]'s choice, with the environment and the clock given so a test can show which wins.
pub(crate) fn pinned_or(get: impl Fn(&str) -> Option<String>, clock: impl Fn() -> u64) -> u64 {
get("SOURCE_DATE_EPOCH").as_deref().and_then(pinned).unwrap_or_else(clock)
}
/// The last date a document can record, as Unix seconds: 9999-12-31T23:59:59Z. A year runs to
/// four digits in `xsd:dateTime`, which is what a .docx core property holds, so a value past this
/// would be written as something no reader accepts -- `292277026596-12-04T15:30:07Z` for
/// `i64::MAX`. Such a value is left to the clock, as a malformed one is.
const LAST_DATE: u64 = 253_402_300_799;
/// The local time zone's offset from UTC in seconds (east positive) at `unix`, daylight saving
/// included: the system's zone, or the browser's on the web. 0 (UTC) when it can't be found.
pub fn local_offset_secs(unix: u64) -> i64 {
@@ -735,3 +789,56 @@ mod iso_tests {
let _ = (civil_from_days(i64::MAX), civil_from_days(i64::MIN));
}
}
#[cfg(test)]
mod saved_time_tests {
use super::{epoch_problem, iso_from_unix_secs, pinned_or};
/// What a saved or exported file records: `SOURCE_DATE_EPOCH` when it holds a non-negative
/// whole number of seconds, the clock whenever it does not. The environment and the clock are
/// given here rather than set, so no test changes this process's environment -- that is
/// `unsafe` under edition 2024 and would reach every test beside it.
#[test]
fn a_pinned_epoch_is_preferred_and_the_clock_answers_otherwise() {
let env = |v: Option<&'static str>| move |_: &str| v.map(str::to_owned);
let clock = || 1_000_000;
assert_eq!(pinned_or(env(Some("1791208980")), clock), 1_791_208_980, "the variable wins");
assert_eq!(pinned_or(env(Some("0")), clock), 0, "the epoch itself counts");
assert_eq!(pinned_or(env(Some(" 1791208980 ")), clock), 1_791_208_980, "spaces around it are allowed");
// The last date a document can write is honoured; past it the year would not fit
// `xsd:dateTime` and the clock answers instead.
assert_eq!(pinned_or(env(Some("253402300799")), clock), 253_402_300_799);
assert_eq!(iso_from_unix_secs(253_402_300_799), "9999-12-31T23:59:59Z");
for ignored in [
None,
Some(""),
Some(" "),
Some("-1"),
Some("later"),
Some("1791208980.5"),
Some("99999999999999999999"),
Some("253402300800"),
Some("9223372036854775807"),
] {
assert_eq!(pinned_or(env(ignored), clock), 1_000_000, "{ignored:?} leaves it to the clock");
}
// Only that variable is read.
assert_eq!(pinned_or(|name: &str| (name == "TZ").then(|| "1791208980".to_owned()), clock), 1_000_000);
// And it reaches the stamp as that instant, not as something near it.
assert_eq!(iso_from_unix_secs(pinned_or(env(Some("1791208980")), clock)), "2026-10-05T14:03:00Z");
}
/// A value that is set and still ignored is reported, so a build that meant to pin its dates
/// hears that it did not (noted in review). Unset and empty say nothing: an empty value is
/// how a CI file leaves the variable off.
#[test]
fn a_set_but_unusable_epoch_is_reported_and_nothing_else_is() {
for quiet in [None, Some(""), Some(" "), Some("0"), Some("1791208980"), Some(" 1791208980 "), Some("253402300799")] {
assert_eq!(epoch_problem(quiet), None, "{quiet:?}");
}
for loud in ["later", "-1", "1791208980.5", "1e9", "253402300800", "99999999999999999999"] {
let problem = epoch_problem(Some(loud)).unwrap_or_else(|| panic!("{loud:?} should be reported"));
assert!(problem.contains(&format!("{loud:?}")) && problem.contains("clock"), "{problem}");
}
}
}
+5 -2
View File
@@ -53,7 +53,10 @@ pub fn specs() -> Vec<CommandSpec> {
CommandSpec::new("caret.set", "Set Caret", "Navigation", set)
.params(r#"{"pos": Pos, "extend"?: bool} | {"page": n, "x": pt, "y": pt}"#)
.pure(),
CommandSpec::new("select.all", "Select All", "Home › Editing › Select", select_all).key("Mod+A").pure(),
CommandSpec::new("select.all", "Select All", "Home › Editing › Select", select_all)
.key("Mod+A")
.params(r#"{"whole"?: bool (default true: select the whole story; false: grow through the cell, row and table first)}"#)
.pure(),
CommandSpec::new("select.range", "Select Range", "Navigation", select_range).params(r#"{"anchor": Pos, "focus": Pos}"#).pure(),
CommandSpec::new("select.word", "Select Word", "Navigation", select_word).pure(),
CommandSpec::new("select.sentence", "Select Sentence", "Navigation", select_sentence).pure(),
@@ -394,7 +397,7 @@ fn select_all(s: &mut Session, v: &Value) -> CmdResult {
s.column_mode = false;
return sel_result(s);
}
if !p::bool(v, "whole").unwrap_or(false)
if !p::bool(v, "whole").unwrap_or(true)
&& let Some(r) = super::table::grow_select_all(s)
{
return r;
+16 -2
View File
@@ -1,12 +1,13 @@
//! Character formatting (Home › Font).
use std::collections::HashMap;
use std::sync::{Arc, PoisonError};
use serde_json::{Value, json};
use wordcraft_doc::eq::{EncloseShape, EncloseStyle, Enclosure};
use wordcraft_doc::props::{Border, CharProps, Highlight, Rgb, TextColor, Underline, VertAlign};
use wordcraft_doc::resolve::ResolvedChar;
use wordcraft_doc::{InlineObject, PartKind, Pos, RevisionKind, StoryRef};
use wordcraft_doc::{Document, InlineObject, PartKind, Pos, RevisionKind, StoryRef};
use super::sel_result;
use super::tools::{is_turkic, lower_char, upper_char};
@@ -955,6 +956,19 @@ pub fn state(s: &Session) -> Value {
(*cached_state(s)).clone()
}
/// The common East Asian family shown by the font controls. If a slot has no face, keep
/// showing the named font. Resolve each theme slot once even for a selection with many runs.
fn selection_east_asian_font<'a>(doc: &'a Document, runs: &'a [ResolvedChar]) -> Option<&'a str> {
let mut themes = HashMap::new();
let mut fonts = runs.iter().map(|run| {
run.font_ea_theme
.and_then(|slot| *themes.entry(slot).or_insert_with(|| wordcraft_layout::para::east_asian_font(doc, run)))
.or(run.font_ea.as_deref())
});
let first = fonts.next().flatten()?;
fonts.all(|font| font == Some(first)).then_some(first)
}
fn compute_state(s: &Session) -> Value {
let all = resolved(s);
let first = all.first().cloned();
@@ -975,7 +989,7 @@ fn compute_state(s: &Session) -> Value {
json!({
"font": font,
"fontShownAs": shown_as,
"fontEastAsia": same(&|r| json!(r.font_ea)),
"fontEastAsia": selection_east_asian_font(&s.doc, &all),
"size": same(&|r| json!(r.size)),
"bold": all.iter().all(shown_bold),
"italic": all.iter().all(shown_italic),
+2 -2
View File
@@ -16,8 +16,8 @@ mod objects;
pub(crate) use header_footer::saved_copy;
use header_footer::{create_hf, edit_hf, header_footer, new_empty_headers, strip_headers};
pub use items::{
DropCapState, default_date_picture, drop_cap_state, format_date, format_date_at, format_date_at_in, format_date_in, format_date_parts,
format_date_parts_in,
DropCapState, default_date_picture, default_time_picture, drop_cap_state, format_date, format_date_at, format_date_at_in, format_date_in,
format_date_parts, format_date_parts_in,
};
use items::{cover_page, date_time, drop_cap, drop_cap_off, field, page_number, symbol};
use links::{bookmark, delete_bookmark, link, link_targets};
+34
View File
@@ -218,6 +218,8 @@ struct DateNames {
days_short: [&'static str; 7],
/// The picture of a `DATE` field without `\@`.
default: &'static str,
/// The picture of a `TIME` field without `\@`.
default_time: &'static str,
}
const ENGLISH: DateNames = DateNames {
@@ -226,6 +228,7 @@ const ENGLISH: DateNames = DateNames {
days: ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"],
days_short: ["Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed"],
default: "M/d/yyyy",
default_time: "h:mm am/pm",
};
/// Portuguese (observed in Word for Mac with a pt-BR document): lower-case names, `MMM` = `out`,
@@ -236,6 +239,7 @@ const PORTUGUESE: DateNames = DateNames {
days: ["quinta-feira", "sexta-feira", "sábado", "domingo", "segunda-feira", "terça-feira", "quarta-feira"],
days_short: ["qui", "sex", "sáb", "dom", "seg", "ter", "qua"],
default: "dd/MM/yyyy",
default_time: "h:mm am/pm",
};
/// German (Word's Windows NLS forms): `MMMM` = `März`, `MMM` = `Mrz`, `ddd` = `Fr` (two
@@ -246,6 +250,7 @@ const GERMAN: DateNames = DateNames {
days: ["Donnerstag", "Freitag", "Samstag", "Sonntag", "Montag", "Dienstag", "Mittwoch"],
days_short: ["Do", "Fr", "Sa", "So", "Mo", "Di", "Mi"],
default: "dd.MM.yyyy",
default_time: "HH:mm",
};
/// Austrian Standard German: January is `Jänner`, abbreviated `Jän` (Österreichisches
@@ -256,6 +261,7 @@ const GERMAN_AUSTRIA: DateNames = DateNames {
days: ["Donnerstag", "Freitag", "Samstag", "Sonntag", "Montag", "Dienstag", "Mittwoch"],
days_short: ["Do", "Fr", "Sa", "So", "Mo", "Di", "Mi"],
default: "dd.MM.yyyy",
default_time: "HH:mm",
};
/// Choose month and weekday names from the language tag: the primary subtag picks the language,
@@ -279,6 +285,12 @@ pub fn default_date_picture(lang: Option<&str>) -> &'static str {
date_names(lang).default
}
/// The picture Word gives a `TIME` field that has no `\@` switch, in the field's language: German
/// shows the 24-hour clock (#8562).
pub fn default_time_picture(lang: Option<&str>) -> &'static str {
date_names(lang).default_time
}
/// Format a date and time with a Word picture; `days_since` (days since 1970-01-01) gives the weekday.
pub fn format_date_parts(fmt: &str, y: i64, m: usize, d: u32, hms: (u32, u32, u32), days_since: i64) -> String {
format_date_parts_in(fmt, None, y, m, d, hms, days_since)
@@ -622,6 +634,28 @@ mod date_time_locale_tests {
assert_eq!(default_date_picture(Some("de-CH")), "dd.MM.yyyy");
}
/// A `TIME` field without `\@` shows the 24-hour clock in a German document and the 12-hour
/// clock in an English one (#8562).
#[test]
fn bare_time_field_follows_the_document_language() {
let refreshed = |lang: &str| {
let mut s = Session::new(wordcraft_doc::Document::new());
s.run("review.language", &json!({"lang": lang, "default": true})).unwrap();
s.run("insert.field", &json!({"instr": "TIME", "result": "stale"})).unwrap();
crate::cmd::references::refresh_date_fields(&mut s.doc);
let path = s.doc.para_paths(StoryRef::Body).remove(0);
let p = s.doc.para(StoryRef::Body, &path).unwrap();
let result = p.objects.iter().find_map(|o| if let InlineObject::Field { result, .. } = o { Some(result.clone()) } else { None });
result.expect("a TIME field")
};
for lang in ["de-DE", "de-AT", "de-CH"] {
let time = refreshed(lang);
assert!(time != "stale" && !time.contains("AM") && !time.contains("PM"), "{lang}: {time}");
}
let time = refreshed("en-US");
assert!(time.contains("AM") || time.contains("PM"), "en-US: {time}");
}
/// Windows NLS short forms: two-letter weekdays (`Mo`, `Di`…) and `Mrz` for March, with no
/// trailing full stop (#7146).
#[test]
+6 -1
View File
@@ -18,6 +18,7 @@ mod styles;
mod tabs_borders;
mod tools;
pub(super) use format::drop_direct_indents;
use format::{align, asian_typography, cur, direction, line_spacing, ls, set_align, set_props, tog};
pub use format::{cur as selection_para, fmt, indent, outdent};
pub use lists::{ListButtons, list_buttons, manage_list, touch_all};
@@ -166,13 +167,17 @@ pub fn specs() -> Vec<CommandSpec> {
CommandSpec::new("para.heading3", "Heading 3", "Home › Styles", |s, _| apply_style(s, &json!({"style": "Heading3"}))).key("Mod+Alt+3"),
CommandSpec::new("para.bullets", "Bullets", "Home › Paragraph", |s, v| list(s, v, ListKind::Bullet)).params(r#"{"kind"?: "bullet" | single char, "off"?: bool}"#).key("Mod+Shift+L"),
CommandSpec::new("para.numbering", "Numbering", "Home › Paragraph", |s, v| list(s, v, ListKind::Numbered))
.params(r#"{"kind"?: "numbered|numberedParen|outline|upperLetter|lowerLetter|lowerLetterDot|lowerRoman", "off"?: bool}"#),
.params(r#"{"kind"?: "numbered|numberedParen|upperLetter|lowerLetter|lowerRoman|outline", "off"?: bool}"#),
CommandSpec::new("para.multilevel", "Multilevel List", "Home › Paragraph", |s, v| list(s, v, ListKind::Legal)).params(r#"{"kind"?: "legal|outline"}"#),
CommandSpec::new("para.listLevel", "Change List Level", "Home › Paragraph › Bullets", |s, v| {
let lvl = p::u64(v, "level").unwrap_or(0).min(8) as u8;
fmt(s, &|p| {
if let Some(n) = p.numbering.as_mut() {
let moved = n.level != lvl;
n.level = lvl;
if moved {
format::drop_direct_indents(p);
}
}
})
})
+24 -2
View File
@@ -163,6 +163,16 @@ pub(super) fn set_props(s: &mut Session, v: &Value) -> CmdResult {
sel_result(s)
}
/// A list item that moves to another level takes that level's indents: a direct indent (a ruler
/// drag, a pasted block, a Word file's `w:ind`) would otherwise win over them and leave the item
/// out of line with its level (#4287).
pub(in crate::cmd) fn drop_direct_indents(p: &mut ParaProps) {
p.indent_left = None;
p.indent_first = None;
p.indent_left_chars = None;
p.indent_first_chars = None;
}
pub fn indent(s: &mut Session, _: &Value) -> CmdResult {
let a = s.sel.ordered().0;
let paths = crate::cmd::selected_paths(s);
@@ -174,7 +184,13 @@ pub fn indent(s: &mut Session, _: &Value) -> CmdResult {
};
let para = s.doc.para_mut(a.story, &path)?;
match num {
Some(n) => para.props.numbering = Some(NumRef { num: n.num, level: n.level.saturating_add(1).min(8) }),
Some(n) => {
let level = n.level.saturating_add(1).min(8);
para.props.numbering = Some(NumRef { num: n.num, level });
if level != n.level {
drop_direct_indents(&mut para.props);
}
}
None => {
para.props.indent_left = Some(((left / tab).floor() + 1.0) * tab);
para.props.cancel_char_indents(true, false, false);
@@ -196,7 +212,13 @@ pub fn outdent(s: &mut Session, _: &Value) -> CmdResult {
};
let para = s.doc.para_mut(a.story, &path)?;
match num {
Some(n) => para.props.numbering = Some(NumRef { num: n.num, level: n.level.saturating_sub(1) }),
Some(n) => {
let level = n.level.saturating_sub(1);
para.props.numbering = Some(NumRef { num: n.num, level });
if level != n.level {
drop_direct_indents(&mut para.props);
}
}
None => {
para.props.indent_left = Some((((left / tab).ceil() - 1.0) * tab).max(0.0));
para.props.cancel_char_indents(true, false, false);
+6 -17
View File
@@ -13,24 +13,13 @@ pub(super) fn list(s: &mut Session, v: &Value, default: ListKind) -> CmdResult {
.map(|p| s.doc.para(a.story, p).and_then(|x| s.doc.styles.resolve_para(&x.props).numbering).filter(|n| n.num != 0))
.collect();
let same_kind = |n: &NumRef| {
let want = wordcraft_doc::numbering::levels_for(kind);
// Is the list's level `i` (with this list's own overrides) the preset's level `i`?
let level_is = |i: u8, with_text: bool| match (s.doc.numbering.level(n.num, i), want.get(usize::from(i))) {
(Some(l), Some(w)) => {
s.doc.numbering.level(n.num, n.level).is_some_and(|l| {
let want = wordcraft_doc::numbering::levels_for(kind);
want.get(usize::from(n.level)).is_some_and(|w| {
(w.format == wordcraft_doc::section::NumFormat::Bullet) == (l.format == wordcraft_doc::section::NumFormat::Bullet)
// A named preset is the same one only in its number style and text: "1." and "A." are
// both `%1.`, so picking one over the other changes the list, not switches it off (#4281).
&& (!with_text || (w.text == l.text && w.format == l.format))
}
_ => false,
};
let named = p::str(v, "kind").is_some();
// A named preset is told by its first level as well as the paragraph's own, as deeper levels of
// two presets can look alike; unless the list starts with the other kind of marker (a bullet
// above numbers, or the reverse), where the paragraph's own level decides.
let is_bullet = |i: u8| s.doc.numbering.level(n.num, i).map(|l| l.format == wordcraft_doc::section::NumFormat::Bullet);
let one_kind_throughout = is_bullet(0) == is_bullet(n.level);
level_is(n.level, named) && (!named || !one_kind_throughout || level_is(0, true))
&& (p::str(v, "kind").is_none() || w.text == l.text)
})
})
};
let remove = off || (!current.is_empty() && current.iter().all(|n| n.as_ref().is_some_and(same_kind)));
if remove {
+1 -1
View File
@@ -607,7 +607,7 @@ fn created_at(stamp: &str) -> Option<(u64, i64)> {
/// Word's default date or time picture when a field instruction carries no `\@` picture switch.
fn default_picture(name: &str, lang: Option<&str>) -> String {
if name == "TIME" { "h:mm am/pm".into() } else { crate::cmd::insert::default_date_picture(lang).into() }
if name == "TIME" { crate::cmd::insert::default_time_picture(lang).into() } else { crate::cmd::insert::default_date_picture(lang).into() }
}
/// Most names SET fields give values.
const MAX_SET: usize = 10_000;
+1 -1
View File
@@ -707,7 +707,7 @@ fn a_toc_inserted_in_the_middle_of_a_document_leaves_the_caret_after_it() {
s.sel = Selection::caret(Pos { story: StoryRef::Body, path: Path::top(1), off: 0 });
s.run("references.toc", &json!({"levels": 2})).unwrap();
let (start, end) = toc_range(&s).unwrap();
assert!(start > 0, "the TOC is inserted after the intro paragraph");
assert_eq!(start, 1, "the TOC must immediately follow Intro without an extra blank paragraph");
assert_eq!(s.doc.body[0].as_para().map(|p| p.plain_text()).as_deref(), Some("Intro"));
assert_eq!(
s.sel.focus,
+2
View File
@@ -439,6 +439,8 @@ pub(super) fn insert_toc(s: &mut Session, v: &Value) -> CmdResult {
s.doc.remove_block(StoryRef::Body, &at.path)?;
}
at.path.last()
} else if at.off == 0 {
at.path.last()
} else {
s.doc.split_paragraph(&at)?.path.last()
};
+3 -11
View File
@@ -19,10 +19,8 @@ pub use changes::{
DELETION_TEXT_CHARS, DeletionBalloon, deletion_balloons, format_changes, has_deletions, has_format_changes, move_changes, tracking_json,
};
use changes::{list_changes, nav_change, resolve_all_then, resolve_sel_then, tracking_options};
use comments::{
comment_at_caret, comments_change, delete_comment, edit_comment, list_comments, nav_comment, new_comment, reply, validate_comment_id,
};
pub use comments::{comment_list, comment_range_at_caret};
use comments::{comments_change, delete_comment, edit_comment, list_comments, nav_comment, new_comment, reply, resolve_comment};
use proofing::{all_issues, issue_at, next_issue, suggestions, thesaurus, word_count};
pub fn specs() -> Vec<CommandSpec> {
@@ -37,14 +35,8 @@ pub fn specs() -> Vec<CommandSpec> {
CommandSpec::new("review.deleteComment", "Delete", "Review › Comments", delete_comment).params(
r#"{"id"?: non-negative 32-bit JSON integer (omit to use the caret), "all"?: bool (every comment), "resolved"?: bool (every resolved comment, with its replies; wins over all)}"#,
),
CommandSpec::new("review.resolveComment", "Resolve", "Review › Comments", |s, v| {
validate_comment_id(v)?;
let id = p::u64(v, "id").map(|x| x as u32).or_else(|| comment_at_caret(s)).ok_or_else(|| CmdError::Params("`id` required".into()))?;
let c = s.doc.comments.get_mut(&id).ok_or_else(|| CmdError::Params("no such comment".into()))?;
c.resolved = p::bool(v, "value").unwrap_or(!c.resolved);
sel_result(s)
})
.params(r#"{"id"?: non-negative 32-bit JSON integer (omit to use the caret), "value"?: bool (omit to toggle)}"#),
CommandSpec::new("review.resolveComment", "Resolve", "Review › Comments", resolve_comment)
.params(r#"{"id"?: non-negative 32-bit JSON integer (a comment or reply; omit to use the caret), "value"?: bool (omit to toggle the whole thread)}"#),
CommandSpec::new("review.nextComment", "Next", "Review › Comments", |s, _| nav_comment(s, 1)).pure(),
CommandSpec::new("review.previousComment", "Previous", "Review › Comments", |s, _| nav_comment(s, -1)).pure(),
CommandSpec::new("review.comments", "Show Comments", "Review › Comments", list_comments).pure(),
+59 -9
View File
@@ -26,7 +26,8 @@ fn resolve_runs(para: &mut wordcraft_doc::Paragraph, from: usize, to: usize, pro
}
/// Accept or reject a revision range in one paragraph; `mark` includes its paragraph mark (and
/// the section break on it), `props` the paragraph's own formatting change.
/// the section break on it), `props` the paragraph's own formatting change. If the next
/// paragraph moves into this path, return how many bytes of this paragraph precede it.
fn resolve_para(
s: &mut Session,
story: StoryRef,
@@ -34,11 +35,11 @@ fn resolve_para(
(from, to): (usize, usize),
(mark, props): (bool, bool),
accept: bool,
) -> Result<(), CmdError> {
) -> Result<Option<usize>, CmdError> {
let para = s.doc.para_mut(story, path)?;
resolve_runs(para, from, to, props, accept)?;
if !mark {
return Ok(());
return Ok(None);
}
if para.mark.fmt_change.is_some() || para.section.as_ref().is_some_and(|x| x.fmt_change.is_some()) {
fmt_revisions::resolve_char(&mut para.mark, accept);
@@ -49,8 +50,9 @@ fn resolve_para(
}
let (ins, del) = (para.mark.ins, para.mark.del);
if ins.is_none() && del.is_none() {
return Ok(());
return Ok(None);
}
let prefix_len = para.len();
// An inserted paragraph mark that is rejected, or a deleted one that is accepted, goes away:
// the next paragraph joins this one (the split is undone). A paragraph left empty goes away
// whole, so the next one keeps its own style and numbering, as in Word. The end mark of a
@@ -66,15 +68,18 @@ fn resolve_para(
if sectioned {
s.doc.remove_section_break(path.last());
}
if crate::cmd::remove_empty_para(s, story, path)? || crate::cmd::join_next_para(s, story, path)? {
return Ok(());
if crate::cmd::remove_empty_para(s, story, path)? {
return Ok(Some(0));
}
if crate::cmd::join_next_para(s, story, path)? {
return Ok(Some(prefix_len));
}
}
let para = s.doc.para_mut(story, path)?;
para.mark.ins = None;
para.mark.del = None;
para.touch();
Ok(())
Ok(None)
}
/// Remove the whole paragraph at `path` when a whole-paragraph revision on its mark resolved to
@@ -259,7 +264,49 @@ fn resolve_loose_blocks(blocks: &mut wordcraft_doc::Blocks, accept: bool) -> Res
Ok(())
}
/// Byte offset after resolving the runs in the endpoint's original paragraph. Only apply it
/// when paragraph removal or joining also moves the endpoint.
fn resolved_offset(s: &Session, end: &Pos, accept: bool) -> usize {
let Some(para) = s.doc.para_at(end) else { return end.off };
let removed: usize = para
.run_ranges()
.filter(|(_, c)| if accept { c.del.is_some() } else { c.ins.is_some() })
.map(|(range, _)| end.off.min(range.end).saturating_sub(range.start))
.sum();
end.off - removed
}
/// The next paragraph has moved into `path` (empty removal) or been appended to its surviving
/// prefix (join). Later siblings, including a table containing an endpoint, shift one block back.
fn remap_after_middle_paragraph(s: &mut Session, story: StoryRef, path: &wordcraft_doc::Path, prefix_len: usize, offsets: &mut [usize; 2]) {
let depth = path.parent().len();
for (end, offset) in [&mut s.sel.anchor, &mut s.sel.focus].into_iter().zip(offsets) {
if end.story != story || !end.path.0.starts_with(path.parent()) {
continue;
}
let Some(&block) = end.path.0.get(depth) else { continue };
if block as usize > path.last() {
let mut dest = end.path.clone();
dest.0[depth] -= 1;
// An endpoint in a terminal paragraph removed earlier still uses terminal clamping.
if s.doc.para(story, &dest).is_none() {
continue;
}
if &dest == path {
*offset = offset.saturating_add(prefix_len);
}
end.path = dest;
} else if &end.path == path {
*offset = (*offset).min(prefix_len);
} else {
continue;
}
end.off = *offset;
}
}
fn resolve_all(s: &mut Session, accept: bool) -> CmdResult {
let mut offsets = [&s.sel.anchor, &s.sel.focus].map(|end| resolved_offset(s, end, accept));
let stories: Vec<StoryRef> = std::iter::once(StoryRef::Body).chain(s.doc.parts.keys().map(|k| StoryRef::Part(*k))).collect();
for st in stories {
for path in s.doc.para_paths(st).into_iter().rev() {
@@ -269,7 +316,7 @@ fn resolve_all(s: &mut Session, accept: bool) -> CmdResult {
let is_last = s.doc.block(st, &path.with_last(path.last().saturating_add(1))).is_none();
let trailing = is_last && s.doc.para(st, &path).is_some_and(|p| (p.mark.del.is_some() && accept) || (p.mark.ins.is_some() && !accept));
let len = s.doc.para(st, &path).map(|p| p.len()).unwrap_or(0);
resolve_para(s, st, &path, (0, len), (true, true), accept)?;
let prefix_len = resolve_para(s, st, &path, (0, len), (true, true), accept)?;
if trailing && remove_trailing_para(s, st, &path)? {
// Selection ends in the removed paragraph go to the end of the one before it;
// clamping later would keep their offsets in that paragraph's text (#8500).
@@ -279,6 +326,9 @@ fn resolve_all(s: &mut Session, accept: bool) -> CmdResult {
}
}
}
if let Some(prefix_len) = prefix_len {
remap_after_middle_paragraph(s, st, &path, prefix_len, &mut offsets);
}
}
}
// Tables, rows, cells, sections and style definitions.
@@ -963,7 +1013,7 @@ fn resolve_sel(s: &mut Session, accept: bool, next: bool) -> CmdResult {
// A paragraph's mark is in the selection when the selection goes on past it.
let mark = path != b.path || caret_mark.as_ref() == Some(&path);
let props = (ranged && (path != b.path || to > from)) || caret_props.as_ref() == Some(&path);
resolve_para(s, a.story, &path, (from, to), (mark, props), accept)?;
let _ = resolve_para(s, a.story, &path, (from, to), (mark, props), accept)?;
if ranged {
resolve_cell(s, a.story, &path, accept)?;
}
+23
View File
@@ -186,6 +186,29 @@ fn threads_of(s: &Session, roots: impl IntoIterator<Item = u32>) -> Vec<u32> {
ids
}
/// Resolve or reopen the whole discussion, even when the target is a reply. A toggle uses
/// the target's state, matching its Resolve/Reopen button even in a mixed-state file.
pub(super) fn resolve_comment(s: &mut Session, v: &Value) -> CmdResult {
validate_comment_id(v)?;
let id = p::u64(v, "id").map(|x| x as u32).or_else(|| comment_at_caret(s)).ok_or_else(|| CmdError::Params("`id` required".into()))?;
let c = s.doc.comments.get(&id).ok_or_else(|| CmdError::Params("no such comment".into()))?;
let resolved = p::bool(v, "value").unwrap_or(!c.resolved);
let mut root = id;
let mut seen = BTreeSet::new();
while seen.insert(root) {
match s.doc.comments.get(&root).and_then(|c| c.parent).filter(|p| s.doc.comments.contains_key(p)) {
Some(parent) => root = parent,
None => break,
}
}
for id in threads_of(s, [root]) {
if let Some(c) = s.doc.comments.get_mut(&id) {
c.resolved = resolved;
}
}
sel_result(s)
}
pub(super) fn delete_comment(s: &mut Session, v: &Value) -> CmdResult {
validate_comment_id(v)?;
let ids: Vec<u32> = if p::bool(v, "resolved").unwrap_or(false) {
+66 -1
View File
@@ -311,7 +311,7 @@ fn comment_range_at_caret_needs_the_caret_inside_the_range() {
assert_eq!(super::comment_range_at_caret(&s), Some(id), "inside the commented text");
s.run("select.text", &json!({"text": "three"})).unwrap();
assert_eq!(super::comment_range_at_caret(&s), None, "elsewhere in the paragraph");
assert_eq!(super::comment_at_caret(&s), Some(id), "the older lookup still falls back to the paragraph's comment");
assert_eq!(super::comments::comment_at_caret(&s), Some(id), "the older lookup still falls back to the paragraph's comment");
}
fn glyph_text(d: &[Draw]) -> String {
@@ -1000,6 +1000,71 @@ fn deleting_a_comment_deletes_replies_to_replies() {
assert_eq!(anchors(&s).len(), 2);
}
/// Resolving from the root, the caret or a nested reply changes the whole discussion in one
/// undo step. Reopening is also thread-wide, and unrelated discussions stay untouched.
#[test]
fn resolving_a_comment_changes_its_whole_thread() {
let mut s = Session::new(Document::from_text("first second"));
s.run("select.text", &json!({"text": "first"})).unwrap();
let root = s.run("review.newComment", &json!({"text": "root"})).unwrap()["id"].as_u64().unwrap();
let reply = s.run("review.reply", &json!({"id": root, "text": "reply"})).unwrap()["id"].as_u64().unwrap();
let nested = s.run("review.reply", &json!({"id": reply, "text": "nested"})).unwrap()["id"].as_u64().unwrap();
s.run("review.reply", &json!({"id": root, "text": "sibling"})).unwrap();
s.run("select.text", &json!({"text": "second"})).unwrap();
let other = s.run("review.newComment", &json!({"text": "other"})).unwrap()["id"].as_u64().unwrap() as u32;
s.run("select.text", &json!({"text": "first"})).unwrap();
let before = s.doc.comments.clone();
let body = s.doc.body.clone();
let parts = s.doc.parts.clone();
let depth = s.undo_depth();
let mut resolved = before.clone();
for (id, c) in &mut resolved {
c.resolved = *id != other;
}
for params in [json!({"id": root, "value": true}), json!({}), json!({"id": nested})] {
s.run("review.resolveComment", &params).unwrap();
assert_eq!(s.doc.comments, resolved, "{params}: all replies resolve, not the other discussion");
assert_eq!(s.undo_depth(), depth + 1, "one undo step for the whole thread");
s.run("review.resolveComment", &json!({"id": reply, "value": true})).unwrap();
assert_eq!(s.undo_depth(), depth + 1, "resolving an already resolved thread adds no step");
s.run("edit.undo", &json!({})).unwrap();
assert_eq!(s.doc.comments, before, "one undo restores every comment");
s.run("edit.redo", &json!({})).unwrap();
assert_eq!(s.doc.comments, resolved);
s.run("review.resolveComment", &json!({"id": nested})).unwrap();
assert_eq!(s.doc.comments, before, "toggling a reply reopens the whole thread");
s.run("edit.undo", &json!({})).unwrap();
assert_eq!(s.doc.comments, resolved);
s.run("edit.undo", &json!({})).unwrap();
assert_eq!(s.doc.comments, before);
}
assert_eq!(s.doc.body, body, "resolution leaves the body and anchors alone");
assert_eq!(s.doc.parts, parts, "resolution leaves the comments' text alone");
}
/// Imported comments can have mixed resolved flags, missing parents or a parent cycle. A
/// thread operation reconciles the connected comments without following a missing parent.
#[test]
fn resolving_a_comment_handles_mixed_state_and_broken_parent_links() {
use wordcraft_doc::Comment;
for parent in [None, Some(99), Some(2)] {
let mut doc = Document::new();
doc.comments.insert(0, Comment { resolved: true, parent, ..Default::default() });
doc.comments.insert(1, Comment { parent: Some(0), ..Default::default() });
doc.comments.insert(2, Comment { parent: Some(1), ..Default::default() });
doc.comments.insert(3, Comment { parent: Some(99), ..Default::default() });
let mut s = Session::new(doc);
s.run("review.resolveComment", &json!({"id": 2})).unwrap();
assert!(
s.doc.comments.iter().all(|(id, c)| c.resolved == (*id != 3)),
"a reply's Resolve action must not reopen its resolved parent: {parent:?}"
);
s.run("review.resolveComment", &json!({"id": 1, "value": false})).unwrap();
assert!(s.doc.comments.values().all(|c| !c.resolved), "{parent:?}");
}
}
/// A parent cycle (possible in a hostile file) doesn't hang Delete; both comments go.
#[test]
fn deleting_a_comment_in_a_parent_cycle_ends() {
+1 -1
View File
@@ -1,7 +1,7 @@
use super::cells::{cell, cell_at, grid_cols, row_ends, selected_cells};
use super::{CmdError, CmdResult, Paragraph, Path, Pos, Selection, Session, StoryRef, Value, sel_result};
/// Ctrl+A in a table, as in Word: the cell, then its row, then the table. A nested table that
/// Explicit staged select-all in a table: the cell, then its row, then the table. A nested table that
/// is already fully selected grows to the cell around it. Returns `None` when the next step is
/// the whole story (not in a table, or the top-level table is already selected).
pub(crate) fn grow_select_all(s: &mut Session) -> Option<CmdResult> {
+4 -4
View File
@@ -630,10 +630,10 @@ fn room_right(l: &DocLayout, doc: &Document, page: usize, target: &ResizeTarget)
let Some(b) = boxes.iter().find(|b| b.story == target.story && b.table == outer && b.row == row && b.cell == cell) else {
return margin;
};
// A right-to-left table has its cells' start (left) margin on their right.
let m = wordcraft_layout::cell_margins(doc, t, row, cell);
let inset = if t.props.bidi_visual { m[1] } else { m[3] };
(b.rect.right() - inset).min(margin)
// A cell's right margin is on its right in a right-to-left table too, as the layout draws
// it (#6941): Word doesn't mirror cell margins.
let right_margin = wordcraft_layout::cell_margins(doc, t, row, cell)[3];
(b.rect.right() - right_margin).min(margin)
}
#[cfg(test)]
@@ -534,6 +534,46 @@ fn a_nested_tables_column_fits_within_its_cell() {
assert_eq!((host1.x, host1.w), (host.x, host.w), "the table around it keeps its columns");
}
/// #8441: a right-to-left table keeps its cells' right margins on their right (#6941), so a
/// nested table in such a cell fits up to that cell's right margin, not its left one, when the
/// two differ.
#[test]
fn a_nested_tables_column_fits_within_a_right_to_left_cell() {
let mut s = rtl_table_session(1, 2);
s.sel = Selection::caret(cell_pos(&s, 0, 0));
s.run("insert.table", &json!({"rows": 1, "cols": 2})).unwrap();
let (inner, _, _) = s.sel.focus.path.cell().unwrap();
let outer = table_path(&s);
// A left margin of 20 pt and a right one of 2 pt; the nested table itself left to right.
s.doc.table_mut(StoryRef::Body, &outer).unwrap().rows[0].cells[0].props.margins = Some([0.0, 20.0, 0.0, 2.0]);
s.doc.table_mut(StoryRef::Body, &inner).unwrap().props.bidi_visual = false;
s.touch();
let rect = |s: &mut Session, table: &Path, cell: usize| {
s.layout().pages[0]
.items
.iter()
.find_map(|it| match it {
Placed::Cell { rect, table: t, row: 0, cell: c, .. } if t == table && *c == cell => Some(*rect),
_ => None,
})
.unwrap()
};
for col in [1, 0] {
let r = rect(&mut s, &inner, col);
s.run("table.fitColumn", &json!({"page": 0, "x": r.right(), "y": mid_y(r)})).unwrap();
}
s.run("text.insert", &json!({"text": "word ".repeat(40)})).unwrap();
let host = rect(&mut s, &outer, 0);
let (a, b) = (rect(&mut s, &inner, 0), rect(&mut s, &inner, 1));
assert!(b.right() < host.right() - 40.0, "{b:?} in {host:?}");
s.run("table.fitColumn", &json!({"page": 0, "x": a.right(), "y": mid_y(a)})).unwrap();
let b1 = rect(&mut s, &inner, 1);
let text_right = host.right() - 2.0;
assert!((b1.right() - text_right).abs() < 0.5, "the table fills its cell's text up to its right margin: {b1:?}, {text_right}");
let host1 = rect(&mut s, &outer, 0);
assert_eq!((host1.x, host1.w), (host.x, host.w), "the table around it keeps its columns");
}
/// Pasting formatting onto a selected column leaves its text (it used to clear it).
#[test]
fn the_format_painter_keeps_a_selected_columns_text() {
+15 -3
View File
@@ -206,7 +206,11 @@ pub(super) fn tab(s: &mut Session, _: &Value) -> CmdResult {
&& n.num != 0
{
let para = s.doc.para_mut(f.story, &f.path)?;
para.props.numbering = Some(NumRef { num: n.num, level: n.level.saturating_add(1).min(8) });
let level = n.level.saturating_add(1).min(8);
para.props.numbering = Some(NumRef { num: n.num, level });
if level != n.level {
crate::cmd::para::drop_direct_indents(&mut para.props);
}
para.touch();
return sel_result(s);
}
@@ -255,7 +259,11 @@ fn indent_by_tab(s: &mut Session, f: &Pos) -> CmdResult {
&& let Some(n) = r.numbering.filter(|n| n.num != 0)
{
let p = s.doc.para_mut(f.story, &f.path)?;
p.props.numbering = Some(NumRef { num: n.num, level: n.level.saturating_add(1).min(8) });
let level = n.level.saturating_add(1).min(8);
p.props.numbering = Some(NumRef { num: n.num, level });
if level != n.level {
crate::cmd::para::drop_direct_indents(&mut p.props);
}
p.touch();
return sel_result(s);
}
@@ -288,7 +296,11 @@ pub(super) fn back_tab(s: &mut Session, _: &Value) -> CmdResult {
let f = s.sel.focus.clone();
if let Some(n) = s.doc.para_at(&f).and_then(|x| x.props.numbering).filter(|n| n.num != 0) {
let para = s.doc.para_mut(f.story, &f.path)?;
para.props.numbering = Some(NumRef { num: n.num, level: n.level.saturating_sub(1) });
let level = n.level.saturating_sub(1);
para.props.numbering = Some(NumRef { num: n.num, level });
if level != n.level {
crate::cmd::para::drop_direct_indents(&mut para.props);
}
para.touch();
return sel_result(s);
}
+20 -9
View File
@@ -260,12 +260,12 @@ fn diff_notes(
}
for &new_id in &notes.inserted {
if let Some(part) = doc.parts.get_mut(&new_id) {
part.blocks = part.blocks.iter().map(|b| Arc::new(mark_block(b, &|c| c.ins = Some(ctx.ins)))).collect();
part.blocks = part.blocks.iter().map(|b| Arc::new(mark_block(b, &|c| c.ins = Some(ctx.ins), &|_| {}))).collect();
}
}
for &orig_id in &notes.deleted {
if let Some(part) = doc.parts.get_mut(&orig_id) {
part.blocks = part.blocks.iter().map(|b| Arc::new(mark_block(b, &|c| c.del = Some(ctx.del)))).collect();
part.blocks = part.blocks.iter().map(|b| Arc::new(mark_block(b, &|c| c.del = Some(ctx.del), &|_| {}))).collect();
}
}
}
@@ -443,14 +443,18 @@ fn diff_blocks(doc: &mut Document, old: &[Arc<Block>], new: &[Arc<Block>], ctx:
(Some(Block::Para(pa)), Some(Block::Para(pb))) => out.push(para_block(word_diff(doc, pa, pb, ctx))),
_ => {
if let Some(x) = a {
out.push(Arc::new(mark_block(x, &|c| {
// An existing deletion is another author's: keep their revision
// stamp instead of re-attributing the paragraph to this compare.
c.del.get_or_insert(ctx.del);
})));
out.push(Arc::new(mark_block(
x,
&|c| {
// An existing deletion is another author's: keep their revision
// stamp instead of re-attributing the paragraph to this compare.
c.del.get_or_insert(ctx.del);
},
&|_| {},
)));
}
if let Some(x) = b {
out.push(Arc::new(mark_block(x, &|c| c.ins = Some(ctx.ins))));
out.push(Arc::new(mark_block(x, &|c| c.ins = Some(ctx.ins), &|c| c.del = None)));
}
}
}
@@ -1627,7 +1631,13 @@ fn block_text(b: &Block, depth: usize) -> String {
/// where the paragraph carries a section break or is the container's only paragraph. A
/// non-terminal section-carrying paragraph is removed whole too: `resolve_para` removes the
/// section break first (#5734, issue #5667), so the following paragraph keeps its own properties.
fn mark_block(b: &Block, f: &dyn Fn(&mut CharProps)) -> Block {
///
/// `mark` additionally updates each paragraph mark. A whole inserted block keeps only the
/// compare's insertion on its mark: a `del` the revised document's mark already carried (a pending
/// deletion by another author) must not survive next to the compare's `ins` — on accept the
/// deletion branch would resolve the inserted paragraph away (#6899). Run-level revisions of the
/// source block are left alone.
fn mark_block(b: &Block, f: &dyn Fn(&mut CharProps), mark: &dyn Fn(&mut CharProps)) -> Block {
let mut out = b.clone();
let mut todo = vec![&mut out];
while let Some(blk) = todo.pop() {
@@ -1636,6 +1646,7 @@ fn mark_block(b: &Block, f: &dyn Fn(&mut CharProps)) -> Block {
let len = p.len();
let _ = p.format(0, len, f);
f(&mut p.mark);
mark(&mut p.mark);
p.touch();
}
Block::Table(t) => {
+199 -62
View File
@@ -16,6 +16,103 @@ fn empty_paras(s: &Session) -> usize {
s.doc.body.iter().filter(|b| matches!(b.as_para(), Some(p) if p.is_empty())).count()
}
#[test]
fn compare_marks_a_whole_paragraph_and_its_mark() {
// A whole inserted paragraph carries the insertion on its mark, not just on its runs.
let mut s = Session::new(Document::from_text("A\nB"));
s.run("review.compare", &json!({"text": "A\nNEW\nB"})).unwrap();
assert_eq!(s.doc.body.len(), 3);
let mid = s.doc.body[1].as_para().unwrap();
assert_eq!(mid.plain_text(), "NEW");
assert!(mid.mark.ins.is_some(), "the inserted paragraph's mark is not marked inserted");
s.run("review.rejectAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nB");
assert_eq!(s.doc.body.len(), 2);
assert_eq!(empty_paras(&s), 0, "rejecting an inserted paragraph left an empty paragraph behind");
let mut s = Session::new(Document::from_text("A\nB"));
s.run("review.compare", &json!({"text": "A\nNEW\nB"})).unwrap();
s.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nNEW\nB");
assert_eq!(s.doc.body.len(), 3);
assert_eq!(empty_paras(&s), 0, "accepting an inserted paragraph left an empty paragraph behind");
// A whole deleted paragraph carries the deletion on its mark.
let mut s = Session::new(Document::from_text("A\nOLD\nB"));
s.run("review.compare", &json!({"text": "A\nB"})).unwrap();
assert_eq!(s.doc.body.len(), 3);
let mid = s.doc.body[1].as_para().unwrap();
assert_eq!(mid.plain_text(), "OLD");
assert!(mid.mark.del.is_some(), "the deleted paragraph's mark is not marked deleted");
s.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nB");
assert_eq!(s.doc.body.len(), 2);
assert_eq!(empty_paras(&s), 0, "accepting a deleted paragraph left an empty paragraph behind");
let mut s = Session::new(Document::from_text("A\nOLD\nB"));
s.run("review.compare", &json!({"text": "A\nB"})).unwrap();
s.run("review.rejectAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nOLD\nB");
assert_eq!(s.doc.body.len(), 3);
assert_eq!(empty_paras(&s), 0, "rejecting a deleted paragraph left an empty paragraph behind");
}
#[test]
fn resolving_a_middle_paragraph_keeps_the_caret_with_its_text() {
for (original, revised, command) in [("A\nB\nC", "A\nNEW\nB\nC", "review.rejectAll"), ("A\nOLD\nB\nC", "A\nB\nC", "review.acceptAll")] {
let mut s = Session::new(Document::from_text(original));
s.run("review.compare", &json!({"text": revised})).unwrap();
s.sel = Selection::caret(Pos::body(2, 1));
s.run(command, &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nB\nC");
assert!(s.sel.is_collapsed());
assert_eq!(s.sel.focus, Pos::body(1, 1), "{command} keeps the caret after B");
s.run("text.insert", &json!({"text": "!"})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nB!\nC");
}
}
#[test]
fn accepting_a_middle_paragraph_join_keeps_the_backward_selection() {
let mut s = Session::new(Document::from_text("A\néDROP\nX🙂B\nC"));
s.run("review.trackChanges", &json!({"value": true})).unwrap();
s.sel = Selection { anchor: Pos::body(1, "é".len()), focus: Pos::body(2, "X".len()) };
s.run("text.delete", &json!({})).unwrap();
s.sel = Selection { anchor: Pos::body(2, "X🙂".len()), focus: Pos::body(1, 0) };
s.run("review.acceptAll", &json!({"stopTracking": true})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\né🙂B\nC");
assert_eq!(s.sel.anchor, Pos::body(1, "é🙂".len()));
assert_eq!(s.sel.focus, Pos::body(1, 0));
s.run("text.insert", &json!({"text": "Q"})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nQB\nC");
}
#[test]
fn compare_marks_an_empty_paragraphs_mark() {
// An empty inserted paragraph is stamped on its mark, though `format` skips its empty range.
let mut s = Session::new(Document::from_text("A\nB"));
s.run("review.compare", &json!({"text": "A\n\nB"})).unwrap();
assert_eq!(s.doc.body.len(), 3);
let empty = s.doc.body[1].as_para().unwrap();
assert!(empty.is_empty());
assert!(empty.mark.ins.is_some(), "the empty inserted paragraph's mark is not marked inserted");
s.run("review.rejectAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nB");
assert_eq!(s.doc.body.len(), 2);
assert_eq!(empty_paras(&s), 0, "rejecting an empty inserted paragraph left it behind");
// An empty deleted paragraph is stamped on its mark too.
let mut s = Session::new(Document::from_text("A\n\nB"));
s.run("review.compare", &json!({"text": "A\nB"})).unwrap();
assert_eq!(s.doc.body.len(), 3);
let empty = s.doc.body[1].as_para().unwrap();
assert!(empty.is_empty());
assert!(empty.mark.del.is_some(), "the empty deleted paragraph's mark is not marked deleted");
s.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "A\nB");
assert_eq!(s.doc.body.len(), 2);
assert_eq!(empty_paras(&s), 0, "accepting an empty deleted paragraph left it behind");
}
#[test]
fn compare_keeps_another_authors_deletion_stamp() {
// A paragraph the original already carries as a tracked deletion by another author: Compare
@@ -1679,6 +1776,43 @@ fn compare_lcs_window_move_past_cap_does_not_cascade_false_revisions() {
assert_eq!(s.doc.plain_text(StoryRef::Body), revised);
}
fn assert_whole_block_mark_compare(from: &str, to: &str, expected_mid: &str, is_del: bool, preserve_bold: bool) {
let expected_empty = |text: &str| text.split('\n').filter(|line| line.is_empty()).count();
let from_len = from.split('\n').count();
let to_len = to.split('\n').count();
let mut s = Session::new(Document::from_text(from));
if preserve_bold && let Some(Block::Para(p)) = s.doc.body.get_mut(1).map(Arc::make_mut) {
p.mark.bold = Some(true);
}
s.run("review.compare", &json!({"text": to})).unwrap();
assert_eq!(s.doc.body.len(), 3);
let mid = s.doc.body[1].as_para().expect("block 1 must be paragraph");
assert_eq!(mid.plain_text(), expected_mid);
if expected_mid.is_empty() {
assert_eq!(mid.len(), 0);
}
if is_del {
assert!(mid.mark.del.is_some(), "whole-block delete must record revision on paragraph mark");
} else {
assert!(mid.mark.ins.is_some(), "whole-block insert must record revision on paragraph mark");
}
if preserve_bold {
assert_eq!(mid.mark.bold, Some(true), "paragraph mark formatting must be preserved on deleted block");
}
let mut s_rej = Session::new(s.doc.clone());
s_rej.run("review.rejectAll", &json!({})).unwrap();
assert_eq!(s_rej.doc.plain_text(StoryRef::Body), from);
assert_eq!(s_rej.doc.body.len(), from_len);
assert_eq!(empty_paras(&s_rej), expected_empty(from), "rejecting a whole-block revision changed empty paragraph count");
s.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), to);
assert_eq!(s.doc.body.len(), to_len);
assert_eq!(empty_paras(&s), expected_empty(to), "accepting a whole-block revision changed empty paragraph count");
}
/// Verifies that `mark_block` records paragraph mark revisions on whole-block deletions,
/// whole-block insertions, empty paragraphs, and ensures clean resolution via `review.acceptAll`
/// and `review.rejectAll`.
@@ -1687,75 +1821,78 @@ fn compare_mark_block_records_paragraph_mark_revisions_on_whole_block_changes()
// Whole block delete/insert: test with differing paragraph count so whole-block paths trigger
let orig_multi = "Keep start.\nDelete me.\nKeep end.";
let rev_multi = "Keep start.\nKeep end.";
let mut s2 = Session::new(Document::from_text(orig_multi));
if let Some(Block::Para(p)) = s2.doc.body.get_mut(1).map(Arc::make_mut) {
p.mark.bold = Some(true);
}
s2.run("review.compare", &json!({"text": rev_multi})).unwrap();
// In s2.doc.body, block 1 was deleted whole.
// Verify that p.mark.del is recorded by mark_block and formatting is preserved.
let del_para = s2.doc.body[1].as_para().expect("block 1 must be paragraph");
assert!(del_para.mark.del.is_some(), "whole-block delete must record revision on paragraph mark");
assert_eq!(del_para.mark.bold, Some(true), "paragraph mark formatting must be preserved on deleted block");
let mut s2_rej = Session::new(s2.doc.clone());
s2_rej.run("review.rejectAll", &json!({})).unwrap();
assert_eq!(s2_rej.doc.plain_text(StoryRef::Body), orig_multi);
assert_eq!(s2_rej.doc.body.len(), 3);
assert_eq!(empty_paras(&s2_rej), 0, "rejecting a deleted paragraph left an empty paragraph behind");
// Accept all changes: deleted paragraph is removed
s2.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s2.doc.plain_text(StoryRef::Body), rev_multi);
assert_eq!(s2.doc.body.len(), 2);
assert_eq!(empty_paras(&s2), 0, "accepting a deleted paragraph left an empty paragraph behind");
// Test whole-block insertion
let mut s3 = Session::new(Document::from_text(rev_multi));
s3.run("review.compare", &json!({"text": orig_multi})).unwrap();
let ins_para = s3.doc.body[1].as_para().expect("block 1 must be paragraph");
assert!(ins_para.mark.ins.is_some(), "whole-block insert must record revision on paragraph mark");
let mut s3_rej = Session::new(s3.doc.clone());
s3_rej.run("review.rejectAll", &json!({})).unwrap();
assert_eq!(s3_rej.doc.plain_text(StoryRef::Body), rev_multi);
assert_eq!(s3_rej.doc.body.len(), 2);
assert_eq!(empty_paras(&s3_rej), 0, "rejecting an inserted paragraph left an empty paragraph behind");
s3.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s3.doc.plain_text(StoryRef::Body), orig_multi);
assert_eq!(s3.doc.body.len(), 3);
assert_eq!(empty_paras(&s3), 0, "accepting an inserted paragraph left an empty paragraph behind");
assert_whole_block_mark_compare(orig_multi, rev_multi, "Delete me.", true, true);
assert_whole_block_mark_compare(rev_multi, orig_multi, "Delete me.", false, false);
// Test empty paragraph deletion and insertion (len == 0, where only mark carries the revision)
let orig_empty = "Before.\n\nAfter.";
let rev_empty = "Before.\nAfter.";
let mut s4 = Session::new(Document::from_text(orig_empty));
s4.run("review.compare", &json!({"text": rev_empty})).unwrap();
let empty_del = s4.doc.body[1].as_para().expect("empty paragraph block");
assert_eq!(empty_del.len(), 0);
assert!(empty_del.mark.del.is_some(), "empty paragraph deletion must set mark.del");
s4.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s4.doc.plain_text(StoryRef::Body), rev_empty);
assert_eq!(s4.doc.body.len(), 2);
assert_eq!(empty_paras(&s4), 0, "accepting an empty deleted paragraph left it behind");
assert_whole_block_mark_compare(orig_empty, rev_empty, "", true, false);
assert_whole_block_mark_compare(rev_empty, orig_empty, "", false, false);
}
let mut s5 = Session::new(Document::from_text(rev_empty));
s5.run("review.compare", &json!({"text": orig_empty})).unwrap();
let empty_ins = s5.doc.body[1].as_para().expect("empty paragraph block");
assert_eq!(empty_ins.len(), 0);
assert!(empty_ins.mark.ins.is_some(), "empty paragraph insertion must set mark.ins");
/// Issue #6899: when the revised document's paragraph mark already carries another author's
/// pending deletion, a whole-paragraph insertion by compare must not leave the mark with both
/// `ins` and `del` — on accept the deletion branch would remove the inserted paragraph (or join
/// it away), losing the inserted break. The revised clone's mark keeps only the compare's `ins`.
#[test]
fn compare_inserted_paragraph_mark_drops_a_foreign_del() {
use wordcraft_doc::{Revision, RevisionKind};
let mut rev = Document::from_text("Keep start.\nNew line.\nKeep end.");
rev.revisions.push(Revision { kind: RevisionKind::Delete, author: "Other".into(), date: String::new(), date_utc: None, move_name: None });
if let Some(Block::Para(p)) = rev.body.get_mut(1).map(Arc::make_mut) {
p.mark.del = Some(0);
}
let path = std::env::temp_dir().join(format!("wc-compare-6899-{}.docx", std::process::id()));
crate::io::save_path(&path, &rev).unwrap();
let check = crate::io::open_path(&path).unwrap();
assert!(check.body[1].as_para().unwrap().mark.del.is_some(), "the foreign del must survive the docx round-trip, or this test proves nothing");
let mut s5_rej = Session::new(s5.doc.clone());
s5_rej.run("review.rejectAll", &json!({})).unwrap();
assert_eq!(s5_rej.doc.plain_text(StoryRef::Body), rev_empty);
assert_eq!(s5_rej.doc.body.len(), 2);
assert_eq!(empty_paras(&s5_rej), 0, "rejecting an empty inserted paragraph left it behind");
let mut s = Session::new(Document::from_text("Keep start.\nKeep end."));
s.run("review.compare", &json!({"path": path.to_string_lossy()})).unwrap();
let _ = std::fs::remove_file(&path);
let ins = s.doc.body[1].as_para().expect("block 1 is the inserted paragraph");
assert!(ins.mark.ins.is_some(), "compare marks the whole inserted paragraph's mark");
assert!(ins.mark.del.is_none(), "the foreign del does not sit next to the compare's ins");
// Accepting keeps the inserted paragraph break: the text reads as the revised document's.
s.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s.doc.plain_text(StoryRef::Body), "Keep start.\nNew line.\nKeep end.");
}
s5.run("review.acceptAll", &json!({})).unwrap();
assert_eq!(s5.doc.plain_text(StoryRef::Body), orig_empty);
assert_eq!(s5.doc.body.len(), 3);
/// Issue #6899, inside a table: `mark_block` recurses into cells, so a paragraph mark there gets
/// the same treatment — a foreign `del` does not sit next to the compare's `ins`.
#[test]
fn compare_inserted_table_cell_paragraph_mark_drops_a_foreign_del() {
use wordcraft_doc::{Revision, RevisionKind, Table};
let mut rev = Document::from_text("Keep start.\nKeep end.");
rev.revisions.push(Revision { kind: RevisionKind::Delete, author: "Other".into(), date: String::new(), date_utc: None, move_name: None });
let mut t = Table::new(1, 1, 200.0);
if let Some(c) = t.rows.first_mut().and_then(|r| r.cells.first_mut())
&& let Some(Block::Para(p)) = c.blocks.first_mut().map(Arc::make_mut)
{
p.mark.del = Some(0);
}
rev.body.insert(1, Arc::new(Block::Table(t)));
let path = std::env::temp_dir().join(format!("wc-compare-6899-table-{}.docx", std::process::id()));
crate::io::save_path(&path, &rev).unwrap();
let check = crate::io::open_path(&path).unwrap();
let cell_marked = check.body.iter().any(|b| match &**b {
Block::Table(t) => {
t.rows.iter().flat_map(|r| r.cells.iter()).flat_map(|c| c.blocks.iter()).any(|b| b.as_para().is_some_and(|p| p.mark.del.is_some()))
}
_ => false,
});
assert!(cell_marked, "the cell paragraph's foreign del must survive the docx round-trip, or this test proves nothing");
let mut s = Session::new(Document::from_text("Keep start.\nKeep end."));
s.run("review.compare", &json!({"path": path.to_string_lossy()})).unwrap();
let _ = std::fs::remove_file(&path);
let Some(Block::Table(t)) = s.doc.body.get(1).map(|b| &**b) else { panic!("block 1 is the inserted table") };
let cell_para = t.rows[0].cells[0].blocks[0].as_para().expect("the cell paragraph");
assert!(cell_para.mark.ins.is_some(), "compare marks the inserted cell paragraph's mark");
assert!(cell_para.mark.del.is_none(), "the foreign del does not sit next to the compare's ins");
s.run("review.acceptAll", &json!({})).unwrap();
assert!(matches!(s.doc.body.get(1).map(|b| &**b), Some(Block::Table(_))), "accepting keeps the inserted table");
}
#[test]
+1 -1
View File
@@ -509,7 +509,7 @@ pub fn open_path_in(path: &std::path::Path, password: Option<&str>, region: &wor
/// Largest document file opened by path.
#[cfg(not(target_arch = "wasm32"))]
const MAX_DOCUMENT: u64 = 2 << 30;
const MAX_DOCUMENT: u64 = 2u64 << 30;
/// The bytes of the document at `path`, read as `file.open` reads a path: inside the automation
/// read root, and only a regular file of at most 2 GB. A named pipe would block the open and a
+18 -1
View File
@@ -92,7 +92,7 @@ pub fn save(ext: &str, doc: &Document, opts: &crate::io::ExportOptions) -> Optio
// Output shows the fields Word fills in as it prints (see `output_fields`).
let out = crate::cmd::references::output_fields(doc);
let doc = out.as_ref().unwrap_or(doc);
Some(crate::strict::export_pdf(doc, opts))
Some(crate::strict::export_pdf(&pdf_document(doc), opts))
}
other => wordcraft_formats::export_with(other, doc, &wordcraft_formats::ExportOptions { comments: opts.markup && opts.comments }),
}
@@ -142,6 +142,23 @@ pub fn render_png(doc: &Document, page: usize, scale: f32, opts: &crate::io::Exp
Ok(img.to_png())
}
/// Supply an absent or unreadable PDF creation date without changing the document or advancing
/// its revision. This covers direct exports and web downloads, which do not pass through
/// `stamp_save`.
///
/// Unreadable, not only absent: the DOCX reader takes `core.created` as it finds it, so a file can
/// arrive carrying something like `not-a-date`. The PDF writer cannot put that in a document and
/// falls back to the clock, which is the one thing a pinned date is meant to stop -- so the
/// question asked here is the writer's own (`reads_as_date`), not whether the string is empty
/// (noted in review).
pub(crate) fn pdf_document(doc: &Document) -> std::borrow::Cow<'_, Document> {
let mut output = std::borrow::Cow::Borrowed(doc);
if !wordcraft_pdf::reads_as_date(&doc.core.created) {
output.to_mut().core.created = crate::cmd::saved_iso();
}
output
}
#[cfg(test)]
pub(crate) mod tests {
use super::*;
+1 -1
View File
@@ -243,7 +243,7 @@ impl Session {
compress: p::bool(v, "compress").unwrap_or(true),
..Default::default()
};
let bytes = wordcraft_pdf::export_layout(doc, &lay, &opts).map_err(|e| CmdError::Failed(e.to_string()))?;
let bytes = wordcraft_pdf::export_layout(&crate::io_ext::pdf_document(doc), &lay, &opts).map_err(|e| CmdError::Failed(e.to_string()))?;
Ok((bytes, plan))
}
}
+1 -1
View File
@@ -106,7 +106,7 @@ impl Session {
pub fn stamp_save(&mut self) {
self.doc.settings.zoom = crate::cmd::view::saved_zoom(&self.view);
let core = &mut self.doc.core;
core.modified = crate::cmd::now_iso();
core.modified = crate::cmd::saved_iso();
if core.created.is_empty() {
core.created = core.modified.clone();
}
+45 -10
View File
@@ -3711,6 +3711,23 @@ fn tracked_table_changes_are_kept_as_formatting_changes() {
assert!(b && !ch, "Accept All keeps it");
}
#[test]
fn ctrl_a_inside_table_selects_document() {
let mut s = s();
run(&mut s, "text.insert", json!({"text": "Before"}));
run(&mut s, "text.newParagraph", json!({}));
run(&mut s, "insert.table", json!({"rows": 2, "cols": 2}));
run(&mut s, "text.insert", json!({"text": "A1"}));
assert!(s.sel.focus.path.cell().is_some());
run(&mut s, "select.all", json!({}));
assert_eq!(s.sel.ordered(), (s.doc.start_of(StoryRef::Body), s.doc.end_of(StoryRef::Body)));
assert!(s.column.is_none());
assert!(s.selected_text().contains("Before"));
assert!(s.selected_text().contains("A1"));
}
#[test]
fn select_all_grows_cell_then_row_then_table_then_document() {
let mut s = s();
@@ -3720,24 +3737,24 @@ fn select_all_grows_cell_then_row_then_table_then_document() {
run(&mut s, "text.insert", json!({"text": "A1"}));
assert_eq!(s.sel.focus.path.cell().map(|(_, r, c)| (r, c)), Some((0, 0)));
run(&mut s, "select.all", json!({}));
assert_eq!(cells(&s), Some(((0, 0), (0, 0))), "first Ctrl+A selects the cell");
run(&mut s, "select.all", json!({"whole": false}));
assert_eq!(cells(&s), Some(((0, 0), (0, 0))), "first staged selection selects the cell");
assert_eq!(s.selected_text(), "A1");
run(&mut s, "select.all", json!({}));
assert_eq!(cells(&s), Some(((0, 0), (0, 1))), "second Ctrl+A selects the row");
run(&mut s, "select.all", json!({"whole": false}));
assert_eq!(cells(&s), Some(((0, 0), (0, 1))), "second staged selection selects the row");
run(&mut s, "select.all", json!({}));
assert_eq!(cells(&s), Some(((0, 1), (0, 1))), "third Ctrl+A selects the table");
run(&mut s, "select.all", json!({"whole": false}));
assert_eq!(cells(&s), Some(((0, 1), (0, 1))), "third staged selection selects the table");
run(&mut s, "select.all", json!({}));
run(&mut s, "select.all", json!({"whole": false}));
assert!(s.column.is_none());
let (a, b) = s.sel.ordered();
assert_eq!(a, s.doc.start_of(StoryRef::Body));
assert_eq!(b, s.doc.end_of(StoryRef::Body));
assert!(s.selected_text().starts_with("Before"));
run(&mut s, "select.all", json!({}));
run(&mut s, "select.all", json!({"whole": false}));
let (a, b) = s.sel.ordered();
assert_eq!((a, b), (s.doc.start_of(StoryRef::Body), s.doc.end_of(StoryRef::Body)));
}
@@ -3748,8 +3765,8 @@ fn select_all_from_a_column_grows_to_the_table() {
run(&mut s, "insert.table", json!({"rows": 2, "cols": 2}));
run(&mut s, "table.selectColumn", json!({}));
assert_eq!(cells(&s), Some(((0, 1), (0, 0))));
run(&mut s, "select.all", json!({}));
assert_eq!(cells(&s), Some(((0, 1), (0, 1))), "Ctrl+A on a column selects the table");
run(&mut s, "select.all", json!({"whole": false}));
assert_eq!(cells(&s), Some(((0, 1), (0, 1))), "staged selection on a column selects the table");
}
#[test]
@@ -16333,3 +16350,21 @@ fn open_and_save_report_format_conversion_errors() {
}
});
}
#[test]
fn opening_open_document_files_reports_section_conversion_errors_without_replacing_the_document() {
let incoming = wordcraft_doc::Document::from_text("Incoming document");
let message = "OpenDocument page conversion failed";
for name in ["incoming.odt", "incoming.ott", "incoming.fodt"] {
let bytes = crate::io::save_bytes(name, &incoming).unwrap();
let params = json!({"path": name, "data": crate::cmd::insert::base64_encode(&bytes)});
let mut s = Session::new(wordcraft_doc::Document::from_text("Keep this document"));
let id = s.document_id();
let err = wordcraft_formats::with_shared_conversion_error(message, || s.run("file.open", &params)).unwrap_err();
assert!(err.to_string().contains(message), "{name}: {err}");
assert_eq!(s.document_id(), id, "{name}");
assert_eq!(text(&s), "Keep this document", "{name}");
run(&mut s, "file.open", params);
assert_eq!(text(&s), "Incoming document", "{name}");
}
}
+24
View File
@@ -6,6 +6,30 @@ use wordcraft_doc::Pos;
use crate::Session;
use crate::cmd::insert::base64_encode;
#[test]
fn format_state_reports_the_east_asian_theme_face_and_keeps_unresolved_and_mixed_controls() {
use std::sync::Arc;
use wordcraft_doc::props::ThemeFont;
use wordcraft_doc::{Document, Path, StoryRef};
let mut doc = Document::from_text("漢字");
Arc::make_mut(&mut doc.styles).default_chr.font_ea = Some("Times New Roman".into());
doc.para_mut(StoryRef::Body, &Path::top(0))
.unwrap()
.format(0, "漢".len(), &|props| props.font_ea_theme = Some(ThemeFont::MinorEastAsia))
.unwrap();
let mut fallback = Session::new(doc.clone());
fallback.run("select.all", &json!({})).unwrap();
assert_eq!(fallback.run("format.state", &json!({})).unwrap()["fontEastAsia"], "Times New Roman");
doc.passthrough.insert("wordcraft:theme.fonts".into(), Arc::new(b"minor\tface\tea\tExample CJK Face\n".to_vec()));
let mut s = Session::new(doc);
s.run("select.range", &json!({"anchor": Pos::body(0, 0), "focus": Pos::body(0, "漢".len())})).unwrap();
assert_eq!(s.run("format.state", &json!({})).unwrap()["fontEastAsia"], "Example CJK Face");
s.run("select.all", &json!({})).unwrap();
assert!(s.run("format.state", &json!({})).unwrap()["fontEastAsia"].is_null(), "the theme face and named face differ");
}
/// The bundled face `file` of family `original` renamed `family` (as long as `original`), so it
/// is a font the database doesn't have.
fn renamed(file: &str, original: &str, family: &str) -> Vec<u8> {
+83 -48
View File
@@ -4639,58 +4639,93 @@ fn issues_1281_1045_english_dialects_proof_typed_text() {
assert_eq!(words, ["21th"]);
}
/// #4281: Home › Numbering offers every preset, "a. b. c." among them, and picking another preset
/// for a list that is already numbered changes its style (only picking the same one again turns it off).
#[test]
fn the_numbering_gallery_presets_each_apply_and_switch_between_each_other() {
let labels = |s: &mut Session| numbers(s).into_iter().map(|(l, _)| l.unwrap_or_default()).collect::<Vec<_>>();
for (kind, want) in [
("numbered", ["1.", "2.", "3."]),
("numberedParen", ["1)", "2)", "3)"]),
("outline", ["I.", "II.", "III."]),
("upperLetter", ["A.", "B.", "C."]),
("lowerLetter", ["a)", "b)", "c)"]),
("lowerLetterDot", ["a.", "b.", "c."]),
("lowerRoman", ["i.", "ii.", "iii."]),
] {
let mut s = s();
typ(&mut s, "One\nTwo\nThree");
run(&mut s, "select.all", json!({}));
run(&mut s, "para.numbering", json!({"kind": kind}));
assert_eq!(labels(&mut s), want, "{kind}");
// Picking the same preset again turns the list off.
run(&mut s, "para.numbering", json!({"kind": kind}));
assert_eq!(labels(&mut s), ["", "", ""], "{kind} again");
}
// From one preset to another: the list changes style, it doesn't go off.
let mut s = s();
typ(&mut s, "One\nTwo\nThree");
run(&mut s, "select.all", json!({}));
run(&mut s, "para.numbering", json!({"kind": "numbered"}));
for (kind, want) in [("upperLetter", "A."), ("lowerLetterDot", "a."), ("lowerRoman", "i."), ("outline", "I."), ("numbered", "1.")] {
run(&mut s, "para.numbering", json!({"kind": kind}));
assert_eq!(labels(&mut s)[0], want, "to {kind}");
}
/// Where the first paragraph's list label starts (points from the page's text edge), and where its text starts.
fn label_and_text_x(s: &mut Session) -> (f32, f32) {
let l = s.layout();
l.pages
.iter()
.flat_map(|p| &p.items)
.find_map(|i| {
if let wordcraft_layout::Placed::Lines { para, l0: 0, .. } = i {
// The text starts where the first cluster is placed, after the label's suffix or tab stop.
para.label.as_ref().and_then(|lb| para.lines.first().and_then(|line| line.xs.first().map(|&x| (lb.x, x))))
} else {
None
}
})
.expect("a list label")
}
/// #4281: whatever level a list item is on, picking a different Numbering preset changes the list
/// and never turns it off; deeper levels of two presets can look alike.
/// #4287: changing a list item's level (Change List Level, Tab, Shift+Tab) puts it at the new level's
/// indent, also when it carried a direct indent (a ruler drag, a pasted block, a Word file's `w:ind`).
#[test]
fn another_numbering_preset_never_switches_a_list_off_at_any_level() {
let kinds = ["numbered", "numberedParen", "outline", "upperLetter", "lowerLetter", "lowerLetterDot", "lowerRoman"];
for a in kinds {
for b in kinds.into_iter().filter(|b| *b != a) {
for level in 0..9 {
let mut s = s();
typ(&mut s, "One");
run(&mut s, "para.numbering", json!({"kind": a}));
run(&mut s, "para.listLevel", json!({"level": level}));
run(&mut s, "para.numbering", json!({"kind": b}));
let label = numbers(&mut s).into_iter().next().and_then(|(l, _)| l);
assert!(label.is_some(), "{a} -> {b} at level {level} turned the list off");
}
}
fn changing_a_list_level_drops_a_direct_indent() {
// The reference: a fresh list item moved to level 2 with no direct indent in the way.
let fresh = |command: &str, params: serde_json::Value| {
let mut s = s();
typ(&mut s, "Item");
run(&mut s, "para.numbering", json!({"kind": "upperLetter"}));
run(&mut s, command, params);
label_and_text_x(&mut s)
};
let dragged = |command: &str, params: serde_json::Value| {
let mut s = s();
typ(&mut s, "Item");
run(&mut s, "para.numbering", json!({"kind": "upperLetter"}));
// The ruler's left-indent marker dragged to a custom place.
run(&mut s, "para.indents", json!({"left": 120.0, "firstLine": -6.0}));
run(&mut s, command, params);
label_and_text_x(&mut s)
};
for (command, params) in [("para.listLevel", json!({"level": 1})), ("para.indent", json!({}))] {
assert_eq!(dragged(command, params.clone()), fresh(command, params), "{command}");
}
// Tab at the start of the item takes it down a level the same way.
let tabbed = |drag: bool| {
let mut s = s();
typ(&mut s, "Item");
run(&mut s, "para.numbering", json!({"kind": "upperLetter"}));
if drag {
run(&mut s, "para.indents", json!({"left": 120.0, "firstLine": -6.0}));
}
run(&mut s, "caret.home", json!({}));
run(&mut s, "text.tab", json!({}));
label_and_text_x(&mut s)
};
assert_eq!(tabbed(true), tabbed(false), "text.tab");
// Shift+Tab takes it back up.
let backtabbed = |drag: bool| {
let mut s = s();
typ(&mut s, "Item");
run(&mut s, "para.numbering", json!({"kind": "upperLetter"}));
run(&mut s, "para.listLevel", json!({"level": 1}));
if drag {
run(&mut s, "para.indents", json!({"left": 200.0, "firstLine": -30.0}));
}
run(&mut s, "text.backTab", json!({}));
label_and_text_x(&mut s)
};
assert_eq!(backtabbed(true), backtabbed(false), "text.backTab");
// Back out (Shift+Tab) from level 2 to 1 as well.
let back = |drag: bool| {
let mut s = s();
typ(&mut s, "Item");
run(&mut s, "para.numbering", json!({"kind": "upperLetter"}));
run(&mut s, "para.listLevel", json!({"level": 1}));
if drag {
run(&mut s, "para.indents", json!({"left": 200.0, "firstLine": -30.0}));
}
run(&mut s, "para.outdent", json!({}));
label_and_text_x(&mut s)
};
assert_eq!(back(true), back(false), "para.outdent");
// A ruler drag with no level change sticks.
let mut s = s();
typ(&mut s, "Item");
run(&mut s, "para.numbering", json!({"kind": "upperLetter"}));
let before = label_and_text_x(&mut s);
run(&mut s, "para.indents", json!({"left": 120.0, "firstLine": -6.0}));
assert_ne!(label_and_text_x(&mut s), before, "the drag moves the item");
}
/// #6788: Enter in a paragraph with a drop cap makes a normal paragraph; only the first keeps
+11
View File
@@ -224,6 +224,17 @@ impl FontDb {
log::debug!("cataloged {n} system font faces");
*self.catalog.write().unwrap_or_else(std::sync::PoisonError::into_inner) = found;
self.catalog_gen.fetch_add(1, Ordering::AcqRel);
{
let mut sys = self.sys.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
sys.tried.clear();
sys.misses.clear();
}
self.fallbacks.write().unwrap_or_else(std::sync::PoisonError::into_inner).map.clear();
{
let mut rf = self.run_fallbacks.write().unwrap_or_else(std::sync::PoisonError::into_inner);
rf.map.clear();
rf.chars = 0;
}
n
}
+4 -7
View File
@@ -82,12 +82,12 @@ pub struct FontFace {
/// than the full-width figure in the table. Word's automatic spacing between East Asian and
/// Latin text is half of it (see `wordcraft_layout::para::grid::auto_space`).
pub avg_char_width: f64,
pub shaper: harfrust::ShaperData,
/// Variable fonts: the named instance's axis settings (user units; empty = default instance),
/// the normalised location and the shaper's view of it.
/// The shaper's view of the face, at the named instance's location for variable fonts.
pub hb: harfrust::Font,
/// Variable fonts: the named instance's axis settings (user units; empty = default instance)
/// and the normalised location.
pub coords: Vec<([u8; 4], f32)>,
pub(super) location: Location,
pub instance: Option<harfrust::ShaperInstance>,
/// Basic Multilingual Plane coverage bitset, built on first use.
pub(super) bmp: std::sync::OnceLock<Box<[u64]>>,
// Some legacy CJK fonts assemble their contours with TrueType instructions.
@@ -205,9 +205,6 @@ impl FontFace {
pub fn skrifa(&self) -> Option<skrifa::FontRef<'_>> {
skrifa::FontRef::from_index(self.data(), self.index).ok()
}
pub fn hb(&self) -> Option<harfrust::FontRef<'_>> {
harfrust::FontRef::from_index(self.data(), self.index).ok()
}
/// Where in the design space glyphs, metrics and outlines come from.
pub fn location(&self) -> LocationRef<'_> {
(&self.location).into()
+1 -1
View File
@@ -98,7 +98,7 @@ impl FontDb {
#[cfg(not(target_arch = "wasm32"))]
{
let enabled = self.sys.lock().unwrap_or_else(std::sync::PoisonError::into_inner).enabled;
if enabled {
if enabled && self.family_maps(FAMILY, c) {
self.load_cataloged(FAMILY);
}
}
+7 -6
View File
@@ -418,10 +418,12 @@ pub(super) fn make_face(
let location = if coords.is_empty() { Location::default() } else { f.axes().location(settings.iter().copied()) };
let m = f.metrics(Size::unscaled(), &location);
let a = f.attributes();
let hb = harfrust::FontRef::from_index(data, index).ok()?;
let shaper = harfrust::ShaperData::new(&hb);
let instance = (!coords.is_empty())
.then(|| harfrust::ShaperInstance::from_variations(&hb, settings.iter().map(|(t, v)| harfrust::Variation { tag: *t, value: *v })));
let source: harfrust::font::Source = match &bytes {
FontBytes::Static(b) => (*b).into(),
FontBytes::Owned(v) => (v.clone() as Arc<dyn AsRef<[u8]> + Send + Sync>).into(),
};
let hb = harfrust::Font::new(source, index)?;
let hb = if coords.is_empty() { hb } else { hb.instance_builder().variations(coords.iter().map(|(t, v)| (harfrust::Tag::new(t), *v))).build() };
let axis = |tag: &[u8; 4]| coords.iter().find(|(t, _)| t == tag).map(|(_, v)| *v);
// Old releases of heavy faces (Arial Black in the core fonts) claim weight 400 where current
// ones say 900, which Word doesn't embolden: a family named for its weight is that heavy.
@@ -447,10 +449,9 @@ pub(super) fn make_face(
cap_height: m.cap_height.map(|v| v as f64).filter(|v| *v > 0.0).unwrap_or(m.ascent as f64 * 0.72),
x_height: m.x_height.map(|v| v as f64).filter(|v| *v > 0.0).unwrap_or(m.ascent as f64 * 0.5),
avg_char_width: avg_char_width(&f, upem),
shaper,
hb,
coords,
location,
instance,
bytes,
index,
bmp: std::sync::OnceLock::new(),
+33
View File
@@ -1018,6 +1018,39 @@ fn catalog_postscript_names() {
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn cataloged_family_without_glyph_is_not_loaded_by_fallback_and_rescan_clears_misses() {
struct Cleanup(std::path::PathBuf);
impl Drop for Cleanup {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.0);
}
}
let dir = std::env::temp_dir().join(format!("wc-sysfonts-{}-cmap-skip-and-rescan", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let _cleanup = Cleanup(dir.clone());
// SourceSerif4-Regular lacks '●' (\u{25CF}): cataloging it under Times New Roman and Arial
// must not cause circle_fallback or system_fallback to load those families when searching for '●'.
std::fs::write(dir.join("TNR.ttf"), named_face("SourceSerif4-Regular.ttf", "Times New Roman")).unwrap();
std::fs::write(dir.join("Arial.ttf"), named_face("SourceSerif4-Regular.ttf", "Arial")).unwrap();
let db = FontDb::with_font_dirs(vec![dir.clone()]);
db.faces.write().unwrap().retain(|face| face.family == "Source Serif 4");
let primary = db.face("Source Serif 4", "Regular");
assert!(db.fallback_for('●', primary.id()).is_none(), "no loaded or cataloged face covers '●'");
assert!(!db.is_loaded("Times New Roman"), "circle_fallback must skip Times New Roman when its cmap lacks '●'");
assert!(!db.is_loaded("Arial"), "system_fallback must skip Arial when its cmap lacks '●'");
// Populate sys.tried before rescanning; replacing Arial.ttf in place with a covering face and
// rescanning clears sys.tried, cached misses, and stale file coverage ranges.
db.sys.lock().unwrap().tried.insert("Arial");
std::fs::write(dir.join("Arial.ttf"), named_face("SourceSans3-Regular.ttf", "Arial")).unwrap();
db.load_system_fonts();
assert!(db.sys.lock().unwrap().tried.is_empty(), "rescan clears sys.tried");
let resolved = db.fallback_for('●', primary.id()).expect("rescan drops cached miss and reloads replaced Arial.ttf");
assert_eq!(resolved.family, "Arial");
}
/// Diagram fallback matches the primary font's serif/sans classification while body-text
/// fallback preserves loaded order (#5672), and changing user fonts invalidates run fallbacks.
#[test]
+67 -53
View File
@@ -20,7 +20,7 @@ pub use fontdb::{
base_style, bundled, bundled_inter, decode_font_file, is_font_file_name, name_language_matches, sniff, system_font_dirs,
};
pub use harfrust::Feature;
use harfrust::{Direction, ShapeOptions, ShapePlan, ShapePlanKey, Shaper, Tag, UnicodeBuffer};
use harfrust::{Buffer, Direction, ShapeOptions, ShapePlan, ShapePlanKey, ShaperFont, Tag};
pub use kurbo::BezPath;
pub use script::{fallback_rank, is_emoji, joins_cursively, needs_layout_tables, script_fallbacks};
use skrifa::MetadataProvider;
@@ -202,50 +202,53 @@ fn shape_dir(
around: ShapeContext<'_>,
) -> Vec<ShapedGlyph> {
let mut out = Vec::with_capacity(text.len());
let shaped = face.hb().map(|hb| {
let shaper = face.shaper.shaper(&hb).instance(face.instance.as_ref()).build();
// One script per shaping call: the shaper picks its script engine (Myanmar, Khmer,
// Indic, USE reordering…) from the run's script, so "Hi မြန်မာ" in one face must not be
// shaped as Latin. Runs come in text order; right-to-left callers regroup by cluster.
for r in script::script_runs(text) {
let Some(sub) = text.get(r.clone()) else { continue };
let mut buf = UnicodeBuffer::new();
for (i, c) in sub.char_indices() {
buf.add(map(c), (r.start + i) as u32);
}
// After the text: adding to a buffer clears what follows it.
let around = around.at_edges_of(text, &r);
buf.set_pre_context(around.before);
buf.set_post_context(around.after);
buf.guess_segment_properties();
buf.set_direction(if rtl { Direction::RightToLeft } else { Direction::LeftToRight });
let plan = shape_plan(face, &shaper, &buf, features);
let gb = shaper.shape(buf, ShapeOptions::new().plan(plan.as_deref()).features(features));
for (info, pos) in gb.glyph_infos().iter().zip(gb.glyph_positions()) {
out.push(ShapedGlyph {
gid: info.glyph_id,
cluster: info.cluster as usize,
x_advance: pos.x_advance,
x_offset: pos.x_offset,
y_offset: pos.y_offset,
});
}
let sf = ShaperFont::new(&face.hb);
// One script per shaping call: the shaper picks its script engine (Myanmar, Khmer,
// Indic, USE reordering…) from the run's script, so "Hi မြန်မာ" in one face must not be
// shaped as Latin. Runs come in text order; right-to-left callers regroup by cluster.
for r in script::script_runs(text) {
let Some(sub) = text.get(r.clone()) else { continue };
let mut buf = Buffer::new();
for (i, c) in sub.char_indices() {
buf.push(map(c) as u32, (r.start + i) as u32);
}
});
if shaped.is_none()
&& let Some(f) = face.skrifa()
{
let cmap = f.charmap();
let gm = f.glyph_metrics(Size::unscaled(), face.location());
for (i, c) in text.char_indices() {
let g = cmap.map(map(c)).unwrap_or_default();
let adv = gm.advance_width(g).unwrap_or(face.upem as f32 * 0.5);
out.push(ShapedGlyph { gid: g.to_u32(), cluster: i, x_advance: adv.round() as i32, x_offset: 0, y_offset: 0 });
// After the text: adding to a buffer clears what follows it.
let around = around.at_edges_of(text, &r);
buf.set_pre_context(around.before);
buf.set_post_context(around.after);
buf.guess_segment_properties();
buf.set_direction(if rtl { Direction::RightToLeft } else { Direction::LeftToRight });
let plan = shape_plan(face, &buf, features);
// A run that exhausts the shaper's budget returns Ok with an incomplete buffer.
if harfrust::shape(&sf, &mut buf, ShapeOptions::new().plan(plan.as_deref()).features(features)).is_err() || !buf.allocation_successful() {
cmap_glyphs(face, sub, r.start, map, &mut out);
continue;
}
for (info, pos) in buf.glyph_infos().iter().zip(buf.glyph_positions()) {
out.push(ShapedGlyph {
gid: info.glyph_id,
cluster: info.cluster as usize,
x_advance: pos.x_advance,
x_offset: pos.x_offset,
y_offset: pos.y_offset,
});
}
}
out
}
/// One glyph per character straight from the cmap, for a run the shaper could not do.
fn cmap_glyphs(face: &FontFace, text: &str, base: usize, map: &impl Fn(char) -> char, out: &mut Vec<ShapedGlyph>) {
let Some(f) = face.skrifa() else { return };
let cmap = f.charmap();
let gm = f.glyph_metrics(Size::unscaled(), face.location());
for (i, c) in text.char_indices() {
let g = cmap.map(map(c)).unwrap_or_default();
let adv = gm.advance_width(g).unwrap_or(face.upem as f32 * 0.5);
out.push(ShapedGlyph { gid: g.to_u32(), cluster: base + i, x_advance: adv.round() as i32, x_offset: 0, y_offset: 0 });
}
}
/// How many shape plans each thread keeps: the oldest is dropped to make room, so a thread never
/// holds more than this many, whatever fonts, scripts and feature sets it shapes.
const MAX_SHAPE_PLANS: usize = 64;
@@ -279,22 +282,22 @@ thread_local! {
/// oldest dropped past [`MAX_SHAPE_PLANS`]). A kept plan is used only for the same face and when
/// harfrust's own [`ShapePlanKey::matches`] accepts it (script, direction, language, the face's
/// variation instance and the features). `None` leaves making it to the shaper.
fn shape_plan(face: &FontFace, shaper: &Shaper, buf: &UnicodeBuffer, features: &[Feature]) -> Option<std::rc::Rc<ShapePlan>> {
fn shape_plan(face: &FontFace, buf: &Buffer, features: &[Feature]) -> Option<std::rc::Rc<ShapePlan>> {
// The buffer's script is unset when it reads as unknown: the guess never sets that.
let script = Some(buf.script()).filter(|s| *s != harfrust::script::UNKNOWN);
let script = buf.script().filter(|s| *s != harfrust::Script::UNKNOWN);
let language = buf.language();
let direction = buf.direction();
if direction == Direction::Invalid {
return None;
}
let key = ShapePlanKey::new(script, direction).language(language.as_ref()).instance(face.instance.as_ref()).features(features);
let key = ShapePlanKey::new(&face.hb, script, direction).language(language).features(features);
let of = PlanFace::of(face);
SHAPE_PLANS.with(|cell| {
let mut plans = cell.try_borrow_mut().ok()?;
if let Some((_, plan)) = plans.iter().find(|(f, plan)| *f == of && key.matches(plan)) {
return Some(plan.clone());
}
let plan = std::rc::Rc::new(ShapePlan::new(shaper, direction, script, language.as_ref(), features));
let plan = std::rc::Rc::new(ShapePlan::new(&face.hb, direction, script, language, features));
if plans.len() >= MAX_SHAPE_PLANS {
plans.remove(0);
}
@@ -359,14 +362,14 @@ mod tests {
#[test]
fn kept_shape_plans_shape_as_fresh_ones() {
let fresh = |face: &FontFace, text: &str, features: &[Feature], rtl: bool| -> Vec<(u32, u32, i32, i32, i32)> {
let Some(hb) = face.hb() else { return Vec::new() };
let shaper = face.shaper.shaper(&hb).instance(face.instance.as_ref()).build();
let mut buf = UnicodeBuffer::new();
let mut buf = Buffer::new();
buf.push_str(text);
buf.guess_segment_properties();
buf.set_direction(if rtl { Direction::RightToLeft } else { Direction::LeftToRight });
let gb = shaper.shape(buf, ShapeOptions::new().features(features));
gb.glyph_infos().iter().zip(gb.glyph_positions()).map(|(i, p)| (i.glyph_id, i.cluster, p.x_advance, p.x_offset, p.y_offset)).collect()
if harfrust::shape(&ShaperFont::new(&face.hb), &mut buf, ShapeOptions::new().features(features)).is_err() {
return Vec::new();
}
buf.glyph_infos().iter().zip(buf.glyph_positions()).map(|(i, p)| (i.glyph_id, i.cluster, p.x_advance, p.x_offset, p.y_offset)).collect()
};
let kept = |face: &FontFace, text: &str, features: &[Feature], rtl: bool| -> Vec<(u32, u32, i32, i32, i32)> {
shape_dir(face, text, features, &|c| c, rtl, ShapeContext::default())
@@ -395,14 +398,14 @@ mod tests {
fn kept_shape_plans_are_bounded() {
let face = FontDb::global().face(DEFAULT_FAMILY, "Regular");
let fresh = |features: &[Feature], rtl: bool| -> Vec<(u32, i32)> {
let Some(hb) = face.hb() else { return Vec::new() };
let shaper = face.shaper.shaper(&hb).instance(face.instance.as_ref()).build();
let mut buf = UnicodeBuffer::new();
let mut buf = Buffer::new();
buf.push_str("office");
buf.guess_segment_properties();
buf.set_direction(if rtl { Direction::RightToLeft } else { Direction::LeftToRight });
let gb = shaper.shape(buf, ShapeOptions::new().features(features));
gb.glyph_infos().iter().zip(gb.glyph_positions()).map(|(i, p)| (i.glyph_id, p.x_advance)).collect()
if harfrust::shape(&ShaperFont::new(&face.hb), &mut buf, ShapeOptions::new().features(features)).is_err() {
return Vec::new();
}
buf.glyph_infos().iter().zip(buf.glyph_positions()).map(|(i, p)| (i.glyph_id, p.x_advance)).collect()
};
for n in 0..3 * MAX_SHAPE_PLANS as u32 {
let features = [feature_value(b"kern", n % 2), feature_value(b"liga", n)];
@@ -415,6 +418,17 @@ mod tests {
assert_eq!(kept_shape_plans(), MAX_SHAPE_PLANS);
}
/// The cmap fallback for a failed run gives one glyph per character, its clusters offset by
/// where the run starts in the text.
#[test]
fn cmap_fallback_keeps_cluster_offsets() {
let face = FontDb::global().face(DEFAULT_FAMILY, "Regular");
let mut out = Vec::new();
cmap_glyphs(&face, "ab", 5, &|c| c, &mut out);
assert_eq!(out.iter().map(|g| g.cluster).collect::<Vec<_>>(), [5, 6]);
assert!(out.iter().all(|g| g.gid != 0 && g.x_advance > 0));
}
#[test]
fn ligatures_can_be_disabled() {
let face = FontDb::global().face(DEFAULT_FAMILY, "Regular");
+4 -3
View File
@@ -122,7 +122,8 @@ const COLOR_EMOJI: &[&str] = &["Segoe UI Emoji", "Apple Color Emoji", "Noto Colo
pub fn is_emoji(c: char) -> bool {
matches!(
u32::from(c),
0x1F000..=0x1FAFF
0x1F000..=0x1F7FF
| 0x1F900..=0x1FAFF
| 0x231A..=0x231B
| 0x23E9..=0x23EC
| 0x23F0
@@ -210,8 +211,8 @@ mod tests {
assert!(fallback_rank(c, "Segoe UI Emoji") < fallback_rank(c, "Segoe UI Symbol"), "{c}");
assert!(fallback_rank(c, "Noto Color Emoji") < fallback_rank(c, "Noto Emoji"), "{c}");
}
// Text-style symbols keep the symbol fonts.
for c in ['✔', '☺', '→', 'a', '1'] {
// Text-style symbols keep the symbol fonts, including Supplemental Arrows-C.
for c in ['✔', '☺', '→', '\u{1F86A}', 'a', '1'] {
assert!(!is_emoji(c), "{c}");
}
}
+4 -8
View File
@@ -4,17 +4,13 @@ use std::sync::Arc;
use wordcraft_doc::{Block, Document, SectionProps};
use crate::shared_section;
pub use craft_odf::text::{CryptError, TEMPLATE_MIME, TEXT_MIME, decrypt, encrypt, is_encrypted};
/// Text room, points, that header and footer bands leave on a page (as Page Setup's margins must).
const MIN_TEXT_ROOM: f32 = 36.0;
fn shared_section(page: &SectionProps) -> craft_wordmodel::SectionProps {
let mut d = Document::new();
d.last_section = page.clone();
wordcraft_docx::to_shared_model(&d).map(|s| s.last_section).unwrap_or_default()
}
/// A shared document opened as a WordCraft one, its pages keeping the text room the header and
/// footer bands leave ([`keep_text_room`]).
fn from_shared(shared: craft_wordmodel::Document) -> Result<Document, String> {
@@ -69,7 +65,7 @@ pub fn import(bytes: &[u8]) -> Result<Document, String> {
}
pub fn import_on(bytes: &[u8], page: &SectionProps) -> Result<Document, String> {
from_shared(craft_odf::text::import_on(bytes, &shared_section(page))?)
from_shared(craft_odf::text::import_on(bytes, &shared_section(page)?)?)
}
pub fn import_flat(bytes: &[u8]) -> Result<Document, String> {
@@ -77,7 +73,7 @@ pub fn import_flat(bytes: &[u8]) -> Result<Document, String> {
}
pub fn import_flat_on(bytes: &[u8], page: &SectionProps) -> Result<Document, String> {
from_shared(craft_odf::text::import_flat_on(bytes, &shared_section(page))?)
from_shared(craft_odf::text::import_flat_on(bytes, &shared_section(page)?)?)
}
/// The shared model an OpenDocument file is written from. ODF's `dc:date` is an instant (a `Z`
+28
View File
@@ -418,6 +418,34 @@ fn odt_round_trip() {
assert_eq!(back.core.creator, "Ada Writer");
}
#[test]
fn open_document_import_on_reports_section_conversion_errors() {
// Original synthetic ODT, OTT and FODT without a page layout, so they use the supplied paper size.
let ns = concat!(
r#"xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" "#,
r#"xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3""#,
);
let body = "<office:body><office:text><text:p>Page geometry</text:p></office:text></office:body>";
let packaged = |mime: &str| {
let content = format!("<office:document-content {ns}>{body}</office:document-content>");
let mut zip = craft_zip::Writer::new();
zip.add("mimetype", mime.as_bytes(), craft_zip::Compression::Stored).unwrap();
zip.add("content.xml", content.as_bytes(), craft_zip::Compression::Stored).unwrap();
zip.finish().unwrap()
};
let flat = format!(r#"<office:document {ns} office:mimetype="{}">{body}</office:document>"#, crate::odt::TEXT_MIME);
let cases = [("odt", packaged(crate::odt::TEXT_MIME)), ("ott", packaged(crate::odt::TEMPLATE_MIME)), ("fodt", flat.into_bytes())];
let page = wordcraft_doc::SectionProps { page_w: 505.0, page_h: 731.0, ..Default::default() };
let message = "OpenDocument page conversion failed";
for (ext, bytes) in cases {
let open = || crate::import_on(ext, &bytes, &page).unwrap();
let doc = open().unwrap();
assert_eq!((doc.last_section.page_w, doc.last_section.page_h), (page.page_w, page.page_h), "{ext}");
assert_eq!(doc.plain_text(wordcraft_doc::StoryRef::Body), "Page geometry", "{ext}");
assert_eq!(crate::with_shared_conversion_error(message, open).unwrap_err(), message, "{ext}");
}
}
/// A flat ODT on A4 with a header and a footer, their bands' minimum heights (`fo:min-height`)
/// stated, and two body paragraphs.
fn flat_odt_with_bands(header: &str, footer: &str) -> Vec<u8> {
+6
View File
@@ -45,6 +45,12 @@ pub use paragraph::layout_para;
pub(crate) use paragraph::word_widths;
pub use proof::{ProofRun, is_list_item, paragraph_issues, proof_runs, proof_text};
/// The East Asian family requested by layout for this run, before installed-font substitution.
/// A theme slot takes precedence over the inherited name and can have no resolved face.
pub fn east_asian_font<'a>(doc: &'a Document, run: &'a ResolvedChar) -> Option<&'a str> {
chars::east_asian_font(doc, run)
}
/// A laid-out paragraph.
#[derive(Clone, Debug)]
pub struct ParaLayout {
+10 -4
View File
@@ -157,10 +157,12 @@ impl<'a> Builder<'a> {
// A mark is set like the character it belongs to, as for `complex`: in small capitals at
// that character's size, even when the run's font already draws the mark, so the two
// stay in one shaping run, can compose or position together, and match their cluster
// whole (#7865, #8571).
// whole (#7865, #8571). Any other character: Small Caps draws lowercase letters, and
// the space and ideographic space, at the small-caps size, as Word does; a no-break
// space, digits and punctuation keep the full size (#7062).
let small = match cur {
Some(k) if mark => k.small,
_ => rc.small_caps && !rc.caps && c.is_lowercase(),
_ => rc.small_caps && !rc.caps && (c.is_lowercase() || c == ' ' || c == '\u{3000}'),
};
let key = SegKey { face, small, complex, rtl };
match cur {
@@ -206,7 +208,9 @@ impl<'a> Builder<'a> {
return i;
}
}
let size = rc.draw_size() * if small { 0.8 } else { 1.0 };
// Small capitals are set at 80% of the size rounded to the half point, as Word does
// (16 pt → 13, 14 → 11, 12 → 9.5, #7062).
let size = if small { (rc.draw_size() * 0.8 * 2.0).round() / 2.0 } else { rc.draw_size() };
// A symbol font that isn't installed, or is installed one em tall (Apple's Symbol), takes
// the height Word gives it.
let (a, d) = match wordcraft_fonts::word::symbol_line(&rc.font, &r) {
@@ -222,7 +226,9 @@ impl<'a> Builder<'a> {
}
None => wordcraft_fonts::word::line_metrics(&face),
};
let k = size as f64 / face.upem.max(1.0);
// A small-caps piece is drawn at 80% but measured for the line at the full size: a Small
// Caps line is as tall as without Small Caps, as in Word (#7063).
let k = rc.draw_size() as f64 / face.upem.max(1.0);
// A fallback face (letters the requested font lacks) is emboldened or slanted when it has
// no bold or italic of its own.
let (synth_bold, synth_italic) = match face_override {
+79 -2
View File
@@ -336,8 +336,12 @@ pub fn autofit_widths(cols: &[(f32, f32)], avail: f32) -> Vec<f32> {
/// How far left of its offset (`w:tblpX`) a floating table placed by one has its edge. Before
/// Word 2013 layout the first cell's text is at the offset, moved by the table's indent; from it
/// the edge is, moved in by half its left border, the indent ignored (measured in Word for
/// Windows).
/// Windows). A right-to-left table (`w:bidiVisual`) has its left edge at the offset in every
/// mode: Word moves it by neither a cell margin nor the indent nor a border (#8517).
pub(crate) fn float_offset_shift(ctx: &Ctx, t: &Table) -> f32 {
if t.props.bidi_visual {
return 0.0;
}
let style = table_style(ctx, t);
if ctx.doc.settings.compat_mode < 15 {
first_cell_left_margin_in(t, default_margins(t, style.as_ref())) - t.props.indent.unwrap_or(0.0)
@@ -602,6 +606,10 @@ fn table_frame(ctx: &mut Ctx, t: &Table, avail: f32, depth: usize, style: Option
// by that half.
indent + half_edge_border(t, &tborders)
} else {
// A right-to-left table too, though its first cell's left margin is on the cell's far
// side: with a left margin of 10 pt and a right one of 2 pt its text ends 8 pt past the
// right margin, as in Word (#8517, measured in Word for Windows). A floating one isn't
// moved ([`float_offset_shift`]).
indent - first_cell_left_margin_in(t, margins_def)
};
// The reading view fits the table into what the start offset leaves of the column, mirrored or not (#7988).
@@ -858,7 +866,13 @@ fn layout_table_rows(ctx: &mut Ctx, story: StoryRef, t: &Table, path: &[u32], av
};
bottoms.push(row_below);
edges.push(row_edge);
heights.push(if collapsed && !cells.is_empty() { rh.max(0.0) } else { rh.max(4.0) });
heights.push(
if (collapsed && !cells.is_empty()) || matches!((row.props.height, row.props.height_rule), (Some(h), HeightRule::Exact) if h > 0.0) {
rh.max(0.0)
} else {
rh.max(4.0)
},
);
rows.push(cells);
}
grow_vertical_merges(&rows, &mut heights);
@@ -1738,6 +1752,10 @@ fn is_automatic(t: &Table) -> bool {
/// Consistent cell widths replace a stale grid without changing the table's total width.
/// Conflicting widths, spans and percentages need the full shared-grid algorithm.
fn apply_cell_widths(t: &Table, grid: &mut [f32]) {
if let Some(widths) = stale_grid_widths(t, grid) {
grid.copy_from_slice(&widths);
return;
}
let Some(first) = t.rows.first() else { return };
if first.cells.len() != grid.len() {
return;
@@ -1757,6 +1775,41 @@ fn apply_cell_widths(t: &Table, grid: &mut [f32]) {
grid.copy_from_slice(&widths);
}
// An autofit table whose width matches its complete point-width rows but not its grid takes the rows.
fn stale_grid_widths(t: &Table, grid: &[f32]) -> Option<Vec<f32>> {
const WIDTH_EPSILON: f32 = 0.5;
const EDGE_EPSILON: f32 = 0.01;
let width = t.props.width.filter(|w| w.is_finite() && (w - grid.iter().sum::<f32>()).abs() > WIDTH_EPSILON)?;
if t.props.fixed || t.props.width_pct.is_some() || t.rows.is_empty() {
return None;
}
let mut edges = vec![None; grid.len() + 1];
edges[0] = Some(0.0);
for row in &t.rows {
if row.first_grid() != 0 || row.grid_after() != 0 {
return None;
}
let (mut g, mut x) = (0usize, 0.0f32);
for cell in &row.cells {
x += cell.props.width.filter(|w| w.is_finite() && *w > 0.0 && cell.props.width_pct.is_none())?;
g = g.saturating_add(cell.span());
let edge = edges.get_mut(g)?;
if edge.is_some_and(|previous: f32| (previous - x).abs() > EDGE_EPSILON) {
return None;
}
edge.get_or_insert(x);
}
if g != grid.len() {
return None;
}
}
if (edges[grid.len()]? - width).abs() > WIDTH_EPSILON {
return None;
}
let widths: Option<Vec<f32>> = edges.windows(2).map(|pair| Some(pair[1]? - pair[0]?)).collect();
widths.filter(|widths| widths.iter().all(|w| *w > 0.0))
}
/// Word sizes each column by the percentage its cells ask for, whichever rows ask: cells without a
/// preferred width take no part, so a header row of percentages sizes the automatic rows below it.
/// The percentages are shares of the table's width, scaled up when they come short of 100%; past
@@ -1958,6 +2011,30 @@ mod width_tests {
assert_eq!(grid, [25.0, 40.0]);
}
#[test]
fn rows_outrank_grid_total() {
let mut table = Table::new(3, 4, 400.0);
let rows = [vec![(4, 400.0)], vec![(2, 150.0), (1, 200.0), (1, 50.0)], vec![(1, 60.0), (1, 90.0), (2, 250.0)]];
for (row, widths) in table.rows.iter_mut().zip(rows) {
row.cells.truncate(widths.len());
for (cell, (span, width)) in row.cells.iter_mut().zip(widths) {
cell.props.span = span;
cell.props.width = Some(width);
}
}
table.grid = vec![100.0, 200.0, 250.0, 100.0];
table.props.width = Some(400.0);
let mut grid = table.grid.clone();
apply_cell_widths(&table, &mut grid);
assert_eq!(grid, [60.0, 90.0, 200.0, 50.0]);
table.props.fixed = true;
grid.copy_from_slice(&table.grid);
apply_cell_widths(&table, &mut grid);
assert_eq!(grid, [100.0, 200.0, 250.0, 100.0], "a fixed table keeps its grid");
}
#[test]
fn autofit_keeps_fitting_widths() {
crate::test_fonts();
+181
View File
@@ -6906,6 +6906,30 @@ fn row_height(l: &DocLayout, row: usize) -> f32 {
l.pages[0].items.iter().find_map(|i| if let Placed::Cell { rect, row: r, .. } = i { (*r == row).then_some(rect.h) } else { None }).unwrap()
}
#[test]
fn exact_rows_below_four_points_keep_their_height() {
crate::test_fonts();
use wordcraft_doc::props::HeightRule;
let mut doc = Document::new();
let mut table = Table::new(40, 1, 200.0);
table.props.cell_margins = Some([0.0; 4]);
for row in &mut table.rows {
row.props.height = Some(2.85);
row.props.height_rule = HeightRule::Exact;
}
doc.body = vec![Arc::new(Block::Table(table))];
let layout = lay(&doc);
let height: f32 = layout
.pages
.iter()
.flat_map(|page| &page.items)
.filter_map(|item| if let Placed::Cell { rect, table, .. } = item { (table == &Path::top(0)).then_some(rect.h) } else { None })
.sum();
assert!((height - 40.0 * 2.85).abs() < 0.1, "40 exact rows should total 114 pt, got {height}");
}
/// The laid-out paragraph in cell (row, col) of the table at body index 1.
fn cell_para(l: &DocLayout, row: u32, col: u32) -> Arc<ParaLayout> {
l.pages[0]
@@ -15267,6 +15291,30 @@ fn cell_widths_override_grid() {
}
}
// Word sizes an autofit table whose width matches its rows from the rows, not a stale grid.
#[test]
fn ordinary_table_takes_row_widths() {
crate::test_fonts();
let mut t = Table::new(3, 2, 132.0);
t.grid = vec![70.0, 62.0];
t.props.width = Some(120.0);
for row in &mut t.rows {
for (cell, width) in row.cells.iter_mut().zip([40.0, 80.0]) {
cell.props.width = Some(width);
cell.blocks = vec![wordcraft_doc::para_block(Paragraph::with_text("A", Default::default()))];
}
}
t.rows[0].cells.truncate(1);
t.rows[0].cells[0].props.span = 2;
t.rows[0].cells[0].props.width = Some(120.0);
let mut d = Document::from_text("After");
d.insert_block(StoryRef::Body, &Path::top(0), wordcraft_doc::Block::Table(t)).unwrap();
let l = lay(&d);
let [(x0, _, _)] = para_at(&l, &[0, 1, 0, 0])[..] else { panic!("cell missing") };
let [(x1, _, _)] = para_at(&l, &[0, 1, 1, 0])[..] else { panic!("cell missing") };
assert!((x1 - x0 - 40.0).abs() < 0.01, "{}", x1 - x0);
}
#[test]
fn percentage_cell_widths_that_disagree_or_span_columns() {
// Measured in Word (A4, 451.3 pt between the margins; 468 pt here), autofit tables 100% wide:
@@ -15759,6 +15807,91 @@ fn caps_draw_sharp_s_as_two_capitals_in_one_cluster() {
assert_eq!(cl.iter().map(|c| c.2.len()).sum::<usize>(), 6, "{cl:?}");
}
/// `text` laid out with `f` applied to all of it: its paragraph's layout.
fn para_with(text: &str, f: &dyn Fn(&mut wordcraft_doc::props::CharProps)) -> ParaLayout {
let mut d = Document::from_text(text);
d.format_range(&Pos::body(0, 0), &Pos::body(0, text.len()), f).unwrap();
let l = lay(&d);
l.pages[0].items.iter().find_map(|it| if let Placed::Lines { para, .. } = it { Some((**para).clone()) } else { None }).expect("a laid-out line")
}
/// Small Caps draws a space (U+0020) at the small-caps size, like a lowercase letter, as Word
/// does (measured: 40 spaces in Times New Roman Bold 10 pt are 80% as wide in Small Caps); a
/// no-break space keeps its full width, and with All Caps as well the space keeps its full width,
/// as All Caps wins (#7062).
#[test]
fn a_space_in_small_caps_is_as_wide_as_at_the_small_caps_size() {
crate::test_fonts();
// The gap between the first and the last letter of `text`.
let gap = |text: &str, f: &dyn Fn(&mut wordcraft_doc::props::CharProps)| {
let pl = para_with(text, f);
let line = &pl.lines[0];
let x = |start: usize| (line.c0..line.c1).find(|&k| pl.clusters[k].start == start).and_then(|k| line.cl_left(k)).unwrap();
x(text.len() - 1) - x(1)
};
// At 10 pt the small-caps size is exactly 8 pt (80%, no rounding to the half point).
let plain: &dyn Fn(&mut wordcraft_doc::props::CharProps) = &|c| c.size = Some(10.0);
let small: &dyn Fn(&mut wordcraft_doc::props::CharProps) = &|c| {
c.small_caps = Some(true);
c.size = Some(10.0);
};
let both: &dyn Fn(&mut wordcraft_doc::props::CharProps) = &|c| {
c.caps = Some(true);
c.small_caps = Some(true);
c.size = Some(10.0);
};
let spaces = format!("a{}a", " ".repeat(10));
let ratio = gap(&spaces, small) / gap(&spaces, plain);
assert!((ratio - 0.8).abs() < 0.01, "Small Caps spaces are 80% as wide: {ratio}");
assert!((gap(&spaces, both) - gap(&spaces, plain)).abs() < 0.01, "All Caps wins: full-width spaces");
let nbsp = format!("a{}a", "\u{a0}".repeat(10));
assert!((gap(&nbsp, small) - gap(&nbsp, plain)).abs() < 0.01, "a no-break space keeps its width");
}
/// Word sets small capitals at 80% of the size rounded to the half point, a size the format can
/// store, like superscript (measured in Word for Microsoft 365, Times New Roman: 10 pt → 8,
/// 11 → 9, 12 → 9.5, 14 → 11, 16 → 13); a Small Caps space takes that size too (#7062).
#[test]
fn small_caps_take_eighty_percent_of_the_size_rounded_to_the_half_point() {
crate::test_fonts();
let width = |text: &str, f: &dyn Fn(&mut wordcraft_doc::props::CharProps)| {
let pl = para_with(text, f);
let line = &pl.lines[0];
(line.c0..line.c1).map(|k| pl.clusters[k].adv).sum::<f32>()
};
for (size, small) in [(16.0_f32, 13.0_f32), (14.0, 11.0), (12.0, 9.5)] {
let small_caps = width("xxxxxxxxxx", &|c| {
c.small_caps = Some(true);
c.size = Some(size);
});
let capitals = width("XXXXXXXXXX", &|c| c.size = Some(small));
assert!((small_caps - capitals).abs() < 0.01, "{size} pt Small Caps draws capitals at {small} pt: {small_caps} vs {capitals}");
let spaces = width("x x", &|c| {
c.small_caps = Some(true);
c.size = Some(size);
}) - width("xx", &|c| {
c.small_caps = Some(true);
c.size = Some(size);
});
let plain = width("x x", &|c| c.size = Some(small)) - width("xx", &|c| c.size = Some(small));
assert!((spaces - plain).abs() < 0.01, "{size} pt Small Caps spaces are {small} pt spaces: {spaces} vs {plain}");
}
}
/// A Small Caps line of lowercase letters is as tall as the same line without Small Caps: the
/// small capitals are drawn at 80% of the size, but the line is measured at the full size, as in
/// Word (#7063).
#[test]
fn a_small_caps_line_of_lowercase_is_as_tall_as_without_small_caps() {
crate::test_fonts();
let text = "only lowercase letters here";
let line = |f: &dyn Fn(&mut wordcraft_doc::props::CharProps)| para_with(text, f).lines[0].clone();
let plain = line(&|c| c.bold = Some(false));
let small = line(&|c| c.small_caps = Some(true));
assert!((small.height - plain.height).abs() < 0.01, "line height: Small Caps {} vs plain {}", small.height, plain.height);
assert!((small.baseline - plain.baseline).abs() < 0.01, "baseline: Small Caps {} vs plain {}", small.baseline, plain.baseline);
}
/// A caps run in a symbol font draws each code as its symbol: ß never becomes two glyphs (#1581).
#[test]
fn caps_in_a_symbol_font_never_expand_characters() {
@@ -19728,6 +19861,54 @@ fn a_floating_table_placed_by_an_offset_takes_its_indent_before_word_2013_only()
assert!((text_x(15, Some(-5.4)) - (margin + 0.25 + 5.4)).abs() < 0.01, "mode 15, indent: {}", text_x(15, Some(-5.4)));
}
/// #8517: a floating right-to-left table placed by an offset has its left edge at the offset in
/// every mode, whatever its first cell's margins, its indent or its left border (measured in
/// Word for Windows: with `w:tblpX` 1 inch from the margin and cells of left 10 / right 2 pt,
/// the leftmost cell's text is 10 pt in from 144 in modes 14 and 15, with or without a 36 pt
/// indent or an 8 pt left border). A left-to-right one still moves out by its first cell's left
/// margin before Word 2013.
#[test]
fn a_floating_right_to_left_table_has_its_edge_at_its_offset() {
crate::test_fonts();
use wordcraft_doc::para::Anchor;
use wordcraft_doc::props::TableFloat;
let left_edge = |mode: u32, rtl: bool, indent: Option<f32>, border: bool| {
let mut t = Table::new(1, 2, 300.0);
t.props.fixed = true;
t.props.bidi_visual = rtl;
t.props.indent = indent;
t.props.cell_margins = Some([0.0, 10.0, 0.0, 2.0]);
if border {
t.props.borders = Some(Borders { left: Some(Border::single(8.0)), ..Default::default() });
}
t.props.float = Some(TableFloat { h_rel: Anchor::Margin, v_rel: Anchor::Paragraph, x: 72.0, ..Default::default() });
for c in &mut t.rows[0].cells {
c.blocks = vec![wordcraft_doc::para_block(wordcraft_doc::Paragraph::with_text("Cell", Default::default()))];
}
let mut d = Document::from_text("Below");
d.settings.compat_mode = mode;
d.insert_block(StoryRef::Body, &Path::top(0), wordcraft_doc::Block::Table(t)).unwrap();
lay(&d).pages[0]
.items
.iter()
.filter_map(|i| match i {
Placed::Cell { rect, .. } => Some(rect.x),
_ => None,
})
.fold(f32::INFINITY, f32::min)
};
let offset = 72.0 + 72.0;
for mode in [14, 15] {
for indent in [None, Some(36.0)] {
for border in [false, true] {
let x = left_edge(mode, true, indent, border);
assert!((x - offset).abs() < 0.01, "mode {mode}, indent {indent:?}, border {border}: {x}");
}
}
}
assert!((left_edge(14, false, None, false) - (offset - 10.0)).abs() < 0.01, "left to right, mode 14");
}
/// From Word 2013 a table moves in by half its first cell's left border, and a first row's
/// `w:tblPrEx` border is that border (measured in Word for Windows): with an 8 pt table border and
/// a 2 pt exception the first cell's text is at 78.38, 1 pt in; without the exception at 81.38.
+1
View File
@@ -70,6 +70,7 @@ pub use export::{export, export_layout};
use exporter::Exporter;
#[cfg(test)]
use glyphs::{baseline, cluster_ends, left_to_right, split_clusters, visual_order};
pub use metadata::reads_as_date;
#[cfg(test)]
use metadata::{civil, parse_iso};
pub use options::{PdfError, PdfOptions, WATERMARK_MAX_CHARS};
+9
View File
@@ -32,6 +32,15 @@ pub(crate) fn metadata(doc: &Document, opts: &PdfOptions) -> Metadata {
m
}
/// Whether `s` is a date this writer can put in a PDF.
///
/// A caller that pins the creation date has to ask the question this writer will ask, because a
/// value it cannot read falls back to the clock below and the export stops being reproducible
/// (noted in review).
pub fn reads_as_date(s: &str) -> bool {
parse_iso(s).is_some()
}
type Civil = (i64, u8, u8, u8, u8, u8);
/// `YYYY-MM-DD[THH:MM[:SS]]…` → civil time.
+91
View File
@@ -4005,6 +4005,97 @@ fn header_and_footer_link_annotations_are_tagged_on_every_page() {
assert_eq!(top_roles, vec!["Div", "P", "Div", "Div", "P", "Div"], "header link before body, footer link after body");
}
/// Neighbouring table cells carrying the same link URL keep separate Link elements, MCIDs, and
/// OBJRs inside their own TD cells (both in RTL tables and when a right-aligned first cell puts
/// the two runs within one em of each other).
#[test]
fn table_cell_links_with_same_target_stay_in_their_own_cells() {
use hayro_syntax::object::{Array, Dict, Name, Object};
use wordcraft_doc::props::{Align, TableProps};
use wordcraft_doc::{Cell, Row, Table};
let link_props = CharProps { link: Some("https://example.com".into()), ..Default::default() };
let make_cell = |text: &str, align: Option<Align>| {
let mut p = Paragraph::with_text(text, link_props.clone());
p.props.align = align;
Cell { blocks: vec![para_block(p)], ..Cell::empty() }
};
for (name, bidi_visual, first_align) in [("rtl", true, None), ("ltr-right-aligned", false, Some(Align::Right))] {
let row = Row { cells: vec![make_cell("First", first_align), make_cell("Second", None)], ..Default::default() };
let table = Table {
props: TableProps { bidi_visual, cell_margins: Some([0.0, 5.4, 0.0, 5.4]), ..Default::default() },
grid: vec![120.0, 120.0],
rows: vec![row],
..Default::default()
};
let mut d = Document::new();
d.body = vec![Arc::new(Block::Table(table))];
let bytes = export(&d, &PdfOptions { compress: false, tagged: true, ..Default::default() }).unwrap();
let pdf = hayro_syntax::Pdf::new(bytes).unwrap();
let annots = pdf.pages()[0].raw().get::<Array>(b"Annots").expect("page Annots");
let annot_ids: Vec<String> = annots.iter::<Dict>().map(|a| format!("{:?}", a.obj_id().expect("indirect annot"))).collect();
assert_eq!(annot_ids.len(), 2, "{name}: expected two link annotations, got {annot_ids:?}");
let root = pdf.xref().get::<Dict>(pdf.xref().root_id()).unwrap();
let struct_tree = root.get::<Dict>(b"StructTreeRoot").expect("StructTreeRoot");
fn children<'a>(dict: &Dict<'a>) -> Vec<Object<'a>> {
match dict.get::<Object>(b"K") {
Some(Object::Array(a)) => a.iter::<Object>().collect(),
Some(other) => vec![other],
None => Vec::new(),
}
}
fn collect_links(d: &Dict, out: &mut Vec<(bool, Option<String>)>) {
if d.get::<Name>(b"S").is_some_and(|s| s.as_ref() == b"Link") {
let mut has_mcid = false;
let mut objr = None;
for item in children(d) {
match item {
Object::Number(_) => has_mcid = true,
Object::Dict(o) if o.get::<Name>(b"Type").is_some_and(|t| t.as_ref() == b"OBJR") => {
objr = o.get::<Dict>(b"Obj").and_then(|obj| obj.obj_id()).map(|id| format!("{id:?}"));
}
_ => {}
}
}
out.push((has_mcid, objr));
}
for item in children(d) {
if let Object::Dict(c) = item {
collect_links(&c, out);
}
}
}
fn collect_tds(dict: &Dict, out: &mut Vec<Vec<(bool, Option<String>)>>) {
if dict.get::<Name>(b"S").is_some_and(|s| s.as_ref() == b"TD") {
let mut cell_links = Vec::new();
collect_links(dict, &mut cell_links);
out.push(cell_links);
return;
}
for item in children(dict) {
if let Object::Dict(c) = item {
collect_tds(&c, out);
}
}
}
let mut tds = Vec::new();
collect_tds(&struct_tree, &mut tds);
assert_eq!(tds.len(), 2, "{name}: expected 2 TD cells, got {tds:?}");
assert_eq!(tds[0].len(), 1, "{name}: first TD should hold 1 Link: {tds:?}");
assert_eq!(tds[1].len(), 1, "{name}: second TD should hold 1 Link: {tds:?}");
assert!(tds[0][0].0 && tds[1][0].0, "{name}: both cell Links must hold an MCID: {tds:?}");
let objr0 = tds[0][0].1.as_deref().expect("first TD Link OBJR");
let objr1 = tds[1][0].1.as_deref().expect("second TD Link OBJR");
assert_ne!(objr0, objr1, "{name}: cells must reference distinct OBJR annotations: {tds:?}");
assert!(annot_ids.iter().any(|id| id == objr0) && annot_ids.iter().any(|id| id == objr1), "{name}: OBJRs must match page Annots");
}
}
/// A paragraph's continuation must follow the footer and header between its pages.
#[test]
fn spanning_paragraph_links_follow_page_reading_order() {
+2 -2
View File
@@ -17,7 +17,7 @@ craft = { workspace = true, features = [
"text-find", "web-api", "web-host", "window",
] }
craft-html = { workspace = true }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35" }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
wordcraft-geom = { workspace = true, features = ["image"] }
wordcraft-doc = { workspace = true }
wordcraft-fonts = { workspace = true }
@@ -77,7 +77,7 @@ craft-ui-test-kit = { workspace = true }
craft = { workspace = true, features = ["ui-testing"] }
[build-dependencies]
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "5299d8d97dc04648dff735d1bd6f60bd18f10b35", features = ["subset"] }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", features = ["subset"] }
serde_json = { workspace = true }
toml = "1"
+24 -24
View File
@@ -86,7 +86,7 @@ fn synthetic_session() -> Session {
}
let mut doc = Document::from_text(&text);
for i in (0..1156).step_by(20) {
let _ = doc.format_paragraphs(&Pos::body(i, 0), &Pos::body(i, 0), &|p| p.style = Some("Heading1".into()));
doc.format_paragraphs(&Pos::body(i, 0), &Pos::body(i, 0), &|p| p.style = Some("Heading1".into())).expect("synthetic: heading style");
}
let mut table = Table::new(250, 8, 468.0);
@@ -97,7 +97,7 @@ fn synthetic_session() -> Session {
cell.props.width = w;
}
}
let _ = doc.insert_block(StoryRef::Body, &Path::top(50), Block::Table(table));
doc.insert_block(StoryRef::Body, &Path::top(50), Block::Table(table)).expect("synthetic: table");
for img_idx in 0..16_u8 {
let mut rgba = image::RgbaImage::new(256, 256);
@@ -109,31 +109,31 @@ fn synthetic_session() -> Session {
255,
]);
}
if let Ok(png) = wordcraft_geom::picture::encode_png(&image::DynamicImage::ImageRgba8(rgba)) {
let key = doc.add_media(png, "png");
let block_idx = 2 + usize::from(img_idx) * 2;
let _ = doc.insert_object(
&Pos::body(block_idx, 0),
InlineObject::Image {
media: key,
w: 144.0,
h: 144.0,
alt: format!("Synthetic image {img_idx}"),
float: Default::default(),
crop: [0.0; 4],
fx: Default::default(),
ole: None,
},
&Default::default(),
);
}
let png = wordcraft_geom::picture::encode_png(&image::DynamicImage::ImageRgba8(rgba)).expect("synthetic: image encoding");
let key = doc.add_media(png, "png");
let block_idx = 2 + usize::from(img_idx) * 2;
doc.insert_object(
&Pos::body(block_idx, 0),
InlineObject::Image {
media: key,
w: 144.0,
h: 144.0,
alt: format!("Synthetic image {img_idx}"),
float: Default::default(),
crop: [0.0; 4],
fx: Default::default(),
ole: None,
},
&Default::default(),
)
.expect("synthetic: image");
}
let mut session = Session::new(doc);
let _ = session.run("review.trackChanges", &json!({"enabled": true}));
let _ = session.run("caret.set", &json!({"pos": {"story": "body", "path": [0], "off": 0}}));
let _ = session.run("text.insert", &json!({"text": "Tracked prefix "}));
let _ = session.run("review.trackChanges", &json!({"enabled": false}));
session.run("review.trackChanges", &json!({"enabled": true})).expect("synthetic: track changes on");
session.run("caret.set", &json!({"pos": {"story": "body", "path": [0], "off": 0}})).expect("synthetic: caret");
session.run("text.insert", &json!({"text": "Tracked prefix "})).expect("synthetic: tracked insertion");
session.run("review.trackChanges", &json!({"enabled": false})).expect("synthetic: track changes off");
session
}
+14 -2
View File
@@ -44,6 +44,10 @@ impl WordApp {
{
return Ok(result);
}
if id == "ui.quit" {
self.clear_command_targets(id);
return Ok(json!({"quit": self.quit()}));
}
// Undo and Redo act on whole steps: a SmartArt typing run still open is folded into its one step first,
// or Undo would take back only the last keystroke of it.
if matches!(id, "edit.undo" | "edit.undoTo" | "edit.redo") {
@@ -871,8 +875,16 @@ impl WordApp {
};
return Some(self.answer_save_changes(answer));
}
// The app menu's Quit (⌘Q): asks about each unsaved document, as the Dock's Quit does.
"ui.quit" => json!({"quit": self.quit()}),
// Programmatic calls (`execute`, control channel, MCP) never open the Save prompt:
// unsaved work needs `{"force": true}`, as `app.quit` does (#8709, #8793).
// The app menu's Quit (⌘Q) runs through `WordApp::run`, which calls `self.quit()`.
"ui.quit" => {
if let Some(e) = crate::control::quit_refused(self, p) {
return Some(Err(e.into()));
}
self.quit_requested = true;
json!({"quit": true})
}
"ui.openFileDialog" => {
self.open_dialog();
json!({})
+5 -2
View File
@@ -181,7 +181,7 @@ pub enum Target {
/// What the pick is remembered as.
remember: Remember,
},
/// Run nothing: the pick is only reported in [`ColorPick::picked`] (a gradient stop's colour).
/// Run nothing: the pick is only reported in [`ColorPick::picked`].
Pick,
}
@@ -258,7 +258,10 @@ fn cell_shading(table: &wordcraft_doc::Table, cells: impl IntoIterator<Item = (u
/// differs across the selection, or cannot be read (a picture's icon colour is not stored).
fn current_of(app: &mut WordApp, target: &Target) -> Option<Rgb> {
use wordcraft_doc::InlineObject;
let Target::Run { cmd, .. } = target else { return None };
let Target::Run { cmd, params, at, .. } = target else { return None };
if let Some(c) = params.pointer(at).and_then(Value::as_str).and_then(parse) {
return Some(c);
}
let s = &app.session;
let shapes = |o: &InlineObject| matches!(o, InlineObject::Shape { .. }) || o.is_canvas();
let objects = || wordcraft_engine::cmd::objects::target_objects(s, shapes).into_iter().map(|(_, o)| o);
+1 -1
View File
@@ -21,7 +21,7 @@
mod handler;
mod screenshots;
pub(crate) use handler::close_refused;
pub(crate) use handler::{close_refused, quit_refused};
pub use handler::{handle, inspect};
#[cfg(test)]
mod doc_tests;
+6 -2
View File
@@ -47,8 +47,12 @@ pub fn inspect(app: &mut WordApp, ctx: &egui::Context) -> Value {
let rect = |r: egui::Rect| [r.left(), r.top(), r.width(), r.height()];
// PLAN: assumed `Label::as_str` and `Tone: Debug` (sh.A3 `status_message`, expiry handled there)
let status = app.status_message().map(|m| json!({"text": m.text.as_str(), "tone": format!("{:?}", m.tone).to_lowercase()}));
// `prefs` stores recent documents as `~/...`; clients pass these entries to `file.open`, which
// needs the full path (#8421).
let mut ui = app.prefs();
ui.recent.clone_from(&app.ui.recent);
json!({
"ui": app.prefs(),
"ui": ui,
"view": app.session.view,
"windows": app.session.windows,
"proofing": app.spelling_review,
@@ -125,7 +129,7 @@ const COMMENT_UNSAVED: &str = "a comment is still being edited: finish it first,
/// Quitting closes every open document, so unsaved work needs the same explicit `force` as
/// `file.close` rather than going silently (#1268, #3274). The interactive path asks about
/// each document in turn; a programmatic call never prompts, so it refuses.
fn quit_refused(app: &WordApp, params: &Value) -> Option<&'static str> {
pub(crate) fn quit_refused(app: &WordApp, params: &Value) -> Option<&'static str> {
let force = params.get("force").and_then(Value::as_bool) == Some(true);
if force {
return None;
+36 -4
View File
@@ -126,17 +126,28 @@ fn closing(form: &str, force: Option<&Value>, target: u64, background: bool) ->
("file.closeDocument", Value::Object(params))
}
"app.quit" => ("app.quit", Value::Object(params)),
"ui.quit" => ("ui.quit", Value::Object(params)),
"engine.execute:ui.quit" => ("engine.execute", json!({"command": "ui.quit", "params": Value::Object(params)})),
_ => ("file.close", Value::Object(params)),
}
}
/// Every way to close or quit over the control channel keeps unsaved work unless `force` is the
/// boolean true, for the active document and for one in the background (#1268, #3274).
/// boolean true, for the active document and for one in the background (#1268, #3274, #8793).
#[test]
fn programmatic_close_guard_covers_every_form() {
let ctx = crate::test_harness::context();
let forces: [(Option<Value>, bool); 4] = [(None, false), (Some(json!("yes")), false), (Some(json!(1)), false), (Some(json!(true)), true)];
let forms = ["engine.execute", "command", "file.close", "engine.execute:closeDocument", "file.closeDocument", "app.quit"];
let forms = [
"engine.execute",
"command",
"file.close",
"engine.execute:closeDocument",
"file.closeDocument",
"app.quit",
"ui.quit",
"engine.execute:ui.quit",
];
for form in forms {
for background in [false, true] {
// A direct `file.close` method has no `doc`.
@@ -154,13 +165,14 @@ fn programmatic_close_guard_covers_every_form() {
let what = format!("{form} background={background} {params}: {r}");
assert_eq!(r["ok"], json!(*accepted), "{what}");
if *accepted {
if form == "app.quit" {
if matches!(form, "app.quit" | "ui.quit" | "engine.execute:ui.quit") {
assert!(a.quit_requested, "{what}");
} else {
assert!(!a.session.is_open(first), "{what}");
}
} else {
assert!(!a.quit_requested && a.session.is_open(first), "{what}");
assert!(prompt(&a).is_none() && a.closing.is_none(), "{what}");
}
}
}
@@ -172,7 +184,13 @@ fn programmatic_close_guard_covers_every_form() {
#[test]
fn programmatic_close_keeps_a_save_the_picker_hasnt_finished() {
let ctx = crate::test_harness::context();
for (method, params) in [("engine.execute", json!({"command": "file.close"})), ("file.close", json!({})), ("app.quit", json!({}))] {
for (method, params) in [
("engine.execute", json!({"command": "file.close"})),
("file.close", json!({})),
("app.quit", json!({})),
("ui.quit", json!({})),
("engine.execute", json!({"command": "ui.quit"})),
] {
let (mut a, saves) = web_picker_app();
a.run("file.close", json!({})).unwrap();
let r = a.run("ui.saveChanges", json!({"answer": "save"})).unwrap();
@@ -393,3 +411,17 @@ fn every_method_the_protocol_doc_lists_is_answered() {
let (req, _rx) = ControlRequest::new("ui.drag", json!({"from": {"x": 10.0, "y": 10.0}, "to": {"x": 20.0, "y": 20.0}}));
assert!(matches!(control::handle(&mut app(), &ctx, &req), Reply::AfterInput));
}
/// #8421: `ui.inspect` lists recent documents as full paths that `file.open` can open, not the
/// `~/...` form the preferences file keeps.
#[test]
fn inspect_lists_recent_documents_as_full_paths() {
let full = crate::prefs::expand_recent_path("~/Documents/report.docx");
assert!(!full.starts_with('~'), "the test needs a home folder");
assert_eq!(crate::prefs::contract_recent_path(&full), "~/Documents/report.docx", "the stored form is contracted");
let mut a = app();
a.ui.recent = vec![full.clone()];
let (req, _rx) = ControlRequest::new("ui.inspect", json!({}));
let Reply::Done(r) = control::handle(&mut a, &installed(), &req) else { panic!("ui.inspect answers at once") };
assert_eq!(r["result"]["ui"]["recent"], json!([full]), "{r}");
}
+33
View File
@@ -763,6 +763,39 @@ fn paragraph_dialog_changes_direction() {
// ---------------------------------------------------------------- Font
#[test]
fn font_dialog_shows_the_east_asian_theme_face_and_only_replaces_it_when_edited() {
use std::sync::Arc;
use wordcraft_doc::props::ThemeFont;
use wordcraft_doc::{Path, StoryRef};
let mut app = app_with("Example");
let doc = &mut app.session.doc;
Arc::make_mut(&mut doc.styles).default_chr.font_ea = Some("Times New Roman".into());
doc.passthrough.insert("wordcraft:theme.fonts".into(), Arc::new(b"minor\tface\tea\tExample CJK Face\n".to_vec()));
let para = doc.para_mut(StoryRef::Body, &Path::top(0)).unwrap();
para.format(0, para.len(), &|props| props.font_ea_theme = Some(ThemeFont::MinorEastAsia)).unwrap();
app.session.touch();
app.run("select.all", json!({})).unwrap();
let mut h = app_harness(app);
h.run_steps(2);
apply_font(&mut h, |form| {
assert!(form.asian);
assert_eq!(form.font_ea, "Example CJK Face");
});
let props = char_props_at_start(h.state());
assert_eq!(props.font_ea_theme, Some(ThemeFont::MinorEastAsia), "unchanged OK keeps the theme slot");
assert!(props.font_ea.is_none(), "the inherited name stays inherited");
apply_font(&mut h, |form| {
form.font_ea = "Times New Roman".into();
});
let props = char_props_at_start(h.state());
assert_eq!(props.font_ea.as_deref(), Some("Times New Roman"));
assert!(props.font_ea_theme.is_none(), "choosing the inherited name makes it an explicit replacement");
}
#[test]
fn font_dialog_sets_the_asian_and_latin_fonts_separately() {
// #505: the Asian text font box and the Latin text font box each set their own font, and
+76 -11
View File
@@ -13,7 +13,7 @@ use craft::theme::Srgba;
use craft::theme::variant::Tone;
use craft::ui::buttons::Button;
use craft::ui::choice::{Checkbox, Radio, RadioGroup};
use craft::ui::contract::{Bind, Entry, Outcome as _, Props as _, Show as _, ShowContainer as _, Trigger};
use craft::ui::contract::{Bind, Entry, Outcome as _, Props as _, Show as _, ShowContainer as _, Trigger, clicked};
use craft::ui::form::{Field, SliderField};
use craft::ui::layout_components::Stack;
use craft::ui::menu::Menu;
@@ -509,7 +509,9 @@ fn solid(app: &mut WordApp, ui: &mut Ui, theme: &[Rgb], color: Rgb, transparency
let mut hex = color.hex();
let label: Label = tl!("Color").into();
let picked = color_field(ui, &label, &mut hex, &ColorFieldEmpty::NoColor, &palette);
if picked.changed
if picked.more_colors {
colors::open_for(app, &Target::cmd("shape.fill"), Some(color), craft::color_ui::ui::ColorPickerTab::Standard);
} else if picked.changed
&& let Some(n) = Rgb::parse(&hex)
{
let _ = app.run("shape.fill", json!({"color": n.hex()}));
@@ -677,17 +679,22 @@ fn gradient(app: &mut WordApp, ui: &mut Ui, g: &Gradient) {
// PLAN: the framework has no public kept-value write; the open flag goes through the saved value
let was: bool = saved_value(&ctx, &key);
let mut open = was || editor.color_requested.is_some();
let mut chosen = None;
Popover::new(tl!("Stop color"), Bind::bound(&mut open)).opened_by(editor.response()).show(ui, |ui, _| {
// PLAN: assumed colors::palette(ui, app, Target::Pick) -> ColorPick (ribbon-w11, rb.A4)
chosen = colors::palette(ui, app, Target::Pick).picked;
let stop_at = editor.color_requested.as_ref().map(|c| c.index).or(match editor.selected {
Some(StopRef::Color(at)) => Some(at),
_ => None,
});
if let (Some(color), Some(StopRef::Color(at))) = (chosen, editor.selected) {
let mut stops = stops_of(g);
if let Some(stop) = stops.color.get_mut(at) {
stop.color = srgba(color, stop.color.a);
apply(app, Some(&with_stops(g, &stops)));
let stop_target = match stop_at.filter(|&at| at < g.stops.len()) {
Some(at) => Target::at("shape.fill", shape_fill::params(Some(&Fill::Gradient(Arc::new(g.clone())))), &format!("/gradient/stops/{at}/color")),
None => Target::Pick,
};
let mut close_popover = false;
Popover::new(tl!("Stop color"), Bind::bound(&mut open)).opened_by(editor.response()).show(ui, |ui, _| {
let pick = colors::palette(ui, app, stop_target.clone());
if pick.picked.is_some() || clicked(&pick.response) {
close_popover = true;
}
});
if close_popover {
open = false;
}
if open != was {
@@ -1066,6 +1073,64 @@ mod tests {
assert_eq!(stroke(h.state()), Some(wordcraft_doc::Rgb(255, 0, 0)));
}
/// Selecting More Colors… in the Solid fill color picker applies the custom color via `shape.fill`
/// while preserving transparency.
#[test]
fn format_shape_pane_solid_more_colors_applies_fill() {
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
a.run("insert.shape", json!({"kind": "rectangle"})).unwrap();
a.run("shape.fill", json!({"color": "112233", "transparency": 35})).unwrap();
a.run("view.formatShapePane", json!({"value": true})).unwrap();
let mut h = harness(a);
h.run_steps(4);
h.query_all_by_role_and_label(egui::accesskit::Role::Button, "Color #112233").last().expect("solid fill color field").click();
h.run_steps(3);
h.get_by_label("More Colors…").click();
h.run_steps(3);
let dialog = h.state_mut().dialog_host.get_mut::<craft::color_ui::ui::ColorPickerDialog>().expect("Colors dialog opened");
assert_eq!(dialog.opening().map(|p| super::rgb_of(p.color)), Some(wordcraft_doc::Rgb(0x11, 0x22, 0x33)));
dialog.set_color(craft::color_ui::ui::PickedColor::rgb(craft::theme::Srgba::rgb(0.0, 1.0, 0.0)));
let ctx = h.ctx.clone();
assert!(h.state_mut().dialog_host.confirm::<craft::color_ui::ui::ColorPickerDialog>(&ctx));
crate::dialogs::host::settle(h.state_mut(), &ctx);
assert_eq!(fill(h.state()), Some(Fill::Solid { color: wordcraft_doc::Rgb(0, 255, 0), transparency: 35.0 }));
}
/// Selecting More Colors… from a gradient stop's color popover applies the custom color to that
/// stop while keeping the other stops and gradient settings intact.
#[test]
fn format_shape_pane_gradient_stop_more_colors_applies_stop_color() {
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
a.run("insert.shape", json!({"kind": "rectangle"})).unwrap();
let stops = json!([{"pos": 0, "color": "FFFFFF", "transparency": 20}, {"pos": 100, "color": "156082", "transparency": 50}]);
a.run("shape.fill", json!({"gradient": {"stops": stops, "angle": 90}})).unwrap();
a.run("view.formatShapePane", json!({"value": true})).unwrap();
let mut h = harness(a);
h.run_steps(4);
h.get_by_label("Color stop 2 of 2").click();
h.run_steps(3);
h.key_press(egui::Key::Enter);
h.run_steps(3);
h.get_by_label("More Colors…").click();
h.run_steps(3);
let dialog = h.state_mut().dialog_host.get_mut::<craft::color_ui::ui::ColorPickerDialog>().expect("Colors dialog opened");
assert_eq!(dialog.opening().map(|p| super::rgb_of(p.color)), Some(wordcraft_doc::Rgb(0x15, 0x60, 0x82)));
dialog.set_color(craft::color_ui::ui::PickedColor::rgb(craft::theme::Srgba::rgb(1.0, 0.0, 0.0)));
let ctx = h.ctx.clone();
assert!(h.state_mut().dialog_host.confirm::<craft::color_ui::ui::ColorPickerDialog>(&ctx));
crate::dialogs::host::settle(h.state_mut(), &ctx);
let Some(Fill::Gradient(g)) = fill(h.state()) else { panic!("expected gradient fill, got {:?}", fill(h.state())) };
assert_eq!(g.stops.len(), 2);
assert_eq!(g.stops[0].color, wordcraft_doc::Rgb(0xFF, 0xFF, 0xFF));
assert_eq!(g.stops[1].color, wordcraft_doc::Rgb(255, 0, 0));
assert_eq!(g.stops[1].transparency, 50.0);
}
fn png_data() -> String {
let img = image::RgbaImage::from_fn(20, 10, |x, y| {
if x > 2 && x < 17 && y > 2 && y < 7 { image::Rgba([200, 30, 30, 255]) } else { image::Rgba([255, 255, 255, 255]) }
+10 -3
View File
@@ -1714,10 +1714,17 @@ mod tests {
.iter()
.filter(|(_, n)| n.label() == Some(label))
.filter_map(|(_, n)| n.bounds())
.find(|b| b.x0 >= picker.x0 && b.x1 <= picker.x1 && b.y0 >= picker.y0 && b.y1 <= picker.y1)
.filter(|b| b.x0 >= picker.x0 && b.x1 <= picker.x1 && b.y0 >= picker.y0 && b.y1 <= picker.y1)
.collect::<Vec<_>>()
};
let search = in_picker("Search").expect("the picker's Search field");
let close = in_picker("Close").expect("the picker's Close button");
let search = *in_picker("Search").first().expect("the picker's Search field");
// The picker has two Close buttons: one in its title bar, above the Search field, and the footer's below
// it. Which comes first in the tree depends on the node ids, so take the footer's by position.
let close = in_picker("Close")
.into_iter()
.filter(|b| b.y0 >= search.y1)
.min_by(|a, b| a.y0.total_cmp(&b.y0))
.expect("the picker's Close button");
(list.y0.max(picker.y0).max(search.y1), list.y1.min(picker.y1).min(close.y0), list)
};
let mut tree = tree;
+2
View File
@@ -187,6 +187,7 @@ pub(crate) fn members(app: &mut WordApp, ui: &mut Ui, preview: bool) {
Row::new().gap(Gap::Tight).show(ui, |ui, _| {
let mut family = st.get("font").and_then(Value::as_str).unwrap_or("").to_string();
let picked = crate::widgets::font_box::font_box(ui, app, tl!("Font").to_string(), &mut family);
crate::ribbon::common::painted_ibeam_over(ui, &picked.edit.response);
follow_list(app, preview, &picked.preview, |f| Some(("format.font".to_string(), json!({"name": f}))));
if let Some(f) = &picked.picked {
let _ = app.run("format.font", json!({"name": f}));
@@ -200,6 +201,7 @@ pub(crate) fn members(app: &mut WordApp, ui: &mut Ui, preview: bool) {
let mut text = size.clone();
// `text` is rebuilt from the selection on every pass: the box keeps what is typed until Enter.
let combo = ComboBox::new(tl!("Font Size").to_string(), Bind::bound(&mut text).policy(EditPolicy::OnCommit), &sizes).show(ui);
crate::ribbon::common::painted_ibeam_over(ui, &combo.edit.response);
follow_list(app, preview, &combo.preview, |v| {
v.trim().parse::<f64>().ok().map(|x| ("format.size".to_string(), json!({"size": x})))
});
+5 -3
View File
@@ -448,7 +448,8 @@ impl PreferencesModel for OptionsModel<'_> {
vec![
GroupSpec::new(Some(tl!("Save documents")), {
// The browser can't write to the user's files, so AutoSave can't be turned on there (#176).
let row = b("save.autosave", tl!("AutoSave documents you have saved in WordCraft"), app.autosave && !browser).enabled(!browser);
let autosaving = !browser && app.autosave && app.autosave_choice != Some(false);
let row = b("save.autosave", tl!("AutoSave documents you have saved in WordCraft"), autosaving).enabled(!browser);
vec![row.help(if browser {
&s.autosave_reason
} else {
@@ -666,8 +667,9 @@ impl PreferencesModel for OptionsModel<'_> {
if self.app.autosave_block() != Some(crate::AutoSaveBlock::Browser) {
self.app.autosave = v;
self.app.session.autosave = v;
// The Options row explicitly enables AutoSave for the active saved document.
if v && self.app.saved_here() {
// The Options row clears a document opt-out so ticking it re-enables saved
// documents; an opened-only file's switch approval (`Some(true)`) is kept.
if v && self.app.autosave_choice == Some(false) {
self.app.autosave_choice = None;
}
}
+71
View File
@@ -179,6 +179,58 @@ fn options_panes_open_and_change_settings() {
}
}
#[test]
fn autosave_option_reflects_document_opt_out_and_reenables_on_tick() {
use egui_kittest::kittest::{NodeT, Queryable};
let dir = std::env::temp_dir().join(format!("wc-ui-autosave-optout-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let (first_path, second_path) = (dir.join("first.docx"), dir.join("second.docx"));
let mut seed = app();
seed.run("text.insert", json!({"text": "Second document."})).unwrap();
seed.run("file.save", json!({"path": second_path.to_string_lossy()})).unwrap();
let mut a = app();
a.run("text.insert", json!({"text": "First document."})).unwrap();
a.run("file.save", json!({"path": first_path.to_string_lossy()})).unwrap();
let first = a.session.document_id();
a.run("file.autosave", json!({"value": false})).unwrap();
a.run("file.open", json!({"path": second_path.to_string_lossy()})).unwrap();
let second = a.session.document_id();
a.run("file.autosave", json!({"value": true})).unwrap();
a.show_document(first).unwrap();
assert!(!a.autosaves(), "the first document keeps its opt-out");
a.run("ui.backstage", json!({"value": true, "page": "options", "pane": "save"})).unwrap();
let mut h = crate::test_harness::builder().build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
options_frames(&mut h, 3);
let box_label = "AutoSave documents you have saved in WordCraft";
assert_eq!(
h.get_by_role_and_label(egui::accesskit::Role::CheckBox, box_label).accesskit_node().toggled(),
Some(egui::accesskit::Toggled::False),
"Options must show unticked while the active document's own switch is off"
);
h.get_by_role_and_label(egui::accesskit::Role::CheckBox, box_label).click();
options_frames(&mut h, 3);
assert_eq!(
h.get_by_role_and_label(egui::accesskit::Role::CheckBox, box_label).accesskit_node().toggled(),
Some(egui::accesskit::Toggled::True),
"ticking re-enables AutoSave for the active document"
);
assert!(h.state().autosaves(), "AutoSave is enabled again for the first document");
h.state_mut().show_document(second).unwrap();
assert!(h.state().autosaves(), "the second document stays AutoSaved");
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn autosave_option_enables_saved_files_without_authorizing_open_only_files() {
let dir = std::env::temp_dir().join(format!("wc-ui-autosave-option-{}", std::process::id()));
@@ -206,6 +258,25 @@ fn autosave_option_enables_saved_files_without_authorizing_open_only_files() {
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn autosave_option_retick_keeps_the_switch_approval_of_an_opened_file() {
let dir = std::env::temp_dir().join(format!("wc-ui-autosave-retick-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let path = dir.join("opened.docx");
let mut seed = app();
seed.run("text.insert", json!({"text": "Opened for the AutoSave test."})).unwrap();
seed.run("file.save", json!({"path": path.to_string_lossy()})).unwrap();
let mut opened = app();
opened.run("file.open", json!({"path": path.to_string_lossy()})).unwrap();
opened.run("file.autosave", json!({"value": true})).unwrap();
assert!(opened.autosaves(), "the document's switch grants permission");
with_model(&mut opened, true, |m| m.set("save.autosave", PrefValue::Bool(false)));
with_model(&mut opened, true, |m| m.set("save.autosave", PrefValue::Bool(true)));
assert!(opened.autosaves(), "ticking the Options box again keeps the approval");
let _ = std::fs::remove_dir_all(&dir);
}
/// One table over the Choice rows and the document's privacy options.
#[test]
fn save_privacy_checkboxes_set_the_privacy_options() {
+20 -2
View File
@@ -219,14 +219,32 @@ mod tests {
let url = "https://example.test/picture.png";
let html = format!(r#"<meta http-equiv="content-type" content="text/html; charset=utf-8"><img src="{url}" alt="A &amp; B">"#);
let url_and_alt = format!("{url}\r\nA & B");
for text in [url, "A & B", &url_and_alt] {
let title = "Picture title";
let srcset_url = "https://example.test/picture-2x.png";
let comma_srcset_url = "https://example.test/a,b.png";
let offers = [
(url, html.clone()),
("A & B", html.clone()),
(&url_and_alt, html.clone()),
(title, format!(r#"<img src="{url}" title="{title}">"#)),
(srcset_url, format!(r#"<img src="{url}" srcset="{srcset_url} 2x">"#)),
(comma_srcset_url, format!(r#"<img src="{url}" srcset="{comma_srcset_url} 2x">"#)),
];
for (text, html) in offers {
let mut app = app_holding(&[Flavor::text(text), Flavor::new(HTML, html.as_bytes().to_vec()), rgba8(4, 4, 200)]);
app.run("edit.paste", json!({})).unwrap();
assert_eq!(pictures(&mut app), 1);
assert_eq!(pictures(&mut app), 1, "clipboard text {text:?}");
assert!(!app.session.doc.plain_text(wordcraft_doc::StoryRef::Body).contains(text));
app.run("edit.undo", json!({})).unwrap();
assert_eq!(pictures(&mut app), 0);
}
let false_match = "b.png";
let html = format!(r#"<img src="{url}" srcset="{comma_srcset_url} 2x">"#);
let mut app = app_holding(&[Flavor::text(false_match), Flavor::new(HTML, html.into_bytes()), rgba8(4, 4, 200)]);
app.run("edit.paste", json!({})).unwrap();
assert_eq!(pictures(&mut app), 0);
assert_eq!(app.session.doc.plain_text(wordcraft_doc::StoryRef::Body), false_match);
}
#[test]
+5 -4
View File
@@ -463,11 +463,12 @@ pub fn import_legacy_window(bytes: &[u8], store: &mut craft::window::restore::St
mod tests;
/// Returns the user's home directory from `HOME` or `USERPROFILE`, if set and non-empty.
/// Windows checks `USERPROFILE` first: there `HOME` is often a mapped network drive or
/// Git for Windows' home, not the profile folder.
fn home_dir() -> Option<std::path::PathBuf> {
std::env::var_os("HOME")
.filter(|h| !h.is_empty())
.or_else(|| std::env::var_os("USERPROFILE").filter(|h| !h.is_empty()))
.map(std::path::PathBuf::from)
let var = |key: &str| std::env::var_os(key).filter(|h| !h.is_empty());
let (first, second) = if cfg!(windows) { ("USERPROFILE", "HOME") } else { ("HOME", "USERPROFILE") };
var(first).or_else(|| var(second)).map(std::path::PathBuf::from)
}
fn strip_tilde_prefix(path: &str) -> Option<&str> {
+1 -4
View File
@@ -251,10 +251,7 @@ fn recent_paths_inside_home_contract_and_expand() {
assert_eq!(super::expand_recent_path_with("~/Docs/test.docx", None), "~/Docs/test.docx");
// Round-trip through WordApp::prefs / apply_prefs using the process home directory.
let real_home = std::env::var_os("HOME")
.filter(|h| !h.is_empty())
.or_else(|| std::env::var_os("USERPROFILE").filter(|h| !h.is_empty()))
.map(std::path::PathBuf::from);
let real_home = super::home_dir();
if let Some(real_home) = real_home {
let doc = real_home.join("WordCraftSyncTest").join("notes.docx");
let doc_str = doc.to_string_lossy().into_owned();
+14 -1
View File
@@ -1,5 +1,7 @@
use std::ops::RangeInclusive;
use craft::behavior::cursor::{Cursor, CursorPriority, PaintedCursor};
use craft::host::target::{Os, Runtime};
use craft::keymap::CommandRef;
use craft::menu::ribbon::{RibbonGroup, RibbonRow};
use craft::ui::buttons::{Arrangement, Button};
@@ -11,7 +13,7 @@ use craft::ui::layout_components::{Row, Stack};
use craft::ui::list::ThumbAspect;
use craft::ui::menu::{Menu, MenuItem, MenuOutput};
use craft::ui::primitives::{FacePaint, IconSpec};
use craft::ui::runtime::env::Label;
use craft::ui::runtime::env::{Env, Label};
use craft::ui::text::NumberField;
use serde_json::Value;
@@ -68,6 +70,17 @@ pub(crate) fn labelled<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> R {
)
}
/// On Windows the system I-beam is the legacy white XOR cursor over the GPU surface; the page
/// replaces it with the framework's painted beam. Do the same over a ribbon or mini-toolbar text
/// field on hover.
pub(crate) fn painted_ibeam_over(ui: &Ui, response: &egui::Response) {
let env = Env::of(ui);
let shell = env.view().shell();
if shell.os == Os::Windows && shell.runtime == Runtime::Native && response.hovered() {
craft::ui::runtime::cursor::request(ui.ctx(), Cursor::Painted(PaintedCursor::IBeam), CursorPriority::Hover);
}
}
/// Two rows of small controls spread over the ribbon's body, `row(ui, 0)` above `row(ui, 1)`, with as much room above
/// the first, between them and under the second, so a two-row group fills the height of the three rows beside it and
/// leaves no empty band over its title.
+4 -3
View File
@@ -14,7 +14,7 @@ use craft::ui::primitives::{HAlign, TextRun};
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
use wordcraft_doc::props::Align;
use super::common::{icon_only, menu_button, two_rows};
use super::common::{icon_only, menu_button, painted_ibeam_over, two_rows};
use super::underline::underline_menu;
use egui::vec2;
use serde_json::Value;
@@ -200,6 +200,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
if at == 0 {
let mut family = st.get("font").and_then(Value::as_str).unwrap_or("").to_string();
let out = crate::widgets::font_box(ui, app, tl!("Font").to_string(), &mut family);
painted_ibeam_over(ui, &out.edit.response);
if let Some(f) = out.picked {
let _ = app.run("format.font", json!({"name": f}));
}
@@ -207,6 +208,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
let out = craft::ui::pickers::ComboBox::new(tl!("Font Size").to_string(), Bind::bound(&mut size), font_size_entries())
.tooltip(tl!("Font Size").to_string())
.show(ui);
painted_ibeam_over(ui, &out.edit.response);
if let Some(v) = out.edit.events.committed()
&& let Ok(x) = v.trim().parse::<f64>()
{
@@ -310,7 +312,6 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
("I. II. III.", "outline"),
("A. B. C.", "upperLetter"),
("a) b) c)", "lowerLetter"),
("a. b. c.", "lowerLetterDot"),
("i. ii. iii.", "lowerRoman"),
] {
MenuItem::command(CommandRef::with_params("para.numbering", json!({"kind": k}))).label(tl!(l).to_string()).show(ui);
@@ -354,7 +355,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
Divider::horizontal().show(ui);
for lv in 0..9u64 {
MenuItem::command(CommandRef::with_params("para.listLevel", json!({"level": lv})))
.label(format!("Change to Level {}", lv + 1))
.label(crate::i18n::fmt(tl!("Change to Level {n}"), &[("n", &(lv + 1).to_string())]))
.show(ui);
}
})),
-41
View File
@@ -1593,44 +1593,3 @@ fn picture_and_shape_size_fields_show_unit_hints() {
assert!(h.query_by_label_contains(expected).is_some(), "{tab} W: hover tooltip shows unit hint");
}
}
/// #4281: the Numbering drop-down lists "a. b. c." and applies it, then switching to another
/// preset changes the list instead of turning it off.
#[test]
fn the_numbering_menu_offers_a_dot_b_dot_c_dot() {
use egui_kittest::kittest::{By, Queryable};
let item = |label: &'static str| By::new().label_contains(label);
let mut a = crate::WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
a.run("text.insert", json!({"text": "One"})).unwrap();
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut crate::WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
for _ in 0..4 {
h.step();
}
let label = |h: &mut egui_kittest::Harness<'_, crate::WordApp>| {
let l = h.state_mut().session.layout();
l.pages.iter().flat_map(|p| &p.items).find_map(|i| match i {
wordcraft_layout::Placed::Lines { para, l0: 0, .. } => para.label.as_ref().map(|lb| lb.text.clone()),
_ => None,
})
};
h.get_by_label("Numbering options").click();
h.run();
for want in ["1. 2. 3.", "a) b) c)", "a. b. c.", "i. ii. iii."] {
assert!(h.query(item(want)).is_some(), "the menu lists {want}");
}
h.get(item("a. b. c.")).click();
h.run();
assert_eq!(label(&mut h).as_deref(), Some("a."));
h.get_by_label("Numbering options").click();
h.run();
h.get(item("A. B. C.")).click();
h.run();
assert_eq!(label(&mut h).as_deref(), Some("A."), "another preset changes the list");
}
+36 -2
View File
@@ -47,6 +47,31 @@ fn read_markup(clip: &ClipboardHandle, mime: &str) -> Option<String> {
Some(String::from_utf8_lossy(&flavor.data).into_owned()).filter(|t| !t.trim().is_empty())
}
/// The image URLs in a srcset, following its candidate URL and descriptor syntax.
fn srcset_urls(srcset: &str) -> impl Iterator<Item = &str> {
let mut rest = srcset;
std::iter::from_fn(move || {
loop {
rest = rest.trim_start_matches(|c: char| c.is_ascii_whitespace() || c == ',');
if rest.is_empty() {
return None;
}
let end = rest.find(char::is_whitespace).unwrap_or(rest.len());
let (raw_url, tail) = rest.split_at(end);
let url = raw_url.trim_end_matches(',');
rest = tail;
if url.is_empty() {
continue;
}
if !raw_url.ends_with(',') {
let descriptor_end = rest.find(',').unwrap_or(rest.len());
rest = if descriptor_end < rest.len() { &rest[descriptor_end + 1..] } else { "" };
}
return Some(url);
}
})
}
/// A browser image copy can carry a source address or the image's alt text alongside the bitmap.
fn single_image_offer(html: &str, text: Option<&str>) -> bool {
use craft_html::{Lexer, Token, unescape};
@@ -61,7 +86,12 @@ fn single_image_offer(html: &str, text: Option<&str>) -> bool {
for token in Lexer::new(fragment) {
match token {
Token::Start(tag) if tag.name == "img" && image.is_none() => {
image = Some((tag.attr("src").unwrap_or_default(), tag.attr("alt").unwrap_or_default()));
image = Some((
tag.attr("src").unwrap_or_default(),
tag.attr("alt").unwrap_or_default(),
tag.attr("title").unwrap_or_default(),
tag.attr("srcset").unwrap_or_default(),
));
}
Token::Start(tag) if wrapper(&tag.name) && tag.attrs.is_empty() => {}
Token::Start(tag) if tag.name == "meta" && tag.attrs.len() == 1 && tag.has("charset") => {}
@@ -75,13 +105,17 @@ fn single_image_offer(html: &str, text: Option<&str>) -> bool {
_ => return false,
}
}
let Some((src, alt)) = image else { return false };
let Some((src, alt, title, srcset)) = image else { return false };
let text = text.unwrap_or_default().trim();
let alt = alt.trim();
let src = src.trim();
let title = title.trim();
let srcset = srcset.trim();
text.is_empty()
|| text == alt
|| text == title
|| text == src
|| srcset_urls(srcset).any(|url| url == text)
|| text.split_once('\n').is_some_and(|(address, description)| address.trim() == src && description.trim() == alt)
}
+50
View File
@@ -1857,6 +1857,26 @@ fn a_direct_close_keeps_unsaved_changes_unless_forced() {
assert!(!a.has_document() && !a.quit_requested);
}
/// A direct programmatic `ui.quit` never opens the Save prompt either: it refuses unsaved
/// work unless `force` is true (#8793).
#[test]
fn a_direct_quit_keeps_unsaved_changes_unless_forced() {
let mut a = typed();
for params in [json!({}), json!({"force": "yes"}), json!({"force": 1})] {
let e = a.execute("ui.quit", params.clone()).unwrap_err();
assert!(e.contains("unsaved") && e.contains("force"), "{params}: {e}");
assert!(a.has_document() && !a.quit_requested && prompt(&a).is_none() && a.closing.is_none(), "{params}");
}
let r = a.execute("ui.quit", json!({"force": true})).unwrap();
assert_eq!(r, json!({"quit": true}));
assert!(a.quit_requested && prompt(&a).is_none());
let mut clean = app();
let r = clean.execute("ui.quit", json!({})).unwrap();
assert_eq!(r, json!({"quit": true}));
assert!(clean.quit_requested);
}
/// The window's close button quit at once; now it asks (the host cancels the close on false).
#[test]
fn window_close_asks_first() {
@@ -2438,6 +2458,36 @@ fn clicks_on_ribbon_and_status_bar_chrome_keep_typing_in_the_document() {
assert_eq!(body_text(h.state()), before, "typing went into the font size box, not the page");
}
/// #7757: Windows draws its system text I-beam in white over the app's surface, so the ribbon's font
/// fields looked cursorless there. Like the page, the font size box must ask for craft's painted
/// I-beam on a native Windows shell; other shells keep the system text cursor.
#[test]
fn the_ribbon_font_size_box_shows_a_painted_ibeam_on_windows() {
use craft::host::target::{Os, Runtime};
use egui::accesskit::Role;
let mut h = harness(app());
h.run_steps(4);
let size =
h.get_all_by_role(Role::TextInput).find(|n| n.value().is_some_and(|v| v.trim().parse::<f64>().is_ok())).expect("the font size box").rect();
h.hover_at(size.center());
h.step();
h.step();
let env = craft::ui::runtime::env::Env::of_root(&h.ctx);
let shell = env.view().shell();
if shell.os == Os::Windows && shell.runtime == Runtime::Native {
assert!(h.output().platform_output.cursor_image.is_some(), "the font size box asks for the painted I-beam on Windows native");
assert_eq!(
craft::ui::runtime::cursor::current(&h.ctx),
Some(craft::behavior::cursor::Cursor::Painted(craft::behavior::cursor::PaintedCursor::IBeam)),
"the font size box asks for the painted I-beam"
);
} else {
assert_eq!(h.output().platform_output.cursor_icon, egui::CursorIcon::Text, "other shells keep the text cursor");
}
}
/// #1538: inserting WordArt leaves its text selected, so Delete erased only the text and the
/// empty box stayed. Escape now selects the box itself, Delete removes it, and a second Escape
/// is back to a caret in the body.
+66 -19
View File
@@ -3,8 +3,10 @@ use std::sync::Arc;
use craft::font_manager::Catalog;
use craft::font_manager::craft_font_catalog::{FontEnv, Os};
use craft::font_manager::missing::MissingFontsWords;
use craft::host::{Host, PickKind, ScriptedFiles};
use craft::ui::buttons::IconButton;
use craft::ui::contract::{Props as _, Show as _};
use craft::ui::contract::{Props as _, Show as _, tooltip};
use egui::accesskit::Role;
use egui::{Key, vec2};
use egui_kittest::kittest::{By, NodeT, Queryable};
@@ -225,24 +227,49 @@ fn drawn_buttons_fade_in_on_hover_and_darken_while_pressed() {
assert_eq!(fill_after, None, "Save button must clear hover fill after unhovering");
}
/// #7317 / #8447: typing in WordCraft's `font_box` updates the popup list on the same frame as
/// the keystroke, shows the Recently Used Fonts section (and WordCraft's `Add Font…` action row)
/// again when cleared, and narrows immediately on subsequent typing.
/// #7317 / #8447 / #8778: WordCraft's `font_box` warns with `MissingAdvice::AddFont` for an
/// uninstalled family, updates the popup list on the same frame as each keystroke, shows the
/// Recently Used Fonts section again when cleared, places `Add Font…` last, and picking `Add Font…`
/// runs `font.add` without changing the family.
#[test]
fn the_typed_list_shows_on_the_frame_of_the_keystroke() {
const RECENT: &str = "Source Serif 4";
const MISSING: &str = "Wordcraft Missing Face";
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Sample")), Services::default());
let files = Arc::new(ScriptedFiles::held());
let host = Host::builder(crate::APP).files(files.clone()).build();
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Sample")), Services::default()).with_host(Arc::new(host));
app.ui.language = "en".into();
app.font_catalog = Some(fixed_catalog());
app.ui.font_picker.recent = vec![RECENT.to_string()];
let mut family = String::new();
let substitute = app.font_box_warning(MISSING).expect("missing family produces a substitute warning");
let words = MissingFontsWords::default();
let expected_note = format!("{} {}", words.shown_as.fill(&[("family", MISSING), ("face", &substitute)]), words.add_font.as_str());
let mut h = crate::test_harness::builder().with_size(vec2(400.0, 900.0)).build_ui(move |ui| {
let _ = super::font_box(ui, &mut app, "Font", &mut family);
});
let mut h = crate::test_harness::builder().with_size(vec2(400.0, 900.0)).build_ui_state(
|ui, (app, family): &mut (WordApp, String)| {
let _ = super::font_box(ui, app, "Font", family);
},
(app, MISSING.to_string()),
);
h.run_steps(2);
// Resting on the warning mark shows the missing-font note together with MissingAdvice::AddFont.
let input_rect = h.get(By::new().role(Role::TextInput)).rect();
let chevron_rect = h.get_by_role_and_label(Role::Button, "Fonts").rect();
let warning_pos = egui::pos2((input_rect.max.x + chevron_rect.min.x) * 0.5, chevron_rect.center().y);
assert!(
h.query_by_label_contains(words.add_font.as_str()).is_none(),
"missing-font advice should wait until the pointer rests on the warning mark"
);
h.event(egui::Event::PointerMoved(warning_pos));
let delay_frames = (tooltip::DELAY / 0.25).ceil() as usize + 3;
h.run_steps(delay_frames);
assert!(
h.query_by_label(expected_note.as_str()).is_some(),
"expected missing-font note with MissingAdvice::AddFont when hovering the warning mark; substitute={substitute:?}"
);
h.get(By::new().role(Role::TextInput)).click();
h.run_steps(2);
@@ -252,7 +279,7 @@ fn the_typed_list_shows_on_the_frame_of_the_keystroke() {
egui::Event::Key { key: Key::Backspace, physical_key: None, pressed: false, repeat: false, modifiers: egui::Modifiers::NONE },
]
};
let send = |h: &mut egui_kittest::Harness<'static, ()>, events: Vec<egui::Event>| {
let send = |h: &mut egui_kittest::Harness<'static, (WordApp, String)>, events: Vec<egui::Event>| {
for ev in events {
h.event(ev);
}
@@ -308,16 +335,13 @@ fn the_typed_list_shows_on_the_frame_of_the_keystroke() {
}
}
// Clearing `"int"` restores the full list with WordCraft's `Add Font…` action row at the end.
// Clearing `"int"` restores the full list with WordCraft's `Add Font…` action row last.
for _ in 0..3 {
send(&mut h, erase());
}
let list_center = h.get_by_role_and_label(Role::ListBox, "Fonts").rect().center();
h.event(egui::Event::PointerMoved(list_center));
for _ in 0..20 {
if h.query_by_role_and_label(Role::TreeItem, "Add Font…").is_some() {
break;
}
let scroll_down = |h: &mut egui_kittest::Harness<'static, (WordApp, String)>| {
h.event(egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Page,
delta: vec2(0.0, -20.0),
@@ -326,9 +350,32 @@ fn the_typed_list_shows_on_the_frame_of_the_keystroke() {
source: egui::MouseWheelSource::Unknown,
});
h.step();
};
let visible_rows = |h: &egui_kittest::Harness<'static, (WordApp, String)>| -> Vec<(String, f32)> {
let mut rows: Vec<(String, f32)> =
h.query_all_by_role(Role::TreeItem).filter_map(|n| Some((n.accesskit_node().label()?, n.rect().min.y))).collect();
rows.sort_by(|a, b| a.1.total_cmp(&b.1));
rows
};
for _ in 0..50 {
if h.query_by_role_and_label(Role::TreeItem, "Add Font…").is_some() {
break;
}
scroll_down(&mut h);
}
assert!(
h.query_by_role_and_label(Role::TreeItem, "Add Font…").is_some(),
"expected WordCraft's Add Font… action row at the end of font_box's cleared list"
);
assert!(h.query_by_role_and_label(Role::TreeItem, "Add Font…").is_some(), "expected WordCraft's Add Font… action row in font_box's cleared list");
scroll_down(&mut h);
let rows = visible_rows(&h);
assert!(rows.len() >= 2, "expected font families above Add Font… in the list, got {rows:?}");
assert_eq!(rows.last().map(|(label, _)| label.as_str()), Some("Add Font…"), "expected Add Font… to be the last row, got {rows:?}");
// Picking Add Font… runs `font.add` without changing `family`.
assert!(files.requests().is_empty(), "no file picker request before picking Add Font…");
h.get_by_role_and_label(Role::TreeItem, "Add Font…").click();
h.run_steps(2);
let requests = files.requests();
assert_eq!(requests.len(), 1, "picking Add Font… should run font.add");
assert_eq!(requests[0].purpose, "font");
assert_eq!(requests[0].kind, PickKind::OpenMany);
assert_eq!(h.state().1, MISSING, "picking Add Font… should leave the family unchanged");
}
+3 -2
View File
@@ -90,7 +90,8 @@ Recorded reader pairs (exact shapes in the policy):
| lib.rs::check_owner_note_pr | NOTE-PR-DANGLING,NOTE-PR-LISTING | access.into_complete_set*2,access.missing*2,access.prefix*2,field.endnote_defs*1,field.footnote_defs*1,field.note_listings*1,field.special_notes*1,type.HashSet*3,type.Observed*3 | each established owner and its selected supporting sources; shared parts in every owner; unowned references excluded; explicit no-root fallback only | source unavailable or malformed; XML event/depth budget; category allocation cap; unknown or ambiguous source discovery; source-local pooled-budget loss | suppress only dependent absence directions and report Incomplete; independent owner and prefix findings survive | NOTE-PR-LISTING,NOTE-PR-DANGLING |
| lib.rs::check_content_part_types | CONTENTPART-TYPE | field.content_types*1,field.rels*1,type.HashSet*2,type.Vec*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::report_malformed | XML-MALFORMED | field.reachable*1,type.Observed*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::story_roles | - | field.content_types*1,field.entries*1,field.rels*2,lookup.canonical_entry*1,type.HashMap*2 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::story_roles | - | field.content_types*1,field.entries*1,field.reachable*2,field.rels*2,lookup.canonical_entry*1,type.HashMap*2 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::report_unknown_story_reachability | - | field.content_types*1,field.entries*1,field.reachable*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::check_rels | REL-DANGLING,REL-DUP-ID,REL-REF-MISSING,REL-TYPED | field.references*1,field.rels*3,lookup.canonical_entry*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | REL-DANGLING |
| lib.rs::report_duplicate_rel_ids | REL-DUP-ID | field.rels*1,type.HashMap*2,type.Vec*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::check_part_refs | REL-REF-MISSING | access.into_complete_set*1,access.is_complete*1,access.missing*1,access.prefix*1,field.collapsed_names*2,field.parts*1,field.references*2,field.rels*1,type.HashSet*2,type.Observed*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | REL-REF-MISSING |
@@ -121,7 +122,7 @@ Recorded reader pairs (exact shapes in the policy):
| lib.rs::report_style_num_refs | NUM-DANGLING | access.missing*1,lookup.entry_by_name*1,parser.parse_style_num_ids*1,type.CompleteSet*1,type.HashSet*1 | each established owner and its selected supporting sources; shared parts in every owner; unowned references excluded; explicit no-root fallback only | source unavailable or malformed; XML event/depth budget; category allocation cap; unknown or ambiguous source discovery; source-local pooled-budget loss | suppress only dependent absence directions and report Incomplete; independent owner and prefix findings survive | NUM-DANGLING |
| lib.rs::report_num_refs | NUM-DANGLING | access.missing*1,access.prefix*1,field.num_ids*1,type.CompleteSet*1,type.HashSet*2 | each established owner and its selected supporting sources; shared parts in every owner; unowned references excluded; explicit no-root fallback only | source unavailable or malformed; XML event/depth budget; category allocation cap; unknown or ambiguous source discovery; source-local pooled-budget loss | suppress only dependent absence directions and report Incomplete; independent owner and prefix findings survive | NUM-DANGLING |
| lib.rs::report_dups_values | NUM-DANGLING | type.HashMap*2,type.Vec*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::check_commentex | COMMENTEX-LINK | access.into_complete_set*3,access.missing*4,access.prefix*1,field.comment_para_ids*2,field.entries*4,type.HashSet*3,type.Observed*3 | each established owner and its selected supporting sources; shared parts in every owner; unowned references excluded; explicit no-root fallback only | source unavailable or malformed; XML event/depth budget; category allocation cap; unknown or ambiguous source discovery; source-local pooled-budget loss | suppress only dependent absence directions and report Incomplete; independent owner and prefix findings survive | COMMENTEX-LINK |
| lib.rs::check_commentex | COMMENTEX-LINK | access.into_complete_set*3,access.missing*4,access.prefix*1,field.comment_para_ids*2,field.content_types*1,field.entries*4,type.HashSet*3,type.Observed*3 | each established owner and its selected supporting sources; shared parts in every owner; unowned references excluded; explicit no-root fallback only | source unavailable or malformed; XML event/depth budget; category allocation cap; unknown or ambiguous source discovery; source-local pooled-budget loss | suppress only dependent absence directions and report Incomplete; independent owner and prefix findings survive | COMMENTEX-LINK |
| lib.rs::read_comments_ext | COMMENTEX-LINK | parser.parse_comments_extended*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::read_comments_ids | COMMENTEX-LINK | parser.parse_comments_ids*1,type.Vec*1 | source-local bounded extraction; no implicit document owner | source unavailable or malformed; XML event/depth budget; category allocation cap | retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set | independent |
| lib.rs::check_custom_xml | CUSTOMXML-SCHEMA | access.into_complete_set*2,access.missing*1,field.content_types*3,field.contexts*2,field.entries*3,lookup.content_unavailable*1,parser.parse_attached_schemas*1,parser.parse_custom_xml_schemas*1,type.CompleteSet*1,type.HashSet*3,type.Observed*2,type.Vec*3 | DECLARED EXCEPTION: PackageRegistryContext for established-unowned own declarations; reached declarations keep their selected registry; never grants story ownership | source unavailable or malformed; XML event/depth budget; category allocation cap | unknown membership or registry source suppresses dependent absence; informational coverage retains the package-registry policy | CUSTOMXML-SCHEMA |
+1
View File
@@ -304,6 +304,7 @@ def unit_audit(name, func, header, body, semantic_json, fields, enum_variants,
('lib.rs', 'absence_suppressed', 'PACKAGE_ABSENCE_RULES'),
('lib.rs', 'check_note_pr', 'reverse_ok'),
('lib.rs', 'report_malformed', 'pkg.reachable'),
('lib.rs', 'report_unknown_story_reachability', 'pkg.reachable'),
('lib.rs', 'check_typed_content', 'non_main_owner_rels'),
('lib.rs', 'report_unreferenced_comments', 'incomplete_owners'),
('lib.rs', 'supporting_part', 'acc.coverage'),
+50 -11
View File
@@ -1563,6 +1563,7 @@ fn check_xml(pkg: &Package, acc: &mut Acc) -> XmlScan {
acc.ran("PROTECTION-PASSWORD");
acc.ran("HEADERSOURCE-PRESENT");
let roles = story_roles(pkg);
report_unknown_story_reachability(pkg, acc);
let graph = PartGraph::new(pkg);
if graph.budget_exhausted() {
acc.note(
@@ -2280,12 +2281,12 @@ fn report_malformed(pkg: &Package, name: &str, err: &str, acc: &mut Acc) {
}
/// Classify the story parts from their effective content type and the relationships that reach
/// them, never from their file names or folder. A comments part stored under an unusual name is
/// still found when a comments relationship or the comments content type names it.
/// them, never from their file names or folder. Only parts reachable from the package root
/// receive roles; declarations in orphan relationship sources cannot establish consumption.
fn story_roles(pkg: &Package) -> HashMap<String, scan::PartRole> {
observation_contract! {
rules: "-";
collections: "field.content_types*1,field.entries*1,field.rels*2,lookup.canonical_entry*1,type.HashMap*2";
collections: "field.content_types*1,field.entries*1,field.reachable*2,field.rels*2,lookup.canonical_entry*1,type.HashMap*2";
scope: "source-local bounded extraction; no implicit document owner";
loss: "source unavailable or malformed; XML event/depth budget; category allocation cap";
fallback: "retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set";
@@ -2296,12 +2297,15 @@ fn story_roles(pkg: &Package) -> HashMap<String, scan::PartRole> {
if let Resolution::One(main) = &pkg.main {
roles.insert(main.to_ascii_lowercase(), scan::PartRole::Main);
}
for e in pkg.entries.iter().filter(|e| !e.is_dir) {
for e in pkg.entries.iter().filter(|e| !e.is_dir && pkg.reachable.contains(&e.name.to_ascii_lowercase())) {
if let Some(role) = content_type_role(pkg.content_types.of(&e.name)) {
roles.entry(e.name.to_ascii_lowercase()).and_modify(|existing| *existing = existing.merge(role)).or_insert(role);
}
}
for rp in &pkg.rels {
if rels_owner_name(&rp.name).is_some_and(|owner| !pkg.reachable.contains(&owner)) {
continue;
}
for r in &rp.rels {
let Some(role) = relationship_role(r.role.kind()) else { continue };
let Some(target) = &r.target_abs else { continue };
@@ -2313,6 +2317,28 @@ fn story_roles(pkg: &Package) -> HashMap<String, scan::PartRole> {
roles
}
/// Do not silently skip candidate stories when their relationship paths may be unread.
fn report_unknown_story_reachability(pkg: &Package, acc: &mut Acc) {
observation_contract! {
rules: "-";
collections: "field.content_types*1,field.entries*1,field.reachable*1";
scope: "source-local bounded extraction; no implicit document owner";
loss: "source unavailable or malformed; XML event/depth budget; category allocation cap";
fallback: "retain proven prefix presence and duplicates; return loss to the caller; no negative membership from an incomplete set";
package_loss: "independent";
}
if ownership_discovery_complete(pkg) {
return;
}
for e in pkg.entries.iter().filter(|e| !e.is_dir) {
if !pkg.reachable.contains(&e.name.to_ascii_lowercase()) && content_type_role(pkg.content_types.of(&e.name)).is_some() {
acc.note(format!("story reachability for {} is unknown; story-scoped checks were not performed for this part", e.name));
acc.set_incomplete();
}
}
}
/// Classify a part role from its declared content type.
fn content_type_role(ct: Option<&str>) -> Option<scan::PartRole> {
let role = match ct? {
@@ -3975,7 +4001,7 @@ fn report_dups_values(acc: &mut Acc, values: &[DecimalId], part: &str, what: &st
fn check_commentex(pkg: &Package, xml: &XmlScan, acc: &mut Acc) {
observation_contract! {
rules: "COMMENTEX-LINK";
collections: "access.into_complete_set*3,access.missing*4,access.prefix*1,field.comment_para_ids*2,field.entries*4,type.HashSet*3,type.Observed*3";
collections: "access.into_complete_set*3,access.missing*4,access.prefix*1,field.comment_para_ids*2,field.content_types*1,field.entries*4,type.HashSet*3,type.Observed*3";
scope: "each established owner and its selected supporting sources; shared parts in every owner; unowned references excluded; explicit no-root fallback only";
loss: "source unavailable or malformed; XML event/depth budget; category allocation cap; unknown or ambiguous source discovery; source-local pooled-budget loss";
fallback: "suppress only dependent absence directions and report Incomplete; independent owner and prefix findings survive";
@@ -4020,11 +4046,17 @@ fn check_commentex(pkg: &Package, xml: &XmlScan, acc: &mut Acc) {
&& if selected {
contributes(&e.name)
} else {
roles.get(&e.name.to_ascii_lowercase()).is_some_and(|r| r.is_comments())
&& (contributes(&e.name) || unresolved_fallback_contributor(owner_map, i, &e.name))
// A comments part without a story role is unreachable: its paragraphs were never read,
// so it cannot supply or rule out a paragraph.
(match roles.get(&e.name.to_ascii_lowercase()) {
Some(role) => role.is_comments(),
None => content_type_role(pkg.content_types.of(&e.name)).is_some_and(|r| r.is_comments()),
}) && (contributes(&e.name) || unresolved_fallback_contributor(owner_map, i, &e.name))
}
}) {
let entry_role = roles.get(&entry.name.to_ascii_lowercase()).copied();
if (!selected && unresolved_fallback_contributor(owner_map, i, &entry.name))
|| (!selected && entry_role.is_none())
|| !xml.category_complete(&entry.name, |f| &f.comment_para_ids)
{
comments_complete = false;
@@ -8467,7 +8499,7 @@ mod budget_tests {
("[Content_Types].xml", ct.into_bytes()),
("_rels/.rels", package_rels()),
("word/document.xml", doc),
("word/_rels/document.xml.rels", br#"<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rsettings" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings3.xml"/></Relationships>"#.to_vec()),
("word/_rels/document.xml.rels", br#"<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rsettings1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/><Relationship Id="rsettings2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings2.xml"/><Relationship Id="rsettings3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings3.xml"/></Relationships>"#.to_vec()),
("word/settings.xml", listing(1, 2)),
("word/settings2.xml", listing(3, 4)),
("word/settings3.xml", listing(5, 6)),
@@ -9209,7 +9241,7 @@ mod budget_tests {
("[Content_Types].xml", content_types_with_override("word/comments.xml", package::COMMENTS_CONTENT_TYPE)),
("_rels/.rels", package_rels()),
("word/document.xml", document()),
("word/_rels/document.xml.rels", doc_rels()),
("word/_rels/document.xml.rels", rels(&format!(r#"<Relationship Id="rC" Type="{NS_R}/comments" Target="comments.xml"/>"#))),
("word/comments.xml", comments),
]);
let report = validate_bytes_limited(&zip, Limits { notes: 1, ..Limits::default() });
@@ -9250,7 +9282,12 @@ mod budget_tests {
),
("_rels/.rels", package_rels()),
("word/document.xml", document()),
("word/_rels/document.xml.rels", doc_rels()),
(
"word/_rels/document.xml.rels",
rels(&format!(
r#"<Relationship Id="rA" Type="{NS_R}/comments" Target="commentsA.xml"/><Relationship Id="rB" Type="{NS_R}/comments" Target="commentsB.xml"/>"#
)),
),
("word/commentsA.xml", comments_a),
("word/commentsB.xml", comments_b),
]);
@@ -9797,7 +9834,9 @@ mod round5_completeness_tests {
} else {
&[1, 2, 4, 3]
};
let gloss_rels = rel("comments", "comments.xml") + &rel("commentsExtended", "gloss-ext.xml");
// gloss-comments.xml is reached through a generic relationship, so it is reachable and keeps
// its content-type role without becoming the glossary's selected comments target.
let gloss_rels = rel("comments", "comments.xml") + &rel("commentsExtended", "gloss-ext.xml") + &rel("aFChunk", "gloss-comments.xml");
package(
vec![
(
+11 -5
View File
@@ -757,6 +757,8 @@ struct State {
wrapper_depth: i64,
fld_depth: i64,
fld_extra_end: usize,
/// A noncanonical spelling makes field balance unreliable for this story (#8850).
fld_noncanonical: bool,
fld_state_unknown: bool,
move_from_start: BTreeSet<DecimalId>,
move_from_end: BTreeSet<DecimalId>,
@@ -3058,7 +3060,10 @@ fn record_structure(state: &mut State, id: &ElemId, attrs: &[Attribute], res: &N
state.fld_depth -= 1;
}
}
_ => {}
"separate" => {}
// Word accepts noncanonical spellings without requiring a balanced field.
// Do not guess aliases or let the remaining canonical markers cause a Fail.
_ => state.fld_noncanonical = true,
}
}
}
@@ -3352,7 +3357,8 @@ fn completed_pairs<K: Eq + std::hash::Hash>(values: &BTreeSet<K>) -> Option<Comp
/// not. The rules in this class are:
///
/// - `FLD-UNBALANCED` for a `w:fldChar` `end` seen at field depth 0 — field nesting is ordered, so
/// the prefix already proves the end is unbalanced whatever follows.
/// the prefix proves the end is unbalanced unless a noncanonical field spelling makes the
/// story's field balance unreliable.
/// - `STRUCT-MOVE-UNPAIRED` for a duplicate move range-start id — once an id has appeared twice in
/// the prefix, the duplicate exists regardless of the rest.
/// - `PARAID-DUP` for a repeated `w14:paraId` value in the part — same reasoning.
@@ -3378,7 +3384,7 @@ fn finish_prefix(state: &State, part: &str, acc: &mut Acc) {
);
}
}
if state.fld_extra_end > 0 {
if state.fld_extra_end > 0 && !state.fld_noncanonical {
acc.add("FLD-UNBALANCED", Some(part.to_string()), format!("{part} has {} w:fldChar end(s) with no open begin", state.fld_extra_end));
}
}
@@ -3422,7 +3428,7 @@ fn finish_completion(state: &State, part: &str, acc: &mut Acc) {
if open(FAMILY_COMMENT) {
report_comment_ranges(acc, part, &state.comment_range_start_ids, &state.comment_range_end_ids, &comment_starts, &comment_ends);
}
if state.fld_depth > 0 && open(FAMILY_FIELD) {
if state.fld_depth > 0 && !state.fld_noncanonical && open(FAMILY_FIELD) {
acc.add("FLD-UNBALANCED", Some(part.to_string()), format!("{part} has {} unclosed w:fldChar begin(s)", state.fld_depth));
}
}
@@ -3440,7 +3446,7 @@ fn completion_dependent_pending(state: &State) -> bool {
package_loss: "independent";
}
state.fld_depth > 0
(state.fld_depth > 0 && !state.fld_noncanonical)
|| state.move_from_start != state.move_from_end
|| state.move_to_start != state.move_to_end
|| state.move_from_names != state.move_to_names
+41
View File
@@ -226,6 +226,47 @@ impl Doc {
}
}
/// Relate `target` (relative to `word/`, or package-absolute with a leading `/`) to the main
/// document with a relationship of `kind`, so the part is reachable from the package root.
pub fn link_main(&mut self, kind: &str, target: &str) {
let rels = String::from_utf8(self.get("word/_rels/document.xml.rels").to_vec()).expect("utf-8");
let id: String = target.chars().map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }).collect();
let insert = format!(
r#"<Relationship Id="rLink_{id}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/{kind}" Target="{target}"/>"#
);
let rels = rels.replace("</Relationships>", &format!("{insert}</Relationships>"));
self.set("word/_rels/document.xml.rels", rels);
}
/// Relate `target` (package-absolute with a leading `/`, or relative to the package root) to the
/// package root with a relationship of `kind`.
pub fn link_package(&mut self, kind: &str, target: &str) {
let rels = String::from_utf8(self.get("_rels/.rels").to_vec()).expect("utf-8");
let id: String = target.chars().map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }).collect();
let insert = format!(
r#"<Relationship Id="rPkg_{id}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/{kind}" Target="{target}"/>"#
);
self.set("_rels/.rels", rels.replace("</Relationships>", &format!("{insert}</Relationships>")));
}
/// Add a part with its content type override and relate it to the main document by the
/// relationship kind that names its story role, so the part is reachable and keeps that role.
pub fn add_linked(&mut self, name: &str, content_type: &str, bytes: impl Into<Vec<u8>>) {
self.add_with_override(name, content_type, bytes);
let kind = match content_type {
CT_COMMENTS => "comments",
CT_FOOTNOTES => "footnotes",
CT_ENDNOTES => "endnotes",
CT_HEADER => "header",
CT_FOOTER => "footer",
CT_GLOSSARY => "glossaryDocument",
CT_SETTINGS => "settings",
other => panic!("no story relationship kind for {other}"),
};
let target = name.strip_prefix("word/").map_or_else(|| format!("/{name}"), str::to_string);
self.link_main(kind, &target);
}
/// The raw bytes of a part (panics when absent).
pub fn get(&self, name: &str) -> &[u8] {
&self.entries.iter().find(|(n, _)| n == name).expect("part exists").1
+38
View File
@@ -155,3 +155,41 @@ fn round9_comments_role_boundary() {
}
}
}
/// Story classification requires a path from the package, including indirect paths.
#[test]
fn story_roles_require_package_reachability() {
for mode in ["direct", "transitive", "untyped", "orphan", "orphan_source", "unknown"] {
let mut d = Doc::minimal();
let payload = format!(r#"<w:hdr {NS} xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"><m:oMath/></w:hdr>"#);
if mode == "untyped" {
d.set("word/payload.xml", payload);
} else {
d.add_with_override("word/payload.xml", CT_HEADER, payload);
}
match mode {
"direct" => d.set_doc_rels(&rel("header", "payload.xml")),
"transitive" | "orphan_source" => {
d.set("word/bridge.xml", "<bridge/>");
d.set("word/_rels/bridge.xml.rels", rels_xml(&rel("header", "payload.xml")));
if mode == "transitive" {
d.set_doc_rels(&rel("customXml", "bridge.xml"));
}
}
"unknown" => {
d.set("word/_rels/document.xml.rels", br#"<?xml version="1.0" encoding="unsupported-test-encoding"?><Relationships/>"#.to_vec())
}
_ => {}
}
let report = validate_bytes(&d.build());
if matches!(mode, "direct" | "transitive") {
assert!(findings(&report, "MATH-PLACEMENT") > 0, "{mode}: {report:?}");
} else {
assert_eq!(findings(&report, "MATH-PLACEMENT"), 0, "{mode}: unreferenced content must not supply story findings: {report:?}");
}
if mode == "unknown" {
assert_eq!(report.verdict, Verdict::Incomplete, "{report:?}");
assert!(report.coverage_notes.iter().any(|note| note.contains("story") && note.contains("reachability")), "{report:?}");
}
}
}
@@ -80,6 +80,7 @@ fn corrupt_glossary_document_notes_are_not_laundered_by_vacuous_main_both_orders
// The main owner is vacuous, including its source-local relationship scope.
d.remove("word/_rels/document.xml.rels");
glossary(&mut d, NOTE);
d.link_package("glossaryDocument", GLOSSARY);
if with_notes {
notes(&mut d, "word/glossary", 1);
d.set("word/glossary/_rels/document.xml.rels", rels_xml(&edge("fn", "footnotes", "footnotes.xml")));
+53 -23
View File
@@ -1687,11 +1687,7 @@ fn renamed_comments_part_is_found() {
#[test]
fn id_comment_dup() {
let mut d = Doc::minimal();
d.add_with_override(
"word/comments.xml",
CT_COMMENTS,
comments(r#"<w:comment w:id="1"><w:p/></w:comment><w:comment w:id="1"><w:p/></w:comment>"#),
);
d.add_linked("word/comments.xml", CT_COMMENTS, comments(r#"<w:comment w:id="1"><w:p/></w:comment><w:comment w:id="1"><w:p/></w:comment>"#));
let report = validate(&d);
assert_eq!(report.verdict, Verdict::Fail);
let f = assert_finding(&report, "ID-COMMENT-DUP", Some("word/comments.xml"));
@@ -1701,7 +1697,7 @@ fn id_comment_dup() {
#[test]
fn id_comment_ref() {
let mut d = Doc::minimal();
d.add_with_override("word/comments.xml", CT_COMMENTS, comments(r#"<w:comment w:id="1"><w:p/></w:comment>"#));
d.add_linked("word/comments.xml", CT_COMMENTS, comments(r#"<w:comment w:id="1"><w:p/></w:comment>"#));
d.set_document(r#"<w:p><w:r><w:commentReference w:id="5"/></w:r></w:p>"#);
let report = validate(&d);
assert_eq!(report.verdict, Verdict::Fail);
@@ -1745,11 +1741,7 @@ fn a_bookmark_start_end_pair_is_not_a_duplicate() {
#[test]
fn bookmark_unpaired_in_comments() {
let mut d = Doc::minimal();
d.add_with_override(
"word/comments.xml",
CT_COMMENTS,
comments(r#"<w:comment w:id="1"><w:p><w:bookmarkStart w:id="7" w:name="bm"/></w:p></w:comment>"#),
);
d.add_linked("word/comments.xml", CT_COMMENTS, comments(r#"<w:comment w:id="1"><w:p><w:bookmarkStart w:id="7" w:name="bm"/></w:p></w:comment>"#));
let report = validate(&d);
assert_eq!(report.verdict, Verdict::Pass);
let f = assert_finding(&report, "BOOKMARK-UNPAIRED", Some("word/comments.xml"));
@@ -1781,7 +1773,7 @@ fn id_revision_dup_is_a_warning() {
#[test]
fn note_dup() {
let mut d = Doc::minimal();
d.add_with_override(
d.add_linked(
"word/footnotes.xml",
CT_FOOTNOTES,
format!(
@@ -1797,7 +1789,7 @@ fn note_dup() {
#[test]
fn note_dup_endnotes() {
let mut d = Doc::minimal();
d.add_with_override(
d.add_linked(
"word/endnotes.xml",
CT_ENDNOTES,
format!(
@@ -2092,6 +2084,31 @@ fn fld_unbalanced() {
assert_finding(&report, "FLD-UNBALANCED", Some("word/document.xml"));
}
// Original in-memory fixtures derived from the spelling observations in #8850.
#[test]
fn fld_word_accepted_spellings() {
let forms = ["begin", "separate", "end", "Begin", "END", "start", "sep", "close", "", " begin "];
let mut failures = Vec::new();
for form in forms {
let sequences = match form {
"begin" => vec![vec![form, "end"]],
"end" => vec![vec!["begin", form]],
"separate" => vec![vec!["begin", form, "end"]],
_ => vec![vec![form, "end"], vec!["begin", form], vec!["begin", form, "end"]],
};
for sequence in sequences {
let mut d = Doc::minimal();
let chars: String = sequence.iter().map(|value| format!(r#"<w:fldChar w:fldCharType="{value}"/>"#)).collect();
d.set_document(&format!("<w:p><w:r>{chars}</w:r></w:p>"));
let report = validate(&d);
if report.verdict != Verdict::Pass {
failures.push(format!("{sequence:?}: {report:?}"));
}
}
}
assert!(failures.is_empty(), "Word-accepted field spellings falsely fail: {failures:#?}");
}
#[test]
fn struct_tc_no_p() {
let mut d = Doc::minimal();
@@ -2376,6 +2393,7 @@ fn math_placement_header_root_direct_child() {
let mut d = Doc::minimal();
d.set("[Content_Types].xml", content_types_xml(&[], &[("/word/header1.xml", CT_HEADER)]));
d.set("word/header1.xml", format!("<w:hdr xmlns:w=\"{W_NS}\" xmlns:m=\"{M_NS}\"><m:oMath/></w:hdr>").into_bytes());
d.link_main("header", "header1.xml");
let report = validate(&d);
assert_finding(&report, "MATH-PLACEMENT", Some("word/header1.xml"));
assert_eq!(math_findings(&report), 2, "{:?}", report.findings);
@@ -2524,6 +2542,7 @@ fn comment_range_count_sums_across_stories() {
}
hdr.push_str("</w:p></w:hdr>");
d.set("word/header1.xml", hdr.into_bytes());
d.link_main("header", "header1.xml");
let report = validate(&d);
assert_finding(&report, "COMMENT-RANGE-COUNT", None);
assert_eq!(range_count_findings(&report), 1, "{:?}", report.findings);
@@ -2610,6 +2629,7 @@ fn comment_range_unpaired_in_glossary_fires() {
.as_bytes()
.to_vec(),
);
d.link_main("glossaryDocument", "glossary.xml");
let report = validate(&d);
assert_finding(&report, "COMMENT-RANGE-UNPAIRED", Some("word/glossary.xml"));
}
@@ -2681,6 +2701,7 @@ fn comment_range_pairing_is_per_part() {
.as_bytes()
.to_vec(),
);
d.link_main("glossaryDocument", "glossary.xml");
let report = validate(&d);
assert_eq!(report.findings.iter().filter(|f| f.rule == "COMMENT-RANGE-UNPAIRED").count(), 2, "{:?}", report.findings);
assert_finding(&report, "COMMENT-RANGE-UNPAIRED", Some("word/document.xml"));
@@ -3175,7 +3196,7 @@ fn note_pr_unknown_when_settings_unreadable() {
/// Settings carrying the given inner XML.
fn settings_doc(inner: &str) -> Doc {
let mut d = Doc::minimal();
d.add_with_override(
d.add_linked(
"word/settings.xml",
CT_SETTINGS,
format!("<?xml version=\"1.0\"?><w:settings xmlns:w=\"{W_NS}\" xmlns:r=\"{R_NS}\">{inner}</w:settings>"),
@@ -3210,7 +3231,7 @@ fn counted_doc(body: &str, compat: bool) -> Doc {
let mut d = Doc::minimal();
d.set_document(body);
if compat {
d.add_with_override(
d.add_linked(
"word/settings.xml",
CT_SETTINGS,
format!("<?xml version=\"1.0\"?><w:settings xmlns:w=\"{W_NS}\"><w:uiCompat97to2003/></w:settings>"),
@@ -3224,7 +3245,7 @@ fn counted_doc(body: &str, compat: bool) -> Doc {
fn counted_doc_val(body: &str, val: &str) -> Doc {
let mut d = Doc::minimal();
d.set_document(body);
d.add_with_override(
d.add_linked(
"word/settings.xml",
CT_SETTINGS,
format!("<?xml version=\"1.0\"?><w:settings xmlns:w=\"{W_NS}\"><w:uiCompat97to2003 w:val=\"{val}\"/></w:settings>"),
@@ -3326,10 +3347,13 @@ fn compat_flag_explicit_val() {
#[test]
fn compat_flag_in_malformed_settings_is_unknown() {
let mut d = counted_doc(&bookmark_body(16_381), false);
d.add_with_override("word/settings.xml", CT_SETTINGS, format!("<w:settings xmlns:w=\"{W_NS}\"><w:uiCompat97to2003/></w:wrong>"));
d.add_linked("word/settings.xml", CT_SETTINGS, format!("<w:settings xmlns:w=\"{W_NS}\"><w:uiCompat97to2003/></w:wrong>"));
let report = validate(&d);
assert_eq!(report.verdict, Verdict::Incomplete, "findings: {:?}", report.findings);
// The reachable malformed settings part is an Error, which outranks the Incomplete verdict.
assert_eq!(report.verdict, Verdict::Fail, "findings: {:?}", report.findings);
assert_finding(&report, "XML-MALFORMED", Some("word/settings.xml"));
assert!(!has(&report, "BOOKMARK-COUNT"), "{:?}", report.findings);
assert!(report.coverage_notes.iter().any(|n| n.contains("compatibility limits")), "{:?}", report.coverage_notes);
}
/// But a second, readable settings part carrying the flag establishes On
@@ -3337,8 +3361,8 @@ fn compat_flag_in_malformed_settings_is_unknown() {
#[test]
fn compat_flag_readable_part_wins() {
let mut d = counted_doc(&bookmark_body(16_381), false);
d.add_with_override("word/settings.xml", CT_SETTINGS, format!("<w:settings xmlns:w=\"{W_NS}\"><w:uiCompat97to2003/></w:wrong>"));
d.add_with_override(
d.add_linked("word/settings.xml", CT_SETTINGS, format!("<w:settings xmlns:w=\"{W_NS}\"><w:uiCompat97to2003/></w:wrong>"));
d.add_linked(
"word/settings2.xml",
CT_SETTINGS,
format!("<?xml version=\"1.0\"?><w:settings xmlns:w=\"{W_NS}\"><w:uiCompat97to2003/></w:settings>"),
@@ -3358,6 +3382,7 @@ fn bookmark_count_sums_across_stories() {
hdr.push_str(&bookmark_body(6_381));
hdr.push_str("</w:hdr>");
d.set("word/header1.xml", hdr.into_bytes());
d.link_main("header", "header1.xml");
let report = validate(&d);
assert_finding(&report, "BOOKMARK-COUNT", None);
}
@@ -3368,13 +3393,15 @@ fn bookmark_count_sums_across_stories() {
#[test]
fn compat_counts_unknown_settings_incomplete() {
let mut d = counted_doc(&bookmark_body(16_381), false);
d.add_with_override(
d.add_linked(
"word/settings.xml",
CT_SETTINGS,
"<w:settings xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:compat>".to_string(),
);
let report = validate(&d);
assert_eq!(report.verdict, Verdict::Incomplete, "findings: {:?}", report.findings);
// The reachable malformed settings part is an Error, which outranks the Incomplete verdict.
assert_eq!(report.verdict, Verdict::Fail, "findings: {:?}", report.findings);
assert_finding(&report, "XML-MALFORMED", Some("word/settings.xml"));
assert!(!has(&report, "BOOKMARK-COUNT"), "{:?}", report.findings);
assert!(report.coverage_notes.iter().any(|n| n.contains("compatibility limits")), "{:?}", report.coverage_notes);
}
@@ -3418,7 +3445,7 @@ fn protection_password_missing_spin_count() {
#[test]
fn protection_password_duplicate_attribute() {
let mut d = Doc::minimal();
d.add_with_override(
d.add_linked(
"word/settings.xml",
CT_SETTINGS,
format!("<?xml version=\"1.0\"?><w:settings xmlns:w=\"{W_NS}\" xmlns:w2=\"{W_NS}\"><w:documentProtection w:algorithmName=\"SHA-512\" w2:algorithmName=\"SHA-256\" w:hashValue=\"aGFzaA==\" w:spinCount=\"100000\"/></w:settings>"),
@@ -3510,6 +3537,7 @@ fn math_placement_header_story_part() {
let mut d = Doc::minimal();
d.set("[Content_Types].xml", content_types_xml(&[], &[("/word/header1.xml", CT_HEADER)]));
d.set("word/header1.xml", format!("<w:hdr xmlns:w=\"{W_NS}\" xmlns:m=\"{M_NS}\"><w:p><m:f/></w:p></w:hdr>").into_bytes());
d.link_main("header", "header1.xml");
let report = validate(&d);
assert_finding(&report, "MATH-PLACEMENT", Some("word/header1.xml"));
}
@@ -5684,6 +5712,8 @@ fn round2_malformed_story_relationships() {
CT_COMMENTS,
format!(r#"<w:comments xmlns:w="{W_NS}"><w:comment w:id="1"><w:p/></w:comment><w:comment w:id="1"><w:p/></w:comment></w:comments>"#),
);
// The malformed main relationships cannot reach the comments part, so the package root does.
d.link_package("comments", "word/comments.xml");
let report = validate_bytes(&d.build());
assert_eq!(report.verdict, Verdict::Fail, "{report:?}");
assert_finding(&report, "ID-COMMENT-DUP", Some("word/comments.xml"));
@@ -175,6 +175,9 @@ fn unowned_header(reached: bool) -> Doc {
d.add_with_override("word/orphan.xml", CT_HEADER, format!(r#"<w:hdr {NS}><w:p><w:pPr><w:pStyle w:val="absent"/><w:numPr><w:numId w:val="9"/></w:numPr></w:pPr><w:r><w:footnoteReference w:id="9"/><w:commentReference w:id="9"/></w:r></w:p></w:hdr>"#));
if reached {
d.set_doc_rels(&rel("header", "orphan.xml"));
} else {
// Reachable from the package root, yet in no document owner's scope.
d.link_package("header", "word/orphan.xml");
}
d
}
+5 -3
View File
@@ -120,6 +120,7 @@ let apps move windows, so there Arrange All and Side by Side only resize.
| `ui.clipboard` | `text?`, `html?`, `rtf?`, `png?` (base64) | puts those flavours on the clipboard; the reply's `offered` lists them |
| `ui.replayAt` | `at` (0–1) | holds Ink Replay at that fraction of its length, while Ink Replay is on |
| `app.quit` | `force?` | quits (see [Closing the document](#closing-the-document)) |
| `ui.quit` | `force?` | quits through `engine.execute` or as a control method, with the same unsaved-work guard as `app.quit` (see [Closing the document](#closing-the-document)) |
Pointer positions default to window points (`coordinates: "screen"`), with `x` and `y` each
defaulting to `0` — so without `control` (or `id` / `label` on `ui.click`), omitting `x` and `y` on
@@ -253,9 +254,10 @@ a file, a save the browser's picker hasn't finished, or a comment still being ty
`force`. The refusal and the Save Changes prompt ask about the same work, so they cannot
disagree (#3274).
`app.quit` closes every open document, so it is refused while any of them has unsaved changes:
the app keeps running and the work stays. Save first, or pass `{"force": true}` to discard the
changes and quit. Only a boolean `true` counts as `force`.
`app.quit` (and `ui.quit` through `engine.execute` or as a control method) closes every open
document, so it is refused while any of them has unsaved changes: the app keeps running and the
work stays. Save first, or pass `{"force": true}` to discard the changes and quit. Only a
boolean `true` counts as `force`.
### Native printing
+1
View File
@@ -234,6 +234,7 @@ Page Setup's margin, paper-size and document-grid number boxes scroll long text
| 2026-10-30 | trivial | the Paste button is named "Paste" for screen readers, without macOS's key on other platforms; the status bar's Go To hint shows the platform's key |
| 2026-11-17 | trivial | A floating table placed by an offset takes `w:tblInd` before Word 2013 (its first cell's text at the offset moved by the indent) and, from Word 2013, stands half its left border in from the offset with `w:tblInd` ignored, as measured in Word for Windows; no ranked gap changed |
| 2026-11-17 | trivial | Right-to-left tables (`w:bidiVisual`): a cell's `w:left` and `w:right` margins (or `w:start` and `w:end`, the cell's or the table's) stay on the sides they name, as measured in Word for Windows; only the left and right borders are drawn mirrored; no ranked gap changed |
| 2026-12-04 | trivial | A floating right-to-left table (`w:bidiVisual`) placed by an offset has its left edge at the offset in every mode, as measured in Word for Windows: before Word 2013 it moves out by neither its first cell's left margin nor `w:tblInd`, and from it not in by half its left border (#8517). An inline one still moves out by that margin before Word 2013, as in Word. Fitting a column of a table nested in a right-to-left cell stops at that cell's right margin (#8441) |
| 2026-10-30 | trivial | #5: a list item deleted whole under Track Changes shows its number as deleted text, in the deletion's colour and mark, and hides it where deletions are hidden (#4828); estimate unchanged |
| 2026-11-03 | trivial | A picture inserted or pasted in a table cell fits the cell (a nested cell too), in text columns the column, in another section that section, instead of the first section's text width (#5428); a fix, so no ranked gap changed; readiness estimates unchanged |
| 2026-10-26 | trivial | Dialog sections improve readability across 13 dialogs; conditional scrolling keeps tall dialogs usable. Ranked gaps and estimates unchanged (#4035, #4038) |
+3 -2
View File
@@ -1,6 +1,6 @@
# Hardware parity with Microsoft Word
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-11-09 · **Change:** trivial (touchpad and mouse-wheel scroll speed preferences, Slow / Normal / Fast, #6146); previously trivial (newly opened window dimensions are constrained to fit available screen dimensions, #5871); previously trivial (print helpers erase loaded plaintext inputs before driver work, #5710); previously trivial (Windows print submissions use isolated helpers so a cancelled driver cannot block a retry, #5710); previously trivial (print cancellation remains available without a document; sending-boundary limitation clarified, #5710); previously trivial (a print job waiting on its driver can be cancelled, and quitting doesn't wait for it, #5710); previously trivial (the printer list no longer waits on printer drivers, #5710); previously trivial (Linux Read Aloud: a sentence a screen reader cuts off is said again); previously trivial (ink page lookup work, #3614); previously trivial (only the PDF sent to the printer has no link annotations; Save these pages as PDF keeps them, #4734); previously trivial (a document with links prints: the print job's PDF has no link annotations, #4734; previously trivial: Pen / stylus row: two-stroke and closed-head arrows; previously trivial: Pen / stylus row: ink, eraser and Ink to Shape incl. arrows landed; previously trivial: a window too big for its screen shrinks to fit when it opens, #1215; previously trivial: 32-bit Windows starts on OpenGL; previously major: first version) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 and Word for Windows
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-12-04 · **Change:** trivial (Windows: a document window maximizes and goes full screen again, #8838); previously trivial (touchpad and mouse-wheel scroll speed preferences, Slow / Normal / Fast, #6146); previously trivial (newly opened window dimensions are constrained to fit available screen dimensions, #5871); previously trivial (print helpers erase loaded plaintext inputs before driver work, #5710); previously trivial (Windows print submissions use isolated helpers so a cancelled driver cannot block a retry, #5710); previously trivial (print cancellation remains available without a document; sending-boundary limitation clarified, #5710); previously trivial (a print job waiting on its driver can be cancelled, and quitting doesn't wait for it, #5710); previously trivial (the printer list no longer waits on printer drivers, #5710); previously trivial (Linux Read Aloud: a sentence a screen reader cuts off is said again); previously trivial (ink page lookup work, #3614); previously trivial (only the PDF sent to the printer has no link annotations; Save these pages as PDF keeps them, #4734); previously trivial (a document with links prints: the print job's PDF has no link annotations, #4734; previously trivial: Pen / stylus row: two-stroke and closed-head arrows; previously trivial: Pen / stylus row: ink, eraser and Ink to Shape incl. arrows landed; previously trivial: a window too big for its screen shrinks to fit when it opens, #1215; previously trivial: 32-bit Windows starts on OpenGL; previously major: first version) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 and Word for Windows
> **Printing update:** 2026-10-12 · direct desktop printing through craft-print; details below.
@@ -15,7 +15,7 @@ pens, microphones (Dictate) and speakers (Read Aloud), and displays.
| Printers: native print dialog, printer choice, copies, duplex, page ranges, tray, scaling | ✅ (`WordPDE.plugin` print-dialog extension on Mac) | 🟡 Direct CUPS printing; printer, copies, collation, duplex, ranges, grayscale, scale to paper size, N-up and booklets; on every desktop the PDF sent to the printer leaves out link annotations, which the spooler can't fit to the paper; Save these pages as PDF keeps them (#4734) | 🟡 Direct spooler printing; printer, copies, collation, duplex, ranges, grayscale, scale to paper size, N-up and booklets; on every desktop the PDF sent to the printer leaves out link annotations, which the spooler can't fit to the paper; Save these pages as PDF keeps them (#4734) | 🟡 Direct spooler printing; printer, copies, collation, duplex, ranges, grayscale, scale to paper size, N-up and booklets; on every desktop the PDF sent to the printer leaves out link annotations, which the spooler can't fit to the paper; Save these pages as PDF keeps them (#4734) | ✅ browser print dialog (#209) | 35% | 5–8 |
| GPU rendering, HiDPI/Retina, pixel-aligned text | ✅ | ✅ wgpu + vello_cpu rasteriser, whole-pixel text (#110, #165) | ✅ DirectX 12 default (#50), OpenGL when DirectX 12 has no GPU driver (#316) or on 32-bit; startup crash on Intel UHD (#170) | ✅ (soft text on KDE at some zooms, #140) | ✅ | 80% | 3–5 (bugs) |
| Pen / stylus: ink, pressure, eraser, ink to shape/math | ✅ (Draw tab, `InkRender.bundle`) | 🟡 ink, stroke eraser, Ink to Shape incl. one- and two-stroke arrows with open or closed heads (#307, #395); pressure and Ink to Math missing | 🟡 same | 🟡 same | 🟡 same | 50% | (Draw tab, 15–25) |
| Multiple monitors, per-monitor DPI, remembered window position, a window that fits its screen | ✅ | ✅ (#38, #76, #1215) | ✅ (winit DPI fix pending, #155) | ✅ | — | 85% | 1 |
| Multiple monitors, per-monitor DPI, remembered window position, a window that fits its screen, maximize and full screen | ✅ | ✅ (#38, #76, #1215, #8838) | ✅ (winit DPI fix pending, #155) | ✅ | — | 85% | 1 |
| Microphone: Dictate | ✅ (cloud speech service) | ❌ | ❌ | ❌ | ❌ | 0% | 8–15 + owner (speech model choice) |
| Speakers: Read Aloud | ✅ | ✅ system speech, speed, sentence skip (#190) | ✅ | 🟡 espeak-ng, then espeak, then Speech Dispatcher (over its socket), each sentence in its language's voice; packages recommend a speech program; silent in the Flatpak (no audio access, no speech program) | 🟡 | 75% | 1–2 |
| Touch screens and touchpads: pinch zoom, inertial scroll | ✅ | ✅ pinch (#179) | ✅ | ✅ inertial scroll (#252), touchpad and wheel scroll speed settings (#6146) | ✅ | 85% | 0–1 |
@@ -28,6 +28,7 @@ File > Print offers 2, 4, 6, 9 or 16 logical pages per physical sheet side and l
| Date | Change | Summary |
|---|---|---|
| 2026-12-04 | trivial | Windows: a document window maximizes (button, Win+Up, snap to the top) and goes full screen again (#8838, #8861); since v0.20.0 the window was sent back to its normal place after the system maximized it. Fixed in craft-libs#5339, repinned. |
| 2026-11-09 | trivial | Touchpad and mouse-wheel scroll speed preferences (Slow, Normal, Fast): scales Wayland touchpad point input by default (4×) so swiping matches desktop speed, and scales mouse wheel line distance; File › Options › Advanced › Scrolling (#6146) |
| 2026-11-07 | trivial | Newly opened secondary windows constrain their initial viewport dimensions to the monitor's usable area, preventing windows from exceeding screen width on scaled displays (#5871) |
| 2026-11-06 | trivial | Print helpers remove loaded PDF/settings files before driver work, tolerate prior removal and report cleanup errors; a held-driver regression checks the files are already absent (#5710) |
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -12,7 +12,7 @@
| Windows | x64, x86 and arm64 `.msi` (one dual-scope package: per-user by default, needs no admin rights; "Everyone on this computer" installs per machine) + portable `.zip` | Azure Trusted Signing (`AZURE_*` secrets) |
| Linux | x86_64 and aarch64 `.AppImage` (+ `.zsync` for AppImageUpdate), `.flatpak` bundle, `.deb`, `.rpm`, `.tar.gz`; Flathub manifest | checksums |
| Linux riscv64 | `.tar.gz` (cross-compiled on `ubuntu-24.04`, glibc >= 2.39; CLI smoke-tested under QEMU) | checksums |
| FreeBSD | x86_64 `.tar.gz` | checksums |
| FreeBSD 15.1+ | x86_64 and aarch64 `.tar.gz` | checksums |
| Web | `wordcraft-web-<version>.zip` (static site: `index.html`, wasm, glue) | none |
3. The run drafts a GitHub Release `WordCraft v<version>` with `SHA256SUMS.txt`; review and publish it.
File diff suppressed because one or more lines are too long
+3 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -187,7 +187,7 @@ fn cmd_wasm() -> Result<(), String> {
}
run(t, &format!("cargo check --target wasm32-unknown-unknown --tests --keep-going -p {}", test_set.join(" -p ")))?;
}
println!("\nwasm32-unknown-unknown check: ok ({} crates, {} test targets: {})", set.len(), test_set.len(), set.join(", "));
println!("\nwasm32-unknown-unknown check: ok ({} crates, {} test crates: {})", set.len(), test_set.len(), test_set.join(", "));
Ok(())
}
+15
View File
@@ -0,0 +1,15 @@
use std::process::Command;
#[test]
fn wasm_summary_lists_only_crates_with_checked_test_targets() {
let output = Command::new(env!("CARGO_BIN_EXE_xtask")).arg("wasm").output().expect("run xtask wasm");
assert!(output.status.success(), "xtask wasm failed:\n{}", String::from_utf8_lossy(&output.stderr));
let stdout = String::from_utf8_lossy(&output.stdout);
let summary = stdout.lines().find(|line| line.starts_with("wasm32-unknown-unknown check: ok")).expect("wasm summary");
assert_eq!(
summary,
"wasm32-unknown-unknown check: ok (15 crates, 8 test crates: wordcraft-control-key, wordcraft-docbin, wordcraft-engine, wordcraft-geom, wordcraft-layout, wordcraft-mcp, wordcraft-pdf, wordcraft-render)"
);
}