pub struct DataModelPoint {
pub model_id: u32,
pub pt_type: Option<String>,
pub text: Option<String>,
pub raw_xml: String,
}Expand description
单个 SmartArt 节点(<dgm:pt>)。
每个 pt 都有唯一的 model_id,通过 <dgm:cxn> 建立父子/兄弟关系。
Fields§
§model_id: u32节点 ID(modelId 属性,必需,同一 dataModel 内唯一)。
pt_type: Option<String>节点类型(type 属性)。
OOXML 定义取值:doc(文档根)/ par(父节点)/ ch(子节点)/
sib(兄弟节点)/ prev(前驱)/ next(后继)。
text: Option<String>节点显示文本(从 <dgm:t>/<a:p>/<a:r>/<a:t> 提取的首个文本)。
若节点无文本(如 type="doc" 的虚拟根),此字段为 None。
raw_xml: String节点原始 XML(保留 byte-exact,用于 round-trip 兜底)。
Implementations§
Source§impl DataModelPoint
impl DataModelPoint
Sourcepub fn set_text(&mut self, new_text: impl Into<String>)
pub fn set_text(&mut self, new_text: impl Into<String>)
设置节点显示文本,同步更新 text 字段与 raw_xml 中的 <a:t> 内容。
§工作原理
- 在
raw_xml中查找<a:t>...</a:t>元素; - 若找到,替换其中的文本内容为
new_text(自动 XML 转义); - 若未找到(如
type="doc"虚拟根节点无<dgm:t>子元素),仅更新text字段,raw_xml保持不变(虚拟根通常不需要显示文本)。
§参数
new_text:新的节点文本内容。
§限制
- 仅替换第一个
<a:t>元素的内容(SmartArt 节点通常只有一个文本运行); - 若
raw_xml为空(用户新建的节点),调用本方法后还需要调用DataModel::to_xml的结构化重建分支才能生成完整 XML。
Sourcepub fn clear_text(&mut self)
pub fn clear_text(&mut self)
清除节点显示文本。
同步更新 text 字段为 None 与 raw_xml 中的 <a:t> 内容为空字符串。
若 raw_xml 中无 <a:t> 元素,仅更新 text 字段。
Trait Implementations§
Source§impl Clone for DataModelPoint
impl Clone for DataModelPoint
Source§fn clone(&self) -> DataModelPoint
fn clone(&self) -> DataModelPoint
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DataModelPoint
impl Debug for DataModelPoint
Source§impl Default for DataModelPoint
impl Default for DataModelPoint
Source§fn default() -> DataModelPoint
fn default() -> DataModelPoint
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DataModelPoint
impl RefUnwindSafe for DataModelPoint
impl Send for DataModelPoint
impl Sync for DataModelPoint
impl Unpin for DataModelPoint
impl UnsafeUnpin for DataModelPoint
impl UnwindSafe for DataModelPoint
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