Skip to main content

excelize_rs/xml/
metadata.rs

1//! Metadata and rich value parts (`xl/metadata.xml`, `xl/richData/`).
2//!
3//! Ported from Go `xmlMetaData.go`.
4
5use serde::{Deserialize, Serialize};
6
7use super::common::XlsxInnerXml;
8
9/// Directly maps the metadata element. A cell in a spreadsheet application can
10/// have metadata associated with it. Metadata is just a set of additional
11/// properties about the particular cell, and this metadata is stored in the
12/// metadata xml part. There are two types of metadata: cell metadata and value
13/// metadata.
14#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
15#[serde(rename = "metadata")]
16pub struct XlsxMetadata {
17    #[serde(rename = "metadataTypes", default, skip_serializing_if = "Option::is_none")]
18    pub metadata_types: Option<XlsxInnerXml>,
19    #[serde(rename = "metadataStrings", default, skip_serializing_if = "Option::is_none")]
20    pub metadata_strings: Option<XlsxInnerXml>,
21    #[serde(rename = "mdxMetadata", default, skip_serializing_if = "Option::is_none")]
22    pub mdx_metadata: Option<XlsxInnerXml>,
23    #[serde(rename = "futureMetadata", default)]
24    pub future_metadata: Vec<XlsxFutureMetadata>,
25    #[serde(rename = "cellMetadata", default, skip_serializing_if = "Option::is_none")]
26    pub cell_metadata: Option<XlsxMetadataBlocks>,
27    #[serde(rename = "valueMetadata", default, skip_serializing_if = "Option::is_none")]
28    pub value_metadata: Option<XlsxMetadataBlocks>,
29    #[serde(rename = "extLst", default, skip_serializing_if = "Option::is_none")]
30    pub ext_lst: Option<XlsxInnerXml>,
31}
32
33/// Directly maps the futureMetadata element. This element represents future
34/// metadata information.
35#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
36pub struct XlsxFutureMetadata {
37    #[serde(rename = "bk", default)]
38    pub bk: Vec<XlsxFutureMetadataBlock>,
39    #[serde(rename = "extLst", default, skip_serializing_if = "Option::is_none")]
40    pub ext_lst: Option<XlsxInnerXml>,
41}
42
43/// Directly maps the bk element. This element represents a block of future
44/// metadata information. This is a location for storing feature extension
45/// information.
46#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
47pub struct XlsxFutureMetadataBlock {
48    #[serde(rename = "extLst", default, skip_serializing_if = "Option::is_none")]
49    pub ext_lst: Option<XlsxInnerXml>,
50}
51
52/// Directly maps the metadata element. This element represents cell metadata
53/// information. Cell metadata is information metadata about a specific cell,
54/// and it stays tied to that cell position.
55#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
56pub struct XlsxMetadataBlocks {
57    #[serde(rename = "@count", default, skip_serializing_if = "Option::is_none")]
58    pub count: Option<i64>,
59    #[serde(rename = "bk", default)]
60    pub bk: Vec<XlsxMetadataBlock>,
61}
62
63/// Directly maps the bk element. This element represents a block of metadata
64/// records.
65#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
66pub struct XlsxMetadataBlock {
67    #[serde(rename = "rc", default)]
68    pub rc: Vec<XlsxMetadataRecord>,
69}
70
71/// Directly maps the rc element. This element represents a reference to a
72/// specific metadata record.
73#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
74pub struct XlsxMetadataRecord {
75    #[serde(rename = "@t")]
76    pub t: i64,
77    #[serde(rename = "@v")]
78    pub v: i64,
79}
80
81/// Directly maps the rvData element that specifies rich value data.
82#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
83#[serde(rename = "rvData")]
84pub struct XlsxRichValueData {
85    #[serde(rename = "@count", default, skip_serializing_if = "Option::is_none")]
86    pub count: Option<i64>,
87    #[serde(rename = "rv", default)]
88    pub rv: Vec<XlsxRichValue>,
89    #[serde(rename = "extLst", default, skip_serializing_if = "Option::is_none")]
90    pub ext_lst: Option<XlsxInnerXml>,
91}
92
93/// Directly maps the rv element that specifies rich value data information for
94/// a single rich value.
95#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
96pub struct XlsxRichValue {
97    #[serde(rename = "@s")]
98    pub s: i64,
99    #[serde(rename = "v", default)]
100    pub v: Vec<String>,
101    #[serde(rename = "fb", default, skip_serializing_if = "Option::is_none")]
102    pub fb: Option<XlsxInnerXml>,
103}
104
105/// Directly maps the richValueRels element. This element specifies a list of
106/// rich value relationships.
107#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
108#[serde(rename = "richValueRels")]
109pub struct XlsxRichValueRels {
110    #[serde(rename = "rel", default)]
111    pub rels: Vec<XlsxRichValueRelRelationship>,
112    #[serde(rename = "extLst", default, skip_serializing_if = "Option::is_none")]
113    pub ext_lst: Option<XlsxInnerXml>,
114}
115
116/// Directly maps the rel element. This element specifies a relationship for a
117/// rich value property.
118#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
119pub struct XlsxRichValueRelRelationship {
120    #[serde(rename = "@id")]
121    pub id: String,
122}
123
124/// Directly maps the rvStructures element. This element specifies rich value
125/// structures, which contain lists of rich value keys and the data types for
126/// the corresponding rich value data.
127#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
128#[serde(rename = "rvStructures")]
129pub struct XlsxRichValueStructures {
130    #[serde(rename = "@count", default, skip_serializing_if = "Option::is_none")]
131    pub count: Option<i64>,
132    #[serde(rename = "s", default)]
133    pub s: Vec<XlsxRichValueStructure>,
134    #[serde(rename = "extLst", default, skip_serializing_if = "Option::is_none")]
135    pub ext_lst: Option<XlsxInnerXml>,
136}
137
138/// Directly maps the s element. This element specifies the list of rich value
139/// structures.
140#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
141pub struct XlsxRichValueStructure {
142    #[serde(rename = "@t")]
143    pub t: String,
144    #[serde(rename = "k", default)]
145    pub k: Vec<XlsxRichValueKey>,
146}
147
148/// Directly maps the k element. This element specifies the rich value key.
149#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
150pub struct XlsxRichValueKey {
151    #[serde(rename = "@n")]
152    pub n: String,
153    #[serde(rename = "@t", default, skip_serializing_if = "Option::is_none")]
154    pub t: Option<String>,
155}
156
157/// Directly maps the webImagesSrd element. This element specifies a list of
158/// sets of properties associated with web image rich values.
159#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
160#[serde(rename = "webImagesSrd")]
161pub struct XlsxWebImagesSupportingRichData {
162    #[serde(rename = "webImageSrd", default)]
163    pub web_image_srd: Vec<XlsxWebImageSupportingRichData>,
164    #[serde(rename = "extLst", default, skip_serializing_if = "Option::is_none")]
165    pub ext_lst: Option<XlsxInnerXml>,
166}
167
168/// Directly maps the webImageSrd element. This element specifies a set of
169/// properties for a web image rich value.
170#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
171pub struct XlsxWebImageSupportingRichData {
172    #[serde(rename = "address", default)]
173    pub address: XlsxExternalReference,
174    #[serde(rename = "moreImagesAddress", default)]
175    pub more_images_address: XlsxExternalReference,
176    #[serde(rename = "blip", default)]
177    pub blip: XlsxExternalReference,
178}
179
180/// Directly maps the externalReference element of the external workbook
181/// references part.
182#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
183pub struct XlsxExternalReference {
184    #[serde(rename = "@r:id", default, skip_serializing_if = "Option::is_none")]
185    pub r_id: Option<String>,
186}