pub struct ParagraphFormat<'a> { /* private fields */ }Expand description
段落格式高阶视图(pptx.text.text._ParagraphFormat)。
§与 python-pptx 的对应
paragraph.alignment = PP_ALIGN.CENTER←→ParagraphFormat::set_alignment;paragraph.line_spacing = 1.5←→ParagraphFormat::set_line_spacing;paragraph.space_before = Pt(6)←→ParagraphFormat::set_space_before。
§设计要点
- 借用 + 透明代理:构造时传入
&mut ParagraphProperties; - 零分配:纯字段操作;
- 互斥语义:
set_line_spacing/set_line_spacing_pct互斥; 后调用的会清空前者。
Implementations§
Source§impl<'a> ParagraphFormat<'a>
impl<'a> ParagraphFormat<'a>
Sourcepub fn new(ppr: &'a mut ParagraphProperties) -> ParagraphFormat<'a>
pub fn new(ppr: &'a mut ParagraphProperties) -> ParagraphFormat<'a>
构造。
Sourcepub fn ppr(&self) -> &ParagraphProperties
pub fn ppr(&self) -> &ParagraphProperties
底层 ppr 不可变引用。
Sourcepub fn ppr_mut(&mut self) -> &mut ParagraphProperties
pub fn ppr_mut(&mut self) -> &mut ParagraphProperties
底层 ppr 可变引用。
Sourcepub fn set_alignment(&mut self, v: Alignment)
pub fn set_alignment(&mut self, v: Alignment)
设置水平对齐。
Sourcepub fn clear_alignment(&mut self)
pub fn clear_alignment(&mut self)
清除水平对齐(走默认)。
Sourcepub fn line_spacing(&self) -> Option<Pt>
pub fn line_spacing(&self) -> Option<Pt>
行距(固定值,Pt)。
Sourcepub fn set_line_spacing(&mut self, v: Pt)
pub fn set_line_spacing(&mut self, v: Pt)
设置行距为固定点数(与 set_line_spacing_pct 互斥)。
Sourcepub fn line_spacing_pct(&self) -> Option<f32>
pub fn line_spacing_pct(&self) -> Option<f32>
行距(倍数,1.0 = 100%)。
Sourcepub fn set_line_spacing_pct(&mut self, v: f32)
pub fn set_line_spacing_pct(&mut self, v: f32)
设置行距为倍数(与 set_line_spacing 互斥)。
Sourcepub fn clear_line_spacing(&mut self)
pub fn clear_line_spacing(&mut self)
清除行距。
Sourcepub fn space_before(&self) -> Option<Emu>
pub fn space_before(&self) -> Option<Emu>
段前(EMU)。
Sourcepub fn set_space_before(&mut self, emu: Emu)
pub fn set_space_before(&mut self, emu: Emu)
设置段前。
Sourcepub fn space_after(&self) -> Option<Emu>
pub fn space_after(&self) -> Option<Emu>
段后(EMU)。
Sourcepub fn set_space_after(&mut self, emu: Emu)
pub fn set_space_after(&mut self, emu: Emu)
设置段后。
Sourcepub fn set_indent(
&mut self,
left: Option<Emu>,
right: Option<Emu>,
first_line: Option<Emu>,
hanging: Option<i32>,
)
pub fn set_indent( &mut self, left: Option<Emu>, right: Option<Emu>, first_line: Option<Emu>, hanging: Option<i32>, )
一次性设置缩进。
Sourcepub fn bullet_style(&self) -> Option<&BulletStyle>
pub fn bullet_style(&self) -> Option<&BulletStyle>
项目符号样式。
返回 None 表示未设置(走默认继承);Some(BulletStyle::None) 表示显式无项目符号。
Sourcepub fn set_bullet_char(&mut self, ch: impl Into<String>)
pub fn set_bullet_char(&mut self, ch: impl Into<String>)
设置自定义字符项目符号(<a:buChar char="..."/>)。
对标 python-pptx paragraph.font + bullet 字符设置。
常用字符:"•" / "▪" / "→" / "○" / "♦"。
Sourcepub fn set_bullet_numbered(
&mut self,
auto_num_type: impl Into<String>,
start_at: Option<u32>,
)
pub fn set_bullet_numbered( &mut self, auto_num_type: impl Into<String>, start_at: Option<u32>, )
设置自动编号项目符号(<a:buAutoNum type="..." startAt="..."/>)。
对标 python-pptx 编号列表。
常用 type:"arabicPeriod" (1.) / "alphaLcParenR" (a)) / "romanLcParenBoth" ((i))。
§参数
auto_num_type:编号类型字面量。start_at:起始编号(可选,None表示从 1 开始)。
Sourcepub fn clear_bullet(&mut self)
pub fn clear_bullet(&mut self)
清除项目符号(<a:buNone/>)。
Sourcepub fn has_bullet(&self) -> bool
pub fn has_bullet(&self) -> bool
是否有项目符号(bullet=true 且 bullet_style 非 None)。
Sourcepub fn add_tab_stop(&mut self, pos: Emu, alignment: TabAlignment)
pub fn add_tab_stop(&mut self, pos: Emu, alignment: TabAlignment)
添加一个制表位(<a:tab pos="..." algn="..."/>)。
对标 python-pptx paragraph.tab_stops.add_tab_stop(position, alignment)。
§参数
pos:制表位位置(EMU);alignment:对齐类型(左/居中/右/小数点)。
Sourcepub fn clear_tab_stops(&mut self)
pub fn clear_tab_stops(&mut self)
清除所有制表位。
Trait Implementations§
Source§impl<'a> Debug for ParagraphFormat<'a>
impl<'a> Debug for ParagraphFormat<'a>
Source§impl<'a> From<&'a mut ParagraphProperties> for ParagraphFormat<'a>
impl<'a> From<&'a mut ParagraphProperties> for ParagraphFormat<'a>
Source§fn from(p: &'a mut ParagraphProperties) -> ParagraphFormat<'a>
fn from(p: &'a mut ParagraphProperties) -> ParagraphFormat<'a>
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a> !UnwindSafe for ParagraphFormat<'a>
impl<'a> Freeze for ParagraphFormat<'a>
impl<'a> RefUnwindSafe for ParagraphFormat<'a>
impl<'a> Send for ParagraphFormat<'a>
impl<'a> Sync for ParagraphFormat<'a>
impl<'a> Unpin for ParagraphFormat<'a>
impl<'a> UnsafeUnpin for ParagraphFormat<'a>
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