Skip to main content

pptx_rs/oxml/
notesmaster.rs

1//! 备注母版 `<p:notesMaster>` 简化模型(TODO-045)。
2//!
3//! 备注母版是"主-版-页"三层中的备注页对应母版——所有 notesSlide
4//! 默认继承它的形状与样式。对应 python-pptx 中 `NotesMaster` / `NotesMasterPart`。
5//!
6//! # 与 python-pptx 的对应
7//!
8//! - `pptx.parts.notesmaster.NotesMasterPart` ←→ 本模块 [`NotesMaster`] 的 OPC 宿主;
9//! - `pptx.NotesMaster` ←→ [`crate::notes_masters::NotesMasterRef`] 高阶句柄。
10//!
11//! # 当前实现范围
12//!
13//! 本模块是**极简只读模型**,仅承载解析出的 shapes 列表 + partname/rid 元数据。
14//! 完整的 `to_xml` 写路径未实现(写场景由 python-pptx 也较少触达)。
15//!
16//! # OOXML 结构(参考)
17//!
18//! ```text
19//! <p:notesMaster>
20//!   <p:cSld>
21//!     <p:spTree>...</p:spTree>          形状树(含占位符:日期/页码/正文等)
22//!   </p:cSld>
23//!   <p:clrMap .../>                      颜色映射
24//!   <p:notesStyle>...</p:notesStyle>     备注文本样式
25//! </p:notesMaster>
26//! ```
27
28use crate::oxml::shape::Sp;
29use crate::oxml::slide::SlideBackground;
30
31/// `<p:notesMaster>` 的内存模型(极简版)。
32///
33/// 仅承载 `cSld/spTree` 内的形状列表 + 可选背景,便于读取路径还原
34/// 已有 .pptx 的备注母版内容。写路径(`to_xml`)暂未实现。
35#[derive(Clone, Debug, Default)]
36pub struct NotesMaster {
37    /// 备注母版中的形状列表(`<p:cSld>/<p:spTree>` 内的 `<p:sp>`)。
38    pub shapes: Vec<Sp>,
39    /// 备注母版背景(`<p:bg>`,可选)。`None` 表示使用默认背景。
40    pub background: Option<SlideBackground>,
41}
42
43impl NotesMaster {
44    /// 创建一个空的备注母版。
45    pub fn new() -> Self {
46        Self::default()
47    }
48
49    /// 形状数量。
50    pub fn len(&self) -> usize {
51        self.shapes.len()
52    }
53
54    /// 是否无形状。
55    pub fn is_empty(&self) -> bool {
56        self.shapes.is_empty()
57    }
58}