A .doc saved by a non-English Word stores its built-in styles under that language's names (Обычный, Kop 1). Word reads a built-in style by its sti and names it from the reserved names in [MS-OE376] Part 4 §2.7.3.9, so the document's own Normal is Normal. The Word 97 reader ignored sti and kept the stored name, so these documents had no Normal. - stsh: one table of the built-in names for sti 0-266, from [MS-OE376]. The Word 97 reader names a built-in style from it; a user-defined style (0x0FFE) and any sti past the table keep the stored name. - word6: the Word 6.0/95 reader uses the same table instead of its own, which stopped at 106. - write: Plain Text is sti 90, not 91 (E-mail Signature). With the reader naming styles by sti, a Plain Text style would otherwise read back as E-mail Signature.
craft-doc-binary
Reader and writer for the Word 97-2003 binary file format (.doc, [MS-DOC]) and the
craft-wordmodel document model. It is WordCraft's reader and writer, on craft-cfb for the
compound file and craft-codepage for 8-bit text.
// Not a compound file: an error, never a panic.
assert!(craft_doc_binary::read(b"not a .doc").is_err());
assert!(!craft_doc_binary::is_encrypted(b"not a .doc"));
// A document written as a .doc reads back.
let bytes = craft_doc_binary::write(&craft_wordmodel::Document::from_text("Hello")).unwrap();
let doc = craft_doc_binary::read(&bytes).unwrap();
assert_eq!(doc.body[0].as_para().map(|p| p.text.as_str()), Some("Hello"));
read(bytes),read_with_password(bytes, Option<&str>),is_encrypted(bytes),write(&document).- Text in pieces (8-bit and UTF-16), paragraph and character formatting, styles, lists, tables, sections, headers and footers, notes, comments, fields, bookmarks, pictures and OfficeArt shapes, document properties.
- XOR obfuscation, RC4 and RC4 CryptoAPI password protection.
- Tracked insertions and deletions, with their author and time.
write produces a Word 97-2003 file (nFib 0x00C1, a version 3 compound file): text, character
and paragraph formatting, styles, fonts, lists, tables, sections with headers and footers,
footnotes and endnotes, fields and hyperlinks, bookmarks, inline pictures, tracked insertions
and deletions, and the document properties. Floating pictures are written in line, nested tables
become paragraphs of their cell, and shapes, charts, text boxes and comments are left out, each
kind logged once per save. It never writes a password-protected file.
Limits
Streams (1 GiB each, refused by craft-cfb before anything is allocated), paragraphs, pieces,
property counts, table nesting and drawing records are capped; the constants are in the source
next to what they bound, and each has a test. Hostile input gives an error or a best-effort
document, never a panic.