From cb05c972fd1fd9300457326e7e834f0c8afd682a Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 05:29:10 -0500 Subject: [PATCH] Model IDML story preference output --- crates/idml/src/model/mod.rs | 2 +- crates/idml/src/model/story.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/idml/src/model/mod.rs b/crates/idml/src/model/mod.rs index e3a002af6..5479d35a5 100644 --- a/crates/idml/src/model/mod.rs +++ b/crates/idml/src/model/mod.rs @@ -26,7 +26,7 @@ pub use spread::{ Graphic, GraphicChild, GraphicKind, Guide, ItemChild, ItemKind, Link, MarginPreference, Page, PageChild, PageItem, Spread, SpreadChild, TextPath, spreads, }; -pub use story::{Ace, CONTAINERS, Cell, Container, ContentPart, Range, Story, Table, TableChild, TextNode, stories}; +pub use story::{Ace, CONTAINERS, Cell, Container, ContentPart, Range, Story, StoryPreference, Table, TableChild, TextNode, stories}; use craft_xml::{El, Local, Node}; diff --git a/crates/idml/src/model/story.rs b/crates/idml/src/model/story.rs index e8c6d7e6b..7d9b4d48a 100644 --- a/crates/idml/src/model/story.rs +++ b/crates/idml/src/model/story.rs @@ -12,6 +12,26 @@ pub struct Story { pub children: Vec, } +/// The IDML `StoryPreference` element written for a story. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct StoryPreference { + pub optical_margin_alignment: bool, + pub optical_margin_size: f64, + pub vertical: bool, + pub right_to_left: bool, +} + +impl StoryPreference { + pub fn to_el(self) -> El { + El::new("StoryPreference") + .with_attr("OpticalMarginAlignment", self.optical_margin_alignment) + .with_attr("OpticalMarginSize", self.optical_margin_size) + .with_attr("FrameType", "TextFrameType") + .with_attr("StoryOrientation", if self.vertical { "Vertical" } else { "Horizontal" }) + .with_attr("StoryDirection", if self.right_to_left { "RightToLeftDirection" } else { "LeftToRightDirection" }) + } +} + /// One node of a story's text, in document order. IDML nests freely (an `XMLElement` or a /// `HyperlinkTextSource` can hold paragraph ranges or content), so every container holds these. #[derive(Clone, Debug, PartialEq)]