mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 22:42:46 +00:00
Model IDML story preference output
This commit is contained in:
2 files changed
+21
-1
No files matched your search
@@ -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};
|
||||
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in new issue
Block a user