Skip to main content

ShapeProperties

Struct ShapeProperties 

Source
pub struct ShapeProperties {
    pub xfrm: Transform,
    pub geometry: Option<Geometry>,
    pub fill: Fill,
    pub line: Option<Line>,
    pub effects: Option<EffectList>,
    pub scene3d: Option<Scene3d>,
    pub sp3d: Option<Sp3d>,
    pub rot_deg: Option<f64>,
}
Expand description

形状属性 <p:spPr>

Fields§

§xfrm: Transform

仿射变换(位置/尺寸/旋转/翻转)。

§geometry: Option<Geometry>

几何(预设或自定义)。None 默认为 Preset(Rectangle)

TODO-024:从 Option<PresetGeometry> 改为 Option<Geometry>, 支持自定义几何(<a:custGeom>)。

§fill: Fill

填充(实色/图片/无/继承)。

§line: Option<Line>

边框(<a:ln>)。None 表示不写出边框。

§effects: Option<EffectList>

效果列表(<a:effectLst>,可选)。

§scene3d: Option<Scene3d>

三维场景(<a:scene3d>,可选,TODO-050)。

定义相机与光照;与 sp3d 共同表达 3D 效果。

§sp3d: Option<Sp3d>

形状 3D 属性(<a:sp3d>,可选,TODO-050)。

定义形状本身的拉伸/棱台/材质。

§rot_deg: Option<f64>

旋转角度(度数,正向顺时针)。

Implementations§

Source§

impl ShapeProperties

Source

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

写 XML。tag 一般为 "p:spPr"

按 OOXML 规范,<p:spPr> 内部必须按以下顺序排列:

  1. <a:xfrm>(可选):位置/尺寸/旋转;
  2. <a:prstGeom> / <a:custGeom>:几何;
  3. 填充相关(<a:noFill> / <a:solidFill> / <a:gradFill> / <a:blipFill> / <a:pattFill>);
  4. <a:ln>:边框;
  5. 效果(<a:effectLst> 等);
  6. <a:scene3d> / <a:sp3d>:三维效果;
  7. <a:extLst>:扩展。

顺序错误会导致 PowerPoint 弹出“Invalid OOXML“对话框。

Source

pub fn write_xfrm_only(&self, w: &mut XmlWriter, tag: &str)

写 xfrm 元素(<p:xfrm><a:xfrm>...</a:xfrm></p:xfrm>)。

仅 pptx-rs 主 crate 的 oxml::shape::GraphicFrame 使用 —— OOXML 中 <p:graphicFrame> 的子元素顺序是:

<p:graphicFrame>
  <p:nvGraphicFramePr>...</p:nvGraphicFramePr>
  <p:xfrm>...</p:xfrm>          ← 本方法
  <a:graphic>...</a:graphic>
  <p:extLst>...</p:extLst>      ← 可选
</p:graphicFrame>

ShapeProperties::write_xml 的区别是:本方法输出 prstGeom / 填充 / 边框(这些是 <p:spPr> 的职责),只输出位置 / 尺寸变换。

tag 参数指定外层元素标签名(如 "p:xfrm" 用于 PPTX)。

Source

pub fn effects(&self) -> Option<&EffectList>

读取效果列表(<a:effectLst>)。None 表示未设置。

Source

pub fn effects_mut(&mut self) -> &mut EffectList

读取效果列表的可变引用。若未设置,自动初始化为空 EffectList

调用此方法后即使不设置任何效果,也会写出空 <a:effectLst/>(PowerPoint 兼容)。 若要避免写出空元素,请用 Self::clear_effects

Source

pub fn set_outer_shadow(&mut self, shadow: ShadowEffect)

设置外阴影(<a:outerShdw>)。覆盖既有外阴影,保留其他效果。

对标 python-pptx shape.shadow.inherit = False + shape.shadow.outerShadow

§参数
  • shadow:阴影配置(方向/距离/模糊半径/颜色)
Source

pub fn set_inner_shadow(&mut self, shadow: ShadowEffect)

设置内阴影(<a:innerShdw>)。覆盖既有内阴影,保留其他效果。

Source

pub fn set_glow(&mut self, glow: GlowEffect)

设置发光(<a:glow>)。覆盖既有发光,保留其他效果。

Source

pub fn set_soft_edge(&mut self, rad: i64)

设置柔化边缘(<a:softEdge>)。覆盖既有柔边,保留其他效果。

Source

pub fn set_reflection(&mut self, reflection: ReflectionEffect)

设置反射(<a:reflection>)。覆盖既有反射,保留其他效果。

Source

pub fn clear_outer_shadow(&mut self)

清除外阴影。

Source

pub fn clear_inner_shadow(&mut self)

清除内阴影。

Source

pub fn clear_glow(&mut self)

清除发光。

Source

pub fn clear_soft_edge(&mut self)

清除柔化边缘。

Source

pub fn clear_reflection(&mut self)

清除反射。

Source

pub fn clear_effects(&mut self)

清除所有效果(删除整个 <a:effectLst> 元素)。

Trait Implementations§

Source§

impl Clone for ShapeProperties

Source§

fn clone(&self) -> ShapeProperties

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 ShapeProperties

Source§

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

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

impl Default for ShapeProperties

Source§

fn default() -> ShapeProperties

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