diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-29 13:37:25 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-29 14:18:13 +0100 |
| commit | 0efe669278a5e1c3f2985eba2f3360e91159c54a (patch) | |
| tree | 502712857c48f0decb5e698257c0a96d358a436e /library/src/structure/document.rs | |
| parent | 836692e73cff0356e409a9ba5b4887b86809d4ca (diff) | |
Reorganize library and tests
Diffstat (limited to 'library/src/structure/document.rs')
| -rw-r--r-- | library/src/structure/document.rs | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/library/src/structure/document.rs b/library/src/structure/document.rs deleted file mode 100644 index e52c92ad..00000000 --- a/library/src/structure/document.rs +++ /dev/null @@ -1,48 +0,0 @@ -use crate::layout::{LayoutRoot, PageNode}; -use crate::prelude::*; - -/// The root node of the model. -#[derive(Hash)] -pub struct DocumentNode(pub StyleVec<PageNode>); - -#[node(LayoutRoot)] -impl DocumentNode { - /// The document's title. - #[property(referenced)] - pub const TITLE: Option<EcoString> = None; - - /// The document's author. - #[property(referenced)] - pub const AUTHOR: Option<EcoString> = None; -} - -impl LayoutRoot for DocumentNode { - /// Layout the document into a sequence of frames, one per page. - fn layout_root( - &self, - world: Tracked<dyn World>, - styles: StyleChain, - ) -> SourceResult<Document> { - let mut pages = vec![]; - for (page, map) in self.0.iter() { - let number = 1 + pages.len(); - let fragment = page.layout(world, number, styles.chain(map))?; - pages.extend(fragment); - } - - Ok(Document { - metadata: Metadata { - title: styles.get(Self::TITLE).clone(), - author: styles.get(Self::AUTHOR).clone(), - }, - pages, - }) - } -} - -impl Debug for DocumentNode { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - f.write_str("Document ")?; - self.0.fmt(f) - } -} |
