f-office 0.2.2

Renders Office Open XML documents the way Microsoft Office does.
Documentation
//! Unstable internal inspection helpers with no semver stability guarantee.
//! Holds placed line data, device-space layout access, and (behind `development`)
//! target profiles and quirks. Normal callers should use the rest of the crate.

#[cfg(feature = "development")]
pub use f_office_docx::on_off;
#[cfg(any(test, feature = "development"))]
pub use f_office_docx::profile;
#[cfg(any(test, feature = "development"))]
pub use f_office_docx::quirks;
/// Source of paragraph IDs for tests that build placed lines without a layout,
/// behind the feature `testing`.
#[cfg(feature = "testing")]
pub use f_office_docx::testing::ParagraphIds;
pub use f_office_docx::{
    AlignedParts, Alignment, BaselineForm, CellEdgeParts, CellPlace, DrawnGlyph, EdgeCheck,
    FirstItem, Fit, LineArea, LineSpacing, LineStory, LineText, ObjectStart, ParagraphId,
    PlacedLine, Step, StepsStart, StoryPart, TableColumns,
};

use crate::{Document, Error, FontDb, Options, Warned};

pub mod roundtrip;

/// The exact place of every line of the body, the headers and the footers of `document`,
/// including table cells.
#[must_use]
pub fn placed_lines(document: &Document) -> &[PlacedLine] {
    &document.lines
}

/// The widths of the grid columns that layout gave each table of the body of `document`,
/// including nested tables.
#[must_use]
pub fn table_columns(document: &Document) -> &[TableColumns] {
    &document.tables
}

/// Opens a DOCX file as [`Document::open_with_art`] does, keeping glyph positions on the layout
/// device without the PDF writer's adjustments.
///
/// # Errors
///
/// As [`Document::open`].
pub fn open_with_device_places(
    docx: &[u8],
    (fonts, art): (&FontDb, &crate::ArtPictures),
    options: &Options,
) -> Result<Warned<Document>, Error> {
    let mut layout = options.layout();
    layout.device_places = true;
    Document::open_with((docx, fonts, art), &options.limits, &layout)
}