Use shared IDML cell geometry values

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 05:34:23 -05:00
1 parent c473898e2f
commit 7f60f55d91
4 files changed
+27 -32

No files matched your search

Generated
+18 -18
View File
@@ -1242,10 +1242,10 @@ dependencies = [
[[package]]
name = "craft-idml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=b6f904c03#b6f904c03bfa70e5185464e817b752da6b986236"
source = "git+https://github.com/storytold/craft-libs?rev=d18d9759e#d18d9759e132fb4023365b9fa1f28fb55676478f"
dependencies = [
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b6f904c03)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b6f904c03)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d18d9759e)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d18d9759e)",
"thiserror 2.0.21",
]
@@ -1662,15 +1662,6 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=b6f904c03#b6f904c03bfa70e5185464e817b752da6b986236"
dependencies = [
"quick-xml 0.41.0",
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
@@ -1689,6 +1680,15 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=d18d9759e#d18d9759e132fb4023365b9fa1f28fb55676478f"
dependencies = [
"quick-xml 0.41.0",
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
@@ -1740,7 +1740,7 @@ dependencies = [
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=b6f904c03#b6f904c03bfa70e5185464e817b752da6b986236"
source = "git+https://github.com/storytold/craft-libs?rev=ba24fe2435adb3c81ad6057faf36365fbba736cf#ba24fe2435adb3c81ad6057faf36365fbba736cf"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -1750,7 +1750,7 @@ dependencies = [
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ba24fe2435adb3c81ad6057faf36365fbba736cf#ba24fe2435adb3c81ad6057faf36365fbba736cf"
source = "git+https://github.com/storytold/craft-libs?rev=d18d9759e#d18d9759e132fb4023365b9fa1f28fb55676478f"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -2021,7 +2021,7 @@ dependencies = [
"craft-prepress",
"craft-print",
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b6f904c03)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d18d9759e)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1)",
"designcraft-color",
"designcraft-compose",
@@ -2103,9 +2103,9 @@ name = "designcraft-idml"
version = "0.20.1"
dependencies = [
"craft-file-formats",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b6f904c03)",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d18d9759e)",
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b6f904c03)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d18d9759e)",
"designcraft-color",
"designcraft-compose",
"designcraft-doc",
@@ -2222,7 +2222,7 @@ version = "0.20.1"
dependencies = [
"craft-docx",
"craft-file-formats",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b6f904c03)",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d18d9759e)",
"craft-rtf",
"craft-wordmodel",
"craft-xlsx",
+2 -2
View File
@@ -16,10 +16,10 @@ craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4052591363
craft-designcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "19692b6190465671e41967c75d0cd4c439d0c84c", version = "=0.1.0" }
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
craft-epub = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "b6f904c03", version = "=0.1.0" }
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "d18d9759e", version = "=0.1.0" }
craft-indd = { git = "https://github.com/storytold/craft-libs", rev = "47bf5650b0d503b97bfb5e841746c4957897d11f", version = "=0.1.0" }
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "cc23ffd4d26f3074808e2187d332564817624f8f", version = "=0.1.0", features = ["tree-render", "tree-text"] }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "b6f904c03", version = "=0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "d18d9759e", version = "=0.1.0" }
craft-xml-dtd = { package = "craft-xml", git = "https://github.com/storytold/craft-libs", rev = "f23b0f33f0d00b157476533a43cbbcfd901aa1f1", version = "=0.1.0" }
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
+6 -6
View File
@@ -1,4 +1,4 @@
use super::values::{span, tint};
use super::values::tint;
use super::{CellRange, El, Importer, RowHeightMode, StoryId, Table, names, swatch};
/// Cells every table in one import may hold between them. A `Cell` carries a whole story, so
@@ -149,16 +149,16 @@ impl<'r> Importer<'r> {
column_strokes.apply_to(&mut t.options.column_strokes);
let mut regions = Vec::new();
for ce in e.find_all("Cell") {
let Some((c, r)) =
ce.get("Name").and_then(|n| n.split_once(':')).and_then(|(a, b)| Some((a.parse::<usize>().ok()?, b.parse::<usize>().ok()?)))
else {
let model_cell = craft_idml::model::Cell::from_el(&crate::xml::to_craft(ce));
let Some((c, r)) = model_cell.position().map(|(c, r)| (c as usize, r as usize)) else {
continue;
};
if r >= nr || c >= nc {
continue;
}
let rs = (span(ce, "RowSpan").max(1.0) as usize).min(nr - r);
let cs = (span(ce, "ColumnSpan").max(1.0) as usize).min(nc - c);
let (cs, rs) = model_cell.span();
let rs = (rs as usize).min(nr - r);
let cs = (cs as usize).min(nc - c);
let mut cell = t.cell(r, c).cloned().unwrap_or_default();
let cell_style = ce.get("AppliedCellStyle").map(|r| self.cell_style_ref(r)).unwrap_or_else(|| designcraft_doc::NO_CELL_STYLE.into());
if cell_style != designcraft_doc::NO_CELL_STYLE {
+1 -6
View File
@@ -1,4 +1,4 @@
use super::{Affine, Color, El, lab};
use super::{Affine, Color, lab};
/// An XMP date property, written as an element or an attribute.
pub(super) fn xmp_date(xmp: &str, key: &str) -> Option<i64> {
@@ -37,11 +37,6 @@ pub(super) fn tint(v: Option<f64>) -> Option<f32> {
v.map(|t| if t < 0.0 || t.is_nan() { 1.0 } else { (t / 100.0).min(1.0) as f32 })
}
/// A cell span count; an infinite span is kept so it clamps to the table edge.
pub(super) fn span(e: &El, k: &str) -> f64 {
e.prop(k).and_then(|v| v.trim().parse::<f64>().ok()).unwrap_or(1.0)
}
pub(super) fn finite(v: Option<f64>) -> Option<f64> {
v.filter(|v| v.is_finite())
}