build: use rust 1.82 and fix clipyy errors (#768)
* build: use rust 1.82 and fix clipyy errors * refactor: fix clippy errorsmain
parent
de071a60dd
commit
69b4c1a4a3
|
@ -4,7 +4,7 @@ use crate::xml_builder::*;
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Comments {
|
||||
pub(crate) comments: Vec<Comment>,
|
||||
|
@ -28,12 +28,6 @@ impl Comments {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Comments {
|
||||
fn default() -> Self {
|
||||
Self { comments: vec![] }
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for Comments {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let mut b = XMLBuilder::new().declaration(Some(true)).open_comments();
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::documents::BuildXML;
|
|||
use crate::xml_builder::*;
|
||||
|
||||
// i.e. <w15:commentEx w15:paraId="00000001" w15:paraIdParent="57D1BD7C" w15:done="0"/>
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CommentsExtended {
|
||||
pub children: Vec<CommentExtended>,
|
||||
|
@ -21,12 +21,6 @@ impl CommentsExtended {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for CommentsExtended {
|
||||
fn default() -> Self {
|
||||
Self { children: vec![] }
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for CommentsExtended {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let mut b = XMLBuilder::new();
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::Serialize;
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AppProps {}
|
||||
|
||||
|
@ -13,12 +13,6 @@ impl AppProps {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for AppProps {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for AppProps {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -3,13 +3,13 @@ use serde::Serialize;
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CoreProps {
|
||||
config: CorePropsConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CorePropsConfig {
|
||||
created: Option<String>,
|
||||
|
@ -23,30 +23,6 @@ pub struct CorePropsConfig {
|
|||
title: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for CorePropsConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
created: None,
|
||||
creator: None,
|
||||
description: None,
|
||||
language: None,
|
||||
last_modified_by: None,
|
||||
modified: None,
|
||||
revision: None,
|
||||
subject: None,
|
||||
title: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CoreProps {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
config: CorePropsConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CoreProps {
|
||||
pub(crate) fn new(config: CorePropsConfig) -> CoreProps {
|
||||
CoreProps { config }
|
||||
|
|
|
@ -96,6 +96,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_toc_instr() {
|
||||
#[allow(unused_allocation)]
|
||||
let b = Box::new(InstrText::TOC(InstrToC::new().heading_styles_range(1, 3))).build();
|
||||
assert_eq!(
|
||||
str::from_utf8(&b).unwrap(),
|
||||
|
@ -105,6 +106,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_pageref_instr() {
|
||||
#[allow(unused_allocation)]
|
||||
let b = Box::new(InstrText::PAGEREF(
|
||||
InstrPAGEREF::new("_Toc90425847").hyperlink(),
|
||||
))
|
||||
|
|
|
@ -255,7 +255,7 @@ impl BuildXML for InstrToC {
|
|||
fn parse_level_range(i: &str) -> Option<(usize, usize)> {
|
||||
let r = i.replace(""", "").replace('\"', "");
|
||||
let r: Vec<&str> = r.split('-').collect();
|
||||
if let Some(s) = r.get(0) {
|
||||
if let Some(s) = r.first() {
|
||||
if let Ok(s) = usize::from_str(s) {
|
||||
if let Some(e) = r.get(1) {
|
||||
if let Ok(e) = usize::from_str(e) {
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize, Serializer};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq, Default)]
|
||||
pub struct IsLgl {}
|
||||
|
||||
impl IsLgl {
|
||||
|
@ -12,12 +12,6 @@ impl IsLgl {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for IsLgl {
|
||||
fn default() -> Self {
|
||||
IsLgl {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for IsLgl {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -52,7 +52,7 @@ impl LineSpacing {
|
|||
}
|
||||
|
||||
pub fn line(mut self, line: i32) -> Self {
|
||||
self.line = Some(line as i32);
|
||||
self.line = Some(line);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
// use super::*;
|
||||
use crate::documents::BuildXML;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::documents::BuildXML;
|
||||
// use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Default)]
|
||||
pub struct McFallback {}
|
||||
|
||||
impl McFallback {
|
||||
|
@ -13,12 +10,6 @@ impl McFallback {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for McFallback {
|
||||
fn default() -> Self {
|
||||
McFallback {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for McFallback {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
// Ignore for now
|
||||
|
|
|
@ -207,7 +207,6 @@ pub use numbering::*;
|
|||
pub use numbering_id::*;
|
||||
pub use numbering_property::*;
|
||||
pub use outline_lvl::*;
|
||||
pub use page_margin::*;
|
||||
pub use page_num::*;
|
||||
pub use page_num_type::*;
|
||||
pub use page_size::*;
|
||||
|
|
|
@ -5,21 +5,12 @@ use super::{IndentLevel, NumberingId};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct NumberingProperty {
|
||||
pub id: Option<NumberingId>,
|
||||
pub level: Option<IndentLevel>,
|
||||
}
|
||||
|
||||
impl Default for NumberingProperty {
|
||||
fn default() -> Self {
|
||||
NumberingProperty {
|
||||
id: None,
|
||||
level: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NumberingProperty {
|
||||
pub fn new() -> NumberingProperty {
|
||||
Default::default()
|
||||
|
|
|
@ -7,6 +7,7 @@ use crate::xml_builder::*;
|
|||
// application. If this element is set, then this style has been designated as being particularly important for the
|
||||
// current document, and this information can be used by an application in any means desired. [Note: This setting
|
||||
// 637ECMA-376 Part 1 does not imply any behavior for the style, only that the style is of particular significance for this document. end note]
|
||||
#[derive(Default)]
|
||||
pub struct QFormat {}
|
||||
|
||||
impl QFormat {
|
||||
|
@ -15,11 +16,6 @@ impl QFormat {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for QFormat {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for QFormat {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize, Serializer};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq, Default)]
|
||||
pub struct SpecVanish {}
|
||||
|
||||
impl SpecVanish {
|
||||
|
@ -12,12 +12,6 @@ impl SpecVanish {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for SpecVanish {
|
||||
fn default() -> Self {
|
||||
SpecVanish {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for SpecVanish {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Serialize, Serializer};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct Start {
|
||||
val: usize,
|
||||
}
|
||||
|
@ -14,12 +14,6 @@ impl Start {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Start {
|
||||
fn default() -> Self {
|
||||
Start { val: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for Start {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -5,7 +5,7 @@ use serde::Serialize;
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Default)]
|
||||
pub struct TextBoxContent {
|
||||
pub children: Vec<TextBoxContentChild>,
|
||||
pub has_numbering: bool,
|
||||
|
@ -62,15 +62,6 @@ impl TextBoxContent {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for TextBoxContent {
|
||||
fn default() -> Self {
|
||||
TextBoxContent {
|
||||
children: vec![],
|
||||
has_numbering: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for TextBoxContent {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize, Serializer};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq, Default)]
|
||||
pub struct Vanish {}
|
||||
|
||||
impl Vanish {
|
||||
|
@ -12,12 +12,6 @@ impl Vanish {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Vanish {
|
||||
fn default() -> Self {
|
||||
Vanish {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for Vanish {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -4,7 +4,7 @@ use serde::Serialize;
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WpAnchor {
|
||||
pub children: Vec<AGraphic>,
|
||||
|
@ -32,12 +32,6 @@ impl WpAnchor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for WpAnchor {
|
||||
fn default() -> Self {
|
||||
WpAnchor { children: vec![] }
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for WpAnchor {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -5,7 +5,7 @@ use serde::Serialize;
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WpsShape {
|
||||
children: Vec<WpsShapeChild>,
|
||||
|
@ -43,12 +43,6 @@ impl WpsShape {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for WpsShape {
|
||||
fn default() -> Self {
|
||||
WpsShape { children: vec![] }
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for WpsShape {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -4,7 +4,7 @@ use serde::Serialize;
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WpsTextBox {
|
||||
pub children: Vec<TextBoxContent>,
|
||||
|
@ -25,15 +25,6 @@ impl WpsTextBox {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for WpsTextBox {
|
||||
fn default() -> Self {
|
||||
WpsTextBox {
|
||||
children: vec![],
|
||||
has_numbering: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for WpsTextBox {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::xml_builder::*;
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FontTable {}
|
||||
|
||||
|
@ -15,12 +15,6 @@ impl FontTable {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for FontTable {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for FontTable {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -96,7 +96,7 @@ impl ser::Serialize for Image {
|
|||
where
|
||||
S: ser::Serializer,
|
||||
{
|
||||
let base64 = base64::display::Base64Display::with_config(&*self.0, base64::STANDARD);
|
||||
let base64 = base64::display::Base64Display::with_config(&self.0, base64::STANDARD);
|
||||
serializer.collect_str(&base64)
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl ser::Serialize for Png {
|
|||
where
|
||||
S: ser::Serializer,
|
||||
{
|
||||
let base64 = base64::display::Base64Display::with_config(&*self.0, base64::STANDARD);
|
||||
let base64 = base64::display::Base64Display::with_config(&self.0, base64::STANDARD);
|
||||
serializer.collect_str(&base64)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::xml_builder::*;
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Numberings {
|
||||
pub abstract_nums: Vec<AbstractNumbering>,
|
||||
|
@ -28,15 +28,6 @@ impl Numberings {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Numberings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
abstract_nums: vec![],
|
||||
numberings: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for Numberings {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let mut b = XMLBuilder::new().declaration(Some(true)).open_numbering();
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Default)]
|
||||
pub struct Rels {
|
||||
pub rels: Vec<(String, String, String)>,
|
||||
}
|
||||
|
@ -61,12 +61,6 @@ impl Rels {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Rels {
|
||||
fn default() -> Self {
|
||||
Rels { rels: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for Rels {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Copy)]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Copy, Default)]
|
||||
pub struct Taskpanes {}
|
||||
|
||||
impl Taskpanes {
|
||||
|
@ -12,12 +12,6 @@ impl Taskpanes {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Taskpanes {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for Taskpanes {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||
use crate::documents::BuildXML;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Default)]
|
||||
pub struct TaskpanesRels {
|
||||
pub rels: Vec<(String, String, String)>,
|
||||
}
|
||||
|
@ -28,12 +28,6 @@ impl TaskpanesRels {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for TaskpanesRels {
|
||||
fn default() -> Self {
|
||||
TaskpanesRels { rels: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl BuildXML for TaskpanesRels {
|
||||
fn build(&self) -> Vec<u8> {
|
||||
let b = XMLBuilder::new();
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WebSettings {
|
||||
pub divs: Vec<Div>,
|
||||
|
@ -13,9 +13,3 @@ impl WebSettings {
|
|||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for WebSettings {
|
||||
fn default() -> Self {
|
||||
Self { divs: vec![] }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
mod documents;
|
||||
#[allow(hidden_glob_reexports)] // should rename?
|
||||
mod errors;
|
||||
mod escape;
|
||||
mod reader;
|
||||
|
|
|
@ -5,7 +5,7 @@ pub fn is_false(v: &str) -> bool {
|
|||
}
|
||||
|
||||
pub fn read_bool(attrs: &[OwnedAttribute]) -> bool {
|
||||
if let Some(v) = attrs.get(0) {
|
||||
if let Some(v) = attrs.first() {
|
||||
if is_false(&v.value) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ pub use attributes::*;
|
|||
pub use document_rels::*;
|
||||
pub use errors::ReaderError;
|
||||
pub use from_xml::*;
|
||||
pub use mc_fallback::*;
|
||||
pub use read_zip::*;
|
||||
pub use xml_element::*;
|
||||
use zip::ZipArchive;
|
||||
|
@ -222,7 +221,7 @@ pub fn read_docx(buf: &[u8]) -> Result<Docx, ReaderError> {
|
|||
// Read commentsExtended
|
||||
let comments_extended_path = rels.find_target_path(COMMENTS_EXTENDED_TYPE);
|
||||
let comments_extended = if let Some(comments_extended_path) = comments_extended_path {
|
||||
if let Some((_, comments_extended_path, ..)) = comments_extended_path.get(0) {
|
||||
if let Some((_, comments_extended_path, ..)) = comments_extended_path.first() {
|
||||
let data = read_zip(
|
||||
&mut archive,
|
||||
comments_extended_path
|
||||
|
@ -244,7 +243,7 @@ pub fn read_docx(buf: &[u8]) -> Result<Docx, ReaderError> {
|
|||
// Read comments
|
||||
let comments_path = rels.find_target_path(COMMENTS_TYPE);
|
||||
let comments = if let Some(paths) = comments_path {
|
||||
if let Some((_, comments_path, ..)) = paths.get(0) {
|
||||
if let Some((_, comments_path, ..)) = paths.first() {
|
||||
let data = read_zip(
|
||||
&mut archive,
|
||||
comments_path.to_str().expect("should have comments."),
|
||||
|
@ -399,7 +398,7 @@ pub fn read_docx(buf: &[u8]) -> Result<Docx, ReaderError> {
|
|||
// Read styles
|
||||
let style_path = rels.find_target_path(STYLE_RELATIONSHIP_TYPE);
|
||||
if let Some(paths) = style_path {
|
||||
if let Some((_, style_path, ..)) = paths.get(0) {
|
||||
if let Some((_, style_path, ..)) = paths.first() {
|
||||
let data = read_zip(
|
||||
&mut archive,
|
||||
style_path.to_str().expect("should have styles"),
|
||||
|
@ -412,7 +411,7 @@ pub fn read_docx(buf: &[u8]) -> Result<Docx, ReaderError> {
|
|||
// Read numberings
|
||||
let num_path = rels.find_target_path(NUMBERING_RELATIONSHIP_TYPE);
|
||||
if let Some(paths) = num_path {
|
||||
if let Some((_, num_path, ..)) = paths.get(0) {
|
||||
if let Some((_, num_path, ..)) = paths.first() {
|
||||
let data = read_zip(
|
||||
&mut archive,
|
||||
num_path.to_str().expect("should have numberings"),
|
||||
|
@ -425,7 +424,7 @@ pub fn read_docx(buf: &[u8]) -> Result<Docx, ReaderError> {
|
|||
// Read settings
|
||||
let settings_path = rels.find_target_path(SETTINGS_TYPE);
|
||||
if let Some(paths) = settings_path {
|
||||
if let Some((_, settings_path, ..)) = paths.get(0) {
|
||||
if let Some((_, settings_path, ..)) = paths.first() {
|
||||
let data = read_zip(
|
||||
&mut archive,
|
||||
settings_path.to_str().expect("should have settings"),
|
||||
|
@ -438,7 +437,7 @@ pub fn read_docx(buf: &[u8]) -> Result<Docx, ReaderError> {
|
|||
// Read web settings
|
||||
let web_settings_path = rels.find_target_path(WEB_SETTINGS_TYPE);
|
||||
if let Some(paths) = web_settings_path {
|
||||
if let Some((_, web_settings_path, ..)) = paths.get(0) {
|
||||
if let Some((_, web_settings_path, ..)) = paths.first() {
|
||||
let data = read_zip(
|
||||
&mut archive,
|
||||
web_settings_path
|
||||
|
|
|
@ -91,7 +91,7 @@ impl ElementReader for Run {
|
|||
XMLElement::Text => text_state = TextState::Text,
|
||||
XMLElement::DeleteText => text_state = TextState::Delete,
|
||||
XMLElement::Break => {
|
||||
if let Some(a) = &attributes.get(0) {
|
||||
if let Some(a) = attributes.first() {
|
||||
run = run.add_break(BreakType::from_str(&a.value)?)
|
||||
} else {
|
||||
run = run.add_break(BreakType::TextWrapping)
|
||||
|
|
|
@ -113,7 +113,7 @@ impl ElementReader for RunProperty {
|
|||
rp = rp.fonts(f);
|
||||
}
|
||||
}
|
||||
XMLElement::Underline => rp = rp.underline(&attributes[0].value.clone()),
|
||||
XMLElement::Underline => rp = rp.underline(attributes[0].value.clone()),
|
||||
XMLElement::Italic => {
|
||||
if !read_bool(&attributes) {
|
||||
rp = rp.disable_italic();
|
||||
|
|
|
@ -26,7 +26,7 @@ impl FromXML for Settings {
|
|||
// Ignore w14:val
|
||||
if local_name == "val" && prefix == "w15" {
|
||||
settings = settings.doc_id(
|
||||
&a.value.to_owned().replace("{", "").replace("}", ""),
|
||||
a.value.to_owned().replace("{", "").replace("}", ""),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ impl ElementReader for Style {
|
|||
let e = XMLElement::from_str(&name.local_name).unwrap();
|
||||
match e {
|
||||
XMLElement::Name => {
|
||||
style = style.name(&attributes[0].value.clone());
|
||||
style = style.name(attributes[0].value.clone());
|
||||
continue;
|
||||
}
|
||||
XMLElement::BasedOn => {
|
||||
|
|
|
@ -34,12 +34,12 @@ impl ElementReader for TableCellProperty {
|
|||
property = property.width(w, width_type);
|
||||
}
|
||||
XMLElement::TableGridSpan => {
|
||||
if let Some(a) = &attributes.get(0) {
|
||||
if let Some(a) = attributes.first() {
|
||||
property = property.grid_span(usize::from_str(&a.value)?)
|
||||
}
|
||||
}
|
||||
XMLElement::TableVMerge => {
|
||||
if let Some(a) = &attributes.get(0) {
|
||||
if let Some(a) = attributes.first() {
|
||||
property = property.vertical_merge(VMergeType::from_str(&a.value)?);
|
||||
} else {
|
||||
// Treat as a continue without attribute
|
||||
|
@ -47,7 +47,7 @@ impl ElementReader for TableCellProperty {
|
|||
}
|
||||
}
|
||||
XMLElement::VAlign => {
|
||||
if let Some(a) = &attributes.get(0) {
|
||||
if let Some(a) = attributes.first() {
|
||||
property = property.vertical_align(VAlignType::from_str(&a.value)?);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ impl ElementReader for TableCellProperty {
|
|||
}
|
||||
}
|
||||
XMLElement::TextDirection => {
|
||||
if let Some(a) = &attributes.get(0) {
|
||||
if let Some(a) = attributes.first() {
|
||||
if let Ok(v) = TextDirectionType::from_str(&a.value) {
|
||||
property = property.text_direction(v);
|
||||
}
|
||||
|
|
|
@ -573,7 +573,7 @@ macro_rules! closed_border_el {
|
|||
|
||||
macro_rules! closed_paragraph_border_el {
|
||||
($name: ident, $ el_name: expr) => {
|
||||
pub(crate) fn $name<'a>(mut self, val: &str, space: &str, size: &str, color: &str) -> Self {
|
||||
pub(crate) fn $name(mut self, val: &str, space: &str, size: &str, color: &str) -> Self {
|
||||
self.writer
|
||||
.write(
|
||||
XmlEvent::start_element($el_name)
|
||||
|
|
|
@ -27,8 +27,6 @@ use std::str;
|
|||
use xml::common::XmlVersion;
|
||||
use xml::writer::{EmitterConfig, EventWriter, XmlEvent};
|
||||
|
||||
pub use elements::*;
|
||||
|
||||
pub struct XMLBuilder {
|
||||
writer: EventWriter<Vec<u8>>,
|
||||
}
|
||||
|
|
|
@ -69,14 +69,13 @@ pub struct XmlData {
|
|||
|
||||
// Get the attributes as a string
|
||||
fn attributes_to_string(attributes: &[(String, String)]) -> String {
|
||||
attributes
|
||||
.iter()
|
||||
.fold(String::new(), |acc, &(ref k, ref v)| {
|
||||
attributes.iter().fold(String::new(), |acc, (k, v)| {
|
||||
format!("{} {}=\"{}\"", acc, k, v)
|
||||
})
|
||||
}
|
||||
|
||||
// Format the XML data as a string
|
||||
#[allow(clippy::only_used_in_recursion)]
|
||||
fn format(data: &XmlData, depth: usize) -> String {
|
||||
let sub = if data.children.is_empty() {
|
||||
String::new()
|
||||
|
@ -88,8 +87,6 @@ fn format(data: &XmlData, depth: usize) -> String {
|
|||
sub
|
||||
};
|
||||
|
||||
// let indt = indent(depth);
|
||||
|
||||
let fmt_data = if let Some(ref d) = data.data {
|
||||
format!("\n{}", d)
|
||||
} else {
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.73
|
||||
1.82
|
Loading…
Reference in New Issue