Skip to main content

Module shape

Module shape 

Source
Expand description

高阶形状:AutoShape / Picture / Group / Connector / Table / TextBox / Freeform。

对应 python-pptx 中 pptx.shapes.* 各类。

设计:所有形状都借用所属 Slide 上的 spTree 元素。本 crate 在第一版 采用了“对 oxml 类型做轻包装 + 直接修改“的策略——即一个 AutoShape 实质 上持有一个 Rc<RefCell<Sp>> 句柄;高阶方法直接 mutate 内部 oxml 模型。

§模块构成

  • base:所有形状共享的 trait Shape
  • autoshape:自选图形(矩形/椭圆/箭头/…);
  • textbox:纯文本框;
  • picture:图片;
  • group:组合 + 递归子形状;
  • connector:连接器(直线/折线/曲线);
  • table:高阶表格(封装 <a:tbl>);
  • chartshape:高阶图表(封装 <p:graphicFrame> + <c:chart> 引用);
  • oleshape:高阶 OLE 对象(封装 <p:graphicFrame> + <p:oleObj> 引用);
  • freeform:手绘自由形(custGeom 极简版)。

§在三层架构中的位置

本模块是 shape::* —— oxml::shape 的“高阶薄包装“。它不引入新数据, 全部为 pub(crate) sp: OxmlSp 等字段的引用/可变访问。

§与 python-pptx 的对应

Re-exports§

pub use autoshape::AutoShape;
pub use base::Shape;
pub use chartshape::ChartShape;
pub use connector::Connector;
pub use freeform::Freeform;
pub use freeform::FreeformBuilder;
pub use freeform::Point;
pub use group::Group;
pub use group::GroupChild;
pub use oleshape::OleObjectShape;
pub use picture::Picture;
pub use smartartshape::SmartArtShape;
pub use table::BorderSide;
pub use table::TableShape;
pub use textbox::TextBox;
pub use crate::oxml::simpletypes::Alignment;
pub use crate::oxml::simpletypes::Cap;
pub use crate::oxml::simpletypes::MsoAnchor;
pub use crate::oxml::simpletypes::MsoAutoSize;
pub use crate::oxml::simpletypes::MsoConnectorType;
pub use crate::oxml::simpletypes::MsoShapeType;
pub use crate::oxml::simpletypes::PresetGeometry;
pub use crate::oxml::simpletypes::TextDirection;
pub use crate::oxml::simpletypes::TextWrapping;
pub use crate::oxml::simpletypes::Underline;

Modules§

autoshape
AutoShape:自选图形(矩形、椭圆、箭头、…)。
base
Shape:所有形状的“基类“包装。
chartshape
ChartShape:高阶图表。
connector
Connector:连接器(直线/折线/曲线)。
freeform
Freeform / FreeformBuilder:手绘自由形(<a:custGeom>)。
group
Group:组合形状。
oleshape
OleObjectShape:高阶 OLE 对象形状(TODO-043)。
picture
Picture:图片(<p:pic>)。
smartartshape
SmartArtShape:高阶 SmartArt 形状(TODO-037 创建 API)。
table
Table:高阶表格。
textbox
TextBox:纯文本框(<p:sp> + prstGeom="rect" + txBody)。

Structs§

PlaceholderShape
占位符形状(暂时借用 AutoShape 表示 + 携带 ph 信息)。

Enums§

ShapeKind
统一的形状枚举(Slide.shapes().get(i) 拿到的是这个)。

Functions§

name_of
从 oxml SlideShape 中取名字(不构造 ShapeKind)。
wrap
把 oxml SlideShape 转换为高阶 ShapeKind