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
impl HwpxStyleStore
Sourcepub fn with_default_fonts(font_name: &str) -> Self
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);Sourcepub fn style_set(&self) -> HancomStyleSet
pub fn style_set(&self) -> HancomStyleSet
Returns the style set used by this store.
Sourcepub fn from_registry(registry: &StyleRegistry) -> Self
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.
Sourcepub fn from_registry_with(
registry: &StyleRegistry,
style_set: HancomStyleSet,
) -> Self
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:
Mapping:
registry.fonts→HwpxFont(assigned to HANGUL group)registry.char_shapes→HwpxCharShape(font ref mirrors same index for all lang groups)registry.para_shapes→HwpxParaShaperegistry.style_entries→HwpxStyle(PARA type, Korean langID)
Sourcepub fn font(&self, index: FontIndex) -> HwpxResult<&HwpxFont>
pub fn font(&self, index: FontIndex) -> HwpxResult<&HwpxFont>
Returns the font at index.
Sourcepub fn font_count(&self) -> usize
pub fn font_count(&self) -> usize
Returns the number of fonts.
Sourcepub fn push_char_shape(&mut self, shape: HwpxCharShape) -> CharShapeIndex
pub fn push_char_shape(&mut self, shape: HwpxCharShape) -> CharShapeIndex
Adds a char shape and returns its index.
Sourcepub fn char_shape(&self, index: CharShapeIndex) -> HwpxResult<&HwpxCharShape>
pub fn char_shape(&self, index: CharShapeIndex) -> HwpxResult<&HwpxCharShape>
Returns the char shape at index.
Sourcepub fn char_shape_count(&self) -> usize
pub fn char_shape_count(&self) -> usize
Returns the number of char shapes.
Sourcepub fn push_para_shape(&mut self, shape: HwpxParaShape) -> ParaShapeIndex
pub fn push_para_shape(&mut self, shape: HwpxParaShape) -> ParaShapeIndex
Adds a para shape and returns its index.
Sourcepub fn para_shape(&self, index: ParaShapeIndex) -> HwpxResult<&HwpxParaShape>
pub fn para_shape(&self, index: ParaShapeIndex) -> HwpxResult<&HwpxParaShape>
Returns the para shape at index.
Sourcepub fn para_shape_count(&self) -> usize
pub fn para_shape_count(&self) -> usize
Returns the number of para shapes.
Sourcepub fn iter_fonts(&self) -> impl Iterator<Item = &HwpxFont>
pub fn iter_fonts(&self) -> impl Iterator<Item = &HwpxFont>
Returns an iterator over all fonts in the store.
Sourcepub fn iter_char_shapes(&self) -> impl Iterator<Item = &HwpxCharShape>
pub fn iter_char_shapes(&self) -> impl Iterator<Item = &HwpxCharShape>
Returns an iterator over all character shapes in the store.
Sourcepub fn iter_para_shapes(&self) -> impl Iterator<Item = &HwpxParaShape>
pub fn iter_para_shapes(&self) -> impl Iterator<Item = &HwpxParaShape>
Returns an iterator over all paragraph shapes in the store.
Sourcepub fn push_style(&mut self, style: HwpxStyle)
pub fn push_style(&mut self, style: HwpxStyle)
Adds a style definition.
Sourcepub fn style(&self, index: usize) -> HwpxResult<&HwpxStyle>
pub fn style(&self, index: usize) -> HwpxResult<&HwpxStyle>
Returns the style at index.
Sourcepub fn style_count(&self) -> usize
pub fn style_count(&self) -> usize
Returns the number of styles.
Sourcepub fn iter_styles(&self) -> impl Iterator<Item = &HwpxStyle>
pub fn iter_styles(&self) -> impl Iterator<Item = &HwpxStyle>
Returns an iterator over all styles in the store.
Sourcepub fn push_border_fill(&mut self, bf: HwpxBorderFill) -> u32
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).
Sourcepub fn border_fill(&self, id: u32) -> HwpxResult<&HwpxBorderFill>
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.
Sourcepub fn border_fill_count(&self) -> usize
pub fn border_fill_count(&self) -> usize
Returns the number of border fills in the store.
Sourcepub fn iter_border_fills(&self) -> impl Iterator<Item = &HwpxBorderFill>
pub fn iter_border_fills(&self) -> impl Iterator<Item = &HwpxBorderFill>
Returns an iterator over all border fills in the store.
Sourcepub fn push_numbering(&mut self, ndef: NumberingDef)
pub fn push_numbering(&mut self, ndef: NumberingDef)
Adds a numbering definition to the store.
Sourcepub fn numbering_count(&self) -> u32
pub fn numbering_count(&self) -> u32
Returns the number of numbering definitions in the store.
Sourcepub fn iter_numberings(&self) -> impl Iterator<Item = &NumberingDef>
pub fn iter_numberings(&self) -> impl Iterator<Item = &NumberingDef>
Returns an iterator over all numbering definitions in the store.
Trait Implementations§
Source§impl Clone for HwpxStyleStore
impl Clone for HwpxStyleStore
Source§fn clone(&self) -> HwpxStyleStore
fn clone(&self) -> HwpxStyleStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more