pub struct AutoShape { /* private fields */ }Expand description
自选形状(带或不带文本都可以)。
Implementations§
Source§impl AutoShape
impl AutoShape
Sourcepub fn new(name: impl Into<String>, geometry: PresetGeometry) -> Self
pub fn new(name: impl Into<String>, geometry: PresetGeometry) -> Self
构造一个指定几何形状(不设置位置/尺寸,由调用方决定)。
Sourcepub fn text_frame(&self) -> &TextBody
pub fn text_frame(&self) -> &TextBody
文本体不可变引用。
Sourcepub fn text_frame_mut(&mut self) -> &mut TextBody
pub fn text_frame_mut(&mut self) -> &mut TextBody
文本体可变引用。
Sourcepub fn properties(&self) -> &ShapeProperties
pub fn properties(&self) -> &ShapeProperties
形状属性不可变引用。
Sourcepub fn properties_mut(&mut self) -> &mut ShapeProperties
pub fn properties_mut(&mut self) -> &mut ShapeProperties
形状属性可变引用。
Sourcepub fn set_fill_color(&mut self, c: impl Into<Color>)
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)。
Sourcepub fn set_stroke_color(&mut self, c: impl Into<Color>)
pub fn set_stroke_color(&mut self, c: impl Into<Color>)
便捷方法:设描边颜色。
Sourcepub fn set_stroke_width(&mut self, w: Emu)
pub fn set_stroke_width(&mut self, w: Emu)
便捷方法:设描边宽度(EMU)。通常 Pt(1.0).emu()。
Sourcepub fn set_outer_shadow(&mut self, shadow: ShadowEffect)
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,
});Sourcepub fn set_inner_shadow(&mut self, shadow: ShadowEffect)
pub fn set_inner_shadow(&mut self, shadow: ShadowEffect)
设置内阴影(<a:innerShdw>)。
Sourcepub fn set_glow(&mut self, glow: GlowEffect)
pub fn set_glow(&mut self, glow: GlowEffect)
设置发光(<a:glow>)。
Sourcepub fn set_soft_edge(&mut self, rad: i64)
pub fn set_soft_edge(&mut self, rad: i64)
设置柔化边缘(<a:softEdge>)。
Sourcepub fn set_reflection(&mut self, reflection: ReflectionEffect)
pub fn set_reflection(&mut self, reflection: ReflectionEffect)
设置反射(<a:reflection>)。
Sourcepub fn clear_effects(&mut self)
pub fn clear_effects(&mut self)
清除所有效果(删除整个 <a:effectLst> 元素)。
Sourcepub fn set_3d_rotation(&mut self, lat_deg: f64, lon_deg: f64, rev_deg: f64)
pub fn set_3d_rotation(&mut self, lat_deg: f64, lon_deg: f64, rev_deg: f64)
Sourcepub fn set_3d_extrusion(&mut self, height_emu: i32, color: Option<Color>)
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>)
Sourcepub fn set_3d_bevel(
&mut self,
top_w: i32,
top_h: i32,
bottom_w: i32,
bottom_h: i32,
)
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)
Sourcepub fn set_3d_material(&mut self, material: MaterialPreset)
pub fn set_3d_material(&mut self, material: MaterialPreset)
设置三维材质预设(<a:sp3d prstMaterial="...">)。
Sourcepub fn scene_3d_mut(&mut self) -> &mut Option<Scene3d>
pub fn scene_3d_mut(&mut self) -> &mut Option<Scene3d>
取三维场景可变引用(可直接操作 camera / lightRig)。
Sourcepub fn locks(&self) -> Option<&ShapeLocks>
pub fn locks(&self) -> Option<&ShapeLocks>
读取形状锁定(<a:spLocks>)。None 表示未设置。
Sourcepub fn locks_mut(&mut self) -> &mut ShapeLocks
pub fn locks_mut(&mut self) -> &mut ShapeLocks
读取形状锁定的可变引用。若未设置,自动初始化为空 ShapeLocks(无任何锁定)。
Sourcepub fn lock_select(&mut self, locked: bool)
pub fn lock_select(&mut self, locked: bool)
便捷锁定:禁止选中(noSelect="1")。
Sourcepub fn lock_resize(&mut self, locked: bool)
pub fn lock_resize(&mut self, locked: bool)
便捷锁定:禁止缩放(noResize="1")。
Sourcepub fn lock_rotate(&mut self, locked: bool)
pub fn lock_rotate(&mut self, locked: bool)
便捷锁定:禁止旋转(noRot="1")。
Sourcepub fn lock_group(&mut self, locked: bool)
pub fn lock_group(&mut self, locked: bool)
便捷锁定:禁止组合(noGrp="1")。
Sourcepub fn clear_locks(&mut self)
pub fn clear_locks(&mut self)
清除所有锁定。
Sourcepub fn set_lock(&mut self, lock_type: LockType, locked: bool)
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:锁定类型枚举;locked:true启用,false解除。
§示例
sh.set_lock(LockType::Select, true);
sh.set_lock(LockType::ChangeAspect, true);
assert!(sh.locks().unwrap().get_lock(LockType::Select));Sourcepub fn style(&self) -> Option<&ShapeStyle>
pub fn style(&self) -> Option<&ShapeStyle>
读取主题样式引用(<p:style>)。None 表示未设置。
Sourcepub fn set_style(&mut self, style: ShapeStyle)
pub fn set_style(&mut self, style: ShapeStyle)
设置主题样式引用(<p:style>)。
对标 python-pptx shape.style 的底层元素引用方式。
§参数
style:主题样式(line_ref / fill_ref / effect_ref / font_ref)
Sourcepub fn clear_style(&mut self)
pub fn clear_style(&mut self)
清除主题样式引用。
Sourcepub fn set_text(&mut self, t: impl Into<String>)
pub fn set_text(&mut self, t: impl Into<String>)
便捷方法:设文本(单段单 Run)。多段请用 text_frame_mut().add_paragraph。
Sourcepub fn adjustments(&self) -> &[AdjustmentValue]
pub fn adjustments(&self) -> &[AdjustmentValue]
取调整值列表(不可变)。
对标 python-pptx shape.adjustments。
Sourcepub fn adjustments_mut(&mut self) -> &mut Vec<AdjustmentValue>
pub fn adjustments_mut(&mut self) -> &mut Vec<AdjustmentValue>
取调整值列表(可变)。
如果几何不是 Preset 变体,返回空 Vec 的可变引用(实际是临时变量)。
调用方应确保几何是 Preset 类型后再调用。
Sourcepub fn set_adjustment(&mut self, idx: usize, value: f64)
pub fn set_adjustment(&mut self, idx: usize, value: f64)
Sourcepub fn adjustment_value(&self, idx: usize) -> Option<f64>
pub fn adjustment_value(&self, idx: usize) -> Option<f64>
取指定索引的调整值归一化值(0.0-1.0)。
对标 python-pptx shape.adjustments[0]。