mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-22 05:52:37 -06:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d18b0b9026 |
Generated
+133
-106
@@ -195,15 +195,6 @@ version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed"
|
||||
dependencies = [
|
||||
"derive_arbitrary",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arboard"
|
||||
version = "3.7.0"
|
||||
@@ -1120,7 +1111,7 @@ dependencies = [
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.3.2",
|
||||
"objc2-foundation 0.3.2",
|
||||
"skrifa",
|
||||
"skrifa 0.44.0",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
@@ -1150,7 +1141,7 @@ dependencies = [
|
||||
"verifysign",
|
||||
"winreg",
|
||||
"winsafe",
|
||||
"zip 9.1.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1253,7 +1244,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=010702ee9b030844c85293
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
"zip 9.1.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1263,7 +1254,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=a20dfd1623709b0bd98301
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
"zip 9.1.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1391,17 +1382,6 @@ version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"
|
||||
|
||||
[[package]]
|
||||
name = "derive_arbitrary"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b034bd7d5f032402a2479444dcc6f74e36a03f31854d41680fb240ef682a1ac"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dify"
|
||||
version = "0.8.0"
|
||||
@@ -1533,7 +1513,7 @@ dependencies = [
|
||||
"objc2-foundation 0.3.2",
|
||||
"parking_lot",
|
||||
"percent-encoding",
|
||||
"pollster 1.0.1",
|
||||
"pollster",
|
||||
"profiling",
|
||||
"raw-window-handle",
|
||||
"send_wrapper",
|
||||
@@ -1648,7 +1628,7 @@ dependencies = [
|
||||
"kittest",
|
||||
"log",
|
||||
"open",
|
||||
"pollster 1.0.1",
|
||||
"pollster",
|
||||
"serde",
|
||||
"tempfile",
|
||||
"toml",
|
||||
@@ -1741,13 +1721,13 @@ dependencies = [
|
||||
"emath",
|
||||
"epaint_default_fonts",
|
||||
"font-types",
|
||||
"harfrust",
|
||||
"harfrust 0.12.0",
|
||||
"log",
|
||||
"nohash-hasher",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"self_cell",
|
||||
"skrifa",
|
||||
"skrifa 0.44.0",
|
||||
"smallvec",
|
||||
"unicode-bidi",
|
||||
"unicode-general-category",
|
||||
@@ -1953,9 +1933,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "font-types"
|
||||
version = "0.12.6"
|
||||
version = "0.12.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c92d9081c7ab3bd83ef1eecdfad090f3d966e3ce74106779664114cfe1a6274"
|
||||
checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
@@ -2168,7 +2148,7 @@ dependencies = [
|
||||
"hashbrown 0.17.1",
|
||||
"log",
|
||||
"peniko",
|
||||
"skrifa",
|
||||
"skrifa 0.44.0",
|
||||
"smallvec",
|
||||
"vello_common",
|
||||
]
|
||||
@@ -2286,7 +2266,7 @@ dependencies = [
|
||||
"muda",
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.3.2",
|
||||
"pollster 1.0.1",
|
||||
"pollster",
|
||||
"rfd",
|
||||
"serde_json",
|
||||
"winit",
|
||||
@@ -2324,9 +2304,9 @@ dependencies = [
|
||||
"gridcraft-mcp",
|
||||
"gridcraft-sandbox",
|
||||
"log",
|
||||
"quick-xml 0.41.0",
|
||||
"quick-xml 0.42.0",
|
||||
"serde_json",
|
||||
"zip 3.0.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2363,7 +2343,7 @@ dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
"unicode-segmentation",
|
||||
"web-time",
|
||||
"zip 3.0.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2429,9 +2409,9 @@ version = "0.19.1"
|
||||
dependencies = [
|
||||
"craft-pdf",
|
||||
"craft-stream-codecs",
|
||||
"harfrust",
|
||||
"harfrust 0.16.0",
|
||||
"sha2 0.11.1",
|
||||
"skrifa",
|
||||
"skrifa 0.48.0",
|
||||
"unicode-bidi",
|
||||
]
|
||||
|
||||
@@ -2441,7 +2421,7 @@ version = "0.19.1"
|
||||
dependencies = [
|
||||
"landlock",
|
||||
"libc",
|
||||
"nix",
|
||||
"nix 0.32.0",
|
||||
"seccompiler",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -2464,7 +2444,7 @@ dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"skrifa",
|
||||
"skrifa 0.48.0",
|
||||
"sys-locale",
|
||||
"toml",
|
||||
"unicode-bidi",
|
||||
@@ -2511,10 +2491,10 @@ dependencies = [
|
||||
"gridcraft-functions",
|
||||
"gridcraft-math",
|
||||
"gridcraft-model",
|
||||
"quick-xml 0.41.0",
|
||||
"quick-xml 0.42.0",
|
||||
"sha2 0.11.1",
|
||||
"thiserror 2.0.21",
|
||||
"zip 3.0.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2565,10 +2545,23 @@ checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"read-fonts",
|
||||
"read-fonts 0.41.0",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "harfrust"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "741c9cd8fb2f39c393366b9cf13e8c31ad6adbbd9d817f0a18fe47cff36a3cca"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"read-fonts 0.47.0",
|
||||
"smallvec",
|
||||
"yoke",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
@@ -3193,9 +3186,9 @@ checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.190"
|
||||
version = "0.2.191"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
||||
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
@@ -3269,9 +3262,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.34"
|
||||
version = "0.4.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
||||
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
|
||||
|
||||
[[package]]
|
||||
name = "lru-slab"
|
||||
@@ -3454,9 +3447,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.31.3"
|
||||
version = "0.31.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
|
||||
checksum = "2bc81ce8148d3b4f3274da811f11cdd824ae661ee4ef732cdb229825cf5be7f7"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77730ed34f01f4990cb2ea67fec715ecebc6fab9a6396cf83c5529b13f581bdc"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cfg-if",
|
||||
@@ -3570,6 +3575,7 @@ dependencies = [
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-uniform-type-identifiers 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3788,7 +3794,7 @@ dependencies = [
|
||||
"objc2-link-presentation",
|
||||
"objc2-quartz-core 0.2.2",
|
||||
"objc2-symbols",
|
||||
"objc2-uniform-type-identifiers",
|
||||
"objc2-uniform-type-identifiers 0.2.2",
|
||||
"objc2-user-notifications",
|
||||
]
|
||||
|
||||
@@ -3815,6 +3821,16 @@ dependencies = [
|
||||
"objc2-foundation 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-uniform-type-identifiers"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7902ac02859fc1f7045f8b598c63f1ae0cc7efeaa06a9bc9f3d9a3c955974fa4"
|
||||
dependencies = [
|
||||
"objc2 0.6.5",
|
||||
"objc2-foundation 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-user-notifications"
|
||||
version = "0.2.2"
|
||||
@@ -3969,12 +3985,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
||||
checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
|
||||
dependencies = [
|
||||
"phf_macros 0.11.3",
|
||||
"phf_shared 0.11.3",
|
||||
"phf_macros 0.13.1",
|
||||
"phf_shared 0.13.1",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3990,12 +4007,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
|
||||
checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
|
||||
dependencies = [
|
||||
"phf_shared 0.11.3",
|
||||
"rand 0.8.8",
|
||||
"fastrand",
|
||||
"phf_shared 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4010,12 +4027,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf_macros"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
|
||||
checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
|
||||
dependencies = [
|
||||
"phf_generator 0.11.3",
|
||||
"phf_shared 0.11.3",
|
||||
"phf_generator 0.13.1",
|
||||
"phf_shared 0.13.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
@@ -4036,9 +4053,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.11.3"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
|
||||
checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
@@ -4143,15 +4160,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pollster"
|
||||
version = "0.4.0"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"
|
||||
|
||||
[[package]]
|
||||
name = "pollster"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc6355899e1c9462875b6757c79f3caa011a1fdae12bbb1a2e72dd1f234f8336"
|
||||
checksum = "3c2c80c4e3afbec8224b9d3e641fbf3a5690cc7595b887b0a27a926bb357ed5c"
|
||||
|
||||
[[package]]
|
||||
name = "polycool"
|
||||
@@ -4318,7 +4329,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"getrandom 0.4.3",
|
||||
"lru-slab",
|
||||
"rand 0.10.3",
|
||||
"rand",
|
||||
"rand_pcg",
|
||||
"ring",
|
||||
"rustc-hash 2.1.3",
|
||||
@@ -4366,15 +4377,6 @@ version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"
|
||||
dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.10.3"
|
||||
@@ -4415,11 +4417,11 @@ checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08"
|
||||
|
||||
[[package]]
|
||||
name = "ratex-font"
|
||||
version = "0.1.14"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a7b73531dabe934a3e725ed5c90d18dacf43778b7a208381390943a9a8c24db"
|
||||
checksum = "1c3599bafdf0e0637d1bb9cf97c01528eaa46fab0c6810c3959c2da5f66b2242"
|
||||
dependencies = [
|
||||
"phf 0.11.3",
|
||||
"phf 0.13.1",
|
||||
"ratex-types",
|
||||
]
|
||||
|
||||
@@ -4466,9 +4468,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratex-types"
|
||||
version = "0.1.14"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0cf0be3d050525f0f7d37af55a443d7648c222ccc617639950e3de1f8e6f9900"
|
||||
checksum = "74b856c4a2c1d4b9669a10f03b207f97e16a53119bf607501732b97b5c87007f"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -4522,6 +4524,33 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.45.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4edc8db0d972de88e53a085b1f01fb3fbdae7bb0cb7a0ce2b2f8285a412fe3ef"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"foldhash 0.2.0",
|
||||
"font-types",
|
||||
"once_cell",
|
||||
"yoke",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a39d2f8f681030a7bcbbcf3e8568775ac2393afd51401a2e2133ee89e3953897"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"foldhash 0.2.0",
|
||||
"font-types",
|
||||
"once_cell",
|
||||
"smallvec",
|
||||
"yoke",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
@@ -4635,9 +4664,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rfd"
|
||||
version = "0.17.2"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20dafead71c16a34e1ff357ddefc8afc11e7d51d6d2b9fbd07eaa48e3e540220"
|
||||
checksum = "c4b9d4857b10297ffb0f64cae711e983a7aeaee561848d56d429d3858bd8ed93"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"dispatch2",
|
||||
@@ -4648,8 +4677,9 @@ dependencies = [
|
||||
"objc2-app-kit 0.3.2",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-uniform-type-identifiers 0.3.2",
|
||||
"percent-encoding",
|
||||
"pollster 0.4.0",
|
||||
"pollster",
|
||||
"raw-window-handle",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
@@ -5178,7 +5208,7 @@ dependencies = [
|
||||
"const-oid 0.9.6",
|
||||
"der",
|
||||
"hex",
|
||||
"rand 0.10.3",
|
||||
"rand",
|
||||
"reqwest",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki",
|
||||
@@ -5270,7 +5300,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts",
|
||||
"read-fonts 0.41.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5213b4825bac3587046330052d61bfac7bd3bd0d203c758d7c2ef726fcea034"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts 0.45.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7240,20 +7280,6 @@ dependencies = [
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12598812502ed0105f607f941c386f43d441e00148fce9dec3ca5ffb0bde9308"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
"zopfli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "9.1.0"
|
||||
@@ -7265,9 +7291,10 @@ dependencies = [
|
||||
"getrandom 0.4.3",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
"nix",
|
||||
"nix 0.31.4",
|
||||
"typed-path",
|
||||
"windows-sys 0.61.2",
|
||||
"zopfli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
+6
-6
@@ -64,8 +64,8 @@ chrono = { version = "0.4.45", default-features = false, features = ["std", "clo
|
||||
web-time = "1.1.0"
|
||||
rayon = "1"
|
||||
regex = { version = "1", default-features = false, features = ["std", "unicode", "perf"] }
|
||||
quick-xml = "0.41"
|
||||
zip = { version = "3", default-features = false, features = ["deflate"] }
|
||||
quick-xml = "0.42"
|
||||
zip = { version = "9", default-features = false, features = ["deflate"] }
|
||||
sha2 = { version = "0.11", default-features = false }
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
|
||||
|
||||
@@ -73,21 +73,21 @@ image = { version = "0.25", default-features = false, features = ["png", "jpeg"]
|
||||
# young (0.1.x), and the gate recorded in docs/decisions.md vetted this release.
|
||||
ratex-parser = "=0.1.14"
|
||||
ratex-layout = "=0.1.14"
|
||||
ratex-types = "=0.1.14"
|
||||
ratex-font = "=0.1.14"
|
||||
ratex-types = "=0.1.16"
|
||||
ratex-font = "=0.1.16"
|
||||
|
||||
# ui
|
||||
egui = "0.37"
|
||||
egui_extras = { version = "0.37", default-features = false }
|
||||
eframe = { version = "0.37", default-features = false }
|
||||
egui_kittest = "0.37"
|
||||
rfd = "0.17"
|
||||
rfd = "0.18"
|
||||
arboard = { version = "3.6", default-features = false }
|
||||
# The desktop's preferred language, for the first-run interface language (native only).
|
||||
sys-locale = "0.3"
|
||||
# Font parser egui's epaint uses; the UI validates system font files with it before handing them
|
||||
# to egui, which panics on a file it can't parse. Same version as epaint's, so no second copy.
|
||||
skrifa = { version = "0.44", default-features = false, features = ["std"] }
|
||||
skrifa = { version = "0.48", default-features = false, features = ["std"] }
|
||||
# Real font bytes for tests (Ubuntu Light, compiled into epaint).
|
||||
epaint_default_fonts = "0.37"
|
||||
# One native window per workbook: the window list, Window menu titles and the immediate-viewport
|
||||
|
||||
@@ -12,7 +12,7 @@ workspace = true
|
||||
[dependencies]
|
||||
craft-pdf.workspace = true
|
||||
craft-stream-codecs.workspace = true
|
||||
harfrust = "=0.12.0"
|
||||
harfrust = "=0.16.0"
|
||||
skrifa = { workspace = true }
|
||||
unicode-bidi = "=0.3.18"
|
||||
|
||||
|
||||
@@ -19,4 +19,4 @@ seccompiler = "=0.5.0"
|
||||
libc = "0.2"
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
nix = { version = "=0.31.3", default-features = false, features = ["fs", "signal"] }
|
||||
nix = { version = "=0.32.0", default-features = false, features = ["fs", "signal"] }
|
||||
|
||||
@@ -467,35 +467,10 @@ fn xlsb_external_book_formulas_and_names_decode_and_roundtrip_through_xlsx() {
|
||||
tabs.extend(wide("Other Sheet"));
|
||||
ext_bin.extend(record(359, &tabs));
|
||||
ext_bin.extend(record(577, &wide("ExtName")));
|
||||
// BrtSupNameFmla (585): ExtPtgRef3D (0x3A, sheet 0..0, r=0, c=0)
|
||||
let mut fmla_payload = 9u32.to_le_bytes().to_vec();
|
||||
fmla_payload.push(0x3A);
|
||||
fmla_payload.extend(0u16.to_le_bytes());
|
||||
fmla_payload.extend(0u16.to_le_bytes());
|
||||
fmla_payload.extend(0u16.to_le_bytes());
|
||||
fmla_payload.extend(0u16.to_le_bytes());
|
||||
ext_bin.extend(record(585, &fmla_payload));
|
||||
let mut bits = vec![0u8; 7];
|
||||
bits[2..6].copy_from_slice(&0u32.to_le_bytes());
|
||||
ext_bin.extend(record(586, &bits));
|
||||
ext_bin.extend(record(587, &[]));
|
||||
// Sheet-scoped external name ("LocalExt" on sheet 1 -> sheetId="0")
|
||||
ext_bin.extend(record(577, &wide("LocalExt")));
|
||||
let mut local_bits = vec![0u8; 7];
|
||||
local_bits[2..6].copy_from_slice(&1u32.to_le_bytes());
|
||||
ext_bin.extend(record(586, &local_bits));
|
||||
ext_bin.extend(record(587, &[]));
|
||||
// BrtExternTableStart (363) with refreshError=1, row 0, and all 5 cell types.
|
||||
let mut t_start = 0u32.to_le_bytes().to_vec();
|
||||
t_start.push(1);
|
||||
ext_bin.extend(record(363, &t_start));
|
||||
ext_bin.extend(record(366, &0u32.to_le_bytes()));
|
||||
ext_bin.extend(record(367, &0u32.to_le_bytes()));
|
||||
ext_bin.extend(record(368, &[&1u32.to_le_bytes()[..], &4.5f64.to_le_bytes()[..]].concat()));
|
||||
ext_bin.extend(record(369, &[&2u32.to_le_bytes()[..], &[1u8]].concat()));
|
||||
ext_bin.extend(record(370, &[&3u32.to_le_bytes()[..], &[0x07u8]].concat()));
|
||||
ext_bin.extend(record(371, &[&4u32.to_le_bytes()[..], &wide("hi")[..]].concat()));
|
||||
ext_bin.extend(record(364, &[]));
|
||||
ext_bin.extend(record(588, &[]));
|
||||
|
||||
let fmla_num = |col: u32, cached: f64, rgce: &[u8]| {
|
||||
@@ -546,177 +521,9 @@ fn xlsb_external_book_formulas_and_names_decode_and_roundtrip_through_xlsx() {
|
||||
assert_eq!(c1.value, Value::Number(12.5));
|
||||
assert_eq!(c1.formula.as_ref().map(|f| f.text.as_str()), Some("[1]!ExtName"));
|
||||
|
||||
let saved = write_xlsx(&wb).unwrap();
|
||||
let (rt, _) = read_xlsx(&saved).unwrap();
|
||||
let (rt, _) = read_xlsx(&write_xlsx(&wb).unwrap()).unwrap();
|
||||
assert_eq!(rt.sheets[0].cell(CellRef::new(0, 0)).and_then(|c| c.formula.as_ref()).map(|f| f.text.as_str()), Some("[1]Data!$A$1"));
|
||||
assert_eq!(rt.sheets[0].value(CellRef::new(0, 0)), Value::Number(99.0));
|
||||
assert_eq!(rt.sheets[0].cell(CellRef::new(0, 1)).and_then(|c| c.formula.as_ref()).map(|f| f.text.as_str()), Some("[1]!ExtName"));
|
||||
assert_eq!(rt.sheets[0].value(CellRef::new(0, 1)), Value::Number(12.5));
|
||||
|
||||
// Verify the external workbook target relationship survives XLSB -> XLSX -> read_xlsx -> XLSX.
|
||||
let saved2 = write_xlsx(&rt).unwrap();
|
||||
let mut zip = zip::ZipArchive::new(std::io::Cursor::new(saved2)).unwrap();
|
||||
let read_zip = |z: &mut zip::ZipArchive<std::io::Cursor<Vec<u8>>>, name: &str| {
|
||||
let mut s = String::new();
|
||||
std::io::Read::read_to_string(&mut z.by_name(name).unwrap(), &mut s).unwrap();
|
||||
s
|
||||
};
|
||||
let wb_xml = read_zip(&mut zip, "xl/workbook.xml");
|
||||
assert!(wb_xml.contains("<externalReferences"), "{wb_xml}");
|
||||
let wb_rels = read_zip(&mut zip, "xl/_rels/workbook.xml.rels");
|
||||
let link_target = wb_rels
|
||||
.split("<Relationship ")
|
||||
.find(|r| r.contains("externalLink\""))
|
||||
.and_then(|r| r.split("Target=\"").nth(1))
|
||||
.and_then(|s| s.split('"').next())
|
||||
.expect("workbook.xml.rels should have an externalLink relationship")
|
||||
.trim_start_matches('/')
|
||||
.to_string();
|
||||
let link_part = if link_target.starts_with("xl/") { link_target } else { format!("xl/{link_target}") };
|
||||
let link_xml = read_zip(&mut zip, &link_part);
|
||||
assert!(link_xml.contains("<sheetName val=\"Data\"/>") && link_xml.contains("name=\"ExtName\""), "{link_xml}");
|
||||
let (dir, file) = link_part.rsplit_once('/').unwrap();
|
||||
let link_rels_xml = read_zip(&mut zip, &format!("{dir}/_rels/{file}.rels"));
|
||||
assert!(
|
||||
link_rels_xml.contains("externalLinkPath")
|
||||
&& link_rels_xml.contains("Target=\"Book2.xlsx\"")
|
||||
&& link_rels_xml.contains("TargetMode=\"External\""),
|
||||
"{link_rels_xml}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xlsb_external_link_ordinals_preserve_missing_slots_on_xlsx_save() {
|
||||
let mut wb_records = record(131, &[]);
|
||||
let mut props = 0u32.to_le_bytes().to_vec();
|
||||
props.extend(0u32.to_le_bytes());
|
||||
props.extend(wide(""));
|
||||
wb_records.extend(record(153, &props));
|
||||
wb_records.extend(record(143, &[]));
|
||||
let mut s1 = 0u32.to_le_bytes().to_vec();
|
||||
s1.extend(1u32.to_le_bytes());
|
||||
s1.extend(wide("one"));
|
||||
s1.extend(wide("Data"));
|
||||
wb_records.extend(record(156, &s1));
|
||||
wb_records.extend(record(144, &[]));
|
||||
// Book 0 = self, Book 1 = non-workbook DDE ("ext1"), Book 2 = valid workbook ("ext2").
|
||||
wb_records.extend(record(357, &[]));
|
||||
wb_records.extend(record(355, &wide("ext1")));
|
||||
wb_records.extend(record(355, &wide("ext2")));
|
||||
let mut xti = 2u32.to_le_bytes().to_vec();
|
||||
for (bk, first, last) in [(1u32, -2i32, -2i32), (2, 0, 0)] {
|
||||
xti.extend(bk.to_le_bytes());
|
||||
xti.extend(first.to_le_bytes());
|
||||
xti.extend(last.to_le_bytes());
|
||||
}
|
||||
wb_records.extend(record(362, &xti));
|
||||
wb_records.extend(record(132, &[]));
|
||||
|
||||
// DDE link part (links/dde1.bin): sbt=1 ("Excel", "topic") with item "R1C1".
|
||||
let mut dde_bin = Vec::new();
|
||||
let mut dde_begin = 1u16.to_le_bytes().to_vec();
|
||||
dde_begin.extend(wide("Excel"));
|
||||
dde_begin.extend(wide("topic"));
|
||||
dde_bin.extend(record(360, &dde_begin));
|
||||
dde_bin.extend(record(577, &wide("R1C1")));
|
||||
dde_bin.extend(record(586, &[0u8; 7]));
|
||||
dde_bin.extend(record(587, &[]));
|
||||
dde_bin.extend(record(588, &[]));
|
||||
|
||||
let mut ext_bin = Vec::new();
|
||||
let mut begin_sup = 0u16.to_le_bytes().to_vec();
|
||||
begin_sup.extend(wide("rId1"));
|
||||
begin_sup.extend(u32::MAX.to_le_bytes());
|
||||
ext_bin.extend(record(360, &begin_sup));
|
||||
let mut tabs = 1u32.to_le_bytes().to_vec();
|
||||
tabs.extend(wide("SheetA"));
|
||||
ext_bin.extend(record(359, &tabs));
|
||||
ext_bin.extend(record(588, &[]));
|
||||
|
||||
let fmla_num = |col: u32, cached: f64, rgce: &[u8]| {
|
||||
let mut data = col.to_le_bytes().to_vec();
|
||||
data.extend([0; 4]);
|
||||
data.extend(cached.to_le_bytes());
|
||||
data.extend([0; 2]);
|
||||
data.extend((rgce.len() as u32).to_le_bytes());
|
||||
data.extend(rgce);
|
||||
data.extend(0u32.to_le_bytes());
|
||||
record(9, &data)
|
||||
};
|
||||
let ptg_1 = [0x39, 0, 0, 1, 0, 0, 0];
|
||||
let ptg_2 = {
|
||||
let mut v = vec![0x3A, 1, 0];
|
||||
v.extend(0u32.to_le_bytes());
|
||||
v.extend(0u16.to_le_bytes());
|
||||
v
|
||||
};
|
||||
let mut data = row(0);
|
||||
data.extend(fmla_num(0, 11.0, &ptg_1));
|
||||
data.extend(fmla_num(1, 22.0, &ptg_2));
|
||||
|
||||
let rels = r#"<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="one" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="../data/one.bin"/><Relationship Id="strings" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="../text/strings.bin"/><Relationship Id="ext1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink" Target="../links/dde1.bin"/><Relationship Id="ext2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink" Target="../links/externalLink2.bin"/></Relationships>"#;
|
||||
let types = r#"<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Override PartName="/records/book.bin" ContentType="application/vnd.ms-excel.sheet.binary.macroEnabled.main"/><Override PartName="/data/one.bin" ContentType="application/vnd.ms-excel.worksheet"/><Override PartName="/text/strings.bin" ContentType="application/vnd.ms-excel.sharedStrings"/><Override PartName="/links/dde1.bin" ContentType="application/vnd.ms-excel.externalLink"/><Override PartName="/links/externalLink2.bin" ContentType="application/vnd.ms-excel.externalLink"/></Types>"#;
|
||||
let link_rels = r#"<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath" Target="SecondBook.xlsx" TargetMode="External"/></Relationships>"#;
|
||||
let bytes = make_zip(&[
|
||||
("[Content_Types].xml", types.as_bytes()),
|
||||
("_rels/.rels", ROOT.as_bytes()),
|
||||
("records/book.bin", &wb_records),
|
||||
("records/_rels/book.bin.rels", rels.as_bytes()),
|
||||
("data/one.bin", &worksheet(&data, &[])),
|
||||
("text/strings.bin", &sst()),
|
||||
("links/dde1.bin", &dde_bin),
|
||||
("links/externalLink2.bin", &ext_bin),
|
||||
("links/_rels/externalLink2.bin.rels", link_rels.as_bytes()),
|
||||
]);
|
||||
|
||||
let (wb, report) = read_xlsb(&bytes).unwrap();
|
||||
assert!(report.warnings.iter().any(|w| w.contains("unresolved or non-workbook external links")), "{:?}", report.warnings);
|
||||
assert!(report.warnings.iter().any(|w| w.contains("replaced with their cached values")), "{:?}", report.warnings);
|
||||
assert!(wb.sheets[0].cell(CellRef::new(0, 0)).is_some_and(|c| c.formula.is_none() && c.value == Value::Number(11.0)));
|
||||
assert_eq!(wb.sheets[0].cell(CellRef::new(0, 1)).and_then(|c| c.formula.as_ref()).map(|f| f.text.as_str()), Some("[1]SheetA!$A$1"));
|
||||
|
||||
// Also verify numeric structured-table headers like `SUM(Sales[2024])` are not mistaken for
|
||||
// external ordinals when an omitted DDE link triggers ordinal remapping.
|
||||
assert_eq!(crate::xlsb::remap_external_formula("SUM(Sales[2024])", &[None, None, Some(1)]), Ok(None));
|
||||
assert_eq!(crate::xlsb::remap_external_formula("Sales[[#Headers],[2024]]", &[None, None, Some(1)]), Ok(None));
|
||||
assert_eq!(
|
||||
crate::xlsb::remap_external_formula("'[2]Other Sheet'!A1+SUM(Sales[2024])", &[None, None, Some(1)]),
|
||||
Ok(Some("'[1]Other Sheet'!A1+SUM(Sales[2024])".into()))
|
||||
);
|
||||
assert_eq!(crate::xlsb::remap_external_formula("[1]!'R1C1'+SUM(Sales[2024])", &[None, None, Some(1)]), Err(()));
|
||||
|
||||
let saved = write_xlsx(&wb).unwrap();
|
||||
let (reopened, rep2) = read_xlsx(&saved).unwrap();
|
||||
assert!(!rep2.warnings.iter().any(|w| w.contains("dropped")), "{:?}", rep2.warnings);
|
||||
assert!(reopened.sheets[0].cell(CellRef::new(0, 0)).is_some_and(|c| c.formula.is_none() && c.value == Value::Number(11.0)));
|
||||
assert_eq!(reopened.sheets[0].cell(CellRef::new(0, 1)).and_then(|c| c.formula.as_ref()).map(|f| f.text.as_str()), Some("[1]SheetA!$A$1"));
|
||||
|
||||
let saved2 = write_xlsx(&reopened).unwrap();
|
||||
let mut zip = zip::ZipArchive::new(std::io::Cursor::new(saved2)).unwrap();
|
||||
let read_zip = |z: &mut zip::ZipArchive<std::io::Cursor<Vec<u8>>>, name: &str| {
|
||||
let mut s = String::new();
|
||||
std::io::Read::read_to_string(&mut z.by_name(name).unwrap(), &mut s).unwrap();
|
||||
s
|
||||
};
|
||||
let wb_xml = read_zip(&mut zip, "xl/workbook.xml");
|
||||
let ref_ids: Vec<&str> =
|
||||
wb_xml.split("<externalReference ").skip(1).filter_map(|s| s.split("r:id=\"").nth(1).and_then(|t| t.split('"').next())).collect();
|
||||
assert_eq!(ref_ids.len(), 1, "only the surviving external link should be emitted: {wb_xml}");
|
||||
let wb_rels = read_zip(&mut zip, "xl/_rels/workbook.xml.rels");
|
||||
let link_target = wb_rels
|
||||
.split("<Relationship ")
|
||||
.find(|r| r.contains(&format!("Id=\"{}\"", ref_ids[0])))
|
||||
.and_then(|r| r.split("Target=\"").nth(1))
|
||||
.and_then(|s| s.split('"').next())
|
||||
.expect("externalReference r:id should resolve in workbook.xml.rels")
|
||||
.trim_start_matches('/');
|
||||
let link_part = if link_target.starts_with("xl/") { link_target.to_string() } else { format!("xl/{link_target}") };
|
||||
let link_xml = read_zip(&mut zip, &link_part);
|
||||
assert!(link_xml.contains("<externalBook ") && link_xml.contains("<sheetName val=\"SheetA\"/>"), "{link_xml}");
|
||||
let (dir, file) = link_part.rsplit_once('/').unwrap();
|
||||
let link_rels = read_zip(&mut zip, &format!("{dir}/_rels/{file}.rels"));
|
||||
assert!(
|
||||
link_rels.contains("externalLinkPath") && link_rels.contains("Target=\"SecondBook.xlsx\"") && link_rels.contains("TargetMode=\"External\""),
|
||||
"{link_rels}"
|
||||
);
|
||||
}
|
||||
|
||||
+1
-252
@@ -2,15 +2,11 @@
|
||||
//! Cell values, formulas, defined names, and merged cells are imported; formatting, charts,
|
||||
//! images, macros and other workbook features are not imported.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Write as _;
|
||||
use std::sync::Arc;
|
||||
|
||||
use gridcraft_core::{CellError, CellRef, DateSystem, RangeRef, Value};
|
||||
use gridcraft_model::{Cell, DefinedName, Formula, Preserved, PreservedPart, PreservedRel, PreservedXml, Sheet, StyleId, Visibility, Workbook};
|
||||
use gridcraft_model::{Cell, DefinedName, Formula, Sheet, StyleId, Visibility, Workbook};
|
||||
|
||||
use crate::write::{NS_MAIN, NS_REL, XML_DECL};
|
||||
use crate::xml::{esc, esc_attr};
|
||||
use crate::{IoError, ReadReport};
|
||||
|
||||
fn map_error(err: craft_xlsx::Error) -> IoError {
|
||||
@@ -193,14 +189,6 @@ pub fn read_xlsb(bytes: &[u8]) -> Result<(Workbook, ReadReport), IoError> {
|
||||
wb.sheets.push(Arc::new(sheet));
|
||||
}
|
||||
import_defined_names(&book, &file_to_model, &mut wb);
|
||||
let external_links = package.external_links(&book).map_err(map_error)?;
|
||||
let (preserved, ordinal_map) = preserve_external_links(&external_links, &mut report);
|
||||
if let Some(preserved) = preserved {
|
||||
wb.preserved = Some(Arc::new(preserved));
|
||||
}
|
||||
if let Some(remap) = ordinal_map {
|
||||
remap_workbook_external_ordinals(&mut wb, &remap, &mut report);
|
||||
}
|
||||
for warning in package.warnings() {
|
||||
report.warn(warning);
|
||||
}
|
||||
@@ -214,242 +202,3 @@ pub fn read_xlsb(bytes: &[u8]) -> Result<(Workbook, ReadReport), IoError> {
|
||||
pub(crate) fn is_xlsb(bytes: &[u8]) -> bool {
|
||||
craft_xlsx::is_xlsb(bytes)
|
||||
}
|
||||
|
||||
fn preserve_external_links(
|
||||
links: &[(String, Option<craft_xlsx::ExternalLink>)],
|
||||
report: &mut ReadReport,
|
||||
) -> (Option<Preserved>, Option<Vec<Option<usize>>>) {
|
||||
if links.is_empty() {
|
||||
return (None, None);
|
||||
}
|
||||
const CT_EXT_LINK: &str = "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml";
|
||||
let mut p = Preserved::default();
|
||||
let mut refs_xml = format!("<externalReferences xmlns:r=\"{NS_REL}\">");
|
||||
let mut remap = vec![None; links.len() + 1];
|
||||
let mut next_ordinal = 0usize;
|
||||
let mut had_unpreserved = false;
|
||||
for (i, (_, link)) in links.iter().enumerate() {
|
||||
let Some(craft_xlsx::ExternalLink::Book(book)) = link else {
|
||||
had_unpreserved = true;
|
||||
continue;
|
||||
};
|
||||
if book.target.is_none() {
|
||||
had_unpreserved = true;
|
||||
continue;
|
||||
}
|
||||
next_ordinal += 1;
|
||||
let old_ordinal = i + 1;
|
||||
remap[old_ordinal] = Some(next_ordinal);
|
||||
let rid = format!("rId{next_ordinal}");
|
||||
let part_name = format!("xl/externalLinks/externalLink{next_ordinal}.xml");
|
||||
let (xml, rels) = external_link_part_xml(book);
|
||||
p.rels.push(PreservedRel { id: rid.clone(), rel_type: format!("{NS_REL}/externalLink"), target: part_name.clone(), external: false });
|
||||
p.parts.push(PreservedPart { name: part_name, content_type: CT_EXT_LINK.into(), data: xml.into_bytes().into(), rels });
|
||||
let _ = write!(refs_xml, "<externalReference r:id=\"{rid}\"/>");
|
||||
}
|
||||
if had_unpreserved {
|
||||
report.warn("XLSB: unresolved or non-workbook external links kept their cached values; their targets could not be preserved");
|
||||
}
|
||||
let preserved = if next_ordinal == 0 {
|
||||
None
|
||||
} else {
|
||||
refs_xml.push_str("</externalReferences>");
|
||||
p.elements.push(PreservedXml { slot: "externalReferences".into(), xml: refs_xml });
|
||||
Some(p)
|
||||
};
|
||||
(preserved, had_unpreserved.then_some(remap))
|
||||
}
|
||||
|
||||
fn remap_workbook_external_ordinals(wb: &mut Workbook, remap: &[Option<usize>], report: &mut ReadReport) {
|
||||
let mut dropped = false;
|
||||
for sheet_arc in &mut wb.sheets {
|
||||
let sheet = Arc::make_mut(sheet_arc);
|
||||
let coords: Vec<CellRef> = sheet.cells.iter().filter(|(_, c)| c.formula.is_some()).map(|(pos, _)| pos).collect();
|
||||
for pos in coords {
|
||||
let Some(cell) = sheet.cells.get_mut(pos) else { continue };
|
||||
let Some(fm) = &cell.formula else { continue };
|
||||
match remap_external_formula(&fm.text, remap) {
|
||||
Ok(Some(rewritten)) => {
|
||||
let mut updated = (**fm).clone();
|
||||
updated.text = rewritten;
|
||||
cell.formula = Some(Arc::new(updated));
|
||||
}
|
||||
Ok(None) => {}
|
||||
Err(()) => {
|
||||
cell.formula = None;
|
||||
dropped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut kept_names = Vec::with_capacity(wb.names.len());
|
||||
for mut name in std::mem::take(&mut wb.names) {
|
||||
match remap_external_formula(&name.formula, remap) {
|
||||
Ok(Some(rewritten)) => {
|
||||
name.formula = rewritten;
|
||||
kept_names.push(name);
|
||||
}
|
||||
Ok(None) => kept_names.push(name),
|
||||
Err(()) => dropped = true,
|
||||
}
|
||||
}
|
||||
wb.names = kept_names;
|
||||
if dropped {
|
||||
report.warn("XLSB: formulas referencing unresolved external links were replaced with their cached values");
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn remap_external_formula(text: &str, remap: &[Option<usize>]) -> Result<Option<String>, ()> {
|
||||
let bytes = text.as_bytes();
|
||||
let mut out: Option<String> = None;
|
||||
let mut i = 0;
|
||||
let mut copied = 0;
|
||||
let mut in_string = false;
|
||||
while i < bytes.len() {
|
||||
if bytes[i] == b'"' {
|
||||
in_string = !in_string;
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
if !in_string && bytes[i] == b'[' {
|
||||
let mut j = i + 1;
|
||||
while j < bytes.len() && bytes[j].is_ascii_digit() {
|
||||
j += 1;
|
||||
}
|
||||
if j > i + 1
|
||||
&& j < bytes.len()
|
||||
&& bytes[j] == b']'
|
||||
&& is_external_ordinal(text, i, j)
|
||||
&& let Ok(old) = text[i + 1..j].parse::<usize>()
|
||||
{
|
||||
let Some(&Some(new_n)) = remap.get(old) else {
|
||||
return Err(());
|
||||
};
|
||||
if new_n != old {
|
||||
let buf = out.get_or_insert_with(|| String::with_capacity(text.len()));
|
||||
buf.push_str(&text[copied..=i]);
|
||||
let _ = write!(buf, "{new_n}]");
|
||||
i = j + 1;
|
||||
copied = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if let Some(mut buf) = out {
|
||||
buf.push_str(&text[copied..]);
|
||||
Ok(Some(buf))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
/// True when `[digits]` at `open..=close` is an external-book ordinal (`[1]Sheet!A1`,
|
||||
/// `'[1]Other Sheet'!A1`, `[1]!Name`) rather than a numeric structured-table column (`Sales[2024]`,
|
||||
/// `Sales[[#Headers],[2024]]`).
|
||||
fn is_external_ordinal(text: &str, open: usize, close: usize) -> bool {
|
||||
let bytes = text.as_bytes();
|
||||
let prev = open.checked_sub(1).map(|k| bytes[k]);
|
||||
if let Some(b) = prev
|
||||
&& (b.is_ascii_alphanumeric() || matches!(b, b'_' | b'.' | b'\\' | b']' | b'['))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let mut k = close + 1;
|
||||
if prev == Some(b'\'') {
|
||||
while k < bytes.len() {
|
||||
if bytes[k] == b'\'' {
|
||||
if bytes.get(k + 1) == Some(&b'\'') {
|
||||
k += 2;
|
||||
continue;
|
||||
}
|
||||
return bytes.get(k + 1) == Some(&b'!');
|
||||
}
|
||||
k += 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if bytes.get(k) == Some(&b'!') {
|
||||
return true;
|
||||
}
|
||||
let start = k;
|
||||
while k < bytes.len() && (bytes[k].is_ascii_alphanumeric() || matches!(bytes[k], b'_' | b'.') || bytes[k] >= 0x80) {
|
||||
k += 1;
|
||||
}
|
||||
k > start && bytes.get(k) == Some(&b'!')
|
||||
}
|
||||
|
||||
fn external_link_part_xml(book: &craft_xlsx::ExternalBook) -> (String, Vec<PreservedRel>) {
|
||||
let mut xml = format!("{XML_DECL}<externalLink xmlns=\"{NS_MAIN}\" xmlns:r=\"{NS_REL}\">");
|
||||
let mut rels = Vec::new();
|
||||
xml.push_str("<externalBook");
|
||||
if let Some(target) = &book.target {
|
||||
xml.push_str(" r:id=\"rId1\"");
|
||||
rels.push(PreservedRel { id: "rId1".into(), rel_type: format!("{NS_REL}/externalLinkPath"), target: target.clone(), external: true });
|
||||
}
|
||||
xml.push('>');
|
||||
if !book.sheet_names.is_empty() {
|
||||
xml.push_str("<sheetNames>");
|
||||
for name in &book.sheet_names {
|
||||
let _ = write!(xml, "<sheetName val=\"{}\"/>", esc_attr(name));
|
||||
}
|
||||
xml.push_str("</sheetNames>");
|
||||
}
|
||||
if !book.defined_names.is_empty() {
|
||||
xml.push_str("<definedNames>");
|
||||
for dn in &book.defined_names {
|
||||
let _ = write!(xml, "<definedName name=\"{}\"", esc_attr(&dn.name));
|
||||
if let Some(refers_to) = &dn.refers_to {
|
||||
let _ = write!(xml, " refersTo=\"{}\"", esc_attr(refers_to));
|
||||
}
|
||||
if let Some(sheet_id) = dn.sheet_id {
|
||||
let _ = write!(xml, " sheetId=\"{sheet_id}\"");
|
||||
}
|
||||
xml.push_str("/>");
|
||||
}
|
||||
xml.push_str("</definedNames>");
|
||||
}
|
||||
if !book.sheet_data.is_empty() {
|
||||
xml.push_str("<sheetDataSet>");
|
||||
for sd in &book.sheet_data {
|
||||
let _ = write!(xml, "<sheetData sheetId=\"{}\"", sd.sheet_id);
|
||||
if sd.refresh_error {
|
||||
xml.push_str(" refreshError=\"1\"");
|
||||
}
|
||||
xml.push('>');
|
||||
let mut rows: BTreeMap<u32, Vec<(craft_xlsx::CellRef, &craft_xlsx::Value)>> = BTreeMap::new();
|
||||
for (pos, val) in &sd.cells {
|
||||
rows.entry(pos.row).or_default().push((*pos, val));
|
||||
}
|
||||
for (r, cells) in rows {
|
||||
let _ = write!(xml, "<row r=\"{}\">", r + 1);
|
||||
for (pos, val) in cells {
|
||||
let r_attr = CellRef::new(pos.row, pos.col);
|
||||
match val {
|
||||
craft_xlsx::Value::Empty => {
|
||||
let _ = write!(xml, "<cell r=\"{r_attr}\"/>");
|
||||
}
|
||||
craft_xlsx::Value::Number(n) => {
|
||||
let _ = write!(xml, "<cell r=\"{r_attr}\"><v>{n}</v></cell>");
|
||||
}
|
||||
craft_xlsx::Value::Text(t) => {
|
||||
let _ = write!(xml, "<cell r=\"{r_attr}\" t=\"str\"><v>{}</v></cell>", esc(t));
|
||||
}
|
||||
craft_xlsx::Value::Bool(b) => {
|
||||
let _ = write!(xml, "<cell r=\"{r_attr}\" t=\"b\"><v>{}</v></cell>", if *b { "1" } else { "0" });
|
||||
}
|
||||
craft_xlsx::Value::Error(e) => {
|
||||
let _ = write!(xml, "<cell r=\"{r_attr}\" t=\"e\"><v>{}</v></cell>", esc(map_cell_error(*e).as_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
xml.push_str("</row>");
|
||||
}
|
||||
xml.push_str("</sheetData>");
|
||||
}
|
||||
xml.push_str("</sheetDataSet>");
|
||||
}
|
||||
xml.push_str("</externalBook></externalLink>");
|
||||
(xml, rels)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user