Model IDML ink manager entries

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 09:05:18 -05:00
1 parent 0e537f7952
commit fb3c910bc1
2 files changed
+27 -2

No files matched your search

+2 -2
View File
@@ -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};
+25
View File
@@ -388,6 +388,31 @@ pub struct ColorGroup {
pub rest: Vec<El>,
}
/// 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<Ink> {
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");