mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
Use shared IDML model for preference output
This commit is contained in:
3 files changed
+75
-83
No files matched your search
Generated
+26
-26
@@ -1242,10 +1242,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-idml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0#d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4#581e4324d9b4f31845644f4f2cfd296f9bdfcff4"
|
||||
dependencies = [
|
||||
"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)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4)",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
@@ -1653,6 +1653,15 @@ dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4#581e4324d9b4f31845644f4f2cfd296f9bdfcff4"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
@@ -1680,15 +1689,6 @@ 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"
|
||||
@@ -1717,6 +1717,16 @@ dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4#581e4324d9b4f31845644f4f2cfd296f9bdfcff4"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
"zip 9.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
@@ -1747,16 +1757,6 @@ dependencies = [
|
||||
"zip 9.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0#d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
"zip 9.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
@@ -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=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4)",
|
||||
"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=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4)",
|
||||
"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=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4)",
|
||||
"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=d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=581e4324d9b4f31845644f4f2cfd296f9bdfcff4)",
|
||||
"craft-rtf",
|
||||
"craft-wordmodel",
|
||||
"craft-xlsx",
|
||||
|
||||
+2
-2
@@ -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 = "d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0", version = "=0.1.0" }
|
||||
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "581e4324d9b4f31845644f4f2cfd296f9bdfcff4", 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 = "d34d9da3e9a834f1f39b5d5a60f1d42c2b6afcd0", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "581e4324d9b4f31845644f4f2cfd296f9bdfcff4", 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" }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::common::{bool_s, pct, pkg_root};
|
||||
use super::common::{bool_s, pkg_root};
|
||||
use super::spread::margin_el;
|
||||
use super::{El, Ex, PARA_BUILTINS, document, escape_id, names, num, pt, st};
|
||||
use craft_idml::model::{CompositeFontDefinition, CompositeFontEntryDefinition, FontDefinition, FontFamilyDefinition, FontsPart};
|
||||
@@ -64,42 +64,30 @@ impl<'a> Ex<'a> {
|
||||
let d = self.d;
|
||||
let s = &d.settings;
|
||||
let mut root = pkg_root("Preferences");
|
||||
root.push(
|
||||
El::new("DocumentPreference")
|
||||
.attr("PageHeight", num(s.page_height))
|
||||
.attr("PageWidth", num(s.page_width))
|
||||
// InDesign creates this many pages before reading the spreads and replaces only the first
|
||||
// spread, so (as InDesign itself writes) the value must be 1.
|
||||
.attr("PagesPerDocument", 1)
|
||||
.attr("FacingPages", bool_s(s.facing_pages))
|
||||
.attr("DocumentBleedTopOffset", num(s.bleed[0]))
|
||||
.attr("DocumentBleedBottomOffset", num(s.bleed[1]))
|
||||
.attr("DocumentBleedInsideOrLeftOffset", num(s.bleed[2]))
|
||||
.attr("DocumentBleedOutsideOrRightOffset", num(s.bleed[3]))
|
||||
.attr("DocumentBleedUniformSize", bool_s(s.bleed.iter().all(|b| *b == s.bleed[0])))
|
||||
.attr("SlugTopOffset", num(s.slug[0]))
|
||||
.attr("SlugBottomOffset", num(s.slug[1]))
|
||||
.attr("SlugInsideOrLeftOffset", num(s.slug[2]))
|
||||
.attr("SlugRightOrOutsideOffset", num(s.slug[3]))
|
||||
.attr("DocumentSlugUniformSize", bool_s(s.slug.iter().all(|b| *b == s.slug[0])))
|
||||
.attr("PreserveLayoutWhenShuffling", "true")
|
||||
.attr("AllowPageShuffle", "true")
|
||||
.attr("OverprintBlack", bool_s(s.overprint_black))
|
||||
.attr("PageBinding", if s.right_to_left_binding { "RightToLeft" } else { "LeftToRight" })
|
||||
.attr("ColumnDirection", "Horizontal")
|
||||
.attr(
|
||||
"Intent",
|
||||
match s.intent {
|
||||
designcraft_doc::Intent::Print => "PrintIntent",
|
||||
designcraft_doc::Intent::Web => "WebIntent",
|
||||
designcraft_doc::Intent::Mobile => "MobileIntent",
|
||||
},
|
||||
)
|
||||
.attr("CreatePrimaryTextFrame", bool_s(s.primary_text_frame))
|
||||
.attr("ColumnGuideLocked", bool_s(s.column_guides_locked))
|
||||
.attr("MasterTextFrame", bool_s(s.primary_text_frame))
|
||||
.attr("SnippetImportUsesOriginalLocation", "false"),
|
||||
);
|
||||
let document_preferences = craft_idml::model::DocumentPreferences {
|
||||
page_width: Some(s.page_width),
|
||||
page_height: Some(s.page_height),
|
||||
facing_pages: Some(s.facing_pages),
|
||||
page_binding: Some(if s.right_to_left_binding { "RightToLeft" } else { "LeftToRight" }.into()),
|
||||
bleed: s.bleed.map(Some),
|
||||
slug: s.slug.map(Some),
|
||||
overprint_black: Some(s.overprint_black),
|
||||
intent: Some(
|
||||
match s.intent {
|
||||
designcraft_doc::Intent::Print => "PrintIntent",
|
||||
designcraft_doc::Intent::Web => "WebIntent",
|
||||
designcraft_doc::Intent::Mobile => "MobileIntent",
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
primary_text_frame: Some(s.primary_text_frame),
|
||||
column_guides_locked: Some(s.column_guides_locked),
|
||||
};
|
||||
let mut document_preference = El::new("DocumentPreference");
|
||||
for (key, value) in document_preferences.to_export_attrs() {
|
||||
document_preference.set(&key, value);
|
||||
}
|
||||
root.push(document_preference);
|
||||
let page = d.parents.first().and_then(|p| p.pages.first()).or_else(|| d.page(0));
|
||||
if let Some(pg) = page {
|
||||
root.push(margin_el(pg));
|
||||
@@ -120,24 +108,28 @@ impl<'a> Ex<'a> {
|
||||
.attr("PointsPerInch", "72"),
|
||||
);
|
||||
let bg = &s.baseline_grid;
|
||||
root.push(
|
||||
El::new("GridPreference")
|
||||
.attr("HorizontalGridlineDivision", num(s.grid.horizontal))
|
||||
.attr("VerticalGridlineDivision", num(s.grid.vertical))
|
||||
.attr("HorizontalGridSubdivision", s.grid.subdivisions)
|
||||
.attr("VerticalGridSubdivision", s.grid.subdivisions)
|
||||
.attr("GridsInBack", bool_s(s.grid.in_back))
|
||||
.attr("BaselineStart", num(bg.start))
|
||||
.attr("BaselineDivision", num(bg.increment))
|
||||
.attr("BaselineViewThreshold", pct(bg.view_threshold))
|
||||
.attr(
|
||||
"BaselineGridRelativeOption",
|
||||
match bg.relative_to {
|
||||
designcraft_doc::GridRelative::TopOfPage => "TopOfPageOfBaselineGridRelativeOption",
|
||||
designcraft_doc::GridRelative::TopMargin => "TopOfMarginOfBaselineGridRelativeOption",
|
||||
},
|
||||
),
|
||||
);
|
||||
let grid_preferences = craft_idml::model::GridPreferences {
|
||||
horizontal_division: Some(s.grid.horizontal),
|
||||
vertical_division: Some(s.grid.vertical),
|
||||
horizontal_subdivision: Some(f64::from(s.grid.subdivisions)),
|
||||
vertical_subdivision: Some(f64::from(s.grid.subdivisions)),
|
||||
grids_in_back: Some(s.grid.in_back),
|
||||
baseline_start: Some(bg.start),
|
||||
baseline_division: Some(bg.increment),
|
||||
baseline_view_threshold: Some(bg.view_threshold * 100.0),
|
||||
baseline_relative_option: Some(
|
||||
match bg.relative_to {
|
||||
designcraft_doc::GridRelative::TopOfPage => "TopOfPageOfBaselineGridRelativeOption",
|
||||
designcraft_doc::GridRelative::TopMargin => "TopOfMarginOfBaselineGridRelativeOption",
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
};
|
||||
let mut grid_preference = El::new("GridPreference");
|
||||
for (key, value) in grid_preferences.to_attrs() {
|
||||
grid_preference.set(&key, value);
|
||||
}
|
||||
root.push(grid_preference);
|
||||
root.push(El::new("PasteboardPreference").attr("PasteboardMargins", pt(s.pasteboard.0, s.pasteboard.1)));
|
||||
root.push(self.footnote_option_el());
|
||||
root.push(El::new("TransparencyPreference").attr(
|
||||
|
||||
Reference in new issue
Block a user