Skip to main content

DataModelPoint

Struct DataModelPoint 

Source
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

Source

pub fn set_text(&mut self, new_text: impl Into<String>)

设置节点显示文本,同步更新 text 字段与 raw_xml 中的 <a:t> 内容。

§工作原理
  1. raw_xml 中查找 <a:t>...</a:t> 元素;
  2. 若找到,替换其中的文本内容为 new_text(自动 XML 转义);
  3. 若未找到(如 type="doc" 虚拟根节点无 <dgm:t> 子元素),仅更新 text 字段, raw_xml 保持不变(虚拟根通常不需要显示文本)。
§参数
  • new_text:新的节点文本内容。
§限制
  • 仅替换第一个 <a:t> 元素的内容(SmartArt 节点通常只有一个文本运行);
  • raw_xml 为空(用户新建的节点),调用本方法后还需要调用 DataModel::to_xml 的结构化重建分支才能生成完整 XML。
Source

pub fn clear_text(&mut self)

清除节点显示文本。

同步更新 text 字段为 Noneraw_xml 中的 <a:t> 内容为空字符串。 若 raw_xml 中无 <a:t> 元素,仅更新 text 字段。

Source

pub fn is_type(&self, type_str: &str) -> bool

按 model_id 查询节点是否为指定类型。

便捷方法:避免外部重复匹配 pt_type 字段。

Trait Implementations§

Source§

impl Clone for DataModelPoint

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataModelPoint

Source§

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

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

impl Default for DataModelPoint

Source§

fn default() -> DataModelPoint

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

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