Skip to main content

Shapes

Struct Shapes 

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

不可变形状视图。

通过 slide.shapes() 获取,提供 len / is_empty / iter / get 等只读 API。

Implementations§

Source§

impl<'a> Shapes<'a>

Source

pub fn len(&self) -> usize

形状数量。

Source

pub fn is_empty(&self) -> bool

是否为空。

Source

pub fn iter(&self) -> impl Iterator<Item = ShapeKind> + 'a

遍历所有形状(克隆为 ShapeKind 枚举)。

返回的 ShapeKind 是高阶句柄,与原 Slide 拥有独立生命周期; 适合“先收集再逐个处理“的链式风格。

Source

pub fn get(&self, idx: usize) -> Option<ShapeKind>

按索引取一个形状(克隆为 ShapeKind)。

Source

pub fn title(&self) -> Option<ShapeKind>

标题占位符(若有)。

对标 python-pptx Slide.shapes.title

§判定策略

按以下顺序查找第一个命中的形状(顺序与 python-pptx 略有差异,但行为更直观):

  1. ph_type == "title"ph_type == "ctrTitle"(居中标题);
  2. ph_idx == 0 的占位符(OOXML 默认 idx=0 即为标题位);
  3. name 含 “title”(不区分大小写)的占位符(兼容手工制作的 slide)。

返回 None 表示该 slide 没有标题占位符。

Source

pub fn placeholders(&self) -> Vec<ShapeKind>

取所有占位符形状(按 ph_idx 升序排列;同 idx 多个按原顺序)。

对标 python-pptx Slide.placeholders / Slide.shapes.placeholders

Source

pub fn placeholder(&self, idx: u32) -> Option<ShapeKind>

ph_idx 查占位符。

对标 python-pptx slide.placeholders[idx]__getitem__ 语义。 返回第一个 ph_idx == idx 的占位符;没有则返回 None

Source

pub fn placeholders_inherited(&self, layout: &SlideLayoutRef) -> Vec<ShapeKind>

取所有占位符,并从给定版式继承位置/尺寸/填充/边框。

对标 python-pptx slide.placeholders 的继承语义:当 slide 占位符 未显式设置 xfrm / fill / line 时,从 layout 中同 ph_idx 的占位符继承。

§参数
  • layout:所属 Presentation 中的版式引用(通过 Presentation::layout_for_slide 获取)。
§返回

返回的 ShapeKind::Placeholder 携带继承后的属性快照(clone), 修改返回值不会回写到 slide。如需修改 slide 上的占位符,请用 ShapesMut::placeholder_mut

§继承规则
  1. 若 slide 占位符 xfrm.is_empty(),从 layout 占位符继承 xfrm;
  2. 若 slide 占位符 fill == Fill::Inherit,从 layout 占位符继承 fill;
  3. 若 slide 占位符 line == None,从 layout 占位符继承 line;
  4. ph_type / ph_idx 保持 slide 自身值不变。
Source

pub fn placeholder_inherited( &self, idx: u32, layout: &SlideLayoutRef, ) -> Option<ShapeKind>

ph_idx 查占位符,并从给定版式继承位置/尺寸/填充/边框。

Shapes::placeholders_inherited 的区别:仅返回指定 idx 的占位符。

Trait Implementations§

Source§

impl<'a> Debug for Shapes<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Shapes<'a>

§

impl<'a> !Send for Shapes<'a>

§

impl<'a> !Sync for Shapes<'a>

§

impl<'a> !UnwindSafe for Shapes<'a>

§

impl<'a> Freeze for Shapes<'a>

§

impl<'a> Unpin for Shapes<'a>

§

impl<'a> UnsafeUnpin for Shapes<'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