mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
Read IDML guides through shared model
This commit is contained in:
3 files changed
+28
-24
No files matched your search
Generated
+12
-12
@@ -1225,10 +1225,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-idml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e#4f4f8f8bc6b4cc850279f927808252d32f7c866e"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5#356ddacd1aac03c285b90a0596a7320ddf5eebb5"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5)",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
@@ -1578,7 +1578,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=40525913633942f84b06d4837a8d90534a55d63f#40525913633942f84b06d4837a8d90534a55d63f"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5#356ddacd1aac03c285b90a0596a7320ddf5eebb5"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1587,7 +1587,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e#4f4f8f8bc6b4cc850279f927808252d32f7c866e"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=40525913633942f84b06d4837a8d90534a55d63f#40525913633942f84b06d4837a8d90534a55d63f"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1614,7 +1614,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/dylanmtaylor/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1#f23b0f33f0d00b157476533a43cbbcfd901aa1f1"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1#f23b0f33f0d00b157476533a43cbbcfd901aa1f1"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
@@ -1633,7 +1633,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e#4f4f8f8bc6b4cc850279f927808252d32f7c866e"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5#356ddacd1aac03c285b90a0596a7320ddf5eebb5"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1914,8 +1914,8 @@ dependencies = [
|
||||
"craft-prepress",
|
||||
"craft-print",
|
||||
"craft-svg 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=2e670cf9377b523112f3fe4b409399772c745895)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1)",
|
||||
"designcraft-color",
|
||||
"designcraft-compose",
|
||||
"designcraft-doc",
|
||||
@@ -1998,8 +1998,8 @@ dependencies = [
|
||||
name = "designcraft-idml"
|
||||
version = "0.20.1"
|
||||
dependencies = [
|
||||
"craft-idml 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5)",
|
||||
"designcraft-color",
|
||||
"designcraft-compose",
|
||||
"designcraft-doc",
|
||||
@@ -2116,7 +2116,7 @@ version = "0.20.1"
|
||||
dependencies = [
|
||||
"craft-docx",
|
||||
"craft-file-formats",
|
||||
"craft-idml 0.1.0 (git+https://github.com/dylanmtaylor/craft-libs?rev=4f4f8f8bc6b4cc850279f927808252d32f7c866e)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=356ddacd1aac03c285b90a0596a7320ddf5eebb5)",
|
||||
"craft-rtf",
|
||||
"craft-wordmodel",
|
||||
"craft-xlsx",
|
||||
|
||||
+3
-3
@@ -16,11 +16,11 @@ craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4052591363
|
||||
craft-document-bundle = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", 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/dylanmtaylor/craft-libs", rev = "4f4f8f8bc6b4cc850279f927808252d32f7c866e", version = "=0.1.0" }
|
||||
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "356ddacd1aac03c285b90a0596a7320ddf5eebb5", 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/dylanmtaylor/craft-libs", rev = "2e670cf9377b523112f3fe4b409399772c745895", version = "=0.1.0", features = ["tree-render", "tree-text"] }
|
||||
craft-xml = { git = "https://github.com/dylanmtaylor/craft-libs", rev = "4f4f8f8bc6b4cc850279f927808252d32f7c866e", version = "=0.1.0" }
|
||||
craft-xml-dtd = { package = "craft-xml", git = "https://github.com/dylanmtaylor/craft-libs", rev = "f23b0f33f0d00b157476533a43cbbcfd901aa1f1", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "356ddacd1aac03c285b90a0596a7320ddf5eebb5", 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" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
|
||||
|
||||
@@ -30,11 +30,11 @@ impl<'r> Importer<'r> {
|
||||
/// Ruler guides of a `<Page>` (its `<Guide>` children), `page` its rectangle in our spread
|
||||
/// coordinates. A guide's Location is measured from the ruler origin: the spread's top left, the
|
||||
/// page's, or the spine. Fit to Page off: the guide crosses the spread.
|
||||
fn guides_of(&self, p: &El, page: Rect, spine: f64) -> Vec<Guide> {
|
||||
p.find_all("Guide")
|
||||
fn guides_of(&self, p: &craft_idml::model::Page, page: Rect, spine: f64) -> Vec<Guide> {
|
||||
p.guides()
|
||||
.filter_map(|g| {
|
||||
let at = g.num("Location").filter(|v| v.is_finite() && v.abs() < 1e7)?;
|
||||
let orientation = if g.get("Orientation") == Some("Horizontal") { Orientation::Horizontal } else { Orientation::Vertical };
|
||||
let at = g.location().filter(|v| v.is_finite() && v.abs() < 1e7)?;
|
||||
let orientation = if g.horizontal() { Orientation::Horizontal } else { Orientation::Vertical };
|
||||
let position = match (orientation, self.settings.ruler_origin) {
|
||||
(Orientation::Horizontal, designcraft_doc::RulerOrigin::Page) => page.y0 + at,
|
||||
(Orientation::Horizontal, _) => at,
|
||||
@@ -45,10 +45,10 @@ impl<'r> Importer<'r> {
|
||||
Some(Guide {
|
||||
orientation,
|
||||
position,
|
||||
spread: g.get("FitToPage") == Some("false"),
|
||||
locked: g.get("Locked") == Some("true"),
|
||||
layer: g.get("ItemLayer").and_then(|l| self.layer_ids.get(l)).copied(),
|
||||
liquid: g.get("GuideType") == Some("Liquid"),
|
||||
spread: !g.fit_to_page(),
|
||||
locked: g.locked(),
|
||||
layer: g.item_layer().and_then(|l| self.layer_ids.get(l)).copied(),
|
||||
liquid: g.liquid(),
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
@@ -138,7 +138,11 @@ impl<'r> Importer<'r> {
|
||||
parent,
|
||||
side,
|
||||
overridden: vec![],
|
||||
guides: self.guides_of(p, Rect::new(r.x0 - min_x, r.y0 - min_y, r.x1 - min_x, r.y1 - min_y), spine),
|
||||
guides: self.guides_of(
|
||||
&craft_idml::model::Page::from_el(&crate::xml::to_craft(p)),
|
||||
Rect::new(r.x0 - min_x, r.y0 - min_y, r.x1 - min_x, r.y1 - min_y),
|
||||
spine,
|
||||
),
|
||||
show_parent_items: show,
|
||||
liquid: names::liquid_rule_in(p.get("LayoutRule").unwrap_or("Off")),
|
||||
transition: None,
|
||||
|
||||
Reference in new issue
Block a user