Crate hwpforge_smithy_hwpx

Crate hwpforge_smithy_hwpx 

Source
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):

  1. Open ZIP, validate mimetype, enumerate section files
  2. Parse Contents/header.xmlHwpxStyleStore
  3. Parse Contents/section*.xml → paragraphs + page settings
  4. Assemble Document<Draft> with sections

Encoding (Core → HWPX):

  1. Serialize HwpxStyleStoreheader.xml
  2. Serialize each section → section{N}.xml
  3. 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 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.
style_store
HWPX-specific style storage.

Structs§

HwpxEncoder
Encodes Core documents to HWPX format (ZIP + XML).