Skip to main content

ParagraphFormat

Struct ParagraphFormat 

Source
pub struct ParagraphFormat<'a> { /* private fields */ }
Expand description

段落格式高阶视图(pptx.text.text._ParagraphFormat)。

§与 python-pptx 的对应

§设计要点

  • 借用 + 透明代理:构造时传入 &mut ParagraphProperties
  • 零分配:纯字段操作;
  • 互斥语义set_line_spacing / set_line_spacing_pct 互斥; 后调用的会清空前者。

Implementations§

Source§

impl<'a> ParagraphFormat<'a>

Source

pub fn new(ppr: &'a mut ParagraphProperties) -> ParagraphFormat<'a>

构造。

Source

pub fn ppr(&self) -> &ParagraphProperties

底层 ppr 不可变引用。

Source

pub fn ppr_mut(&mut self) -> &mut ParagraphProperties

底层 ppr 可变引用。

Source

pub fn alignment(&self) -> Option<Alignment>

水平对齐。

Source

pub fn set_alignment(&mut self, v: Alignment)

设置水平对齐。

Source

pub fn clear_alignment(&mut self)

清除水平对齐(走默认)。

Source

pub fn level(&self) -> u8

段落级别(0-8)。

Source

pub fn set_level(&mut self, lvl: u8)

设置段落级别。

Source

pub fn line_spacing(&self) -> Option<Pt>

行距(固定值,Pt)。

Source

pub fn set_line_spacing(&mut self, v: Pt)

设置行距为固定点数(与 set_line_spacing_pct 互斥)。

Source

pub fn line_spacing_pct(&self) -> Option<f32>

行距(倍数,1.0 = 100%)。

Source

pub fn set_line_spacing_pct(&mut self, v: f32)

设置行距为倍数(与 set_line_spacing 互斥)。

Source

pub fn clear_line_spacing(&mut self)

清除行距。

Source

pub fn space_before(&self) -> Option<Emu>

段前(EMU)。

Source

pub fn set_space_before(&mut self, emu: Emu)

设置段前。

Source

pub fn space_after(&self) -> Option<Emu>

段后(EMU)。

Source

pub fn set_space_after(&mut self, emu: Emu)

设置段后。

Source

pub fn set_indent( &mut self, left: Option<Emu>, right: Option<Emu>, first_line: Option<Emu>, hanging: Option<i32>, )

一次性设置缩进。

Source

pub fn indent(&self) -> Indent

缩进(EMU 视图)。

Source

pub fn bullet_style(&self) -> Option<&BulletStyle>

项目符号样式。

返回 None 表示未设置(走默认继承);Some(BulletStyle::None) 表示显式无项目符号。

Source

pub fn set_bullet_char(&mut self, ch: impl Into<String>)

设置自定义字符项目符号(<a:buChar char="..."/>)。

对标 python-pptx paragraph.font + bullet 字符设置。 常用字符:"•" / "▪" / "→" / "○" / "♦"

Source

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 开始)。
Source

pub fn clear_bullet(&mut self)

清除项目符号(<a:buNone/>)。

Source

pub fn has_bullet(&self) -> bool

是否有项目符号(bullet=truebullet_styleNone)。

Source

pub fn tab_stops(&self) -> &[TabStop]

制表位列表(不可变)。

对标 python-pptx _ParagraphFormat.tab_stops

Source

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:对齐类型(左/居中/右/小数点)。
Source

pub fn clear_tab_stops(&mut self)

清除所有制表位。

Trait Implementations§

Source§

impl<'a> Debug for ParagraphFormat<'a>

Source§

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

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

impl<'a> From<&'a mut ParagraphProperties> for ParagraphFormat<'a>

Source§

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V