Skip to main content

OleObjectShape

Struct OleObjectShape 

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

高阶 OLE 对象形状(承载 <p:graphicFrame> + <p:oleObj r:id="..."/> 引用)。

通过 OleObjectShape::ole / OleObjectShape::ole_mut 访问 OLE 数据模型; 通过 Shape trait 方法(left / top / width / height)调整位置与尺寸。

§内部不变量

frame.graphic 始终保持为 Graphic::OleObject(_)。本类型所有便捷方法 (rid / set_rid / image_rid / prog_id / name / show_as_icon) 在不变量被破坏时静默忽略或返回默认值,绝不 panic—— 这与库整体“零 panic“约定一致(参见 .trae/rules/project_rules.md §5)。

Implementations§

Source§

impl OleObjectShape

Source

pub fn new(prog_id: impl Into<String>, name: impl Into<String>) -> Self

构造一个指定 progId 与显示名的 OLE 对象形状(rid/image_rid 留空,由 presentation 层填充)。

§参数
  • prog_id:OLE 程序标识符(如 "Excel.Sheet.12" / "Package")。
  • name:显示名(如 "Worksheet")。
Source

pub fn from_frame(frame: OxmlFrame) -> Self

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

Source

pub fn ole(&self) -> Option<&OxmlOleObject>

取内部 oxml OleObject 引用。

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

Source

pub fn ole_mut(&mut self) -> Option<&mut OxmlOleObject>

取内部 oxml OleObject 可变引用。

Source

pub fn rid(&self) -> &str

当前关联的 OLE 关系 id(指向 /ppt/embeddings/oleObjectN.bin)。

新建时为空字符串;由 Presentation::to_opc_package 在写出 ole part 时填充。 不变量被破坏时返回空字符串。

Source

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

设置 OLE 关系 id(一般由 presentation 层自动调用,用户无需直接设置)。 不变量被破坏时静默忽略。

Source

pub fn image_rid(&self) -> &str

当前关联的图标图片关系 id(指向 /ppt/media/imageN.{ext})。

空字符串表示无图标图片,PowerPoint 会用默认图标显示。 不变量被破坏时返回空字符串。

Source

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

设置图标图片关系 id。不变量被破坏时静默忽略。

Source

pub fn prog_id(&self) -> &str

OLE 程序标识符(如 "Excel.Sheet.12")。

不变量被破坏时返回 "Package" 作为兜底。

Source

pub fn set_prog_id(&mut self, prog_id: impl Into<String>)

修改 OLE 程序标识符。不变量被破坏时静默忽略。

Source

pub fn ole_name(&self) -> &str

显示名(如 "Worksheet" / "Document")。

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

Source

pub fn set_ole_name(&mut self, name: impl Into<String>)

修改显示名。不变量被破坏时静默忽略。

Source

pub fn show_as_icon(&self) -> bool

是否以图标形式显示。

不变量被破坏时返回 true(与默认值一致)。

Source

pub fn set_show_as_icon(&mut self, show: bool)

设置是否以图标形式显示。不变量被破坏时静默忽略。

Source

pub fn set_icon_size(&mut self, width: Emu, height: Emu)

设置图标显示尺寸(EMU)。 不变量被破坏时静默忽略。

Source

pub fn set_pic_id_name(&mut self, id: u32, name: impl Into<String>)

设置图标 Pic 形状的 id 与 name(用于 <p:oleObj spid="..."><p:cNvPr name="...">)。 不变量被破坏时静默忽略。

Source

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

将本 OLE 对象形状标记为占位符。

写出 XML 时会在 <p:nvGraphicFramePr>/<p:nvPr> 内插入 <p:ph type="obj" idx="..."/>,使 PowerPoint 把该 graphicFrame 识别为对象占位符的填充实例。

§参数
  • ph_idx:占位符索引(对应 <p:ph idx="..."/>)。
  • ph_type:占位符类型字符串(如 "obj"),None 时省略 type 属性。
Source

pub fn clear_placeholder(&mut self)

清除占位符标记,使本 OLE 对象形状变为普通 graphicFrame。

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 OleObjectShape

Source§

fn clone(&self) -> OleObjectShape

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 OleObjectShape

Source§

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

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

impl Default for OleObjectShape

Source§

fn default() -> OleObjectShape

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

impl Shape for OleObjectShape

Source§

fn rotation(&self) -> f64

OLE 对象不支持旋转(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