-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DESKTOP-U434MT0\hiro
committed
Jun 9, 2024
1 parent
eac7240
commit 25390f6
Showing
30 changed files
with
464 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
use super::Choice; | ||
use super::Fallback; | ||
use super::OleObject; | ||
use super::EmbeddedObjectProperties; | ||
use super::Int32Value; | ||
use super::StringValue; | ||
use helper::const_str::MC_NS; | ||
use quick_xml::events::{BytesStart, Event}; | ||
use quick_xml::Reader; | ||
use quick_xml::Writer; | ||
use reader::driver::*; | ||
use std::io::Cursor; | ||
use structs::drawing::spreadsheet::TwoCellAnchor; | ||
use structs::raw::RawRelationships; | ||
use structs::vml::Shape; | ||
use writer::driver::*; | ||
|
||
#[derive(Clone, Default, Debug)] | ||
pub struct AlternateContent { | ||
choice: Choice, | ||
fallback: Fallback, | ||
} | ||
|
||
impl AlternateContent { | ||
pub fn get_choice(&self) -> &Choice { | ||
&self.choice | ||
} | ||
|
||
pub fn get_choice_mut(&mut self) -> &mut Choice { | ||
&mut self.choice | ||
} | ||
|
||
pub fn set_choice(&mut self, value: Choice) -> &mut Self { | ||
self.choice = value; | ||
self | ||
} | ||
|
||
pub fn get_fallback(&self) -> &Fallback { | ||
&self.fallback | ||
} | ||
|
||
pub fn get_fallback_mut(&mut self) -> &mut Fallback { | ||
&mut self.fallback | ||
} | ||
|
||
pub fn set_fallback(&mut self, value: Fallback) -> &mut Self { | ||
self.fallback = value; | ||
self | ||
} | ||
|
||
pub(crate) fn set_attributes<R: std::io::BufRead>( | ||
&mut self, | ||
reader: &mut Reader<R>, | ||
e: &BytesStart, | ||
relationships: &RawRelationships, | ||
) { | ||
xml_read_loop!( | ||
reader, | ||
Event::Start(ref e) => { | ||
match e.name().into_inner() { | ||
b"mc:Choice" => { | ||
let mut obj = Choice::default(); | ||
obj.set_attributes(reader, e, relationships); | ||
self.set_choice(obj); | ||
} | ||
b"mc:Fallback" => { | ||
let mut obj = Fallback::default(); | ||
obj.set_attributes(reader, e, relationships); | ||
self.set_fallback(obj); | ||
} | ||
_ => (), | ||
} | ||
}, | ||
Event::End(ref e) => { | ||
if e.name().into_inner() == b"mc:AlternateContent" { | ||
return | ||
} | ||
}, | ||
Event::Eof => panic!("Error not find {} end element", "mc:AlternateContent") | ||
); | ||
} | ||
|
||
pub(crate) fn write_to( | ||
&self, | ||
writer: &mut Writer<Cursor<Vec<u8>>>, | ||
) { | ||
// mc:AlternateContent | ||
write_start_tag( | ||
writer, | ||
"mc:AlternateContent", | ||
vec![("xmlns:mc", MC_NS)], | ||
false, | ||
); | ||
|
||
// mc:Choice | ||
self.choice.write_to(writer); | ||
|
||
// mc:Fallback | ||
self.fallback.write_to(writer); | ||
|
||
write_end_tag(writer, "mc:AlternateContent"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use super::OleObject; | ||
use super::EmbeddedObjectProperties; | ||
use super::Int32Value; | ||
use super::StringValue; | ||
use helper::const_str::MC_NS; | ||
use quick_xml::events::{BytesStart, Event}; | ||
use quick_xml::Reader; | ||
use quick_xml::Writer; | ||
use reader::driver::*; | ||
use std::io::Cursor; | ||
use structs::drawing::spreadsheet::TwoCellAnchor; | ||
use structs::raw::RawRelationships; | ||
use structs::vml::Shape; | ||
use writer::driver::*; | ||
|
||
#[derive(Clone, Default, Debug)] | ||
pub struct Choice { | ||
requires: StringValue, | ||
ole_object: OleObject, | ||
} | ||
|
||
impl Choice { | ||
pub fn get_requires(&self) -> &str { | ||
self.requires.get_value() | ||
} | ||
|
||
pub fn set_requires<S: Into<String>>(&mut self, value: S) -> &mut Self { | ||
self.requires.set_value(value); | ||
self | ||
} | ||
|
||
pub fn get_ole_object(&self) -> &OleObject { | ||
&self.ole_object | ||
} | ||
|
||
pub fn get_ole_object_mut(&mut self) -> &mut OleObject { | ||
&mut self.ole_object | ||
} | ||
|
||
pub fn set_ole_object(&mut self, value: OleObject) -> &mut Self { | ||
self.ole_object = value; | ||
self | ||
} | ||
|
||
pub(crate) fn set_attributes<R: std::io::BufRead>( | ||
&mut self, | ||
reader: &mut Reader<R>, | ||
e: &BytesStart, | ||
relationships: &RawRelationships, | ||
) { | ||
set_string_from_xml!(self, e, requires, "Requires"); | ||
xml_read_loop!( | ||
reader, | ||
Event::Start(ref e) => { | ||
match e.name().into_inner() { | ||
b"oleObject" => { | ||
let mut obj = OleObject::default(); | ||
obj.set_attributes(reader, e, relationships); | ||
self.set_ole_object(obj); | ||
} | ||
_ => (), | ||
} | ||
}, | ||
Event::End(ref e) => { | ||
if e.name().into_inner() == b"mc:Choice" { | ||
return | ||
} | ||
}, | ||
Event::Eof => panic!("Error not find {} end element", "mc:Choice") | ||
); | ||
} | ||
|
||
pub(crate) fn write_to( | ||
&self, | ||
writer: &mut Writer<Cursor<Vec<u8>>>, | ||
) { | ||
// mc:Choice | ||
write_start_tag( | ||
writer, | ||
"mc:Choice", | ||
vec![("Requires", self.requires.get_value_str())], | ||
false, | ||
); | ||
|
||
// oleObject | ||
self.ole_object.write_to(writer); | ||
|
||
write_end_tag(writer, "mc:Choice"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.