ColumnSettings

Struct ColumnSettings 

Source
pub struct ColumnSettings {
    pub column_type: ColumnType,
    pub layout_mode: ColumnLayoutMode,
    pub columns: Vec<ColumnDef>,
}
Expand description

Multi-column layout settings for a section.

Maps to HWPX <hp:ctrl><hp:colPr>. Single-column layout is represented as None on Section rather than a ColumnSettings with one column.

§Examples

use hwpforge_core::column::{ColumnSettings, ColumnType, ColumnLayoutMode};
use hwpforge_foundation::HwpUnit;

let cs = ColumnSettings::equal_columns(3, HwpUnit::from_mm(4.0).unwrap()).unwrap();
assert_eq!(cs.columns.len(), 3);
assert_eq!(cs.column_type, ColumnType::Newspaper);
assert_eq!(cs.layout_mode, ColumnLayoutMode::Left);

Fields§

§column_type: ColumnType

Column flow type.

§layout_mode: ColumnLayoutMode

Column balance strategy.

§columns: Vec<ColumnDef>

Individual column definitions. Length = number of columns (>= 2).

Implementations§

Source§

impl ColumnSettings

Source

pub fn equal_columns(count: u32, gap: HwpUnit) -> Result<Self, &'static str>

Creates an equal-width N-column layout with the given gap.

All columns get the same gap value (last column gap is set to zero by the encoder). Uses ColumnType::Newspaper and ColumnLayoutMode::Left as defaults.

§Errors

Returns an error if count < 2 (single-column should be None).

§Examples
use hwpforge_core::column::ColumnSettings;
use hwpforge_foundation::HwpUnit;

let cs = ColumnSettings::equal_columns(2, HwpUnit::from_mm(4.0).unwrap()).unwrap();
assert_eq!(cs.columns.len(), 2);
Source

pub fn custom(columns: Vec<ColumnDef>) -> Result<Self, &'static str>

Creates a variable-width column layout from explicit definitions.

Uses ColumnType::Newspaper and ColumnLayoutMode::Left as defaults.

§Errors

Returns an error if columns.len() < 2 (single-column should be None).

§Examples
use hwpforge_core::column::{ColumnSettings, ColumnDef};
use hwpforge_foundation::HwpUnit;

let cs = ColumnSettings::custom(vec![
    ColumnDef { width: HwpUnit::new(14000).unwrap(), gap: HwpUnit::new(1134).unwrap() },
    ColumnDef { width: HwpUnit::new(27000).unwrap(), gap: HwpUnit::ZERO },
]).unwrap();
assert_eq!(cs.columns.len(), 2);
Source

pub fn count(&self) -> usize

Returns the number of columns.

Source

pub fn is_equal_width(&self) -> bool

Returns true if all columns have the same width (or width is zero, meaning 한글 calculates equal widths).

Trait Implementations§

Source§

impl Clone for ColumnSettings

Source§

fn clone(&self) -> ColumnSettings

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 ColumnSettings

Source§

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

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

impl<'de> Deserialize<'de> for ColumnSettings

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ColumnSettings

Source§

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

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

impl JsonSchema for ColumnSettings

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for ColumnSettings

Source§

fn eq(&self, other: &ColumnSettings) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ColumnSettings

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ColumnSettings

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,