#[non_exhaustive]pub struct TableCell {
pub paragraphs: Vec<Paragraph>,
pub col_span: u16,
pub row_span: u16,
pub width: HwpUnit,
pub height: Option<HwpUnit>,
pub background: Option<Color>,
pub border_fill_id: Option<u32>,
pub margin: Option<TableMargin>,
pub vertical_align: Option<TableVerticalAlign>,
}Expand description
A single cell within a table row.
Each cell contains its own paragraphs (rich content). Spans default to 1 (no spanning).
§Examples
use hwpforge_core::table::TableCell;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{HwpUnit, ParaShapeIndex};
let cell = TableCell::new(
vec![Paragraph::new(ParaShapeIndex::new(0))],
HwpUnit::from_mm(40.0).unwrap(),
);
assert_eq!(cell.col_span, 1);
assert_eq!(cell.row_span, 1);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.paragraphs: Vec<Paragraph>Rich content within the cell.
col_span: u16Number of columns this cell spans. Must be >= 1.
row_span: u16Number of rows this cell spans. Must be >= 1.
width: HwpUnitCell width.
height: Option<HwpUnit>Optional explicit cell height.
background: Option<Color>Optional cell background color.
border_fill_id: Option<u32>Optional border/fill reference for this cell.
margin: Option<TableMargin>Optional cell-local margin override.
vertical_align: Option<TableVerticalAlign>Optional vertical alignment override for the cell content box.
Implementations§
Source§impl TableCell
impl TableCell
Sourcepub fn new(paragraphs: Vec<Paragraph>, width: HwpUnit) -> Self
pub fn new(paragraphs: Vec<Paragraph>, width: HwpUnit) -> Self
Creates a cell with default spans (1x1) and no background.
§Examples
use hwpforge_core::table::TableCell;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{HwpUnit, ParaShapeIndex};
let cell = TableCell::new(
vec![Paragraph::new(ParaShapeIndex::new(0))],
HwpUnit::from_mm(50.0).unwrap(),
);
assert_eq!(cell.col_span, 1);
assert_eq!(cell.row_span, 1);
assert!(cell.background.is_none());Sourcepub fn with_span(
paragraphs: Vec<Paragraph>,
width: HwpUnit,
col_span: u16,
row_span: u16,
) -> Self
pub fn with_span( paragraphs: Vec<Paragraph>, width: HwpUnit, col_span: u16, row_span: u16, ) -> Self
Creates a cell with explicit span values.
§Examples
use hwpforge_core::table::TableCell;
use hwpforge_core::paragraph::Paragraph;
use hwpforge_foundation::{HwpUnit, ParaShapeIndex};
let merged = TableCell::with_span(
vec![Paragraph::new(ParaShapeIndex::new(0))],
HwpUnit::from_mm(100.0).unwrap(),
2, // col_span
3, // row_span
);
assert_eq!(merged.col_span, 2);
assert_eq!(merged.row_span, 3);Sourcepub fn with_height(self, height: HwpUnit) -> Self
pub fn with_height(self, height: HwpUnit) -> Self
Sets an explicit cell height.
Sourcepub fn with_background(self, background: Color) -> Self
pub fn with_background(self, background: Color) -> Self
Sets the cell background color.
Sourcepub fn with_border_fill_id(self, border_fill_id: u32) -> Self
pub fn with_border_fill_id(self, border_fill_id: u32) -> Self
Sets the cell border/fill reference.
Sourcepub fn with_margin(self, margin: TableMargin) -> Self
pub fn with_margin(self, margin: TableMargin) -> Self
Sets the cell-local margin override.
Sourcepub fn with_vertical_align(self, vertical_align: TableVerticalAlign) -> Self
pub fn with_vertical_align(self, vertical_align: TableVerticalAlign) -> Self
Sets the vertical alignment override for the cell content box.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TableCell
impl<'de> Deserialize<'de> for TableCell
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 TableCell
impl JsonSchema for TableCell
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