use super::super::StringValue;
use super::Color2Type;
use quick_xml::events::{BytesStart, Event};
use quick_xml::Reader;
use quick_xml::Writer;
use reader::driver::*;
use std::io::Cursor;
use writer::driver::*;
#[derive(Clone, Default, Debug)]
pub struct ColorScheme {
name: StringValue,
accent1: Color2Type,
accent2: Color2Type,
accent3: Color2Type,
accent4: Color2Type,
accent5: Color2Type,
accent6: Color2Type,
dk1: Color2Type,
dk2: Color2Type,
fol_hlink: Color2Type,
hlink: Color2Type,
lt1: Color2Type,
lt2: Color2Type,
}
impl ColorScheme {
pub fn get_name(&self) -> &str {
self.name.get_value()
}
pub fn set_name<S: Into<String>>(&mut self, value: S) -> &mut Self {
self.name.set_value(value);
self
}
pub fn set_accent1(&mut self, value: Color2Type) {
self.accent1 = value;
}
pub fn get_accent1(&self) -> &Color2Type {
&self.accent1
}
pub fn get_accent1_mut(&mut self) -> &mut Color2Type {
&mut self.accent1
}
pub fn set_accent2(&mut self, value: Color2Type) {
self.accent2 = value;
}
pub fn get_accent2(&self) -> &Color2Type {
&self.accent2
}
pub fn get_accent2_mut(&mut self) -> &mut Color2Type {
&mut self.accent2
}
pub fn set_accent3(&mut self, value: Color2Type) {
self.accent3 = value;
}
pub fn get_accent3(&self) -> &Color2Type {
&self.accent3
}
pub fn get_accent3_mut(&mut self) -> &mut Color2Type {
&mut self.accent3
}
pub fn set_accent4(&mut self, value: Color2Type) {
self.accent4 = value;
}
pub fn get_accent4(&self) -> &Color2Type {
&self.accent4
}
pub fn get_accent4_mut(&mut self) -> &mut Color2Type {
&mut self.accent4
}
pub fn set_accent5(&mut self, value: Color2Type) {
self.accent5 = value;
}
pub fn get_accent5(&self) -> &Color2Type {
&self.accent5
}
pub fn get_accent5_mut(&mut self) -> &mut Color2Type {
&mut self.accent5
}
pub fn set_accent6(&mut self, value: Color2Type) {
self.accent6 = value;
}
pub fn get_accent6(&self) -> &Color2Type {
&self.accent6
}
pub fn get_accent6_mut(&mut self) -> &mut Color2Type {
&mut self.accent6
}
pub fn set_dk1(&mut self, value: Color2Type) {
self.dk1 = value;
}
pub fn get_dk1(&self) -> &Color2Type {
&self.dk1
}
pub fn get_dk1_mut(&mut self) -> &mut Color2Type {
&mut self.dk1
}
pub fn set_dk2(&mut self, value: Color2Type) {
self.dk2 = value;
}
pub fn get_dk2(&self) -> &Color2Type {
&self.dk2
}
pub fn get_dk2_mut(&mut self) -> &mut Color2Type {
&mut self.dk2
}
pub fn set_fol_hlink(&mut self, value: Color2Type) {
self.fol_hlink = value;
}
pub fn get_fol_hlink(&self) -> &Color2Type {
&self.fol_hlink
}
pub fn get_fol_hlink_mut(&mut self) -> &mut Color2Type {
&mut self.fol_hlink
}
pub fn set_hlink(&mut self, value: Color2Type) {
self.hlink = value;
}
pub fn get_hlink(&self) -> &Color2Type {
&self.hlink
}
pub fn get_hlink_mut(&mut self) -> &mut Color2Type {
&mut self.hlink
}
pub fn set_lt1(&mut self, value: Color2Type) {
self.lt1 = value;
}
pub fn get_lt1(&self) -> &Color2Type {
&self.lt1
}
pub fn get_lt1_mut(&mut self) -> &mut Color2Type {
&mut self.lt1
}
pub fn set_lt2(&mut self, value: Color2Type) {
self.lt2 = value;
}
pub fn get_lt2(&self) -> &Color2Type {
&self.lt2
}
pub fn get_lt2_mut(&mut self) -> &mut Color2Type {
&mut self.lt2
}
pub fn get_color_map(&self) -> Vec<String> {
vec![
self.dk1.get_val(),
self.lt1.get_val(),
self.dk2.get_val(),
self.lt2.get_val(),
self.accent1.get_val(),
self.accent2.get_val(),
self.accent3.get_val(),
self.accent4.get_val(),
self.accent5.get_val(),
self.accent6.get_val(),
self.hlink.get_val(),
self.fol_hlink.get_val(),
]
}
pub(crate) fn set_attributes<R: std::io::BufRead>(
&mut self,
reader: &mut Reader<R>,
e: &BytesStart,
) {
set_string_from_xml!(self, e, name, "name");
xml_read_loop!(
reader,
Event::Start(ref e) => {
match e.name().into_inner() {
b"a:accent1" => {
self.accent1.set_attributes(reader, e);
}
b"a:accent2" => {
self.accent2.set_attributes(reader, e);
}
b"a:accent3" => {
self.accent3.set_attributes(reader, e);
}
b"a:accent4" => {
self.accent4.set_attributes(reader, e);
}
b"a:accent5" => {
self.accent5.set_attributes(reader, e);
}
b"a:accent6" => {
self.accent6.set_attributes(reader, e);
}
b"a:dk1" => {
self.dk1.set_attributes(reader, e);
}
b"a:dk2" => {
self.dk2.set_attributes(reader, e);
}
b"a:folHlink" => {
self.fol_hlink.set_attributes(reader, e);
}
b"a:hlink" => {
self.hlink.set_attributes(reader, e);
}
b"a:lt1" => {
self.lt1.set_attributes(reader, e);
}
b"a:lt2" => {
self.lt2.set_attributes(reader, e);
}
_ => (),
}
},
Event::End(ref e) => {
if e.name().into_inner() == b"a:clrScheme" {
return
}
},
Event::Eof => panic!("Error not find {} end element", "a:clrScheme")
);
}
pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
let mut attributes: Vec<(&str, &str)> = Vec::new();
if self.name.has_value() {
attributes.push(("name", self.name.get_value_string()));
}
write_start_tag(writer, "a:clrScheme", attributes, false);
let _ = &self.dk1.write_to_dk1(writer);
let _ = &self.lt1.write_to_lt1(writer);
let _ = &self.dk2.write_to_dk2(writer);
let _ = &self.lt2.write_to_lt2(writer);
let _ = &self.accent1.write_to_accent1(writer);
let _ = &self.accent2.write_to_accent2(writer);
let _ = &self.accent3.write_to_accent3(writer);
let _ = &self.accent4.write_to_accent4(writer);
let _ = &self.accent5.write_to_accent5(writer);
let _ = &self.accent6.write_to_accent6(writer);
let _ = &self.hlink.write_to_hlink(writer);
let _ = &self.fol_hlink.write_to_fol_hlink(writer);
write_end_tag(writer, "a:clrScheme");
}
}