diff --git a/.gitignore b/.gitignore index b77ecb8d99..d719a143a6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,10 @@ plan/ /target /dist -/corpus +/corpus/* +!/corpus/docx/ +/corpus/docx/* +!/corpus/docx/README.md /log .DS_Store /.claude/ diff --git a/Cargo.lock b/Cargo.lock index b5b615e493..2115bcdc67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -600,12 +600,6 @@ version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - [[package]] name = "block-buffer" version = "0.10.4" @@ -1137,19 +1131,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-graphics2" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b65858d95344d2711161cd92196732f67d6c5fea238cf12f994584828731a5c" -dependencies = [ - "bitflags 2.13.2", - "block", - "cfg-if", - "core-foundation 0.10.1", - "libc", -] - [[package]] name = "core_detect" version = "1.0.0" @@ -1192,7 +1173,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-automation", "craft-behavior", @@ -1233,18 +1214,19 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "block2 0.6.2", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "objc2-core-graphics", "objc2-foundation 0.3.2", ] [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "rustix 1.1.6", ] @@ -1252,7 +1234,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1277,7 +1259,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1295,7 +1277,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-docpath", @@ -1313,12 +1295,12 @@ dependencies = [ [[package]] name = "craft-cfb" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "egui", ] @@ -1326,7 +1308,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "md-5", "rayon", @@ -1335,12 +1317,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" [[package]] name = "craft-color" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "serde", ] @@ -1348,7 +1330,7 @@ dependencies = [ [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-cms", @@ -1368,7 +1350,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1379,7 +1361,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1389,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "rayon", ] @@ -1397,7 +1379,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1423,7 +1405,7 @@ dependencies = [ [[package]] name = "craft-doc-binary" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "chrono", "craft-cfb", @@ -1440,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "serde", ] @@ -1448,7 +1430,7 @@ dependencies = [ [[package]] name = "craft-docx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "base64 0.23.1", "chrono", @@ -1468,7 +1450,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1487,7 +1469,7 @@ dependencies = [ [[package]] name = "craft-drawingml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "chrono", "craft-xml", @@ -1499,7 +1481,7 @@ dependencies = [ [[package]] name = "craft-flow" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-wordmodel", "image", @@ -1509,7 +1491,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1524,7 +1506,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1543,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1552,7 +1534,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "cap-primitives", "craft-atomic", @@ -1575,7 +1557,7 @@ dependencies = [ [[package]] name = "craft-font-subset" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "brotli 9.1.3", "harfbuzz-subset-sys", @@ -1588,7 +1570,7 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-font-subset", ] @@ -1596,7 +1578,7 @@ dependencies = [ [[package]] name = "craft-gpu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "egui-wgpu", "log", @@ -1608,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1621,7 +1603,7 @@ dependencies = [ [[package]] name = "craft-html" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-codepage", "craft-flow", @@ -1634,8 +1616,10 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.1", "chrono", "fixed_decimal", "icu_calendar", @@ -1662,7 +1646,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-dds", "craft-jpeg", @@ -1689,7 +1673,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1707,7 +1691,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "thiserror 2.0.21", ] @@ -1715,7 +1699,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-host", "craft-i18n", @@ -1730,7 +1714,7 @@ dependencies = [ [[package]] name = "craft-latex" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-flow", "craft-math", @@ -1741,7 +1725,7 @@ dependencies = [ [[package]] name = "craft-markdown" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-flow", "craft-html", @@ -1751,7 +1735,7 @@ dependencies = [ [[package]] name = "craft-math" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-xml", "roxmltree", @@ -1761,7 +1745,7 @@ dependencies = [ [[package]] name = "craft-mcp-server" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "serde_json", ] @@ -1769,7 +1753,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -1787,7 +1771,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "brotli-decompressor 6.3.1", "chrono", @@ -1799,7 +1783,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "encoding_rs", "image", @@ -1810,7 +1794,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "chardetng", "chrono", @@ -1821,15 +1805,16 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24#1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ + "uds_windows", "winsafe", ] [[package]] name = "craft-odf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "aes", "base64 0.23.1", @@ -1855,7 +1840,7 @@ dependencies = [ [[package]] name = "craft-ods" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-odf", "craft-sheet", @@ -1866,7 +1851,7 @@ dependencies = [ [[package]] name = "craft-offcrypto" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "aes", "base64 0.23.1", @@ -1883,7 +1868,7 @@ dependencies = [ [[package]] name = "craft-opc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-xml", "craft-zip", @@ -1894,7 +1879,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-keymap", @@ -1910,7 +1895,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "krilla", "serde", @@ -1920,14 +1905,14 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "arboard", "async-channel", "async-io", "async-process", "clipboard-win", - "core-graphics2", + "craft-appkit", "craft-atomic", "craft-docpath", "craft-host", @@ -1938,6 +1923,8 @@ dependencies = [ "js-sys", "log", "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", "objc2-foundation 0.3.2", "rfd", "serde", @@ -1956,7 +1943,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -1980,7 +1967,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1991,7 +1978,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "dispatch2", "egui", @@ -2004,7 +1991,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -2023,7 +2010,7 @@ dependencies = [ [[package]] name = "craft-rtf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-codepage", "craft-flow", @@ -2036,7 +2023,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-atomic", "craft-host", @@ -2053,17 +2040,17 @@ dependencies = [ [[package]] name = "craft-sheet" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" [[package]] name = "craft-ssip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-xml", "flate2", @@ -2080,7 +2067,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-keymap", @@ -2092,7 +2079,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -2116,7 +2103,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2131,7 +2118,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-atomic", "craft-behavior", @@ -2146,7 +2133,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "serde", "thiserror 2.0.21", @@ -2156,7 +2143,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "serde", "thiserror 2.0.21", @@ -2165,7 +2152,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-keymap", @@ -2180,12 +2167,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2199,9 +2186,10 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", + "craft-font-catalog", "craft-i18n", "craft-keymap", "craft-theme", @@ -2215,7 +2203,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "accesskit", "craft-behavior", @@ -2253,7 +2241,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2264,7 +2252,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -2282,7 +2270,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2291,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -2324,7 +2312,7 @@ dependencies = [ [[package]] name = "craft-ui-test-kit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -2335,7 +2323,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-behavior", "craft-host", @@ -2354,7 +2342,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "base64 0.22.1", "chrono", @@ -2386,7 +2374,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "js-sys", "serde_json", @@ -2397,7 +2385,7 @@ dependencies = [ [[package]] name = "craft-web-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-host", "craft-platform", @@ -2409,7 +2397,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "winsafe", ] @@ -2417,7 +2405,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-appkit", "craft-atomic", @@ -2449,7 +2437,7 @@ dependencies = [ [[package]] name = "craft-wordmodel" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "base64 0.23.1", "craft-math", @@ -2463,7 +2451,7 @@ dependencies = [ [[package]] name = "craft-xls" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-cfb", "craft-sheet", @@ -2476,7 +2464,7 @@ dependencies = [ [[package]] name = "craft-xlsx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "craft-drawingml", "craft-opc", @@ -2488,7 +2476,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2498,7 +2486,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2854,7 +2842,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", "emath", @@ -2887,7 +2875,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -2922,7 +2910,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "accesskit", "ahash", @@ -2941,7 +2929,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -2960,7 +2948,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "accesskit_winit", "arboard", @@ -2986,7 +2974,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "egui", @@ -2999,7 +2987,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", "egui", @@ -3012,7 +3000,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "dify", "eframe", @@ -3038,7 +3026,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", ] @@ -3119,7 +3107,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -3145,7 +3133,11 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.1", +] [[package]] name = "equivalent" @@ -3874,7 +3866,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3883,7 +3875,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3901,7 +3893,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3919,12 +3911,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "flate2", "hayro-ccitt", @@ -4653,7 +4645,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4670,7 +4662,7 @@ dependencies = [ "skrifa 0.42.1", "smallvec", "subsetter", - "tiny-skia-path", + "tiny-skia-path 0.12.0", "xmp-writer", "yoke", "zune-jpeg", @@ -4792,7 +4784,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" dependencies = [ "arrayvec", "kurbo", @@ -6555,7 +6547,7 @@ dependencies = [ "pico-args", "rgb", "svgtypes", - "tiny-skia", + "tiny-skia 0.12.0", "usvg", ] @@ -6818,6 +6810,17 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sctk-adwaita" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" +dependencies = [ + "log", + "smithay-client-toolkit 0.19.2", + "tiny-skia 0.11.4", +] + [[package]] name = "security-framework" version = "3.7.0" @@ -7706,6 +7709,20 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path 0.11.4", +] + [[package]] name = "tiny-skia" version = "0.12.0" @@ -7718,7 +7735,18 @@ dependencies = [ "cfg-if", "log", "png 0.18.1", - "tiny-skia-path", + "tiny-skia-path 0.12.0", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", ] [[package]] @@ -8133,7 +8161,7 @@ dependencies = [ "siphasher", "strict-num", "svgtypes", - "tiny-skia-path", + "tiny-skia-path 0.12.0", ] [[package]] @@ -8963,7 +8991,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/storytold/winit.git?rev=a517b3846ee8457d84ee4975110bfda6797c44dc#a517b3846ee8457d84ee4975110bfda6797c44dc" +source = "git+https://github.com/storytold/winit.git?rev=0dfcec0eb62fda5904137a63a6dd0c3d83295f45#0dfcec0eb62fda5904137a63a6dd0c3d83295f45" dependencies = [ "ahash", "android-activity", @@ -8992,6 +9020,7 @@ dependencies = [ "raw-window-handle", "redox_syscall 0.4.1", "rustix 0.38.44", + "sctk-adwaita", "smithay-client-toolkit 0.19.2", "smol_str", "tracing", @@ -9649,6 +9678,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee" name = "xtask" version = "0.18.1" dependencies = [ + "serde", "serde_json", ] @@ -10021,19 +10051,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" [[patch.unused]] name = "hayro" version = "0.7.1" -source = "git+https://github.com/storytold/craft-libs?rev=7097741460d683b4ddf1ba78026e7759f2d5ee21#7097741460d683b4ddf1ba78026e7759f2d5ee21" +source = "git+https://github.com/storytold/craft-libs?rev=d73e274a01408ef433a291a667e6014937d72165#d73e274a01408ef433a291a667e6014937d72165" diff --git a/Cargo.toml b/Cargo.toml index 494b15daa2..538811307d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } +wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", 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 = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0", default-features = false } -craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0", default-features = false } +craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } # foundation kurbo = { version = "0.13", features = ["serde"] } @@ -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 = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0", default-features = false, features = ["write"] } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0", default-features = false, features = ["write"] } -craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0", features = ["doc"] } -craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0", features = ["text"] } -craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-html = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0", features = ["flow"] } -craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-math = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0", features = ["detect"] } -craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21", version = "=0.1.0" } +craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0", features = ["doc"] } +craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0", features = ["text"] } +craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-html = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0", features = ["flow"] } +craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-math = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0", features = ["detect"] } +craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", version = "=0.1.0" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165", 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,27 +174,27 @@ 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 = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -hayro = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "7097741460d683b4ddf1ba78026e7759f2d5ee21" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +hayro = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "d73e274a01408ef433a291a667e6014937d72165" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +emath = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } diff --git a/NOTICE b/NOTICE index a4d01fdc21..b246537bd5 100644 --- a/NOTICE +++ b/NOTICE @@ -188,3 +188,34 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Linux Wayland window decorations +------------------------------- +sctk-adwaita 0.10.1 (https://github.com/PolyMeilex/sctk-adwaita, +commit d5f343c45c04d4a026db57f76760819b7325db00) is used by winit on Linux +for vector window controls. Its title-font features are disabled: no Cantarell +font is embedded by this dependency and no font file is added to this repo. + +sctk-adwaita's MIT licence: + +MIT License + +Copyright (c) 2022 Bartłomiej Maryńczak + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ROADMAP.md b/ROADMAP.md index 7c81c4f08f..300fb991fa 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,7 +1,7 @@ # WordCraft roadmap > **Last reviewed:** 2026-10-31 · **Last updated:** 2026-11-21 · **Change:** trivial (table rows split across pages: a cell's first paragraph on the page can split even when only one line fits, if the row starts at the top, with or without its own headers, or continues from the previous page (#6823)); previously trivial (release wrap areas when strict column balancing moves the anchor line, #6821); previously trivial (balanced columns keep lines together from Word 2013's layout, #6821); previously trivial (progress log: TIFF picture chooser, drop and pasted-path routing, #6704); previously minor (added layout.fitOnePage and its Layout › Page Setup ribbon button to condense a multi-page document by one page while preserving typography hierarchy); previously minor (#3398: persistent screen paper colors; parity estimates unchanged); previously minor (#3693: additional Delete Previous Sentence command and shortcut; Word-parity estimates unchanged) -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-20 · **Change:** trivial (legacy header lines stay in place around narrow Square, Tight and Through logos, #6805); previously trivial (progress log: `wordcraft-cli mcp` needs both automation roots and refuses `--connect`, #7124); previously trivial (progress log: File › Print’s preview pages as the print job prints and marks tracked changes with Track Changes Options, #5232, #6267); previously trivial (formatting shortcuts say what they did to screen readers); previously trivial (dialogs are dialogs to screen readers, their tabs are tabs, and colour fields and swatches say their colour); previously 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); previously trivial (progress log: border boxes close their corners; previously trivial: progress log: file formats, codecs and protocols from craft-libs, #778); previously trivial (progress log: Get the Missing Fonts); previously trivial (progress log: a deleted list item's number is drawn as deleted text under Track Changes (#4828)); previously trivial (progress log: Save As and Export offer Browse in WordCraft… on Linux/BSD, #3535); previously trivial (progress log: Review › Language can set the whole document's proofing language, #3518); previously trivial (progress log: Auto interface size capped to the screen, #4030); previously trivial (progress log: DOCX section line numbering stays off without a positive `w:countBy`, #6209); previously trivial (progress log: Save As on Linux: the desktop portal's Save dialog reports the file type picked, updating the extension so saving as PDF writes a .pdf, #6180); previously trivial (Vertical scrollbar track: clicking above the elevator moves one screen up and clicking below it moves one screen down, as in Word (#5853)); previously trivial (progress log: #4501 refactor regressions restored: per-section header grid, ODT default font, link tooltip, #4683); previously trivial (progress log: the window moves by its title bar behind a modal dialog, #5124); previously trivial (progress log: `convert --strict` and `render --strict` refuse a silently incomplete PDF or PNG (#6005, #6008)); ; trivial (progress log: ODT columns stating only their shares); previously trivial (progress log: ODT font size for every script); previously trivial (progress log: ODT text turning off what its style turns on); previously trivial (progress log: edited ODT paragraphs keep custom styles with an outline level); previously trivial (progress log: ODT pictures keep the size their file gives); previously trivial (progress log: ODT frames keep the page they are anchored to); previously trivial (pointer zoom stretches page rasters until it stops); previously trivial (dark-theme interface text on Linux no longer looks semi-bold); previously trivial (Control/MCP #2596 review: partial-write outcomes, path-bearing image exports, accept-thread startup cleanup and malformed UTF-8 handling); previously trivial (progress log: a turned inline picture whose file keeps no room for the turn keeps its line to its frame); previously trivial (progress log: the Arabic interface's Styles gallery reads from the right (#5566)); previously trivial (progress log: ODT pictures offered in several formats); previously trivial (progress log: ODT heading text of another size); previously trivial (Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged; previously trivial: progress log: Custom document properties dialog, #2982; previously trivial: progress log: View › New Window; previously trivial: progress log: interface translations come from storytold/craft-i18n through the `craft-i18n` crate; previously trivial: progress log: disabled-control reasons translated in every interface language, #2678; previously trivial: progress log: mail merge record navigation and record ranges for printing, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: group connector rerouting preserves rotated and flipped free or unresolved endpoints under nonuniform group scaling; readiness estimates unchanged; previously trivial: progress log: a word with no break opportunity in it no longer makes the layout quadratic, #3412; previously trivial: progress log: a relationship the markup names without the prefix is read as it wrote, and an ordinary `id` names no part; previously trivial: progress log: a document with many relationships opens in the time its part takes, and an id the text only mentions is not a reference, #3411; previously trivial: progress log: read only and comments-only protection grey out edits; previously trivial: progress log: an empty paragraph with a hidden mark shows nothing, not even its list number, #3982; previously trivial: progress log: "NaN" in the Font dialog's Size box no longer closes the app, #3663; previously trivial: progress log: a table cell span from a `.json` file no longer overflows, #3637; previously trivial: progress log: a click in the footer while editing the header moves there; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Slovenian interface catalog, 2,614 entries; previously trivial: Insert Table of Figures dialog for any caption label, #3013; previously trivial: progress log: Home › Underline drop-down, #2738; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: progress log: the scrollbar page tip stays on one line, #3341; previously trivial: progress log: forms protection greys out the control buttons; previously trivial: progress log: a document with many content controls saves in the time the controls take, #13; previously trivial: progress log: Word signature lines kept on save; previously trivial: a Thai run with Latin finds one installed font covering it all on Linux too, #1549; previously trivial: progress log: closing the header returns to the body selection, #3331; previously trivial: progress log: saving to a NAS share mounted by GVFS, #3003; previously trivial: progress log: a picture dragged near the bottom of a page lands there, #3169; previously trivial: centred list labels after leading page breaks, #2964; previously trivial: progress log: inline pictures drag to an insertion cursor and stay inline, #2233, #2234; previously trivial: progress log: a text file saved over itself closes without asking, #2376; previously trivial: progress log: a text frame in the paragraph defaults frames nothing, #2360; previously trivial: fixed font inputs in four layout controls; previously trivial: typing no longer starts render threads on every repaint, #3027; previously trivial: a right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, goes to the next line with its text, #1840; previously trivial: progress log: banded rows shade as in Word, #3415; previously trivial: progress log: the table handles show while the caret is in the table, #2428; previously trivial: progress log: a click below a floating table reaches the text after it, #2038; previously trivial: progress log: Delete on selected table cells leaves one empty paragraph in each, #2802; previously trivial: progress log: lam-alef in exported PDFs extracts whole with fonts that draw it as two glyphs, #2310; previously trivial: Bullets and Numbering toggle off style-inherited lists at their effective level, including basedOn chains and numbered ListParagraph styles; other paragraphs and list definitions stay unchanged (related to #3459); previously trivial (progress log: a shape dropped just after a page break inside a paragraph stays on the new page, #4262); previously trivial (progress log: a float anchored on a later page of a long paragraph is drawn there, #4250); previously minor (progress log: `file.closeDocument` over the control channel and MCP bridge is refused while the document it names has unsaved changes; previously trivial (progress log: ODT element audit, ODT checked against 220 files from other applications, ODT display styles); previously trivial (progress log: Shape Format › Size in the interface unit, #4196); previously trivial (progress log: typed n-ary operators such as ∫ and ∑ wait for their limits, observed in Word for Windows on #4938 (#4917)); previously trivial (progress log: a paragraph naming an undefined style is formatted as Normal, #5077); previously trivial (progress log: justified and distributed lines keep the width of the spaces before their first character); 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 (progress log: a print job waiting on its driver can be cancelled, and quitting doesn't wait for it, #5710); previously trivial (progress log: the Print panel's printer list no longer waits on printer drivers, #5710); previously trivial (Page drawing indexes text-box warp lookups per paragraph (#3614)); previously trivial (built-in citation source lookups, #4888; current-main progress records retained); previously trivial (progress log: Times and Courier take their Windows counterparts' line spacing; previously trivial (progress log: the status bar's count can be words, characters or characters without spaces, #2797); previously trivial (Linux display server setting in File › Options › Advanced, #2184); previously trivial (progress log: Linux Read Aloud through Speech Dispatcher, #4576); previously trivial (progress log: a click just outside a floating table by turned cell text, #4181; previously minor: progress log: Spanish proofing, #3360, #3553; previously trivial: progress log: Insert › Table's grid previews the hovered table on the page, #3931; previously trivial (progress log: MHT quoted MIME parameters); previously trivial (progress log: CLI convert format options); previously trivial (MATH construction reuse, #3630); previously trivial (DOCX `w:adjustRightInd` is preserved through style resolution and ordered DOCX saves); previously trivial (per-page ink object lookups, #3614); previously trivial (progress log: ODT display settings removed); previously trivial (progress log: dialogs are modal except the five Word keeps modeless, and a press beside one shakes it, #3859); previously trivial (progress log: picture brightness, contrast and transparency, ODT element audit, ODT checked against 220 files from other applications, ODT display styles); previously trivial (progress log: the dialogs of the mirrored Arabic interface read right to left: label-and-field rows, tables (list columns, the Models table), tile galleries and the Add/Remove arrows follow the reading direction, through one `rtl::Table` helper that draws exactly as before in English; no ranked gap closed, readiness estimates unchanged); previously trivial (progress log: fonts that aren't installed are flagged in the font box and status bar); previously trivial (progress log: ODT sections inside text boxes); previously trivial (progress log: ODT definitions sharing a name, sections around tables, stacking order); previously trivial (progress log: ODT forms and indexes written as read); previously trivial (progress log: ODT table styles saved, WordCraft-origin documents checked in LibreOffice); previously trivial (progress log: ODT interpretation profile); previously trivial (progress log: ODT controls, custom shapes, in-line placement); previously trivial (progress log: ODT charts kept, frame outlines, header height); previously trivial (progress log: ODT header rows); previously trivial (progress log: ODT layout setting, padding, columns); previously trivial (progress log: ODT tables, header spacing, picture paragraphs); previously trivial (progress log: ODT round trips keep their page count); previously trivial (progress log: emphasis marks, SET fields, ODT page backgrounds and tables); previously trivial (progress log: ODT checked against LibreOffice's templates); previously trivial (progress log: ODT at ~90%); previously trivial (progress log: ODT read and written nearly whole); previously trivial (progress log: ODT text boxes); previously trivial (progress log: ODT layout settings); previously trivial (progress log: ODT character styles); previously trivial (progress log: ODT custom styles); previously trivial (progress log: ODT equations saved); previously trivial (progress log: ODT floating pictures); previously trivial (progress log: ODT paragraph borders); previously trivial (progress log: ODT heading numbering); previously trivial (progress log: ODT table borders); previously trivial (progress log: ODT heading styles); previously trivial (progress log: ODT tab stops); previously trivial (progress log: ODT character formatting); previously trivial (progress log: ODT lists); previously trivial (progress log: ODT comments); previously trivial (progress log: ODT footnotes and endnotes); previously trivial (progress log: ODT headers, footers and fields); previously trivial (progress log: ODT paragraph spacing); previously trivial (progress log: Options › Language redesign, CP4.3); previously trivial (progress log: the missing-pack bar on a fresh install, the caret's typing language, and the spelling menu heading in the interface language, CP4.3); previously trivial (progress log: Language pack languages in every language list, CP4.3); previously trivial (progress log: craft-proof pin, French elision and Valencian, CP4.3); previously trivial (progress log: a long comment's card and balloon stop at ten lines, #3382); previously trivial (progress log: a pasted text box story is charged for the formatting it copies); previously trivial (progress log: a .doc table row keeps one override per cell); previously trivial (progress log: a .doc file's sections find their paragraphs by index); previously minor (Arabic interface language with mirrored UI, #1195); previously trivial (progress log: Replace and Remove Table of Contents with Word's title above a section break, #4041); previously trivial (progress log: a password-protected file named on the command line asks for its password after the startup document is replaced, #5299); previously trivial (progress log: language-packs-2 published and pinned, 75 Language packs); previously trivial (progress log: language-packs-1 published and pinned, CP4.4); previously trivial (progress log: Language packs, CP4);; previously trivial (DOCX table rows and cells inside selected alternate-content branches survive open and repeated saves (#5219); broader corpus qualification and readiness estimates unchanged); previously trivial (progress log: a list inside a Markdown block quote stays quoted); previously trivial (progress log: arrowheads keep their kind, width and length and are drawn at Word's sizes); previously trivial (progress log: the line between columns for selected text, #5178); previously trivial (progress log: .doc standard font, #5066); previously trivial (progress log: a table row doesn't split off a picture that doesn't fit, #4272); previously trivial (progress log: a middle or bottom cell of a row split across pages lines up on the first page); previously trivial (progress log: tab leader dots spaced and placed as in Word); previously trivial (progress log: a list level above counts its first number at the first deeper item); previously trivial (progress log: paragraph side borders lie outside the text, #5036); previously trivial (progress log: TOC page numbers as PAGEREF fields, #5097); previously trivial (progress log: Backstage keytips, #4960); previously trivial (Progress log: only the printer's PDF leaves out links; Save these pages as PDF keeps them, #4734); previously trivial (progress log: Chinese and Japanese text counts a word per character, #4547; previously trivial: aligned-copy review fixes retain the document axis through scrolling and include secondary selections (#4764)); previously trivial (connector rerouting indexes laid-out object positions once per batch (#3631); previously trivial (progress log: corporate authors in bibliographies, #4848); previously trivial (custom-property bookmark-link preservation, #4767); previously trivial (progress log: Table Properties follows the selection, #4857); previously trivial (Relative font-size commands preserve mixed sizes in the selection (#4903); existing button steps and one-point shortcuts are unchanged; readiness estimates unchanged); previously trivial (Arabic Backspace removes one combining mark and keeps its base letter (#4757); previously trivial (note conversion walks reference offsets and formatting runs together, #4750); previously trivial (DOCX comment-ID save lookups); previously trivial (progress log: RTF pictures stored as Windows or Enhanced Metafiles are imported, #4259); previously trivial (#4658 bounds nested Markdown reference-label work); previously trivial (HTML import keeps preformatted lines with CR or CRLF input newlines, #4810); previously trivial (progress log: Insert › Shapes icon grid, #4349); previously trivial (progress log: AutoCorrect Options with no document open, #4585); previously trivial (progress log: window fallback geometry and equation symbol tooltips); previously trivial (progress log: window titles omit NUL characters, #3634); previously trivial (Recipient labels continue across product-sized sheets instead of stopping after the first sheet (#4880)); previously trivial (progress log: Custom document properties dialog, #2982; previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously trivial: progress log: a text box that keeps the keyboard no longer resets the input method every frame, #2986; previously trivial: progress log: recovery copies and .json files store pictures as base64, #586 follow-up; previously trivial: progress log: legacy menu keys, #1697; previously trivial: progress log: shape gradients and transparency, #1500; previously trivial: progress log: Focus fills the screen, and Full Screen View shows the pages alone, #1678; previously trivial: progress log: text above a float's anchor wraps around it, #2048; previously trivial: progress log: File › Recover follows the app theme, #3243; previously trivial: progress log: formatting toolbar with the text context menu, #2959; previously trivial: progress log: caret inside ligatures, #1974; previously trivial: text typed into a content control takes the control's formatting; localized placeholder styles recognised; previously trivial: forms protection keeps its content controls: no inserting, Properties or Remove Content Control; previously trivial: long navigation headings wrap onto further lines within the pane, #3015; previously trivial: clearing a no-match font query keeps the recent heading visible, #2068; previously trivial: a word after a slash wraps whole, like Word, #2963; previously trivial: progress log: a header-cell picture watermark sits behind the text, #1775; previously trivial: symbols keep their font when the text font changes, #2036; previously trivial: opening a DOCX no longer copies its pictures; previously trivial: Add Font imports every selected font file, #1789); previously trivial (RTF export writes sections (gap 19); previously trivial: ODT export writes sections (gap 19); previously trivial: Read Aloud speaks each sentence in its own language, #1843; previously trivial: hint-reliant CJK outlines; previously trivial: Ctrl+wheel zoom no longer scrolls the document, #1743; previously trivial: progress log: Turkish case mapping in AutoCorrect, #1923; previously trivial: a mouse drag on a table leaves the view where it is, #1738; previously trivial: progress log: Hebrew field results and smart quotes, #1670; previously trivial: Backspace removes a selected table, rows or columns, #1844; previously trivial: progress log: mixed Hebrew/Latin text keeps its order in Word, #1543; previously trivial: progress log: web typing in non-Latin text no longer repeats, #1480; previously trivial: progress log: font family caches bounded and math font lookups follow font changes, #1354; previously trivial: `-->` AutoCorrect replacement, #2223; previously trivial: numbered headings, #1793; previously trivial: Navigation Find exposes Results, #2096; previously trivial: progress log: Columns on selected text, #2024; previously trivial: progress log: legacy outline, shadow, emboss and imprint text effects drawn, #2534; previously trivial: progress log: Indonesian proofing, #498; previously trivial: progress log: DOCX glossary documents (building blocks); previously trivial: progress log: Read Mode keeps the keyboard and shows whole, unobscured columns, #1772); previously trivial: progress log: font list entries of tall-ascent fonts no longer cut off, #2570); previously trivial: progress log: Split Cells and Convert Text to Table dialogs follow the Word check, #2592; previously trivial: a new source's Tag is made like Word's, three letters of the author and two digits of the year with a number added when taken, and an edit keeps the Tag, #2094; previously trivial: Web Layout fills the window width, #1876; previously trivial: progress log: Different First Page headers reachable from page 1, #2826; previously trivial: Language dialog keeps inherited proofing language and no-proof choices (#2717); previously trivial: progress log: web preferences kept between visits, #2132; previously trivial: progress log: undrawable private-use list bullets show the level's default bullet, #1683; previously trivial: progress log: `w:eastAsianLayout` kept on save; previously trivial: table style editor formats every part, #714); previously trivial: VML freeforms read and kept on save; previously trivial: progress log: consistent preferred cell widths; previously trivial: multi-paragraph field instructions no longer add blank lines; previously trivial: page-break-only list paragraphs hide their labels; previously trivial: progress log: grouped `flowChartOr` shapes draw their circle and crossing spokes; previously trivial: progress log: copies keep their formatting in other programs, #1523; previously trivial: progress log: privacy options on save, #1062; previously trivial: progress log: equation pictures in theme colours on Windows, #1002; previously trivial: symbol fonts, #776; previously trivial: the save prompt answers from the keyboard, #861; previously trivial: table column and row markers on the rulers, #700; previously trivial: table borders and the resize handle drag on the page, #217; previously trivial: formatting revisions landed, #41; previously trivial: Draw tab ink, #307, and Draw Table and Eraser, #303, landed: catalog 402/434; previously minor: readiness table with hours per audience; full number back to the additive weighted sum, 60%; mainstream and essentials numbers added; alpha gate checked; previously major: full re-measure against Word for Mac 16.113.4; progress docs restructured); previously trivial (progress log: ODT documents keep their language); previously trivial (progress log: ODT table and row backgrounds) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-28 · **Change:** trivial (progress log: DOCX tracked changes dated in local time, as Word reads `w:date`, with their UTC time in `w16du:dateUtc`, #6851); previously trivial (progress log: Review › Delete › Delete All Comments in Document and Delete All Resolved Comments, #7818); previously trivial (legacy header lines stay in place around narrow Square, Tight and Through logos, #6805); previously trivial (progress log: `wordcraft-cli mcp` needs both automation roots and refuses `--connect`, #7124); previously trivial (progress log: File › Print’s preview pages as the print job prints and marks tracked changes with Track Changes Options, #5232, #6267); previously trivial (formatting shortcuts say what they did to screen readers); previously trivial (dialogs are dialogs to screen readers, their tabs are tabs, and colour fields and swatches say their colour); previously 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); previously trivial (progress log: border boxes close their corners; previously trivial: progress log: file formats, codecs and protocols from craft-libs, #778); previously trivial (progress log: Get the Missing Fonts); previously trivial (progress log: a deleted list item's number is drawn as deleted text under Track Changes (#4828)); previously trivial (progress log: Save As and Export offer Browse in WordCraft… on Linux/BSD, #3535); previously trivial (progress log: Review › Language can set the whole document's proofing language, #3518); previously trivial (progress log: Auto interface size capped to the screen, #4030); previously trivial (progress log: DOCX section line numbering stays off without a positive `w:countBy`, #6209); previously trivial (progress log: Save As on Linux: the desktop portal's Save dialog reports the file type picked, updating the extension so saving as PDF writes a .pdf, #6180); previously trivial (Vertical scrollbar track: clicking above the elevator moves one screen up and clicking below it moves one screen down, as in Word (#5853)); previously trivial (progress log: #4501 refactor regressions restored: per-section header grid, ODT default font, link tooltip, #4683); previously trivial (progress log: the window moves by its title bar behind a modal dialog, #5124); previously trivial (progress log: `convert --strict` and `render --strict` refuse a silently incomplete PDF or PNG (#6005, #6008)); ; trivial (progress log: ODT columns stating only their shares); previously trivial (progress log: ODT font size for every script); previously trivial (progress log: ODT text turning off what its style turns on); previously trivial (progress log: edited ODT paragraphs keep custom styles with an outline level); previously trivial (progress log: ODT pictures keep the size their file gives); previously trivial (progress log: ODT frames keep the page they are anchored to); previously trivial (pointer zoom stretches page rasters until it stops); previously trivial (dark-theme interface text on Linux no longer looks semi-bold); previously trivial (Control/MCP #2596 review: partial-write outcomes, path-bearing image exports, accept-thread startup cleanup and malformed UTF-8 handling); previously trivial (progress log: a turned inline picture whose file keeps no room for the turn keeps its line to its frame); previously trivial (progress log: the Arabic interface's Styles gallery reads from the right (#5566)); previously trivial (progress log: ODT pictures offered in several formats); previously trivial (progress log: ODT heading text of another size); previously trivial (Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged; previously trivial: progress log: Custom document properties dialog, #2982; previously trivial: progress log: View › New Window; previously trivial: progress log: interface translations come from storytold/craft-i18n through the `craft-i18n` crate; previously trivial: progress log: disabled-control reasons translated in every interface language, #2678; previously trivial: progress log: mail merge record navigation and record ranges for printing, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: group connector rerouting preserves rotated and flipped free or unresolved endpoints under nonuniform group scaling; readiness estimates unchanged; previously trivial: progress log: a word with no break opportunity in it no longer makes the layout quadratic, #3412; previously trivial: progress log: a relationship the markup names without the prefix is read as it wrote, and an ordinary `id` names no part; previously trivial: progress log: a document with many relationships opens in the time its part takes, and an id the text only mentions is not a reference, #3411; previously trivial: progress log: read only and comments-only protection grey out edits; previously trivial: progress log: an empty paragraph with a hidden mark shows nothing, not even its list number, #3982; previously trivial: progress log: "NaN" in the Font dialog's Size box no longer closes the app, #3663; previously trivial: progress log: a table cell span from a `.json` file no longer overflows, #3637; previously trivial: progress log: a click in the footer while editing the header moves there; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Slovenian interface catalog, 2,614 entries; previously trivial: Insert Table of Figures dialog for any caption label, #3013; previously trivial: progress log: Home › Underline drop-down, #2738; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: progress log: the scrollbar page tip stays on one line, #3341; previously trivial: progress log: forms protection greys out the control buttons; previously trivial: progress log: a document with many content controls saves in the time the controls take, #13; previously trivial: progress log: Word signature lines kept on save; previously trivial: a Thai run with Latin finds one installed font covering it all on Linux too, #1549; previously trivial: progress log: closing the header returns to the body selection, #3331; previously trivial: progress log: saving to a NAS share mounted by GVFS, #3003; previously trivial: progress log: a picture dragged near the bottom of a page lands there, #3169; previously trivial: centred list labels after leading page breaks, #2964; previously trivial: progress log: inline pictures drag to an insertion cursor and stay inline, #2233, #2234; previously trivial: progress log: a text file saved over itself closes without asking, #2376; previously trivial: progress log: a text frame in the paragraph defaults frames nothing, #2360; previously trivial: fixed font inputs in four layout controls; previously trivial: typing no longer starts render threads on every repaint, #3027; previously trivial: a right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, goes to the next line with its text, #1840; previously trivial: progress log: banded rows shade as in Word, #3415; previously trivial: progress log: the table handles show while the caret is in the table, #2428; previously trivial: progress log: a click below a floating table reaches the text after it, #2038; previously trivial: progress log: Delete on selected table cells leaves one empty paragraph in each, #2802; previously trivial: progress log: lam-alef in exported PDFs extracts whole with fonts that draw it as two glyphs, #2310; previously trivial: Bullets and Numbering toggle off style-inherited lists at their effective level, including basedOn chains and numbered ListParagraph styles; other paragraphs and list definitions stay unchanged (related to #3459); previously trivial (progress log: a shape dropped just after a page break inside a paragraph stays on the new page, #4262); previously trivial (progress log: a float anchored on a later page of a long paragraph is drawn there, #4250); previously minor (progress log: `file.closeDocument` over the control channel and MCP bridge is refused while the document it names has unsaved changes; previously trivial (progress log: ODT element audit, ODT checked against 220 files from other applications, ODT display styles); previously trivial (progress log: Shape Format › Size in the interface unit, #4196); previously trivial (progress log: typed n-ary operators such as ∫ and ∑ wait for their limits, observed in Word for Windows on #4938 (#4917)); previously trivial (progress log: a paragraph naming an undefined style is formatted as Normal, #5077); previously trivial (progress log: justified and distributed lines keep the width of the spaces before their first character); 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 (progress log: a print job waiting on its driver can be cancelled, and quitting doesn't wait for it, #5710); previously trivial (progress log: the Print panel's printer list no longer waits on printer drivers, #5710); previously trivial (Page drawing indexes text-box warp lookups per paragraph (#3614)); previously trivial (built-in citation source lookups, #4888; current-main progress records retained); previously trivial (progress log: Times and Courier take their Windows counterparts' line spacing; previously trivial (progress log: the status bar's count can be words, characters or characters without spaces, #2797); previously trivial (Linux display server setting in File › Options › Advanced, #2184); previously trivial (progress log: Linux Read Aloud through Speech Dispatcher, #4576); previously trivial (progress log: a click just outside a floating table by turned cell text, #4181; previously minor: progress log: Spanish proofing, #3360, #3553; previously trivial: progress log: Insert › Table's grid previews the hovered table on the page, #3931; previously trivial (progress log: MHT quoted MIME parameters); previously trivial (progress log: CLI convert format options); previously trivial (MATH construction reuse, #3630); previously trivial (DOCX `w:adjustRightInd` is preserved through style resolution and ordered DOCX saves); previously trivial (per-page ink object lookups, #3614); previously trivial (progress log: ODT display settings removed); previously trivial (progress log: dialogs are modal except the five Word keeps modeless, and a press beside one shakes it, #3859); previously trivial (progress log: picture brightness, contrast and transparency, ODT element audit, ODT checked against 220 files from other applications, ODT display styles); previously trivial (progress log: the dialogs of the mirrored Arabic interface read right to left: label-and-field rows, tables (list columns, the Models table), tile galleries and the Add/Remove arrows follow the reading direction, through one `rtl::Table` helper that draws exactly as before in English; no ranked gap closed, readiness estimates unchanged); previously trivial (progress log: fonts that aren't installed are flagged in the font box and status bar); previously trivial (progress log: ODT sections inside text boxes); previously trivial (progress log: ODT definitions sharing a name, sections around tables, stacking order); previously trivial (progress log: ODT forms and indexes written as read); previously trivial (progress log: ODT table styles saved, WordCraft-origin documents checked in LibreOffice); previously trivial (progress log: ODT interpretation profile); previously trivial (progress log: ODT controls, custom shapes, in-line placement); previously trivial (progress log: ODT charts kept, frame outlines, header height); previously trivial (progress log: ODT header rows); previously trivial (progress log: ODT layout setting, padding, columns); previously trivial (progress log: ODT tables, header spacing, picture paragraphs); previously trivial (progress log: ODT round trips keep their page count); previously trivial (progress log: emphasis marks, SET fields, ODT page backgrounds and tables); previously trivial (progress log: ODT checked against LibreOffice's templates); previously trivial (progress log: ODT at ~90%); previously trivial (progress log: ODT read and written nearly whole); previously trivial (progress log: ODT text boxes); previously trivial (progress log: ODT layout settings); previously trivial (progress log: ODT character styles); previously trivial (progress log: ODT custom styles); previously trivial (progress log: ODT equations saved); previously trivial (progress log: ODT floating pictures); previously trivial (progress log: ODT paragraph borders); previously trivial (progress log: ODT heading numbering); previously trivial (progress log: ODT table borders); previously trivial (progress log: ODT heading styles); previously trivial (progress log: ODT tab stops); previously trivial (progress log: ODT character formatting); previously trivial (progress log: ODT lists); previously trivial (progress log: ODT comments); previously trivial (progress log: ODT footnotes and endnotes); previously trivial (progress log: ODT headers, footers and fields); previously trivial (progress log: ODT paragraph spacing); previously trivial (progress log: Options › Language redesign, CP4.3); previously trivial (progress log: the missing-pack bar on a fresh install, the caret's typing language, and the spelling menu heading in the interface language, CP4.3); previously trivial (progress log: Language pack languages in every language list, CP4.3); previously trivial (progress log: craft-proof pin, French elision and Valencian, CP4.3); previously trivial (progress log: a long comment's card and balloon stop at ten lines, #3382); previously trivial (progress log: a pasted text box story is charged for the formatting it copies); previously trivial (progress log: a .doc table row keeps one override per cell); previously trivial (progress log: a .doc file's sections find their paragraphs by index); previously minor (Arabic interface language with mirrored UI, #1195); previously trivial (progress log: Replace and Remove Table of Contents with Word's title above a section break, #4041); previously trivial (progress log: a password-protected file named on the command line asks for its password after the startup document is replaced, #5299); previously trivial (progress log: language-packs-2 published and pinned, 75 Language packs); previously trivial (progress log: language-packs-1 published and pinned, CP4.4); previously trivial (progress log: Language packs, CP4);; previously trivial (DOCX table rows and cells inside selected alternate-content branches survive open and repeated saves (#5219); broader corpus qualification and readiness estimates unchanged); previously trivial (progress log: a list inside a Markdown block quote stays quoted); previously trivial (progress log: arrowheads keep their kind, width and length and are drawn at Word's sizes); previously trivial (progress log: the line between columns for selected text, #5178); previously trivial (progress log: .doc standard font, #5066); previously trivial (progress log: a table row doesn't split off a picture that doesn't fit, #4272); previously trivial (progress log: a middle or bottom cell of a row split across pages lines up on the first page); previously trivial (progress log: tab leader dots spaced and placed as in Word); previously trivial (progress log: a list level above counts its first number at the first deeper item); previously trivial (progress log: paragraph side borders lie outside the text, #5036); previously trivial (progress log: TOC page numbers as PAGEREF fields, #5097); previously trivial (progress log: Backstage keytips, #4960); previously trivial (Progress log: only the printer's PDF leaves out links; Save these pages as PDF keeps them, #4734); previously trivial (progress log: Chinese and Japanese text counts a word per character, #4547; previously trivial: aligned-copy review fixes retain the document axis through scrolling and include secondary selections (#4764)); previously trivial (connector rerouting indexes laid-out object positions once per batch (#3631); previously trivial (progress log: corporate authors in bibliographies, #4848); previously trivial (custom-property bookmark-link preservation, #4767); previously trivial (progress log: Table Properties follows the selection, #4857); previously trivial (Relative font-size commands preserve mixed sizes in the selection (#4903); existing button steps and one-point shortcuts are unchanged; readiness estimates unchanged); previously trivial (Arabic Backspace removes one combining mark and keeps its base letter (#4757); previously trivial (note conversion walks reference offsets and formatting runs together, #4750); previously trivial (DOCX comment-ID save lookups); previously trivial (progress log: RTF pictures stored as Windows or Enhanced Metafiles are imported, #4259); previously trivial (#4658 bounds nested Markdown reference-label work); previously trivial (HTML import keeps preformatted lines with CR or CRLF input newlines, #4810); previously trivial (progress log: Insert › Shapes icon grid, #4349); previously trivial (progress log: AutoCorrect Options with no document open, #4585); previously trivial (progress log: window fallback geometry and equation symbol tooltips); previously trivial (progress log: window titles omit NUL characters, #3634); previously trivial (Recipient labels continue across product-sized sheets instead of stopping after the first sheet (#4880)); previously trivial (progress log: Custom document properties dialog, #2982; previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously trivial: progress log: a text box that keeps the keyboard no longer resets the input method every frame, #2986; previously trivial: progress log: recovery copies and .json files store pictures as base64, #586 follow-up; previously trivial: progress log: legacy menu keys, #1697; previously trivial: progress log: shape gradients and transparency, #1500; previously trivial: progress log: Focus fills the screen, and Full Screen View shows the pages alone, #1678; previously trivial: progress log: text above a float's anchor wraps around it, #2048; previously trivial: progress log: File › Recover follows the app theme, #3243; previously trivial: progress log: formatting toolbar with the text context menu, #2959; previously trivial: progress log: caret inside ligatures, #1974; previously trivial: text typed into a content control takes the control's formatting; localized placeholder styles recognised; previously trivial: forms protection keeps its content controls: no inserting, Properties or Remove Content Control; previously trivial: long navigation headings wrap onto further lines within the pane, #3015; previously trivial: clearing a no-match font query keeps the recent heading visible, #2068; previously trivial: a word after a slash wraps whole, like Word, #2963; previously trivial: progress log: a header-cell picture watermark sits behind the text, #1775; previously trivial: symbols keep their font when the text font changes, #2036; previously trivial: opening a DOCX no longer copies its pictures; previously trivial: Add Font imports every selected font file, #1789); previously trivial (RTF export writes sections (gap 19); previously trivial: ODT export writes sections (gap 19); previously trivial: Read Aloud speaks each sentence in its own language, #1843; previously trivial: hint-reliant CJK outlines; previously trivial: Ctrl+wheel zoom no longer scrolls the document, #1743; previously trivial: progress log: Turkish case mapping in AutoCorrect, #1923; previously trivial: a mouse drag on a table leaves the view where it is, #1738; previously trivial: progress log: Hebrew field results and smart quotes, #1670; previously trivial: Backspace removes a selected table, rows or columns, #1844; previously trivial: progress log: mixed Hebrew/Latin text keeps its order in Word, #1543; previously trivial: progress log: web typing in non-Latin text no longer repeats, #1480; previously trivial: progress log: font family caches bounded and math font lookups follow font changes, #1354; previously trivial: `-->` AutoCorrect replacement, #2223; previously trivial: numbered headings, #1793; previously trivial: Navigation Find exposes Results, #2096; previously trivial: progress log: Columns on selected text, #2024; previously trivial: progress log: legacy outline, shadow, emboss and imprint text effects drawn, #2534; previously trivial: progress log: Indonesian proofing, #498; previously trivial: progress log: DOCX glossary documents (building blocks); previously trivial: progress log: Read Mode keeps the keyboard and shows whole, unobscured columns, #1772); previously trivial: progress log: font list entries of tall-ascent fonts no longer cut off, #2570); previously trivial: progress log: Split Cells and Convert Text to Table dialogs follow the Word check, #2592; previously trivial: a new source's Tag is made like Word's, three letters of the author and two digits of the year with a number added when taken, and an edit keeps the Tag, #2094; previously trivial: Web Layout fills the window width, #1876; previously trivial: progress log: Different First Page headers reachable from page 1, #2826; previously trivial: Language dialog keeps inherited proofing language and no-proof choices (#2717); previously trivial: progress log: web preferences kept between visits, #2132; previously trivial: progress log: undrawable private-use list bullets show the level's default bullet, #1683; previously trivial: progress log: `w:eastAsianLayout` kept on save; previously trivial: table style editor formats every part, #714); previously trivial: VML freeforms read and kept on save; previously trivial: progress log: consistent preferred cell widths; previously trivial: multi-paragraph field instructions no longer add blank lines; previously trivial: page-break-only list paragraphs hide their labels; previously trivial: progress log: grouped `flowChartOr` shapes draw their circle and crossing spokes; previously trivial: progress log: copies keep their formatting in other programs, #1523; previously trivial: progress log: privacy options on save, #1062; previously trivial: progress log: equation pictures in theme colours on Windows, #1002; previously trivial: symbol fonts, #776; previously trivial: the save prompt answers from the keyboard, #861; previously trivial: table column and row markers on the rulers, #700; previously trivial: table borders and the resize handle drag on the page, #217; previously trivial: formatting revisions landed, #41; previously trivial: Draw tab ink, #307, and Draw Table and Eraser, #303, landed: catalog 402/434; previously minor: readiness table with hours per audience; full number back to the additive weighted sum, 60%; mainstream and essentials numbers added; alpha gate checked; previously major: full re-measure against Word for Mac 16.113.4; progress docs restructured); previously trivial (progress log: ODT documents keep their language); previously trivial (progress log: ODT table and row backgrounds) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 > **Validation status:** 2026-11-18 · trivial · DOCX validation warns once per duplicated folded font name, including case variants. Independent endpoint review remains open. > **Last reviewed:** 2026-10-31 · **Last updated:** 2026-11-18 · **Change:** trivial (progress log: TIFF picture chooser, drop and pasted-path routing, #6704); previously minor (added layout.fitOnePage and its Layout › Page Setup ribbon button to condense a multi-page document by one page while preserving typography hierarchy); previously minor (#3398: persistent screen paper colors; parity estimates unchanged); previously minor (#3693: additional Delete Previous Sentence command and shortcut; Word-parity estimates unchanged) > **Floating anchor row segments:** 2026-11-07 · A floating anchor after a manual page/column break counts visible content on the far side of the same wrapped row. Marker-only cover anchors retain their previous-page rule. Synthetic picture spacing, placement and history controls; no new native Word measurement. Readiness estimates unchanged. @@ -60,7 +60,9 @@ discounts and the user evidence (120 issues from outside users, 4 praise, 0 "swi **Why alpha:** the core workflows (write, format, styles, lists, tables, references, review, mail merge, open and save .docx) work end to end and ship as signed builds on every desktop platform -and the web. **Why not beta:** DOCX has never been tested on real-world files; charts, SmartArt and +and the web. **Why not beta:** DOCX has not been tested on a real-world corpus yet (the opt-in +`cargo xtask docx-corpus` harness can now run one locally, but no corpus or Word comparison is +checked in); charts, SmartArt and OLE objects are dropped silently; pagination differs from Word (no Aptos-metric font, no column balancing or footnote continuation); content controls are lost; there is open field evidence of a startup crash and several hangs; no native printing. Gaps #1–#7 in [`docs/gaps.md`](docs/gaps.md) @@ -121,7 +123,7 @@ Weights and evidence per area: [docs/target-app-parity.md](docs/target-app-parit | English | en | full | 100% | | Simplified Chinese | zh-hans | partial | ~95% | | Spanish | es | partial | ~95% | -| Hindi | hi | none | 0% | +| Hindi | hi | partial (interface catalog, native-speaker reviewed; no proofing) | ~75% (2,800 entries; `cargo xtask i18n-report` lists 801 strings without Hindi) | | Arabic | ar | partial (catalog + mirrored UI; no kashida; no proofing; native review open) | ~95% | | French | fr | partial (interface complete, native-speaker reviewed; spelling from the French Language pack, no grammar marks) | 100% (2,615 entries) | | Portuguese | pt-br (pt-PT none) | partial | ~95% | @@ -153,8 +155,12 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm ## Progress log +- 2026-12-01: Hindi interface language (`hi`): File › Options › Interface language offers हिन्दी, and `hi`, `hi-IN` and `hi_IN.UTF-8` system locales pick it. The catalog is craft-i18n's `locales/hi/wordcraft.tsv` (`craft-i18n.rev` at 217f413); interface text is drawn by the embedded Noto Sans Devanagari face. No Hindi proofing, so the Hindi interface doesn't set the language of new documents. Readiness estimates unchanged. - 2026-11-28: Layout indexes numbering definitions for each list and STYLEREF walk. List labels still follow the document's literal labels, start overrides and nested restart rules (#3615). +- 2026-11-27: Home › Paragraph › Borders with whole table cells selected (the table, rows, columns or a block of cells) borders the cells as one block, as Word does, instead of drawing a box around each paragraph in them: All Borders gives a continuous grid, Outside and Inside follow the block's edges, a single side toggles, and No Border clears the cells (#7874). +- 2026-11-25: Review › Comments › Delete is a split button whose menu has Delete, Delete All Comments in Document and Delete All Resolved Comments, which deletes each resolved comment with its replies and keeps the open ones (`review.deleteComment {"resolved": true}`, #7818). Readiness estimates unchanged. + - 2026-11-24: Pasting a plain table over selected cells overwrites from the selection's top-left, even when the copy is wider than the selection (#6742). - 2026-11-21: Layout: strict column balancing measures a kept paragraph again in each candidate column, so a float in one column does not make the paragraph skip another where it fits (#6821). Readiness estimates unchanged. @@ -178,6 +184,7 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm - 2026-11-03: A picture inserted or pasted in a table cell fits the cell, as in Word, instead of running out of it; in text columns it fits the column, in a section with other margins that section's width (#5428). - 2026-11-09: Touchpad and mouse-wheel scroll speed settings (#6146): scales Wayland touchpad point input by default (4×) so two-finger scrolling matches desktop speed rather than crawling 1:1, and scales mouse wheel line distance; File › Options › Advanced › Scrolling; commands ui.scrollSpeed and ui.touchpadScrollSpeed. +- 2026-11-28: Tracked changes made in WordCraft and saved as DOCX or Word XML are dated (`w:date`) in local wall-clock time with a `Z`, as Word writes and reads it, with their UTC time beside it in `w16du:dateUtc` (craft-libs#3220); they were saved in UTC, so Word showed them shifted by the author's offset from UTC (#6851). A change keeps its UTC time and is grouped by it, so two edits an hour apart in the repeated hour as daylight saving time ends stay separate changes, also after a save and reopen. A change read from a file is written as read: open doesn't guess the zone of a `w:date` without `dateUtc`. No ranked gap closed; readiness estimates unchanged. - 2026-11-15: Layout: from Word 2013's layout (compatibility mode 15), balancing the columns before a continuous break keeps the last two, three or five lines of a paragraph that began on the page before together, keeps a two- or three-line paragraph that begins the last page whole, and holds a paragraph with keep lines together (or keep with next) whole in the first column when the strict rules fit. Synthetic tests also cover a footnote and a float (#6821); mode 14 splits them as before. Readiness estimates unchanged. - 2026-11-15: Layout: the first paragraph of a table cell on a page can split even when only one line fits, if the row starts at the top (possibly below its own headers) or continues from the previous page, and a non-exact row marked Can't Split that is taller than a page splits at the page's end, as in Word, instead of the row running off the bottom of the page (#6823). Readiness estimates unchanged. - 2026-11-14: Save As and Export (also the formats on the Print page) offer Browse in WordCraft… on Linux and the BSDs, as File › Open does, for when the system file dialog doesn't appear (#3535, from VoiceLessQ's #3801). Exporting in the built-in browser lists Export's formats as the types; the chosen type is the format and its extension, which replaces a known document extension on a typed name (`notes.docx` as plain text is `notes.txt`). An export the system dialog's name makes impossible (Word XML over an existing `.xml`) is refused on the Export page itself, not only the hidden status bar. Readiness estimates unchanged. @@ -402,6 +409,7 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm - 2026-10-24: AutoCorrect: a word typed after a no-break space or an ideographic space is corrected as after a plain space (replacements, sentence capitals, ordinals and links). AutoCorrect left such a word as typed. - 2026-10-24: MCP `type_text` with `paragraphs: true` is one command (#3973): it was a `text.newParagraph` and a `text.insert` per line, each snapshotting the whole document for Undo, so 10,000 lines took 2.8 s (doubling the lines cost 2.4–3.2×) and left an Undo step per line; now they take ~10 ms (linear) and one Undo takes them all back. A CRLF is one break, not two, and the breaks no longer run AutoCorrect (the per-line way capitalised every line but the last). Typed line breaks are the Enter key, so in a one-line content control, where Enter does nothing, they no longer split it into paragraphs. - 2026-10-24: Track Changes: the border-line (`---` and the others) and `+---+` table AutoFormats mark the typed characters deleted instead of removing them, so Reject All brings them back. Characters the same author typed with tracking on are removed, as a tracked Backspace removes them. A border at the top of a story is a tracked formatting change too, as the border on the paragraph above already was. The table is inserted untracked, as Insert › Table inserts one. A line that holds a tracked deletion no longer triggers either AutoFormat. +- 2026-10-23: Headers and footers: with the caret in a later section's header or footer, Link to Previous, Header/Footer Position, Insert › Header/Footer and Page Borders change that section. They counted the header's paragraphs as body paragraphs, so section 2's header changed section 1 (#3639). - 2026-10-23: cu20we: DrawingML flat, square and round line caps are imported, saved, displayed and exported to PDF; absent or unknown caps default to flat. VML end caps (including shapetype inheritance) are preserved through DOCX save. Ink and metafile stroke handling remain separate. Synthetic DOCX, raster and PDF regressions cover the change; no new native Word comparison. - 2026-10-23: cu20we: paragraph-relative box floats start above effective space before; header, footer, cell and text-box layout regressions pass. Framed paragraph positioning is unchanged; no new native Word comparison. - 2026-10-23: AutoFormat As You Type: `*Bold* and _italic_ as real formatting`. With the option on, `*word*` typed and finished becomes bold and `_word_` italic, without the marks. It is off by default (`tools.autocorrect {"boldItalic"}`). @@ -445,6 +453,7 @@ Imported Word 97–2003 `.doc`/`.dot` files now ask for a supported DOCX target - 2026-10-20: Restrict Editing: with Filling in forms enforced, the Developer tab's content-control buttons and Properties grey out in the ribbon, their tooltips saying why, as in Word; before, they looked live and only refused when clicked. - 2026-10-20: The page tip shown while dragging the vertical scrollbar stays on one line; it broke into two or three lines ("Page 10 of" / "40") as the page number grew during the drag (#3341). - 2026-10-20: Layout: text in Apple's Times and Courier takes Times New Roman's and Courier New's single-line spacing, as in Word for Mac; in a corpus of 180 real manuscripts, the five set in Times no longer gain a page. +- 2026-10-19: The empty window (no document, as after Esc on the Start screen or File › Close) says no document is open in the page area and offers Blank document, Browse… and Home; Home returns to the Start screen without making a document (#3126). - 2026-10-19: Restrict Editing: with Filling in forms enforced, inserting content controls, their Properties and Remove Content Control are refused, as in Word (it greys them out), so a form's fields stay as they are and only their content is filled in. - 2026-10-19: Content controls: text typed over a placeholder takes the control's own run properties (`w:sdtPr/w:rPr`, ECMA-376 §17.5.2.27), as in Word, and the placeholder style is recognised by its built-in name "Placeholder Text" whatever its localized id (German Word: `Platzhaltertext`), so entries in forms from localized Word no longer stay grey. @@ -488,6 +497,7 @@ Imported Word 97–2003 `.doc`/`.dot` files now ask for a supported DOCX target | 2026-10-25 | Custom document properties (#2982, split from #1798): File › Info › Properties › Advanced Properties… opens a Custom Document Properties dialog that lists the document's custom properties and adds, modifies and deletes them through the name/value form (text properties only; Word's number/date/yes-no types not offered). OK is one undoable `file.properties` step and marks the document changed; Cancel discards everything; names and values are validated against the engine's limits with the error shown in the dialog. Saved properties survive a DOCX round trip. | | 2026-10-24 | #4085: Ctrl+Alt+H toggles the last chosen highlight colour; explicit colour setters remain idempotent. Mixed, inherited and pending formatting and Undo/Redo covered by command/key regressions. | | 2026-10-23 | File > Print: N-up physical sheets and left/right-bound booklets, shared preview/PDF geometry and padded copies (#641); printer jobs keep upstream’s link-annotation fix. | +| 2026-10-23 | Header and footer commands change the section of the header the caret is in (#3639) | | 2026-10-23 | A command that changes nothing is not an edit: it adds no undo step, marks no unsaved changes and forces no relayout, so the redo stack survives it and five hundred of them can no longer push the user's own edits out of the undo history. | | 2026-10-23 | Interface translations come from storytold/craft-i18n, shared with the other Crafting Apps: the catalogs are embedded at build time from the commit in `craft-i18n.rev` and looked up through craft-libs' `craft-i18n` crate; `crates/ui-egui/src/i18n/*.tsv` are gone (translations now go to craft-i18n). Strings other apps already translate show translated; a build without `CRAFT_I18N_DIR` is English only | | 2026-10-23 | Comment times show in the user's own time zone, as in Word: the Comments pane converts them (it showed the file's UTC time) and the balloons show them under each author (they showed none). The file's UTC time (Word's `w16cex:dateUtc`) wins over `w:date`, a time naming its zone is converted, and one without a zone shows as written (#2322, #2337) | @@ -595,6 +605,7 @@ Imported Word 97–2003 `.doc`/`.dot` files now ask for a supported DOCX target | 2026-10-15 | Rulers: the numbers thin out as the page shrinks on screen (every 1, 2, 4… units, at least 30 px apart, the small ticks at least 4 px apart), give way to the indent, tab and column markers, and the margins get ticks only; both rulers span the caret's page at its own scale in One Page and Multiple Pages and follow the caret to another page (#1878) | | 2026-10-15 | Spelling as you type no longer flags the word being typed; the squiggle comes when the word ends or the caret leaves it, as in Word (#1552) | | 2026-10-15 | Text Highlight Color: No Color becomes the Highlight button's choice, as in Word, so the next click on the button removes highlighting instead of applying the colour picked before; the ribbon and the mini toolbar share one menu (#2105) | +| 2026-10-15 | Design › Paragraph Spacing presets update built-in paragraph styles, so existing styled paragraphs follow the preset; custom paragraph styles keep their own spacing (#1913) | | 2026-10-14 | Insert › Date & Time and DATE, TIME and other date fields show the computer's local date, time and weekday, daylight saving included, as Word does (#1707); they showed UTC, so a user in New Zealand at noon on 31 October got 30 October 23:00. Timestamps saved in files (revisions, comments, document properties) stay UTC. Backstage's greeting follows the local hour too | | 2026-10-14 | DOCX row table border exceptions render and survive saving. Explicit cell borders win; a row exception does not change other rows. | | 2026-10-14 | Tab stops edited on the ruler: the corner selector picks Left/Center/Right/Decimal/Bar, a click sets a stop (Alt skips the snap), dragging moves it with a guide line and position tooltip, dragging off the ruler clears it; markers draw per kind and mirror for RTL; one `para.tabs` call and one undo step per gesture | @@ -616,6 +627,7 @@ Imported Word 97–2003 `.doc`/`.dot` files now ask for a supported DOCX target | 2026-11-07 | Page Setup also bounds the unfocused margin display after a long numeric paste; the accepted value is retained (#5650). | | 2026-11-05 | Page Setup's margin, paper-size and document-grid number boxes scroll long text inside the field instead of enlarging the dialog (#5650). Readiness estimates unchanged. | | 2026-10-29 | Print Markup discovers comment balloon anchors in one forward paragraph-object walk; anchor positions, filtering and the existing cap stay unchanged (#3614) | +| 2026-10-29 | PDF figure tagging reuses requested paragraph prefixes within each export (#3614); alternative text, decorative roles and drawing/page order stay unchanged. Synthetic export scaling and tag/persistence controls; readiness estimates unchanged. | | 2026-10-26 | Spelling & Grammar opens a right-side Proofing task pane observed in Word for Windows: sentence context, directly clickable suggestion cards and ignore/dictionary actions. Current-story traversal and stale-target checks are retained. Right-click keeps its compact menu. | | 2026-10-26 | View › Window across the native windows (#322): Arrange All, View Side by Side, Synchronous Scrolling | | 2026-10-22 | Documents that keep content in another format (`w:altChunk`: a web page, RTF, text or another Word document, as generators and mail-merge tools write them) show it where it stands, as Word does, instead of leaving it out; one such file in the docxide-pdf corpus opened as an empty page and now matches Word's 8 pages. `.mht` web archives open, and web pages open the way Word opens them (style sheets, paragraph margins, Times New Roman, single lines, automatic spacing). Insert › Text from File keeps the inserted file's pictures | @@ -949,6 +961,8 @@ Imported Word 97–2003 `.doc`/`.dot` files now ask for a supported DOCX target | 2026-10-07 | v0.1.0 released; contributor credits in About (#6) | | 2026-10-06 | Layout arc: wrap around floats, text boxes, page borders, line numbers, row splitting, drop caps, hyphenation, comment balloons; release pipeline for every platform; first estimate (~62% real feature parity, 120–150 h to 100%) | | 2026-10-05 | M0–M12 first versions: model, layout, render, engine with 200+ commands, Word-style UI, DOCX I/O, PDF and other formats, references, review, mailings, CLI, MCP, web | +| 2026-10-19 | Mixed-direction lines: Latin text with digits, hyphens, spaces, full stops and commas after a Persian or Arabic word reads as typed ("2-naphthol", "Windows 11"), as in Word, in right-to-left and left-to-right paragraphs; a combining mark at the end of the Persian or Arabic word stays with its letter (#2150). | +| 2026-10-23 | A recipient list over what it keeps is refused while it is read: 1,000 columns, 2 M cells (its records times its widest record) and 64 MiB of cell text, so a hostile file is never built and then cut. | Footer page-table height and body wrapping are corrected. Other pagination gaps remain open. @@ -957,6 +971,7 @@ Quoted field escapes are interpreted like Word, and body `PAGE` fields use their Section page-numbering settings preserve `w:chapStyle` values across the full unsigned-byte range. MATH glyphs that reference the same construction now share its immutable variants and assembly data (#3630). Glyph mappings, values and the existing partial-record fallback stay unchanged. Repeated glyph IDs keep their last valid reference without retaining superseded constructions. Distinct overlapping constructions and assembly-only sharing remain separate. +- 2026-10-15: Design › Paragraph Spacing presets update built-in paragraph styles, so existing styled paragraphs follow the preset; custom paragraph styles keep their own spacing (#1913). Readiness unchanged. - 2026-10-15: Find opens Navigation on Results; editing the query restores Results after manual Headings/Pages navigation. Typed and selected-text searches retain document contents (#2096). ## Revision history @@ -1217,6 +1232,7 @@ MATH glyphs that reference the same construction now share its immutable variant | 2026-10-20 | trivial | Progress log: the scrollbar page tip stays on one line (#3341) | | 2026-10-20 | trivial | Progress log: Times and Courier take their Windows counterparts' line spacing | | 2026-10-20 | trivial | Progress log: saving to a NAS share mounted by GVFS (#3003) | +| 2026-10-19 | trivial | Empty window (#3126): with no document open (Esc on the Start screen, File › Close), the page area says no document is open and offers Blank document, Browse… and Home; Home goes back to the Start screen without making a document | | 2026-10-19 | trivial | Progress log: Linux display server setting (#2184) | | 2026-10-19 | trivial | Progress log: the status bar's count can be words, characters or characters without spaces (#2797) | | 2026-10-19 | trivial | Text context menus include the existing formatting mini toolbar (#2959); paste options remain in PR #2599. Readiness estimates unchanged. | @@ -1541,6 +1557,8 @@ MATH glyphs that reference the same construction now share its immutable variant > 2026-10-23 · cu20we review follow-up: Only paragraph-relative box floats use the pre-spacing origin. Line-relative floats and page/margin fallbacks in cells and text boxes keep the text-top origin. Synthetic controls compare zero and 24 pt space-before across all four box contexts. New cap conversion helpers and regression tests document their contracts; readiness estimates unchanged. | 2026-11-12 | minor | Progress log: layout.fitOnePage condenses a multi-page document by one page while preserving typography hierarchy (#6433) | | 2026-11-03 | trivial | Progress log: a line breaks after a hyphen before a slash (#3408) | +| 2026-10-19 | trivial | Progress log: Latin text in right-to-left lines keeps its order (#2150) | +| 2026-10-30 | trivial | Progress log: Left and Right step into an equation next to the caret (#4138); readiness estimates unchanged | ### Format Painter integration refresh, 2026-10-30 diff --git a/apps/wordcraft-cli/src/main.rs b/apps/wordcraft-cli/src/main.rs index fe14ef4a09..436fccb924 100644 --- a/apps/wordcraft-cli/src/main.rs +++ b/apps/wordcraft-cli/src/main.rs @@ -36,9 +36,11 @@ USAGE: page can't be drawn or a picture is missing or undecodable (report on stderr, as for convert --strict) wordcraft-cli run [--file F | --template T] [--script FILE|-] [--cmd 'id={json}' …] - [--save OUT] [--page N] [--scale S] [--print] [--author NAME] + [--save OUT …] [--page N] [--scale S] [--print] [--author NAME] run commands headlessly, then save (--author names who tracked changes and comments are by). + Repeat --save OUT to write multiple outputs in order, + after any outputs from --script. PNG saves use --page (1-based, default 1) and --scale (default 2). --script runs a JSON file (- is stdin) first: {\"file\"?, \"template\"?, \"commands\": [{\"command\": id, @@ -632,6 +634,13 @@ fn run>(args: &[S]) -> Result<(), Failure> { } } validate_options("run", &rest, RUN_OPTIONS)?; + let mut cli_outputs = Vec::new(); + for (i, arg) in rest.iter().enumerate() { + if arg == "--save" { + let path = rest.get(i + 1).filter(|value| !value.is_empty() && !value.starts_with("--")).ok_or("run: --save requires a path")?; + cli_outputs.push(path.clone()); + } + } let page = parse_page_arg("run", &rest)?; let scale = parse_scale_arg("run", &rest)?; let password = password_from(&rest)?; @@ -680,7 +689,7 @@ fn run>(args: &[S]) -> Result<(), Failure> { i += 1; } } - let outputs: Vec = script.iter().flat_map(|c| c.save.iter().cloned()).chain(arg_value(&rest, "--save")).collect(); + let outputs: Vec = script.iter().flat_map(|c| c.save.iter().cloned()).chain(cli_outputs).collect(); // Check every output can be made before writing any, so a bad one leaves no half-done job. for out in &outputs { let parent = Path::new(out).parent().filter(|p| !p.as_os_str().is_empty()); @@ -1048,6 +1057,7 @@ fn launcher_profile_flag(args: &[OsString]) -> bool { } fn main() -> ExitCode { + wordcraft_engine::malloc_tuning::apply(); let args: Vec = std::env::args_os().skip(1).collect(); if launcher_profile_flag(&args) { eprintln!("wordcraft-cli: --launch-profile and --profile-root are the desktop app's Nightly bootstrap, not a CLI option"); diff --git a/apps/wordcraft-cli/src/tests.rs b/apps/wordcraft-cli/src/tests.rs index 29ef49dad2..def150bec6 100644 --- a/apps/wordcraft-cli/src/tests.rs +++ b/apps/wordcraft-cli/src/tests.rs @@ -564,6 +564,64 @@ fn script_builds_a_document_and_saves_docx_and_pdf_relative_to_the_script() { assert!(json.contains("Hello script") && json.contains("\"bold\":true")); } +#[test] +fn run_saves_each_cli_output_and_still_accepts_a_single_save() { + let dir = script_dir("cli-saves"); + let input = dir.join("in.docx"); + let docx = dir.join("out.docx"); + let pdf = dir.join("out.pdf"); + run(&args(&["run", "--template", "sample", "--save", &input.to_string_lossy()])).unwrap(); + run(&args(&["run", "--file", &input.to_string_lossy(), "--save", &docx.to_string_lossy(), "--save", &pdf.to_string_lossy()])).unwrap(); + assert_eq!(listed_text(&open(&docx, None).unwrap().doc).unwrap(), listed_text(&open(&input, None).unwrap().doc).unwrap()); + assert!(std::fs::read(pdf).unwrap().starts_with(b"%PDF")); +} + +#[test] +fn run_saves_script_and_cli_outputs() { + let dir = script_dir("mixed-saves"); + let script = write_script(&dir, r#"{"commands":["caret.docEnd"],"save":["script.txt","script.docx"]}"#); + let first = dir.join("cli.txt"); + let second = dir.join("cli.docx"); + run(&args(&["run", "--save", &first.to_string_lossy(), "--script", &script, "--save", &second.to_string_lossy()])).unwrap(); + for path in [dir.join("script.txt"), dir.join("script.docx"), first, second] { + assert!(path.is_file(), "{} was not written", path.display()); + } +} + +#[test] +fn run_rejects_a_missing_second_save_path_before_writing() { + let dir = script_dir("missing-save"); + let first = dir.join("first.docx"); + let first_path = first.to_string_lossy(); + for tail in [vec!["--save"], vec!["--save", "--print"], vec!["--save", ""]] { + let mut argv: Vec<&str> = vec!["run", "--save", &first_path]; + argv.extend(tail); + assert_eq!(run(&args(&argv)), Err("run: --save requires a path".into())); + assert!(!first.exists()); + } +} + +#[test] +fn run_preflights_script_and_cli_outputs_in_order_before_writing() { + let dir = script_dir("preflight-saves"); + let first = dir.join("first.docx"); + let invalid = dir.join("missing/later.docx"); + let last = dir.join("missing-too/last.docx"); + let mut script = write_script(&dir, r#"{"commands":["caret.docEnd"],"save":["missing-script/script.docx"]}"#); + let first_path = first.to_string_lossy(); + let invalid_path = invalid.to_string_lossy(); + let last_path = last.to_string_lossy(); + let argv = |script: &str| args(&["run", "--save", &first_path, "--save", &invalid_path, "--script", script, "--save", &last_path]); + let err = run(&argv(&script)).unwrap_err().to_string(); + assert!(err.contains("script.docx"), "{err}"); + assert!(!first.exists()); + + script = write_script(&dir, r#"{"commands":["caret.docEnd"],"save":["script.docx"]}"#); + let err = run(&argv(&script)).unwrap_err().to_string(); + assert!(err.contains("later.docx"), "{err}"); + assert!(!first.exists() && !dir.join("script.docx").exists()); +} + #[test] fn script_with_a_bad_output_writes_no_output() { let dir = script_dir("badout"); diff --git a/apps/wordcraft-cli/tests/it/main.rs b/apps/wordcraft-cli/tests/it/main.rs index 15e6a68665..931e05d06d 100644 --- a/apps/wordcraft-cli/tests/it/main.rs +++ b/apps/wordcraft-cli/tests/it/main.rs @@ -3,6 +3,8 @@ mod closed_stdout; mod convert_fields; mod convert_region; mod help; +#[cfg(all(target_os = "linux", target_env = "gnu"))] +mod malloc_tuning; mod mcp_roots; #[cfg(all(unix, not(target_os = "macos")))] mod non_utf8_args; diff --git a/apps/wordcraft-cli/tests/it/malloc_tuning.rs b/apps/wordcraft-cli/tests/it/malloc_tuning.rs new file mode 100644 index 0000000000..27920c5948 --- /dev/null +++ b/apps/wordcraft-cli/tests/it/malloc_tuning.rs @@ -0,0 +1,78 @@ +//! The CLI binary re-executes itself on Linux glibc with `MALLOC_TRIM_THRESHOLD_` fixed so freed +//! page/render buffers are returned to the OS while respecting caller-supplied values. + +use std::io::{BufRead, BufReader, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Command, Stdio}; +use std::sync::atomic::{AtomicUsize, Ordering}; + +use wordcraft_engine::malloc_tuning::{TRIM_THRESHOLD, TRIM_THRESHOLD_VAR}; + +struct TempDirs(PathBuf); + +impl TempDirs { + fn new(tag: &str) -> Self { + static NEXT: AtomicUsize = AtomicUsize::new(0); + let root = loop { + let n = NEXT.fetch_add(1, Ordering::Relaxed); + let dir = std::env::temp_dir().join(format!("wc-cli-malloc-{tag}-{}-{n}", std::process::id())); + match std::fs::create_dir(&dir) { + Ok(()) => break dir, + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {} + Err(e) => panic!("temp dir {}: {e}", dir.display()), + } + }; + std::fs::create_dir_all(root.join("in")).unwrap(); + std::fs::create_dir_all(root.join("out")).unwrap(); + Self(root) + } +} + +impl Drop for TempDirs { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.0); + } +} + +fn s(p: &Path) -> String { + p.to_string_lossy().into_owned() +} + +fn mcp_environ(tag: &str, set: Option<&str>) -> Vec { + let dirs = TempDirs::new(tag); + let mut cmd = Command::new(env!("CARGO_BIN_EXE_wordcraft-cli")); + for var in [TRIM_THRESHOLD_VAR, "MALLOC_MMAP_THRESHOLD_", "MALLOC_TOP_PAD_", "MALLOC_MMAP_MAX_", "MALLOC_ARENA_MAX", "GLIBC_TUNABLES"] { + cmd.env_remove(var); + } + if let Some(v) = set { + cmd.env(TRIM_THRESHOLD_VAR, v); + } + let mut child = cmd + .args(["mcp", "--automation-read-root", &s(&dirs.0.join("in")), "--automation-write-root", &s(&dirs.0.join("out"))]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + .unwrap(); + let mut stdin = child.stdin.take().unwrap(); + writeln!(stdin, r#"{{"jsonrpc":"2.0","id":1,"method":"ping"}}"#).unwrap(); + let mut reply = String::new(); + BufReader::new(child.stdout.take().unwrap()).read_line(&mut reply).unwrap(); + assert!(reply.contains(r#""id":1"#), "mcp answered after re-exec: {reply}"); + let environ = std::fs::read(format!("/proc/{}/environ", child.id())).unwrap(); + drop(stdin); + assert!(child.wait().unwrap().success()); + environ.split(|&b| b == 0).map(|e| String::from_utf8_lossy(e).into_owned()).collect() +} + +#[test] +fn sets_the_trim_threshold() { + let env = mcp_environ("default", None); + assert!(env.contains(&format!("{TRIM_THRESHOLD_VAR}={TRIM_THRESHOLD}")), "{env:?}"); +} + +#[test] +fn keeps_a_value_the_user_set() { + let env = mcp_environ("explicit", Some("999999")); + assert!(env.contains(&format!("{TRIM_THRESHOLD_VAR}=999999")), "{env:?}"); +} diff --git a/apps/wordcraft-web/src/host.rs b/apps/wordcraft-web/src/host.rs index 8f12cd4079..94f8e821a6 100644 --- a/apps/wordcraft-web/src/host.rs +++ b/apps/wordcraft-web/src/host.rs @@ -110,7 +110,7 @@ impl Bridge { fn listen(&self, intake: IntakeSender) { self.host.listen(move |message| { if let Message::Open { name, data } = message { - deliver_open(&intake, &name, &data); + deliver_open(&intake, name.as_deref().unwrap_or("document"), &data); } }); } @@ -119,7 +119,7 @@ impl Bridge { /// The file an open message carries, queued for the next frame like a dropped file. A host's file /// is untrusted input: an oversized one is refused before it is copied into the app's memory (the /// data's own length, not the host's claim). The crate has cleaned the name (and cut it to 255 -/// characters); a blank one comes as `document` and becomes `Document.docx`. +/// characters); a missing one comes as `None` and becomes `Document.docx`. fn deliver_open(intake: &IntakeSender, name: &str, data: &FileData) { let name = if name == "document" { DEFAULT_NAME } else { name }.to_string(); let FileData::Bytes(array) = data else { diff --git a/apps/wordcraft-web/src/prefs.rs b/apps/wordcraft-web/src/prefs.rs index 5ca6055e59..bdf68c90cf 100644 --- a/apps/wordcraft-web/src/prefs.rs +++ b/apps/wordcraft-web/src/prefs.rs @@ -13,14 +13,14 @@ pub fn open() -> (SharedSettings, craft::settings::LoadReport) { use std::time::Duration; use craft::settings::{LegacyFile, LocalStorageFiles, Location, OpenOptions, SettingsStore}; - use wordcraft_ui_egui::prefs::legacy_ui_json; + use wordcraft_ui_egui::prefs::legacy_ui_json_slots; /// Largest stored value read back (`localStorage` holds about 5 MB per site). const MAX_STORED: usize = 4 << 20; let options = OpenOptions::new(Location::Dir("wordcraft".into())) .files(Arc::new(LocalStorageFiles::new(MAX_STORED))) .debounce(Duration::ZERO) - .legacy(vec![LegacyFile { path: "wordcraft.ui".into(), parse: legacy_ui_json }]); + .legacy(vec![LegacyFile { paths: vec!["wordcraft.ui".into()], parse: legacy_ui_json_slots }]); let (store, report) = SettingsStore::open_with(options); (SharedSettings::new(store), report) } diff --git a/apps/wordcraft/Cargo.toml b/apps/wordcraft/Cargo.toml index b4dd178055..51de73f2b8 100644 --- a/apps/wordcraft/Cargo.toml +++ b/apps/wordcraft/Cargo.toml @@ -60,8 +60,14 @@ winresource = "0.1" # kAEOpenDocuments Apple event, which winit doesn't handle (#27). craft = { workspace = true, features = ["platform-apple-events", "menu"] } -[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies] +[target.'cfg(all(unix, not(any(target_os = "macos", target_os = "linux"))))'.dependencies] winit = { version = "0.30", default-features = false, features = ["x11"] } + +[target.'cfg(target_os = "linux")'.dependencies] +# Retain X11 fallback; draw Wayland client-side controls without bundled title fonts. +winit = { version = "0.30", default-features = false, features = ["x11", "wayland-csd-adwaita-notitle"] } + +[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies] # Check that the libraries winit's X11 backend opens are installed before choosing XWayland (see # `x11_libraries` in main.rs). Both are already in the build through winit's `x11` feature, at # these versions and with this feature. diff --git a/apps/wordcraft/src/main.rs b/apps/wordcraft/src/main.rs index 0fbbf3251f..7ee63a2c8b 100644 --- a/apps/wordcraft/src/main.rs +++ b/apps/wordcraft/src/main.rs @@ -492,6 +492,9 @@ fn main() -> eframe::Result { let updates_unsafe = start_over_failed.is_some(); #[cfg(not(target_os = "linux"))] let updates_unsafe = false; + // Before any thread or logger starts: re-exec on Linux glibc with MALLOC_TRIM_THRESHOLD_ + // fixed so large freed document/render buffers return to the OS. + wordcraft_engine::malloc_tuning::apply(); // First, so the panic hook (set once, by this call; the later one only gives it the crash-log // folder) and every start-up warning are recorded. let logger = logs::install(LogNames::new("wordcraft")); @@ -745,6 +748,15 @@ fn main() -> eframe::Result { } let spool = Spool::new(host.jobs_shared().clone()); let mut app = WordApp::new(session, services(spool.clone(), intake, nightly)).with_host(host).with_settings(settings.clone()); + // Drawn by the processor (WARP, llvmpipe; #2221), animations that follow the system stop. + if let Some(state) = &cc.wgpu_render_state { + let info = state.adapter.get_info(); + let software = info.device_type == eframe::wgpu::DeviceType::Cpu; + if software { + log::warn!("graphics: drawing in software on {} ({:?}): animations that follow the system are off", info.name, info.backend); + } + app.set_software_drawing(software); + } // PLAN: writer note 9 puts `with_settings` after `with_control`; it comes first here because // the region check below reads the saved region the settings apply. if std::env::var("WORDCRAFT_FILE_DIALOG").is_ok_and(|v| v.trim().eq_ignore_ascii_case("builtin")) { diff --git a/apps/wordcraft/src/prefs.rs b/apps/wordcraft/src/prefs.rs index 64d83e8a85..bc38e12cfe 100644 --- a/apps/wordcraft/src/prefs.rs +++ b/apps/wordcraft/src/prefs.rs @@ -10,7 +10,7 @@ use std::path::{Path, PathBuf}; use craft::settings::{LegacyFile, LoadReport, Location, OpenOptions, SettingsStore, SharedSettings, Source}; use craft::window::restore::Store; -use wordcraft_ui_egui::prefs::{Prefs, import_legacy_window, legacy_ui_json}; +use wordcraft_ui_egui::prefs::{Prefs, import_legacy_window, legacy_ui_json_slots}; /// The most of an old `ui.json` read for its window entry; the file is a few kilobytes. const LEGACY_LIMIT: u64 = 8 << 20; @@ -41,7 +41,7 @@ fn open_in(dir: Option, placement: &mut Store) -> (SharedSettings OpenOptions::new(Location::Memory), }; if let Some(dir) = &dir { - options = options.legacy(vec![LegacyFile { path: dir.join("ui.json"), parse: legacy_ui_json }]); + options = options.legacy(vec![LegacyFile { paths: vec![dir.join("ui.json")], parse: legacy_ui_json_slots }]); } let (store, report) = SettingsStore::::open_with(options); if let Source::Legacy(path) = &report.source { diff --git a/apps/wordcraft/tests/it/linux_decorations.rs b/apps/wordcraft/tests/it/linux_decorations.rs new file mode 100644 index 0000000000..e073ea54fa --- /dev/null +++ b/apps/wordcraft/tests/it/linux_decorations.rs @@ -0,0 +1,167 @@ +//! Integration test for Linux Wayland client-side window decoration controls (#5814, #5375). +//! +//! Ensures that on Linux, client-side window controls use font-free Adwaita vector paths +//! so the close button is rendered as a clean vector cross rather than a square fallback, +//! and that sctk-adwaita has proper license attribution in NOTICE without bundling font files. + +use std::path::Path; + +/// Strips an unquoted TOML `#` comment from a single line. +fn strip_toml_comment(line: &str) -> &str { + let mut in_double = false; + let mut in_single = false; + for (idx, ch) in line.char_indices() { + match ch { + '"' if !in_single => in_double = !in_double, + '\'' if !in_double => in_single = !in_single, + '#' if !in_double && !in_single => return &line[..idx], + _ => {} + } + } + line +} + +/// Extracts the comment-stripped body of a TOML table section by exact `[header]`. +fn toml_section(content: &str, header: &str) -> String { + let mut in_section = false; + let mut out = String::new(); + for raw_line in content.lines() { + let line = strip_toml_comment(raw_line).trim(); + if line.starts_with('[') && line.ends_with(']') { + if in_section { + break; + } + in_section = line == header; + continue; + } + if in_section && !line.is_empty() { + out.push_str(line); + out.push('\n'); + } + } + assert!(in_section, "expected target section {header} in apps/wordcraft/Cargo.toml"); + out +} + +/// Parses the `features = [...]` string array from the `winit = { ... }` dependency entry in a TOML section. +fn winit_features(section: &str) -> Vec<&str> { + let winit_start = section.find("winit").expect("target section must declare a winit dependency"); + let after_winit = §ion[winit_start..]; + let table_end = after_winit.find('}').expect("winit inline table must close with '}'"); + let winit_table = &after_winit[..=table_end]; + let features_start = winit_table.find("features").expect("winit dependency must declare features"); + let after_features = &winit_table[features_start..]; + let open_bracket = after_features.find('[').expect("winit features must open with '['"); + let after_open = &after_features[open_bracket + 1..]; + let close_bracket = after_open.find(']').expect("winit features must close with ']'"); + let array_body = &after_open[..close_bracket]; + array_body.split(',').map(|item| item.trim().trim_matches('"')).filter(|item| !item.is_empty()).collect() +} + +/// Verifies that `apps/wordcraft/Cargo.toml` enables `wayland-csd-adwaita-notitle` for Linux. +#[test] +fn linux_manifest_enables_wayland_csd_adwaita_notitle() { + let cargo_toml = Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml"); + let content = std::fs::read_to_string(&cargo_toml).expect("read apps/wordcraft/Cargo.toml"); + + let linux_section = toml_section(&content, "[target.'cfg(target_os = \"linux\")'.dependencies]"); + let linux_features = winit_features(&linux_section); + assert!( + linux_features.contains(&"x11") && linux_features.contains(&"wayland-csd-adwaita-notitle"), + "Linux winit dependency must enable x11 and wayland-csd-adwaita-notitle, got: {linux_features:?}" + ); + + let other_unix_section = toml_section(&content, "[target.'cfg(all(unix, not(any(target_os = \"macos\", target_os = \"linux\"))))'.dependencies]"); + let other_unix_features = winit_features(&other_unix_section); + assert!( + other_unix_features.contains(&"x11") && !other_unix_features.contains(&"wayland-csd-adwaita-notitle"), + "Non-Linux Unix winit dependency must enable x11 without wayland-csd-adwaita-notitle, got: {other_unix_features:?}" + ); +} + +/// Verifies that `NOTICE` documents sctk-adwaita and its MIT licence. +#[test] +fn notice_documents_sctk_adwaita_attribution() { + let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().and_then(Path::parent).expect("workspace root"); + let notice = std::fs::read_to_string(workspace_root.join("NOTICE")).expect("read NOTICE"); + assert!(notice.contains("Linux Wayland window decorations"), "NOTICE must include 'Linux Wayland window decorations'"); + assert!(notice.contains("sctk-adwaita"), "NOTICE must document sctk-adwaita"); + assert!(notice.contains("Bartłomiej Maryńczak"), "NOTICE must retain sctk-adwaita's author copyright"); +} + +/// Parses `[[package]]` entries from `Cargo.lock` as `(name, version, dependencies)`. +fn parse_lockfile_packages(lockfile: &str) -> Vec<(&str, &str, Vec<&str>)> { + lockfile + .split("[[package]]") + .skip(1) + .filter_map(|chunk| { + let mut name = None; + let mut version = None; + let mut deps = Vec::new(); + let mut in_deps = false; + for raw_line in chunk.lines() { + let line = raw_line.trim(); + if in_deps { + if line == "]" { + in_deps = false; + continue; + } + let dep = line.trim_end_matches(',').trim().trim_matches('"'); + if !dep.is_empty() { + deps.push(dep); + } + continue; + } + if let Some(rest) = line.strip_prefix("name = ") { + name = Some(rest.trim_matches('"')); + } else if let Some(rest) = line.strip_prefix("version = ") { + version = Some(rest.trim_matches('"')); + } else if line == "dependencies = [" { + in_deps = true; + } + } + Some((name?, version?, deps)) + }) + .collect() +} + +/// Verifies that WordCraft's resolved Linux `winit` -> `sctk-adwaita` dependency path in +/// `Cargo.lock` does not pull in any title-font renderer crates. +#[test] +fn cargo_lock_contains_font_free_sctk_adwaita() { + use std::collections::{HashSet, VecDeque}; + + let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().and_then(Path::parent).expect("workspace root"); + let lockfile = std::fs::read_to_string(workspace_root.join("Cargo.lock")).expect("read Cargo.lock"); + let packages = parse_lockfile_packages(&lockfile); + + let has_dep = |pkg_name: &str, target: &str| { + packages.iter().any(|(name, _, deps)| *name == pkg_name && deps.iter().any(|spec| spec.split_whitespace().next() == Some(target))) + }; + assert!(has_dep("winit", "sctk-adwaita"), "winit in Cargo.lock must depend on sctk-adwaita"); + + let mut queue = VecDeque::new(); + let mut visited = HashSet::new(); + for (idx, (name, _, _)) in packages.iter().enumerate() { + if *name == "sctk-adwaita" && visited.insert(idx) { + queue.push_back(idx); + } + } + assert!(!queue.is_empty(), "Cargo.lock must include sctk-adwaita"); + + let forbidden = ["fontdue", "ab_glyph", "cosmic-text", "crossfont"]; + while let Some(idx) = queue.pop_front() { + let (name, _, deps) = &packages[idx]; + assert!(!forbidden.contains(name), "sctk-adwaita's resolved dependency path must not include title-font renderer {name}"); + for spec in deps { + let mut parts = spec.split_whitespace(); + let dep_name = parts.next().expect("dependency name"); + let dep_ver = parts.next(); + for (next_idx, (cand_name, cand_ver, _)) in packages.iter().enumerate() { + if *cand_name == dep_name && dep_ver.is_none_or(|v| v == *cand_ver) && visited.insert(next_idx) { + queue.push_back(next_idx); + } + } + } + } +} diff --git a/apps/wordcraft/tests/it/main.rs b/apps/wordcraft/tests/it/main.rs index cfa99b937d..a412732dc3 100644 --- a/apps/wordcraft/tests/it/main.rs +++ b/apps/wordcraft/tests/it/main.rs @@ -2,5 +2,7 @@ mod appimage_env; mod control_arg; mod help; +#[cfg(target_os = "linux")] +mod linux_decorations; #[cfg(unix)] mod non_utf8_args; diff --git a/corpus/docx/README.md b/corpus/docx/README.md new file mode 100644 index 0000000000..71456ae45e --- /dev/null +++ b/corpus/docx/README.md @@ -0,0 +1,96 @@ +# DOCX corpus (local only) + +This directory is where a local, real-world DOCX corpus can live for the opt-in +`cargo xtask docx-corpus` harness. **The corpus is never committed.** `/corpus` is +git-ignored; only this README is tracked. Never commit Word-produced files, documents +you do not have the right to redistribute, or any proprietary template, theme, font +or image. Word-produced documents are useful locally, including ones you made +yourself, but they must stay untracked. + +## Populate it + +Put `.docx` files anywhere under this directory (subfolders are walked, symlinks are +skipped): + +```sh +mkdir -p corpus/docx/mine +cp ~/Documents/report.docx corpus/docx/mine/ +``` + +Useful sources for a local corpus: + +- documents you wrote yourself, exported from Word, Google Docs, LibreOffice or Pages; +- public-domain or openly licensed DOCX samples whose licence allows local testing; +- synthetic files generated by WordCraft (`wordcraft-cli run --template sample --save …`); +- deliberately broken files for the failure path (a text file renamed `.docx`, a + truncated ZIP, a package missing `word/document.xml`). + +Keep a note of where each file came from. If a corpus must be shared, share the +manifest and the harness report, not the documents. + +## Run it + +```sh +# The runner builds wordcraft-cli before every run (a no-op when it is current). +cargo xtask docx-corpus --dir corpus/docx +cargo xtask docx-corpus --dir corpus/docx --out target/docx-corpus/report.json +cargo xtask docx-corpus --dir corpus/docx --all-pages +cargo xtask docx-corpus --dir corpus/docx --timeout 120 --cli target/debug/wordcraft-cli +``` + +Options: + +| Option | Meaning | +|---|---| +| `--dir ` | corpus directory (required) | +| `--out ` | JSON report path (default `target/docx-corpus/report.json`); the Markdown summary is written beside it with an `.md` extension | +| `--all-pages` | render every page instead of only page 1 (capped at 2,000 pages per file) | +| `--timeout ` | per-child-process timeout, default 60, maximum 3,600 | +| `--cli ` | use a specific `wordcraft-cli` binary | +| `-h`, `--help` | usage | + +A missing or empty corpus directory is not an error: the command explains what is +missing and exits successfully. + +## What each file goes through + +Every `.docx` is handled in child `wordcraft-cli` processes, each with the timeout +above, so one hostile or hanging file cannot stop the run: + +1. **Open + inspect** — `wordcraft-cli info` gives page and word counts; `wordcraft-cli text` + gives the plain text baseline. +2. **Render** — page 1 to PNG (`--all-pages` renders every page). Images go to + `-artifacts/-/page-NNNN.png` beside the report. +3. **Save** — `wordcraft-cli convert` writes a temporary `.docx` copy under the system + temporary directory. +4. **Reopen + compare** — the copy is opened again for page count and plain text. The + temporary copy is then deleted. + +The report records file name, bytes, open time, page count, word count, render time, +round-trip time, rendered images, and every failure. Failures are classified as: + +| Kind | Meaning | +|---|---| +| `open` | the file could not be opened or inspected (invalid package, encrypted, timeout, oversized, …) | +| `render` | page rendering failed | +| `save` | saving the temporary copy failed | +| `reopen` | the saved copy could not be opened or its text read | +| `text_mismatch` | reopened plain text differs from the original | +| `page_count_delta` | reopened page count differs from the original | + +The JSON report is deterministic for the same corpus and arguments apart from the +timing fields: files are sorted by relative path, failure counts are always present, +and there is no timestamp. The Markdown summary is a short human-readable table. + +## Limits + +- This harness measures open/render/save/reopen and text/page stability. It does **not** + compare with Word's own rendering or page count, and it does not fix document bugs. + A Word-vs-WordCraft visual comparison is a separate task. +- PNG rendering is a smoke test that the page can be produced, not a fidelity score. +- Files are treated as hostile: recursion depth, file count, file size, render pages and + child output are capped, and symlinks are skipped. The caps are deliberately generous + for normal documents; a file above them is reported as a failure rather than skipped + silently. +- The corpus and its reports stay local. `target/` is git-ignored too, so reports do not + enter commits. diff --git a/craft-i18n.rev b/craft-i18n.rev index b91ff589cd..b790685cd3 100644 --- a/craft-i18n.rev +++ b/craft-i18n.rev @@ -1 +1 @@ -e56d26244bbac099bfd42e23fb12f78a4be418a7 +217f4130d7d3dbb21a160f23f6b0021918906cc0 diff --git a/crates/control-key/src/lib.rs b/crates/control-key/src/lib.rs index 90eccfda42..2d8cdbcb80 100644 --- a/crates/control-key/src/lib.rs +++ b/crates/control-key/src/lib.rs @@ -21,26 +21,32 @@ pub fn use_settings_dir(dir: PathBuf) -> Result<(), String> { /// an environment variable a child or a wrapper might have inherited. `WORDCRAFT_PROFILE_DIR` /// overrides the entire folder for isolated runs otherwise. pub fn settings_dir() -> Option { - if let Some(path) = CHOSEN.get() { + settings_dir_with(CHOSEN.get(), |k| std::env::var_os(k)) +} + +fn settings_dir_with(chosen: Option<&PathBuf>, mut env: impl FnMut(&str) -> Option) -> Option { + if let Some(path) = chosen { return Some(path.clone()); } - if let Some(path) = std::env::var_os("WORDCRAFT_PROFILE_DIR").filter(|p| !p.is_empty()) { + if let Some(path) = env("WORDCRAFT_PROFILE_DIR").filter(|p| !p.is_empty()) { return Some(PathBuf::from(path)); } - platform_settings_dir() + platform_settings_dir_for(env) } /// The platform's own folder, when nothing chose one (see [`settings_dir`]). +#[cfg(test)] fn platform_settings_dir() -> Option { + platform_settings_dir_for(|k| std::env::var_os(k)) +} + +fn platform_settings_dir_for(mut env: impl FnMut(&str) -> Option) -> Option { if cfg!(target_os = "macos") { - std::env::var_os("HOME").map(|h| PathBuf::from(h).join("Library/Application Support/WordCraft")) + env("HOME").map(|h| PathBuf::from(h).join("Library/Application Support/WordCraft")) } else if cfg!(windows) { - std::env::var_os("APPDATA").map(|a| PathBuf::from(a).join("WordCraft")) + env("APPDATA").map(|a| PathBuf::from(a).join("WordCraft")) } else { - std::env::var_os("XDG_CONFIG_HOME") - .map(PathBuf::from) - .or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config"))) - .map(|c| c.join("wordcraft")) + env("XDG_CONFIG_HOME").map(PathBuf::from).or_else(|| env("HOME").map(|h| PathBuf::from(h).join(".config"))).map(|c| c.join("wordcraft")) } } @@ -109,4 +115,26 @@ mod tests { assert_eq!(key_path(dir, 7981), dir.join("control-key.local-7981")); } } + + #[test] + fn settings_dir_is_the_apps_folder() { + let default_dir = settings_dir_with(None, |key| match key { + "HOME" | "APPDATA" | "XDG_CONFIG_HOME" => Some("/tmp/base".into()), + _ => None, + }) + .expect("settings_dir should return Some when platform env var is set"); + let default_name = default_dir.file_name().and_then(|n| n.to_str()).unwrap_or(""); + assert!(default_name == "wordcraft" || default_name == "WordCraft", "{}", default_dir.display()); + assert_eq!(settings_dir_with(None, |_| None), None); + + let override_dir = settings_dir_with(None, |key| (key == "WORDCRAFT_PROFILE_DIR").then(|| "/tmp/profile".into())); + assert_eq!(override_dir.as_deref(), Some(Path::new("/tmp/profile"))); + + let empty_override = settings_dir_with(None, |key| match key { + "WORDCRAFT_PROFILE_DIR" => Some("".into()), + "HOME" | "APPDATA" | "XDG_CONFIG_HOME" => Some("/tmp/base".into()), + _ => None, + }); + assert_eq!(empty_override, Some(default_dir)); + } } diff --git a/crates/doc/src/chart.rs b/crates/doc/src/chart.rs index 4132252af1..6ce2999a00 100644 --- a/crates/doc/src/chart.rs +++ b/crates/doc/src/chart.rs @@ -230,10 +230,26 @@ impl ChartAxis { pub const MAX_FMT: usize = 128; /// A number format code: control characters as spaces, ends trimmed, at most [`MAX_FMT`] -/// characters. +/// characters. A trailing space stays when it is part of the code: the character after `_`, +/// `*` or `\`, or text inside quotes. pub fn clean_fmt(s: &str) -> String { - let s: String = s.chars().take(MAX_FMT * 4).map(|c| if c.is_control() { ' ' } else { c }).collect(); - s.trim().chars().take(MAX_FMT).collect::().trim_end().to_string() + let chars: Vec = s.chars().take(MAX_FMT * 4).skip_while(|c| c.is_whitespace() || c.is_control()).take(MAX_FMT).collect(); + let mut keep = 0; + let mut quoted = false; + let mut operand = false; + for (i, &c) in chars.iter().enumerate() { + if !c.is_control() && (!c.is_whitespace() || operand || quoted) { + keep = i + 1; + } + if operand { + operand = false; + } else if c == '"' { + quoted = !quoted; + } else if !quoted && matches!(c, '_' | '*' | '\\') { + operand = true; + } + } + chars[..keep].iter().map(|&c| if c.is_control() { ' ' } else { c }).collect() } /// A chart WordCraft can edit. @@ -512,4 +528,37 @@ mod tests { spec.sanitize(); assert_eq!(spec.series[0].line_w, Some(20.0), "a wild width clamps to 20 pt"); } + + #[test] + fn format_keeps_a_trailing_space_that_is_an_operand() { + // `_`, `*` and `\` take the next character, so a final space after one is part of the code. + assert_eq!(clean_fmt("0_ "), "0_ "); + assert_eq!(clean_fmt("#,##0_ "), "#,##0_ "); + assert_eq!(clean_fmt("0* "), "0* "); + assert_eq!(clean_fmt("0\\ "), "0\\ "); + assert_eq!(clean_fmt("0_ \n "), "0_ "); + assert_eq!(clean_fmt("0\"a "), "0\"a ", "a space inside quotes is text"); + // Other spaces at the ends, and control characters, still go. + assert_eq!(clean_fmt(" 0.00 \t"), "0.00"); + assert_eq!(clean_fmt("0_\n"), "0_"); + assert_eq!(clean_fmt("0\"a\" "), "0\"a\""); + assert_eq!(clean_fmt("\\_ "), "\\_", "an escaped `_` takes no operand"); + assert_eq!(clean_fmt("0\u{1}0"), "0 0"); + assert_eq!(clean_fmt("_\u{1}"), "_"); + assert_eq!(clean_fmt(" \n "), ""); + let long = format!("{}_ ", "0".repeat(MAX_FMT - 2)); + assert_eq!(clean_fmt(&long), long, "a code of exactly MAX_FMT characters keeps its operand"); + + // Axis and series formats both go through the cleaner. + let mut a = ChartAxis { fmt: Some("0_ ".into()), ..Default::default() }; + a.sanitize(); + assert_eq!(a.fmt.as_deref(), Some("0_ ")); + let mut spec = ChartSpec { + series: vec![ChartSeries { name: "s".into(), values: vec![Some(1.0)], fmt: Some("#,##0_ ".into()), ..Default::default() }], + categories: vec!["a".into()], + ..Default::default() + }; + spec.sanitize(); + assert_eq!(spec.series[0].fmt.as_deref(), Some("#,##0_ ")); + } } diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index b03ab1690c..6b94a1a946 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -703,25 +703,44 @@ impl Document { } /// A drawing id no shape uses yet (for gluing a connector to a shape that has none). + /// + /// Returns one past the largest in-use shape id across the body, all secondary parts, and + /// footnote/endnote separator stories (walking nested groups and tables); if `u32::MAX` is + /// already in use, falls back via [`free_id`] to the smallest unused non-zero id (or `0` only + /// if every non-zero `u32` id is taken). pub fn next_shape_id(&self) -> u32 { - let mut max = 0u32; + let mut largest: Option = None; + let mut used: Vec = Vec::new(); + let mut record = |id: u32| { + if id != 0 { + largest = largest.max(Some(id)); + used.push(id); + } + }; let mut see = |o: &InlineObject| match o { - InlineObject::Shape { extra, .. } => max = max.max(extra.id), + InlineObject::Shape { extra, .. } => record(extra.id), InlineObject::Group { children, .. } => { - for c in children { - if let InlineObject::Shape { extra, .. } = &c.obj { - max = max.max(extra.id); + let mut todo: Vec<&InlineObject> = children.iter().map(|c| &c.obj).collect(); + while let Some(obj) = todo.pop() { + match obj { + InlineObject::Shape { extra, .. } => record(extra.id), + InlineObject::Group { children, .. } => todo.extend(children.iter().map(|c| &c.obj)), + _ => {} } } } _ => {} }; - for blocks in std::iter::once(&self.body).chain(self.parts.values().map(|p| &p.blocks)) { + let sep_stories = [&self.footnote_separators, &self.endnote_separators] + .into_iter() + .flat_map(|s| [&s.separator, &s.continuation_separator, &s.continuation_notice]) + .flatten(); + for blocks in std::iter::once(&self.body).chain(self.parts.values().map(|p| &p.blocks)).chain(sep_stories) { for b in blocks { edit::each_para(b, 0, &mut |p| p.objects.iter().for_each(&mut see)); } } - max.saturating_add(1).max(1) + free_id(largest, used.into_iter(), 1).unwrap_or(0) } /// Change every inline object in every story (paragraphs inside tables too), copying only @@ -798,7 +817,10 @@ impl Document { stories.extend(self.parts.values_mut().map(|p| &mut p.blocks)); for blocks in stories { for b in blocks.iter_mut() { - edit::each_para_mut(Arc::make_mut(b), 0, &mut Paragraph::normalize); + edit::each_para_mut(Arc::make_mut(b), 0, &mut |p: &mut Paragraph| { + p.normalize(); + p.reconcile_objects(); + }); } } } diff --git a/crates/doc/src/para.rs b/crates/doc/src/para.rs index 0ed90870b1..7e2104de8c 100644 --- a/crates/doc/src/para.rs +++ b/crates/doc/src/para.rs @@ -340,6 +340,72 @@ impl Paragraph { self.runs = out; } + /// Make the objects match the U+FFFC markers one to one (files lie): drop surplus objects, + /// and remove markers past the last object. Runs must already cover the text. + /// + /// One scan finds the unmatched markers, one pass removes them and the runs and objects are + /// fixed up once, so the cost is linear in the paragraph however many markers are unmatched. + /// There is no cap on the markers: stopping early would leave markers without objects. + pub fn reconcile_objects(&mut self) { + let keep = self.objects.len(); + // Byte offsets of the unmatched markers (every marker after the first `keep`), ascending. + let mut seen = 0usize; + let mut drop: Vec = Vec::new(); + for (i, _) in self.text.match_indices(OBJ) { + crate::work::steps(1); + if seen >= keep { + drop.push(i); + } + seen += 1; + } + if self.objects.len() > seen { + self.objects.truncate(seen); + self.touch(); + } + if drop.is_empty() { + return; + } + let w = OBJ.len_utf8(); + if self.text.len() == drop.len() * w { + // Emptying: the mark keeps the formatting of what was deleted (as `delete` does). + let revisions = (self.mark.ins, self.mark.del, self.mark.fmt_change.clone()); + let mut mark = self.props_of_char(0).clone(); + (mark.ins, mark.del, mark.fmt_change) = revisions; + self.mark = mark; + } + // Shrink the runs: each removed marker takes `w` bytes off the run that holds it. + let mut d = 0usize; + let mut start = 0usize; + for r in &mut self.runs { + crate::work::steps(1); + let re = start + r.len; + let mut cut = 0usize; + while let Some(&off) = drop.get(d) { + crate::work::steps(1); + if off >= re { + break; + } + if off >= start { + cut += w; + } + d += 1; + } + start = re; + r.len -= cut.min(r.len); + } + let mut out = String::with_capacity(self.text.len() - drop.len() * w); + // The pieces between markers; marker `k` sits before piece `k + 1` and stays if matched. + for (k, piece) in self.text.split(OBJ).enumerate() { + if k > 0 && k <= keep { + out.push(OBJ); + } + out.push_str(piece); + } + self.text = out; + self.normalize(); + self.touch(); + } + /// Delete `a..b` (bytes). Objects inside are removed. pub fn delete(&mut self, a: usize, b: usize) -> Result<()> { let (a, b) = (a.min(b), a.max(b)); @@ -553,7 +619,8 @@ impl Paragraph { /// The word around `off` (double-click): (start, end) without trailing space. pub fn word_at(&self, off: usize) -> (usize, usize) { let off = self.clamp(off); - let is_w = |c: char| crate::bidi::is_word_char(c); + // Word's word unit takes a typographic apostrophe (’) like `'`, at either end too (#6517). + let is_w = |c: char| crate::bidi::is_word_char(c) || c == '’'; let mut a = off; for (i, c) in self.text.get(..off).unwrap_or("").char_indices().rev() { if !is_w(c) { @@ -786,6 +853,21 @@ mod tests { assert_eq!(p.prev_boundary(0), 0); } + #[test] + fn word_at_takes_a_typographic_apostrophe_like_a_straight_one() { + // Byte offsets: `’` is three bytes. Word: `don’t ` (#6517). + let p = Paragraph::with_text("don’t stop", CharProps::default()); + assert_eq!(p.word_at(1), (0, 8)); + assert_eq!(p.word_at(2), (0, 8)); + let p = Paragraph::with_text("the dogs’ bone", CharProps::default()); + assert_eq!(p.word_at(5), (4, 12)); + let p = Paragraph::with_text("’tis here", CharProps::default()); + assert_eq!(p.word_at(3), (0, 7)); + assert_eq!(p.word_at(4), (0, 7)); + let p = Paragraph::with_text("well-known", CharProps::default()); + assert_eq!(p.word_at(1), (0, 4)); + } + proptest::proptest! { #[test] fn edits_keep_runs_consistent(ops in proptest::collection::vec((0u8..4, 0usize..40, 0usize..40, "[a-zé ]{0,5}"), 0..40)) { diff --git a/crates/doc/src/para/inline_object.rs b/crates/doc/src/para/inline_object.rs index c33eb078e4..f5a0bc95c5 100644 --- a/crates/doc/src/para/inline_object.rs +++ b/crates/doc/src/para/inline_object.rs @@ -291,25 +291,47 @@ impl InlineObject { _ => None, } } - /// The text box stories this object shows: a text box's, or its group members'. + /// The text box stories this object shows: a text box's, or its group members' (nested groups + /// included, in member order). pub fn text_boxes(&self) -> Vec { match self { InlineObject::Shape { story: Some(id), .. } => vec![*id], - InlineObject::Group { children, .. } => children.iter().filter_map(|c| c.obj.text_box()).collect(), + InlineObject::Group { children, .. } => { + let mut out = Vec::new(); + let mut todo: Vec<&InlineObject> = children.iter().rev().map(|c| &c.obj).collect(); + while let Some(obj) = todo.pop() { + match obj { + InlineObject::Shape { story: Some(id), .. } => out.push(*id), + InlineObject::Group { children, .. } => { + todo.extend(children.iter().rev().map(|c| &c.obj)); + } + _ => {} + } + } + out + } _ => Vec::new(), } } - /// The text box story slots of this object and its group members, to repoint. + /// The text box story slots of this object and its group members (nested groups included, in + /// member order), to repoint. pub fn text_box_slots(&mut self) -> Vec<&mut Option> { match self { InlineObject::Shape { story, .. } => vec![story], - InlineObject::Group { children, .. } => children - .iter_mut() - .filter_map(|c| match &mut c.obj { - InlineObject::Shape { story, .. } => Some(story), - _ => None, - }) - .collect(), + InlineObject::Group { children, .. } => { + let mut out = Vec::new(); + let mut todo: Vec<&mut InlineObject> = children.iter_mut().rev().map(|c| &mut c.obj).collect(); + while let Some(obj) = todo.pop() { + match obj { + InlineObject::Shape { story, .. } => out.push(story), + InlineObject::Group { children, .. } => { + todo.extend(children.iter_mut().rev().map(|c| &mut c.obj)); + } + _ => {} + } + } + out + } _ => Vec::new(), } } diff --git a/crates/doc/src/review.rs b/crates/doc/src/review.rs index 5a0b96820a..949f55dbd5 100644 --- a/crates/doc/src/review.rs +++ b/crates/doc/src/review.rs @@ -42,11 +42,27 @@ pub struct Revision { /// insertion or deletion. #[serde(skip_serializing_if = "Option::is_none")] pub move_name: Option, + /// The change's UTC timestamp: from the file (`w16du:dateUtc`, where `date` is the local time + /// Word writes in `w:date`), or the time WordCraft stamped the change with. `None` when the + /// file doesn't give it. + #[serde(skip_serializing_if = "Option::is_none")] + pub date_utc: Option, } impl Revision { pub fn new(kind: RevisionKind, author: impl Into, date: impl Into) -> Revision { - Revision { kind, author: author.into(), date: date.into(), move_name: None } + Revision { kind, author: author.into(), date: date.into(), move_name: None, date_utc: None } + } + + /// A change made here: `date` is the local wall-clock time it was made at, as Word writes + /// `w:date`, and `date_utc` the same instant in UTC. + pub fn made_at(kind: RevisionKind, author: impl Into, date: impl Into, utc: impl Into) -> Revision { + Revision { kind, author: author.into(), date: date.into(), move_name: None, date_utc: Some(utc.into()) } + } + + /// The instant changes are grouped by: the UTC time when it is known, else `date`. + pub fn instant(&self) -> &str { + self.date_utc.as_deref().unwrap_or(&self.date) } } diff --git a/crates/doc/src/tests.rs b/crates/doc/src/tests.rs index 43cdedcb44..e7f9501652 100644 --- a/crates/doc/src/tests.rs +++ b/crates/doc/src/tests.rs @@ -440,6 +440,116 @@ fn prune_text_boxes_drops_only_unshown_ones() { assert_eq!(d.prune_text_boxes(), 0); } +/// A text-box shape (`story: Some(id)`) or plain shape (`story: None`) for nested-group tests. +fn test_shape(story: Option) -> InlineObject { + InlineObject::Shape { + kind: para::ShapeKind::TextBox, + w: 50.0, + h: 20.0, + fill: None, + stroke: None, + stroke_width: 0.0, + float: Default::default(), + story, + freeform: None, + effects: Default::default(), + extra: Default::default(), + } +} + +/// A group holding `children`. +fn test_group(children: Vec) -> InlineObject { + InlineObject::Group { + w: 100.0, + h: 100.0, + float: Default::default(), + ch_w: 100.0, + ch_h: 100.0, + children: children.into_iter().map(|obj| para::GroupChild { x: 0.0, y: 0.0, obj }).collect(), + canvas: None, + } +} + +/// `obj` wrapped inside `levels` nested [`InlineObject::Group`]s. +fn nested_group(levels: usize, obj: InlineObject) -> InlineObject { + (0..levels).fold(obj, |inner, _| test_group(vec![inner])) +} + +#[test] +fn nested_group_text_boxes_are_collected_and_slots_repointed_in_order() { + let mut outer = test_group(vec![ + test_shape(Some(1)), + test_shape(None), + nested_group(1, test_shape(Some(2))), // depth 2 from outer + test_group(vec![nested_group(1, test_shape(Some(3))), test_shape(Some(4))]), // depth 3 and depth 2 + nested_group(39, test_shape(Some(5))), // depth 40 from outer + ]); + assert_eq!(outer.text_boxes(), vec![1, 2, 3, 4, 5]); + let slots = outer.text_box_slots(); + assert_eq!(slots.len(), 6); + for id in slots.into_iter().flatten() { + *id += 100; + } + assert_eq!(outer.text_boxes(), vec![101, 102, 103, 104, 105]); +} + +#[test] +fn prune_text_boxes_keeps_nested_group_boxes_and_drops_unreachable() { + let para_of = |t: &str| vec![para_block(Paragraph::with_text(t, CharProps::default()))]; + let mut d = Document::from_text("body"); + let depth2 = d.add_part(PartKind::TextBox, para_of("depth 2")); + let depth3 = d.add_part(PartKind::TextBox, para_of("depth 3")); + let deep = d.add_part(PartKind::TextBox, para_of("depth 40")); + let linked_live = d.add_part(PartKind::TextBox, para_of("linked follower")); + let orphan = d.add_part(PartKind::TextBox, para_of("unreachable")); + let orphan_nested = d.add_part(PartKind::TextBox, para_of("inside unreachable")); + + // Live link between two nested-group boxes and a dangling link to an unreachable box. + d.parts.get_mut(&depth2).unwrap().body.next = Some(linked_live); + d.parts.get_mut(&depth3).unwrap().body.next = Some(orphan); + + d.insert_object(&Pos::body(0, 0), nested_group(2, test_shape(Some(depth2))), &CharProps::default()).unwrap(); + d.insert_object(&Pos::body(0, 0), nested_group(3, test_shape(Some(depth3))), &CharProps::default()).unwrap(); + d.insert_object(&Pos::body(0, 0), nested_group(40, test_shape(Some(deep))), &CharProps::default()).unwrap(); + d.insert_object(&Pos::body(0, 0), nested_group(2, test_shape(Some(linked_live))), &CharProps::default()).unwrap(); + let at_orphan = Pos { story: StoryRef::Part(orphan), path: Path::top(0), off: 0 }; + d.insert_object(&at_orphan, nested_group(2, test_shape(Some(orphan_nested))), &CharProps::default()).unwrap(); + + assert_eq!(d.prune_text_boxes(), 2); + let kept: Vec = d.parts.keys().copied().collect(); + assert_eq!(kept, vec![depth2, depth3, deep, linked_live]); + assert_eq!(d.plain_text(StoryRef::Part(depth2)), "depth 2"); + assert_eq!(d.plain_text(StoryRef::Part(depth3)), "depth 3"); + assert_eq!(d.plain_text(StoryRef::Part(deep)), "depth 40"); + assert_eq!(d.parts.get(&depth2).unwrap().body.next, Some(linked_live), "live chain link stays"); + assert_eq!(d.parts.get(&depth3).unwrap().body.next, None, "dangling chain link is cleared"); + assert_eq!(d.prune_text_boxes(), 0); +} + +#[test] +fn prune_text_boxes_terminates_on_cyclic_nested_group_stories() { + let para_of = |t: &str| vec![para_block(Paragraph::with_text(t, CharProps::default()))]; + let mut d = Document::from_text("body"); + let a = d.add_part(PartKind::TextBox, para_of("a")); + let b = d.add_part(PartKind::TextBox, para_of("b")); + let dead_c = d.add_part(PartKind::TextBox, para_of("dead c")); + let dead_d = d.add_part(PartKind::TextBox, para_of("dead d")); + + let at = |id| Pos { story: StoryRef::Part(id), path: Path::top(0), off: 0 }; + // Reachable cycle: body -> nested group -> a -> nested group -> b -> nested group -> (a, b). + d.insert_object(&Pos::body(0, 0), nested_group(2, test_shape(Some(a))), &CharProps::default()).unwrap(); + d.insert_object(&at(a), nested_group(2, test_shape(Some(b))), &CharProps::default()).unwrap(); + d.insert_object(&at(b), nested_group(2, test_group(vec![test_shape(Some(a)), test_shape(Some(b))])), &CharProps::default()).unwrap(); + // Unreachable cycle: dead_c <-> dead_d through nested groups. + d.insert_object(&at(dead_c), nested_group(2, test_shape(Some(dead_d))), &CharProps::default()).unwrap(); + d.insert_object(&at(dead_d), nested_group(2, test_shape(Some(dead_c))), &CharProps::default()).unwrap(); + + assert_eq!(d.prune_text_boxes(), 2); + let kept: Vec = d.parts.keys().copied().collect(); + assert_eq!(kept, vec![a, b]); + assert_eq!(d.counted_stories(), vec![StoryRef::Body, StoryRef::Part(a), StoryRef::Part(b)]); +} + /// `blocks` in the only cell of `levels` tables, each nested in the next. fn nested_tables(levels: usize, blocks: Blocks) -> Blocks { (0..levels).fold(blocks, |inner, _| { @@ -818,3 +928,302 @@ fn missing_pictures_are_capped_deduplicated_and_not_content() { assert!(!serde_json::to_string(&d).unwrap().contains("p0")); assert_eq!(MissingPictureReason::ExternalTarget.label(), "external target"); } + +#[test] +fn normalize_runs_reconciles_objects_with_markers() { + let c = CharProps::default(); + let markers = |p: &Paragraph| p.text.chars().filter(|ch| *ch == '\u{FFFC}').count(); + let build = || { + let mut d = Document::from_text("abc"); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + p.insert_object(1, fs("A"), &c).unwrap(); + p.insert_object(5, fs("B"), &c).unwrap(); + d + }; + // More objects than markers (as a hand-edited .json can say): the surplus goes. + let mut d = build(); + d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().objects.push(fs("C")); + d.normalize_runs(); + let p = d.para(StoryRef::Body, &Path::top(0)).unwrap(); + assert_eq!((markers(p), p.objects.len()), (2, 2)); + assert_eq!(p.objects, vec![fs("A"), fs("B")]); + // More markers than objects: the unmatched marker goes, runs still cover the text. + let mut d = build(); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + p.text.push('\u{FFFC}'); + p.runs[0].len += 3; + d.normalize_runs(); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + assert_eq!((markers(p), p.objects.len()), (2, 2)); + assert_eq!(p.runs.iter().map(|r| r.len).sum::(), p.text.len()); + // Deleting the first marker keeps B on the second. + p.delete(1, 4).unwrap(); + assert_eq!(p.objects, vec![fs("B")]); + // The cost is linear: the markers and runs `reconcile_objects` walks (`crate::work`), not a + // timing. 8x the unmatched markers cost about 8x the steps, far more if each removal rescans. + let reconcile = |extra: usize| { + let mut p = Paragraph::default(); + p.objects = vec![fs("A")]; + p.text = format!("\u{FFFC}{}x", "\u{FFFC}".repeat(extra)); + p.runs = vec![Run { len: p.text.len(), props: c.clone() }]; + crate::work::count(|| { + p.reconcile_objects(); + assert_eq!(p.text, "\u{FFFC}x"); + std::hint::black_box(&p); + }) + }; + let (s1, s8) = (reconcile(2_000), reconcile(16_000)); + assert!(s1 > 0, "no steps counted, so the walk this test watches no longer counts them (crate::work)"); + let ratio = s8 as f64 / s1 as f64; + assert!(ratio <= 12.0, "8x the markers cost {ratio:.1}x the steps ({s1} -> {s8})"); +} + +#[test] +fn reconcile_objects_drops_many_unmatched_markers_in_one_pass() { + let c = CharProps::default(); + let mut d = Document::from_text(""); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + p.insert_object(0, fs("A"), &c).unwrap(); + p.insert_object(p.text.len(), fs("B"), &c).unwrap(); + let extra = 50_000; + // "x" followed by many unmatched markers around more text, in one run. + p.text = format!("\u{FFFC}x\u{FFFC}{}y{}z", "\u{FFFC}".repeat(extra), "\u{FFFC}".repeat(extra)); + p.runs = vec![Run { len: p.text.len(), props: c.clone() }]; + p.reconcile_objects(); + assert_eq!(p.text, "\u{FFFC}x\u{FFFC}yz"); + assert_eq!(p.objects, vec![fs("A"), fs("B")]); + assert_eq!(p.runs.iter().map(|r| r.len).sum::(), p.text.len()); +} + +#[test] +fn reconcile_objects_keeps_every_matched_object() { + let c = CharProps::default(); + let n = 100_050; + let mut d = Document::from_text(""); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + p.text = "\u{FFFC}".repeat(n); + p.objects = (0..n).map(|_| fs("A")).collect(); + p.runs = vec![Run { len: p.text.len(), props: c }]; + p.reconcile_objects(); + assert_eq!(p.objects.len(), n); + assert_eq!(p.text.matches('\u{FFFC}').count(), n); + assert_eq!(p.runs.iter().map(|r| r.len).sum::(), p.text.len()); +} + +#[test] +fn reconcile_objects_keeps_run_props_across_several_runs() { + let (plain, bold) = (CharProps::default(), CharProps { bold: Some(true), ..CharProps::default() }); + let italic = CharProps { italic: Some(true), ..CharProps::default() }; + let mut d = Document::from_text(""); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + p.objects = vec![fs("A")]; + // Runs: plain "ab" | bold "" (only unmatched, becomes empty) | italic "c" | plain "d". + let x = "\u{FFFC}"; + let parts = [ + (format!("a\u{FFFC}b{x}"), plain.clone()), + (format!("{x}{x}"), bold), + (format!("{x}c{x}"), italic.clone()), + ("d".to_string(), plain.clone()), + ]; + p.text = parts.iter().map(|(t, _)| t.as_str()).collect(); + p.runs = parts.iter().map(|(t, c)| Run { len: t.len(), props: c.clone() }).collect(); + p.reconcile_objects(); + assert_eq!(p.text, "a\u{FFFC}bcd"); + assert_eq!(p.objects, vec![fs("A")]); + let got: Vec<(usize, CharProps)> = p.runs.iter().map(|r| (r.len, r.props.clone())).collect(); + // "ab" plain (5 bytes: 1 + 3 + 1), "c" italic, "d" plain. + assert_eq!(got, vec![(5, plain.clone()), (1, italic), (1, plain)]); +} + +#[test] +fn reconcile_objects_marker_on_run_boundary_shrinks_the_right_run() { + let (plain, bold) = (CharProps::default(), CharProps { bold: Some(true), ..CharProps::default() }); + let mut d = Document::from_text(""); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + let x = "\u{FFFC}"; + // plain "ab" | bold "cd" : the marker is the first byte of the second run. + p.text = format!("ab{x}cd"); + p.runs = vec![Run { len: 2, props: plain.clone() }, Run { len: 2 + x.len(), props: bold.clone() }]; + p.reconcile_objects(); + assert_eq!(p.text, "abcd"); + let got: Vec<(usize, CharProps)> = p.runs.iter().map(|r| (r.len, r.props.clone())).collect(); + assert_eq!(got, vec![(2, plain), (2, bold)]); +} + +#[test] +fn reconcile_objects_all_unmatched_markers_empties_the_paragraph() { + let bold = CharProps { bold: Some(true), ..CharProps::default() }; + let mut d = Document::from_text(""); + let p = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + p.text = "\u{FFFC}".repeat(3); + p.runs = vec![Run { len: p.text.len(), props: bold.clone() }]; + p.mark = CharProps { ins: Some(7), ..CharProps::default() }; + p.reconcile_objects(); + assert_eq!(p.text, ""); + assert!(p.objects.is_empty()); + assert!(p.runs.is_empty()); + // The mark takes the deleted formatting but keeps its own revision. + assert_eq!(p.mark, CharProps { bold: Some(true), ins: Some(7), ..CharProps::default() }); +} + +fn shape_with_id(id: u32, story: Option) -> InlineObject { + InlineObject::Shape { + kind: para::ShapeKind::Rectangle, + w: 50.0, + h: 20.0, + fill: None, + stroke: None, + stroke_width: 0.0, + float: Default::default(), + story, + freeform: None, + effects: Default::default(), + extra: connector::ShapeExtra { id, ..Default::default() }, + } +} + +fn group_of(children: Vec) -> InlineObject { + InlineObject::Group { + w: 100.0, + h: 100.0, + float: Default::default(), + ch_w: 100.0, + ch_h: 100.0, + children: children.into_iter().map(|obj| para::GroupChild { x: 0.0, y: 0.0, obj }).collect(), + canvas: None, + } +} + +fn nested_group_of(depth: usize, leaf: InlineObject) -> InlineObject { + (0..depth).fold(leaf, |inner, _| group_of(vec![inner])) +} + +#[test] +fn next_shape_id_accounts_for_shapes_in_nested_groups() { + // Doubly-nested group carrying shape id 1: must not reissue id 1. + let mut d = Document::from_text("body"); + d.insert_object(&Pos::body(0, 0), nested_group_of(2, shape_with_id(1, None)), &CharProps::default()).unwrap(); + assert_eq!(d.next_shape_id(), 2); + + // Deeper nesting (5-level and 40-level groups) with mixed siblings. + d.insert_object( + &Pos::body(0, 0), + nested_group_of(5, group_of(vec![shape_with_id(42, None), nested_group_of(35, shape_with_id(99, None))])), + &CharProps::default(), + ) + .unwrap(); + assert_eq!(d.next_shape_id(), 100); + + // Nested group inside a secondary story (part). + let hdr = d.add_part(PartKind::Header, vec![para_block(Paragraph::with_text("hdr", CharProps::default()))]); + let at_hdr = Pos { story: StoryRef::Part(hdr), path: Path::top(0), off: 0 }; + d.insert_object(&at_hdr, nested_group_of(3, shape_with_id(150, None)), &CharProps::default()).unwrap(); + assert_eq!(d.next_shape_id(), 151); +} + +#[test] +fn next_shape_id_preserves_flat_group_and_ungrouped_allocation() { + let mut d = Document::from_text("body"); + assert_eq!(d.next_shape_id(), 1); + + // Ungrouped shapes (including id 0). + d.insert_object(&Pos::body(0, 0), shape_with_id(0, None), &CharProps::default()).unwrap(); + assert_eq!(d.next_shape_id(), 1); + d.insert_object(&Pos::body(0, 0), shape_with_id(3, None), &CharProps::default()).unwrap(); + d.insert_object(&Pos::body(0, 0), shape_with_id(7, None), &CharProps::default()).unwrap(); + assert_eq!(d.next_shape_id(), 8); + + // Flat (1-level) group. + d.insert_object(&Pos::body(0, 0), group_of(vec![shape_with_id(12, None), shape_with_id(4, None)]), &CharProps::default()).unwrap(); + assert_eq!(d.next_shape_id(), 13); + + // At u32::MAX, overflow falls back to an unused non-zero id rather than reissuing u32::MAX. + d.insert_object(&Pos::body(0, 0), nested_group_of(2, shape_with_id(u32::MAX, None)), &CharProps::default()).unwrap(); + let id = d.next_shape_id(); + assert_ne!(id, 0); + for used in [3, 4, 7, 12, u32::MAX] { + assert_ne!(id, used); + } + assert_eq!(id, 1); +} + +#[test] +fn next_shape_id_avoids_reissuing_u32_max_on_overflow() { + // Non-overflow boundary: u32::MAX - 1 still advances to u32::MAX. + let mut d = Document::from_text("body"); + d.insert_object(&Pos::body(0, 0), shape_with_id(u32::MAX - 1, None), &CharProps::default()).unwrap(); + assert_eq!(d.next_shape_id(), u32::MAX); + + // Once u32::MAX is in use inside a nested group, allocator must not reissue any in-use id. + let hdr = d.add_part(PartKind::Header, vec![para_block(Paragraph::with_text("hdr", CharProps::default()))]); + let at_hdr = Pos { story: StoryRef::Part(hdr), path: Path::top(0), off: 0 }; + d.insert_object(&Pos::body(0, 0), shape_with_id(1, None), &CharProps::default()).unwrap(); + d.insert_object(&at_hdr, nested_group_of(2, shape_with_id(2, None)), &CharProps::default()).unwrap(); + d.insert_object(&Pos::body(0, 0), nested_group_of(3, shape_with_id(u32::MAX, None)), &CharProps::default()).unwrap(); + + let in_use = [1, 2, u32::MAX - 1, u32::MAX]; + let first = d.next_shape_id(); + assert_ne!(first, 0); + assert!(!in_use.contains(&first), "reissued in-use shape id {first}"); + assert_eq!(first, 3); + + // Using the returned id advances to the next unused id rather than repeating it. + d.insert_object(&Pos::body(0, 0), nested_group_of(2, shape_with_id(first, None)), &CharProps::default()).unwrap(); + let second = d.next_shape_id(); + assert_ne!(second, 0); + assert_ne!(second, first); + assert!(!in_use.contains(&second), "reissued in-use shape id {second}"); + assert_eq!(second, 4); +} + +#[test] +fn next_shape_id_terminates_on_cyclic_nested_group_stories() { + // InlineObject::Group owns Vec by value (and unsafe is forbidden), so a cyclic + // in-memory Group tree cannot be constructed in safe Rust; mirror #8068 by constructing a + // cyclic text-box story graph through nested groups instead. + let para_of = |t: &str| vec![para_block(Paragraph::with_text(t, CharProps::default()))]; + let mut d = Document::from_text("body"); + let a = d.add_part(PartKind::TextBox, para_of("a")); + let b = d.add_part(PartKind::TextBox, para_of("b")); + let at = |id| Pos { story: StoryRef::Part(id), path: Path::top(0), off: 0 }; + + d.insert_object(&Pos::body(0, 0), nested_group_of(2, shape_with_id(5, Some(a))), &CharProps::default()).unwrap(); + d.insert_object(&at(a), nested_group_of(2, shape_with_id(10, Some(b))), &CharProps::default()).unwrap(); + d.insert_object(&at(b), nested_group_of(2, shape_with_id(25, Some(a))), &CharProps::default()).unwrap(); + + assert_eq!(d.next_shape_id(), 26); +} + +#[test] +fn next_shape_id_accounts_for_shapes_in_note_separators() { + let blocks_with = |obj: InlineObject| -> Blocks { + let mut p = Paragraph::with_text("sep", CharProps::default()); + p.insert_object(0, obj, &CharProps::default()).unwrap(); + vec![para_block(p)] + }; + + // A shape ID used only in a footnote separator story must not be reissued. + let mut d = Document::from_text("body"); + d.footnote_separators.separator = Some(blocks_with(shape_with_id(1, None))); + assert_eq!(d.next_shape_id(), 2); + + // Every footnote and endnote separator slot is walked, including nested groups and tables. + d.footnote_separators.continuation_separator = Some(blocks_with(nested_group_of(2, shape_with_id(2, None)))); + d.footnote_separators.continuation_notice = Some(nested_tables(1, blocks_with(shape_with_id(5, None)))); + assert_eq!(d.next_shape_id(), 6); + + d.endnote_separators.separator = Some(blocks_with(shape_with_id(9, None))); + assert_eq!(d.next_shape_id(), 10); + + d.endnote_separators.continuation_separator = Some(blocks_with(nested_group_of(3, shape_with_id(14, None)))); + assert_eq!(d.next_shape_id(), 15); + + // Overflow fallback also respects IDs held exclusively in note-separator stories. + d.endnote_separators.continuation_notice = Some(blocks_with(nested_group_of(2, shape_with_id(u32::MAX, None)))); + let allocated = d.next_shape_id(); + assert_ne!(allocated, 0); + for used in [1, 2, 5, 9, 14, u32::MAX] { + assert_ne!(allocated, used); + } + assert_eq!(allocated, 3); +} diff --git a/crates/docx/src/model_bridge.rs b/crates/docx/src/model_bridge.rs index 3f560de973..c2a4828706 100644 --- a/crates/docx/src/model_bridge.rs +++ b/crates/docx/src/model_bridge.rs @@ -177,6 +177,19 @@ fn glossary_value_from_shared( }) } +fn note_separators_from_shared( + source: craft_wordmodel::NoteSeparators, + graphics: &mut GraphicCache, +) -> Result { + let craft_wordmodel::NoteSeparators { separator, continuation_separator, continuation_notice } = source; + let mut blocks = |b: Option| b.map(|b| blocks_from_shared(b, graphics)).transpose(); + Ok(wordcraft_doc::NoteSeparators { + separator: blocks(separator)?, + continuation_separator: blocks(continuation_separator)?, + continuation_notice: blocks(continuation_notice)?, + }) +} + fn missing_pictures_from_shared(source: craft_wordmodel::MissingPictures) -> Result { let mut target = wordcraft_doc::MissingPictures::default(); target.truncated = source.truncated; @@ -239,8 +252,8 @@ pub fn from_shared_model(mut source: craft_wordmodel::Document) -> Result>()?; diff --git a/crates/docx/tests/it/fixtures.rs b/crates/docx/tests/it/fixtures.rs index 5663f751dd..da82e7155e 100644 --- a/crates/docx/tests/it/fixtures.rs +++ b/crates/docx/tests/it/fixtures.rs @@ -2444,6 +2444,36 @@ fn note_separators_and_continuation_notice_round_trip() { check(&wordcraft_docx::read(&out).unwrap()); } +/// A picture frame shape in a footnote or endnote separator opens as the same shape kind as it does +/// in the body, instead of failing the whole document. (The test name dates from when the body +/// opened this shape as a rectangle.) +#[test] +fn a_frame_shape_in_a_note_separator_reads_as_a_rectangle() { + let frame = r#""#; + let notes = |root: &str, item: &str| { + format!(r#"{frame}"#) + }; + let footnotes = notes("footnotes", "footnote"); + let endnotes = notes("endnotes", "endnote"); + let bytes = docx( + &format!("{frame}"), + &[("rId1", "footnotes", "footnotes.xml"), ("rId2", "endnotes", "endnotes.xml")], + &[("word/footnotes.xml", &footnotes), ("word/endnotes.xml", &endnotes)], + ); + let d = wordcraft_docx::read(&bytes).unwrap(); + let shapes = |p: &Paragraph| -> Vec<(ShapeKind, f32)> { + p.objects.iter().filter_map(|o| if let InlineObject::Shape { kind, w, .. } = o { Some((*kind, *w)) } else { None }).collect() + }; + let in_body = shapes(d.body[0].as_para().unwrap()); + assert_eq!(in_body.len(), 1, "{in_body:?}"); + assert_eq!(in_body[0].1, 40.0); + assert_eq!(in_body[0].0, ShapeKind::Frame); + for separators in [&d.footnote_separators, &d.endnote_separators] { + let sep = separators.separator.as_ref().unwrap()[0].as_para().unwrap(); + assert_eq!(shapes(sep), in_body); + } +} + /// Issue #534: East Asian number formats are read, labelled and written back as they were; a /// value the format doesn't define is decimal, and a level without `w:ind` has no indent. #[test] diff --git a/crates/docx/tests/it/roundtrip.rs b/crates/docx/tests/it/roundtrip.rs index 7bbcfb019b..8a63376bd4 100644 --- a/crates/docx/tests/it/roundtrip.rs +++ b/crates/docx/tests/it/roundtrip.rs @@ -316,7 +316,13 @@ fn styles_and_lists_round_trip() { #[test] fn tracked_style_definition_change_round_trips() { let mut d = Document::new(); - d.revisions.push(Revision { kind: RevisionKind::Format, author: "Ana".into(), date: "2026-10-17T10:00:00Z".into(), move_name: None }); + d.revisions.push(Revision { + kind: RevisionKind::Format, + author: "Ana".into(), + date: "2026-10-17T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); std::sync::Arc::make_mut(&mut d.styles).upsert(Style { id: "Mine".into(), name: "Mine".into(), @@ -1005,8 +1011,20 @@ fn toc_field_skips_nested_stories() { #[test] fn tracked_changes_round_trip() { let mut d = Document::new(); - d.revisions.push(Revision { kind: RevisionKind::Insert, author: "Alice".into(), date: "2026-05-01T10:00:00Z".into(), move_name: None }); - d.revisions.push(Revision { kind: RevisionKind::Delete, author: "Bob".into(), date: "2026-05-02T10:00:00Z".into(), move_name: None }); + d.revisions.push(Revision { + kind: RevisionKind::Insert, + author: "Alice".into(), + date: "2026-05-01T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); + d.revisions.push(Revision { + kind: RevisionKind::Delete, + author: "Bob".into(), + date: "2026-05-02T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); d.settings.track_changes = true; let ins = CharProps { ins: Some(0), ..Default::default() }; let del = CharProps { del: Some(1), bold: Some(true), ..Default::default() }; @@ -1034,8 +1052,20 @@ fn tracked_changes_round_trip() { fn tracked_equations_round_trip() { // Issue #6011: equations saved with tracked revision marks (w:ins / w:del) around math. let mut d = Document::new(); - d.revisions.push(Revision { kind: RevisionKind::Insert, author: "Alice".into(), date: "2026-05-01T10:00:00Z".into(), move_name: None }); - d.revisions.push(Revision { kind: RevisionKind::Delete, author: "Bob".into(), date: "2026-05-02T10:00:00Z".into(), move_name: None }); + d.revisions.push(Revision { + kind: RevisionKind::Insert, + author: "Alice".into(), + date: "2026-05-01T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); + d.revisions.push(Revision { + kind: RevisionKind::Delete, + author: "Bob".into(), + date: "2026-05-02T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); d.settings.track_changes = true; let ins = CharProps { ins: Some(0), ..Default::default() }; let del = CharProps { del: Some(1), ..Default::default() }; @@ -1089,8 +1119,20 @@ fn tracked_equations_round_trip() { fn nested_omath_para_revisions_read() { // Defensive reader check: w:ins and w:del nested inside m:oMathPara. let mut d = Document::new(); - d.revisions.push(Revision { kind: RevisionKind::Insert, author: "Ada".into(), date: "2026-05-01T10:00:00Z".into(), move_name: None }); - d.revisions.push(Revision { kind: RevisionKind::Delete, author: "Charles".into(), date: "2026-05-02T10:00:00Z".into(), move_name: None }); + d.revisions.push(Revision { + kind: RevisionKind::Insert, + author: "Ada".into(), + date: "2026-05-01T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); + d.revisions.push(Revision { + kind: RevisionKind::Delete, + author: "Charles".into(), + date: "2026-05-02T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); let doc_xml = r#"x+1y-1"#; let base = wordcraft_docx::write(&d).unwrap(); let bytes = replace_part(&base, "word/document.xml", doc_xml.as_bytes()); @@ -1108,8 +1150,20 @@ fn tracked_paragraph_marks_round_trip() { // Issue #229: an inserted / deleted paragraph mark is `w:ins` / `w:del` in the mark's // `w:rPr` (ECMA-376 §17.13.5.16, §17.13.5.15), alone or with mark formatting. let mut d = Document::new(); - d.revisions.push(Revision { kind: RevisionKind::Insert, author: "Alice".into(), date: "2026-05-01T10:00:00Z".into(), move_name: None }); - d.revisions.push(Revision { kind: RevisionKind::Delete, author: "Bob".into(), date: "2026-05-02T10:00:00Z".into(), move_name: None }); + d.revisions.push(Revision { + kind: RevisionKind::Insert, + author: "Alice".into(), + date: "2026-05-01T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); + d.revisions.push(Revision { + kind: RevisionKind::Delete, + author: "Bob".into(), + date: "2026-05-02T10:00:00Z".into(), + move_name: None, + date_utc: None, + }); let mut split = Paragraph::with_text("Owned ALPHA ", CharProps::default()); split.mark.ins = Some(0); let mut joined = Paragraph::with_text("Owned BETA", CharProps::default()); @@ -1863,7 +1917,7 @@ fn kitchen_sink() -> Document { let f = d.add_part(PartKind::Footnote, vec![para_block(Paragraph::with_text("Note", CharProps::default()))]); let c = d.add_part(PartKind::Comment, vec![para_block(Paragraph::with_text("Comment", CharProps::default()))]); d.comments.insert(3, Comment { author: "X".into(), part: c, ..Default::default() }); - d.revisions.push(Revision { kind: RevisionKind::Insert, author: "A".into(), date: String::new(), move_name: None }); + d.revisions.push(Revision { kind: RevisionKind::Insert, author: "A".into(), date: String::new(), move_name: None, date_utc: None }); d.last_section.headers.default = Some(h); let mut blocks: Blocks = Vec::new(); let mut p = para_runs(&[ diff --git a/crates/docx/tests/it/wordml2003_write.rs b/crates/docx/tests/it/wordml2003_write.rs index 848bac3ab0..0695e1a278 100644 --- a/crates/docx/tests/it/wordml2003_write.rs +++ b/crates/docx/tests/it/wordml2003_write.rs @@ -41,7 +41,7 @@ fn sample() -> Document { let foot = d.add_part(PartKind::Footnote, vec![para_block(Paragraph::with_text("Sown in May.", CharProps::default()))]); let com = d.add_part(PartKind::Comment, vec![para_block(Paragraph::with_text("Too short?", CharProps::default()))]); d.comments.insert(3, Comment { author: "Bo".into(), part: com, ..Default::default() }); - d.revisions.push(Revision { kind: RevisionKind::Insert, author: "Ada".into(), date: String::new(), move_name: None }); + d.revisions.push(Revision { kind: RevisionKind::Insert, author: "Ada".into(), date: String::new(), move_name: None, date_utc: None }); d.last_section.headers.default = Some(head); let mut p = Paragraph::new(); diff --git a/crates/engine/src/catalog.rs b/crates/engine/src/catalog.rs index fd659bdbf8..0e6c1f8bfd 100644 --- a/crates/engine/src/catalog.rs +++ b/crates/engine/src/catalog.rs @@ -298,6 +298,8 @@ Review|Language|Translate|review.translate Review|Language|Language|review.language Review|Comments|New Comment|review.newComment Review|Comments|Delete|review.deleteComment +Review|Comments|Delete All Comments in Document|review.deleteComment +Review|Comments|Delete All Resolved Comments|review.deleteComment Review|Comments|Previous|review.previousComment Review|Comments|Next|review.nextComment Review|Comments|Show Comments|review.comments diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 4c260d3c44..dadf831c59 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -210,14 +210,21 @@ pub fn new_revision(s: &mut Session, kind: RevisionKind) -> u32 { .iter() .enumerate() .rev() - .find(|(i, r)| r.kind == kind && r.author == s.author && r.date == date && r.move_name.is_none() && held != Some(*i as u32)) + .find(|(i, r)| r.kind == kind && r.author == s.author && r.instant() == date && r.move_name.is_none() && held != Some(*i as u32)) { return i as u32; } - s.doc.revisions.push(Revision { kind, author: s.author.clone(), date, move_name: None }); + s.doc.revisions.push(made_revision(kind, s.author.clone(), date)); (s.doc.revisions.len() - 1) as u32 } +/// A revision record for a change made at `utc` (ISO 8601, UTC): dated in local wall-clock time, +/// as Word writes `w:date`, with the UTC time beside it, so a save writes it as it is (#6851). +pub fn made_revision(kind: RevisionKind, author: String, utc: String) -> Revision { + let date = crate::io_ext::word_date(&utc, local_offset_secs).unwrap_or_else(|| utc.clone()); + Revision::made_at(kind, author, date, utc) +} + /// Whether the paragraph at `path` is followed by another paragraph in the same container (so /// its paragraph mark can be removed by joining the two). pub fn has_next_para(s: &Session, story: StoryRef, path: &wordcraft_doc::Path) -> bool { @@ -556,6 +563,10 @@ pub fn iso_from_unix_secs(secs: u64) -> String { /// Seconds since the Unix epoch (UTC): the system clock, or the browser's on the web. pub fn now_unix() -> u64 { + #[cfg(test)] + if let Some(now) = TEST_NOW.with(std::cell::Cell::get) { + return now; + } #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] { std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0) @@ -577,9 +588,23 @@ pub fn now_iso() -> String { /// 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 { + #[cfg(test)] + if let Some(zone) = TEST_ZONE.with(std::cell::Cell::get) { + return zone(unix); + } system_offset_secs(unix).clamp(-26 * 3600, 26 * 3600) } +#[cfg(test)] +thread_local! { + /// The clock [`now_unix`] reads on this thread in place of the system's, so a test can make + /// edits at the instants it needs. + pub static TEST_NOW: std::cell::Cell> = const { std::cell::Cell::new(None) }; + /// The zone [`local_offset_secs`] gives on this thread in place of the system's. CI runs on + /// UTC, where local time is UTC, so a test sets a zone that isn't to tell them apart. + pub static TEST_ZONE: std::cell::Cell i64>> = const { std::cell::Cell::new(None) }; +} + #[cfg(not(target_arch = "wasm32"))] fn system_offset_secs(unix: u64) -> i64 { use chrono::Offset; diff --git a/crates/engine/src/cmd/canvas.rs b/crates/engine/src/cmd/canvas.rs index 8e2edd957d..8124420ae5 100644 --- a/crates/engine/src/cmd/canvas.rs +++ b/crates/engine/src/cmd/canvas.rs @@ -362,10 +362,10 @@ fn copy_member(s: &mut Session, pos: &Pos, index: usize) -> CmdResult { if !copied { return Err(CmdError::Failed("the member vanished".into())); } - s.clipboard_text = f.clipboard_text(); - s.clip_history.push(&f, &s.clipboard_text); - s.clipboard = Some(f); - Ok(super::edit::copy_result(s)) + let text = f.clipboard_text(); + let r = super::edit::copy_result(s, &f, &text)?; + s.clip_history.push(&f, &text); + Ok(r) } /// Take member `index` out of the canvas at `pos`; the canvas stays selected. diff --git a/crates/engine/src/cmd/caret.rs b/crates/engine/src/cmd/caret.rs index 024deb9952..95feb3c6c6 100644 --- a/crates/engine/src/cmd/caret.rs +++ b/crates/engine/src/cmd/caret.rs @@ -1,7 +1,9 @@ //! Caret movement and selection. use serde_json::Value; -use wordcraft_doc::{Pos, StoryRef}; +use wordcraft_doc::math_edit::MathPos; +use wordcraft_doc::para::OBJ; +use wordcraft_doc::{InlineObject, Pos, StoryRef}; use wordcraft_layout::ViewMode; use super::{parse_pos, sel_result}; @@ -119,9 +121,31 @@ fn lr(s: &mut Session, v: &Value, is_left: bool) -> CmdResult { if bidi_para(s) { return visual_lr(s, v, is_left); } + if !extend(v) + && !s.math_left + && let Some(r) = into_equation(s, is_left) + { + return r; + } mv(s, v, if is_left { left } else { right }) } +/// Left/Right onto an equation opens it, at its end from the right and at its start from the +/// left, as in Word (#4138). Leaving it puts the caret on the far side, so the same arrow then +/// moves on instead of going back in. A caret.left/right that itself left an equation (sent +/// while editing one) moves on too. +fn into_equation(s: &mut Session, is_left: bool) -> Option { + let f = s.sel.focus.clone(); + let off = if is_left { f.off.checked_sub(OBJ.len_utf8())? } else { f.off }; + if !matches!(s.doc.para_at(&f)?.object_at(off), Some(InlineObject::Equation { .. })) { + return None; + } + s.sel = Selection::caret(Pos { off, ..f }); + s.goal_x = None; + s.pending = None; + Some(super::equation::edit_at(s, (!is_left).then(MathPos::default))) +} + /// Left/Right in bidirectional text: one caret position to the left or right on the screen. /// Past the line's visual end the caret goes to the neighbouring line in reading order (the /// previous line when moving toward the paragraph's start edge). @@ -276,7 +300,11 @@ fn page(s: &mut Session, v: &Value, dir: i32) -> CmdResult { } let Some(c) = l.caret_on(&from, s.page_hint) else { return sel_result(s) }; let np = if dir < 0 { c.page.saturating_sub(1) } else { (c.page + 1).min(l.pages.len().saturating_sub(1)) }; - let to = l.hit(np, c.x, c.top + 1.0, from.story).unwrap_or(from); + let to = if np == c.page { + if dir < 0 { s.doc.start_of(from.story) } else { s.doc.end_of(from.story) } + } else { + l.hit(np, c.x, c.top + 1.0, from.story).unwrap_or(from) + }; s.page_hint = np; apply(s, to, ext); sel_result(s) diff --git a/crates/engine/src/cmd/citations.rs b/crates/engine/src/cmd/citations.rs index f889790a56..ccdc826e3d 100644 --- a/crates/engine/src/cmd/citations.rs +++ b/crates/engine/src/cmd/citations.rs @@ -35,7 +35,7 @@ pub fn specs() -> Vec { vec![ CommandSpec::new("references.sources", "Manage Sources", "References › Citations & Bibliography", sources) .params(r#"{"add"?: Source, "remove"?: tag, "import"?: path (a Word bibliography file, `b:Sources` / `Sources.xml`)} → list"#), - CommandSpec::new("references.citation", "Insert Citation", "References › Citations & Bibliography", citation).params(r#"{"tag"?: string, "source"?: Source (added if new), "pages"?: string}"#), + CommandSpec::new("references.citation", "Insert Citation", "References › Citations & Bibliography", citation).params(r#"{"tag"?: string, "source"?: Source (added, or edited when its tag exists, and cited when no tag is given), "pages"?: string}"#), CommandSpec::new("references.citationStyle", "Style", "References › Citations & Bibliography", |s, v| { let st = p::str(v, "style").unwrap_or("APA"); let st = find_style(st).ok_or_else(|| { diff --git a/crates/engine/src/cmd/citations/sources.rs b/crates/engine/src/cmd/citations/sources.rs index 8cc68bd0bd..78ae48339c 100644 --- a/crates/engine/src/cmd/citations/sources.rs +++ b/crates/engine/src/cmd/citations/sources.rs @@ -37,22 +37,7 @@ fn auto_tag_base(src: &Source) -> String { /// document's sources. `import` reads a Word bibliography file (`b:Sources`, #2640). pub(super) fn sources(s: &mut Session, v: &Value) -> CmdResult { if let Some(a) = v.get("add") { - let mut src: Source = serde_json::from_value(a.clone()).map_err(|e| CmdError::Params(e.to_string()))?; - // A new source's tag is made from its author and year; an edit keeps the tag it has. - if src.tag.is_empty() { - src.tag = auto_tag(&s.doc, &src); - } - // Edit Source keeps the source's place in the list and refreshes its citations. - match s.doc.sources.iter().position(|x| x.tag == src.tag) { - Some(i) => { - if let Some(x) = s.doc.sources.get_mut(i) { - *x = src; - } - update_citations(s)?; - } - None => s.doc.sources.push(src), - } - s.touch(); + add_source(s, a)?; } if let Some(t) = p::str(v, "remove") { s.doc.sources.retain(|x| x.tag != t); @@ -63,6 +48,28 @@ pub(super) fn sources(s: &mut Session, v: &Value) -> CmdResult { Ok(serde_json::to_value(&s.doc.sources).unwrap_or(Value::Null)) } +/// Adds a source, or edits the one with its tag, and returns that tag (#7443). +fn add_source(s: &mut Session, a: &Value) -> Result { + let mut src: Source = serde_json::from_value(a.clone()).map_err(|e| CmdError::Params(e.to_string()))?; + // A new source's tag is made from its author and year; an edit keeps the tag it has. + if src.tag.is_empty() { + src.tag = auto_tag(&s.doc, &src); + } + let tag = src.tag.clone(); + // Edit Source keeps the source's place in the list and refreshes its citations. + match s.doc.sources.iter().position(|x| x.tag == src.tag) { + Some(i) => { + if let Some(x) = s.doc.sources.get_mut(i) { + *x = src; + } + update_citations(s)?; + } + None => s.doc.sources.push(src), + } + s.touch(); + Ok(tag) +} + /// The largest bibliography sources file imported from disk. #[cfg(not(target_arch = "wasm32"))] const MAX_SOURCES_FILE: u64 = 32 << 20; @@ -126,15 +133,16 @@ fn import_sources(s: &mut Session, path: &str) -> Result<(), CmdError> { } pub(super) fn citation(s: &mut Session, v: &Value) -> CmdResult { - if v.get("source").is_some() { - sources(s, &json!({"add": v.get("source")}))?; - } - let tag = match p::str(v, "tag") { - Some(t) => t.to_string(), - None => match v.get("source") { - Some(_) => s.doc.sources.last().map(|x| x.tag.clone()).unwrap_or_default(), - None => return Err(CmdError::Params("give `tag` or `source`".into())), - }, + // The source just added or edited is the one cited when no `tag` is given, wherever it sits + // in the list (#7443). + let added = match v.get("source") { + Some(a) => Some(add_source(s, a)?), + None => None, + }; + let tag = match (p::str(v, "tag"), added) { + (Some(t), _) => t.to_string(), + (None, Some(t)) => t, + (None, None) => return Err(CmdError::Params("give `tag` or `source`".into())), }; let src = s.doc.sources.iter().find(|x| x.tag == tag).cloned().ok_or_else(|| CmdError::Params(format!("no source `{tag}`")))?; let pages = p::str(v, "pages").unwrap_or("").to_string(); diff --git a/crates/engine/src/cmd/citations/tests.rs b/crates/engine/src/cmd/citations/tests.rs index b1fcdfede0..b9ba37ff19 100644 --- a/crates/engine/src/cmd/citations/tests.rs +++ b/crates/engine/src/cmd/citations/tests.rs @@ -597,6 +597,22 @@ fn editing_author_and_year_keeps_the_tag_and_updates_the_citation_text() { assert!(f[0].1.contains("Jones") && f[0].1.contains("2021"), "{:?}", f[0].1); } +#[test] +fn citing_an_edited_source_that_is_not_last_cites_that_source() { + let mut s = Session::new(wordcraft_doc::Document::new()); + s.run("references.sources", &json!({"add": src_of("Alice, Ann", "2000")})).unwrap(); + s.run("references.sources", &json!({"add": src_of("Bob, Ben", "2001")})).unwrap(); + let mut edited = src_of("Alice Edited, Ann", "2000"); + edited["tag"] = json!("Ali00"); + let r = s.run("references.citation", &json!({"source": edited})).unwrap(); + assert_eq!(r["tag"], "Ali00"); + let tags: Vec<_> = s.doc.sources.iter().map(|x| x.tag.as_str()).collect(); + assert_eq!(tags, ["Ali00", "Bob01"]); + let f = fields(&s); + assert_eq!(f[0].0, "CITATION Ali00"); + assert!(f[0].1.contains("Alice Edited") && f[0].1.contains("2000"), "{:?}", f[0].1); +} + #[test] fn a_new_sources_tag_is_three_letters_and_two_year_digits() { let mut s = Session::new(wordcraft_doc::Document::new()); diff --git a/crates/engine/src/cmd/column.rs b/crates/engine/src/cmd/column.rs index bb9263d17a..403b184e20 100644 --- a/crates/engine/src/cmd/column.rs +++ b/crates/engine/src/cmd/column.rs @@ -244,10 +244,10 @@ fn copy(s: &mut Session, segs: &[(Pos, Pos)]) -> CmdResult { rows.push(row_text(s, &a, &b)); blocks.push(Block::Para(para)); } - s.clipboard_text = rows.join("\n"); + let text = rows.join("\n"); let media = s.doc.media_of_blocks(&blocks); - s.clipboard = Some(Fragment { blocks, parts, media }); - Ok(super::edit::copy_result(s)) + let f = Fragment { blocks, parts, media }; + super::edit::copy_result(s, &f, &text) } /// Delete each row's piece (bottom up, so earlier positions stay valid) and leave the caret at diff --git a/crates/engine/src/cmd/controls.rs b/crates/engine/src/cmd/controls.rs index 8af16c9422..d7e5ef5404 100644 --- a/crates/engine/src/cmd/controls.rs +++ b/crates/engine/src/cmd/controls.rs @@ -279,6 +279,22 @@ fn content_base(s: &Session, r: &ControlRange) -> CharProps { content_props(&s.doc, &props) } +/// The formatting of what replaces a control's content: typed text, a list entry, a date or a +/// check box's mark. In place of the placeholder, that is the control's own run properties +/// (ECMA-376 §17.5.2.27), else the content's formatting without the placeholder style: the +/// showing placeholder's own character style is that style, whatever a producer called it (Word +/// localizes only the id; another program may localize the name too). In place of a value, it is +/// that value's formatting. +fn replacement_props(s: &Session, r: &ControlRange) -> CharProps { + if !r.control.showing_placeholder { + return content_base(s, r); + } + match &r.control.run_props { + Some(rp) => content_props(&s.doc, rp), + None => CharProps { style: None, ..content_base(s, r) }, + } +} + // --------------------------------------------------------------------------------------------- // Rules for typing and deleting @@ -327,14 +343,8 @@ pub fn prepare_edit(s: &mut Session) -> Result, CmdError> { if !r.control.showing_placeholder || !r.contains(&b) { return Ok(None); } - // Text typed in place of the placeholder takes the control's own run properties (Word, and - // ECMA-376 §17.5.2.27), else the content's formatting without the placeholder style. The - // showing placeholder's own character style is that style, whatever a producer called it - // (Word localizes only the id; another program may localize the name too). - let props = match &r.control.run_props { - Some(rp) => content_props(&s.doc, rp), - None => CharProps { style: None, ..content_base(s, &r) }, - }; + // Text typed in place of the placeholder takes the control's own run properties, as in Word. + let props = replacement_props(s, &r); s.sel = Selection { anchor: r.content_start(), focus: r.end.clone() }; if let Some(c) = s.doc.control_mut(&r.start) { c.showing_placeholder = false; @@ -666,7 +676,7 @@ fn toggle_check_box(s: &mut Session, v: &Value) -> CmdResult { } let now = p::bool(v, "value").unwrap_or(!checked); let (ch, font) = if now { (*checked_char, checked_font) } else { (*unchecked_char, unchecked_font) }; - let mut props = content_base(s, &r); + let mut props = replacement_props(s, &r); if !font.is_empty() { props.font = Some(font.clone()); } @@ -696,7 +706,7 @@ fn choose_item(s: &mut Session, v: &Value) -> CmdResult { return Err(CmdError::Params("give index, value or text".into())); }; let Some(item) = item.cloned() else { return Err(CmdError::Params("no such entry".into())) }; - let props = content_base(s, &r); + let props = replacement_props(s, &r); let end = set_content(s, &r, &item.display, &props)?; if let Some(c) = s.doc.control_mut(&r.start) { if let ControlKind::ComboBox { last_value, .. } | ControlKind::DropDown { last_value, .. } = &mut c.kind { @@ -716,7 +726,7 @@ fn set_date(s: &mut Session, v: &Value) -> CmdResult { } let (y, m, d) = p::str(v, "date").and_then(parse_date).ok_or_else(|| CmdError::Params("date: YYYY-MM-DD".into()))?; let text = format_date_value(format, y, m, d); - let props = content_base(s, &r); + let props = replacement_props(s, &r); let end = set_content(s, &r, &text, &props)?; if let Some(c) = s.doc.control_mut(&r.start) { if let ControlKind::Date { full_date, .. } = &mut c.kind { diff --git a/crates/engine/src/cmd/design.rs b/crates/engine/src/cmd/design.rs index 374661533c..c0b4ab3f1c 100644 --- a/crates/engine/src/cmd/design.rs +++ b/crates/engine/src/cmd/design.rs @@ -3,7 +3,7 @@ use serde_json::{Value, json}; use std::sync::Arc; use wordcraft_doc::props::{Border, BorderStyle, Borders, CharProps, LineSpacing, Rgb, TextColor}; -use wordcraft_doc::{Watermark, styles}; +use wordcraft_doc::{StyleKind, Watermark, styles}; use super::sel_result; use crate::{CmdError, CmdResult, CommandSpec, Session, p}; @@ -209,9 +209,16 @@ fn para_spacing(s: &mut Session, v: &Value) -> CmdResult { "double" => (0.0, 8.0, 2.0), _ => (0.0, 8.0, 1.15), }; - Arc::make_mut(&mut s.doc.styles).default_para.space_before = Some(before); - Arc::make_mut(&mut s.doc.styles).default_para.space_after = Some(after); - Arc::make_mut(&mut s.doc.styles).default_para.line_spacing = Some(LineSpacing::Multiple(line)); + let st = Arc::make_mut(&mut s.doc.styles); + let apply = |p: &mut wordcraft_doc::props::ParaProps| { + p.space_before = Some(before); + p.space_after = Some(after); + p.line_spacing = Some(LineSpacing::Multiple(line)); + }; + apply(&mut st.default_para); + for style in st.styles.iter_mut().filter(|style| style.builtin && style.kind == StyleKind::Paragraph) { + apply(&mut style.para); + } sel_result(s) } @@ -287,7 +294,7 @@ fn page_borders(s: &mut Session, v: &Value) -> CmdResult { }; let blocks: Vec = match p::str(v, "applyTo") { Some("document") => s.doc.sections().iter().map(|(end, _)| *end).collect(), - Some("section") | None => vec![s.sel.focus.path.0.first().copied().unwrap_or(0) as usize], + Some("section") | None => vec![super::page::section_end_of_focus(s)], Some(x) => return Err(CmdError::Params(format!("unknown `applyTo` `{x}`"))), }; for block in blocks { @@ -295,3 +302,34 @@ fn page_borders(s: &mut Session, v: &Value) -> CmdResult { } sel_result(s) } + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + use wordcraft_doc::{Document, Style}; + + #[test] + fn paragraph_spacing_preset_updates_builtin_styles_and_keeps_custom_styles() { + let mut s = Session::new(Document::new()); + Arc::make_mut(&mut s.doc.styles).styles.push(Style { + id: "CustomSpacing".into(), + name: "Custom Spacing".into(), + kind: StyleKind::Paragraph, + builtin: false, + para: wordcraft_doc::props::ParaProps { space_after: Some(24.0), ..Default::default() }, + ..Default::default() + }); + + s.run("design.paragraphSpacing", &json!({"value": "double"})).unwrap(); + + let normal = s.doc.styles.get("Normal").unwrap(); + assert_eq!(normal.para.line_spacing, Some(LineSpacing::Multiple(2.0))); + let heading = s.doc.styles.get("Heading1").unwrap(); + assert_eq!((heading.para.space_before, heading.para.space_after), (Some(0.0), Some(8.0))); + assert_eq!(heading.para.line_spacing, Some(LineSpacing::Multiple(2.0))); + let custom = s.doc.styles.get("CustomSpacing").unwrap(); + assert_eq!(custom.para.space_after, Some(24.0)); + assert_eq!(custom.para.line_spacing, None); + } +} diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 7c1b0b3478..f8a6dd2f50 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -208,29 +208,28 @@ fn copy_with(s: &mut Session, whole: Option<&Path>) -> CmdResult { None if a == b => return Ok(json!({"text": ""})), None => s.doc.copy_range(&a, &b), }; - s.clipboard_text = f.clipboard_text(); - s.clip_history.push(&f, &s.clipboard_text); - s.clipboard = Some(f); - Ok(copy_result(s)) + let text = f.clipboard_text(); + let r = copy_result(s, &f, &text)?; + s.clip_history.push(&f, &text); + Ok(r) } /// What Copy and Cut return: the clipboard's text, and the copy as HTML (equations as MathML, /// #816) and as RTF for the host to put on the system clipboard too, so other programs keep the /// formatting; and for a copy of one equation alone, its MathML (#1297). -pub(crate) fn copy_result(s: &mut Session) -> Value { - (s.clipboard_html, s.clipboard_rtf) = match &s.clipboard { - Some(f) => { - let mut d = f.to_document(); - d.styles = s.doc.styles.clone(); - if d.media.is_empty() { - d.media = s.doc.media.clone(); - } - (wordcraft_formats::html::export_fragment(&d), wordcraft_formats::rtf::export(&d)) - } - None => (String::new(), String::new()), - }; - let mut r = json!({"text": s.clipboard_text}); - for (k, v) in [("html", &s.clipboard_html), ("rtf", &s.clipboard_rtf)] { +/// +/// The copy goes on the clipboard whole or not at all: a copy whose HTML or RTF cannot be made +/// is refused, and the clipboard keeps what it held. +pub(crate) fn copy_result(s: &mut Session, f: &Fragment, text: &str) -> CmdResult { + let mut d = f.to_document(); + d.styles = s.doc.styles.clone(); + if d.media.is_empty() { + d.media = s.doc.media.clone(); + } + let html = wordcraft_formats::html::export_fragment(&d).map_err(|e| CmdError::Failed(format!("the copy cannot be exported as HTML: {e}")))?; + let rtf = wordcraft_formats::rtf::export(&d).map_err(|e| CmdError::Failed(format!("the copy cannot be exported as RTF: {e}")))?; + let mut r = json!({"text": text}); + for (k, v) in [("html", &html), ("rtf", &rtf)] { if !v.is_empty() { r[k] = json!(v); } @@ -239,10 +238,16 @@ pub(crate) fn copy_result(s: &mut Session) -> Value { // ("MathML" on Windows, `public.mathml.presentation` on macOS; #1297). Word looks for them // before anything else when it pastes; a copy with text around the equation doesn't offer // them, so pasting it keeps the text. - if let Some((linear, display)) = s.clipboard.as_ref().and_then(|f| f.sole_equation()) { + if let Some((linear, display)) = f.sole_equation() { r["mathml"] = json!(wordcraft_formats::mathml::linear_to_mathml(linear, display)); } - r + // The copy is on the clipboard now: its text, its fragment and its HTML and RTF flavours, + // all at once. + s.clipboard_text = text.to_string(); + s.clipboard = Some(f.clone()); + s.clipboard_html = html; + s.clipboard_rtf = rtf; + Ok(r) } /// Cut the selection, selected object, or whole table cells to the clipboard and remove it from the document. diff --git a/crates/engine/src/cmd/equation.rs b/crates/engine/src/cmd/equation.rs index eabab36848..f47964c1cd 100644 --- a/crates/engine/src/cmd/equation.rs +++ b/crates/engine/src/cmd/equation.rs @@ -261,6 +261,11 @@ fn insert_nodes_as_equation(s: &mut Session, nodes: Arg, v: &Value) -> CmdResult /// Starts editing the equation at the caret, materializing lazy nodes and clamping the requested /// position, and returns the equation and caret. fn edit(s: &mut Session, v: &Value) -> CmdResult { + edit_at(s, v.get("pos").and_then(|p| serde_json::from_value::(p.clone()).ok())) +} + +/// [`edit`] at `pos` in the equation, or at its end without one. +pub(super) fn edit_at(s: &mut Session, pos: Option) -> CmdResult { let at = equation_at_caret(s).ok_or_else(|| CmdError::Disabled("no equation at the caret".into()))?; let nodes = match s.doc.para_at(&at).and_then(|p| p.object_at(at.off)) { Some(InlineObject::Equation { math, linear, .. }) => { @@ -272,8 +277,7 @@ fn edit(s: &mut Session, v: &Value) -> CmdResult { } _ => return Err(CmdError::Failed("no equation there".into())), }; - let pos = - v.get("pos").and_then(|p| serde_json::from_value::(p.clone()).ok()).unwrap_or_else(|| MathPos::new(Vec::new(), me::units(&nodes))); + let pos = pos.unwrap_or_else(|| MathPos::new(Vec::new(), me::units(&nodes))); let Some(session) = crate::next_math_session() else { return Err(CmdError::Failed("no equation editing session available".into())); }; diff --git a/crates/engine/src/cmd/equation/tests.rs b/crates/engine/src/cmd/equation/tests.rs index e3eb384087..fda8e84522 100644 --- a/crates/engine/src/cmd/equation/tests.rs +++ b/crates/engine/src/cmd/equation/tests.rs @@ -59,6 +59,74 @@ fn structures_symbols_and_navigation() { assert!(s.math.is_none()); } +#[test] +fn left_and_right_step_into_an_equation_next_to_the_caret() { + let mut s = session(); + s.run("document.setText", &json!({"text": "ab\ncd"})).unwrap(); + let p0 = s.doc.start_of(s.sel.focus.story); + let p1 = Pos { path: s.doc.next_para(p0.story, &p0.path).unwrap(), ..p0.clone() }; + // An equation between "a" and "b", and another one between "c" and "d". + for p in [&p0, &p1] { + s.run("caret.set", &json!({"pos": Pos { off: 1, ..p.clone() }})).unwrap(); + s.run("insert.equation", &json!({"linear": "x+y", "edit": false})).unwrap(); + } + let after = 1 + OBJ.len_utf8(); + let editing = |s: &Session| s.math.as_ref().map(|m| (m.at.path.clone(), m.at.off, m.pos.clone())); + + // Right from "a|" enters the equation at its start. + s.run("caret.set", &json!({"pos": Pos { off: 1, ..p0.clone() }})).unwrap(); + s.run("caret.right", &json!({})).unwrap(); + assert_eq!(editing(&s), Some((p0.path.clone(), 1, MathPos::default()))); + // Leaving it to the right, the next Right goes on to the text, not back in. + for _ in 0..10 { + if s.math.is_none() { + break; + } + s.run("equation.move", &json!({"dir": "right"})).unwrap(); + } + assert_eq!((s.math.is_none(), s.sel.focus.off), (true, after)); + s.run("caret.right", &json!({})).unwrap(); + assert_eq!((s.math.is_none(), s.sel.focus.off), (true, after + 1)); + + // Left from just after the equation in the second paragraph enters it at its end. + s.run("caret.set", &json!({"pos": Pos { off: after, ..p1.clone() }})).unwrap(); + s.run("caret.left", &json!({})).unwrap(); + let end = MathPos::new(Vec::new(), me::units(&nodes_of(&s, &Pos { off: 1, ..p1.clone() }).unwrap())); + assert_eq!(editing(&s), Some((p1.path.clone(), 1, end))); + for _ in 0..10 { + if s.math.is_none() { + break; + } + s.run("equation.move", &json!({"dir": "left"})).unwrap(); + } + assert_eq!((s.math.is_none(), s.sel.focus.off), (true, 1)); + s.run("caret.left", &json!({})).unwrap(); + assert_eq!((s.math.is_none(), s.sel.focus.off), (true, 0)); + + // Shift+Right selects over the equation, as before. + s.run("caret.set", &json!({"pos": Pos { off: 1, ..p0.clone() }})).unwrap(); + s.run("caret.right", &json!({"extend": true})).unwrap(); + assert_eq!((s.math.is_none(), s.sel.anchor.off, s.sel.focus.off), (true, 1, after)); + + // caret.left/right sent while editing (the arrow keys go to equation.move instead) leave + // the equation and move on, as before, rather than opening the equation they land next to. + s.run("caret.set", &json!({"pos": Pos { off: after, ..p0.clone() }})).unwrap(); + s.run("equation.edit", &json!({})).unwrap(); + s.run("caret.left", &json!({})).unwrap(); + assert_eq!((s.math.is_none(), s.sel.focus.off), (true, 1)); + // With two equations side by side, Right from the first goes on past the second. + s.run("caret.set", &json!({"pos": Pos { off: after, ..p1.clone() }})).unwrap(); + s.run("insert.equation", &json!({"linear": "z", "edit": false})).unwrap(); + s.run("caret.set", &json!({"pos": Pos { off: 1, ..p1.clone() }})).unwrap(); + s.run("equation.edit", &json!({})).unwrap(); + s.run("caret.right", &json!({})).unwrap(); + assert_eq!((s.math.is_none(), s.sel.focus.off), (true, after + OBJ.len_utf8())); + // That holds only for the command that left the equation: the next Right opens one again. + s.run("caret.set", &json!({"pos": Pos { off: 1, ..p0.clone() }})).unwrap(); + s.run("caret.right", &json!({})).unwrap(); + assert_eq!(editing(&s), Some((p0.path.clone(), 1, MathPos::default()))); +} + #[test] fn numbering_conversion_and_display() { let mut s = session(); @@ -635,3 +703,24 @@ fn a_math_name_is_corrected_by_any_character_that_cannot_continue_it() { s.run("equation.type", &json!({"text": r"\alpha+"})).unwrap(); assert_eq!(linear(&s), r"\alpha+"); } + +/// Paste Formatting keeps an open equation open (matching other formatting commands and +/// `cmd::column`), whereas content-pasting commands leave the equation first. +#[test] +fn paste_formatting_keeps_an_open_equation_open() { + let mut s = session(); + s.run("text.insert", &json!({"text": "source "})).unwrap(); + s.run("select.text", &json!({"text": "source"})).unwrap(); + s.run("format.bold", &json!({})).unwrap(); + s.run("edit.copyFormat", &json!({})).unwrap(); + s.run("caret.docEnd", &json!({})).unwrap(); + s.run("insert.equation", &json!({"linear": "x"})).unwrap(); + let before = s.math.clone(); + assert!(before.is_some()); + + s.run("edit.pasteFormat", &json!({})).unwrap(); + assert_eq!(s.math, before, "edit.pasteFormat keeps the open equation open"); + + s.run("edit.pasteText", &json!({"text": "y"})).unwrap(); + assert!(s.math.is_none(), "edit.pasteText closes the open equation"); +} diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs index 13a352ae63..b7ac232031 100644 --- a/crates/engine/src/cmd/file.rs +++ b/crates/engine/src/cmd/file.rs @@ -94,9 +94,9 @@ pub fn specs() -> Vec { .pure(), CommandSpec::new("file.save", "Save", "File", save) .key("Mod+S / Shift+F12 / Alt+Shift+F2") - .params(r#"{"path"?: string, "password"?: string (encrypt this and later saves with it, as file.encrypt does), "markup"?: bool (Print Markup for a PDF, PNG, HTML, Markdown or text copy: comments shown; default file.printMarkup), "format"?: "wordml2003" (an .xml file as a Word 2003 XML Document) | "flatopc" (as a Word XML Document, the default; saving over a Word 2003 XML file keeps that format), "strict"?: bool (a .pdf or .png only: refuse, writing nothing, if a character can't be drawn or a picture is missing; see file.strictReport)}"#) + .params(r#"{"path"?: string (required with `copy`), "password"?: string (encrypt this and later saves with it, as file.encrypt does), "markup"?: bool (Print Markup for a PDF, PNG, HTML, Markdown or text copy: comments shown; default file.printMarkup), "format"?: "wordml2003" (an .xml file as a Word 2003 XML Document) | "flatopc" (as a Word XML Document, the default; saving over a Word 2003 XML file keeps that format), "strict"?: bool (a .pdf or .png only: refuse, writing nothing, if a character can't be drawn or a picture is missing; see file.strictReport), "copy"?: bool (write a copy at `path`, as File › Export does: the document keeps its own file, unsaved changes and save stamps; not with `password`)}"#) .pure(), - CommandSpec::new("file.saveAs", "Save As", "File", save_as).key(super::mac_or("F12 / Mod+Shift+S", "F12 / Alt+F2")).params(r#"{"path": string, "password"?: string, "markup"?: bool, "format"?: string (as file.save), "strict"?: bool (as file.save)}"#).pure(), + CommandSpec::new("file.saveAs", "Save As", "File", save_as).key(super::mac_or("F12 / Mod+Shift+S", "F12 / Alt+F2")).params(r#"{"path": string, "password"?: string, "markup"?: bool, "format"?: string (as file.save), "strict"?: bool (as file.save), "copy"?: bool (as file.save)}"#).pure(), // Pure: the password must not land in Repeat or a recorded macro, and it isn't an edit // to undo; it marks the document as changed itself. CommandSpec::new("file.encrypt", "Encrypt with Password", "File › Info › Protect Document", encrypt) @@ -393,6 +393,14 @@ fn encrypt(s: &mut Session, v: &Value) -> CmdResult { /// Executes `file.save`: writes the document or text to disk, preserving exact file text for /// unedited Markdown files, and updating session path and dirty state. fn save(s: &mut Session, v: &Value) -> CmdResult { + // A copy (File › Export, #6131) is written and nothing else: the document keeps its own file, + // its unsaved changes and its save stamps, so the next Save still goes to the original. + // It never falls back to the document's own file or opens the Save As picker (whose answer is + // an ordinary save that adopts the file). + let as_copy = p::bool(v, "copy") == Some(true); + if as_copy && p::str(v, "path").is_none() { + return Err(CmdError::Params("`copy` needs a `path`: the copy has to go somewhere".into())); + } let path = match p::str(v, "path").map(std::path::PathBuf::from).or_else(|| s.path.clone()) { Some(p) => p, None => { @@ -401,6 +409,9 @@ fn save(s: &mut Session, v: &Value) -> CmdResult { } }; check_strict_output(p::bool(v, "strict").unwrap_or(false), &path.to_string_lossy())?; + if as_copy && v.get("password").is_some_and(|pw| !pw.is_null()) { + return Err(CmdError::Params("`password` changes the document's own saves, so it can't come with `copy` (use file.encrypt)".into())); + } if let Some(pw) = v.get("password").filter(|pw| !pw.is_null()) { let Some(pw) = pw.as_str().filter(|pw| !pw.is_empty()) else { return Err(CmdError::Params("`password` must be a non-empty string (file.encrypt removes a password)".into())); @@ -443,11 +454,14 @@ fn save(s: &mut Session, v: &Value) -> CmdResult { Some(text) => crate::io::save_text_path(&path, text), None => crate::io::save_path_with(&path, copy.as_ref().unwrap_or(&s.doc), password, &opts), }; - if let Err(e) = written { - (s.doc.settings.zoom, s.doc.core.last_modified_by, s.doc.core.created, s.doc.core.modified, s.doc.core.revision) = before_stamp; - return Err(CmdError::Failed(e)); - } let encrypted = password.is_some() && crate::io::can_encrypt(&path.to_string_lossy()); + if written.is_err() || as_copy { + (s.doc.settings.zoom, s.doc.core.last_modified_by, s.doc.core.created, s.doc.core.modified, s.doc.core.revision) = before_stamp; + } + written.map_err(CmdError::Failed)?; + if as_copy { + return Ok(json!({"saved": true, "path": path.to_string_lossy(), "encrypted": encrypted, "copy": true})); + } // A save in a format that doesn't keep everything (plain text, Markdown, a page image) is a // copy, except over the document's own file: a note.txt opened and saved is saved (#2376). // A Markdown file saved as another one loses nothing its own save wouldn't: it moves there. diff --git a/crates/engine/src/cmd/fmt_revisions.rs b/crates/engine/src/cmd/fmt_revisions.rs index 6da100825c..a8aa1bfd29 100644 --- a/crates/engine/src/cmd/fmt_revisions.rs +++ b/crates/engine/src/cmd/fmt_revisions.rs @@ -53,11 +53,11 @@ impl Recorder<'_> { if let Some(r) = self.rid { return r; } - let found = self.revisions.iter().rposition(|r| r.kind == RevisionKind::Format && r.author == self.author && r.date == self.date); + let found = self.revisions.iter().rposition(|r| r.kind == RevisionKind::Format && r.author == self.author && r.instant() == self.date); let r = match found { Some(i) => i as u32, None => { - self.revisions.push(Revision { kind: RevisionKind::Format, author: self.author.clone(), date: self.date.clone(), move_name: None }); + self.revisions.push(crate::cmd::made_revision(RevisionKind::Format, self.author.clone(), self.date.clone())); self.revisions.len().saturating_sub(1) as u32 } }; diff --git a/crates/engine/src/cmd/format.rs b/crates/engine/src/cmd/format.rs index 6084116b60..44e3494d84 100644 --- a/crates/engine/src/cmd/format.rs +++ b/crates/engine/src/cmd/format.rs @@ -209,7 +209,8 @@ fn target(s: &Session) -> Option<(Pos, Pos)> { return Some((a, b)); } let p = s.doc.para_at(&a)?; - let is_w = |c: char| c.is_alphanumeric() || c == '\'' || c == '_'; + // Word takes a typographic apostrophe (’) like `'` here (#6517). + let is_w = |c: char| c.is_alphanumeric() || matches!(c, '\'' | '’' | '_'); let before = p.text.get(..a.off)?.chars().next_back(); let after = p.text.get(a.off..)?.chars().next(); if before.is_some_and(is_w) && after.is_some_and(is_w) { @@ -351,6 +352,16 @@ fn resolved(s: &Session) -> Vec { out } +/// Whether a toggle without a `value` turns its format on. A selection follows its first character +/// in document order, as Word does: one that starts formatted loses the format, all of it (#6516). +fn turns_on(s: &Session, has: impl Fn(&ResolvedChar) -> bool) -> bool { + let chars = resolved(s); + if !s.sel.is_collapsed() || selected_text_box(s).is_some() || column_rows(s).is_some() { + return !chars.first().is_some_and(has); + } + !chars.iter().all(has) +} + /// Bold as drawn: a run marked complex script (`w:cs`) or right to left (`w:rtl`) shows its /// complex-script bold. fn shown_bold(r: &ResolvedChar) -> bool { @@ -366,7 +377,7 @@ fn shown_italic(r: &ResolvedChar) -> bool { fn toggle(s: &mut Session, v: &Value, get: fn(&ResolvedChar) -> bool, set: fn(&mut CharProps, bool)) -> CmdResult { let on = match p::bool(v, "value") { Some(b) => b, - None => !resolved(s).iter().all(get), + None => turns_on(s, get), }; apply(s, &|c| set(c, on)) } @@ -376,7 +387,7 @@ fn underline(s: &mut Session, v: &Value) -> CmdResult { let on = match (p::bool(v, "value"), style) { (Some(b), _) => b, (None, Some(_)) => true, - (None, None) => !resolved(s).iter().all(|r| r.underline != Underline::None), + (None, None) => turns_on(s, |r| r.underline != Underline::None), }; let u = if on { style.unwrap_or(Underline::Single) } else { Underline::None }; apply(s, &|c| c.underline = Some(u)) diff --git a/crates/engine/src/cmd/index.rs b/crates/engine/src/cmd/index.rs index 17b62cbbe1..9864fab8ba 100644 --- a/crates/engine/src/cmd/index.rs +++ b/crates/engine/src/cmd/index.rs @@ -27,6 +27,7 @@ pub fn specs() -> Vec { r#"{"type"?: "indented|runIn", "columns"?: 1-4, "rightAlign"?: bool, "tabLeader"?: "dot|hyphen|underscore|none", "headings"?: bool (letter headings)} (replaces an existing index's settings)"#, ), CommandSpec::new("references.updateIndex", "Update Index", "References › Index", |s, _| { + check_index_reachable(s)?; super::citations::update_generated(s)?; sel_result(s) }), @@ -135,8 +136,67 @@ fn index_field(s: &Session) -> Option<(usize, String)> { }) } +/// Whether an INDEX field (a plain one or a range field, as Word files hold it) sits in the main +/// text's own paragraphs (`main`), or anywhere else a reader sees: a table cell, a text box, a +/// header or a footer in use. Stored headers and footers no page shows (a first-page header +/// while Different First Page is off) don't count. Only an index in the main text is rebuilt. +fn has_index(s: &Session, main: bool) -> bool { + s.doc.shown_stories().into_iter().any(|story| { + s.doc + .para_paths(story) + .iter() + .filter(|path| (story == StoryRef::Body && path.depth() == 0) == main) + .filter_map(|path| s.doc.para(story, path)) + .any(|p| { + p.objects.iter().any(|o| { + matches!(o, InlineObject::Field { instr, .. } | InlineObject::FieldStart { instr, .. } if FieldCode::parse(instr).name == "INDEX") + }) + }) + }) +} + +/// Refuses Insert and Update Index when the document has an index they can't rebuild, even beside +/// one in the main text, rather than adding a second index or reporting an update that left it +/// unchanged. +fn check_index_reachable(s: &Session) -> Result<(), CmdError> { + if has_index(s, false) { + return Err(CmdError::Failed( + "the index is in a table, text box, header or footer, where it can't be updated; move it into the main text, then use Update Index" + .into(), + )); + } + // A range-field index after text in its paragraph is not rebuilt either: Update Index only + // takes one that starts its paragraph. + if range_index_after_text(s) { + return Err(CmdError::Failed( + "the index follows text in its paragraph, where it can't be updated; put it at the start of its own paragraph in the main text".into(), + )); + } + Ok(()) +} + +/// Whether a main-text range-field INDEX has text before it in its paragraph. +fn range_index_after_text(s: &Session) -> bool { + s.doc.body.iter().filter_map(|b| b.as_para()).any(|p| { + p.objects_with_offsets().any(|(off, o)| { + matches!(o, InlineObject::FieldStart { instr, .. } if FieldCode::parse(instr).name == "INDEX") + && !p.text.get(..off).is_some_and(|t| t.chars().all(|c| c.is_whitespace() || c == wordcraft_doc::para::OBJ)) + }) + }) +} + fn insert_index(s: &mut Session, v: &Value) -> CmdResult { let instr = index_instr(v); + check_index_reachable(s)?; + // An index Word wrote as a range field is first made a plain field in its own paragraph, as + // Update Index makes it, so it takes the new settings rather than a second index being added + // beside it (#8034). + if index_field(s).is_none() && has_index(s, true) { + super::citations::update_generated(s)?; + if index_field(s).is_none() { + return Err(CmdError::Failed("the document already has an index; use Update Index to rebuild it".into())); + } + } match index_field(s) { Some((i, _)) => { // Settings for the index that is there: a new field code, then rebuild it. @@ -484,4 +544,157 @@ mod tests { let (i, _) = index_field(&s).unwrap(); assert_eq!(s.doc.body[i + 2].as_para().unwrap().props.tabs.as_ref().unwrap()[0].leader, TabLeader::Hyphen); } + + /// #3670: an index in a table cell or a text box (as imported documents have it) can't be + /// rebuilt where it is, so Insert and Update Index say so, and Insert Index doesn't add a + /// second index at the caret. + #[test] + fn an_index_outside_the_main_text_is_refused_not_doubled() { + let indexes = |s: &Session| { + std::iter::once(StoryRef::Body) + .chain(s.doc.parts.keys().map(|k| StoryRef::Part(*k))) + .flat_map(|story| s.doc.para_paths(story).into_iter().filter_map(move |path| s.doc.para(story, &path).cloned())) + .flat_map(|p| p.objects) + .filter(|o| matches!(o, InlineObject::Field { instr, .. } | InlineObject::FieldStart { instr, .. } if FieldCode::parse(instr).name == "INDEX")) + .count() + }; + for in_box in [false, true] { + let mut s = Session::new(wordcraft_doc::Document::from_text( + "Kilns are hot. +End.", + )); + s.run("select.text", &json!({"text": "Kilns"})).unwrap(); + s.run("references.markEntry", &json!({})).unwrap(); + s.run("caret.docEnd", &json!({})).unwrap(); + let at = if in_box { + s.run("insert.textBox", &json!({"text": "Box"})).unwrap(); + let id = s.doc.parts.iter().find(|(_, p)| p.kind == wordcraft_doc::PartKind::TextBox).map(|(id, _)| *id).unwrap(); + Pos { story: StoryRef::Part(id), path: Path::top(0), off: 0 } + } else { + s.run("insert.table", &json!({"rows": 1, "cols": 1})).unwrap(); + let cell = s.doc.para_paths(StoryRef::Body).into_iter().find(|path| path.depth() > 0).unwrap(); + Pos { story: StoryRef::Body, path: cell, off: 0 } + }; + // A range field, as a Word file holds its index. + let p = s.doc.para_mut(at.story, &at.path).unwrap(); + p.insert_object(0, InlineObject::FieldEnd, &CharProps::default()).unwrap(); + p.insert_object(0, InlineObject::FieldStart { instr: r#"INDEX \h "A""#.into(), locked: false, dirty: false }, &CharProps::default()) + .unwrap(); + s.run("caret.docEnd", &json!({})).unwrap(); + let r = s.run("references.index", &json!({"columns": 2})); + assert!(r.is_err(), "Insert Index with the index in a {}: {r:?}", if in_box { "text box" } else { "table" }); + assert_eq!(indexes(&s), 1, "INDEX fields after Insert Index"); + assert!(s.run("references.updateIndex", &json!({})).is_err(), "Update Index reports the index it can't rebuild"); + } + } + + /// #3670: an index in a table is refused even when the main text also has one, so the update + /// can't report success and leave the table's index as it was. + #[test] + fn an_index_in_a_table_is_refused_beside_one_in_the_main_text() { + let mut s = Session::new(wordcraft_doc::Document::from_text("Kilns are hot.")); + s.run("select.text", &json!({"text": "Kilns"})).unwrap(); + s.run("references.markEntry", &json!({})).unwrap(); + s.run("caret.docEnd", &json!({})).unwrap(); + s.run("references.index", &json!({})).unwrap(); + s.run("insert.table", &json!({"rows": 1, "cols": 1})).unwrap(); + let cell = s.doc.para_paths(StoryRef::Body).into_iter().find(|path| path.depth() > 0).unwrap(); + let p = s.doc.para_mut(StoryRef::Body, &cell).unwrap(); + p.insert_object(0, InlineObject::FieldEnd, &CharProps::default()).unwrap(); + p.insert_object(0, InlineObject::FieldStart { instr: r#"INDEX \h "A""#.into(), locked: false, dirty: false }, &CharProps::default()).unwrap(); + assert!(s.run("references.index", &json!({"columns": 2})).is_err()); + assert!(s.run("references.updateIndex", &json!({})).is_err()); + } + + /// #3670: only the headers a page shows count. An INDEX in a first-page header is out of + /// reach while Different First Page is on, and doesn't block Insert Index while it is off. + #[test] + fn an_index_in_a_header_blocks_insert_only_while_the_header_is_shown() { + let with_header_index = |first: bool, title_page: bool| { + let mut d = wordcraft_doc::Document::from_text("Kilns are hot."); + let mut p = wordcraft_doc::Paragraph::new(); + p.insert_object(0, InlineObject::FieldEnd, &CharProps::default()).unwrap(); + p.insert_object(0, InlineObject::FieldStart { instr: r#"INDEX \h "A""#.into(), locked: false, dirty: false }, &CharProps::default()) + .unwrap(); + let id = d.add_part(wordcraft_doc::PartKind::Header, vec![std::sync::Arc::new(wordcraft_doc::Block::Para(p))]); + if first { + d.last_section.headers.first = Some(id); + } else { + d.last_section.headers.default = Some(id); + } + d.last_section.title_page = title_page; + let mut s = Session::new(d); + s.run("select.text", &json!({"text": "Kilns"})).unwrap(); + s.run("references.markEntry", &json!({})).unwrap(); + s.run("caret.docEnd", &json!({})).unwrap(); + s + }; + let body_has_index = |s: &Session| index_field(s).is_some(); + // Linked (default) header: shown, so Insert Index is refused. + let mut s = with_header_index(false, false); + assert!(s.run("references.index", &json!({})).is_err()); + assert!(!body_has_index(&s)); + // First-page header with Different First Page off: hidden, so the body gets its index. + let mut s = with_header_index(true, false); + s.run("references.index", &json!({})).unwrap(); + assert!(body_has_index(&s)); + // The same header with Different First Page on is shown again. + let mut s = with_header_index(true, true); + assert!(s.run("references.index", &json!({})).is_err()); + assert!(!body_has_index(&s)); + } + + /// An index Word wrote as a range field in the main text takes Insert Index's settings and is + /// rebuilt, rather than a second index being added at the caret (#8034). + #[test] + fn insert_index_gives_a_range_field_index_in_the_main_text_its_settings() { + let mut s = Session::new(wordcraft_doc::Document::from_text("Kilns are hot.")); + s.run("select.text", &json!({"text": "Kilns"})).unwrap(); + s.run("references.markEntry", &json!({})).unwrap(); + s.run("caret.docEnd", &json!({})).unwrap(); + let at = s.doc.body.len(); + let mut para = wordcraft_doc::para::Paragraph::new(); + para.insert_object(0, InlineObject::FieldEnd, &CharProps::default()).unwrap(); + para.insert_object(0, InlineObject::FieldStart { instr: r#"INDEX \h "A""#.into(), locked: false, dirty: false }, &CharProps::default()) + .unwrap(); + s.doc.insert_block(StoryRef::Body, &Path::top(at), wordcraft_doc::Block::Para(para)).unwrap(); + s.run("caret.docEnd", &json!({})).unwrap(); + s.run("references.index", &json!({"columns": 2})).unwrap(); + let instrs: Vec = s + .doc + .body + .iter() + .filter_map(|b| b.as_para()) + .flat_map(|p| p.objects.iter()) + .filter_map(|o| match o { + InlineObject::Field { instr, .. } | InlineObject::FieldStart { instr, .. } if FieldCode::parse(instr).name == "INDEX" => { + Some(instr.clone()) + } + _ => None, + }) + .collect(); + assert_eq!(instrs.len(), 1, "one index, not a second beside it: {instrs:?}"); + assert!(FieldCode::parse(&instrs[0]).arg('c').is_some(), "the index took the new columns setting: {instrs:?}"); + let text: String = + s.doc.body.iter().filter_map(|b| b.as_para()).map(|p| p.text.replace(wordcraft_doc::para::OBJ, "")).collect::>().join( + " +", + ); + assert!(text.contains("Kilns are hot."), "the text before the index survives: {text:?}"); + assert!(text.contains("Kilns, 1"), "Update Index generated an entry: {text:?}"); + } + + #[test] + fn a_range_field_index_after_text_is_refused_not_reported_updated() { + let mut s = Session::new(wordcraft_doc::Document::from_text("Kilns are hot.")); + s.run("select.text", &json!({"text": "Kilns"})).unwrap(); + s.run("references.markEntry", &json!({})).unwrap(); + let p = s.doc.para_mut(StoryRef::Body, &Path::top(0)).unwrap(); + let end = p.len(); + p.insert_object(end, InlineObject::FieldEnd, &CharProps::default()).unwrap(); + p.insert_object(end, InlineObject::FieldStart { instr: r#"INDEX \h "A""#.into(), locked: false, dirty: false }, &CharProps::default()) + .unwrap(); + assert!(s.run("references.updateIndex", &json!({})).is_err()); + assert!(s.run("references.index", &json!({})).is_err()); + } } diff --git a/crates/engine/src/cmd/insert.rs b/crates/engine/src/cmd/insert.rs index 2d44a4562e..10a626979c 100644 --- a/crates/engine/src/cmd/insert.rs +++ b/crates/engine/src/cmd/insert.rs @@ -21,8 +21,8 @@ pub use items::{ }; use items::{cover_page, date_time, drop_cap, drop_cap_off, field, page_number, symbol}; use links::{bookmark, delete_bookmark, link, link_targets}; -pub use links::{bookmark_name_ok, bookmark_range, bookmark_span}; -pub use objects::{base64_decode, base64_encode}; +pub use links::{bookmark_name_ok, bookmark_range, bookmark_span, selection_is_one_line}; +pub use objects::{MAX_TABLE_ROWS, base64_decode, base64_encode}; use objects::{icon, shape, table, text_box}; pub(crate) use objects::{image_ext, picture}; diff --git a/crates/engine/src/cmd/insert/header_footer.rs b/crates/engine/src/cmd/insert/header_footer.rs index 2bdbeb5ce7..65dc23b84c 100644 --- a/crates/engine/src/cmd/insert/header_footer.rs +++ b/crates/engine/src/cmd/insert/header_footer.rs @@ -7,7 +7,7 @@ use super::{ /// even page or the default), made when there is none: with Different First Page on, a header /// inserted on page 1 is the one page 1 shows (#2826). pub(super) fn hf_part(s: &mut Session, header: bool) -> u32 { - let block = s.sel.focus.path.0.first().copied().unwrap_or(0) as usize; + let block = crate::cmd::page::section_end_of_focus(s); let layout = s.layout(); let page = if s.sel.focus.story == StoryRef::Body { layout.page_of(&s.sel.focus) } else { Some(s.page_hint) }; let slot = page.and_then(|pg| layout.pages.get(pg)).map(|pg| pg.hf_slot).unwrap_or_default(); @@ -98,15 +98,12 @@ pub(super) fn edit_hf(s: &mut Session, v: &Value, header: bool) -> CmdResult { let shown = match page { Some(page) => shown_hf(s, page, header)?, None => { - let block = s.sel.focus.path.0.first().copied().unwrap_or(0) as usize; - let set = s - .doc - .sections() - .into_iter() - .find(|(end, _)| block <= *end) - .or_else(|| s.doc.sections().pop()) - .map(|(_, sp)| if header { sp.headers.default } else { sp.footers.default }); - set.flatten().filter(|id| s.doc.parts.contains_key(id)) + // The caret's section's own, else the one it is linked to from a section before it, as + // layout shows it (#3639): editing that one keeps the link. + let section = crate::cmd::page::hf_section_of_focus(s); + let sections = s.doc.sections(); + let set = sections.iter().take(section + 1).rev().find_map(|(_, sp)| if header { sp.headers.default } else { sp.footers.default }); + set.filter(|id| s.doc.parts.contains_key(id)) } }; let Some(id) = shown else { diff --git a/crates/engine/src/cmd/insert/items.rs b/crates/engine/src/cmd/insert/items.rs index 5343437592..1a89580dcf 100644 --- a/crates/engine/src/cmd/insert/items.rs +++ b/crates/engine/src/cmd/insert/items.rs @@ -205,21 +205,26 @@ pub fn format_date_at_in(fmt: &str, lang: Option<&str>, unix: u64, offset_secs: format_date_parts_in(fmt, lang, y, m as usize, d, hms, days) } -/// Month and weekday names of a language, as Word writes them in date fields: full names, the -/// three-letter forms (`MMM`, `ddd`) being their first three letters, without a full stop. -/// Weekdays start on Thursday (1970-01-01). +/// Month and weekday names of a language, as Word writes them in date fields: full names and the +/// abbreviations used by `MMM` and `ddd`. Weekdays start on Thursday (1970-01-01). struct DateNames { /// Full month names (January through December). months: [&'static str; 12], + /// Abbreviated month names for `MMM` (January through December). + months_short: [&'static str; 12], /// Weekday names starting on Thursday (1970-01-01). days: [&'static str; 7], + /// Abbreviated weekday names for `ddd`, starting on Thursday (1970-01-01). + days_short: [&'static str; 7], /// The picture of a `DATE` field without `\@`. default: &'static str, } const ENGLISH: DateNames = DateNames { months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + months_short: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], days: ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"], + days_short: ["Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed"], default: "M/d/yyyy", }; @@ -227,14 +232,46 @@ const ENGLISH: DateNames = DateNames { /// `ddd` = `qui`, and `dd/MM/yyyy` for a field without a picture. const PORTUGUESE: DateNames = DateNames { months: ["janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"], + months_short: ["jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"], 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", }; -/// Choose month and weekday names according to the primary language subtag. +/// German (Word's Windows NLS forms): `MMMM` = `März`, `MMM` = `Mrz`, `ddd` = `Fr` (two +/// letters), and `dd.MM.yyyy` for a field without a picture. Covers de-DE, de-CH and bare `de`. +const GERMAN: DateNames = DateNames { + months: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"], + months_short: ["Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"], + days: ["Donnerstag", "Freitag", "Samstag", "Sonntag", "Montag", "Dienstag", "Mittwoch"], + days_short: ["Do", "Fr", "Sa", "So", "Mo", "Di", "Mi"], + default: "dd.MM.yyyy", +}; + +/// Austrian Standard German: January is `Jänner`, abbreviated `Jän` (Österreichisches +/// Wörterbuch; Windows NLS `de-AT`). Every other month and weekday matches [`GERMAN`]. +const GERMAN_AUSTRIA: DateNames = DateNames { + months: ["Jänner", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"], + months_short: ["Jän", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"], + days: ["Donnerstag", "Freitag", "Samstag", "Sonntag", "Montag", "Dienstag", "Mittwoch"], + days_short: ["Do", "Fr", "Sa", "So", "Mo", "Di", "Mi"], + default: "dd.MM.yyyy", +}; + +/// Choose month and weekday names from the language tag: the primary subtag picks the language, +/// and a region subtag refines it (`de-AT` writes `Jänner`). Tags compare case-insensitively, as +/// `w:lang` values do. fn date_names(lang: Option<&str>) -> &'static DateNames { - let primary = lang.and_then(|l| l.trim().split(['-', '_']).next()).unwrap_or(""); - if primary.eq_ignore_ascii_case("pt") { &PORTUGUESE } else { &ENGLISH } + let mut subtags = lang.unwrap_or("").trim().split(['-', '_']); + let primary = subtags.next().unwrap_or(""); + if primary.eq_ignore_ascii_case("pt") { + &PORTUGUESE + } else if primary.eq_ignore_ascii_case("de") { + // Austria keeps `Jänner` / `Jän`; Germany and Switzerland keep `Januar` / `Jan`. + if subtags.any(|region| region.eq_ignore_ascii_case("AT")) { &GERMAN_AUSTRIA } else { &GERMAN } + } else { + &ENGLISH + } } /// The picture Word gives a `DATE` field that has no `\@` switch, in the field's language. @@ -252,9 +289,12 @@ pub fn format_date_parts(fmt: &str, y: i64, m: usize, d: u32, hms: (u32, u32, u3 #[allow(clippy::too_many_arguments)] pub fn format_date_parts_in(fmt: &str, lang: Option<&str>, y: i64, m: usize, d: u32, (hh, mm, ss): (u32, u32, u32), days_since: i64) -> String { let names = date_names(lang); - let month = names.months.get(m.saturating_sub(1)).copied().unwrap_or(names.months[0]); - let day = names.days.get(days_since.rem_euclid(7) as usize).copied().unwrap_or(names.days[0]); - let three = |s: &str| -> String { s.chars().take(3).collect() }; + let mi = m.saturating_sub(1); + let di = days_since.rem_euclid(7) as usize; + let month = names.months.get(mi).copied().unwrap_or(names.months[0]); + let month_short = names.months_short.get(mi).copied().unwrap_or(names.months_short[0]); + let day = names.days.get(di).copied().unwrap_or(names.days[0]); + let day_short = names.days_short.get(di).copied().unwrap_or(names.days_short[0]); let mut out = String::new(); let chars: Vec = fmt.chars().collect(); let mut i = 0; @@ -296,11 +336,11 @@ pub fn format_date_parts_in(fmt: &str, lang: Option<&str>, y: i64, m: usize, d: ('y' | 'Y', 4..) => out.push_str(&format!("{y:04}")), ('y' | 'Y', _) => out.push_str(&format!("{:02}", y % 100)), ('M', 4..) => out.push_str(month), - ('M', 3) => out.push_str(&three(month)), + ('M', 3) => out.push_str(month_short), ('M', 2) => out.push_str(&format!("{m:02}")), ('M', 1) => out.push_str(&m.to_string()), ('d' | 'D', 4..) => out.push_str(day), - ('d' | 'D', 3) => out.push_str(&three(day)), + ('d' | 'D', 3) => out.push_str(day_short), ('d' | 'D', 2) => out.push_str(&format!("{d:02}")), ('d' | 'D', 1) => out.push_str(&d.to_string()), ('H', 2..) => out.push_str(&format!("{hh:02}")), @@ -311,7 +351,7 @@ pub fn format_date_parts_in(fmt: &str, lang: Option<&str>, y: i64, m: usize, d: ('m', _) => out.push_str(&mm.to_string()), ('s', 2..) => out.push_str(&format!("{ss:02}")), ('s', _) => out.push_str(&ss.to_string()), - ('a' | 'A', _) => out.push_str(if hh < 12 { "AM" } else { "PM" }), + // Bare `a`/`A` is literal; AM/PM is the `am/pm` token (#3488). _ => { for _ in 0..n { out.push(c); @@ -574,6 +614,43 @@ mod date_time_locale_tests { assert_eq!(format("MMMM", 20), "outubro"); } + /// German month and weekday names, and the default picture, are chosen by the language tag + /// (de-DE, de-AT, de-CH), as in Word (#7146). + #[test] + fn german_date_names_render_for_de() { + assert_eq!(format_date_parts_in("dddd, d. MMMM yyyy", Some("de-DE"), 2026, 11, 21, (12, 0, 0), 2), "Samstag, 21. November 2026"); + assert_eq!(default_date_picture(Some("de-CH")), "dd.MM.yyyy"); + } + + /// Windows NLS short forms: two-letter weekdays (`Mo`, `Di`…) and `Mrz` for March, with no + /// trailing full stop (#7146). + #[test] + fn german_short_names_match_windows_nls() { + let format = |pic| format_date_parts_in(pic, Some("de-DE"), 2026, 3, 15, (12, 0, 0), 3); + assert_eq!(format("ddd, d. MMM yyyy"), "So, 15. Mrz 2026"); + assert_eq!(format("dddd"), "Sonntag"); + assert_eq!(format("MMM"), "Mrz"); + } + + /// Austrian Standard German writes January as `Jänner` (`Jän`), while Germany, Switzerland + /// and bare `de` keep `Januar` (`Jan`); every other name is shared (#7146). + #[test] + fn austrian_german_january_is_jaenner() { + let january = |lang, pic| format_date_parts_in(pic, Some(lang), 2026, 1, 15, (12, 0, 0), 0); + assert_eq!(january("de-AT", "MMMM"), "Jänner"); + assert_eq!(january("de-AT", "MMM"), "Jän"); + assert_eq!(january("de_at", "MMMM"), "Jänner", "region subtags compare case-insensitively"); + for lang in ["de-DE", "de-CH", "de"] { + assert_eq!(january(lang, "MMMM"), "Januar", "{lang}"); + assert_eq!(january(lang, "MMM"), "Jan", "{lang}"); + } + // Only January differs: February and March read the same in Austria and Germany. + for month in [2, 3] { + let names = |lang| format_date_parts_in("MMMM MMM", Some(lang), 2026, month, 1, (12, 0, 0), 0); + assert_eq!(names("de-AT"), names("de-DE")); + } + } + /// A pt-BR dynamic field keeps its result after DOCX round-trip and refresh. #[test] fn pt_br_date_time_dialog_inserts_dynamic_field() { diff --git a/crates/engine/src/cmd/insert/links.rs b/crates/engine/src/cmd/insert/links.rs index f383365134..5463049bc4 100644 --- a/crates/engine/src/cmd/insert/links.rs +++ b/crates/engine/src/cmd/insert/links.rs @@ -84,25 +84,40 @@ pub(super) fn link(s: &mut Session, v: &Value) -> CmdResult { sel_result(s) } -/// The `text` to retype a selection with before linking it: only when it differs from the selected -/// text and both fit in one line of one paragraph without pictures or fields, outside any field's -/// result. Otherwise (as Word shows `<>`) the selection keeps its text. -fn retyped_text(s: &Session, v: &Value) -> Option { +/// What can't stand in one line of text: breaks, and pictures or fields. +const NOT_ONE_LINE: [char; 7] = { use wordcraft_doc::para::{COLUMN_BREAK, LINE_BREAK, OBJ, PAGE_BREAK}; - /// What can't stand in one line of text: breaks, and pictures or fields. - const NOT_ONE_LINE: [char; 7] = [LINE_BREAK, '\r', '\u{2029}', '\u{b}', PAGE_BREAK, COLUMN_BREAK, OBJ]; - let text = p::str(v, "text").filter(|t| !t.is_empty() && t.len() <= 4096)?; - if text.contains(NOT_ONE_LINE) { - return None; - } + [LINE_BREAK, '\r', '\u{2029}', '\u{b}', PAGE_BREAK, COLUMN_BREAK, OBJ] +}; + +/// The raw text of the selection when it is one run of one paragraph without breaks, pictures or fields. +fn one_line_selection(s: &Session) -> Option<&str> { let (a, b) = s.sel.ordered(); if a.story != b.story || a.path != b.path { return None; } - let shown = s.doc.para(a.story, &a.path)?.text.get(a.off..b.off)?; - if shown.contains(NOT_ONE_LINE) || shown == text { + s.doc.para(a.story, &a.path)?.text.get(a.off..b.off).filter(|t| !t.contains(NOT_ONE_LINE)) +} + +/// Whether the selection is plain text in one line of one paragraph: otherwise (as Word shows +/// `<>`) Text to display can't show it and linking keeps its content (#8286). +pub fn selection_is_one_line(s: &Session) -> bool { + one_line_selection(s).is_some() +} + +/// The `text` to retype a selection with before linking it: only when it differs from the selected +/// text and both fit in one line of one paragraph without pictures or fields, outside any field's +/// result. Otherwise (as Word shows `<>`) the selection keeps its text. +fn retyped_text(s: &Session, v: &Value) -> Option { + let text = p::str(v, "text").filter(|t| !t.is_empty() && t.len() <= 4096)?; + if text.contains(NOT_ONE_LINE) { return None; } + let shown = one_line_selection(s)?; + if shown == text { + return None; + } + let (a, b) = s.sel.ordered(); // A selection in a field's result (between its markers, which it doesn't hold) is retyped by // the next update of the field, not here. if s.doc.field_ranges(a.story).iter().any(|r| r.start < b && a <= r.end) { diff --git a/crates/engine/src/cmd/insert/objects.rs b/crates/engine/src/cmd/insert/objects.rs index b59ac80dbe..09b24f6fea 100644 --- a/crates/engine/src/cmd/insert/objects.rs +++ b/crates/engine/src/cmd/insert/objects.rs @@ -23,8 +23,13 @@ fn insert_block_at_caret(s: &mut Session, block: Block) -> Result CmdResult { - let rows = p::u64(v, "rows").unwrap_or(2).clamp(1, 1000) as usize; + let rows = p::u64(v, "rows").unwrap_or(2).clamp(1, MAX_TABLE_ROWS as u64) as usize; let cols = p::u64(v, "cols").unwrap_or(2).clamp(1, 63) as usize; let width = s.doc.sections().first().map(|(_, sp)| sp.text_width()).unwrap_or(468.0); let mut t = Table::new(rows, cols, width); diff --git a/crates/engine/src/cmd/insert/tests.rs b/crates/engine/src/cmd/insert/tests.rs index de38fe91fa..9f4c5165e9 100644 --- a/crates/engine/src/cmd/insert/tests.rs +++ b/crates/engine/src/cmd/insert/tests.rs @@ -358,6 +358,8 @@ fn date_pictures_keep_quoted_text() { // Two quotes outside quoted text are one too (an apostrophe), not an empty quoted text. assert_eq!(format_date_parts("yyyy '' MM", 2026, 10, 21, (0, 0, 0), 0), "2026 ' 10"); assert_eq!(format_date_parts("d''MM", 2026, 10, 21, (0, 0, 0), 0), "21'10"); + // Bare `a` is literal, not AM/PM (#3488). + assert_eq!(format_date_parts("yyyy a", 2026, 10, 21, (14, 30, 0), 0), "2026 a"); } #[test] diff --git a/crates/engine/src/cmd/mailings.rs b/crates/engine/src/cmd/mailings.rs index fa109031a6..49efc35eba 100644 --- a/crates/engine/src/cmd/mailings.rs +++ b/crates/engine/src/cmd/mailings.rs @@ -27,7 +27,7 @@ pub use merge::{merge_range, refresh}; #[cfg(test)] use merge::{mergefield_name, placeholder}; use recipients::recipients; -pub use recipients::{RECIPIENT_EXTENSIONS, is_spreadsheet_name, parse_csv}; +pub use recipients::{CsvLimits, MAX_CELLS, MAX_FIELDS, MAX_TEXT_BYTES, RECIPIENT_EXTENSIONS, RECIPIENT_LIMITS, is_spreadsheet_name, parse_csv}; /// The mail-merge data source and preview state (lives in the session, not the document). #[derive(Clone, Debug, Default)] diff --git a/crates/engine/src/cmd/mailings/recipients.rs b/crates/engine/src/cmd/mailings/recipients.rs index 45aee66368..0233038779 100644 --- a/crates/engine/src/cmd/mailings/recipients.rs +++ b/crates/engine/src/cmd/mailings/recipients.rs @@ -19,22 +19,32 @@ fn csv_separator(text: &str) -> char { [',', ';', '\t'].into_iter().max_by_key(|c| unquoted.matches(*c).count()).unwrap_or(',') } -/// Ends the current row: kept when it has any non-empty field, otherwise dropped. -fn push_csv_row(rows: &mut Vec>, row: &mut Vec) { - if row.iter().any(|x| !x.is_empty()) { - rows.push(std::mem::take(row)); - } else { - row.clear(); - } +/// What a CSV may hold while it is read: the parser refuses a list that is over these, so a +/// hostile file is never built and then cut. +#[derive(Clone, Copy)] +pub struct CsvLimits { + /// Most columns in a record. + pub fields: usize, + /// Most cells in the list: its records times its widest record. + pub cells: usize, + /// Most bytes of cell text in all. + pub text: usize, } /// Parse CSV (RFC 4180-ish: quotes, doubled quotes, commas/semicolons/tabs). -pub fn parse_csv(text: &str) -> Vec> { +/// +/// The limits are kept while the list is read, not after it: a record wider than +/// `limits.fields`, a list of more than `limits.cells` cells, or more than `limits.text` bytes +/// of cell text is refused, rather than built and then cut. +pub fn parse_csv(text: &str, limits: &CsvLimits) -> Result>, CmdError> { let sep = csv_separator(text); let mut rows = Vec::new(); let mut row = Vec::new(); let mut cell = String::new(); let mut q = false; + // The widest record read so far, and the bytes of cell text read so far. + let mut widest = 0usize; + let mut text_bytes = 0usize; let mut chars = text.chars().peekable(); while let Some(c) = chars.next() { if q { @@ -51,29 +61,75 @@ pub fn parse_csv(text: &str) -> Vec> { } else if c == '"' { q = true; } else if c == sep { - row.push(std::mem::take(&mut cell)); + end_cell(&mut row, &mut cell, &mut text_bytes, limits)?; } else if c == '\n' || c == '\r' { if c == '\r' && chars.peek() == Some(&'\n') { chars.next(); } - row.push(std::mem::take(&mut cell)); - push_csv_row(&mut rows, &mut row); + end_cell(&mut row, &mut cell, &mut text_bytes, limits)?; + end_row(&mut rows, &mut row, &mut widest, limits)?; } else { cell.push(c); } + // The text read so far: the finished cells and the one being read. + if text_bytes.saturating_add(cell.len()) > limits.text { + return Err(CmdError::Failed(format!("the CSV can't have more than {} of text", text_size(limits.text)))); + } if rows.len() > 100_000 { break; } } - row.push(cell); - push_csv_row(&mut rows, &mut row); - rows + // The last cell, when the file doesn't end with a line break. + end_cell(&mut row, &mut cell, &mut text_bytes, limits)?; + end_row(&mut rows, &mut row, &mut widest, limits)?; + Ok(rows) +} + +/// A finished cell joins the record: the record's width stays inside the limit. +fn end_cell(row: &mut Vec, cell: &mut String, text_bytes: &mut usize, limits: &CsvLimits) -> Result<(), CmdError> { + *text_bytes = text_bytes.saturating_add(cell.len()); + row.push(std::mem::take(cell)); + if row.len() > limits.fields { + return Err(CmdError::Failed(format!("the CSV can't have more than {} columns", limits.fields))); + } + Ok(()) +} + +/// A finished record joins the list (an empty one is dropped). The list costs its records times +/// its widest record — a recipient list pads every record to the header's width — so a list +/// over the limit is refused here, while it is read. +fn end_row(rows: &mut Vec>, row: &mut Vec, widest: &mut usize, limits: &CsvLimits) -> Result<(), CmdError> { + if row.iter().any(|x| !x.is_empty()) { + *widest = (*widest).max(row.len()); + rows.push(std::mem::take(row)); + } else { + row.clear(); + } + if rows.len().saturating_mul(*widest) > limits.cells { + return Err(CmdError::Failed(format!("the CSV can't have more than {} cells (its records times its widest record)", limits.cells))); + } + Ok(()) +} + +/// A byte budget, said the way a reader says it. +fn text_size(bytes: usize) -> String { + if bytes >= 1 << 20 { format!("{} MB", bytes >> 20) } else { format!("{bytes} bytes") } } /// Most records and fields a recipient list keeps. const MAX_RECORDS: usize = 100_000; -const MAX_FIELDS: usize = 1_000; +pub const MAX_FIELDS: usize = 1_000; + +/// Most cells a recipient list keeps: its records times its fields. A recipient list pads every +/// record to the header's width, so this is what a list costs, not how many values it says. +pub const MAX_CELLS: usize = 2_000_000; + +/// Most bytes of cell text a recipient list keeps. The table path keeps the same budget. +pub const MAX_TEXT_BYTES: usize = 64 << 20; + +/// The limits a recipient list keeps. +pub const RECIPIENT_LIMITS: CsvLimits = CsvLimits { fields: MAX_FIELDS, cells: MAX_CELLS, text: MAX_TEXT_BYTES }; pub(super) fn cell(x: &Value) -> String { match x { @@ -117,12 +173,12 @@ fn table_from_rows(fields: Option<&Vec>, arr: &[Value]) -> Result<(Vec Vec> { +fn recipient_csv(text: &str, headers: bool) -> Result>, CmdError> { let prefix = text .split_inclusive(['\n', '\r']) .take_while(|line| headers && line.trim().is_empty()) .fold(0_usize, |bytes, line| bytes.saturating_add(line.len())); - parse_csv(text.get(prefix..).unwrap_or_default()) + parse_csv(text.get(prefix..).unwrap_or_default(), &RECIPIENT_LIMITS) } pub(super) fn recipients(s: &mut Session, v: &Value) -> CmdResult { @@ -131,7 +187,7 @@ pub(super) fn recipients(s: &mut Session, v: &Value) -> CmdResult { table_from_rows(v.get("fields").and_then(Value::as_array), arr)? } else { let all = if let Some(c) = p::str(v, "csv") { - recipient_csv(c, p::bool(v, "headers").unwrap_or(true)) + recipient_csv(c, p::bool(v, "headers").unwrap_or(true))? } else { let (bytes, ext) = if let Some(d) = p::str(v, "data") { let b = crate::cmd::insert::base64_decode(d.trim()).ok_or_else(|| CmdError::Params("`data` isn't valid base64".into()))?; @@ -188,7 +244,7 @@ pub(super) fn recipients(s: &mut Session, v: &Value) -> CmdResult { sheet = json!(chosen); rows } else { - recipient_csv(&decode(&bytes, v)?, p::bool(v, "headers").unwrap_or(true)) + recipient_csv(&decode(&bytes, v)?, p::bool(v, "headers").unwrap_or(true))? } }; header_split(all, p::bool(v, "headers").unwrap_or(true))? diff --git a/crates/engine/src/cmd/mailings/tests.rs b/crates/engine/src/cmd/mailings/tests.rs index f35774665c..6e60fdcbf9 100644 --- a/crates/engine/src/cmd/mailings/tests.rs +++ b/crates/engine/src/cmd/mailings/tests.rs @@ -2,9 +2,54 @@ use super::*; #[test] fn csv_parsing() { - let r = parse_csv("Name,City\n\"Smith, Ann\",Paris\r\nBo,\"Oslo \"\"N\"\"\"\n\n"); + let r = parse_csv("Name,City\n\"Smith, Ann\",Paris\r\nBo,\"Oslo \"\"N\"\"\"\n\n", &RECIPIENT_LIMITS).unwrap(); assert_eq!(r, vec![vec!["Name", "City"], vec!["Smith, Ann", "Paris"], vec!["Bo", "Oslo \"N\""]]); - assert_eq!(parse_csv("a;b\n1;2")[1], vec!["1", "2"]); + assert_eq!(parse_csv("a;b\n1;2", &RECIPIENT_LIMITS).unwrap()[1], vec!["1", "2"]); +} + +/// The parser keeps its limits while it reads the list, so a hostile list is refused +/// instead of being built and then cut. +#[test] +fn csv_parsing_refuses_a_list_over_its_limits() { + // A record wider than the limit. + let e = parse_csv("a,b,c,d,e", &CsvLimits { fields: 4, cells: 100, text: 1_000 }).unwrap_err(); + assert!(e.to_string().contains("4 columns"), "{e}"); + // More cells than the list keeps. + let e = parse_csv("a,b\nc,d\ne,f\ng,h\ni,j\nk,l", &CsvLimits { fields: 10, cells: 10, text: 1_000 }).unwrap_err(); + assert!(e.to_string().contains("10 cells"), "{e}"); + // More text than the list keeps. + let e = parse_csv("abcdefghij", &CsvLimits { fields: 10, cells: 100, text: 8 }).unwrap_err(); + assert!(e.to_string().contains("of text"), "{e}"); + // A list inside the limits still parses. + let limits = CsvLimits { fields: 4, cells: 10, text: 1_000 }; + assert_eq!(parse_csv("a,b\nc,d", &limits).unwrap(), vec![vec!["a", "b"], vec!["c", "d"]]); +} + +/// A recipient list over its limits is refused, not built. +#[test] +fn a_recipient_list_over_its_limits_is_refused() { + // A record wider than the list's fields. + let wide = format!("{}\nvalue", "f,".repeat(MAX_FIELDS + 1)); + let e = parse_csv(&wide, &RECIPIENT_LIMITS).unwrap_err(); + assert!(e.to_string().contains(&format!("{MAX_FIELDS} columns")), "{e}"); + + // A record of exactly the limit's width is kept. + let exact = format!("{}\nvalue", "f,".repeat(MAX_FIELDS - 1)); + assert_eq!(parse_csv(&exact, &RECIPIENT_LIMITS).unwrap()[0].len(), MAX_FIELDS); + + // A wide header over many records: the list would cost more cells than it keeps, and + // every record is padded to the header's width. + let mut csv = format!("{}\n", (0..MAX_FIELDS).map(|i| format!("f{i}")).collect::>().join(",")); + for _ in 0..=MAX_CELLS / MAX_FIELDS { + csv.push_str("value\n"); + } + let e = parse_csv(&csv, &RECIPIENT_LIMITS).unwrap_err(); + assert!(e.to_string().contains(&format!("{MAX_CELLS} cells")), "{e}"); + + // The command refuses it too, with a message of its own. + let mut s = Session::new(Document::new()); + let e = s.run("mailings.recipients", &json!({"csv": wide})).unwrap_err(); + assert!(e.to_string().contains("columns"), "{e}"); } /// #4001: finishing a merge opens a new document, with a new undo history. It is not an @@ -56,13 +101,16 @@ fn csv_delimiter_reads_complete_header_record() { let quoted = header.replace('"', "\"\""); let text = format!("\"{quoted}\"{sep}City{sep}{sep}\r\nAda{sep}Paris{sep}{sep}\nBo{sep}Oslo{sep}{sep}"); assert_eq!( - parse_csv(&text), + parse_csv(&text, &RECIPIENT_LIMITS).unwrap(), vec![vec![header.as_str(), "City", "", ""], vec!["Ada", "Paris", "", ""], vec!["Bo", "Oslo", "", ""]], "separator {sep:?}, embedded newline {newline:?}" ); // A multiline field after an ordinary column must not end detection either. let text = format!("ID{sep}\"{quoted}\"{sep}City\n1{sep}Ada{sep}Paris\n2{sep}Bo{sep}Oslo"); - assert_eq!(parse_csv(&text), vec![vec!["ID", header.as_str(), "City"], vec!["1", "Ada", "Paris"], vec!["2", "Bo", "Oslo"]]); + assert_eq!( + parse_csv(&text, &RECIPIENT_LIMITS).unwrap(), + vec![vec!["ID", header.as_str(), "City"], vec!["1", "Ada", "Paris"], vec!["2", "Bo", "Oslo"]] + ); } } } @@ -74,7 +122,7 @@ fn csv_delimiter_reads_multiline_headers_after_blank_lines() { let header = format!("Given{newline}Family"); for prefix in ["\n\r\n", "\r", "\r\r"] { let text = format!("{prefix}\"{header}\"{sep}City\rAda{sep}Paris"); - assert_eq!(parse_csv(&text), vec![vec![header.as_str(), "City"], vec!["Ada", "Paris"]]); + assert_eq!(parse_csv(&text, &RECIPIENT_LIMITS).unwrap(), vec![vec![header.as_str(), "City"], vec!["Ada", "Paris"]]); } } } @@ -99,34 +147,41 @@ fn recipient_csv_blank_prefix_keeps_columns_without_dropping_literal_records() { let rows = s.merge.rows.clone(); assert!(s.run("mailings.recipients", &json!({"csv": " \t\r\n \r"})).is_err()); assert_eq!(s.merge.rows, rows, "an empty headered list must not replace existing recipients"); - assert_eq!(parse_csv(" \nName,Email\nAda,ada@example.com")[0], vec![" "], "the shared CSV reader keeps literal whitespace rows"); + assert_eq!( + parse_csv(" \nName,Email\nAda,ada@example.com", &RECIPIENT_LIMITS).unwrap()[0], + vec![" "], + "the shared CSV reader keeps literal whitespace rows" + ); } #[test] fn csv_delimiter_keeps_record_boundaries_and_ties() { // Later records cannot choose the header's delimiter. - assert_eq!(parse_csv("Name;City\rAda;Paris,,,,\rBo;Oslo"), vec![vec!["Name", "City"], vec!["Ada", "Paris,,,,"], vec!["Bo", "Oslo"]]); + assert_eq!( + parse_csv("Name;City\rAda;Paris,,,,\rBo;Oslo", &RECIPIENT_LIMITS).unwrap(), + vec![vec!["Name", "City"], vec!["Ada", "Paris,,,,"], vec!["Bo", "Oslo"]] + ); // Existing ties prefer tab, then semicolon, then comma. - assert_eq!(parse_csv("A,B;C\n1,2;3"), vec![vec!["A,B", "C"], vec!["1,2", "3"]]); - assert_eq!(parse_csv("A;B\tC\n1;2\t3"), vec![vec!["A;B", "C"], vec!["1;2", "3"]]); - assert_eq!(parse_csv("Name\nAda,Paris;Oslo"), vec![vec!["Name"], vec!["Ada,Paris;Oslo"]]); - assert!(parse_csv("").is_empty()); - assert_eq!(parse_csv("\nName\nAda"), vec![vec!["Name"], vec!["Ada"]]); + assert_eq!(parse_csv("A,B;C\n1,2;3", &RECIPIENT_LIMITS).unwrap(), vec![vec!["A,B", "C"], vec!["1,2", "3"]]); + assert_eq!(parse_csv("A;B\tC\n1;2\t3", &RECIPIENT_LIMITS).unwrap(), vec![vec!["A;B", "C"], vec!["1;2", "3"]]); + assert_eq!(parse_csv("Name\nAda,Paris;Oslo", &RECIPIENT_LIMITS).unwrap(), vec![vec!["Name"], vec!["Ada,Paris;Oslo"]]); + assert!(parse_csv("", &RECIPIENT_LIMITS).unwrap().is_empty()); + assert_eq!(parse_csv("\nName\nAda", &RECIPIENT_LIMITS).unwrap(), vec![vec!["Name"], vec!["Ada"]]); // The reader remains permissive about an unterminated quoted cell. - assert_eq!(parse_csv("Name,City\nAda,\"Paris\nOslo"), vec![vec!["Name", "City"], vec!["Ada", "Paris\nOslo"]]); + assert_eq!(parse_csv("Name,City\nAda,\"Paris\nOslo", &RECIPIENT_LIMITS).unwrap(), vec![vec!["Name", "City"], vec!["Ada", "Paris\nOslo"]]); } #[test] fn csv_delimiter_ignores_quoted_text() { - let r = parse_csv("\"Name, first, last\";City\nAnn;Paris\n"); + let r = parse_csv("\"Name, first, last\";City\nAnn;Paris\n", &RECIPIENT_LIMITS).unwrap(); assert_eq!(r, vec![vec!["Name, first, last", "City"], vec!["Ann", "Paris"]]); } #[test] fn csv_delimiter_skips_leading_blank_lines() { let want = vec![vec!["Name", "Email"], vec!["Ann", "ann@x.org"]]; - assert_eq!(parse_csv("\nName,Email\nAnn,ann@x.org\n"), want); - assert_eq!(parse_csv("\r\n\r\nName;Email\r\nAnn;ann@x.org"), want); + assert_eq!(parse_csv("\nName,Email\nAnn,ann@x.org\n", &RECIPIENT_LIMITS).unwrap(), want); + assert_eq!(parse_csv("\r\n\r\nName;Email\r\nAnn;ann@x.org", &RECIPIENT_LIMITS).unwrap(), want); } /// Field types ignore case (ECMA-376 Part 1, 17.16.1), and `MERGEFIELDX` is another field. diff --git a/crates/engine/src/cmd/md_source.rs b/crates/engine/src/cmd/md_source.rs index 6d73496124..b5367d7e63 100644 --- a/crates/engine/src/cmd/md_source.rs +++ b/crates/engine/src/cmd/md_source.rs @@ -103,7 +103,7 @@ fn exact_text(s: &Session) -> Option { return res.clone(); } let kept = [s.md_file.latest.as_deref(), s.md_file.saved.as_deref()]; - let res = kept.into_iter().flatten().find(|text| parse(&s.doc, text).same_content(&s.doc)).map(str::to_string); + let res = kept.into_iter().flatten().find(|text| parse(&s.doc, text).is_ok_and(|d| d.same_content(&s.doc))).map(str::to_string); *s.md_file.cached_exact.borrow_mut() = Some((s.rev(), res.clone())); res } @@ -216,15 +216,16 @@ fn enter(s: &mut Session) -> Result<(), CmdError> { // The file's own text when it still says what the document holds, so nothing is lost. let (text, loses_content, block_lines) = match exact_text(s) { Some(text) => { - let (_, lines) = parse_with_lines(&s.doc, &text); + let (_, lines) = parse_with_lines(&s.doc, &text)?; (text, false, lines) } None => { - let text = wordcraft_formats::markdown::export(&s.doc); + let text = wordcraft_formats::markdown::export(&s.doc) + .map_err(|e| CmdError::Failed(format!("the document cannot be written as Markdown: {e}")))?; if text.len() > MAX_SOURCE_BYTES { return Err(CmdError::Failed(too_long())); } - let (doc, lines) = parse_with_lines(&s.doc, &text); + let (doc, lines) = parse_with_lines(&s.doc, &text)?; let loses_content = !doc.same_content(&s.doc); (text, loses_content, lines) } @@ -289,7 +290,19 @@ pub fn apply(s: &mut Session) { } (src.text.clone(), src.entry_text.clone(), src.entry_doc.clone(), src.has_step, src.entry_lines.clone()) }; - let (doc, lines) = if text == *entry_text { ((*entry_doc).clone(), entry_lines) } else { parse_with_lines(&s.doc, &text) }; + let (doc, lines) = if text == *entry_text { + ((*entry_doc).clone(), entry_lines) + } else { + // The text cannot be read as Markdown: the document stays as it is, rather than + // becoming an empty one. + match parse_with_lines(&s.doc, &text) { + Ok(v) => v, + Err(e) => { + s.status = e.to_string(); + return; + } + } + }; let step = if !has_step { s.checkpoint(LABEL); Some(s.undo_mark()) @@ -313,19 +326,20 @@ pub fn apply(s: &mut Session) { /// `text` as a document and block lines, with what isn't in Markdown from `current`: its page, settings, /// properties and language, as opening the file gave it. -fn parse_with_lines(current: &Document, text: &str) -> (Document, Vec) { - let (mut doc, lines) = wordcraft_formats::markdown::import_on_with_lines(text, ¤t.last_section); +fn parse_with_lines(current: &Document, text: &str) -> Result<(Document, Vec), CmdError> { + let (mut doc, lines) = wordcraft_formats::markdown::import_on_with_lines(text, ¤t.last_section) + .map_err(|e| CmdError::Failed(format!("the Markdown cannot be read: {e}")))?; doc.ensure_nonempty(); doc.settings = current.settings.clone(); doc.core = current.core.clone(); Arc::make_mut(&mut doc.styles).default_chr.lang = current.styles.default_chr.lang.clone(); - (doc, lines) + Ok((doc, lines)) } /// `text` as a document, with what isn't in Markdown from `current`: its page, settings, /// properties and language, as opening the file gave it. -fn parse(current: &Document, text: &str) -> Document { - parse_with_lines(current, text).0 +fn parse(current: &Document, text: &str) -> Result { + parse_with_lines(current, text).map(|(doc, _)| doc) } /// The byte offset where `line` starts, or the end of a text with fewer lines. diff --git a/crates/engine/src/cmd/moves.rs b/crates/engine/src/cmd/moves.rs index e0d1da2a39..33683a1e1b 100644 --- a/crates/engine/src/cmd/moves.rs +++ b/crates/engine/src/cmd/moves.rs @@ -56,7 +56,7 @@ pub fn cut_tracked(s: &mut Session) -> Result { if !s.doc.settings.track_changes || !s.doc.settings.track_moves || a == b || a.story != b.story || !move_sized(&s.clipboard_text) { return Ok(false); } - s.doc.revisions.push(Revision::new(RevisionKind::Delete, s.author.clone(), now_iso())); + s.doc.revisions.push(crate::cmd::made_revision(RevisionKind::Delete, s.author.clone(), now_iso())); let rid = (s.doc.revisions.len() - 1) as u32; let at = track_delete_as(s, &a, &b, rid)?.at; s.sel = Selection::caret(at); @@ -75,13 +75,13 @@ pub fn take_paste(s: &mut Session, frag: &Fragment) -> Option { return None; } let src = s.doc.revisions.get(m.rev as usize).filter(|r| r.kind == RevisionKind::Delete && r.move_name.is_none())?; - let date = src.date.clone(); + let (date, date_utc) = (src.date.clone(), src.date_utc.clone()); let taken: BTreeSet<&str> = s.doc.revisions.iter().filter_map(|r| r.move_name.as_deref()).collect(); let name = (1..).map(|n: u64| format!("move{n}")).find(|n| !taken.contains(n.as_str()))?; if let Some(r) = s.doc.revisions.get_mut(m.rev as usize) { r.move_name = Some(name.clone()); } - s.doc.revisions.push(Revision { kind: RevisionKind::Insert, author: s.author.clone(), date, move_name: Some(name) }); + s.doc.revisions.push(Revision { kind: RevisionKind::Insert, author: s.author.clone(), date, move_name: Some(name), date_utc }); Some((s.doc.revisions.len() - 1) as u32) } @@ -278,4 +278,23 @@ mod tests { assert_eq!(texts(&s), ["First one.", "Second one.", "Third one."]); assert!(kinds(&mut s).is_empty()); } + + /// A command that fails between a tracked cut and its paste changed nothing, so the move + /// the cut recorded is still there: the paste is a move, as it was before the command. + #[test] + fn a_failed_command_between_a_tracked_cut_and_its_paste_leaves_the_move() { + let mut s = Session::new(Document::new()); + s.run("document.setText", &json!({"text": "First one.\nSecond one.\nThird one."})).unwrap(); + s.run("file.setAuthor", &json!({"name": "Ana"})).unwrap(); + s.run("review.trackChanges", &json!({"value": true})).unwrap(); + s.run("select.range", &json!({"anchor": {"block": 1, "off": 0}, "focus": {"block": 2, "off": 0}})).unwrap(); + s.run("edit.cut", &json!({})).unwrap(); + // A command that fails: there is no such character style. + assert!(s.run("format.charStyle", &json!({"style": "NoSuchStyle"})).is_err()); + s.run("caret.set", &json!({"pos": {"block": 0, "off": 0}})).unwrap(); + s.run("edit.paste", &json!({})).unwrap(); + let k = kinds(&mut s); + assert!(k.iter().any(|(k, m)| k == "moveTo" && m == "move1"), "{k:?}"); + assert!(k.iter().any(|(k, m)| k == "moveFrom" && m == "move1"), "{k:?}"); + } } diff --git a/crates/engine/src/cmd/objects.rs b/crates/engine/src/cmd/objects.rs index af597bbe57..8b5c2e7989 100644 --- a/crates/engine/src/cmd/objects.rs +++ b/crates/engine/src/cmd/objects.rs @@ -29,6 +29,7 @@ pub use picture::{OriginalSize, PictureLook, cropped_original_size, fit_size, or use picture::{clear_background, grown, picture_style}; #[cfg(test)] pub(crate) use select::all_objects; +pub(crate) use select::select_object; pub(crate) use select::{edit_obj, has_shape_or_canvas}; #[cfg(test)] use select::{has_group, holds_ink, obj_size, with_obj}; diff --git a/crates/engine/src/cmd/objects/select.rs b/crates/engine/src/cmd/objects/select.rs index 93442941a7..9404804964 100644 --- a/crates/engine/src/cmd/objects/select.rs +++ b/crates/engine/src/cmd/objects/select.rs @@ -176,7 +176,7 @@ pub fn min_size(o: &InlineObject) -> f32 { } /// Select the object whose character is at `pos`. -pub(super) fn select_object(s: &mut Session, pos: &Pos) { +pub(crate) fn select_object(s: &mut Session, pos: &Pos) { s.sel = Selection { anchor: pos.clone(), focus: Pos { off: pos.off + wordcraft_doc::para::OBJ.len_utf8(), ..pos.clone() } }; } diff --git a/crates/engine/src/cmd/page.rs b/crates/engine/src/cmd/page.rs index 503154ec7a..87f766869e 100644 --- a/crates/engine/src/cmd/page.rs +++ b/crates/engine/src/cmd/page.rs @@ -250,6 +250,26 @@ pub fn section_index_of_focus(s: &Session) -> usize { } } +/// The caret's section, for the header and footer commands. In a header or footer it is the +/// section of the caret's page when that page shows it: a section linked to the previous one +/// shows that section's header, so the header alone names the earlier section (#3639). +pub fn hf_section_of_focus(s: &mut Session) -> usize { + let wordcraft_doc::StoryRef::Part(id) = s.sel.focus.story else { return section_index_of_focus(s) }; + let layout = s.layout(); + match layout.pages.get(s.page_hint) { + Some(pg) if pg.header_story == Some(id) || pg.footer_story == Some(id) => pg.section, + _ => section_of_part(s, id), + } +} + +/// The last body block of the caret's section ([`hf_section_of_focus`]), the block +/// [`wordcraft_doc::Document::section_mut`] takes. In a header or footer the caret's block index +/// counts that story's paragraphs, not the body's, so it would name another section (#3639). +pub fn section_end_of_focus(s: &mut Session) -> usize { + let i = hf_section_of_focus(s); + s.doc.sections().get(i).map(|(end, _)| *end).unwrap_or(0) +} + pub fn sect(s: &Session) -> SectionProps { let i = section_index_of_focus(s); s.doc.sections().get(i).map(|(_, x)| (*x).clone()).unwrap_or_default() diff --git a/crates/engine/src/cmd/para.rs b/crates/engine/src/cmd/para.rs index 1eeafa87d3..1feecb1bda 100644 --- a/crates/engine/src/cmd/para.rs +++ b/crates/engine/src/cmd/para.rs @@ -200,7 +200,7 @@ pub fn specs() -> Vec { r#"{"color": "RRGGBB" | null, "paragraph"?: bool} (text selected inside one paragraph is shaded itself, as in Word; `paragraph: true` shades the paragraphs instead, as Borders and Shading › Apply to: Paragraph)"#, ), CommandSpec::new("para.borders", "Borders", "Home › Paragraph", borders).params( - r#"{"kind": "bottom|top|left|right|none|all|outside|inside|horizontalLine", "width"?: pt, "color"?: "RRGGBB", "style"?: "single|double|dotted|dashed|thick|triple|dotDash|wave", "sides"?: Sides} where Sides = {"top"|"left"|"bottom"|"right"|"between": {"style"?, "width"?: pt, "color"?: "RRGGBB"} | null}: exactly these sides (others off), instead of `kind`"#, + r#"{"kind": "bottom|top|left|right|none|all|outside|inside|horizontalLine", "width"?: pt, "color"?: "RRGGBB", "style"?: "single|double|dotted|dashed|thick|triple|dotDash|wave", "sides"?: Sides} where Sides = {"top"|"left"|"bottom"|"right"|"between": {"style"?, "width"?: pt, "color"?: "RRGGBB"} | null}: exactly these sides (others off), instead of `kind` (with whole table cells selected, `kind` borders the cells as a block instead of their paragraphs)"#, ), CommandSpec::new("para.sort", "Sort", "Home › Paragraph", sort).params(r#"{"descending"?: bool}"#), CommandSpec::new("para.keepNext", "Keep with Next", "Home › Paragraph › Line and Page Breaks", |s, v| tog(s, v, |p| p.keep_next, |p, b| p.keep_next = Some(b))) diff --git a/crates/engine/src/cmd/para/tabs_borders.rs b/crates/engine/src/cmd/para/tabs_borders.rs index f4fb30e756..02405ea1b1 100644 --- a/crates/engine/src/cmd/para/tabs_borders.rs +++ b/crates/engine/src/cmd/para/tabs_borders.rs @@ -102,6 +102,10 @@ pub(super) fn borders(s: &mut Session, v: &Value) -> CmdResult { // A paragraph with a bottom border, like Word's Horizontal Line. return fmt(s, &|p| p.borders = Some(Borders { bottom: Some(Border { width: 1.5, ..b }), ..Default::default() })); } + // Whole table cells selected: the border goes on the cells, not their paragraphs (#7874). + if let Some(range) = s.cell_range().cloned() { + return crate::cmd::table::cell_block_borders(s, &range, kind, b); + } fmt(s, &|p| { let mut cur = p.borders.unwrap_or_default(); match kind { diff --git a/crates/engine/src/cmd/paste.rs b/crates/engine/src/cmd/paste.rs index 507b0b447c..92024f6233 100644 --- a/crates/engine/src/cmd/paste.rs +++ b/crates/engine/src/cmd/paste.rs @@ -187,7 +187,7 @@ fn paste_special(s: &mut Session, v: &Value) -> CmdResult { return Ok(r); } "formatted" => s.clipboard.clone().ok_or_else(|| CmdError::Failed("the clipboard is empty".into()))?, - "html" => adopt(s, import_html(&src)), + "html" => adopt(s, import_html(&src).map_err(|e| CmdError::Failed(format!("bad HTML: {e}")))?), _ => adopt(s, wordcraft_formats::rtf::import(src.as_bytes()).map_err(|e| CmdError::Failed(format!("bad RTF: {e}")))?), }; insert(s, frag)?; @@ -204,8 +204,8 @@ const BLOCKQUOTE_INDENT: f32 = 36.0; /// (#1270): it pastes as a Normal paragraph indented by the page's `blockquote` margins, else half /// an inch each side, rather than in the (centred, italic) Quote style. Opening an .html file keeps /// `
` as Quote, so HTML round-trips. -fn import_html(html: &str) -> Document { - let mut doc = wordcraft_formats::html::import(html_fragment(html)); +fn import_html(html: &str) -> Result { + let mut doc = wordcraft_formats::html::import(html_fragment(html))?; let (left, right) = blockquote_margins(html); for b in &mut doc.body { each_para(Arc::make_mut(b), 0, &mut |p| { @@ -217,7 +217,7 @@ fn import_html(html: &str) -> Document { } }); } - doc + Ok(doc) } /// The left and right margins (points) the payload's `