hwpforge_smithy_hwpx/
lib.rs

1//! HWPX format codec for HwpForge.
2//!
3//! This crate reads and writes HWPX files (ZIP archives containing XML,
4//! per KS X 6101), converting between HwpForge Core's document types
5//! and the HWPX on-disk format.
6//!
7//! # Architecture
8//!
9//! **Decoding** (HWPX → Core):
10//! 1. Open ZIP, validate mimetype, enumerate section files
11//! 2. Parse `Contents/header.xml` → [`HwpxStyleStore`]
12//! 3. Parse `Contents/section*.xml` → paragraphs + page settings
13//! 4. Assemble `Document<Draft>` with sections
14//!
15//! **Encoding** (Core → HWPX):
16//! 1. Serialize [`HwpxStyleStore`] → `header.xml`
17//! 2. Serialize each section → `section{N}.xml`
18//! 3. Package into ZIP with metadata files
19//!
20//! # Quick Start
21//!
22//! ```no_run
23//! use hwpforge_smithy_hwpx::{HwpxDecoder, HwpxEncoder};
24//!
25//! // Decode
26//! let result = HwpxDecoder::decode_file("document.hwpx").unwrap();
27//! println!("Sections: {}", result.document.sections().len());
28//!
29//! // Round-trip: decode → validate → encode
30//! let validated = result.document.validate().unwrap();
31//! let output = HwpxEncoder::encode(&validated, &result.style_store, &result.image_store).unwrap();
32//! std::fs::write("output.hwpx", &output).unwrap();
33//! ```
34//!
35//! # Supported Content
36//!
37//! - Text runs with character shapes, paragraph shapes, styles
38//! - Tables (nested), images (binary + path), text boxes
39//! - Headers, footers, page numbers, footnotes, endnotes
40//! - Shapes: line, ellipse, polygon, arc, curve, connect line
41//! - Equations (HancomEQN), charts (18 types, OOXML)
42//! - Multi-column layouts, captions, bookmarks, fields, memos
43//! - Page settings (size, margins, landscape, gutter, master pages)
44//!
45//! Not yet supported:
46//! - OLE objects, form controls, change tracking
47
48#![deny(missing_docs)]
49#![deny(unsafe_code)]
50
51pub mod decoder;
52pub mod default_styles;
53mod encoder;
54pub mod error;
55mod schema;
56pub mod style_store;
57
58pub use decoder::{HwpxDecoder, HwpxDocument};
59pub use default_styles::{DefaultStyleEntry, HancomStyleSet};
60pub use encoder::HwpxEncoder;
61pub use error::{HwpxError, HwpxErrorCode, HwpxResult};
62pub use style_store::{
63    HwpxCharShape, HwpxFont, HwpxFontRef, HwpxParaShape, HwpxStyle, HwpxStyleStore,
64};