mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
Delegate IDML designmap root grammar to craft-idml
This commit is contained in:
4 files changed
+28
-31
No files matched your search
Generated
+9
-9
@@ -1242,10 +1242,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-idml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f22dfad3#4f22dfad31c0abb496b5f8db9444cb2d0d49ec80"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=5f1eb9262#5f1eb926265eb8f7d9dcc11e644115cc0ea57d85"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4f22dfad3)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4f22dfad3)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5f1eb9262)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5f1eb9262)",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
@@ -1656,7 +1656,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f22dfad3#4f22dfad31c0abb496b5f8db9444cb2d0d49ec80"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=5f1eb9262#5f1eb926265eb8f7d9dcc11e644115cc0ea57d85"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1730,7 +1730,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f22dfad3#4f22dfad31c0abb496b5f8db9444cb2d0d49ec80"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=5f1eb9262#5f1eb926265eb8f7d9dcc11e644115cc0ea57d85"
|
||||
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=4f22dfad3)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5f1eb9262)",
|
||||
"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=4f22dfad3)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5f1eb9262)",
|
||||
"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=4f22dfad3)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5f1eb9262)",
|
||||
"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=4f22dfad3)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5f1eb9262)",
|
||||
"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 = "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 = "4f22dfad3", version = "=0.1.0" }
|
||||
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "5f1eb9262", 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 = "4f22dfad3", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "5f1eb9262", 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" }
|
||||
|
||||
@@ -9,9 +9,9 @@ use designcraft_doc::{
|
||||
};
|
||||
use designcraft_geom::{Affine, PathData};
|
||||
|
||||
use crate::base64_encode;
|
||||
use crate::names::{self, CHAR_BUILTINS, OBJECT_BUILTINS, PARA_BUILTINS, escape_id, num, pt};
|
||||
use crate::xml::{El, Node, document};
|
||||
use crate::{DOM_VERSION, base64_encode};
|
||||
|
||||
mod common;
|
||||
mod designmap;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::common::{anchor_self, bool_s, p, uid, with_props, xref_format_self};
|
||||
use super::{CHAR_BUILTINS, DOM_VERSION, Document, El, Ex, HashSet, PARA_BUILTINS, escape_id, names, num};
|
||||
use super::{CHAR_BUILTINS, Document, El, Ex, HashSet, PARA_BUILTINS, escape_id, names, num};
|
||||
|
||||
impl<'a> Ex<'a> {
|
||||
// ---------- designmap ----------
|
||||
@@ -7,17 +7,14 @@ impl<'a> Ex<'a> {
|
||||
pub(super) fn designmap(&mut self, masters: &[(String, Vec<u8>)], spreads: &[(String, Vec<u8>)], stories: &[(String, Vec<u8>)]) -> Vec<u8> {
|
||||
let d = self.d;
|
||||
let story_list: Vec<String> = d.stories.keys().map(|k| uid(k.0)).collect();
|
||||
let mut root = El::new("Document")
|
||||
.attr("xmlns:idPkg", craft_idml::PACKAGING_NS)
|
||||
.attr("DOMVersion", DOM_VERSION)
|
||||
.attr("Self", "d")
|
||||
.attr("StoryList", story_list.join(" "))
|
||||
.attr("Name", format!("{}.indd", d.title))
|
||||
.attr("ZeroPoint", {
|
||||
let [x, y] = d.zero_point();
|
||||
format!("{} {}", num(x), num(y))
|
||||
})
|
||||
.attr("ActiveLayer", d.layers.first().map(|l| uid(l.id.0)).unwrap_or_else(|| "n".into()));
|
||||
let [x, y] = d.zero_point();
|
||||
let mut root = crate::xml::from_craft(craft_idml::designmap_root(
|
||||
"d",
|
||||
&story_list.join(" "),
|
||||
&format!("{}.indd", d.title),
|
||||
&format!("{} {}", num(x), num(y)),
|
||||
&d.layers.first().map(|l| uid(l.id.0)).unwrap_or_else(|| "n".into()),
|
||||
));
|
||||
root.push(
|
||||
El::new("Language")
|
||||
.attr("Self", "Language/$ID/[No Language]")
|
||||
@@ -64,9 +61,9 @@ impl<'a> Ex<'a> {
|
||||
for t in &d.styles.mojikumi_tables {
|
||||
root.push(mojikumi_table_el(t));
|
||||
}
|
||||
root.push(El::new("idPkg:Graphic").attr("src", "Resources/Graphic.xml"));
|
||||
root.push(El::new("idPkg:Fonts").attr("src", "Resources/Fonts.xml"));
|
||||
root.push(El::new("idPkg:Styles").attr("src", "Resources/Styles.xml"));
|
||||
root.push(crate::xml::from_craft(craft_idml::designmap_include("Graphic", "Resources/Graphic.xml")));
|
||||
root.push(crate::xml::from_craft(craft_idml::designmap_include("Fonts", "Resources/Fonts.xml")));
|
||||
root.push(crate::xml::from_craft(craft_idml::designmap_include("Styles", "Resources/Styles.xml")));
|
||||
root.push(
|
||||
El::new("NumberingList")
|
||||
.attr("Self", "NumberingList/$ID/[Default]")
|
||||
@@ -74,7 +71,7 @@ impl<'a> Ex<'a> {
|
||||
.attr("ContinueNumbersAcrossStories", "false")
|
||||
.attr("ContinueNumbersAcrossDocuments", "false"),
|
||||
);
|
||||
root.push(El::new("idPkg:Preferences").attr("src", "Resources/Preferences.xml"));
|
||||
root.push(crate::xml::from_craft(craft_idml::designmap_include("Preferences", "Resources/Preferences.xml")));
|
||||
for c in &d.conditions {
|
||||
root.push(
|
||||
El::new("Condition")
|
||||
@@ -99,10 +96,10 @@ impl<'a> Ex<'a> {
|
||||
root.push(layer_el(l));
|
||||
}
|
||||
for (name, _) in masters {
|
||||
root.push(El::new("idPkg:MasterSpread").attr("src", name));
|
||||
root.push(crate::xml::from_craft(craft_idml::designmap_include("MasterSpread", name)));
|
||||
}
|
||||
for (name, _) in spreads {
|
||||
root.push(El::new("idPkg:Spread").attr("src", name));
|
||||
root.push(crate::xml::from_craft(craft_idml::designmap_include("Spread", name)));
|
||||
}
|
||||
// Sections.
|
||||
let mut secs = d.sections.clone();
|
||||
@@ -154,7 +151,7 @@ impl<'a> Ex<'a> {
|
||||
root.push(xref_format_el(i, f));
|
||||
}
|
||||
for (name, _) in stories {
|
||||
root.push(El::new("idPkg:Story").attr("src", name));
|
||||
root.push(crate::xml::from_craft(craft_idml::designmap_include("Story", name)));
|
||||
}
|
||||
// The document's own hyperlinks (#1446): a destination element, a source element for a
|
||||
// page item (a text source is already in its story) and a `Hyperlink` joining them.
|
||||
|
||||
Reference in new issue
Block a user