Skip to main content

AutoShape

Struct AutoShape 

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

自选形状(带或不带文本都可以)。

Implementations§

Source§

impl AutoShape

Source

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

构造一个指定几何形状(不设置位置/尺寸,由调用方决定)。

Source

pub fn from_sp(sp: OxmlSp) -> Self

从 oxml OxmlSp 构造包装。

Source

pub fn sp(&self) -> &OxmlSp

取出内部 oxml 引用。

Source

pub fn sp_mut(&mut self) -> &mut OxmlSp

取出内部 oxml 可变引用。

Source

pub fn text_frame(&self) -> &TextBody

文本体不可变引用。

Source

pub fn text_frame_mut(&mut self) -> &mut TextBody

文本体可变引用。

Source

pub fn properties(&self) -> &ShapeProperties

形状属性不可变引用。

Source

pub fn properties_mut(&mut self) -> &mut ShapeProperties

形状属性可变引用。

Source

pub fn set_fill(&mut self, fill: Fill)

设填充。

Source

pub fn set_fill_color(&mut self, c: impl Into<Color>)

便捷方法:设填充为指定 RGB 颜色。

对应 python-pptx 中 shape.fill.solid(); shape.fill.fore_color.rgb = RGBColor(r, g, b)

Source

pub fn set_stroke_color(&mut self, c: impl Into<Color>)

便捷方法:设描边颜色。

Source

pub fn set_stroke_width(&mut self, w: Emu)

便捷方法:设描边宽度(EMU)。通常 Pt(1.0).emu()

Source

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

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

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

§示例
sh.set_outer_shadow(ShadowEffect {
    dir: 2_700_000,        // 向下(1/60000 度)
    dist: 38_100,          // 3pt(EMU)
    blur_rad: 38_100,
    color: Color::RGB(RGBColor(0x80, 0x80, 0x80)),
    rot_with_shape: None,
});
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_effects(&mut self)

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

Source

pub fn set_3d_rotation(&mut self, lat_deg: f64, lon_deg: f64, rev_deg: f64)

设置三维旋转(<a:rot lat="..." lon="..." rev="..."/>)。

三个角度均以为单位(用户直觉),内部转换为 1/60000 度(OOXML ST_Angle)。 若 scene3d 不存在则自动创建默认 Scene3d(正交前视图 + 平衡光)。

§参数
  • lat_deg:纬度(-90°~90°,正值抬头)
  • lon_deg:经度(0°~360°,正值右转)
  • rev_deg:滚转(沿视线轴的旋转,正值顺时针)
§示例
sh.set_3d_rotation(30.0, 45.0, 0.0); // 抬头 30° + 右转 45°
Source

pub fn set_3d_extrusion(&mut self, height_emu: i32, color: Option<Color>)

设置三维拉伸高度与可选拉伸颜色(<a:sp3d extrusionH="..."> + <a:extrusionClr>)。

§参数
  • height_emu:拉伸高度(EMU,38100 = 3pt)
  • color:拉伸颜色(None 表示不写出 <a:extrusionClr>
Source

pub fn set_3d_bevel( &mut self, top_w: i32, top_h: i32, bottom_w: i32, bottom_h: i32, )

设置三维棱台(<a:bevelT> + <a:bevelB>)。

§参数
  • top_w / top_h:顶部棱台的宽高(EMU,63500 = 5pt)
  • bottom_w / bottom_h:底部棱台的宽高(EMU)
Source

pub fn set_3d_material(&mut self, material: MaterialPreset)

设置三维材质预设(<a:sp3d prstMaterial="...">)。

Source

pub fn clear_3d(&mut self)

清除所有三维效果(删除 scene3d + sp3d)。

Source

pub fn scene_3d(&self) -> Option<&Scene3d>

取三维场景引用(camera + lightRig)。None 表示未设置 3D 场景。

Source

pub fn scene_3d_mut(&mut self) -> &mut Option<Scene3d>

取三维场景可变引用(可直接操作 camera / lightRig)。

Source

pub fn sp_3d(&self) -> Option<&Sp3d>

取形状三维属性引用(拉伸/棱台/材质)。

Source

pub fn sp_3d_mut(&mut self) -> &mut Option<Sp3d>

取形状三维属性可变引用。

Source

pub fn locks(&self) -> Option<&ShapeLocks>

读取形状锁定(<a:spLocks>)。None 表示未设置。

Source

pub fn locks_mut(&mut self) -> &mut ShapeLocks

读取形状锁定的可变引用。若未设置,自动初始化为空 ShapeLocks(无任何锁定)。

Source

pub fn lock_select(&mut self, locked: bool)

便捷锁定:禁止选中(noSelect="1")。

Source

pub fn lock_move(&mut self, locked: bool)

便捷锁定:禁止移动(noMove="1")。

Source

pub fn lock_resize(&mut self, locked: bool)

便捷锁定:禁止缩放(noResize="1")。

Source

pub fn lock_rotate(&mut self, locked: bool)

便捷锁定:禁止旋转(noRot="1")。

Source

pub fn lock_group(&mut self, locked: bool)

便捷锁定:禁止组合(noGrp="1")。

Source

pub fn clear_locks(&mut self)

清除所有锁定。

Source

pub fn set_lock(&mut self, lock_type: LockType, locked: bool)

统一锁定入口:按 crate::oxml::shape::LockType 设置指定锁定(TODO-027 高阶 API)。

对标 python-pptx 风格 shape.set_lock(MSO_SHAPE_LOCK_TYPE.Select, True)。 比 lock_select / lock_move 等具名方法更通用,可覆盖所有 12 种锁定类型。

§参数
  • lock_type:锁定类型枚举;
  • lockedtrue 启用,false 解除。
§示例
sh.set_lock(LockType::Select, true);
sh.set_lock(LockType::ChangeAspect, true);
assert!(sh.locks().unwrap().get_lock(LockType::Select));
Source

pub fn style(&self) -> Option<&ShapeStyle>

读取主题样式引用(<p:style>)。None 表示未设置。

Source

pub fn set_style(&mut self, style: ShapeStyle)

设置主题样式引用(<p:style>)。

对标 python-pptx shape.style 的底层元素引用方式。

§参数
  • style:主题样式(line_ref / fill_ref / effect_ref / font_ref)
Source

pub fn clear_style(&mut self)

清除主题样式引用。

Source

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

便捷方法:设文本(单段单 Run)。多段请用 text_frame_mut().add_paragraph

Source

pub fn text(&self) -> String

文本快捷访问:返回首段首 Run 的文本(多段时只反映首段)。

Source

pub fn adjustments(&self) -> &[AdjustmentValue]

取调整值列表(不可变)。

对标 python-pptx shape.adjustments

Source

pub fn adjustments_mut(&mut self) -> &mut Vec<AdjustmentValue>

取调整值列表(可变)。

如果几何不是 Preset 变体,返回空 Vec 的可变引用(实际是临时变量)。 调用方应确保几何是 Preset 类型后再调用。

Source

pub fn set_adjustment(&mut self, idx: usize, value: f64)

设置指定索引的调整值(归一化 0.0-1.0)。

对标 python-pptx shape.adjustments[0] = 0.15

§参数
  • idx:调整值索引(0-based);
  • value:归一化值(0.0-1.0)。
§行为
  • idx 超出现有列表长度,自动追加新条目;
  • 新条目的 name 默认为 "adj" (首个)或 "adjN"(后续)。
Source

pub fn adjustment_value(&self, idx: usize) -> Option<f64>

取指定索引的调整值归一化值(0.0-1.0)。

对标 python-pptx shape.adjustments[0]

Trait Implementations§

Source§

impl Clone for AutoShape

Source§

fn clone(&self) -> AutoShape

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 AutoShape

Source§

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

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

impl Default for AutoShape

Source§

fn default() -> AutoShape

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

impl Shape for AutoShape

Source§

fn rotation(&self) -> f64

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

Source§

fn set_rotation(&mut self, deg: f64)

设置旋转角度。OOXML 内部单位是“60000 分之一度“, 本方法在读写时自动转换。

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)

设置高。

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