Skip to main content

SmartArtShape

Struct SmartArtShape 

Source
pub struct SmartArtShape { /* private fields */ }
Expand description

高阶 SmartArt 形状(承载 <p:graphicFrame> + <dgm:relIds> 引用)。

通过 SmartArtShape::smart_art / SmartArtShape::smart_art_mut 访问 内部 SmartArtRef(含 4 个关系 id 与原始 XML);通过 Shape trait 方法 (left / top / width / height)调整位置与尺寸。

§内部不变量

frame.graphic 始终保持为 Graphic::SmartArt(_)。本类型所有便捷方法 (dm_rid / set_dm_rid / lo_rid / set_lo_rid / …)在不变量被破坏时 静默忽略或返回空字符串,绝不 panic—— 这与库整体“零 panic“约定一致(参见 .trae/rules/project_rules.md §5)。

Implementations§

Source§

impl SmartArtShape

Source

pub fn new() -> Self

构造一个 SmartArt 形状(4 个关系 id 留空,由 presentation 层填充)。

内部调用 SmartArtRef::from_rids 构造初始 raw_xml。 后续通过 SmartArtShape::set_dm_rid 等 setter 更新任一 rid 时, raw_xml整体重新生成(4 个 rid 同步刷新)。

Source

pub fn from_rids(dm_rid: &str, lo_rid: &str, qs_rid: &str, cs_rid: &str) -> Self

从 4 个关系 id 构造 SmartArt 形状(直接初始化路径)。

Source

pub fn from_frame(frame: OxmlFrame) -> Self

从 oxml Frame 构造(通常用于读取已有 SmartArt 时)。

Source

pub fn smart_art(&self) -> Option<&SmartArtRef>

取内部 oxml SmartArtRef 引用。

返回 None 仅在内部不变量被外部错误破坏时(frame.graphic 不是 SmartArt 变体)。

Source

pub fn smart_art_mut(&mut self) -> Option<&mut SmartArtRef>

取内部 oxml SmartArtRef 可变引用。

Source

pub fn dm_rid(&self) -> &str

数据模型关系 id(r:dm,指向 /ppt/diagrams/diagramDataN.xml)。

不变量被破坏时返回空字符串。

Source

pub fn lo_rid(&self) -> &str

布局定义关系 id(r:lo,指向 /ppt/diagrams/diagramLayoutN.xml)。

Source

pub fn qs_rid(&self) -> &str

样式关系 id(r:qs,指向 /ppt/diagrams/diagramQuickStyleN.xml)。

Source

pub fn cs_rid(&self) -> &str

颜色关系 id(r:cs,指向 /ppt/diagrams/diagramColorsN.xml)。

Source

pub fn set_dm_rid(&mut self, rid: impl Into<String>)

设置数据模型关系 id(r:dm)。

重要:任一 rid 变更都会触发 raw_xml 整体重建(4 个 rid 同步刷新), 因为 raw_xml 内的 <dgm:relIds> 元素同时承载 4 个属性。 不变量被破坏时静默忽略。

Source

pub fn set_lo_rid(&mut self, rid: impl Into<String>)

设置布局定义关系 id(r:lo)。语义同 Self::set_dm_rid

Source

pub fn set_qs_rid(&mut self, rid: impl Into<String>)

设置样式关系 id(r:qs)。语义同 Self::set_dm_rid

Source

pub fn set_cs_rid(&mut self, rid: impl Into<String>)

设置颜色关系 id(r:cs)。语义同 Self::set_dm_rid

Source

pub fn set_all_rids( &mut self, dm_rid: impl Into<String>, lo_rid: impl Into<String>, qs_rid: impl Into<String>, cs_rid: impl Into<String>, )

一次性设置全部 4 个关系 id(比逐个 setter 高效:仅重建一次 raw_xml)。

Source

pub fn set_placeholder(&mut self, ph_idx: u32, ph_type: Option<&str>)

将本 SmartArt 形状标记为占位符。

写出 XML 时会在 <p:nvGraphicFramePr>/<p:nvPr> 内插入 <p:ph type="..." idx="..."/>

Source

pub fn clear_placeholder(&mut self)

清除占位符标记。

Source

pub fn is_placeholder(&self) -> bool

是否被标记为占位符。

Source

pub fn ph_idx(&self) -> Option<u32>

占位符索引(若已标记)。

Source

pub fn ph_type(&self) -> Option<&str>

占位符类型字符串(若已标记)。

Trait Implementations§

Source§

impl Clone for SmartArtShape

Source§

fn clone(&self) -> SmartArtShape

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SmartArtShape

Source§

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

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

impl Default for SmartArtShape

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Shape for SmartArtShape

Source§

fn rotation(&self) -> f64

SmartArt 不支持旋转(OOXML 规范)。调用 Shape::set_rotation 会被忽略。

Source§

fn id(&self) -> u32

形状唯一 ID(在所属 slide 内)。 Read more
Source§

fn set_id(&mut self, id: u32)

设置 ID。
Source§

fn name(&self) -> &str

形状名。
Source§

fn set_name(&mut self, name: String)

设置形状名。
Source§

fn shape_type(&self) -> &'static str

形状类型(如 "text_box" / "picture" / …)。 Read more
Source§

fn left(&self) -> Emu

左上角 x(EMU)。
Source§

fn set_left(&mut self, emu: Emu)

设置左上角 x。
Source§

fn top(&self) -> Emu

左上角 y(EMU)。
Source§

fn set_top(&mut self, emu: Emu)

设置左上角 y。
Source§

fn width(&self) -> Emu

宽(EMU)。
Source§

fn set_width(&mut self, emu: Emu)

设置宽。
Source§

fn height(&self) -> Emu

高(EMU)。
Source§

fn set_height(&mut self, emu: Emu)

设置高。
Source§

fn set_rotation(&mut self, _deg: f64)

设置旋转角度。

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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