pub struct Section {
pub paragraphs: Vec<Paragraph>,
pub page_settings: PageSettings,
pub header: Option<HeaderFooter>,
pub footer: Option<HeaderFooter>,
pub page_number: Option<PageNumber>,
pub column_settings: Option<ColumnSettings>,
pub visibility: Option<Visibility>,
pub line_number_shape: Option<LineNumberShape>,
pub page_border_fills: Option<Vec<PageBorderFillEntry>>,
pub master_pages: Option<Vec<MasterPage>>,
pub begin_num: Option<BeginNum>,
pub text_direction: TextDirection,
}Expand description
A document section: paragraphs + page geometry.
§Examples
use hwpforge_core::section::Section;
use hwpforge_core::PageSettings;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::ParaShapeIndex;
let section = Section::with_paragraphs(
vec![Paragraph::new(ParaShapeIndex::new(0))],
PageSettings::a4(),
);
assert_eq!(section.paragraph_count(), 1);Fields§
§paragraphs: Vec<Paragraph>Ordered paragraphs in this section.
page_settings: PageSettingsPage dimensions and margins for this section.
header: Option<HeaderFooter>Optional header for this section.
Optional footer for this section.
page_number: Option<PageNumber>Optional page number settings for this section.
column_settings: Option<ColumnSettings>Multi-column layout. None = single column (default).
visibility: Option<Visibility>Visibility flags for headers, footers, borders, etc.
None = default visibility (show everything).
line_number_shape: Option<LineNumberShape>Line numbering settings. None = no line numbers.
page_border_fills: Option<Vec<PageBorderFillEntry>>Page border/fill entries. None = default 3 entries (BOTH/EVEN/ODD with borderFillIDRef=1).
master_pages: Option<Vec<MasterPage>>Master pages (background content rendered behind the body).
None = no master pages (default).
begin_num: Option<BeginNum>Starting numbers for auto-numbering sequences.
None = default values (all start at 1).
text_direction: TextDirectionText writing direction for this section.
Defaults to TextDirection::Horizontal (가로쓰기).
Implementations§
Source§impl Section
impl Section
Sourcepub fn new(page_settings: PageSettings) -> Self
pub fn new(page_settings: PageSettings) -> Self
Creates an empty section with the given page settings.
§Examples
use hwpforge_core::section::Section;
use hwpforge_core::PageSettings;
let section = Section::new(PageSettings::a4());
assert!(section.is_empty());Sourcepub fn with_paragraphs(
paragraphs: Vec<Paragraph>,
page_settings: PageSettings,
) -> Self
pub fn with_paragraphs( paragraphs: Vec<Paragraph>, page_settings: PageSettings, ) -> Self
Creates a section with pre-built paragraphs.
§Examples
use hwpforge_core::section::Section;
use hwpforge_core::PageSettings;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::ParaShapeIndex;
let section = Section::with_paragraphs(
vec![Paragraph::new(ParaShapeIndex::new(0))],
PageSettings::letter(),
);
assert_eq!(section.paragraph_count(), 1);Sourcepub fn with_text_direction(self, dir: TextDirection) -> Self
pub fn with_text_direction(self, dir: TextDirection) -> Self
Sets the text writing direction for this section and returns self.
§Examples
use hwpforge_core::section::Section;
use hwpforge_core::PageSettings;
use hwpforge_foundation::TextDirection;
let section = Section::new(PageSettings::a4())
.with_text_direction(TextDirection::Vertical);
assert_eq!(section.text_direction, TextDirection::Vertical);Sourcepub fn add_paragraph(&mut self, paragraph: Paragraph)
pub fn add_paragraph(&mut self, paragraph: Paragraph)
Appends a paragraph to this section.
Sourcepub fn paragraph_count(&self) -> usize
pub fn paragraph_count(&self) -> usize
Returns the number of paragraphs.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Section
impl<'de> Deserialize<'de> for Section
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Section
impl JsonSchema for Section
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more