diff --git a/crates/idml/src/model/mod.rs b/crates/idml/src/model/mod.rs index 49ba0b3eb..33ba5a75c 100644 --- a/crates/idml/src/model/mod.rs +++ b/crates/idml/src/model/mod.rs @@ -19,8 +19,8 @@ mod story; pub use geometry::{MAX_PATH_POINTS, PathGeometry, PathGeometryError, PathPoint, SubPath}; pub use resources::{ - ColorGroup, ColorSpace, GradientStop, GradientStopValue, StrokeStyle, StrokeStyleKind, Style, StyleGroup, StyleKind, StyleNode, Swatch, - SwatchKind, color_groups, named, preference, stroke_styles, style_groups, swatches, + ColorGroup, ColorSpace, GradientStop, GradientStopValue, Ink, StrokeStyle, StrokeStyleKind, Style, StyleGroup, StyleKind, StyleNode, Swatch, + SwatchKind, color_groups, inks, named, preference, stroke_styles, style_groups, swatches, }; pub use spread::{Graphic, GraphicChild, GraphicKind, Guide, ItemChild, ItemKind, Link, Page, PageChild, PageItem, Spread, SpreadChild, spreads}; pub use story::{Ace, CONTAINERS, Cell, Container, ContentPart, Range, Story, Table, TableChild, TextNode, stories}; diff --git a/crates/idml/src/model/resources.rs b/crates/idml/src/model/resources.rs index 3a5b80d9a..baca34a8e 100644 --- a/crates/idml/src/model/resources.rs +++ b/crates/idml/src/model/resources.rs @@ -388,6 +388,31 @@ pub struct ColorGroup { pub rest: Vec, } +/// An Ink Manager entry, preserving its source values. +#[derive(Clone, Debug, PartialEq)] +pub struct Ink { + pub values: Values, +} + +impl Ink { + pub fn name(&self) -> Option<&str> { + self.values.name() + } + + pub fn convert_to_process(&self) -> bool { + self.values.get("ConvertToProcess") == Some("true") + } + + pub fn alias(&self) -> Option<&str> { + self.values.get("AliasInkName") + } +} + +/// Ink Manager entries among the document's top-level elements. +pub fn inks(top: &[El]) -> Vec { + top.iter().filter(|el| el.local() == "Ink").map(|el| Ink { values: Values::of(el) }).collect() +} + impl ColorGroup { pub fn to_el(&self) -> El { let mut el = self.values.element("ColorGroup");