mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 22:35:26 +00:00
Use shared IDML stroke values for import
This commit is contained in:
3 files changed
+40
-35
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=598a1e5b9#598a1e5b92e03b19115bd3012cbd4dce98267e13"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=56e1735c7#56e1735c70b0f36b454c32a50a56d42f64a5e321"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=598a1e5b9)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=598a1e5b9)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=56e1735c7)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=56e1735c7)",
|
||||
"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=598a1e5b9#598a1e5b92e03b19115bd3012cbd4dce98267e13"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=56e1735c7#56e1735c70b0f36b454c32a50a56d42f64a5e321"
|
||||
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=598a1e5b9#598a1e5b92e03b19115bd3012cbd4dce98267e13"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=56e1735c7#56e1735c70b0f36b454c32a50a56d42f64a5e321"
|
||||
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=598a1e5b9)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=56e1735c7)",
|
||||
"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=598a1e5b9)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=56e1735c7)",
|
||||
"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=598a1e5b9)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=56e1735c7)",
|
||||
"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=598a1e5b9)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=56e1735c7)",
|
||||
"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 = "598a1e5b9", version = "=0.1.0" }
|
||||
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "56e1735c7", 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 = "598a1e5b9", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "56e1735c7", 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" }
|
||||
|
||||
@@ -169,47 +169,52 @@ impl<'r> Importer<'r> {
|
||||
}
|
||||
|
||||
pub(super) fn stroke_from(&mut self, e: &El, item: Option<&El>) -> Stroke {
|
||||
let g = |s: &Self, k: &str| -> Option<String> { if item.is_some() { s.attr_or_style(e, k) } else { e.get(k).map(str::to_string) } };
|
||||
let color = g(self, "StrokeColor");
|
||||
let model_elements = if item.is_some() {
|
||||
std::iter::once(e).chain(self.object_style_chain(e)).map(crate::xml::to_craft).collect::<Vec<_>>()
|
||||
} else {
|
||||
vec![crate::xml::to_craft(e)]
|
||||
};
|
||||
let model_refs: Vec<_> = model_elements.iter().collect();
|
||||
let model = craft_idml::model::StrokeValues::from_elements(&model_refs);
|
||||
let mut s = Stroke::none();
|
||||
if let Some(c) = color {
|
||||
s.swatch = self.swatch_ref(&c);
|
||||
if let Some(c) = model.color.as_deref() {
|
||||
s.swatch = self.swatch_ref(c);
|
||||
}
|
||||
if let Some(w) = g(self, "StrokeWeight").and_then(|v| v.parse::<f64>().ok()).filter(|v| v.is_finite()) {
|
||||
if let Some(w) = model.weight {
|
||||
s.weight = w;
|
||||
}
|
||||
if let Some(t) = g(self, "StrokeTint").and_then(|v| v.parse().ok()) {
|
||||
if let Some(t) = model.tint {
|
||||
s.tint = tint(Some(t)).unwrap_or(1.0);
|
||||
}
|
||||
if let Some(t) = g(self, "StrokeType") {
|
||||
s.kind = names::stroke_type_in(&t);
|
||||
if let Some(t) = model.kind.as_deref() {
|
||||
s.kind = names::stroke_type_in(t);
|
||||
}
|
||||
if let Some(v) = g(self, "StrokeAlignment") {
|
||||
s.align = names::stroke_align_in(&v);
|
||||
if let Some(v) = model.alignment.as_deref() {
|
||||
s.align = names::stroke_align_in(v);
|
||||
}
|
||||
if let Some(v) = g(self, "EndCap") {
|
||||
s.cap = names::cap_in(&v);
|
||||
if let Some(v) = model.cap.as_deref() {
|
||||
s.cap = names::cap_in(v);
|
||||
}
|
||||
if let Some(v) = g(self, "EndJoin") {
|
||||
s.join = names::join_in(&v);
|
||||
if let Some(v) = model.join.as_deref() {
|
||||
s.join = names::join_in(v);
|
||||
}
|
||||
if let Some(v) = g(self, "MiterLimit").and_then(|v| v.parse::<f64>().ok()).filter(|v| v.is_finite()) {
|
||||
if let Some(v) = model.miter_limit {
|
||||
s.miter_limit = v;
|
||||
}
|
||||
if let Some(v) = g(self, "LeftLineEnd") {
|
||||
s.start = names::arrow_in(&v);
|
||||
if let Some(v) = model.start.as_deref() {
|
||||
s.start = names::arrow_in(v);
|
||||
}
|
||||
if let Some(v) = g(self, "RightLineEnd") {
|
||||
s.end = names::arrow_in(&v);
|
||||
if let Some(v) = model.end.as_deref() {
|
||||
s.end = names::arrow_in(v);
|
||||
}
|
||||
if let Some(v) = g(self, "GapColor") {
|
||||
s.gap_swatch = self.swatch_ref(&v);
|
||||
if let Some(v) = model.gap_color.as_deref() {
|
||||
s.gap_swatch = self.swatch_ref(v);
|
||||
}
|
||||
if let Some(t) = g(self, "GapTint").and_then(|v| v.parse().ok()) {
|
||||
if let Some(t) = model.gap_tint {
|
||||
s.gap_tint = tint(Some(t)).unwrap_or(1.0);
|
||||
}
|
||||
s.overprint = g(self, "OverprintStroke").as_deref() == Some("true");
|
||||
s.gap_overprint = g(self, "OverprintGap").as_deref() == Some("true");
|
||||
s.overprint = model.overprint == Some(true);
|
||||
s.gap_overprint = model.gap_overprint == Some(true);
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user