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
impl SmartArtShape
Sourcepub fn new() -> Self
pub fn new() -> Self
构造一个 SmartArt 形状(4 个关系 id 留空,由 presentation 层填充)。
内部调用 SmartArtRef::from_rids 构造初始 raw_xml。
后续通过 SmartArtShape::set_dm_rid 等 setter 更新任一 rid 时,
raw_xml 会整体重新生成(4 个 rid 同步刷新)。
Sourcepub fn from_rids(dm_rid: &str, lo_rid: &str, qs_rid: &str, cs_rid: &str) -> Self
pub fn from_rids(dm_rid: &str, lo_rid: &str, qs_rid: &str, cs_rid: &str) -> Self
从 4 个关系 id 构造 SmartArt 形状(直接初始化路径)。
Sourcepub fn from_frame(frame: OxmlFrame) -> Self
pub fn from_frame(frame: OxmlFrame) -> Self
从 oxml Frame 构造(通常用于读取已有 SmartArt 时)。
Sourcepub fn smart_art(&self) -> Option<&SmartArtRef>
pub fn smart_art(&self) -> Option<&SmartArtRef>
取内部 oxml SmartArtRef 引用。
返回 None 仅在内部不变量被外部错误破坏时(frame.graphic 不是 SmartArt 变体)。
Sourcepub fn smart_art_mut(&mut self) -> Option<&mut SmartArtRef>
pub fn smart_art_mut(&mut self) -> Option<&mut SmartArtRef>
取内部 oxml SmartArtRef 可变引用。
Sourcepub fn set_dm_rid(&mut self, rid: impl Into<String>)
pub fn set_dm_rid(&mut self, rid: impl Into<String>)
设置数据模型关系 id(r:dm)。
重要:任一 rid 变更都会触发 raw_xml 整体重建(4 个 rid 同步刷新),
因为 raw_xml 内的 <dgm:relIds> 元素同时承载 4 个属性。
不变量被破坏时静默忽略。
Sourcepub fn set_lo_rid(&mut self, rid: impl Into<String>)
pub fn set_lo_rid(&mut self, rid: impl Into<String>)
设置布局定义关系 id(r:lo)。语义同 Self::set_dm_rid。
Sourcepub fn set_qs_rid(&mut self, rid: impl Into<String>)
pub fn set_qs_rid(&mut self, rid: impl Into<String>)
设置样式关系 id(r:qs)。语义同 Self::set_dm_rid。
Sourcepub fn set_cs_rid(&mut self, rid: impl Into<String>)
pub fn set_cs_rid(&mut self, rid: impl Into<String>)
设置颜色关系 id(r:cs)。语义同 Self::set_dm_rid。
Sourcepub 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>,
)
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)。
Sourcepub fn set_placeholder(&mut self, ph_idx: u32, ph_type: Option<&str>)
pub fn set_placeholder(&mut self, ph_idx: u32, ph_type: Option<&str>)
将本 SmartArt 形状标记为占位符。
写出 XML 时会在 <p:nvGraphicFramePr>/<p:nvPr> 内插入
<p:ph type="..." idx="..."/>。
Sourcepub fn clear_placeholder(&mut self)
pub fn clear_placeholder(&mut self)
清除占位符标记。
Sourcepub fn is_placeholder(&self) -> bool
pub fn is_placeholder(&self) -> bool
是否被标记为占位符。
Trait Implementations§
Source§impl Clone for SmartArtShape
impl Clone for SmartArtShape
Source§fn clone(&self) -> SmartArtShape
fn clone(&self) -> SmartArtShape
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SmartArtShape
impl Debug for SmartArtShape
Source§impl Default for SmartArtShape
impl Default for SmartArtShape
Source§impl Shape for SmartArtShape
impl Shape for SmartArtShape
Source§fn rotation(&self) -> f64
fn rotation(&self) -> f64
SmartArt 不支持旋转(OOXML 规范)。调用 Shape::set_rotation 会被忽略。