pub struct CustomProperties { /* private fields */ }Expand description
自定义文档属性集合(/docProps/custom.xml)。
对标 python-pptx 中 Presentation.custom_properties(v1.0+)。
存储用户自定义的键值对,PowerPoint 在“文件 → 信息 → 属性 → 高级属性 → 自定义“中显示。
§序列化
to_opc_package 会在 custom_properties 非空时写出 /docProps/custom.xml,
并在 _rels/.rels 中添加 custom-properties 关系。
§示例
use pptx_rs::Presentation;
use pptx_rs::presentation::CustomPropertyValue;
let mut p = Presentation::new().unwrap();
p.custom_properties_mut().set("Project", CustomPropertyValue::Text("Demo".to_string()));
p.custom_properties_mut().set("Version", CustomPropertyValue::Int(42));
p.save("out.pptx").unwrap();Implementations§
Source§impl CustomProperties
impl CustomProperties
Sourcepub fn set(&mut self, name: impl Into<String>, value: CustomPropertyValue)
pub fn set(&mut self, name: impl Into<String>, value: CustomPropertyValue)
Sourcepub fn get(&self, name: &str) -> Option<&CustomPropertyValue>
pub fn get(&self, name: &str) -> Option<&CustomPropertyValue>
取指定名称的属性值。
Sourcepub fn remove(&mut self, name: &str) -> Option<CustomPropertyValue>
pub fn remove(&mut self, name: &str) -> Option<CustomPropertyValue>
移除指定名称的属性。
返回被移除的值(若存在)。
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &CustomPropertyValue)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &CustomPropertyValue)>
返回所有条目的迭代器。
Sourcepub fn to_xml(&self) -> String
pub fn to_xml(&self) -> String
序列化为 /docProps/custom.xml 的 XML 字符串。
§XML 结构
<Properties xmlns="...custom-properties" xmlns:vt="...docPropsVTypes">
<property fmtid="{D5CDD505-...}" pid="2" name="Key1">
<vt:lpwstr>Value1</vt:lpwstr>
</property>
...
</Properties>pid 从 2 开始(1 保留给 SummaryInformation)。
Trait Implementations§
Source§impl Clone for CustomProperties
impl Clone for CustomProperties
Source§fn clone(&self) -> CustomProperties
fn clone(&self) -> CustomProperties
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CustomProperties
impl Debug for CustomProperties
Source§impl Default for CustomProperties
impl Default for CustomProperties
Source§fn default() -> CustomProperties
fn default() -> CustomProperties
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CustomProperties
impl RefUnwindSafe for CustomProperties
impl Send for CustomProperties
impl Sync for CustomProperties
impl Unpin for CustomProperties
impl UnsafeUnpin for CustomProperties
impl UnwindSafe for CustomProperties
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more