2019-11-13 11:50:15 +02:00
|
|
|
use crate::documents::BuildXML;
|
|
|
|
use crate::xml_builder::*;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct DocumentRels {}
|
|
|
|
|
|
|
|
impl DocumentRels {
|
|
|
|
pub fn new() -> DocumentRels {
|
|
|
|
DocumentRels {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BuildXML for DocumentRels {
|
|
|
|
fn build(&self) -> Vec<u8> {
|
|
|
|
let b = XMLBuilder::new();
|
|
|
|
b.declaration(None)
|
|
|
|
.open_relationships("http://schemas.openxmlformats.org/package/2006/relationships")
|
|
|
|
.relationship(
|
|
|
|
"rId1",
|
|
|
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
|
|
|
|
"styles.xml",
|
|
|
|
)
|
|
|
|
.relationship(
|
|
|
|
"rId2",
|
2019-12-05 08:44:18 +02:00
|
|
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
|
|
|
|
"comments.xml",
|
|
|
|
)
|
|
|
|
.relationship(
|
|
|
|
"rId3",
|
2019-11-13 11:50:15 +02:00
|
|
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
|
|
|
|
"fontTable.xml",
|
|
|
|
)
|
|
|
|
.relationship(
|
2019-12-05 08:44:18 +02:00
|
|
|
"rId4",
|
2019-11-13 11:50:15 +02:00
|
|
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
|
|
|
|
"settings.xml",
|
|
|
|
)
|
|
|
|
.close()
|
|
|
|
.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
#[cfg(test)]
|
|
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use std::str;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_build() {
|
|
|
|
let c = DocumentRels::new();
|
|
|
|
let b = c.build();
|
|
|
|
assert_eq!(
|
|
|
|
str::from_utf8(&b).unwrap(),
|
|
|
|
r#"<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
|
|
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" />
|
|
|
|
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml" />
|
|
|
|
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml" />
|
|
|
|
</Relationships>"#
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|