-
-
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 10, 2024
1 parent
eac7240
commit c0bc0b6
Showing
22 changed files
with
347 additions
and
80 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,141 @@ | ||
// a:blipFill | ||
use super::super::super::BooleanValue; | ||
use super::Blip; | ||
use super::SourceRectangle; | ||
use super::Stretch; | ||
use quick_xml::events::{BytesStart, Event}; | ||
use quick_xml::Reader; | ||
use quick_xml::Writer; | ||
use reader::driver::*; | ||
use std::io::Cursor; | ||
use structs::raw::RawRelationships; | ||
use writer::driver::*; | ||
|
||
#[derive(Clone, Default, Debug)] | ||
pub struct BlipFill { | ||
rotate_with_shape: BooleanValue, | ||
blip: Blip, | ||
source_rectangle: Option<SourceRectangle>, | ||
stretch: Stretch, | ||
} | ||
|
||
impl BlipFill { | ||
pub fn get_rotate_with_shape(&self) -> &bool { | ||
self.rotate_with_shape.get_value() | ||
} | ||
|
||
pub fn set_rotate_with_shape(&mut self, value: bool) -> &mut BlipFill { | ||
self.rotate_with_shape.set_value(value); | ||
self | ||
} | ||
|
||
pub fn get_source_rectangle(&self) -> Option<&SourceRectangle> { | ||
self.source_rectangle.as_ref() | ||
} | ||
|
||
pub fn get_source_rectangle_mut(&mut self) -> Option<&mut SourceRectangle> { | ||
self.source_rectangle.as_mut() | ||
} | ||
|
||
pub fn set_source_rectangle(&mut self, value: SourceRectangle) -> &mut BlipFill { | ||
self.source_rectangle = Some(value); | ||
self | ||
} | ||
|
||
pub fn get_blip(&self) -> &Blip { | ||
&self.blip | ||
} | ||
|
||
pub fn get_blip_mut(&mut self) -> &mut Blip { | ||
&mut self.blip | ||
} | ||
|
||
pub fn set_blip(&mut self, value: Blip) -> &mut BlipFill { | ||
self.blip = value; | ||
self | ||
} | ||
|
||
pub fn get_stretch(&self) -> &Stretch { | ||
&self.stretch | ||
} | ||
|
||
pub fn get_stretch_mut(&mut self) -> &mut Stretch { | ||
&mut self.stretch | ||
} | ||
|
||
pub fn set_stretch(&mut self, value: Stretch) -> &mut BlipFill { | ||
self.stretch = value; | ||
self | ||
} | ||
|
||
pub(crate) fn set_attributes<R: std::io::BufRead>( | ||
&mut self, | ||
reader: &mut Reader<R>, | ||
e: &BytesStart, | ||
drawing_relationships: Option<&RawRelationships>, | ||
) { | ||
set_string_from_xml!(self, e, rotate_with_shape, "rotWithShape"); | ||
|
||
xml_read_loop!( | ||
reader, | ||
Event::Start(ref e) => { | ||
match e.name().into_inner() { | ||
b"a:blip" => { | ||
self.blip | ||
.set_attributes(reader, e, drawing_relationships.unwrap(), false); | ||
} | ||
b"a:stretch" => { | ||
self.stretch.set_attributes(reader, e); | ||
} | ||
_ => (), | ||
} | ||
}, | ||
Event::Empty(ref e) => { | ||
match e.name().into_inner() { | ||
b"a:blip" => { | ||
self.blip | ||
.set_attributes(reader, e, drawing_relationships.unwrap(), true); | ||
} | ||
b"a:srcRect" => { | ||
let mut source_rectangle = SourceRectangle::default(); | ||
source_rectangle.set_attributes(reader, e); | ||
self.set_source_rectangle(source_rectangle); | ||
} | ||
_ => (), | ||
} | ||
}, | ||
Event::End(ref e) => { | ||
if e.name().into_inner() == b"a:blipFill" { | ||
return; | ||
} | ||
}, | ||
Event::Eof => panic!("Error not find {} end element", "a:blipFill") | ||
); | ||
} | ||
|
||
pub(crate) fn write_to( | ||
&self, | ||
writer: &mut Writer<Cursor<Vec<u8>>>, | ||
rel_list: &mut Vec<(String, String)>, | ||
) { | ||
// a:blipFill | ||
let mut attributes: Vec<(&str, &str)> = Vec::new(); | ||
if self.rotate_with_shape.has_value() { | ||
attributes.push(("rotWithShape", self.rotate_with_shape.get_value_string())) | ||
} | ||
write_start_tag(writer, "a:blipFill", attributes, false); | ||
|
||
// a:blip | ||
let _ = &self.blip.write_to(writer, rel_list); | ||
|
||
// a:srcRect | ||
if let Some(v) = &self.source_rectangle { | ||
v.write_to(writer); | ||
} | ||
|
||
// a:stretch | ||
let _ = &self.stretch.write_to(writer); | ||
|
||
write_end_tag(writer, "a:blipFill"); | ||
} | ||
} |
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
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.