oxedyne/fe2o3/fe2o3_file/src/office/docx/mod.rs
2.1 KiB, 19 runs
created by r1870400018:22579, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! WordprocessingML: the `.docx` half of the Office formats. |
| 2 | //! |
| 3 | //! # What a `.docx` is, in one paragraph |
| 4 | //! |
| 5 | //! A ZIP holding `[Content_Types].xml`, which says what each part is; `_rels/.rels`, which points at |
| 6 | //! the document part; `word/document.xml`, which is the content; and `word/_rels/document.xml.rels`, |
| 7 | //! which points at everything the content refers to. Add `word/styles.xml` and headings mean |
| 8 | //! something. Everything else -- the theme, the settings, the font table, the people, the comments -- |
| 9 | //! is optional, and a document that omits them opens. |
| 10 | //! |
| 11 | //! Inside `word/document.xml` the nesting is `w:document > w:body > w:p > w:r > w:t`: a body of |
| 12 | //! paragraphs, each of runs, each of text. A run is the unit formatting applies to, which is why |
| 13 | //! bold text in the middle of a sentence splits a paragraph into three runs. |
| 14 | //! |
| 15 | //! # Creating comes first, and is not the same problem as editing |
| 16 | //! |
| 17 | //! [`write`] builds a document from the neutral tree in [`oxedyne_fe2o3_text::doc`]. It is the easy direction: |
| 18 | //! every byte is ours, there is nothing to preserve, and Word lays the result out when it opens it. |
| 19 | //! Editing a document somebody else wrote is a different problem with a different answer -- see |
| 20 | //! [`crate::office`] -- and sharing code between them is how the second one gets the first one's |
| 21 | //! assumptions. |
| 22 | //! |
| 23 | //! [Written with AI entirely](https://need2know.ai/entirely-ai/code)\ |
| 24 | //! Anthropic Claude |
| 25 | |
| 26 | pub mod edit; |
| 27 | pub mod parts; |
| 28 | pub mod read; |
| 29 | pub mod write; |
| 30 | |
| 31 | pub use read::read; |
| 32 | pub use write::write; |
| 33 | |
| 34 | /// The WordprocessingML namespace, which nearly every element of a document is in. |
| 35 | pub const NS_W: &str = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"; |
| 36 | |
| 37 | //// A4 page geometry, in twips -- a twip is a twentieth of a point. |
| 38 | pub const PAGE_W: u32 = 11906; |
| 39 | pub const PAGE_H: u32 = 16838; |
| 40 | pub const MARGIN: u32 = 1134; // on each side: two centimetres |
| 41 | pub const TEXT_W: u32 = PAGE_W - 2 * MARGIN; // what a table has to lay itself out in |
| 42 | |
| 43 | /// The `w:numId` of the bulleted list definition. See [`parts::numbering`]. |
| 44 | pub const NUM_BULLET: &str = "1"; |
| 45 | /// The `w:numId` of the numbered list definition. |
| 46 | pub const NUM_ORDERED: &str = "2"; |