Debian Codegraph @

.cargo/vendor/onenote_parser/src/one/property_set/ink_container.rs

raw
1 use crate::errors::{ErrorKind, Result};
2 use crate::fsshttpb::data::exguid::ExGuid;
3 use crate::one::property::object_reference::ObjectReference;
4 use crate::one::property::time::Time;
5 use crate::one::property::{simple, PropertyType};
6 use crate::one::property_set::PropertySetId;
7 use crate::onestore::object::Object;
8
9 /// An ink container.
10 #[allow(dead_code)]
11 pub(crate) struct Data {
12 pub(crate) offset_from_parent_horiz: Option<f32>,
13 pub(crate) offset_from_parent_vert: Option<f32>,
14 pub(crate) last_modified: Option<Time>,
15 pub(crate) ink_data: Option<ExGuid>,
16 pub(crate) ink_scaling_x: Option<f32>,
17 pub(crate) ink_scaling_y: Option<f32>,
18 }
19
20 pub(crate) fn parse(object: &Object) -> Result<Data> {
21 if object.id() != PropertySetId::InkContainer.as_jcid() {
22 return Err(ErrorKind::MalformedOneNoteFileData(
23 format!("unexpected object type: 0x{:X}", object.id().0).into(),
24 )
25 .into());
26 }
27
28 let last_modified = Time::parse(PropertyType::LastModifiedTime, object)?;
29 let offset_from_parent_horiz = simple::parse_f32(PropertyType::OffsetFromParentHoriz, object)?;
30 let offset_from_parent_vert = simple::parse_f32(PropertyType::OffsetFromParentVert, object)?;
31 let ink_data = ObjectReference::parse(PropertyType::InkData, object)?;
32 let ink_scaling_x = simple::parse_f32(PropertyType::InkScalingX, object)?;
33 let ink_scaling_y = simple::parse_f32(PropertyType::InkScalingX, object)?;
34
35 let data = Data {
36 offset_from_parent_horiz,
37 offset_from_parent_vert,
38 last_modified,
39 ink_data,
40 ink_scaling_x,
41 ink_scaling_y,
42 };
43
44 Ok(data)
45 }