Expand description
HWPX format codec for HwpForge.
This crate reads and writes HWPX files (ZIP archives containing XML, per KS X 6101), converting between HwpForge Core’s document types and the HWPX on-disk format.
§Architecture
Decoding (HWPX → Core):
- Open ZIP, validate mimetype, enumerate section files
- Parse
Contents/header.xml→HwpxStyleStore - Parse
Contents/section*.xml→ paragraphs + page settings - Assemble
Document<Draft>with sections
Encoding (Core → HWPX):
- Serialize
HwpxStyleStore→header.xml - Serialize each section →
section{N}.xml - Package into ZIP with metadata files
§Quick Start
use hwpforge_smithy_hwpx::{HwpxDecoder, HwpxEncoder};
// Decode
let result = HwpxDecoder::decode_file("document.hwpx").unwrap();
println!("Sections: {}", result.document.sections().len());
// Round-trip: decode → validate → encode
let validated = result.document.validate().unwrap();
let output = HwpxEncoder::encode(&validated, &result.style_store, &result.image_store).unwrap();
std::fs::write("output.hwpx", &output).unwrap();§Supported Content
- Text runs with character shapes, paragraph shapes, styles
- Tables (nested), images (binary + path), text boxes
- Headers, footers, page numbers, footnotes, endnotes
- Shapes: line, ellipse, polygon, arc, curve, connect line
- Equations (HancomEQN), charts (18 types, OOXML)
- Multi-column layouts, captions, bookmarks, fields, memos
- Page settings (size, margins, landscape, gutter, master pages)
Not yet supported:
- OLE objects, form controls, change tracking
Re-exports§
pub use decoder::HwpxDecoder;pub use decoder::HwpxDocument;pub use default_styles::DefaultStyleEntry;pub use default_styles::HancomStyleSet;pub use error::HwpxError;pub use error::HwpxErrorCode;pub use error::HwpxResult;pub use exchange::ExportedDocument;pub use exchange::ExportedSection;pub use exchange::PreservedTextSlot;pub use exchange::SectionPreservation;pub use exchange::TextLocator;pub use exchange::SECTION_PRESERVATION_VERSION;pub use presets::builtin_presets;pub use presets::style_store_for_preset;pub use presets::PresetInfo;pub use style_store::HwpxCharShape;pub use style_store::HwpxFont;pub use style_store::HwpxFontRef;pub use style_store::HwpxParaShape;pub use style_store::HwpxStyle;pub use style_store::HwpxStyleStore;
Modules§
- decoder
- HWPX decoding pipeline.
- default_
styles - Version-aware default style definitions for 한글 (Hangul Word Processor).
- error
- Error types for the HWPX decoder.
- exchange
- Shared exchange types for JSON round-trip editing.
- presets
- Built-in style presets for HWPX document generation.
- style_
store - HWPX-specific style storage.
Structs§
- Hwpx
Encoder - Encodes Core documents to HWPX format (ZIP + XML).
- Hwpx
Patcher - Preserve-first patch engine for section-level edits.
- Hwpx
Registry Bridge - Bridge that converts registry-local style indices into store-local HWPX ids.
- Hwpx
Style Lookup - A bridge combining
HwpxStyleStore(style queries) andImageStore(binary image data) into a singleStyleLookupimplementor. - Package
Entry Info - Metadata about a single ZIP entry inside an HWPX package.
- Package
Reader - Reader for HWPX ZIP archives.
- Section
Export Outcome - Result of a section-only export intended for later patching.
- Section
Patch Outcome - Result of patching a single exported section back into a base HWPX package.
Enums§
- Section
Workflow Error - Domain error for shared section export/patch workflows.
- Section
Workflow Warning - Non-fatal warning emitted while preparing a section export.