From 2237ece46d8acbc2702e670398a0542c77397c99 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Fri, 12 Jun 2020 19:13:44 +0900 Subject: [PATCH] fix: size reader (#86) --- docx-core/src/reader/attributes/indent.rs | 8 ++++---- docx-core/src/reader/errors.rs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docx-core/src/reader/attributes/indent.rs b/docx-core/src/reader/attributes/indent.rs index bb66cd1..5cef0cb 100644 --- a/docx-core/src/reader/attributes/indent.rs +++ b/docx-core/src/reader/attributes/indent.rs @@ -25,15 +25,15 @@ pub fn read_indent(attrs: &[OwnedAttribute]) -> ReadIndentResult { for a in attrs { let local_name = &a.name.local_name; if local_name == "left" || local_name == "start" { - start = Some(i32::from_str(&a.value)?); + start = Some(f64::from_str(&a.value)? as i32); } else if local_name == "leftChars" || local_name == "startChars" { start_chars = Some(i32::from_str(&a.value)?); } else if local_name == "end" || local_name == "right" { - end = Some(i32::from_str(&a.value)?); + end = Some(f64::from_str(&a.value)? as i32); } else if local_name == "hanging" { - special = Some(SpecialIndentType::Hanging(i32::from_str(&a.value)?)) + special = Some(SpecialIndentType::Hanging(f64::from_str(&a.value)? as i32)) } else if local_name == "firstLine" { - special = Some(SpecialIndentType::FirstLine(i32::from_str(&a.value)?)) + special = Some(SpecialIndentType::FirstLine(f64::from_str(&a.value)? as i32)) } } diff --git a/docx-core/src/reader/errors.rs b/docx-core/src/reader/errors.rs index 62effd4..141ed31 100644 --- a/docx-core/src/reader/errors.rs +++ b/docx-core/src/reader/errors.rs @@ -6,6 +6,8 @@ pub enum ReaderError { ZipError(#[from] zip::result::ZipError), #[error("Failed to parse int.")] NumError(#[from] std::num::ParseIntError), + #[error("Failed to parse float.")] + FloatError(#[from] std::num::ParseFloatError), #[error("Failed to convert type.")] TypeError(#[from] crate::types::TypeError), #[error("Failed to read xml.")]