HwpxStyleStore

Struct HwpxStyleStore 

Source
pub struct HwpxStyleStore { /* private fields */ }
Expand description

HWPX-specific style storage populated from header.xml.

Unlike Blueprint’s StyleRegistry, this has no inheritance or template merging — it holds exactly what was parsed from the file.

§Index Safety

All accessors return HwpxResult<&T> to guard against invalid indices from malformed HWPX files.

§Examples

use hwpforge_smithy_hwpx::HwpxStyleStore;
use hwpforge_foundation::CharShapeIndex;

let store = HwpxStyleStore::new();
assert!(store.char_shape(CharShapeIndex::new(0)).is_err());

Implementations§

Source§

impl HwpxStyleStore

Source

pub fn new() -> Self

Creates an empty store.

Source

pub fn with_default_fonts(font_name: &str) -> Self

Creates a new style store with the given font registered for all 7 language groups (HANGUL, LATIN, HANJA, JAPANESE, OTHER, SYMBOL, USER).

This eliminates the common boilerplate of manually pushing fonts for each language.

§Examples
use hwpforge_smithy_hwpx::style_store::HwpxStyleStore;

let store = HwpxStyleStore::with_default_fonts("함초롬돋움");
assert_eq!(store.font_count(), 7);
Source

pub fn style_set(&self) -> HancomStyleSet

Returns the style set used by this store.

Source

pub fn from_registry(registry: &StyleRegistry) -> Self

Creates a store from a Blueprint StyleRegistry using the default style set (HancomStyleSet::Modern).

This is the bridge that lets the MD → Core → HWPX pipeline carry resolved styles all the way through to the HWPX encoder.

To target a specific 한글 version, use from_registry_with.

Source

pub fn from_registry_with( registry: &StyleRegistry, style_set: HancomStyleSet, ) -> Self

Creates a store from a Blueprint StyleRegistry with a specific style set.

The style_set controls which default styles are injected:

  • Classic — 18 styles (한글 2014–2020)
  • Modern — 22 styles (한글 2022+)
  • Latest — 23 styles (한글 2025+)

Mapping:

  • registry.fontsHwpxFont (assigned to HANGUL group)
  • registry.char_shapesHwpxCharShape (font ref mirrors same index for all lang groups)
  • registry.para_shapesHwpxParaShape
  • registry.style_entriesHwpxStyle (PARA type, Korean langID)
Source

pub fn push_font(&mut self, font: HwpxFont) -> FontIndex

Adds a font and returns its index.

Source

pub fn font(&self, index: FontIndex) -> HwpxResult<&HwpxFont>

Returns the font at index.

Source

pub fn font_count(&self) -> usize

Returns the number of fonts.

Source

pub fn push_char_shape(&mut self, shape: HwpxCharShape) -> CharShapeIndex

Adds a char shape and returns its index.

Source

pub fn char_shape(&self, index: CharShapeIndex) -> HwpxResult<&HwpxCharShape>

Returns the char shape at index.

Source

pub fn char_shape_count(&self) -> usize

Returns the number of char shapes.

Source

pub fn push_para_shape(&mut self, shape: HwpxParaShape) -> ParaShapeIndex

Adds a para shape and returns its index.

Source

pub fn para_shape(&self, index: ParaShapeIndex) -> HwpxResult<&HwpxParaShape>

Returns the para shape at index.

Source

pub fn para_shape_count(&self) -> usize

Returns the number of para shapes.

Source

pub fn iter_fonts(&self) -> impl Iterator<Item = &HwpxFont>

Returns an iterator over all fonts in the store.

Source

pub fn iter_char_shapes(&self) -> impl Iterator<Item = &HwpxCharShape>

Returns an iterator over all character shapes in the store.

Source

pub fn iter_para_shapes(&self) -> impl Iterator<Item = &HwpxParaShape>

Returns an iterator over all paragraph shapes in the store.

Source

pub fn push_style(&mut self, style: HwpxStyle)

Adds a style definition.

Source

pub fn style(&self, index: usize) -> HwpxResult<&HwpxStyle>

Returns the style at index.

Source

pub fn style_count(&self) -> usize

Returns the number of styles.

Source

pub fn iter_styles(&self) -> impl Iterator<Item = &HwpxStyle>

Returns an iterator over all styles in the store.

Source

pub fn push_border_fill(&mut self, bf: HwpxBorderFill) -> u32

Adds a border fill to the store and returns its 1-based ID.

Border fill IDs in HWPX are 1-based (unlike other indices which are 0-based).

Source

pub fn border_fill(&self, id: u32) -> HwpxResult<&HwpxBorderFill>

Returns the border fill with the given 1-based ID.

§Errors

Returns HwpxError::IndexOutOfBounds if no border fill with that ID exists.

Source

pub fn border_fill_count(&self) -> usize

Returns the number of border fills in the store.

Source

pub fn iter_border_fills(&self) -> impl Iterator<Item = &HwpxBorderFill>

Returns an iterator over all border fills in the store.

Source

pub fn push_numbering(&mut self, ndef: NumberingDef)

Adds a numbering definition to the store.

Source

pub fn push_tab(&mut self, tab: TabDef)

Adds a tab property definition to the store.

Source

pub fn numbering_count(&self) -> u32

Returns the number of numbering definitions in the store.

Source

pub fn tab_count(&self) -> u32

Returns the number of tab property definitions in the store.

Source

pub fn iter_numberings(&self) -> impl Iterator<Item = &NumberingDef>

Returns an iterator over all numbering definitions in the store.

Source

pub fn iter_tabs(&self) -> impl Iterator<Item = &TabDef>

Returns an iterator over all tab property definitions in the store.

Trait Implementations§

Source§

impl Clone for HwpxStyleStore

Source§

fn clone(&self) -> HwpxStyleStore

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HwpxStyleStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HwpxStyleStore

Source§

fn default() -> HwpxStyleStore

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.