Skip to main content

Sp

Struct Sp 

Source
pub struct Sp {
    pub id: u32,
    pub name: String,
    pub is_placeholder: bool,
    pub ph_idx: Option<u32>,
    pub ph_type: Option<String>,
    pub properties: ShapeProperties,
    pub style: Option<ShapeStyle>,
    pub text: TextBody,
    pub ext_lst: Option<ExtensionList>,
    pub c_nv_sp_pr_tx_box: bool,
    pub locks: Option<ShapeLocks>,
}
Expand description

<p:sp> 普通形状(如文本框、矩形、椭圆等)。

Fields§

§id: u32

形状 ID(同一 slide 内唯一)。

§name: String

形状名(仅显示用)。

§is_placeholder: bool

是否为占位符。

§ph_idx: Option<u32>

占位符 idx(placeholder idx,仅当 is_placeholder)。

§ph_type: Option<String>

占位符类型(title / body / …)。

完整取值见 PP_PLACEHOLDER_TYPE 枚举:

  • title / ctrTitle / subTitle
  • body / ftr / dt / sldNum / hdr
  • tbl / chart / pic / sldImg / media
  • obj / vertAlign 等等

is_placeholder=trueph_type=None 时,写 XML 时默认body 写出。

§properties: ShapeProperties

形状属性(xfrm / prstGeom / 填充 / 边框)。

§style: Option<ShapeStyle>

主题样式引用(p:style,可选)。

§text: TextBody

文本体(p:txBody)。

§ext_lst: Option<ExtensionList>

扩展列表(p:extLst),用于承载 PowerPoint 私有扩展。

§c_nv_sp_pr_tx_box: bool

标记该 sp 为纯文本框(对应 <p:cNvSpPr txBox="1"/>)。

python-pptx 中 shapes.add_textbox(...) 创建的就是带这个标志的 p:sp。 该标志让 PowerPoint 把它识别为“自由文本框“而非“自选图形 + 文本“,从而 走非自动布局(不套用母版占位符约束)。

§locks: Option<ShapeLocks>

形状锁定属性(<a:spLocks>,可选)。

None 表示不写出 <a:spLocks> 元素。 Some(ShapeLocks { .. })is_empty() == false 时写出。

Implementations§

Source§

impl Sp

Source

pub fn write_xml(&self, w: &mut XmlWriter)

写 XML。

按 OOXML CT_Shape 的子元素顺序:

<p:sp>
  <p:nvSpPr>...</p:nvSpPr>
  <p:spPr>...</p:spPr>            ← spPr 必填
  <p:style>...</p:style>          ← 可选:主题样式引用
  <p:txBody>...</p:txBody>        ← 可选:文本体
  <p:extLst>...</p:extLst>        ← 可选:扩展
</p:sp>

Trait Implementations§

Source§

impl Clone for Sp

Source§

fn clone(&self) -> Sp

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 Sp

Source§

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

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

impl Default for Sp

Source§

fn default() -> Sp

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

Auto Trait Implementations§

§

impl Freeze for Sp

§

impl RefUnwindSafe for Sp

§

impl Send for Sp

§

impl Sync for Sp

§

impl Unpin for Sp

§

impl UnsafeUnpin for Sp

§

impl UnwindSafe for Sp

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