Skip to main content

TextDocument

Struct TextDocument 

Source
pub struct TextDocument {
    pub document: Document,
}
Expand description

An OpenDocument text document.

The body is a flow of block elements — paragraphs, headings, lists, tables, sections, frames — in the order they are read, which is the order they are drawn. Nothing here paginates: a page layout says how wide a line may be, and that is what Self::page_layout is for.

Fields§

§document: Document

The package and everything shared with the other two formats.

Implementations§

Source§

impl TextDocument

Source

pub fn read(bytes: &[u8]) -> Result<Self, Error>

Read a .odt package.

§Errors

The bytes are not a text document, or its content.xml cannot be read.

Source

pub fn body(&self) -> Option<&Element>

The office:text element: the flow.

None for a package that declares itself a text document and carries no text body, which is a broken document rather than an empty one.

Source

pub fn body_mut(&mut self) -> Option<&mut Element>

The same, for changing it.

Source

pub fn body_path(&self) -> Option<Vec<usize>>

Where Self::body is under the content root, as a path of child indices: what an editor addresses the body’s paragraphs from.

Source

pub fn page_layout(&self) -> PageLayout

The page layout the document’s first master page points at.

A text document has one master page per page style, and the first is the one the body starts on. Where there is none, or no styles.xml at all, the default of PageLayout applies.

Source

pub fn text_width(&self) -> f32

The width a line of body text may be: the page less its side margins.

Source

pub fn outline(&self) -> Vec<Heading>

The document’s headings, as an outline for navigating it: each heading’s level, its text, and its position among the body’s children.

Only the top level of the body is walked. A heading inside a table cell or a frame is not a heading in the outline — ODF permits one and no application lists it — and a heading inside a section is, which is why sections are descended into.

Source

pub fn paragraph_style(&self, element: &Element) -> Rc<Properties>

The style a block element asks for, resolved.

The family is the one the element belongs to, which for everything in a text flow is Family::Paragraph except a table and its parts.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.