use crate::style::{ParagraphStyleRef, TextStyleRef};
use crate::xmltree::{XmlContent, XmlTag};
use std::fmt::{Display, Formatter};
pub type TextTag = XmlTag;
pub type TextContent = XmlContent;
text_tag!(TextH, "text:h");
impl TextH {
pub fn class_names(mut self, class_names: &[&ParagraphStyleRef]) -> Self {
let mut buf = String::new();
for n in class_names {
buf.push_str(n.as_str());
buf.push(' ');
}
self.xml.set_attr("text:class-names", buf);
self
}
pub fn condstyle_name(mut self, name: &ParagraphStyleRef) -> Self {
self.xml.set_attr("text:condstyle-name", name.to_string());
self
}
pub fn id(mut self, id: &str) -> Self {
self.xml.set_attr("text:id", id);
self
}
pub fn list_header(mut self, lh: bool) -> Self {
self.xml.set_attr("text:is-list-header", lh.to_string());
self
}
pub fn outline_level(mut self, l: u8) -> Self {
self.xml.set_attr("text:outlinelevel", l.to_string());
self
}
pub fn restart_numbering(mut self, r: bool) -> Self {
self.xml.set_attr("text:restart-numbering", r.to_string());
self
}
pub fn start_value(mut self, l: u8) -> Self {
self.xml.set_attr("text:start-value", l.to_string());
self
}
pub fn style_name(mut self, name: &ParagraphStyleRef) -> Self {
self.xml.set_attr("text:style-name", name.to_string());
self
}
pub fn xml_id(mut self, id: &str) -> Self {
self.xml.set_attr("xml:id", id);
self
}
}
text_tag!(TextP, "text:p");
impl TextP {
pub fn class_names(mut self, class_names: &[&ParagraphStyleRef]) -> Self {
let mut buf = String::new();
for n in class_names {
buf.push_str(n.as_str());
buf.push(' ');
}
self.xml.set_attr("text:class-names", buf);
self
}
pub fn condstyle_name(mut self, name: &ParagraphStyleRef) -> Self {
self.xml.set_attr("text:condstyle-name", name.to_string());
self
}
pub fn id(mut self, id: &str) -> Self {
self.xml.set_attr("text:id", id);
self
}
pub fn style_name(mut self, name: &ParagraphStyleRef) -> Self {
self.xml.set_attr("text:style-name", name.to_string());
self
}
pub fn xml_id(mut self, id: &str) -> Self {
self.xml.set_attr("xml:id", id);
self
}
}
text_tag!(TextSpan, "text:span");
impl TextSpan {
pub fn class_names(mut self, class_names: &[&TextStyleRef]) -> Self {
let mut buf = String::new();
for n in class_names {
buf.push_str(n.as_str());
buf.push(' ');
}
self.xml.set_attr("text:class-names", buf);
self
}
pub fn style_name(mut self, name: &TextStyleRef) -> Self {
self.xml.set_attr("text:style-name", name.to_string());
self
}
}
text_tag!(TextA, "text:a");
impl TextA {
pub fn style_name(mut self, style: &TextStyleRef) -> Self {
self.xml.set_attr("text:style-name", style.to_string());
self
}
pub fn visited_style_name(mut self, style: &TextStyleRef) -> Self {
self.xml
.set_attr("text:visited-style-name", style.to_string());
self
}
pub fn href<S: Into<String>>(mut self, uri: S) -> Self {
self.xml.set_attr("xlink:href", uri.into());
self
}
}
text_tag!(TextS, "text:s");
impl TextS {
pub fn count(mut self, count: u32) -> Self {
self.xml.set_attr("text:c", count.to_string());
self
}
}
text_tag!(TextTab, "text:tab");
impl TextTab {
pub fn tab_ref(mut self, tab_ref: u32) -> Self {
self.xml.set_attr("text:tab-ref", tab_ref.to_string());
self
}
}
text_tag!(TextLineBreak, "text:line-break");
text_tag!(SoftPageBreak, "text:soft-page-break");
text_tag!(AuthorInitials, "text:author-initials");
text_tag!(AuthorName, "text:author_name");
text_tag!(Chapter, "text:chapter");
text_tag!(CharacterCount, "text:character-count");
text_tag!(CreationDate, "text:creation-date");
text_tag!(CreationTime, "text:creation-time");
text_tag!(Creator, "text:creator");
text_tag!(Date, "text:date");
text_tag!(Description, "text:description");
text_tag!(EditingCycles, "text:editing-cycles");
text_tag!(EditingDuration, "text:editing-duration");
text_tag!(FileName, "text:file-name");
text_tag!(InitialCreator, "text:initial-creator");
text_tag!(Keywords, "text:keywords");
text_tag!(ModificationDate, "text:modification-date");
text_tag!(ModificationTime, "text:modification-time");
text_tag!(PageCount, "text:pagecount");
text_tag!(PageNumber, "text:page-number");
text_tag!(PrintDate, "text:print-date");
text_tag!(PrintedBy, "text:printed-by");
text_tag!(PrintTime, "text:print-time");
text_tag!(SheetName, "text:sheet-name");
text_tag!(Subject, "text:subject");
text_tag!(TableCount, "text:table-count");
text_tag!(Time, "text:time");
text_tag!(Title, "text:title");