Files
craft-libs/crates/rtf/src/doc.rs
T

61 lines
2.9 KiB
Rust

//! Rich Text Format, read into and written from the word model (`craft_wordmodel::Document`)
//! through the text formats' flow (`craft_flow`). Feature `doc`.
//!
//! WordCraft's RTF reader and writer.
//!
//! Export: font and colour tables, a small stylesheet (headings with outline levels, Title,
//! Quote, Code), list tables (`\listtable` / `\listoverridetable` with `\listtext` labels for
//! older readers), document info, page setup, paragraph formatting (`\pard`, alignment, page
//! break before), character formatting (`\b \i \ul \strike \super \sub \f \fs \cf \chcbpat`),
//! hyperlinks as `HYPERLINK` fields, bookmarks, pictures (`\pngblip` / `\jpegblip`), tables
//! (`\trowd … \cellx … \cell … \row`, header rows, vertical merges, shading), footnotes and
//! endnotes (`{\super\chftn}{\footnote[\ftnalt] …}`) and comments (`{\*\atrfstart n}` …
//! `{\*\atrfend n}` around the commented text, then `{\*\atnid initials}{\*\atnauthor name}`
//! `\chatn{\*\annotation{\*\atnref n}{\*\atndate …}` text `}`).
//!
//! Import: a tolerant reader for groups and destinations (unknown `\*` destinations and objects
//! are skipped; headers, footers, notes and comments are read into stories of their own),
//! `\par \line \tab \page`, `\uN` with `\ucN`
//! fallback skipping, `\'hh` and 8-bit text in the document's code page (`\ansicpg`, `\mac`, `\pc`, `\pca`) or
//! the current font's (`\fcharset`, `\cpg`: Cyrillic, Central European, Greek, Mac OS Roman, the
//! East Asian multibyte pages 932/936/949/950…; Windows-1252 when none is named). A multibyte
//! code page's bytes stream through one decoder, so a lead byte and its trail byte decode
//! together and a run that looks like a UTF-8 BOM is not mistaken for one; the formatting words
//! above, stylesheet-based
//! headings and `\outlinelevel`, lists through `\ls`/`\ilvl`, fields, bookmarks, pictures and
//! tables, footnotes, endnotes (`\footnote` with `\ftnalt`) and comments (author, initials, date,
//! text, the commented range). Group nesting, picture sizes and the number of notes and comments
//! are capped. Not kept: custom note marks, comment replies (`\atnparent`), notes inside
//! headers, footers and other notes, tables inside note and comment texts (flattened).
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use craft_wordmodel::props::VAlign;
use craft_wordmodel::{Align, Block, Blocks, Document, InlineObject, Paragraph, Rgb};
use craft_flow::{self as model, Cell, FBlock, FTable, Flow, Fmt, Inline, Kind, ListInfo, Meta, Para, RevMark, make_img};
use crate::date;
mod export;
mod parse;
mod reader;
mod state;
mod styles;
mod text;
mod word;
pub use date::{dttm_to_iso, iso_to_dttm};
pub use export::{GENERATOR, esc, export, export_with_generator};
#[cfg(test)]
use export::{Tables, Writer};
pub use parse::{import, parse};
use reader::Reader;
#[cfg(test)]
use state::MAX_SECTIONS;
#[cfg(test)]
use word::hyperlink;
#[cfg(test)]
mod tests;