pub struct TextBody {
pub body_properties: Option<BodyProperties>,
pub paragraphs: Vec<Paragraph>,
}Expand description
文本体 <p:txBody>。
对应 python-pptx 的 TextFrame 类:提供段落列表 + 自动调整 / 边距 /
垂直对齐 / 换行等“文本框级“属性。
Fields§
§body_properties: Option<BodyProperties>§paragraphs: Vec<Paragraph>Implementations§
Source§impl TextBody
impl TextBody
pub fn new() -> TextBody
Sourcepub fn write_xml(&self, w: &mut XmlWriter, tag: &str)
pub fn write_xml(&self, w: &mut XmlWriter, tag: &str)
写 XML。
tag 参数指定外层元素标签名(如 "p:txBody" 用于 PPTX,
"c:txBody" 用于 chart 标题等)。这样本类型可在不同格式间复用。
Sourcepub fn first_paragraph(&self) -> Option<&Paragraph>
pub fn first_paragraph(&self) -> Option<&Paragraph>
取首个段落(TextFrame.paragraphs[0] 的等价物)。
Sourcepub fn first_paragraph_mut(&mut self) -> Option<&mut Paragraph>
pub fn first_paragraph_mut(&mut self) -> Option<&mut Paragraph>
取首个段落的可变引用。
Sourcepub fn paragraph_mut(&mut self, idx: usize) -> Option<&mut Paragraph>
pub fn paragraph_mut(&mut self, idx: usize) -> Option<&mut Paragraph>
取第 idx 个段落的可变引用(越界返回 None)。
Sourcepub fn add_paragraph(&mut self) -> &mut Paragraph
pub fn add_paragraph(&mut self) -> &mut Paragraph
新增一个空段落并返回其可变引用。
对应 TextFrame.add_paragraph()。
Sourcepub fn add_paragraph_with_text(&mut self, text: &str) -> &mut Paragraph
pub fn add_paragraph_with_text(&mut self, text: &str) -> &mut Paragraph
新增一个带文本的段落,返回其可变引用。
文本按 \n 切分为多段,与 python-pptx 的 TextFrame.text = "a\nb" 行为对齐。
Sourcepub fn remove_paragraph(&mut self, idx: usize) -> Option<Paragraph>
pub fn remove_paragraph(&mut self, idx: usize) -> Option<Paragraph>
移除第 idx 个段落。
Sourcepub fn set_text(&mut self, text: &str)
pub fn set_text(&mut self, text: &str)
整体替换文本(按 \n 切分为多段,丢弃原段落属性)。
对应 python-pptx text_frame.text = "a\nb"。
Sourcepub fn auto_size(&self) -> MsoAutoSize
pub fn auto_size(&self) -> MsoAutoSize
自动调整策略(TextFrame.auto_size)。
Sourcepub fn set_auto_size(&mut self, v: MsoAutoSize)
pub fn set_auto_size(&mut self, v: MsoAutoSize)
设置自动调整策略。
Sourcepub fn vertical_anchor(&self) -> Option<MsoAnchor>
pub fn vertical_anchor(&self) -> Option<MsoAnchor>
垂直对齐(TextFrame.vertical_anchor)。
Sourcepub fn set_vertical_anchor(&mut self, v: MsoAnchor)
pub fn set_vertical_anchor(&mut self, v: MsoAnchor)
设置垂直对齐。
Sourcepub fn set_word_wrap(&mut self, v: bool)
pub fn set_word_wrap(&mut self, v: bool)
设置是否自动换行。
Sourcepub fn margin_left(&self) -> Option<Emu>
pub fn margin_left(&self) -> Option<Emu>
左边距(EMU)。
Sourcepub fn margin_right(&self) -> Option<Emu>
pub fn margin_right(&self) -> Option<Emu>
右边距。
Sourcepub fn margin_top(&self) -> Option<Emu>
pub fn margin_top(&self) -> Option<Emu>
上边距。
Sourcepub fn margin_bottom(&self) -> Option<Emu>
pub fn margin_bottom(&self) -> Option<Emu>
下边距。
Sourcepub fn set_margin_left(&mut self, emu: Emu)
pub fn set_margin_left(&mut self, emu: Emu)
设置左边距。
Sourcepub fn set_margin_right(&mut self, emu: Emu)
pub fn set_margin_right(&mut self, emu: Emu)
设置右边距。
Sourcepub fn set_margin_top(&mut self, emu: Emu)
pub fn set_margin_top(&mut self, emu: Emu)
设置上边距。
Sourcepub fn set_margin_bottom(&mut self, emu: Emu)
pub fn set_margin_bottom(&mut self, emu: Emu)
设置下边距。
Sourcepub fn set_num_cols(&mut self, count: u32)
pub fn set_num_cols(&mut self, count: u32)
设置文本列数。
Sourcepub fn col_spacing(&self) -> Option<Emu>
pub fn col_spacing(&self) -> Option<Emu>
列间距(spcCol 属性,EMU)。
Sourcepub fn set_col_spacing(&mut self, emu: Emu)
pub fn set_col_spacing(&mut self, emu: Emu)
设置列间距。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextBody
impl RefUnwindSafe for TextBody
impl Send for TextBody
impl Sync for TextBody
impl Unpin for TextBody
impl UnsafeUnpin for TextBody
impl UnwindSafe for TextBody
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more