Read document preferences through shared IDML model

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 08:24:20 -05:00
1 parent b373afcf7c
commit 5d1b5ccb17
3 files changed
+43 -44

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=b0d92234f14937517826880c5f44a290f98c1fb1#b0d92234f14937517826880c5f44a290f98c1fb1"
source = "git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0#d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0"
dependencies = [
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
"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=b0d92234f14937517826880c5f44a290f98c1fb1#b0d92234f14937517826880c5f44a290f98c1fb1"
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=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0#d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0"
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=b0d92234f14937517826880c5f44a290f98c1fb1#b0d92234f14937517826880c5f44a290f98c1fb1"
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=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0#d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0"
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=b0d92234f14937517826880c5f44a290f98c1fb1)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
"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=b0d92234f14937517826880c5f44a290f98c1fb1)",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
"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=b0d92234f14937517826880c5f44a290f98c1fb1)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
"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=b0d92234f14937517826880c5f44a290f98c1fb1)",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
"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 = "93d0998383aa150fa50a2ffbf49ef37786e37eca", 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 = "b0d92234f14937517826880c5f44a290f98c1fb1", version = "=0.1.0" }
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0", 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 = "b0d92234f14937517826880c5f44a290f98c1fb1", version = "=0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0", 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" }
+23 -24
View File
@@ -25,45 +25,43 @@ impl IndexTopic {
impl<'r> Importer<'r> {
pub(super) fn doc_prefs(&mut self, e: &El) {
let s = &mut self.settings;
if let Some(v) = e.get("OverprintBlack") {
s.overprint_black = v != "false";
let values = craft_idml::model::DocumentPreferences::from_el(&crate::xml::to_craft(e));
if let Some(v) = values.overprint_black {
s.overprint_black = v;
}
if let Some(v) = e.num("PageWidth") {
if let Some(v) = values.page_width {
s.page_width = v;
}
if let Some(v) = e.num("PageHeight") {
if let Some(v) = values.page_height {
s.page_height = v;
}
if let Some(v) = e.boolean("FacingPages") {
if let Some(v) = values.facing_pages {
s.facing_pages = v;
}
if let Some(v) = e.get("PageBinding") {
if let Some(v) = values.page_binding.as_deref() {
s.right_to_left_binding = v == "RightToLeft";
}
for (i, k) in ["DocumentBleedTopOffset", "DocumentBleedBottomOffset", "DocumentBleedInsideOrLeftOffset", "DocumentBleedOutsideOrRightOffset"]
.iter()
.enumerate()
{
if let Some(v) = e.num(k) {
for (i, value) in values.bleed.into_iter().enumerate() {
if let Some(v) = value {
s.bleed[i] = v;
}
}
for (i, k) in ["SlugTopOffset", "SlugBottomOffset", "SlugInsideOrLeftOffset", "SlugRightOrOutsideOffset"].iter().enumerate() {
if let Some(v) = e.num(k) {
for (i, value) in values.slug.into_iter().enumerate() {
if let Some(v) = value {
s.slug[i] = v;
}
}
if let Some(i) = e.get("Intent") {
if let Some(i) = values.intent.as_deref() {
s.intent = match i {
"WebIntent" => designcraft_doc::Intent::Web,
"MobileIntent" => designcraft_doc::Intent::Mobile,
_ => designcraft_doc::Intent::Print,
};
}
if let Some(v) = e.boolean("CreatePrimaryTextFrame") {
if let Some(v) = values.primary_text_frame {
s.primary_text_frame = v;
}
if let Some(v) = e.boolean("ColumnGuideLocked") {
if let Some(v) = values.column_guides_locked {
s.column_guides_locked = v;
}
}
@@ -71,28 +69,29 @@ impl<'r> Importer<'r> {
pub(super) fn grid_prefs(&mut self, e: &El) {
let s = &mut self.settings;
let bg: &mut BaselineGrid = &mut s.baseline_grid;
if let Some(v) = e.num("BaselineStart") {
let values = craft_idml::model::GridPreferences::from_el(&crate::xml::to_craft(e));
if let Some(v) = values.baseline_start {
bg.start = v;
}
if let Some(v) = e.num("BaselineDivision") {
if let Some(v) = values.baseline_division {
bg.increment = v;
}
if let Some(v) = e.num("BaselineViewThreshold") {
if let Some(v) = values.baseline_view_threshold {
bg.view_threshold = v / 100.0;
}
if let Some(v) = e.get("BaselineGridRelativeOption") {
if let Some(v) = values.baseline_relative_option.as_deref() {
bg.relative_to = if v.contains("Margin") { GridRelative::TopMargin } else { GridRelative::TopOfPage };
}
if let Some(v) = e.num("HorizontalGridlineDivision") {
if let Some(v) = values.horizontal_division {
s.grid.horizontal = v;
}
if let Some(v) = e.num("VerticalGridlineDivision") {
if let Some(v) = values.vertical_division {
s.grid.vertical = v;
}
if let Some(v) = e.num("HorizontalGridSubdivision") {
if let Some(v) = values.horizontal_subdivision {
s.grid.subdivisions = v.max(1.0) as u32;
}
if let Some(v) = e.boolean("GridsInBack") {
if let Some(v) = values.grids_in_back {
s.grid.in_back = v;
}
}