Model IDML story preference output

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 09:05:19 -05:00
1 parent efd77798b1
commit cb05c972fd
2 files changed
+21 -1

No files matched your search

+1 -1
View File
@@ -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};
+20
View File
@@ -12,6 +12,26 @@ pub struct Story {
pub children: Vec<TextNode>,
}
/// 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)]