Control

Enum Control 

Source
#[non_exhaustive]
pub enum Control {
Show 20 variants TextBox { paragraphs: Vec<Paragraph>, width: HwpUnit, height: HwpUnit, horz_offset: i32, vert_offset: i32, caption: Option<Caption>, style: Option<ShapeStyle>, }, Hyperlink { text: String, url: String, }, Footnote { inst_id: Option<u32>, paragraphs: Vec<Paragraph>, }, Endnote { inst_id: Option<u32>, paragraphs: Vec<Paragraph>, }, Line { start: ShapePoint, end: ShapePoint, width: HwpUnit, height: HwpUnit, horz_offset: i32, vert_offset: i32, caption: Option<Caption>, style: Option<ShapeStyle>, }, Ellipse { center: ShapePoint, axis1: ShapePoint, axis2: ShapePoint, width: HwpUnit, height: HwpUnit, horz_offset: i32, vert_offset: i32, paragraphs: Vec<Paragraph>, caption: Option<Caption>, style: Option<ShapeStyle>, }, Polygon { vertices: Vec<ShapePoint>, width: HwpUnit, height: HwpUnit, horz_offset: i32, vert_offset: i32, paragraphs: Vec<Paragraph>, caption: Option<Caption>, style: Option<ShapeStyle>, }, Equation { script: String, width: HwpUnit, height: HwpUnit, base_line: u32, text_color: Color, font: String, }, Chart {
Show 16 fields chart_type: ChartType, data: ChartData, width: HwpUnit, height: HwpUnit, title: Option<String>, legend: LegendPosition, grouping: ChartGrouping, bar_shape: Option<BarShape>, explosion: Option<u32>, of_pie_type: Option<OfPieType>, radar_style: Option<RadarStyle>, wireframe: Option<bool>, bubble_3d: Option<bool>, scatter_style: Option<ScatterStyle>, show_markers: Option<bool>, stock_variant: Option<StockVariant>,
}, Dutmal { main_text: String, sub_text: String, position: DutmalPosition, sz_ratio: u32, align: DutmalAlign, }, Compose { compose_text: String, circle_type: String, char_sz: i32, compose_type: String, }, Arc {
Show 14 fields arc_type: ArcType, center: ShapePoint, axis1: ShapePoint, axis2: ShapePoint, start1: ShapePoint, end1: ShapePoint, start2: ShapePoint, end2: ShapePoint, width: HwpUnit, height: HwpUnit, horz_offset: i32, vert_offset: i32, caption: Option<Caption>, style: Option<ShapeStyle>,
}, Curve { points: Vec<ShapePoint>, segment_types: Vec<CurveSegmentType>, width: HwpUnit, height: HwpUnit, horz_offset: i32, vert_offset: i32, caption: Option<Caption>, style: Option<ShapeStyle>, }, ConnectLine { start: ShapePoint, end: ShapePoint, control_points: Vec<ShapePoint>, connect_type: String, width: HwpUnit, height: HwpUnit, horz_offset: i32, vert_offset: i32, caption: Option<Caption>, style: Option<ShapeStyle>, }, Bookmark { name: String, bookmark_type: BookmarkType, }, CrossRef { target_name: String, ref_type: RefType, content_type: RefContentType, as_hyperlink: bool, }, Field { field_type: FieldType, hint_text: Option<String>, help_text: Option<String>, }, Memo { content: Vec<Paragraph>, author: String, date: String, }, IndexMark { primary: String, secondary: Option<String>, }, Unknown { tag: String, data: Option<String>, },
}
Expand description

An inline control element.

Controls are non-text elements that appear within a Run. Each variant carries its own data; the enum is #[non_exhaustive] for forward compatibility.

§Examples

use hwpforge_core::control::Control;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{HwpUnit, ParaShapeIndex};

let text_box = Control::TextBox {
    paragraphs: vec![Paragraph::new(ParaShapeIndex::new(0))],
    width: HwpUnit::from_mm(80.0).unwrap(),
    height: HwpUnit::from_mm(40.0).unwrap(),
    horz_offset: 0,
    vert_offset: 0,
    caption: None,
    style: None,
};
assert!(text_box.is_text_box());
assert!(!text_box.is_hyperlink());

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TextBox

An inline text box with its own paragraph content. Maps to HWPX <hp:rect> + <hp:drawText> (drawing object, not control).

Fields

§paragraphs: Vec<Paragraph>

Paragraphs inside the text box.

§width: HwpUnit

Box width (HWPUNIT).

§height: HwpUnit

Box height (HWPUNIT).

§horz_offset: i32

Horizontal offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§vert_offset: i32

Vertical offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§caption: Option<Caption>

Optional caption attached to this text box.

§style: Option<ShapeStyle>

Optional visual style overrides (border color, fill, line width).

A hyperlink with display text and URL.

Fields

§text: String

Visible text of the link.

§url: String

Target URL.

§

Footnote

A footnote containing paragraph content. Maps to HWPX <hp:ctrl><hp:footNote>.

Fields

§inst_id: Option<u32>

Instance identifier (unique ID for linking, optional).

§paragraphs: Vec<Paragraph>

Paragraphs that form the footnote body.

§

Endnote

An endnote containing paragraph content. Maps to HWPX <hp:ctrl><hp:endNote>.

Fields

§inst_id: Option<u32>

Instance identifier (unique ID for linking, optional).

§paragraphs: Vec<Paragraph>

Paragraphs that form the endnote body.

§

Line

A line drawing object (2 endpoints). Maps to HWPX <hp:line>.

Fields

§start: ShapePoint

Start point (x, y in HWPUNIT).

§end: ShapePoint

End point (x, y in HWPUNIT).

§width: HwpUnit

Bounding box width (HWPUNIT).

§height: HwpUnit

Bounding box height (HWPUNIT).

§horz_offset: i32

Horizontal offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§vert_offset: i32

Vertical offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§caption: Option<Caption>

Optional caption attached to this line.

§style: Option<ShapeStyle>

Optional visual style overrides (border color, fill, line width).

§

Ellipse

An ellipse (or circle) drawing object. Maps to HWPX <hp:ellipse>.

Fields

§center: ShapePoint

Center point (x, y in HWPUNIT).

§axis1: ShapePoint

Axis 1 endpoint (defines semi-major axis direction and length).

§axis2: ShapePoint

Axis 2 endpoint (perpendicular to axis1, defines semi-minor axis).

§width: HwpUnit

Bounding box width (HWPUNIT).

§height: HwpUnit

Bounding box height (HWPUNIT).

§horz_offset: i32

Horizontal offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§vert_offset: i32

Vertical offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§paragraphs: Vec<Paragraph>

Optional text content inside the ellipse.

§caption: Option<Caption>

Optional caption attached to this ellipse.

§style: Option<ShapeStyle>

Optional visual style overrides (border color, fill, line width).

§

Polygon

A polygon drawing object (3+ vertices). Maps to HWPX <hp:polygon>.

Fields

§vertices: Vec<ShapePoint>

Ordered list of vertices (minimum 3).

§width: HwpUnit

Bounding box width (HWPUNIT).

§height: HwpUnit

Bounding box height (HWPUNIT).

§horz_offset: i32

Horizontal offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§vert_offset: i32

Vertical offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§paragraphs: Vec<Paragraph>

Optional text content inside the polygon.

§caption: Option<Caption>

Optional caption attached to this polygon.

§style: Option<ShapeStyle>

Optional visual style overrides (border color, fill, line width).

§

Equation

An inline equation (수식) using HancomEQN script format. Maps to HWPX <hp:equation> with <hp:script> child.

Equations have NO shape common block (no offset, orgSz, curSz, flip, rotation, lineShape, fillBrush, shadow). Only sz + pos + outMargin + script.

Fields

§script: String

HancomEQN script text (e.g. "{a+b} over {c+d}").

§width: HwpUnit

Bounding box width (HWPUNIT).

§height: HwpUnit

Bounding box height (HWPUNIT).

§base_line: u32

Baseline position (51-90 typical range).

§text_color: Color

Text color.

§font: String

Font name (typically "HancomEQN").

§

Chart

An OOXML chart embedded in the document. Maps to HWPX <hp:switch><hp:case><hp:chart> with separate Chart XML file.

Charts have NO shape common block (like Equation): only sz + pos + outMargin.

Fields

§chart_type: ChartType

Chart type (18 variants covering all OOXML chart types).

§data: ChartData

Chart data (category-based or XY-based).

§width: HwpUnit

Chart width (HWPUNIT, default ~32250 ≈ 114mm).

§height: HwpUnit

Chart height (HWPUNIT, default ~18750 ≈ 66mm).

§title: Option<String>

Optional chart title.

§legend: LegendPosition

Legend position.

§grouping: ChartGrouping

Series grouping mode.

§bar_shape: Option<BarShape>

3D bar/column shape (None = default Box).

§explosion: Option<u32>

Exploded pie/doughnut percentage (None = not exploded, Some(25) = 25% explosion).

§of_pie_type: Option<OfPieType>

Pie-of-pie or bar-of-pie sub-type (None = default pie-of-pie).

§radar_style: Option<RadarStyle>

Radar chart rendering style (None = default Standard).

§wireframe: Option<bool>

Surface chart wireframe mode (None = default solid).

§bubble_3d: Option<bool>

3D bubble effect (None = default flat).

§scatter_style: Option<ScatterStyle>

Scatter chart style (None = default Dots).

§show_markers: Option<bool>

Show data point markers on line charts (None = no markers).

§stock_variant: Option<StockVariant>

Stock chart sub-variant (None = default HLC, 3 series).

VHLC and VOHLC generate a composite <c:plotArea> with both <c:barChart> (volume) and <c:stockChart> (price) elements.

§

Dutmal

Dutmal (덧말): annotation text displayed above or below main text. Maps to HWPX <hp:dutmal>.

Fields

§main_text: String

Main text that receives the annotation.

§sub_text: String

Annotation text displayed above/below.

§position: DutmalPosition

Position of the annotation relative to main text.

§sz_ratio: u32

Size ratio of annotation text relative to main (0 = auto).

§align: DutmalAlign

Alignment of the annotation text.

§

Compose

Compose (글자겹침): overlaid/combined characters. Maps to HWPX <hp:compose>.

Fields

§compose_text: String

The combined text (e.g. “12” for two overlaid digits).

§circle_type: String

Circle/frame type for the composition.

§char_sz: i32

Character size adjustment (-3 = slightly smaller).

§compose_type: String

Composition layout type.

§

Arc

An arc (partial ellipse) drawing object. Maps to HWPX <hp:ellipse> with hasArcPr="1".

Fields

§arc_type: ArcType

Arc type (normal open arc, pie/sector, chord).

§center: ShapePoint

Center point of the parent ellipse.

§axis1: ShapePoint

Axis 1 endpoint (semi-major axis).

§axis2: ShapePoint

Axis 2 endpoint (semi-minor axis).

§start1: ShapePoint

Arc start point 1.

§end1: ShapePoint

Arc end point 1.

§start2: ShapePoint

Arc start point 2.

§end2: ShapePoint

Arc end point 2.

§width: HwpUnit

Bounding box width (HWPUNIT).

§height: HwpUnit

Bounding box height (HWPUNIT).

§horz_offset: i32

Horizontal offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§vert_offset: i32

Vertical offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§caption: Option<Caption>

Optional caption attached to this arc.

§style: Option<ShapeStyle>

Optional visual style overrides.

§

Curve

A curve drawing object (bezier/polyline). Maps to HWPX <hp:curve>.

Fields

§points: Vec<ShapePoint>

Ordered control points for the curve path.

§segment_types: Vec<CurveSegmentType>

Segment types (one per segment between points).

§width: HwpUnit

Bounding box width (HWPUNIT).

§height: HwpUnit

Bounding box height (HWPUNIT).

§horz_offset: i32

Horizontal offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§vert_offset: i32

Vertical offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§caption: Option<Caption>

Optional caption attached to this curve.

§style: Option<ShapeStyle>

Optional visual style overrides.

§

ConnectLine

A connect line drawing object (line with control points for routing). Maps to HWPX <hp:connectLine>.

Fields

§start: ShapePoint

Start point of the connect line.

§end: ShapePoint

End point of the connect line.

§control_points: Vec<ShapePoint>

Intermediate control points for routing.

§connect_type: String

Connect line type (e.g. “STRAIGHT”, “BENT”, “CURVED”).

§width: HwpUnit

Bounding box width (HWPUNIT).

§height: HwpUnit

Bounding box height (HWPUNIT).

§horz_offset: i32

Horizontal offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§vert_offset: i32

Vertical offset from anchor point (HWPUNIT, 0 = inline/treat-as-char).

§caption: Option<Caption>

Optional caption attached to this connect line.

§style: Option<ShapeStyle>

Optional visual style overrides.

§

Bookmark

A bookmark marking a named location in the document. Maps to HWPX <hp:ctrl><hp:bookmark> (point) or fieldBegin/fieldEnd type="BOOKMARK" (span).

Fields

§name: String

Bookmark name (unique within the document).

§bookmark_type: BookmarkType

Type: point bookmark or span start/end.

§

CrossRef

A cross-reference (상호참조) to a bookmark, table, figure, or equation. Maps to HWPX fieldBegin type="CROSSREF" with parameters.

Fields

§target_name: String

Target bookmark or object name (e.g. "bookmark1", "table23").

§ref_type: RefType

What kind of target is being referenced.

§content_type: RefContentType

What content to display at the reference site.

§as_hyperlink: bool

Whether to render the reference as a clickable hyperlink.

§

Field

A press-field (누름틀) — an interactive form field. Maps to HWPX fieldBegin type="CLICK_HERE" with parameters and metaTag.

Fields

§field_type: FieldType

Field type (ClickHere, Date, Time, etc.).

§hint_text: Option<String>

Hint/visible text shown in the field placeholder.

§help_text: Option<String>

Help text shown when hovering or clicking the field.

§

Memo

A memo (메모) annotation attached to text. Maps to HWPX fieldBegin type="MEMO" with <hp:subList> body inside.

Fields

§content: Vec<Paragraph>

Paragraphs forming the memo body content.

§author: String

Author name.

§date: String

Date string (e.g. "2026-03-05").

§

IndexMark

An index mark for building a document index (찾아보기). Maps to HWPX <hp:ctrl><hp:indexmark>.

Fields

§primary: String

Primary index key (required).

§secondary: Option<String>

Secondary (sub-entry) index key.

§

Unknown

An unrecognized control element preserved for round-trip fidelity.

tag holds the element’s tag name or type identifier. data holds optional serialized content for lossless preservation.

Fields

§tag: String

Tag name or type identifier of the unrecognized element.

§data: Option<String>

Optional serialized data for round-trip preservation.

Implementations§

Source§

impl Control

Source

pub fn is_text_box(&self) -> bool

Returns true if this is a Control::TextBox.

Returns true if this is a Control::Hyperlink.

Source

pub fn is_footnote(&self) -> bool

Returns true if this is a Control::Footnote.

Source

pub fn is_endnote(&self) -> bool

Returns true if this is a Control::Endnote.

Source

pub fn is_line(&self) -> bool

Returns true if this is a Control::Line.

Source

pub fn is_ellipse(&self) -> bool

Returns true if this is a Control::Ellipse.

Source

pub fn is_polygon(&self) -> bool

Returns true if this is a Control::Polygon.

Source

pub fn is_equation(&self) -> bool

Returns true if this is a Control::Equation.

Source

pub fn is_chart(&self) -> bool

Returns true if this is a Control::Chart.

Source

pub fn is_unknown(&self) -> bool

Returns true if this is a Control::Unknown.

Source

pub fn is_dutmal(&self) -> bool

Returns true if this is a Control::Dutmal.

Source

pub fn is_compose(&self) -> bool

Returns true if this is a Control::Compose.

Source

pub fn is_arc(&self) -> bool

Returns true if this is a Control::Arc.

Source

pub fn is_curve(&self) -> bool

Returns true if this is a Control::Curve.

Source

pub fn is_connect_line(&self) -> bool

Returns true if this is a Control::ConnectLine.

Source

pub fn is_bookmark(&self) -> bool

Returns true if this is a Control::Bookmark.

Source

pub fn is_cross_ref(&self) -> bool

Returns true if this is a Control::CrossRef.

Source

pub fn is_field(&self) -> bool

Returns true if this is a Control::Field.

Source

pub fn is_memo(&self) -> bool

Returns true if this is a Control::Memo.

Source

pub fn is_index_mark(&self) -> bool

Returns true if this is a Control::IndexMark.

Source

pub fn bookmark(name: &str) -> Self

Creates a point bookmark at a named location.

§Examples
use hwpforge_core::control::Control;

let bm = Control::bookmark("section1");
assert!(bm.is_bookmark());
Source

pub fn field(hint: &str) -> Self

Creates a press-field (누름틀) with the given hint text.

§Examples
use hwpforge_core::control::Control;

let field = Control::field("이름을 입력하세요");
assert!(field.is_field());
Source

pub fn index_mark(primary: &str) -> Self

Creates an index mark with a primary key.

§Examples
use hwpforge_core::control::Control;

let mark = Control::index_mark("한글");
assert!(mark.is_index_mark());
Source

pub fn memo(content: Vec<Paragraph>, author: &str, date: &str) -> Self

Creates a memo annotation with the given text content.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::ParaShapeIndex;

let para = Paragraph::new(ParaShapeIndex::new(0));
let memo = Control::memo(vec![para], "Author", "2026-03-05");
assert!(memo.is_memo());
Source

pub fn cross_ref( target: &str, ref_type: RefType, content_type: RefContentType, ) -> Self

Creates a cross-reference to a bookmark target.

§Examples
use hwpforge_core::control::Control;
use hwpforge_foundation::{RefType, RefContentType};

let xref = Control::cross_ref("section1", RefType::Bookmark, RefContentType::Page);
assert!(xref.is_cross_ref());
Source

pub fn chart(chart_type: ChartType, data: ChartData) -> Self

Creates a chart control with default dimensions and settings.

Defaults: width ≈ 114mm, height ≈ 66mm, no title, right legend, clustered grouping.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::chart::{ChartType, ChartData};

let data = ChartData::category(&["A", "B"], &[("S1", &[10.0, 20.0])]);
let ctrl = Control::chart(ChartType::Column, data);
assert!(ctrl.is_chart());
Source

pub fn equation(script: &str) -> Self

Creates an equation control with default dimensions for the given HancomEQN script.

Defaults: width ≈ 31mm (8779 HWPUNIT), height ≈ 9.2mm (2600 HWPUNIT), baseline 71%, black text, HancomEQN font.

§Examples
use hwpforge_core::control::Control;

let ctrl = Control::equation("{a+b} over {c+d}");
assert!(ctrl.is_equation());
Source

pub fn text_box( paragraphs: Vec<Paragraph>, width: HwpUnit, height: HwpUnit, ) -> Self

Creates a text box control with the given paragraphs and dimensions.

Defaults: inline positioning (horz_offset=0, vert_offset=0), no caption, no style override.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{HwpUnit, ParaShapeIndex};

let para = Paragraph::new(ParaShapeIndex::new(0));
let width = HwpUnit::from_mm(80.0).unwrap();
let height = HwpUnit::from_mm(40.0).unwrap();
let ctrl = Control::text_box(vec![para], width, height);
assert!(ctrl.is_text_box());
Source

pub fn footnote(paragraphs: Vec<Paragraph>) -> Self

Creates a footnote control with the given paragraph content.

Defaults: no inst_id.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::run::Run;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{CharShapeIndex, ParaShapeIndex};

let para = Paragraph::with_runs(
    vec![Run::text("Note text", CharShapeIndex::new(0))],
    ParaShapeIndex::new(0),
);
let ctrl = Control::footnote(vec![para]);
assert!(ctrl.is_footnote());
Source

pub fn endnote(paragraphs: Vec<Paragraph>) -> Self

Creates an endnote control with the given paragraph content.

Defaults: no inst_id.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::run::Run;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{CharShapeIndex, ParaShapeIndex};

let para = Paragraph::with_runs(
    vec![Run::text("End note", CharShapeIndex::new(0))],
    ParaShapeIndex::new(0),
);
let ctrl = Control::endnote(vec![para]);
assert!(ctrl.is_endnote());
Source

pub fn footnote_with_id(inst_id: u32, paragraphs: Vec<Paragraph>) -> Self

Creates a footnote with an explicit instance ID for cross-referencing.

Use this when you need stable inst_id references (e.g. matching decoder output). For simple footnotes without cross-references, prefer Control::footnote.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::ParaShapeIndex;

let ctrl = Control::footnote_with_id(1, vec![Paragraph::new(ParaShapeIndex::new(0))]);
assert!(ctrl.is_footnote());
Source

pub fn endnote_with_id(inst_id: u32, paragraphs: Vec<Paragraph>) -> Self

Creates an endnote with an explicit instance ID for cross-referencing.

Use this when you need stable inst_id references (e.g. matching decoder output). For simple endnotes without cross-references, prefer Control::endnote.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::ParaShapeIndex;

let ctrl = Control::endnote_with_id(2, vec![Paragraph::new(ParaShapeIndex::new(0))]);
assert!(ctrl.is_endnote());
Source

pub fn ellipse(width: HwpUnit, height: HwpUnit) -> Self

Creates an ellipse control with the given bounding box dimensions.

Geometry is auto-derived: center=(w/2, h/2), axis1=(w, h/2), axis2=(w/2, h). Defaults: inline positioning (horz_offset=0, vert_offset=0), no paragraphs, no caption, no style.

§Examples
use hwpforge_core::control::Control;
use hwpforge_foundation::HwpUnit;

let width = HwpUnit::from_mm(40.0).unwrap();
let height = HwpUnit::from_mm(30.0).unwrap();
let ctrl = Control::ellipse(width, height);
assert!(ctrl.is_ellipse());
Source

pub fn ellipse_with_text( width: HwpUnit, height: HwpUnit, paragraphs: Vec<Paragraph>, ) -> Self

Creates an ellipse control with paragraph content inside.

Same as Control::ellipse but accepts paragraphs for text drawn inside the ellipse. Geometry is auto-derived: center=(w/2, h/2), axis1=(w, h/2), axis2=(w/2, h). Defaults: inline positioning (horz_offset=0, vert_offset=0), no caption, no style.

§Examples
use hwpforge_core::control::Control;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{HwpUnit, ParaShapeIndex};

let width = HwpUnit::from_mm(40.0).unwrap();
let height = HwpUnit::from_mm(30.0).unwrap();
let para = Paragraph::new(ParaShapeIndex::new(0));
let ctrl = Control::ellipse_with_text(width, height, vec![para]);
assert!(ctrl.is_ellipse());
Source

pub fn polygon(vertices: Vec<ShapePoint>) -> CoreResult<Self>

Creates a polygon control from the given vertices.

The bounding box is auto-derived from the min/max of vertex coordinates. Defaults: no paragraphs, no caption, no style.

Returns an error if fewer than 3 vertices are provided.

§Errors

Returns CoreError::InvalidStructure if vertices.len() < 3.

§Examples
use hwpforge_core::control::{Control, ShapePoint};

let vertices = vec![
    ShapePoint::new(0, 1000),
    ShapePoint::new(500, 0),
    ShapePoint::new(1000, 1000),
];
let ctrl = Control::polygon(vertices).unwrap();
assert!(ctrl.is_polygon());
Source

pub fn line(start: ShapePoint, end: ShapePoint) -> CoreResult<Self>

Creates a line control between two endpoints.

The bounding box width and height are derived from the absolute difference of the endpoint coordinates: width = |end.x - start.x|, height = |end.y - start.y|. Each axis is clamped to a minimum of 100 HwpUnit (~1pt) because 한글 cannot render lines with a zero-dimension bounding box. Defaults: no caption, no style.

Returns an error if start and end are the same point (degenerate line).

§Errors

Returns CoreError::InvalidStructure if start equals end.

§Examples
use hwpforge_core::control::{Control, ShapePoint};

let ctrl = Control::line(ShapePoint::new(0, 0), ShapePoint::new(5000, 0)).unwrap();
assert!(ctrl.is_line());
Source

pub fn horizontal_line(width: HwpUnit) -> Self

Creates a horizontal line of the given width.

Shortcut for line(ShapePoint::new(0, 0), ShapePoint::new(width.as_i32(), 0)). The bounding box height is clamped to 100 HwpUnit (~1pt minimum) because 한글 cannot render lines with a zero-dimension bounding box. Defaults: no caption, no style.

§Examples
use hwpforge_core::control::Control;
use hwpforge_foundation::HwpUnit;

let width = HwpUnit::from_mm(100.0).unwrap();
let ctrl = Control::horizontal_line(width);
assert!(ctrl.is_line());
Source

pub fn dutmal(main_text: impl Into<String>, sub_text: impl Into<String>) -> Self

Creates a dutmal (annotation text) control with default positioning.

Defaults: position = Top, sz_ratio = 0 (auto), align = Center.

§Examples
use hwpforge_core::control::Control;

let ctrl = Control::dutmal("본문", "주석");
assert!(ctrl.is_dutmal());
Source

pub fn compose(text: impl Into<String>) -> Self

Creates a compose (글자겹침) control with default settings.

Defaults: circle_type = "SHAPE_REVERSAL_TIRANGLE" (spec typo preserved), char_sz = -3, compose_type = "SPREAD".

§Examples
use hwpforge_core::control::Control;

let ctrl = Control::compose("12");
assert!(ctrl.is_compose());
Source

pub fn arc(arc_type: ArcType, width: HwpUnit, height: HwpUnit) -> Self

Creates an arc control with the given bounding box dimensions.

Geometry is auto-derived from the bounding box. Defaults: inline positioning, no caption, no style.

§Examples
use hwpforge_core::control::Control;
use hwpforge_foundation::{ArcType, HwpUnit};

let width = HwpUnit::from_mm(40.0).unwrap();
let height = HwpUnit::from_mm(30.0).unwrap();
let ctrl = Control::arc(ArcType::Pie, width, height);
assert!(ctrl.is_arc());
Source

pub fn curve(points: Vec<ShapePoint>) -> CoreResult<Self>

Creates a curve control from the given control points.

All segments default to CurveSegmentType::Curve. The bounding box is auto-derived from min/max of point coordinates.

Returns an error if fewer than 2 points are provided.

§Errors

Returns CoreError::InvalidStructure if points.len() < 2.

§Examples
use hwpforge_core::control::{Control, ShapePoint};

let pts = vec![
    ShapePoint::new(0, 0),
    ShapePoint::new(2500, 5000),
    ShapePoint::new(5000, 0),
];
let ctrl = Control::curve(pts).unwrap();
assert!(ctrl.is_curve());
Source

pub fn connect_line(start: ShapePoint, end: ShapePoint) -> CoreResult<Self>

Creates a connect line between two endpoints.

Defaults: no control points, type “STRAIGHT”, no caption, no style.

Returns an error if start equals end.

§Errors

Returns CoreError::InvalidStructure if start equals end.

§Examples
use hwpforge_core::control::{Control, ShapePoint};

let ctrl = Control::connect_line(
    ShapePoint::new(0, 0),
    ShapePoint::new(5000, 5000),
).unwrap();
assert!(ctrl.is_connect_line());

Creates a hyperlink control with the given display text and URL.

§Examples
use hwpforge_core::control::Control;

let ctrl = Control::hyperlink("Visit Rust", "https://rust-lang.org");
assert!(ctrl.is_hyperlink());

Trait Implementations§

Source§

impl Clone for Control

Source§

fn clone(&self) -> Control

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 Control

Source§

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

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

impl<'de> Deserialize<'de> for Control

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 Control

Source§

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

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

impl JsonSchema for Control

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 Control

Source§

fn eq(&self, other: &Control) -> 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 Control

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 Control

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>,