From 1f81738f446e13651bb1b1e05ee0177655fd5878 Mon Sep 17 00:00:00 2001 From: mxsrm <7951225+mxsrm@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:13:17 +0100 Subject: [PATCH 001/167] Optimize code (#249) * refactor: simplify `split_rgb` string slicing logic - Updated the `split_rgb` function in `src/helper/color.rs` to replace manual character skipping and collecting with direct string slicing (`&rgb[0..2]`, etc.). - Improves readability and reduces unnecessary intermediate string allocations. - Maintains the same functionality for parsing RGB hex strings into `(i32, i32, i32)`. * refactor: clippy lint in writer/driver.rs error: written amount is not handled --> src/writer/driver.rs:49:5 | 49 | writer.get_mut().write(data.into().as_bytes()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount * chore: update lint configuration to enforce stricter Clippy rules - Removed `#![allow(warnings)]` and `#![allow(clippy::all)]` directives to prevent silencing all lints. - Added `#![deny(clippy::correctness)]` to ensure critical correctness issues are treated as errors. - Enabled warnings for additional Clippy categories: `style`, `complexity`, `perf`, and `cargo`. - Improves code quality by emphasizing best practices, maintainability, and performance. * refactor: fix `cargo check` warnings * refactor: clippy lints * fix(tests): umya-spreadsheet::integration_test issue_172 was failing * style: cargo fmt * deps: update `chrono` crate to v0.4.39 * refactor!: trivial copy pass by ref In many calling conventions instances of structs will be passed through registers if they fit into two or less general purpose registers. This patch removes most of the references used for the basic integer, float and boolean types. Closes #239. --- Cargo.toml | 2 +- README.md | 8 +- src/helper/address.rs | 2 +- src/helper/binary.rs | 5 +- src/helper/color.rs | 82 ++--- src/helper/coordinate.rs | 63 ++-- src/helper/crypt.rs | 213 ++++++------ src/helper/date.rs | 64 ++-- src/helper/formula.rs | 203 +++++------- src/helper/html.rs | 35 +- src/helper/number_format.rs | 79 +++-- src/helper/number_format/date_formater.rs | 6 +- src/helper/number_format/fraction_formater.rs | 24 +- src/helper/number_format/number_formater.rs | 37 ++- .../number_format/percentage_formater.rs | 2 +- src/helper/range.rs | 2 - src/lib.rs | 19 +- src/reader/xlsx.rs | 2 - src/reader/xlsx/pivot_table.rs | 16 +- src/reader/xlsx/styles.rs | 2 - src/reader/xlsx/table.rs | 145 ++++---- src/reader/xlsx/workbook.rs | 20 +- src/reader/xlsx/worksheet.rs | 1 - src/structs/address.rs | 36 +- src/structs/alignment.rs | 4 +- src/structs/anchor.rs | 48 +-- src/structs/auto_filter.rs | 16 +- src/structs/bold.rs | 4 +- src/structs/boolean_value.rs | 6 +- src/structs/borders.rs | 4 +- src/structs/borders_crate.rs | 1 + src/structs/break.rs | 6 +- src/structs/byte_value.rs | 7 +- src/structs/cache_field.rs | 5 +- src/structs/cache_fields.rs | 6 +- src/structs/cache_source.rs | 13 +- src/structs/cell.rs | 65 ++-- src/structs/cell_format.rs | 23 +- src/structs/cell_formula.rs | 80 +++-- src/structs/cell_style.rs | 4 +- src/structs/cell_value.rs | 19 +- src/structs/cells.rs | 61 ++-- src/structs/chart.rs | 66 ++-- src/structs/color.rs | 67 ++-- src/structs/column.rs | 29 +- src/structs/column_breaks.rs | 2 +- src/structs/column_fields.rs | 2 + src/structs/column_items.rs | 2 + src/structs/column_reference.rs | 22 +- src/structs/columns.rs | 30 +- src/structs/comment.rs | 25 +- src/structs/conditional_formatting.rs | 24 +- src/structs/conditional_formatting_rule.rs | 16 +- src/structs/coordinate.rs | 54 +-- src/structs/csv_writer_option.rs | 4 +- .../custom_document_property.rs | 2 +- src/structs/custom_properties/properties.rs | 6 +- src/structs/data_field.rs | 14 +- src/structs/data_fields.rs | 2 + src/structs/data_validation.rs | 6 +- src/structs/defined_name.rs | 41 +-- src/structs/double_value.rs | 7 +- src/structs/drawing/bevel_bottom.rs | 4 +- src/structs/drawing/bevel_top.rs | 4 +- src/structs/drawing/blip.rs | 2 +- src/structs/drawing/blip_fill.rs | 2 +- src/structs/drawing/body_properties.rs | 72 ++-- src/structs/drawing/charts/auto_labeled.rs | 2 +- .../drawing/charts/auto_title_deleted.rs | 2 +- src/structs/drawing/charts/axis_id.rs | 2 +- src/structs/drawing/charts/bubble_3d.rs | 2 +- src/structs/drawing/charts/bubble_scale.rs | 2 +- src/structs/drawing/charts/chart.rs | 16 +- src/structs/drawing/charts/chart_space.rs | 16 +- src/structs/drawing/charts/crossing_axis.rs | 2 +- src/structs/drawing/charts/date1904.rs | 2 +- src/structs/drawing/charts/delete.rs | 2 +- src/structs/drawing/charts/explosion.rs | 2 +- .../drawing/charts/first_slice_angle.rs | 2 +- src/structs/drawing/charts/formula.rs | 16 +- src/structs/drawing/charts/gap_width.rs | 2 +- src/structs/drawing/charts/height.rs | 2 +- src/structs/drawing/charts/hole_size.rs | 2 +- src/structs/drawing/charts/index.rs | 2 +- .../drawing/charts/invert_if_negative.rs | 2 +- src/structs/drawing/charts/label_offset.rs | 2 +- src/structs/drawing/charts/left.rs | 2 +- .../drawing/charts/no_multi_level_labels.rs | 2 +- .../drawing/charts/numbering_format.rs | 2 +- src/structs/drawing/charts/order.rs | 2 +- src/structs/drawing/charts/overlap.rs | 2 +- src/structs/drawing/charts/overlay.rs | 2 +- src/structs/drawing/charts/page_margins.rs | 12 +- src/structs/drawing/charts/perspective.rs | 2 +- src/structs/drawing/charts/plot_area.rs | 16 +- .../drawing/charts/plot_visible_only.rs | 2 +- .../drawing/charts/right_angle_axes.rs | 2 +- src/structs/drawing/charts/rotate_x.rs | 2 +- src/structs/drawing/charts/rotate_y.rs | 2 +- src/structs/drawing/charts/rounded_corners.rs | 2 +- src/structs/drawing/charts/second_pie_size.rs | 2 +- .../drawing/charts/show_bubble_size.rs | 2 +- .../drawing/charts/show_category_name.rs | 2 +- .../charts/show_data_labels_over_maximum.rs | 2 +- .../drawing/charts/show_leader_lines.rs | 2 +- src/structs/drawing/charts/show_legend_key.rs | 2 +- src/structs/drawing/charts/show_marker.rs | 2 +- .../drawing/charts/show_negative_bubbles.rs | 2 +- src/structs/drawing/charts/show_percent.rs | 2 +- .../drawing/charts/show_series_name.rs | 2 +- src/structs/drawing/charts/show_value.rs | 2 +- src/structs/drawing/charts/smooth.rs | 2 +- src/structs/drawing/charts/string_literal.rs | 2 +- src/structs/drawing/charts/string_point.rs | 2 +- src/structs/drawing/charts/style.rs | 2 +- src/structs/drawing/charts/thickness.rs | 2 +- src/structs/drawing/charts/top.rs | 2 +- src/structs/drawing/charts/vary_colors.rs | 2 +- src/structs/drawing/charts/width.rs | 2 +- src/structs/drawing/end_connection.rs | 4 +- src/structs/drawing/extension_list.rs | 4 +- src/structs/drawing/extents.rs | 4 +- src/structs/drawing/fill_rectangle.rs | 16 +- src/structs/drawing/glow.rs | 2 +- src/structs/drawing/gradient_fill.rs | 2 +- src/structs/drawing/gradient_stop.rs | 8 +- src/structs/drawing/graphic.rs | 16 +- src/structs/drawing/graphic_data.rs | 18 +- src/structs/drawing/group_shape_locks.rs | 16 +- src/structs/drawing/linear_gradient_fill.rs | 4 +- src/structs/drawing/list_style.rs | 70 ++-- src/structs/drawing/miter.rs | 2 +- src/structs/drawing/offset.rs | 4 +- src/structs/drawing/outline.rs | 2 +- src/structs/drawing/percentage_type.rs | 2 +- src/structs/drawing/picture_locks.rs | 4 +- src/structs/drawing/point_2d_type.rs | 10 +- .../drawing/positive_fixed_percentage_type.rs | 2 +- src/structs/drawing/positive_size_2d_type.rs | 10 +- src/structs/drawing/rotation.rs | 6 +- src/structs/drawing/run_properties.rs | 2 +- src/structs/drawing/soft_edge.rs | 2 +- src/structs/drawing/source_rectangle.rs | 16 +- src/structs/drawing/spacing_percent.rs | 2 +- src/structs/drawing/spreadsheet/blip_fill.rs | 2 +- src/structs/drawing/spreadsheet/extent.rs | 4 +- .../drawing/spreadsheet/from_marker.rs | 16 +- .../drawing/spreadsheet/graphic_frame.rs | 16 +- .../drawing/spreadsheet/group_shape.rs | 6 +- .../spreadsheet/group_shape_properties.rs | 11 +- .../drawing/spreadsheet/marker_type.rs | 62 ++-- .../non_visual_connection_shape_properties.rs | 2 +- .../non_visual_drawing_properties.rs | 8 +- .../non_visual_graphic_frame_properties.rs | 2 +- ...n_visual_group_shape_drawing_properties.rs | 8 +- .../non_visual_group_shape_properties.rs | 2 +- .../non_visual_picture_drawing_properties.rs | 2 +- .../non_visual_picture_properties.rs | 2 +- .../non_visual_shape_properties.rs | 2 +- .../drawing/spreadsheet/one_cell_anchor.rs | 26 +- src/structs/drawing/spreadsheet/shape.rs | 2 +- src/structs/drawing/spreadsheet/to_marker.rs | 16 +- src/structs/drawing/spreadsheet/transform.rs | 6 +- .../drawing/spreadsheet/two_cell_anchor.rs | 86 +++-- .../drawing/spreadsheet/worksheet_drawing.rs | 98 +++--- src/structs/drawing/start_connection.rs | 4 +- .../drawing/text_paragraph_properties_type.rs | 34 +- src/structs/drawing/transform2d.rs | 14 +- src/structs/embedded_object_properties.rs | 10 +- src/structs/field.rs | 4 +- src/structs/fills.rs | 1 + src/structs/font.rs | 12 +- src/structs/font_char_set.rs | 2 +- src/structs/font_family_numbering.rs | 2 +- src/structs/font_size.rs | 2 +- src/structs/fonts.rs | 1 + src/structs/from_marker.rs | 36 +- src/structs/gradient_fill.rs | 2 +- src/structs/gradient_stop.rs | 2 +- src/structs/hyperlink.rs | 4 +- src/structs/image.rs | 140 ++++---- src/structs/int16_value.rs | 7 +- src/structs/int32_value.rs | 7 +- src/structs/int64_value.rs | 7 +- src/structs/italic.rs | 4 +- src/structs/location.rs | 7 +- src/structs/media_object.rs | 4 +- src/structs/member_property_index.rs | 2 +- src/structs/merge_cells.rs | 4 +- src/structs/numbering_format.rs | 12 +- src/structs/numbering_formats.rs | 13 +- src/structs/object_anchor.rs | 10 +- src/structs/office/excel/formula.rs | 11 +- .../office/excel/reference_sequence.rs | 12 +- .../office2010/excel/data_validation.rs | 26 +- .../excel/data_validation_forumla1.rs | 20 +- .../excel/data_validation_forumla2.rs | 20 +- .../office2010/excel/data_validations.rs | 8 +- src/structs/ole_object.rs | 9 +- src/structs/ole_objects.rs | 10 +- src/structs/page_margins.rs | 12 +- src/structs/page_setup.rs | 14 +- src/structs/pane.rs | 4 +- src/structs/pivot_cache_definition.rs | 25 +- src/structs/pivot_field.rs | 11 +- src/structs/pivot_fields.rs | 6 +- src/structs/pivot_table.rs | 7 - src/structs/pivot_table_definition.rs | 45 +-- src/structs/pivot_table_style.rs | 18 +- src/structs/print_options.rs | 4 +- src/structs/properties.rs | 27 +- src/structs/protection.rs | 5 +- src/structs/range.rs | 24 +- src/structs/raw/raw_relationships.rs | 12 +- src/structs/raw/raw_worksheet.rs | 2 +- src/structs/rich_text.rs | 2 +- src/structs/row.rs | 32 +- src/structs/row_breaks.rs | 2 +- src/structs/row_item.rs | 6 +- src/structs/row_items.rs | 5 +- src/structs/row_reference.rs | 20 +- src/structs/rows.rs | 14 +- src/structs/s_byte_value.rs | 4 +- src/structs/sequence_of_references.rs | 24 +- src/structs/shared_items.rs | 14 +- src/structs/shared_string_item.rs | 2 +- src/structs/shared_string_table.rs | 3 +- src/structs/sheet_format_properties.rs | 24 +- src/structs/sheet_protection.rs | 37 +-- src/structs/sheet_view.rs | 18 +- src/structs/spreadsheet.rs | 80 ++--- src/structs/strike.rs | 4 +- src/structs/style.rs | 6 +- src/structs/stylesheet.rs | 40 +-- src/structs/tab_color.rs | 6 +- src/structs/table.rs | 21 +- src/structs/text_element.rs | 1 + src/structs/to_marker.rs | 36 +- src/structs/true_false_blank_value.rs | 8 +- src/structs/true_false_value.rs | 4 +- src/structs/u_int16_value.rs | 4 +- src/structs/u_int32_value.rs | 4 +- src/structs/vml/fill.rs | 10 +- src/structs/vml/image_data.rs | 8 +- src/structs/vml/shadow.rs | 4 +- src/structs/vml/shape.rs | 24 +- src/structs/vml/spreadsheet/anchor.rs | 104 +++--- src/structs/vml/spreadsheet/auto_fill.rs | 2 +- .../vml/spreadsheet/auto_size_picture.rs | 2 +- src/structs/vml/spreadsheet/client_data.rs | 44 +-- .../vml/spreadsheet/comment_column_target.rs | 14 +- .../vml/spreadsheet/comment_row_target.rs | 20 +- .../vml/spreadsheet/move_with_cells.rs | 2 +- .../vml/spreadsheet/resize_with_cells.rs | 2 +- src/structs/vml/spreadsheet/visible.rs | 2 +- src/structs/workbook_protection.rs | 13 +- src/structs/workbook_view.rs | 2 +- src/structs/worksheet.rs | 313 +++++++++--------- src/structs/worksheet_source.rs | 3 +- src/structs/writer_manager.rs | 14 +- src/traits.rs | 4 + src/traits/adjustment_coordinate.rs | 25 +- .../adjustment_coordinate_with_2sheet.rs | 26 +- .../adjustment_coordinate_with_sheet.rs | 25 +- src/traits/adjustment_value.rs | 7 +- src/writer/csv.rs | 4 +- src/writer/driver.rs | 20 +- src/writer/xlsx.rs | 7 +- src/writer/xlsx/chart.rs | 12 +- src/writer/xlsx/comment.rs | 12 +- src/writer/xlsx/content_types.rs | 16 +- src/writer/xlsx/doc_props_app.rs | 12 +- src/writer/xlsx/doc_props_core.rs | 12 +- src/writer/xlsx/doc_props_custom.rs | 12 +- src/writer/xlsx/drawing.rs | 12 +- src/writer/xlsx/drawing_rels.rs | 20 +- src/writer/xlsx/rels.rs | 17 +- src/writer/xlsx/shared_strings.rs | 12 +- src/writer/xlsx/styles.rs | 12 +- src/writer/xlsx/table.rs | 34 +- src/writer/xlsx/theme.rs | 12 +- src/writer/xlsx/vml_drawing.rs | 8 +- src/writer/xlsx/vml_drawing_rels.rs | 18 +- src/writer/xlsx/workbook.rs | 14 +- src/writer/xlsx/workbook_rels.rs | 16 +- src/writer/xlsx/worksheet.rs | 35 +- src/writer/xlsx/worksheet_rels.rs | 14 +- tests/integration_test.rs | 201 ++++++----- 288 files changed, 2397 insertions(+), 2627 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3c9270d1..ab6c07e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ base64 = "0.22.1" byteorder = "1.5" cbc = "0.1.2" cfb = "0.10.0" -chrono = { version = "0.4.38", default-features = false, features = ["clock"] } +chrono = { version = "0.4.39", default-features = false, features = ["clock"] } encoding_rs = "0.8.35" fancy-regex = "0.14.0" getrandom = { version = "0.2.15" } diff --git a/README.md b/README.md index 13871177..90c7e279 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,14 @@ Please be aware of this. Copies the style of the specified column or row. ```rust let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); -let sheet = book.get_sheet_mut(&0).unwrap(); +let sheet = book.get_sheet_mut(0).unwrap(); sheet.copy_row_styling(&3, &5, None, None); sheet.copy_col_styling(&3, &5, None, None); ``` #### * The function to create a new comment has been implemented. ```rust let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); -let sheet = book.get_sheet_mut(&0).unwrap(); +let sheet = book.get_sheet_mut(0).unwrap(); let mut comment = Comment::default(); comment.new_comment("B2"); comment.set_text_string("TEST"); @@ -94,8 +94,8 @@ let _ = umya_spreadsheet::writer::xlsx::set_password(&from_path, &to_path, "pass let mut book = umya_spreadsheet::new_file(); book.get_sheet_by_name("Sheet1").unwrap().get_cell("A1").get_value(); book.get_sheet_by_name("Sheet1").unwrap().get_cell((1, 1)).get_value(); -book.get_sheet_by_name("Sheet1").unwrap().get_cell((&1, &1)).get_value(); -book.get_sheet_mut(0).unwrap().get_cell((&1, &1)).get_value(); +book.get_sheet_by_name("Sheet1").unwrap().get_cell((1, 1)).get_value(); +book.get_sheet_mut(0).unwrap().get_cell((1, 1)).get_value(); ``` ### Change Value ```rust diff --git a/src/helper/address.rs b/src/helper/address.rs index 69de88d5..1189d820 100644 --- a/src/helper/address.rs +++ b/src/helper/address.rs @@ -8,7 +8,7 @@ pub fn split_address(address: &str) -> (&str, &str) { } pub fn join_address(sheet_name: &str, address: &str) -> String { - if sheet_name == "" { + if sheet_name.is_empty() { return address.to_string(); } format!("{}!{}", sheet_name, address) diff --git a/src/helper/binary.rs b/src/helper/binary.rs index 2d11c908..f067e954 100644 --- a/src/helper/binary.rs +++ b/src/helper/binary.rs @@ -1,9 +1,6 @@ use crate::structs::MediaObject; -use base64::{engine::general_purpose::STANDARD, Engine as _}; -use std::fs; use std::fs::File; use std::io::BufReader; -use std::io::Cursor; use std::io::Read; #[inline] @@ -13,7 +10,7 @@ pub fn get_binary_data(path: &str) -> Vec { let file = File::open(path).unwrap(); BufReader::new(file).read_to_end(&mut buf).unwrap(); - return buf; + buf } #[inline] diff --git a/src/helper/color.rs b/src/helper/color.rs index eb670fa0..dd140396 100644 --- a/src/helper/color.rs +++ b/src/helper/color.rs @@ -19,47 +19,41 @@ pub struct MsHlsColor { const RGBMAX: f64 = 255.0; const HLSMAX: f64 = 255.0; -pub fn calc_tint(rgb: &str, tint: &f64) -> String { +pub fn calc_tint(rgb: &str, tint: f64) -> String { let mut ms_hls = convert_rgb_to_ms_hls(rgb); - ms_hls.l = calculate_final_lum_value(tint, &(ms_hls.l as f64)); + ms_hls.l = calculate_final_lum_value(tint, ms_hls.l as f64); convert_ms_hls_to_rgb(&ms_hls) } -pub fn calculate_final_lum_value(tint: &f64, lum: &f64) -> i32 { - let mut lum1 = 0.0; - - if tint < &0.0 { - lum1 = lum * (1.0 + tint); +pub fn calculate_final_lum_value(tint: f64, lum: f64) -> i32 { + let lum1 = if tint < 0.0 { + lum * (1.0 + tint) } else { - lum1 = lum * (1.0 - tint) + (HLSMAX - HLSMAX * (1.0 - tint)); - } + lum * (1.0 - tint) + (HLSMAX - HLSMAX * (1.0 - tint)) + }; - return to_i32(lum1); + to_i32(lum1) } pub fn split_rgb(rgb: &str) -> (i32, i32, i32) { - let r_str = rgb.chars().skip(0).take(2).collect::(); - let g_str = rgb.chars().skip(2).take(2).collect::(); - let b_str = rgb.chars().skip(4).take(2).collect::(); - let r = i32::from_str_radix(&r_str, 16).unwrap(); - let g = i32::from_str_radix(&g_str, 16).unwrap(); - let b = i32::from_str_radix(&b_str, 16).unwrap(); + let r = i32::from_str_radix(&rgb[0..2], 16).unwrap(); + let g = i32::from_str_radix(&rgb[2..4], 16).unwrap(); + let b = i32::from_str_radix(&rgb[4..6], 16).unwrap(); (r, g, b) } #[inline] -pub fn join_rgb(r: &i32, g: &i32, b: &i32) -> String { +pub fn join_rgb(r: i32, g: i32, b: i32) -> String { format!("{:02X}{:02X}{:02X}", r, g, b) } pub fn convert_rgb_to_ms_hls(rgb: &str) -> MsHlsColor { let hls = convert_rgb_to_hls(rgb); - - let mut ms_hls = MsHlsColor::default(); - ms_hls.h = to_i32(hls.h * self::HLSMAX); - ms_hls.l = to_i32(hls.l * self::HLSMAX); - ms_hls.s = to_i32(hls.s * self::HLSMAX); - ms_hls + MsHlsColor { + h: to_i32(hls.h * self::HLSMAX), + l: to_i32(hls.l * self::HLSMAX), + s: to_i32(hls.s * self::HLSMAX), + } } pub fn convert_rgb_to_hls(rgb: &str) -> HlsColor { @@ -116,23 +110,24 @@ pub fn convert_rgb_to_hls(rgb: &str) -> HlsColor { hls.h = 4.0 + gc - rc; } - hls.h = positive_decimal_part(&(hls.h / 6.0)); + hls.h = positive_decimal_part(hls.h / 6.0); - return hls; + hls } pub fn convert_ms_hls_to_rgb(ms_hls: &MsHlsColor) -> String { - let mut hls = HlsColor::default(); - hls.h = ms_hls.h as f64 / self::HLSMAX; - hls.l = ms_hls.l as f64 / self::HLSMAX; - hls.s = ms_hls.s as f64 / self::HLSMAX; + let hls = HlsColor { + h: (ms_hls.h as f64 / self::HLSMAX), + l: (ms_hls.l as f64 / self::HLSMAX), + s: (ms_hls.s as f64 / self::HLSMAX), + }; convert_hls_to_rgb(&hls) } pub fn convert_hls_to_rgb(hls: &HlsColor) -> String { if hls.s == 0.0 { let rtn_l = to_i32(hls.l * RGBMAX); - return join_rgb(&rtn_l, &rtn_l, &rtn_l); + return join_rgb(rtn_l, rtn_l, rtn_l); } let t1 = if hls.l < 0.5 { @@ -144,39 +139,34 @@ pub fn convert_hls_to_rgb(hls: &HlsColor) -> String { let t2 = 2.0 * hls.l - t1; let h = hls.h; let t_r = h + (1.0 / 3.0); - let r = set_color(&t1, &t2, &t_r); + let r = set_color(t1, t2, t_r); let t_g = h; - let g = set_color(&t1, &t2, &t_g); + let g = set_color(t1, t2, t_g); let t_b = h - (1.0 / 3.0); - let b = set_color(&t1, &t2, &t_b); + let b = set_color(t1, t2, t_b); let rtn_r = to_i32(r * RGBMAX); let rtn_g = to_i32(g * RGBMAX); let rtn_b = to_i32(b * RGBMAX); - join_rgb(&rtn_r, &rtn_g, &rtn_b) + join_rgb(rtn_r, rtn_g, rtn_b) } -pub fn set_color(t1: &f64, t2: &f64, t3: &f64) -> f64 { - let mut t1 = t1.clone(); - let mut t2 = t2.clone(); - let mut t3 = positive_decimal_part(t3); - - let mut color: f64 = 0.0; +pub fn set_color(t1: f64, t2: f64, t3: f64) -> f64 { + let t3 = positive_decimal_part(t3); if 6.0 * t3 < 1.0 { - color = t2 + (t1 - t2) * 6.0 * t3; + t2 + (t1 - t2) * 6.0 * t3 } else if 2.0 * t3 < 1.0 { - color = t1; + t1 } else if 3.0 * t3 < 2.0 { - color = t2 + (t1 - t2) * ((2.0 / 3.0) - t3) * 6.0; + t2 + (t1 - t2) * ((2.0 / 3.0) - t3) * 6.0 } else { - color = t2; + t2 } - color } #[inline] -fn positive_decimal_part(hue: &f64) -> f64 { +fn positive_decimal_part(hue: f64) -> f64 { let hue = hue % 1.0; if hue >= 0.0 { diff --git a/src/helper/coordinate.rs b/src/helper/coordinate.rs index 33a4496b..96620bb1 100644 --- a/src/helper/coordinate.rs +++ b/src/helper/coordinate.rs @@ -53,10 +53,10 @@ pub fn column_index_from_string>(column: S) -> u32 { } #[inline] -pub fn string_from_column_index(column_index: &u32) -> String { - assert!(column_index >= &1u32, "Column number starts from 1."); +pub fn string_from_column_index(column_index: u32) -> String { + assert!(column_index >= 1u32, "Column number starts from 1."); - index_to_alpha(*column_index) + index_to_alpha(column_index) } /// @@ -94,47 +94,47 @@ where } #[inline] -pub fn coordinate_from_index(col: &u32, row: &u32) -> String { +pub fn coordinate_from_index(col: u32, row: u32) -> String { format!("{}{}", string_from_column_index(col), row) } pub fn coordinate_from_index_with_lock( - col: &u32, - row: &u32, - is_lock_col: &bool, - is_lock_row: &bool, + col: u32, + row: u32, + is_lock_col: bool, + is_lock_row: bool, ) -> String { format!( "{}{}{}{}", - if *is_lock_col { "$" } else { "" }, + if is_lock_col { "$" } else { "" }, string_from_column_index(col), - if *is_lock_row { "$" } else { "" }, + if is_lock_row { "$" } else { "" }, row ) } #[inline] -pub(crate) fn adjustment_insert_coordinate(num: &u32, root_num: &u32, offset_num: &u32) -> u32 { - if (num >= root_num && offset_num != &0) { +pub(crate) fn adjustment_insert_coordinate(num: u32, root_num: u32, offset_num: u32) -> u32 { + if num >= root_num && offset_num != 0 { num + offset_num } else { - *num + num } } #[inline] -pub(crate) fn adjustment_remove_coordinate(num: &u32, root_num: &u32, offset_num: &u32) -> u32 { - if (num >= root_num && offset_num != &0) { +pub(crate) fn adjustment_remove_coordinate(num: u32, root_num: u32, offset_num: u32) -> u32 { + if num >= root_num && offset_num != 0 { num - offset_num } else { - *num + num } } #[inline] -pub(crate) fn is_remove_coordinate(num: &u32, root_num: &u32, offset_num: &u32) -> bool { - if root_num != &0 && offset_num != &0 { - return num >= root_num && num < &(root_num + offset_num); +pub(crate) fn is_remove_coordinate(num: u32, root_num: u32, offset_num: u32) -> bool { + if root_num != 0 && offset_num != 0 { + return num >= root_num && num < (root_num + offset_num); } false } @@ -162,13 +162,6 @@ impl From<(u32, u32)> for CellCoordinates { } } -impl From<(&u32, &u32)> for CellCoordinates { - #[inline] - fn from(value: (&u32, &u32)) -> Self { - CellCoordinates::new(*value.0, *value.1) - } -} - impl From for CellCoordinates { #[inline] fn from(value: String) -> Self { @@ -205,15 +198,15 @@ mod tests { #[test] fn string_from_column_index_1() { - assert_eq!(string_from_column_index(&1), String::from("A")); - assert_eq!(string_from_column_index(&26), String::from("Z")); - assert_eq!(string_from_column_index(&27), String::from("AA")); - assert_eq!(string_from_column_index(&28), String::from("AB")); - assert_eq!(string_from_column_index(&53), String::from("BA")); - assert_eq!(string_from_column_index(&702), String::from("ZZ")); - assert_eq!(string_from_column_index(&703), String::from("AAA")); - assert_eq!(string_from_column_index(&8160), String::from("LAV")); - assert_eq!(string_from_column_index(&16384), String::from("XFD")); + assert_eq!(string_from_column_index(1), String::from("A")); + assert_eq!(string_from_column_index(26), String::from("Z")); + assert_eq!(string_from_column_index(27), String::from("AA")); + assert_eq!(string_from_column_index(28), String::from("AB")); + assert_eq!(string_from_column_index(53), String::from("BA")); + assert_eq!(string_from_column_index(702), String::from("ZZ")); + assert_eq!(string_from_column_index(703), String::from("AAA")); + assert_eq!(string_from_column_index(8160), String::from("LAV")); + assert_eq!(string_from_column_index(16384), String::from("XFD")); } #[test] diff --git a/src/helper/crypt.rs b/src/helper/crypt.rs index 2e7847c9..8e90d90c 100644 --- a/src/helper/crypt.rs +++ b/src/helper/crypt.rs @@ -36,7 +36,7 @@ pub fn encrypt_sheet_protection(password: &str, sheet_protection: &mut SheetProt password, key_hash_algorithm, &key_salt_value, - &key_spin_count, + key_spin_count, ); let salt_value_str = STANDARD.encode(key_salt_value); @@ -58,7 +58,7 @@ pub fn encrypt_workbook_protection(password: &str, workbook_protection: &mut Wor password, key_hash_algorithm, &key_salt_value, - &key_spin_count, + key_spin_count, ); let salt_value_str = STANDARD.encode(key_salt_value); @@ -80,7 +80,7 @@ pub fn encrypt_revisions_protection(password: &str, workbook_protection: &mut Wo password, key_hash_algorithm, &key_salt_value, - &key_spin_count, + key_spin_count, ); let salt_value_str = STANDARD.encode(key_salt_value); @@ -116,11 +116,11 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { // encrypted_package let encrypted_package = crypt_package( - &true, + true, package_cipher_algorithm, package_cipher_chaining, package_hash_algorithm, - &package_block_size, + package_block_size, &package_salt_value, &package_key, data, @@ -131,11 +131,11 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { let hmac_key_iv = create_iv( package_hash_algorithm, &package_salt_value, - &package_block_size, - &BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY.to_vec(), + package_block_size, + BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY, ); let encrypted_hmac_key = crypt( - &true, + true, package_cipher_algorithm, package_cipher_chaining, &package_key, @@ -149,11 +149,11 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { let hmac_value_iv = create_iv( package_hash_algorithm, &package_salt_value, - &package_block_size, - &BLOCK_KEYS_DATA_INTEGRITY_HMAC_VALUE.to_vec(), + package_block_size, + BLOCK_KEYS_DATA_INTEGRITY_HMAC_VALUE, ); let encrypted_hmac_value = crypt( - &true, + true, package_cipher_algorithm, package_cipher_chaining, &package_key, @@ -167,12 +167,12 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { password, key_hash_algorithm, &key_salt_value, - &key_spin_count, - &key_key_bits, - &BLOCK_KEYS_KEY.to_vec(), + key_spin_count, + key_key_bits, + BLOCK_KEYS_KEY, ); let encrypted_key_value = crypt( - &true, + true, key_cipher_algorithm, key_cipher_chaining, &key, @@ -187,12 +187,12 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { password, key_hash_algorithm, &key_salt_value, - &key_spin_count, - &key_key_bits, - &BLOCK_VERIFIER_HASH_INPUT.to_vec(), + key_spin_count, + key_key_bits, + BLOCK_VERIFIER_HASH_INPUT, ); let encrypted_verifier_hash_input = crypt( - &true, + true, key_cipher_algorithm, key_cipher_chaining, &verifier_hash_input_key, @@ -207,12 +207,12 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { password, key_hash_algorithm, &key_salt_value, - &key_spin_count, - &key_key_bits, - &BLOCK_VERIFIER_HASH_VALUE.to_vec(), + key_spin_count, + key_key_bits, + BLOCK_VERIFIER_HASH_VALUE, ); let encrypted_verifier_hash_value = crypt( - &true, + true, key_cipher_algorithm, key_cipher_chaining, &verifier_hash_value_key, @@ -224,19 +224,19 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { // XML let encryption_info_buffer = build_encryption_info( &package_salt_value, - &package_block_size, - &package_key_bits, - &package_hash_size, + package_block_size, + package_key_bits, + package_hash_size, package_cipher_algorithm, package_cipher_chaining, package_hash_algorithm, &encrypted_hmac_key, &encrypted_hmac_value, - &key_spin_count, + key_spin_count, &key_salt_value, - &key_block_size, - &key_key_bits, - &key_hash_size, + key_block_size, + key_key_bits, + key_hash_size, key_cipher_algorithm, key_cipher_chaining, key_hash_algorithm, @@ -259,18 +259,18 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { // Encrypt/decrypt the package #[allow(clippy::too_many_arguments)] fn crypt_package( - encrypt: &bool, + encrypt: bool, cipher_algorithm: &str, cipher_chaining: &str, hash_algorithm: &str, - block_size: &usize, + block_size: usize, salt_value: &[u8], key: &[u8], input: &[u8], ) -> Vec { // The first 8 bytes is supposed to be the length, but it seems like it is really the length - 4.. let mut output_chunks: Vec> = Vec::new(); - let offset = if encrypt == &true { 0 } else { PACKAGE_OFFSET }; + let offset = if encrypt { 0 } else { PACKAGE_OFFSET }; // The package is encoded in chunks. Encrypt/decrypt each and concat. let mut i: usize = 0; @@ -294,7 +294,7 @@ fn crypt_package( // Create the initialization vector // Create the block key from the current index - let block_key_buffer = create_uint32_le_buffer(&(i as u32), None); + let block_key_buffer = create_uint32_le_buffer(i as u32, None); let iv = create_iv(hash_algorithm, salt_value, block_size, &block_key_buffer); // Encrypt/decrypt the chunk and add it to the array @@ -316,16 +316,16 @@ fn crypt_package( let output_chunks_as: Vec<_> = output_chunks.iter().map(AsRef::as_ref).collect(); let mut output = buffer_concat(output_chunks_as); - if *encrypt { + if encrypt { // Put the length of the package in the first 8 bytes let input_len = input.len(); output = buffer_concat(vec![ - &create_uint32_le_buffer(&(input_len as u32), Some(&PACKAGE_OFFSET)), + &create_uint32_le_buffer(input_len as u32, Some(PACKAGE_OFFSET)), &output, ]); } else { // Truncate the buffer to the size in the prefix - let length = buffer_read_u_int32_le(input, &0); + let length = buffer_read_u_int32_le(input, 0); output = output[0..length as usize].to_vec(); } @@ -336,20 +336,20 @@ fn crypt_package( fn create_iv( hash_algorithm: &str, salt_value: &[u8], - block_size: &usize, + block_size: usize, block_key: &[u8], ) -> Vec { // Create the initialization vector by hashing the salt with the block key. // Truncate or pad as needed to meet the block size. let mut iv = hash(hash_algorithm, vec![salt_value, block_key]).unwrap(); - match iv.len().cmp(block_size) { + match iv.len().cmp(&block_size) { Ordering::Less => { - let mut tmp = buffer_alloc(0x36, *block_size); + let mut tmp = buffer_alloc(0x36, block_size); buffer_copy(&mut tmp, &iv); iv = tmp; } Ordering::Greater => { - iv = buffer_slice(&iv, 0, *block_size); + iv = buffer_slice(&iv, 0, block_size); } _ => {} } @@ -358,7 +358,7 @@ fn create_iv( // Encrypt/decrypt input fn crypt( - _encrypt: &bool, + _encrypt: bool, _cipher_algorithm: &str, _cipher_chaining: &str, key: &[u8], @@ -400,8 +400,8 @@ fn convert_password_to_key( password: &str, hash_algorithm: &str, salt_value: &[u8], - spin_count: &usize, - key_bits: &usize, + spin_count: usize, + key_bits: usize, block_key: &[u8], ) -> Vec { // Password must be in unicode buffer @@ -417,8 +417,8 @@ fn convert_password_to_key( let mut key = hash(hash_algorithm, vec![salt_value, &password_buffer]).unwrap(); // Now regenerate until spin count - for i in 0..*spin_count { - let iterator = create_uint32_le_buffer(&(i as u32), None); + for i in 0..spin_count { + let iterator = create_uint32_le_buffer(i as u32, None); key = hash(hash_algorithm, vec![&iterator, &key]).unwrap(); } @@ -442,7 +442,7 @@ fn convert_password_to_hash( password: &str, hash_algorithm: &str, salt_value: &[u8], - spin_count: &usize, + spin_count: usize, ) -> Vec { // Password must be in unicode buffer let mut password_buffer: Vec = Vec::new(); @@ -457,8 +457,8 @@ fn convert_password_to_hash( let mut key = hash(hash_algorithm, vec![salt_value, &password_buffer]).unwrap(); // Now regenerate until spin count - for i in 0..*spin_count { - let iterator = create_uint32_le_buffer(&(i as u32), None); + for i in 0..spin_count { + let iterator = create_uint32_le_buffer(i as u32, None); key = hash(hash_algorithm, vec![&key, &iterator]).unwrap(); } @@ -480,49 +480,49 @@ fn hash(algorithm: &str, buffers: Vec<&[u8]>) -> Result, String> { #[inline] fn gen_random_16() -> Vec { let buf: &mut [u8] = &mut [0; 16]; - getrandom::getrandom(buf); + getrandom::getrandom(buf).unwrap(); buf.to_vec() } #[inline] fn gen_random_32() -> Vec { let buf: &mut [u8] = &mut [0; 32]; - getrandom::getrandom(buf); + getrandom::getrandom(buf).unwrap(); buf.to_vec() } #[inline] fn gen_random_64() -> Vec { let buf: &mut [u8] = &mut [0; 64]; - getrandom::getrandom(buf); + getrandom::getrandom(buf).unwrap(); buf.to_vec() } // Create a buffer of an integer encoded as a uint32le #[inline] -fn create_uint32_le_buffer(value: &u32, buffer_size: Option<&usize>) -> Vec { - let bs_prm = buffer_size.unwrap_or(&4); - let mut buffer = buffer_alloc(0, *bs_prm); - buffer_write_u_int32_le(&mut buffer, value, &0); +fn create_uint32_le_buffer(value: u32, buffer_size: Option) -> Vec { + let bs_prm = buffer_size.unwrap_or(4); + let mut buffer = buffer_alloc(0, bs_prm); + buffer_write_u_int32_le(&mut buffer, value, 0); buffer } #[allow(clippy::too_many_arguments)] fn build_encryption_info( package_salt_value: &[u8], - package_block_size: &usize, - package_key_bits: &usize, - package_hash_size: &usize, + package_block_size: usize, + package_key_bits: usize, + package_hash_size: usize, package_cipher_algorithm: &str, package_cipher_chaining: &str, package_hash_algorithm: &str, data_integrity_encrypted_hmac_key: &[u8], data_integrity_encrypted_hmac_value: &[u8], - key_spin_count: &usize, + key_spin_count: usize, key_salt_value: &[u8], - key_block_size: &usize, - key_key_bits: &usize, - key_hash_size: &usize, + key_block_size: usize, + key_key_bits: usize, + key_hash_size: usize, key_cipher_algorithm: &str, key_cipher_chaining: &str, key_hash_algorithm: &str, @@ -532,11 +532,13 @@ fn build_encryption_info( ) -> Vec { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // Map the object into the appropriate XML structure. Buffers are encoded in base 64. @@ -632,7 +634,7 @@ fn build_encryption_info( write_end_tag(&mut writer, "encryption"); let result = writer.into_inner().into_inner().to_vec(); - buffer_concat(vec![&ENCRYPTION_INFO_PREFIX.to_vec(), &result]) + buffer_concat(vec![ENCRYPTION_INFO_PREFIX, &result]) } #[inline] @@ -654,18 +656,18 @@ fn buffer_concat(buffers: Vec<&[u8]>) -> Vec { } fn buffer_copy(buffer1: &mut [u8], buffer2: &[u8]) { for (i, byte) in buffer2.iter().enumerate() { - std::mem::replace(&mut buffer1[i], *byte); + let _ = std::mem::replace(&mut buffer1[i], *byte); } } #[inline] -fn buffer_read_u_int32_le(buffer: &[u8], _cnt: &usize) -> u32 { +fn buffer_read_u_int32_le(buffer: &[u8], _cnt: usize) -> u32 { LittleEndian::read_u32(buffer) } #[inline] -fn buffer_write_u_int32_le(buffer: &mut [u8], value: &u32, _cnt: &usize) { - LittleEndian::write_u32(buffer, *value); +fn buffer_write_u_int32_le(buffer: &mut [u8], value: u32, _cnt: usize) { + LittleEndian::write_u32(buffer, value); } #[cfg(test)] @@ -721,11 +723,11 @@ mod tests { // encrypted_package let encrypted_package = crypt_package( - &true, + true, package_cipher_algorithm, package_cipher_chaining, package_hash_algorithm, - &package_block_size, + package_block_size, &package_salt_value, &package_key, &data, @@ -736,14 +738,14 @@ mod tests { let hmac_key_iv = create_iv( package_hash_algorithm, &package_salt_value, - &package_block_size, - &BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY.to_vec(), + package_block_size, + BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY, ); let converted = encode_hex(&hmac_key_iv); assert_eq!(&converted, "ba1bf00eed82b07ee65e574eb1f46043"); let encrypted_hmac_key = crypt( - &true, + true, package_cipher_algorithm, package_cipher_chaining, &package_key, @@ -762,14 +764,14 @@ mod tests { let hmac_value_iv = create_iv( package_hash_algorithm, &package_salt_value, - &package_block_size, - &BLOCK_KEYS_DATA_INTEGRITY_HMAC_VALUE.to_vec(), + package_block_size, + BLOCK_KEYS_DATA_INTEGRITY_HMAC_VALUE, ); let converted = encode_hex(&hmac_value_iv); assert_eq!(&converted, "088385b871292e7ed8414f173c5b6622"); let encrypted_hmac_value = crypt( - &true, + true, package_cipher_algorithm, package_cipher_chaining, &package_key, @@ -785,9 +787,9 @@ mod tests { password, key_hash_algorithm, &key_salt_value, - &key_spin_count, - &key_key_bits, - &BLOCK_KEYS_KEY.to_vec(), + key_spin_count, + key_key_bits, + BLOCK_KEYS_KEY, ); let converted = encode_hex(&key); assert_eq!( @@ -796,7 +798,7 @@ mod tests { ); let encrypted_key_value = crypt( - &true, + true, key_cipher_algorithm, key_cipher_chaining, &key, @@ -816,9 +818,9 @@ mod tests { password, key_hash_algorithm, &key_salt_value, - &key_spin_count, - &key_key_bits, - &BLOCK_VERIFIER_HASH_INPUT.to_vec(), + key_spin_count, + key_key_bits, + BLOCK_VERIFIER_HASH_INPUT, ); let converted = encode_hex(&verifier_hash_input_key); assert_eq!( @@ -827,7 +829,7 @@ mod tests { ); let encrypted_verifier_hash_input = crypt( - &true, + true, key_cipher_algorithm, key_cipher_chaining, &verifier_hash_input_key, @@ -847,15 +849,15 @@ mod tests { password, key_hash_algorithm, &key_salt_value, - &key_spin_count, - &key_key_bits, - &BLOCK_VERIFIER_HASH_VALUE.to_vec(), + key_spin_count, + key_key_bits, + BLOCK_VERIFIER_HASH_VALUE, ); //let converted = encode_hex(&verifier_hash_value_key); //assert_eq!(&converted, "d5515a6062e3e99551b80b92db1fe646483884cdb63e1e7595a9f2cca7532884"); let encrypted_verifier_hash_value = crypt( - &true, + true, key_cipher_algorithm, key_cipher_chaining, &verifier_hash_value_key, @@ -869,19 +871,19 @@ mod tests { // XML let _ = build_encryption_info( &package_salt_value, - &package_block_size, - &package_key_bits, - &package_hash_size, + package_block_size, + package_key_bits, + package_hash_size, package_cipher_algorithm, package_cipher_chaining, package_hash_algorithm, &encrypted_hmac_key, &encrypted_hmac_value, - &key_spin_count, + key_spin_count, &key_salt_value, - &key_block_size, - &key_key_bits, - &key_hash_size, + key_block_size, + key_key_bits, + key_hash_size, key_cipher_algorithm, key_cipher_chaining, key_hash_algorithm, @@ -896,10 +898,7 @@ mod tests { let package_salt_value = decode_hex("4c251b321d85cecfcb6d952ba6d81846").unwrap(); let result = hash( "SHA512", - vec![ - &package_salt_value, - &BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY.to_vec(), - ], + vec![&package_salt_value, BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY], ) .unwrap(); let converted = encode_hex(&result); @@ -923,9 +922,9 @@ mod tests { "password", "SHA512", &key_salt_value, - &100000, - &256, - &BLOCK_KEYS_KEY.to_vec(), + 100000, + 256, + BLOCK_KEYS_KEY, ); let converted = encode_hex(&result); assert_eq!( diff --git a/src/helper/date.rs b/src/helper/date.rs index 049f4767..c07066c9 100644 --- a/src/helper/date.rs +++ b/src/helper/date.rs @@ -3,21 +3,18 @@ use chrono::{Duration, NaiveDateTime}; pub const CALENDAR_WINDOWS_1900: &str = "1900"; pub const CALENDAR_MAC_1904: &str = "1904"; -pub fn excel_to_date_time_object( - excel_timestamp: &f64, - time_zone: Option, -) -> NaiveDateTime { +pub fn excel_to_date_time_object(excel_timestamp: f64, time_zone: Option) -> NaiveDateTime { let _time_zone = match time_zone { Some(v) => v, None => get_default_timezone(), }; - let mut base_date = if excel_timestamp < &1f64 { + let base_date = if excel_timestamp < 1f64 { // Unix timestamp base date NaiveDateTime::parse_from_str("1970-01-01 00:00:00", "%Y-%m-%d %T").unwrap() } else { // Allow adjustment for 1900 Leap Year in MS Excel - if excel_timestamp < &60f64 { + if excel_timestamp < 60f64 { NaiveDateTime::parse_from_str("1899-12-31 00:00:00", "%Y-%m-%d %T").unwrap() } else { NaiveDateTime::parse_from_str("1899-12-30 00:00:00", "%Y-%m-%d %T").unwrap() @@ -80,7 +77,7 @@ pub fn convert_date_mac_1904( convert_date_crate(year, month, day, hours, minutes, seconds, false) } -fn convert_date_crate( +pub fn convert_date_crate( year: i32, month: i32, day: i32, @@ -89,41 +86,36 @@ fn convert_date_crate( seconds: i32, is_calendar_windows_1900: bool, ) -> f64 { - let mut year = year; - let mut month = month; - let mut myexcel_base_date = 0; - let mut excel1900is_leap_year = 0; - - if is_calendar_windows_1900 { - excel1900is_leap_year = 1; - if &year == &1900 && &month <= &2 { - excel1900is_leap_year = 0; - } - myexcel_base_date = 2415020; + // Initialize the base date and leap year for the calendar + let (base_date, is_leap_year) = if is_calendar_windows_1900 { + let is_leap = if year == 1900 && month <= 2 { 0 } else { 1 }; + (2415020, is_leap) } else { - myexcel_base_date = 2416481; - } + (2416481, 0) + }; - // Julian base date Adjustment - if month > 2 { - month -= 3; + // Adjust month and year for Julian date calculation + let (year_adj, month_adj) = if month > 2 { + (year, month - 3) } else { - month += 9; - year -= 1; - } + (year - 1, month + 9) + }; - // Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0) - let century = (year.to_string()[0..2]).parse::().unwrap(); - let decade = (year.to_string()[2..4]).parse::().unwrap(); + // Calculate the Julian date components + let century = year_adj / 100; + let decade = year_adj % 100; - let excel_date = ((146097 * century) / 4) as i32 - + ((1461 * decade) / 4) as i32 - + ((153 * month + 2) / 5) as i32 + let julian_date = ((146097 * century) / 4) + + ((1461 * decade) / 4) + + ((153 * month_adj + 2) / 5) + day + 1721119 - - myexcel_base_date - + excel1900is_leap_year; - let excel_time = ((hours * 3600) + (minutes * 60) + seconds) as f64 / 86400 as f64; + - base_date + + is_leap_year; + + // Calculate the time portion of the date + let time_in_days = ((hours * 3600 + minutes * 60 + seconds) as f64) / 86400.0; - return (excel_date as f64 + excel_time) as f64; + // Return the final Excel date and time + julian_date as f64 + time_in_days } diff --git a/src/helper/formula.rs b/src/helper/formula.rs index c3d6dba4..642aebe7 100644 --- a/src/helper/formula.rs +++ b/src/helper/formula.rs @@ -1,9 +1,8 @@ use crate::helper::address::*; use crate::helper::coordinate::*; -use crate::helper::coordinate::*; use crate::helper::range::*; use crate::structs::StringValue; -use fancy_regex::{Captures, Regex}; +use fancy_regex::Regex; /** PARTLY BASED ON: */ /** Copyright (c) 2007 E. W. Bachtal, Inc. */ @@ -108,10 +107,10 @@ const OPERATORS_SN: &str = "+-"; const OPERATORS_INFIX: &str = "+-*/^&=><"; const OPERATORS_POSTFIX: &str = "%"; -pub const ERRORS: &'static [&'static str] = &[ +pub const ERRORS: &[&str] = &[ "#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A", ]; -const COMPARATORS_MULTI: &'static [&'static str] = &[">=", "<=", "<>"]; +const COMPARATORS_MULTI: &[&str] = &[">=", "<=", "<>"]; lazy_static! { pub static ref SCIENTIFIC_REGEX: Regex = Regex::new(r#"/^[1-9]{1}(\\.\\d+)?E{1}$/"#).unwrap(); @@ -122,7 +121,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec let formula = formula.into(); let formula_length = formula.chars().count(); - if formula_length < 2 || formula.chars().next().unwrap() != '=' { + if formula_length < 2 || !formula.starts_with('=') { return tokens; } @@ -135,7 +134,6 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec let mut in_path = false; let mut in_range = false; let mut in_error = false; - let mut next_token: Option = None; let mut index = 1; let mut value = String::from(""); @@ -197,7 +195,6 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec in_range = false; } value = format!("{}{}", value, formula.chars().nth(index).unwrap()); - index; continue; } @@ -221,17 +218,16 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // scientific notation check - if self::OPERATORS_SN.contains(formula.chars().nth(index).unwrap()) { - if value.len() > 1 { - if SCIENTIFIC_REGEX - .is_match(&formula.chars().nth(index).unwrap().to_string()) + if let Some(current_char) = formula.chars().nth(index) { + if self::OPERATORS_SN.contains(current_char) + && value.len() > 1 + && SCIENTIFIC_REGEX + .is_match(¤t_char.to_string()) .unwrap_or(false) - { - value = format!("{}{}", value, formula.chars().nth(index).unwrap()); - index += 1; - - continue; - } + { + value.push(current_char); + index += 1; + continue; } } @@ -239,7 +235,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // establish state-dependent character evaluations if formula.chars().nth(index).unwrap() == self::QUOTE_DOUBLE { - if value != "" { + if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); @@ -254,7 +250,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } if formula.chars().nth(index).unwrap() == self::QUOTE_SINGLE { - if value != "" { + if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); @@ -277,7 +273,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } if formula.chars().nth(index).unwrap() == self::ERROR_START { - if value != "" { + if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); @@ -294,7 +290,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // mark start and end of arrays and array rows if formula.chars().nth(index).unwrap() == self::BRACE_OPEN { - if value != "" { + if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); @@ -323,7 +319,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } if formula.chars().nth(index).unwrap() == self::SEMICOLON { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); @@ -354,7 +350,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } if formula.chars().nth(index).unwrap() == self::BRACE_CLOSE { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); @@ -379,7 +375,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // trim white-space if formula.chars().nth(index).unwrap() == self::WHITESPACE { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); @@ -391,8 +387,8 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec obj.set_token_type(FormulaTokenTypes::Whitespace); tokens1.push(obj); index += 1; - while ((formula.chars().nth(index).unwrap() == self::WHITESPACE) - && (index < formula_length)) + while (formula.chars().nth(index).unwrap() == self::WHITESPACE) + && (index < formula_length) { index += 1; } @@ -401,32 +397,31 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // multi-character comparators - if (index + 2) <= formula_length { - if COMPARATORS_MULTI + if (index + 2) <= formula_length + && COMPARATORS_MULTI .iter() .any(|&x| x == formula.chars().skip(index).take(2).collect::()) - { - if value != "" { - let mut obj = FormulaToken::default(); - obj.set_value(value); - obj.set_token_type(FormulaTokenTypes::Operand); - tokens1.push(obj); - value = String::from(""); - } + { + if !value.is_empty() { let mut obj = FormulaToken::default(); - obj.set_value(formula.chars().skip(index).take(2).collect::()); - obj.set_token_type(FormulaTokenTypes::OperatorInfix); - obj.set_token_sub_type(FormulaTokenSubTypes::Logical); + obj.set_value(value); + obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - index += 2; - - continue; + value = String::from(""); } + let mut obj = FormulaToken::default(); + obj.set_value(formula.chars().skip(index).take(2).collect::()); + obj.set_token_type(FormulaTokenTypes::OperatorInfix); + obj.set_token_sub_type(FormulaTokenSubTypes::Logical); + tokens1.push(obj); + index += 2; + + continue; } // standard infix operators if self::OPERATORS_INFIX.contains(formula.chars().nth(index).unwrap()) { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); @@ -444,7 +439,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // standard postfix operators (only one) if self::OPERATORS_POSTFIX.contains(formula.chars().nth(index).unwrap()) { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); @@ -462,7 +457,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // start subexpression or function if formula.chars().nth(index).unwrap() == self::PAREN_OPEN { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Function); @@ -485,7 +480,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // function, subexpression, or array parameters, or operand unions if formula.chars().nth(index).unwrap() == self::COMMA { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); @@ -517,7 +512,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // stop subexpression if formula.chars().nth(index).unwrap() == self::PAREN_CLOSE { - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); @@ -541,7 +536,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // dump remaining accumulation - if value != "" { + if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value.clone()); obj.set_token_type(FormulaTokenTypes::Operand); @@ -550,12 +545,14 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections let token_count = tokens1.len(); + #[allow(unused_assignments)] let mut previous_token = None; + #[allow(unused_assignments)] let mut next_token = None; for i in 0..token_count { let token = tokens1.get(i).unwrap(); if i > 0 { - match tokens1.get((i - 1)) { + match tokens1.get(i - 1) { Some(v) => { previous_token = Some(v.clone()); } @@ -567,9 +564,9 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec previous_token = None; } - match tokens1.get((i + 1)) { - Some(v) => { - next_token = Some(tokens1.get((i + 1)).unwrap()); + match tokens1.get(i + 1) { + Some(_) => { + next_token = Some(tokens1.get(i + 1).unwrap()); } None => { next_token = None; @@ -624,6 +621,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators // to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names let token_count = tokens2.len(); + #[allow(unused_assignments)] let mut previous_token = None; for i in 0..token_count { let mut token = tokens2.get(i).unwrap().clone(); @@ -695,7 +693,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec if token.get_token_type() == &FormulaTokenTypes::OperatorInfix && token.get_token_sub_type() == &FormulaTokenSubTypes::Nothing { - if "<>=".contains(token.get_value().chars().nth(0).unwrap()) { + if "<>=".contains(token.get_value().chars().next().unwrap()) { token.set_token_sub_type(FormulaTokenSubTypes::Logical); } else if token.get_value() == "&" { token.set_token_sub_type(FormulaTokenSubTypes::Concatenation); @@ -711,7 +709,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec if token.get_token_type() == &FormulaTokenTypes::Operand && token.get_token_sub_type() == &FormulaTokenSubTypes::Nothing { - if !token.get_value().parse::().is_ok() { + if token.get_value().parse::().is_err() { if token.get_value().to_uppercase() == "TRUE" || token.get_value().to_uppercase() == "FALSE" { @@ -727,12 +725,9 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec continue; } - - if token.get_token_type() == &FormulaTokenTypes::Function { - if token.get_value() != "" { - if token.get_value().chars().nth(0).unwrap() == '@' { - token.set_value(token.get_value().chars().skip(1).collect::()); - } + if let FormulaTokenTypes::Function = token.get_token_type() { + if !token.get_value().is_empty() && token.get_value().starts_with('@') { + token.set_value(token.get_value().chars().skip(1).collect::()); } } @@ -780,10 +775,10 @@ pub(crate) fn render(formula_token_list: &[FormulaToken]) -> String { pub fn adjustment_formula_coordinate( token_list: &mut [FormulaToken], - offset_col_num: &i32, - offset_row_num: &i32, + offset_col_num: i32, + offset_row_num: i32, ) { - for token in token_list.into_iter() { + for token in token_list.iter_mut() { if token.get_token_type() == &FormulaTokenTypes::Operand && token.get_token_sub_type() == &FormulaTokenSubTypes::Range { @@ -816,12 +811,8 @@ pub fn adjustment_formula_coordinate( row_num = calc_row_num as u32; } } - let new_corrdinate = coordinate_from_index_with_lock( - &col_num, - &row_num, - &is_lock_col, - &is_lock_row, - ); + let new_corrdinate = + coordinate_from_index_with_lock(col_num, row_num, is_lock_col, is_lock_row); coordinate_list_new.push(new_corrdinate); } else { coordinate_list_new.push(coordinate.to_string()); @@ -838,23 +829,24 @@ pub fn adjustment_formula_coordinate( } } +#[allow(clippy::too_many_arguments)] pub fn adjustment_insert_formula_coordinate( token_list: &mut [FormulaToken], - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, worksheet_name: &str, self_worksheet_name: &str, ignore_worksheet: bool, ) -> String { - for token in token_list.into_iter() { + for token in token_list.iter_mut() { if token.get_token_type() == &FormulaTokenTypes::Operand && token.get_token_sub_type() == &FormulaTokenSubTypes::Range { let (sheet_name, range) = split_address(token.get_value()); if ignore_worksheet - || (sheet_name == "" && worksheet_name == self_worksheet_name) + || (sheet_name.is_empty() && worksheet_name == self_worksheet_name) || (sheet_name == worksheet_name) { let mut coordinate_list_new: Vec = Vec::new(); @@ -867,24 +859,18 @@ pub fn adjustment_insert_formula_coordinate( let is_lock_col = cell.2.unwrap(); let is_lock_row = cell.3.unwrap(); if !is_lock_col { - col_num = adjustment_insert_coordinate( - &col_num, - root_col_num, - offset_col_num, - ); + col_num = + adjustment_insert_coordinate(col_num, root_col_num, offset_col_num); } if !is_lock_row { - row_num = adjustment_insert_coordinate( - &row_num, - root_row_num, - offset_row_num, - ); + row_num = + adjustment_insert_coordinate(row_num, root_row_num, offset_row_num); } let new_corrdinate = coordinate_from_index_with_lock( - &col_num, - &row_num, - &is_lock_col, - &is_lock_row, + col_num, + row_num, + is_lock_col, + is_lock_row, ); coordinate_list_new.push(new_corrdinate); } else { @@ -896,26 +882,27 @@ pub fn adjustment_insert_formula_coordinate( } } } - render(token_list.as_ref()) + render(token_list) } +#[allow(clippy::too_many_arguments)] pub fn adjustment_remove_formula_coordinate( token_list: &mut [FormulaToken], - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, worksheet_name: &str, self_worksheet_name: &str, ignore_worksheet: bool, ) -> String { - for token in token_list.into_iter() { + for token in token_list.iter_mut() { if token.get_token_type() == &FormulaTokenTypes::Operand && token.get_token_sub_type() == &FormulaTokenSubTypes::Range { let (sheet_name, range) = split_address(token.get_value()); if ignore_worksheet - || (sheet_name == "" && worksheet_name == self_worksheet_name) + || (sheet_name.is_empty() && worksheet_name == self_worksheet_name) || (sheet_name == worksheet_name) { let mut coordinate_list_new: Vec = Vec::new(); @@ -928,24 +915,18 @@ pub fn adjustment_remove_formula_coordinate( let is_lock_col = cell.2.unwrap(); let is_lock_row = cell.3.unwrap(); if !is_lock_col { - col_num = adjustment_remove_coordinate( - &col_num, - root_col_num, - offset_col_num, - ); + col_num = + adjustment_remove_coordinate(col_num, root_col_num, offset_col_num); } if !is_lock_row { - row_num = adjustment_remove_coordinate( - &row_num, - root_row_num, - offset_row_num, - ); + row_num = + adjustment_remove_coordinate(row_num, root_row_num, offset_row_num); } let new_corrdinate = coordinate_from_index_with_lock( - &col_num, - &row_num, - &is_lock_col, - &is_lock_row, + col_num, + row_num, + is_lock_col, + is_lock_row, ); coordinate_list_new.push(new_corrdinate); } else { @@ -957,7 +938,7 @@ pub fn adjustment_remove_formula_coordinate( } } } - render(token_list.as_ref()) + render(token_list) } #[cfg(test)] diff --git a/src/helper/html.rs b/src/helper/html.rs index 031aac65..5ea25a92 100644 --- a/src/helper/html.rs +++ b/src/helper/html.rs @@ -4,8 +4,7 @@ use crate::structs::RichText; use crate::structs::TextElement; use crate::structs::UnderlineValues; use crate::structs::VerticalAlignmentRunValues; -use chrono::format; -use html_parser::{Dom, Element, Node}; +use html_parser::{Dom, Node}; use std::collections::HashMap; use thin_vec::ThinVec; @@ -51,6 +50,7 @@ pub fn html_to_richtext_custom( Ok(result) } +#[allow(clippy::field_reassign_with_default)] fn read_node(node_list: &Vec, parent_element: &[HfdElement]) -> ThinVec { let mut result: ThinVec = ThinVec::new(); @@ -71,7 +71,7 @@ fn read_node(node_list: &Vec, parent_element: &[HfdElement]) -> ThinVec, parent_element: &[HfdElement]) -> ThinVec {} } } - if &data.text != "" { + if !data.text.is_empty() { result.push(data); } result @@ -113,15 +113,15 @@ fn make_rich_text(html_flat_data_list: &[HtmlFlatData], method: &dyn AnalysisMet let mut result = RichText::default(); for html_flat_data in html_flat_data_list { - let mut font_name: Option<&str> = method.font_name(html_flat_data); - let mut size: Option = method.size(html_flat_data); - let mut color: Option = method.color(html_flat_data); - let mut is_bold: bool = method.is_bold(html_flat_data); - let mut is_italic: bool = method.is_italic(html_flat_data); - let mut is_underline: bool = method.is_underline(html_flat_data); - let mut is_superscript: bool = method.is_superscript(html_flat_data); - let mut is_subscript: bool = method.is_subscript(html_flat_data); - let mut is_strikethrough: bool = method.is_strikethrough(html_flat_data); + let font_name: Option<&str> = method.font_name(html_flat_data); + let size: Option = method.size(html_flat_data); + let color: Option = method.color(html_flat_data); + let is_bold: bool = method.is_bold(html_flat_data); + let is_italic: bool = method.is_italic(html_flat_data); + let is_underline: bool = method.is_underline(html_flat_data); + let is_superscript: bool = method.is_superscript(html_flat_data); + let is_subscript: bool = method.is_subscript(html_flat_data); + let is_strikethrough: bool = method.is_strikethrough(html_flat_data); let mut text_element = TextElement::default(); let mut font = Font::default(); @@ -192,7 +192,7 @@ impl HfdElement { pub fn get_by_name_and_attribute(&self, name: &str, attribute: &str) -> Option<&str> { self.attributes .get(attribute) - .and_then(|v| (self.name == name).then(|| v)) + .and_then(|v| (self.name == name).then_some(v)) .map(|x| x.as_str()) } @@ -219,7 +219,7 @@ pub trait AnalysisMethod { struct DataAnalysis {} impl AnalysisMethod for DataAnalysis { #[inline] - fn font_name<'a>(&'a self, html_flat_data: &'a HtmlFlatData) -> Option<&str> { + fn font_name<'a>(&'a self, html_flat_data: &'a HtmlFlatData) -> Option<&'a str> { html_flat_data .element .iter() @@ -236,7 +236,6 @@ impl AnalysisMethod for DataAnalysis { } fn color(&self, html_flat_data: &HtmlFlatData) -> Option { - let mut result: Option = None; html_flat_data .element .iter() @@ -248,7 +247,7 @@ impl AnalysisMethod for DataAnalysis { .find_map(|(key, value)| { (*key.to_uppercase() == color).then(|| value.to_uppercase()) }) - .or_else(|| Some(color)) + .or(Some(color)) }) } @@ -814,5 +813,5 @@ const COLOR_MAP: &[(&str, &str)] = &[ #[test] fn convert_test() { let html = r#"test
TEST
TEST
"#; - let result = html_to_richtext(html).unwrap(); + let _ = html_to_richtext(html).unwrap(); } diff --git a/src/helper/number_format.rs b/src/helper/number_format.rs index 9c7f6d71..6458ec8d 100644 --- a/src/helper/number_format.rs +++ b/src/helper/number_format.rs @@ -5,13 +5,10 @@ mod percentage_formater; use std::borrow::Cow; -use crate::helper::date::*; use crate::structs::Color; use crate::structs::NumberingFormat; -use fancy_regex::Captures; use fancy_regex::Matches; use fancy_regex::Regex; -use thousands::Separable; pub struct Split<'r, 't> { finder: Matches<'r, 't>, @@ -26,7 +23,7 @@ pub fn split<'r, 't>(regex: &'r Regex, text: &'t str) -> Split<'r, 't> { } } -impl<'r, 't> Iterator for Split<'r, 't> { +impl<'t> Iterator for Split<'_, 't> { type Item = &'t str; fn next(&mut self) -> Option { @@ -86,7 +83,7 @@ pub fn to_formatted_string, P: AsRef>(value: S, format: P) -> let sections: Vec<&str> = split(&SECTION_REGEX, &format).collect(); - let (_, split_format, split_value) = split_format(sections, &value.parse::().unwrap()); + let (_, split_format, split_value) = split_format(sections, value.parse::().unwrap()); format = Cow::Owned(split_format); value = Cow::Owned(split_value); @@ -101,20 +98,20 @@ pub fn to_formatted_string, P: AsRef>(value: S, format: P) -> if DATE_TIME_REGEX.is_match(&format).unwrap_or(false) { // datetime format - value = date_formater::format_as_date(&value.parse::().unwrap(), &format); + value = date_formater::format_as_date(value.parse::().unwrap(), &format); } else if format.starts_with('"') && format.ends_with('"') { let conv_format = format.trim_matches('"').parse::().unwrap(); value = Cow::Owned(conv_format.to_string()); } else if PERCENT_DOLLAR_REGEX.is_match(&format).unwrap_or(false) { // % number format - value = percentage_formater::format_as_percentage(&value.parse::().unwrap(), &format); + value = percentage_formater::format_as_percentage(value.parse::().unwrap(), &format); } else { - value = number_formater::format_as_number(&value.parse::().unwrap(), &format); + value = number_formater::format_as_number(value.parse::().unwrap(), &format); } value.trim().to_string() } -fn split_format(sections: Vec<&str>, value: &f64) -> (String, String, String) { +fn split_format(sections: Vec<&str>, value: f64) -> (String, String, String) { let mut converted_sections: Vec = Vec::new(); // Extract the relevant section depending on whether number is positive, negative, or zero? @@ -153,57 +150,59 @@ fn split_format(sections: Vec<&str>, value: &f64) -> (String, String, String) { ]; sections.into_iter().enumerate().for_each(|(idx, section)| { let mut converted_section = section.to_string(); - if color_re.find(section).ok().flatten().is_some() { - let mut item: Vec = Vec::new(); - for ite in color_re.captures(section).ok().flatten().unwrap().iter() { - item.push(ite.unwrap().as_str().to_string()); + + // Process color matching + if let Some(captures) = color_re.captures(section).ok().flatten() { + let items: Vec = captures + .iter() + .filter_map(|cap| cap.map(|c| c.as_str().to_string())) + .collect(); + + if let Some(first_item) = items.first() { + colors[idx] = first_item.clone(); } - std::mem::replace(&mut colors[idx], item.get(0).unwrap().to_string()); + converted_section = color_re.replace_all(section, "").to_string(); } - if cond_re.find(section).ok().flatten().is_some() { - let mut item: Vec = Vec::new(); - for ite in cond_re.captures(section).ok().flatten().unwrap().iter() { - match ite { - Some(v) => item.push(v.as_str().to_string()), - None => {} - } - } - match item.get(1) { - Some(v) => { - std::mem::replace(&mut condops[idx], v.to_string()); - } - None => {} + + // Process conditional matching + if let Some(captures) = cond_re.captures(section).ok().flatten() { + let items: Vec = captures + .iter() + .filter_map(|cap| cap.map(|c| c.as_str().to_string())) + .collect(); + + if let Some(v) = items.get(1) { + condops[idx] = v.clone(); } - match item.get(2) { - Some(v) => { - std::mem::replace(&mut condvals[idx], v.to_string()); - } - None => {} + if let Some(v) = items.get(2) { + condvals[idx] = v.clone(); } + converted_section = cond_re.replace_all(section, "").to_string(); } + converted_sections.insert(idx, converted_section); }); let mut color = &colors[0]; let mut format: &str = &converted_sections[0]; - let mut absval = *value; + let mut absval = value; match cnt { 2 => { absval = absval.abs(); - let condval_one = &condvals[0].parse::().unwrap(); - if !split_format_compare(value, &condops[0], condval_one, ">=", &0f64) { + let condval_one = condvals[0].parse::().unwrap(); + if !split_format_compare(value, &condops[0], condval_one, ">=", 0f64) { color = &colors[1]; format = &converted_sections[1]; } } 3 | 4 => { absval = absval.abs(); - let condval_one = &condvals[0].parse::().unwrap(); - let condval_two = &condvals[1].parse::().unwrap(); - if !split_format_compare(value, &condops[0], condval_one, ">", &0f64) { - if split_format_compare(value, &condops[1], condval_two, "<", &0f64) { + let condval_one = condvals[0].parse::().unwrap(); + let condval_two = condvals[1].parse::().unwrap(); + if !split_format_compare(value, &condops[0], condval_one, ">", 0f64) { + if split_format_compare(value, &condops[1], condval_two, "<", 0f64) { color = &colors[1]; format = &converted_sections[1]; } else { @@ -217,7 +216,7 @@ fn split_format(sections: Vec<&str>, value: &f64) -> (String, String, String) { (color.to_string(), format.into(), absval.to_string()) } -fn split_format_compare(value: &f64, cond: &str, val: &f64, dfcond: &str, dfval: &f64) -> bool { +fn split_format_compare(value: f64, cond: &str, val: f64, dfcond: &str, dfval: f64) -> bool { let mut check_cond = cond; let mut check_val = val; if cond.is_empty() { diff --git a/src/helper/number_format/date_formater.rs b/src/helper/number_format/date_formater.rs index 7e836afd..383df289 100644 --- a/src/helper/number_format/date_formater.rs +++ b/src/helper/number_format/date_formater.rs @@ -1,12 +1,8 @@ use std::borrow::Cow; use crate::helper::date::*; -use crate::structs::Color; -use crate::structs::NumberingFormat; use fancy_regex::Captures; -use fancy_regex::Matches; use fancy_regex::Regex; -use thousands::Separable; const DATE_FORMAT_REPLACEMENTS: &[(&str, &str)] = &[ // first remove escapes related to non-format characters @@ -57,7 +53,7 @@ const DATE_FORMAT_REPLACEMENTS_24: &[(&str, &str)] = &[("hh", "%H"), ("h", "%-H" const DATE_FORMAT_REPLACEMENTS_12: &[(&str, &str)] = &[("hh", "%I"), ("h", "%-I")]; -pub(crate) fn format_as_date<'input>(value: &f64, format: &'input str) -> Cow<'input, str> { +pub(crate) fn format_as_date(value: f64, format: &str) -> Cow { let format = Cow::Borrowed(format); // strip off first part containing e.g. [$-F800] or [$USD-409] diff --git a/src/helper/number_format/fraction_formater.rs b/src/helper/number_format/fraction_formater.rs index 463d1f0c..34ac7ea0 100644 --- a/src/helper/number_format/fraction_formater.rs +++ b/src/helper/number_format/fraction_formater.rs @@ -1,15 +1,5 @@ -use std::borrow::Cow; - -use crate::helper::date::*; -use crate::structs::Color; -use crate::structs::NumberingFormat; -use fancy_regex::Captures; -use fancy_regex::Matches; -use fancy_regex::Regex; -use thousands::Separable; - -pub(crate) fn format_as_fraction(value: &f64, format: &str) -> String { - let sign = if value < &0f64 { "-" } else { "" }; +pub(crate) fn format_as_fraction(value: f64, format: &str) -> String { + let sign = if value < 0f64 { "-" } else { "" }; let integer_part = value.abs().floor(); let decimal_part = (value.abs() % 1f64) @@ -20,7 +10,7 @@ pub(crate) fn format_as_fraction(value: &f64, format: &str) -> String { let decimal_length = decimal_part.to_string().len(); let decimal_divisor = 10f64.powi(decimal_length as i32); - let gcd = gcd(&decimal_part, &decimal_divisor); + let gcd = gcd(decimal_part, decimal_divisor); let mut adjusted_decimal_part = decimal_part / gcd; let adjusted_decimal_divisor = decimal_divisor / gcd; @@ -70,10 +60,10 @@ pub(crate) fn format_as_fraction(value: &f64, format: &str) -> String { } #[inline] -fn gcd(a: &f64, b: &f64) -> f64 { - if b == &0f64 { - *a +fn gcd(a: f64, b: f64) -> f64 { + if b == 0f64 { + a } else { - gcd(b, &(a % b)) + gcd(b, a % b) } } diff --git a/src/helper/number_format/number_formater.rs b/src/helper/number_format/number_formater.rs index eebc31ed..c9631166 100644 --- a/src/helper/number_format/number_formater.rs +++ b/src/helper/number_format/number_formater.rs @@ -3,7 +3,7 @@ use fancy_regex::Regex; use std::borrow::Cow; use thousands::Separable; -pub(crate) fn format_as_number<'input>(value: &f64, format: &'input str) -> Cow<'input, str> { +pub(crate) fn format_as_number(value: f64, format: &str) -> Cow { lazy_static! { static ref THOUSANDS_SEP_REGEX: Regex = Regex::new(r#"(#,#|0,0)"#).unwrap(); static ref SCALE_REGEX: Regex = Regex::new(r#"(#|0)(,+)"#).unwrap(); @@ -53,7 +53,7 @@ pub(crate) fn format_as_number<'input>(value: &f64, format: &'input str) -> Cow< if FRACTION_REGEX.is_match(&format).unwrap_or(false) { if value.parse::().is_err() { //println!("format as fraction {} {}", value, format); - value = format_as_fraction(&value.parse::().unwrap(), &format); + value = format_as_fraction(value.parse::().unwrap(), &format); } } else { // Handle the number itself @@ -80,7 +80,7 @@ pub(crate) fn format_as_number<'input>(value: &f64, format: &'input str) -> Cow< &value, &format, &item, - &use_thousands, + use_thousands, r"(0+)(\.?)(0*)", ); } @@ -92,7 +92,7 @@ pub(crate) fn format_as_number<'input>(value: &f64, format: &'input str) -> Cow< for ite in re.captures(&format).ok().flatten().unwrap().iter() { item.push(ite.unwrap().as_str().to_string()); } - value = format!("{}{}", item.get(0).unwrap(), value); + value = format!("{}{}", item.first().unwrap(), value); // // Currency or Accounting // let currency_code = item.get(1).unwrap().to_string(); // value = Regex::new(r#"\[\$([^\]]*)\]"#).unwrap().replace_all(&value, currency_code.as_str()).to_string(); @@ -105,7 +105,7 @@ fn format_straight_numeric_value( value: &str, _format: &str, matches: &[String], - use_thousands: &bool, + use_thousands: bool, _number_regex: &str, ) -> String { let mut value = value.to_string(); @@ -113,7 +113,7 @@ fn format_straight_numeric_value( let right = matches.get(3).unwrap(); // minimun width of formatted number (including dot) - if *use_thousands { + if use_thousands { value = value.parse::().unwrap().separate_with_commas(); } let blocks: Vec<&str> = value.split('.').collect(); @@ -144,7 +144,7 @@ fn format_straight_numeric_value( value = format!("{}.{}", left_value, right_value); value - // if use_thousands == &true { + // if use_thousands == true { // value = value.parse::().unwrap().separate_with_commas(); // dbg!(&value); // value = Regex::new(&number_regex).unwrap().replace_all(&format, value.as_str()); @@ -159,7 +159,7 @@ fn format_straight_numeric_value( // let pow = 10i32.pow(format_collect.get(1).unwrap().len() as u32); // value = format!("{}", value.parse::().unwrap() * pow); // } - // value = complex_number_format_mask(&value.parse::().unwrap(), &format, &true); + // value = complex_number_format_mask(&value.parse::().unwrap(), &format, true); // } else { // value = format!("{:0width$.len$}", value, width = min_width, len = right.len()); // value = Regex::new(&number_regex).unwrap().replace_all(&format, value.as_str()); @@ -168,6 +168,7 @@ fn format_straight_numeric_value( // value } +#[allow(dead_code)] fn merge_complex_number_format_masks(numbers: &[String], masks: &[String]) -> Vec { let mut decimal_count = numbers[1].len(); let mut post_decimal_masks: Vec = Vec::new(); @@ -184,7 +185,8 @@ fn merge_complex_number_format_masks(numbers: &[String], masks: &[String]) -> Ve vec![masks.join("."), post_decimal_masks.join(".")] } -fn process_complex_number_format_mask(number: &f64, mask: &str) -> String { +#[allow(dead_code)] +fn process_complex_number_format_mask(number: f64, mask: &str) -> String { let mut result = number.to_string(); let mut mask = mask.to_string(); let re = Regex::new(r#"0+"#).unwrap(); @@ -206,7 +208,7 @@ fn process_complex_number_format_mask(number: &f64, mask: &str) -> String { } if masking_blocks.len() > 1 { - let mut number = *number; + let mut number = number; let mut offset: usize = 0; for (block, pos) in masking_blocks.iter().rev() { let divisor = format!("{}{}", 1, block).parse::().unwrap(); @@ -228,11 +230,12 @@ fn process_complex_number_format_mask(number: &f64, mask: &str) -> String { result } -fn complex_number_format_mask(number: &f64, mask: &str, split_on_point: &bool) -> String { - let sign = number < &0.0; +#[allow(dead_code)] +fn complex_number_format_mask(number: f64, mask: &str, split_on_point: bool) -> String { + let sign = number < 0.0; let number = number.abs(); - if *split_on_point && mask.contains('.') && number.to_string().contains('.') { + if split_on_point && mask.contains('.') && number.to_string().contains('.') { let number_str = number.to_string(); let numbers_as: Vec<&str> = number_str.split('.').collect(); let mut numbers: Vec = Vec::new(); @@ -248,16 +251,16 @@ fn complex_number_format_mask(number: &f64, mask: &str, split_on_point: &bool) - masks = merge_complex_number_format_masks(&numbers, &masks); } let result1 = - complex_number_format_mask(&numbers[0].parse::().unwrap(), &masks[0], &false); + complex_number_format_mask(numbers[0].parse::().unwrap(), &masks[0], false); let result2 = complex_number_format_mask( - &numbers[1] + numbers[1] .chars() .rev() .collect::() .parse::() .unwrap(), &masks[1].chars().rev().collect::(), - &false, + false, ) .chars() .rev() @@ -266,6 +269,6 @@ fn complex_number_format_mask(number: &f64, mask: &str, split_on_point: &bool) - return format!("{}{}.{}", if sign { "-" } else { "" }, result1, result2); } - let result = process_complex_number_format_mask(&number, mask); + let result = process_complex_number_format_mask(number, mask); format!("{}{}", if sign { "-" } else { "" }, result) } diff --git a/src/helper/number_format/percentage_formater.rs b/src/helper/number_format/percentage_formater.rs index 333e788c..8df41393 100644 --- a/src/helper/number_format/percentage_formater.rs +++ b/src/helper/number_format/percentage_formater.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -pub(crate) fn format_as_percentage<'input>(value: &f64, format: &'input str) -> Cow<'input, str> { +pub(crate) fn format_as_percentage(value: f64, format: &str) -> Cow { let mut value = value.to_string(); let mut format = Cow::Borrowed(format); format = Cow::Owned(format.replace('%', "")); diff --git a/src/helper/range.rs b/src/helper/range.rs index 962a16d1..24e29eed 100644 --- a/src/helper/range.rs +++ b/src/helper/range.rs @@ -1,7 +1,5 @@ use crate::helper::coordinate::*; -use super::coordinate; - /// `(col, row)` pub type BasicCellIndex = (u32, u32); diff --git a/src/lib.rs b/src/lib.rs index 4b391c84..8f58c107 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ //! use umya_spreadsheet::*; //! let mut book = new_file(); //! -//! let mut clone_sheet = book.get_sheet(&0).unwrap().clone(); +//! let mut clone_sheet = book.get_sheet(0).unwrap().clone(); //! clone_sheet.set_name("New Sheet"); //! let _ = book.add_sheet(clone_sheet); //! ``` @@ -44,9 +44,9 @@ //! book.get_sheet_by_name_mut("Sheet2").unwrap().get_cell_mut("B2").set_value_from_i32(1); //! book.get_sheet_by_name_mut("Sheet2").unwrap().get_cell_mut("C3").set_value_from_bool(true); //! // or -//! book.get_sheet_mut(&1).unwrap().get_cell_mut((1, 1)).set_value("TEST1"); -//! book.get_sheet_mut(&1).unwrap().get_cell_mut((2, 2)).set_value_from_i32(1)); -//! book.get_sheet_mut(&1).unwrap().get_cell_mut((3, 3)).set_value_from_bool(true)); +//! book.get_sheet_mut(1).unwrap().get_cell_mut((1, 1)).set_value("TEST1"); +//! book.get_sheet_mut(1).unwrap().get_cell_mut((2, 2)).set_value_from_i32(1)); +//! book.get_sheet_mut(1).unwrap().get_cell_mut((3, 3)).set_value_from_bool(true)); //! ``` //! ### Read value //! ```rust @@ -58,9 +58,9 @@ //! // read value //! let a1_value = book.get_sheet_by_name("Sheet2").unwrap().get_value("A1"); //! // or -//! let a1_value = book.get_sheet(&1).unwrap().get_value((1, 1)); +//! let a1_value = book.get_sheet(1).unwrap().get_value((1, 1)); //! // or formatted value -//! let a1_value = book.get_sheet(&1).unwrap().get_formatted_value("A1"); +//! let a1_value = book.get_sheet(1).unwrap().get_formatted_value("A1"); //! assert_eq!("TEST1", a1_value); // TEST1 //! ``` //! ### Change style @@ -77,7 +77,7 @@ //! .get_bottom_mut() //! .set_border_style(Border::BORDER_MEDIUM); //! // or -//! book.get_sheet_mut(&1).unwrap() +//! book.get_sheet_mut(1).unwrap() //! .get_style_mut((1, 1)) //! .get_borders_mut() //! .get_bottom_mut() @@ -116,8 +116,8 @@ //! let _ = writer::xlsx::write(&book, path); //! ``` -#![allow(warnings)] -#![allow(clippy::all)] +#![deny(clippy::correctness)] +#![warn(clippy::style, clippy::complexity, clippy::perf, clippy::trivially_copy_pass_by_ref)] extern crate chrono; extern crate fancy_regex; @@ -149,7 +149,6 @@ pub mod traits; pub mod writer; pub use self::structs::*; -pub use self::traits::*; /// create new spreadsheet file. /// # Arguments diff --git a/src/reader/xlsx.rs b/src/reader/xlsx.rs index e9f93296..fe110411 100644 --- a/src/reader/xlsx.rs +++ b/src/reader/xlsx.rs @@ -1,8 +1,6 @@ -use std::fmt; use std::fs::File; use std::io; use std::path::Path; -use std::string::FromUtf8Error; use std::sync::Arc; use std::sync::RwLock; diff --git a/src/reader/xlsx/pivot_table.rs b/src/reader/xlsx/pivot_table.rs index 5e955b14..38f71b69 100644 --- a/src/reader/xlsx/pivot_table.rs +++ b/src/reader/xlsx/pivot_table.rs @@ -1,4 +1,3 @@ -use super::driver::*; use super::XlsxError; use crate::structs::raw::RawFile; use crate::structs::PivotTable; @@ -8,6 +7,7 @@ use quick_xml::events::Event; use quick_xml::Reader; use std::result; +#[allow(dead_code)] pub(crate) fn read( worksheet: &mut Worksheet, pivot_table_file: &RawFile, @@ -19,20 +19,18 @@ pub(crate) fn read( let mut pivot_table = PivotTable::default(); loop { match reader.read_event_into(&mut buf) { - Ok(Event::Start(ref e)) => match e.name().into_inner() { - b"pivotTableDefinition" => { + Ok(Event::Start(ref e)) => { + if e.name().into_inner() == b"pivotTableDefinition" { let mut obj = PivotTableDefinition::default(); obj.set_attributes(&mut reader, e); pivot_table.set_pivot_table_definition(obj); } - _ => (), - }, - Ok(Event::End(ref e)) => match e.name().into_inner() { - b"pivotTableDefinition" => { + } + Ok(Event::End(ref e)) => { + if e.name().into_inner() == b"pivotTableDefinition" { break; } - _ => (), - }, + } Ok(Event::Eof) => break, Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e), _ => (), diff --git a/src/reader/xlsx/styles.rs b/src/reader/xlsx/styles.rs index 04d75109..57918213 100644 --- a/src/reader/xlsx/styles.rs +++ b/src/reader/xlsx/styles.rs @@ -16,8 +16,6 @@ pub fn read( let mut reader = Reader::from_reader(r); reader.config_mut().trim_text(true); - let theme = spreadsheet.get_theme().clone(); - xml_read_loop!( reader, Event::Start(ref e) => { diff --git a/src/reader/xlsx/table.rs b/src/reader/xlsx/table.rs index 66ada7f1..e530ed93 100644 --- a/src/reader/xlsx/table.rs +++ b/src/reader/xlsx/table.rs @@ -1,7 +1,6 @@ use super::driver::*; use super::XlsxError; use crate::structs::raw::RawFile; -use crate::structs::Comment; use crate::structs::Worksheet; use crate::structs::{Table, TableColumn, TableStyleInfo}; use quick_xml::events::Event; @@ -24,23 +23,20 @@ pub(crate) fn read( Ok(Event::Empty(ref e)) => match e.name().into_inner() { b"tableColumn" => { table_column = TableColumn::default(); - for a in e.attributes().with_checks(false) { - match a { - Ok(ref attr) => match attr.key.0 { - b"name" => { - let attr_val = get_attribute_value(attr)?; - table_column.set_name(attr_val); - } - b"totalsRowLabel" => { - let attr_val = get_attribute_value(attr)?; - table_column.set_totals_row_label_str(&attr_val); - } - b"totalsRowFunction" => { - let attr_val = get_attribute_value(attr)?; - table_column.set_totals_row_function_str(&attr_val); - } - _ => {} - }, + for attr in e.attributes().with_checks(false).flatten() { + match attr.key.0 { + b"name" => { + let attr_val = get_attribute_value(&attr)?; + table_column.set_name(attr_val); + } + b"totalsRowLabel" => { + let attr_val = get_attribute_value(&attr)?; + table_column.set_totals_row_label_str(&attr_val); + } + b"totalsRowFunction" => { + let attr_val = get_attribute_value(&attr)?; + table_column.set_totals_row_function_str(&attr_val); + } _ => {} } } @@ -56,28 +52,23 @@ pub(crate) fn read( let mut show_last_col = false; let mut show_row_stripes = false; let mut show_col_stripes = false; - for a in e.attributes().with_checks(false) { - match a { - Ok(ref attr) => { - let attr_val = get_attribute_value(attr)?; - match attr.key.0 { - b"name" => { - name = attr_val; - } - b"showFirstColumn" => { - show_first_col = attr_val == "1"; - } - b"showLastColumn" => { - show_last_col = attr_val == "1"; - } - b"showRowStripes" => { - show_row_stripes = attr_val == "1"; - } - b"showColumnStripes" => { - show_col_stripes = attr_val == "1"; - } - _ => {} - } + for attr in e.attributes().with_checks(false).flatten() { + let attr_val = get_attribute_value(&attr)?; + match attr.key.0 { + b"name" => { + name = attr_val; + } + b"showFirstColumn" => { + show_first_col = attr_val == "1"; + } + b"showLastColumn" => { + show_last_col = attr_val == "1"; + } + b"showRowStripes" => { + show_row_stripes = attr_val == "1"; + } + b"showColumnStripes" => { + show_col_stripes = attr_val == "1"; } _ => {} } @@ -97,55 +88,47 @@ pub(crate) fn read( Ok(Event::Text(e)) => string_value = e.unescape().unwrap().to_string(), Ok(Event::Start(ref e)) => match e.name().into_inner() { b"table" => { - for a in e.attributes().with_checks(false) { - match a { - Ok(ref attr) => { - let attr_val = get_attribute_value(attr)?; - match attr.key.0 { - b"displayName" => { - table.set_display_name(&attr_val); - } - b"name" => { - table.set_name(&attr_val); - } - b"ref" => { - let area_coords: Vec<&str> = attr_val.split(':').collect(); - if area_coords.len() == 2 { - table.set_area((area_coords[0], area_coords[1])); - } - } - b"totalsRowShown" => { - table.set_totals_row_shown_str(&attr_val); - } - b"totalsRowCount" => { - table.set_totals_row_count_str(&attr_val); - } - _ => {} + for attr in e.attributes().with_checks(false).flatten() { + let attr_val = get_attribute_value(&attr)?; + match attr.key.0 { + b"displayName" => { + table.set_display_name(&attr_val); + } + b"name" => { + table.set_name(&attr_val); + } + b"ref" => { + let area_coords: Vec<&str> = attr_val.split(':').collect(); + if area_coords.len() == 2 { + table.set_area((area_coords[0], area_coords[1])); } } + b"totalsRowShown" => { + table.set_totals_row_shown_str(&attr_val); + } + b"totalsRowCount" => { + table.set_totals_row_count_str(&attr_val); + } _ => {} } } } b"tableColumn" => { table_column = TableColumn::default(); - for a in e.attributes().with_checks(false) { - match a { - Ok(ref attr) => match attr.key.0 { - b"name" => { - let attr_val = get_attribute_value(attr)?; - table_column.set_name(attr_val); - } - b"totalsRowLabel" => { - let attr_val = get_attribute_value(attr)?; - table_column.set_totals_row_label_str(&attr_val); - } - b"totalsRowFunction" => { - let attr_val = get_attribute_value(attr)?; - table_column.set_totals_row_function_str(&attr_val); - } - _ => {} - }, + for attr in e.attributes().with_checks(false).flatten() { + match attr.key.0 { + b"name" => { + let attr_val = get_attribute_value(&attr)?; + table_column.set_name(attr_val); + } + b"totalsRowLabel" => { + let attr_val = get_attribute_value(&attr)?; + table_column.set_totals_row_label_str(&attr_val); + } + b"totalsRowFunction" => { + let attr_val = get_attribute_value(&attr)?; + table_column.set_totals_row_function_str(&attr_val); + } _ => {} } } diff --git a/src/reader/xlsx/workbook.rs b/src/reader/xlsx/workbook.rs index c6f5990c..8acb89b6 100644 --- a/src/reader/xlsx/workbook.rs +++ b/src/reader/xlsx/workbook.rs @@ -50,7 +50,7 @@ pub(crate) fn read( if let Some(v) = state { worksheet.set_state_str(&v); } - spreadsheet.add_sheet(worksheet); + spreadsheet.add_sheet(worksheet).unwrap(); } b"pivotCache" => { let cache_id = get_attribute(e, b"cacheId").unwrap(); @@ -72,21 +72,17 @@ pub(crate) fn read( for defined_name in &defined_names { if defined_name.has_local_sheet_id() { - let local_sheet_id = defined_name.get_local_sheet_id().clone() as usize; + let local_sheet_id = defined_name.get_local_sheet_id() as usize; spreadsheet - .get_sheet_mut(&local_sheet_id) + .get_sheet_mut(local_sheet_id) .unwrap() .add_defined_names(defined_name.clone()); } else { - match defined_name.get_address_obj().get(0) { - Some(v) => match spreadsheet.get_sheet_by_name_mut(v.get_sheet_name()) { - Some(s) => { - s.add_defined_names(defined_name.clone()); - continue; - } - None => {} - }, - None => {} + if let Some(v) = defined_name.get_address_obj().first() { + if let Some(s) = spreadsheet.get_sheet_by_name_mut(v.get_sheet_name()) { + s.add_defined_names(defined_name.clone()); + continue; + } } spreadsheet.add_defined_names(defined_name.clone()); } diff --git a/src/reader/xlsx/worksheet.rs b/src/reader/xlsx/worksheet.rs index 4acceb18..553dfd7c 100644 --- a/src/reader/xlsx/worksheet.rs +++ b/src/reader/xlsx/worksheet.rs @@ -270,7 +270,6 @@ fn get_hyperlink( raw_relationships: Option<&RawRelationships>, ) -> (String, Hyperlink) { let mut hyperlink = Hyperlink::default(); - let mut rid = String::from(""); let coordition = get_attribute(e, b"ref").unwrap_or_default(); if let Some(v) = get_attribute(e, b"location") { diff --git a/src/structs/address.rs b/src/structs/address.rs index 10a8bb66..feaa19f8 100644 --- a/src/structs/address.rs +++ b/src/structs/address.rs @@ -43,7 +43,7 @@ impl Address { let org_value = value.into(); let (sheet_name, range) = split_address(&org_value); self.range.set_range(range); - if sheet_name != "" { + if !sheet_name.is_empty() { self.sheet_name = sheet_name.into(); } self @@ -80,7 +80,7 @@ impl Address { if sheet_name.contains(r#"""#) { with_space_char = "'"; } - if with_space_char == "" { + if with_space_char.is_empty() { lazy_static! { static ref RE: Regex = Regex::new(r"[^0-9a-zA-Z]").unwrap(); } @@ -88,10 +88,10 @@ impl Address { with_space_char = "'"; } } - if with_space_char == "" { - if (None, None, None, None) != index_from_coordinate(&sheet_name) { - with_space_char = "'"; - } + if with_space_char.is_empty() + && (None, None, None, None) != index_from_coordinate(&sheet_name) + { + with_space_char = "'"; } } format!( @@ -105,10 +105,10 @@ impl AdjustmentCoordinateWithSheet for Address { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if &*self.sheet_name == sheet_name { self.range.adjustment_insert_coordinate( @@ -124,10 +124,10 @@ impl AdjustmentCoordinateWithSheet for Address { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if &*self.sheet_name == sheet_name { self.range.adjustment_remove_coordinate( @@ -143,10 +143,10 @@ impl AdjustmentCoordinateWithSheet for Address { fn is_remove_coordinate_with_sheet( &self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { &*self.sheet_name == sheet_name && self.range.is_remove_coordinate( diff --git a/src/structs/alignment.rs b/src/structs/alignment.rs index 383bd186..91c9cc9c 100644 --- a/src/structs/alignment.rs +++ b/src/structs/alignment.rs @@ -42,7 +42,7 @@ impl Alignment { } #[inline] - pub fn get_wrap_text(&self) -> &bool { + pub fn get_wrap_text(&self) -> bool { self.wrap_text.get_value() } @@ -52,7 +52,7 @@ impl Alignment { } #[inline] - pub fn get_text_rotation(&self) -> &u32 { + pub fn get_text_rotation(&self) -> u32 { self.text_rotation.get_value() } diff --git a/src/structs/anchor.rs b/src/structs/anchor.rs index 1ee0c426..f97327f9 100644 --- a/src/structs/anchor.rs +++ b/src/structs/anchor.rs @@ -12,8 +12,8 @@ pub struct Anchor { impl Anchor { #[inline] - pub fn get_left_column(&self) -> &u32 { - &self.left_column + pub fn get_left_column(&self) -> u32 { + self.left_column } #[inline] @@ -22,8 +22,8 @@ impl Anchor { } #[inline] - pub fn get_left_offset(&self) -> &u32 { - &self.left_offset + pub fn get_left_offset(&self) -> u32 { + self.left_offset } #[inline] @@ -32,8 +32,8 @@ impl Anchor { } #[inline] - pub fn get_top_row(&self) -> &u32 { - &self.top_row + pub fn get_top_row(&self) -> u32 { + self.top_row } #[inline] @@ -42,8 +42,8 @@ impl Anchor { } #[inline] - pub fn get_top_offset(&self) -> &u32 { - &self.top_offset + pub fn get_top_offset(&self) -> u32 { + self.top_offset } #[inline] @@ -52,8 +52,8 @@ impl Anchor { } #[inline] - pub fn get_right_column(&self) -> &u32 { - &self.right_column + pub fn get_right_column(&self) -> u32 { + self.right_column } #[inline] @@ -62,8 +62,8 @@ impl Anchor { } #[inline] - pub fn get_right_offset(&self) -> &u32 { - &self.right_offset + pub fn get_right_offset(&self) -> u32 { + self.right_offset } #[inline] @@ -72,8 +72,8 @@ impl Anchor { } #[inline] - pub fn get_bottom_row(&self) -> &u32 { - &self.bottom_row + pub fn get_bottom_row(&self) -> u32 { + self.bottom_row } #[inline] @@ -82,8 +82,8 @@ impl Anchor { } #[inline] - pub fn get_bottom_offset(&self) -> &u32 { - &self.bottom_offset + pub fn get_bottom_offset(&self) -> u32 { + self.bottom_offset } #[inline] @@ -92,26 +92,26 @@ impl Anchor { } #[inline] - pub(crate) fn _adjustment_insert_row(&mut self, num_rows: &u32) { + pub(crate) fn _adjustment_insert_row(&mut self, num_rows: u32) { self.top_row += num_rows; self.bottom_row += num_rows; } #[inline] - pub(crate) fn _adjustment_insert_column(&mut self, num_cols: &u32) { + pub(crate) fn _adjustment_insert_column(&mut self, num_cols: u32) { self.left_column += num_cols; self.right_column += num_cols; } #[inline] - pub(crate) fn _adjustment_remove_row(&mut self, num_rows: &u32) { - self.top_row = self.top_row.saturating_sub(*num_rows).max(1); - self.bottom_row = self.bottom_row.saturating_sub(*num_rows).max(1); + pub(crate) fn _adjustment_remove_row(&mut self, num_rows: u32) { + self.top_row = self.top_row.saturating_sub(num_rows).max(1); + self.bottom_row = self.bottom_row.saturating_sub(num_rows).max(1); } #[inline] - pub(crate) fn _adjustment_remove_column(&mut self, num_cols: &u32) { - self.left_column = self.left_column.saturating_sub(*num_cols).max(1); - self.right_column = self.right_column.saturating_sub(*num_cols).max(1); + pub(crate) fn _adjustment_remove_column(&mut self, num_cols: u32) { + self.left_column = self.left_column.saturating_sub(num_cols).max(1); + self.right_column = self.right_column.saturating_sub(num_cols).max(1); } } diff --git a/src/structs/auto_filter.rs b/src/structs/auto_filter.rs index 8fa7381a..0051968e 100644 --- a/src/structs/auto_filter.rs +++ b/src/structs/auto_filter.rs @@ -28,10 +28,10 @@ impl AdjustmentCoordinate for AutoFilter { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.range.adjustment_insert_coordinate( root_col_num, @@ -44,10 +44,10 @@ impl AdjustmentCoordinate for AutoFilter { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.range.adjustment_remove_coordinate( root_col_num, diff --git a/src/structs/bold.rs b/src/structs/bold.rs index c8b880df..9c3f00a9 100644 --- a/src/structs/bold.rs +++ b/src/structs/bold.rs @@ -14,7 +14,7 @@ pub struct Bold { impl Bold { #[inline] - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } @@ -37,7 +37,7 @@ impl Bold { #[inline] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // b - if *self.val.get_value() { + if self.val.get_value() { write_start_tag(writer, "b", vec![], true); } } diff --git a/src/structs/boolean_value.rs b/src/structs/boolean_value.rs index 51bb0c2f..51cb79c3 100644 --- a/src/structs/boolean_value.rs +++ b/src/structs/boolean_value.rs @@ -5,13 +5,13 @@ pub struct BooleanValue { impl BooleanValue { #[inline] - pub(crate) fn get_value(&self) -> &bool { - self.value.as_ref().unwrap_or(&false) + pub(crate) fn get_value(&self) -> bool { + self.value.unwrap_or(false) } #[inline] pub(crate) fn get_value_string(&self) -> &str { - match *self.get_value() { + match self.get_value() { true => "1", false => "0", } diff --git a/src/structs/borders.rs b/src/structs/borders.rs index 1be79db4..e3c19295 100644 --- a/src/structs/borders.rs +++ b/src/structs/borders.rs @@ -232,7 +232,7 @@ impl Borders { } #[inline] - pub fn get_diagonal_down(&self) -> &bool { + pub fn get_diagonal_down(&self) -> bool { self.diagonal_down.get_value() } @@ -242,7 +242,7 @@ impl Borders { } #[inline] - pub fn get_diagonal_up(&self) -> &bool { + pub fn get_diagonal_up(&self) -> bool { self.diagonal_up.get_value() } diff --git a/src/structs/borders_crate.rs b/src/structs/borders_crate.rs index 093b5006..516d1688 100644 --- a/src/structs/borders_crate.rs +++ b/src/structs/borders_crate.rs @@ -21,6 +21,7 @@ impl BordersCrate { } #[inline] + #[allow(dead_code)] pub(crate) fn get_borders_mut(&mut self) -> &mut ThinVec { &mut self.borders } diff --git a/src/structs/break.rs b/src/structs/break.rs index d7c97e12..0ca210d0 100644 --- a/src/structs/break.rs +++ b/src/structs/break.rs @@ -18,7 +18,7 @@ pub struct Break { impl Break { #[inline] - pub fn get_id(&self) -> &u32 { + pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -29,7 +29,7 @@ impl Break { } #[inline] - pub fn get_max(&self) -> &u32 { + pub fn get_max(&self) -> u32 { self.max.get_value() } @@ -40,7 +40,7 @@ impl Break { } #[inline] - pub fn get_manual_page_break(&self) -> &bool { + pub fn get_manual_page_break(&self) -> bool { self.manual_page_break.get_value() } diff --git a/src/structs/byte_value.rs b/src/structs/byte_value.rs index 86fd8ed6..f7fd702b 100644 --- a/src/structs/byte_value.rs +++ b/src/structs/byte_value.rs @@ -4,11 +4,8 @@ pub struct ByteValue { } impl ByteValue { #[inline] - pub(crate) fn get_value(&self) -> &u8 { - match &self.value { - Some(v) => v, - None => &0, - } + pub(crate) fn get_value(&self) -> u8 { + self.value.unwrap_or(0) } #[inline] diff --git a/src/structs/cache_field.rs b/src/structs/cache_field.rs index 6a6e6ced..2ea0cac9 100644 --- a/src/structs/cache_field.rs +++ b/src/structs/cache_field.rs @@ -20,12 +20,13 @@ impl CacheField { self.name.get_value_str() } + #[allow(dead_code)] pub(crate) fn set_name>(&mut self, value: S) -> &mut Self { self.name.set_value(value); self } - pub fn get_number_format_id(&self) -> &u32 { + pub fn get_number_format_id(&self) -> u32 { self.number_format_id.get_value() } @@ -47,6 +48,7 @@ impl CacheField { self } + #[allow(dead_code)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -73,6 +75,7 @@ impl CacheField { ); } + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // pivotField write_start_tag( diff --git a/src/structs/cache_fields.rs b/src/structs/cache_fields.rs index b17f8376..853b8ade 100644 --- a/src/structs/cache_fields.rs +++ b/src/structs/cache_fields.rs @@ -1,10 +1,6 @@ // cacheFields use crate::reader::driver::*; -use crate::structs::BooleanValue; -use crate::structs::ByteValue; use crate::structs::CacheField; -use crate::structs::StringValue; -use crate::structs::UInt32Value; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -29,6 +25,7 @@ impl CacheFields { self } + #[allow(dead_code, unused_variables)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -52,6 +49,7 @@ impl CacheFields { ); } + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // cacheFields write_start_tag( diff --git a/src/structs/cache_source.rs b/src/structs/cache_source.rs index 8084b161..00a9253e 100644 --- a/src/structs/cache_source.rs +++ b/src/structs/cache_source.rs @@ -3,7 +3,6 @@ use crate::structs::EnumValue; use crate::structs::SourceValues; use crate::structs::WorksheetSource; -use crate::helper::const_str::*; use crate::reader::driver::*; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; @@ -40,6 +39,7 @@ impl CacheSource { self } + #[allow(dead_code)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -70,20 +70,19 @@ impl CacheSource { ); } + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // cacheSource let empty_flg = self.worksheet_source.is_none(); - let mut attributes: Vec<(&str, &str)> = Vec::new(); - attributes.push(("type", self.r#type.get_hash_string())); + let attributes = vec![("type", self.r#type.get_hash_string())]; + write_start_tag(writer, "cacheSource", attributes, empty_flg); if !empty_flg { // worksheetSource - match &self.worksheet_source { - Some(v) => v.write_to(writer), - None => {} + if let Some(v) = &self.worksheet_source { + v.write_to(writer) } - write_end_tag(writer, "cacheSource"); } } diff --git a/src/structs/cell.rs b/src/structs/cell.rs index 5c8d8462..9b623e60 100644 --- a/src/structs/cell.rs +++ b/src/structs/cell.rs @@ -86,13 +86,13 @@ impl Cell { let CellCoordinates { col, row } = coordinate.into(); let formula = self.cell_value.get_formula(); - if formula != "" { + if !formula.is_empty() { let org_col_num = self.coordinate.get_col_num(); let org_row_num = self.coordinate.get_row_num(); - let offset_col_num = col as i32 - *org_col_num as i32; - let offset_row_num = row as i32 - *org_row_num as i32; + let offset_col_num = col as i32 - org_col_num as i32; + let offset_row_num = row as i32 - org_row_num as i32; let mut tokens = parse_to_tokens(format!("={}", formula)); - adjustment_formula_coordinate(&mut tokens, &offset_col_num, &offset_row_num); + adjustment_formula_coordinate(&mut tokens, offset_col_num, offset_row_num); let result_formula = render(tokens.as_ref()); self.cell_value.set_formula(result_formula); } @@ -122,7 +122,7 @@ impl Cell { } #[inline] - pub fn get_cell_meta_index(&self) -> &u32 { + pub fn get_cell_meta_index(&self) -> u32 { self.cell_meta_index.get_value() } @@ -273,7 +273,7 @@ impl Cell { } #[inline] - pub fn get_formula_shared_index(&self) -> Option<&u32> { + pub fn get_formula_shared_index(&self) -> Option { if let Some(v) = self.get_formula_obj() { if v.get_formula_type() == &CellFormulaValues::Shared { return Some(v.get_shared_index()); @@ -282,7 +282,7 @@ impl Cell { None } - pub(crate) fn get_width_point(&self, column_font_size: &f64) -> f64 { + pub(crate) fn get_width_point(&self, column_font_size: f64) -> f64 { // get cell value len. let char_cnt = self.get_width_point_cell(); @@ -452,7 +452,7 @@ impl Cell { writer: &mut Writer>>, shared_string_table: &Arc>, stylesheet: &mut Stylesheet, - formula_shared_list: &HashMap<&u32, (String, Option)>, + formula_shared_list: &HashMap)>, ) { let empty_flag_value = self.cell_value.is_empty(); let empty_flag_style = self.style.is_empty(); @@ -478,11 +478,11 @@ impl Cell { attributes.push(("s", &xf_index_str)); } - let cell_meta_index_str = self.cell_meta_index.get_value_string(); - if self.cell_meta_index.has_value() { - // NOT SUPPORT - //attributes.push(("cm", &cell_meta_index_str)); - } + // NOT SUPPORTED + // let cell_meta_index_str = self.cell_meta_index.get_value_string(); + // if self.cell_meta_index.has_value() { + // attributes.push(("cm", &cell_meta_index_str)); + // } if empty_flag_value { write_start_tag(writer, "c", attributes, true); @@ -491,11 +491,8 @@ impl Cell { write_start_tag(writer, "c", attributes, false); // f - match &self.cell_value.formula { - Some(v) => { - v.write_to(writer, &coordinate, formula_shared_list); - } - None => {} + if let Some(v) = &self.cell_value.formula { + v.write_to(writer, &coordinate, formula_shared_list); } // v @@ -537,10 +534,10 @@ impl AdjustmentCoordinate for Cell { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.coordinate.adjustment_insert_coordinate( root_col_num, @@ -553,10 +550,10 @@ impl AdjustmentCoordinate for Cell { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.coordinate.adjustment_remove_coordinate( root_col_num, @@ -572,10 +569,10 @@ impl AdjustmentCoordinateWith2Sheet for Cell { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.cell_value.adjustment_insert_coordinate_with_2sheet( self_sheet_name, @@ -592,10 +589,10 @@ impl AdjustmentCoordinateWith2Sheet for Cell { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.cell_value.adjustment_remove_coordinate_with_2sheet( self_sheet_name, diff --git a/src/structs/cell_format.rs b/src/structs/cell_format.rs index 056f950d..0f3d00c8 100644 --- a/src/structs/cell_format.rs +++ b/src/structs/cell_format.rs @@ -5,7 +5,6 @@ use super::Protection; use super::UInt32Value; use crate::reader::driver::*; use crate::writer::driver::*; -use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -30,7 +29,7 @@ pub(crate) struct CellFormat { impl CellFormat { #[inline] - pub(crate) fn get_number_format_id(&self) -> &u32 { + pub(crate) fn get_number_format_id(&self) -> u32 { self.number_format_id.get_value() } @@ -41,7 +40,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_font_id(&self) -> &u32 { + pub(crate) fn get_font_id(&self) -> u32 { self.font_id.get_value() } @@ -52,7 +51,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_fill_id(&self) -> &u32 { + pub(crate) fn get_fill_id(&self) -> u32 { self.fill_id.get_value() } @@ -63,7 +62,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_border_id(&self) -> &u32 { + pub(crate) fn get_border_id(&self) -> u32 { self.border_id.get_value() } @@ -74,7 +73,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_format_id(&self) -> &u32 { + pub(crate) fn get_format_id(&self) -> u32 { self.format_id.get_value() } @@ -85,7 +84,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_apply_number_format(&self) -> &bool { + pub(crate) fn get_apply_number_format(&self) -> bool { self.apply_number_format.get_value() } @@ -101,7 +100,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_apply_fill(&self) -> &bool { + pub(crate) fn get_apply_fill(&self) -> bool { self.apply_fill.get_value() } @@ -117,7 +116,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_apply_border(&self) -> &bool { + pub(crate) fn get_apply_border(&self) -> bool { self.apply_border.get_value() } @@ -133,7 +132,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_apply_font(&self) -> &bool { + pub(crate) fn get_apply_font(&self) -> bool { self.apply_font.get_value() } @@ -149,7 +148,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_apply_alignment(&self) -> &bool { + pub(crate) fn get_apply_alignment(&self) -> bool { self.apply_alignment.get_value() } @@ -165,7 +164,7 @@ impl CellFormat { } #[inline] - pub(crate) fn get_apply_protection(&self) -> &bool { + pub(crate) fn get_apply_protection(&self) -> bool { self.apply_protection.get_value() } diff --git a/src/structs/cell_formula.rs b/src/structs/cell_formula.rs index a09811a9..6ae7a71a 100644 --- a/src/structs/cell_formula.rs +++ b/src/structs/cell_formula.rs @@ -8,7 +8,6 @@ use crate::structs::StringValue; use crate::structs::UInt32Value; use crate::traits::AdjustmentCoordinateWith2Sheet; use crate::writer::driver::*; -use quick_xml::de; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -32,7 +31,7 @@ pub struct CellFormula { } impl CellFormula { #[inline] - pub fn get_bx(&self) -> &bool { + pub fn get_bx(&self) -> bool { self.bx.get_value() } @@ -43,7 +42,7 @@ impl CellFormula { } #[inline] - pub fn get_data_table_2d(&self) -> &bool { + pub fn get_data_table_2d(&self) -> bool { self.data_table_2d.get_value() } @@ -54,7 +53,7 @@ impl CellFormula { } #[inline] - pub fn get_data_table_row(&self) -> &bool { + pub fn get_data_table_row(&self) -> bool { self.data_table_row.get_value() } @@ -75,7 +74,7 @@ impl CellFormula { } #[inline] - pub fn get_input_1deleted(&self) -> &bool { + pub fn get_input_1deleted(&self) -> bool { self.input_1deleted.get_value() } @@ -86,7 +85,7 @@ impl CellFormula { } #[inline] - pub fn get_input_2deleted(&self) -> &bool { + pub fn get_input_2deleted(&self) -> bool { self.input_2deleted.get_value() } @@ -130,7 +129,7 @@ impl CellFormula { } #[inline] - pub fn get_shared_index(&self) -> &u32 { + pub fn get_shared_index(&self) -> u32 { self.shared_index.get_value() } @@ -196,7 +195,7 @@ impl CellFormula { // Shared if self.formula_type.get_value() == &CellFormulaValues::Shared { - match formula_shared_list.get(self.shared_index.get_value()) { + match formula_shared_list.get(&self.shared_index.get_value()) { Some((parent_cell_reference_str, token)) => { let parent_cell = index_from_coordinate(parent_cell_reference_str); let self_cell = index_from_coordinate(cell_reference_str); @@ -213,10 +212,10 @@ impl CellFormula { let mut token_new = token.clone(); let value = adjustment_insert_formula_coordinate( &mut token_new, - &root_col_num, - &offset_col_num, - &root_row_num, - &offset_row_num, + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, "", "", true, @@ -225,7 +224,7 @@ impl CellFormula { } None => { formula_shared_list.insert( - self.shared_index.get_value().clone(), + self.shared_index.get_value(), ( cell_reference_str.to_string(), parse_to_tokens(format!("={}", self.text.get_value_str())), @@ -240,41 +239,41 @@ impl CellFormula { &self, writer: &mut Writer>>, coordinate: &str, - formula_shared_list: &HashMap<&u32, (String, Option)>, + formula_shared_list: &HashMap)>, ) { // f let mut attributes: Vec<(&str, &str)> = Vec::new(); let bx_str = self.bx.get_value_string(); if self.bx.has_value() { - attributes.push(("bx", &bx_str)); + attributes.push(("bx", bx_str)); } let data_table_2d_str = self.data_table_2d.get_value_string(); if self.data_table_2d.has_value() { - attributes.push(("dt2D", &data_table_2d_str)); + attributes.push(("dt2D", data_table_2d_str)); } let data_table_row_str = self.data_table_row.get_value_string(); if self.data_table_row.has_value() { - attributes.push(("dtr", &data_table_row_str)); + attributes.push(("dtr", data_table_row_str)); } let formula_type_str = self.formula_type.get_value_string(); if self.formula_type.has_value() { // Not SUPPORT Array if self.formula_type.get_value() != &CellFormulaValues::Array { - attributes.push(("t", &formula_type_str)); + attributes.push(("t", formula_type_str)); } } let input_1deleted_str = self.input_1deleted.get_value_string(); if self.input_1deleted.has_value() { - attributes.push(("del1", &input_1deleted_str)); + attributes.push(("del1", input_1deleted_str)); } let input_2deleted_str = self.input_2deleted.get_value_string(); if self.input_2deleted.has_value() { - attributes.push(("del2", &input_2deleted_str)); + attributes.push(("del2", input_2deleted_str)); } if self.r1.has_value() { @@ -285,22 +284,19 @@ impl CellFormula { attributes.push(("r2", self.r2.get_value_str())); } + #[allow(unused_assignments)] let mut reference_str = String::from(""); - match formula_shared_list.get(self.shared_index.get_value()) { - Some((start_col, end_col)) => { - if coordinate == start_col { - reference_str = match end_col { - Some(v) => { - format!("{}:{}", start_col, v) - } - None => { - format!("{}", start_col) - } - }; - attributes.push(("ref", &reference_str)); - } + if let Some((start_col, end_col)) = formula_shared_list.get(&self.shared_index.get_value()) + { + if coordinate == start_col { + reference_str = match end_col { + Some(v) => { + format!("{}:{}", start_col, v) + } + None => start_col.to_string(), + }; + attributes.push(("ref", &reference_str)); } - None => {} } let shared_index_str = self.shared_index.get_value_string(); @@ -318,10 +314,10 @@ impl AdjustmentCoordinateWith2Sheet for CellFormula { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if let Some(v) = self.text.get_value() { let formula = adjustment_insert_formula_coordinate( @@ -355,10 +351,10 @@ impl AdjustmentCoordinateWith2Sheet for CellFormula { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if let Some(v) = self.text.get_value() { let formula = adjustment_remove_formula_coordinate( diff --git a/src/structs/cell_style.rs b/src/structs/cell_style.rs index 979fd56c..78844c1e 100644 --- a/src/structs/cell_style.rs +++ b/src/structs/cell_style.rs @@ -28,7 +28,7 @@ impl CellStyle { } #[inline] - pub fn get_builtin_id(&self) -> &u32 { + pub fn get_builtin_id(&self) -> u32 { self.builtin_id.get_value() } @@ -39,7 +39,7 @@ impl CellStyle { } #[inline] - pub fn get_format_id(&self) -> &u32 { + pub fn get_format_id(&self) -> u32 { self.format_id.get_value() } diff --git a/src/structs/cell_value.rs b/src/structs/cell_value.rs index f0fffb2c..23958d6d 100644 --- a/src/structs/cell_value.rs +++ b/src/structs/cell_value.rs @@ -1,7 +1,6 @@ use super::RichText; use super::SharedStringItem; use super::Text; -use crate::helper::formula::*; use crate::structs::CellFormula; use crate::structs::CellRawValue; use crate::traits::AdjustmentCoordinateWith2Sheet; @@ -252,10 +251,10 @@ impl AdjustmentCoordinateWith2Sheet for CellValue { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if let Some(v) = &mut self.formula { v.adjustment_insert_coordinate_with_2sheet( @@ -274,10 +273,10 @@ impl AdjustmentCoordinateWith2Sheet for CellValue { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if let Some(v) = &mut self.formula { v.adjustment_remove_coordinate_with_2sheet( @@ -324,7 +323,7 @@ mod tests { fn error_checking() { let path = std::path::Path::new("./tests/test_files/pr_204.xlsx"); let book = crate::reader::xlsx::read(path).unwrap(); - let sheet = book.get_sheet(&0).unwrap(); + let sheet = book.get_sheet(0).unwrap(); let cell = sheet.get_cell_value("A1"); assert!(cell.raw_value.is_error()); diff --git a/src/structs/cells.rs b/src/structs/cells.rs index 5c435cbc..706ead7a 100644 --- a/src/structs/cells.rs +++ b/src/structs/cells.rs @@ -7,7 +7,6 @@ use crate::structs::Column; use crate::structs::Row; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWith2Sheet; -use crate::traits::AdjustmentCoordinateWithSheet; use std::collections::HashMap; #[derive(Clone, Default, Debug)] @@ -48,7 +47,7 @@ impl Cells { } #[inline] - pub fn get_collection_by_column(&self, column_num: &u32) -> Vec<&Cell> { + pub fn get_collection_by_column(&self, column_num: u32) -> Vec<&Cell> { self.map .values() .filter(|k| k.get_coordinate().get_col_num() == column_num) @@ -57,7 +56,7 @@ impl Cells { } #[inline] - pub fn get_collection_by_row(&self, row_num: &u32) -> Vec<&Cell> { + pub fn get_collection_by_row(&self, row_num: u32) -> Vec<&Cell> { self.map .values() .filter(|k| k.get_coordinate().get_row_num() == row_num) @@ -66,19 +65,19 @@ impl Cells { } #[inline] - pub fn get_collection_by_column_to_hashmap(&self, column_num: &u32) -> HashMap { + pub fn get_collection_by_column_to_hashmap(&self, column_num: u32) -> HashMap { self.map .iter() - .filter(|(k, _v)| &k.1 == column_num) + .filter(|(k, _v)| k.1 == column_num) .map(|(k, v)| (k.0, v.as_ref())) .collect() } #[inline] - pub fn get_collection_by_row_to_hashmap(&self, row_num: &u32) -> HashMap { + pub fn get_collection_by_row_to_hashmap(&self, row_num: u32) -> HashMap { self.map .iter() - .filter(|(k, _v)| &k.0 == row_num) + .filter(|(k, _v)| k.0 == row_num) .map(|(k, v)| (k.1, v.as_ref())) .collect() } @@ -198,8 +197,8 @@ impl Cells { } #[inline] - pub(crate) fn remove(&mut self, col_num: &u32, row_num: &u32) -> bool { - let k = (*row_num, *col_num); + pub(crate) fn remove(&mut self, col_num: u32, row_num: u32) -> bool { + let k = (row_num, col_num); self.map.remove(&k).is_some() } @@ -208,7 +207,7 @@ impl Cells { let range_upper = range.to_uppercase(); let coordinate_list = get_coordinate_list(&range_upper); for (col_num, row_num) in coordinate_list { - result.push(self.get((&col_num, &row_num))); + result.push(self.get((col_num, row_num))); } result } @@ -218,13 +217,13 @@ impl Cells { let range_upper = range.to_uppercase(); let coordinate_list = get_coordinate_list(&range_upper); for (col_num, row_num) in coordinate_list { - result.push(self.get_cell_value((&col_num, &row_num))); + result.push(self.get_cell_value((col_num, row_num))); } result } #[inline] - pub fn get_formatted_value_by_column_and_row(&self, col_num: &u32, row_num: &u32) -> String { + pub fn get_formatted_value_by_column_and_row(&self, col_num: u32, row_num: u32) -> String { match self.get((col_num, row_num)) { Some(v) => v.get_formatted_value(), None => "".into(), @@ -238,8 +237,8 @@ impl Cells { .map(|(_, cell)| { ( ( - *cell.get_coordinate().get_row_num(), - *cell.get_coordinate().get_col_num(), + cell.get_coordinate().get_row_num(), + cell.get_coordinate().get_col_num(), ), std::mem::take(cell), ) @@ -251,10 +250,10 @@ impl AdjustmentCoordinate for Cells { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { // update cell for ((_, _), cell) in self.get_collection_to_hashmap_mut() { @@ -271,13 +270,13 @@ impl AdjustmentCoordinate for Cells { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { // update cell - self.map.retain(|k, x| { + self.map.retain(|_, x| { !(x.get_coordinate().is_remove_coordinate( root_col_num, offset_col_num, @@ -302,10 +301,10 @@ impl AdjustmentCoordinateWith2Sheet for Cells { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for ((_, _), cell) in self.get_collection_to_hashmap_mut() { cell.adjustment_insert_coordinate_with_2sheet( @@ -324,10 +323,10 @@ impl AdjustmentCoordinateWith2Sheet for Cells { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for ((_, _), cell) in self.get_collection_to_hashmap_mut() { cell.adjustment_remove_coordinate_with_2sheet( diff --git a/src/structs/chart.rs b/src/structs/chart.rs index 2f32e1d2..84cd5f98 100644 --- a/src/structs/chart.rs +++ b/src/structs/chart.rs @@ -106,15 +106,15 @@ use crate::traits::AdjustmentCoordinateWithSheet; /// // Get Chart by Worksheet. /// let mut worksheet = book.get_sheet_by_name_mut("Sheet1").unwrap(); /// let chart = worksheet.get_chart("C1"); -/// let chart = worksheet.get_chart_by_column_and_row(&3, &1); +/// let chart = worksheet.get_chart_by_column_and_row(&3, 1); /// let chart = worksheet.get_chart_mut("C1"); -/// let chart = worksheet.get_chart_by_column_and_row_mut(&3, &1); +/// let chart = worksheet.get_chart_by_column_and_row_mut(&3, 1); /// /// // Use this if there are multiple Charts in a given cell. /// let charts = worksheet.get_charts("C1"); -/// let charts = worksheet.get_charts_by_column_and_row(&3, &1); +/// let charts = worksheet.get_charts_by_column_and_row(&3, 1); /// let charts = worksheet.get_charts_mut("C1"); -/// let charts = worksheet.get_charts_by_column_and_row_mut(&3, &1); +/// let charts = worksheet.get_charts_by_column_and_row_mut(&3, 1); /// /// // Set Chart Title, Series Title, Horizonal Title and Vertical Title. /// let mut chart = book.get_sheet_by_name_mut("Sheet1").unwrap().get_chart_mut("C1").unwrap(); @@ -278,9 +278,7 @@ impl Chart { pub fn get_chart_space(&self) -> &ChartSpace { match self.two_cell_anchor.get_graphic_frame() { - Some(v) => { - return v.get_graphic().get_graphic_data().get_chart_space(); - } + Some(v) => v.get_graphic().get_graphic_data().get_chart_space(), None => { panic!("Non-ChartSpace."); } @@ -289,12 +287,10 @@ impl Chart { pub fn get_chart_space_mut(&mut self) -> &mut ChartSpace { match self.two_cell_anchor.get_graphic_frame_mut() { - Some(v) => { - return v - .get_graphic_mut() - .get_graphic_data_mut() - .get_chart_space_mut(); - } + Some(v) => v + .get_graphic_mut() + .get_graphic_data_mut() + .get_chart_space_mut(), None => { panic!("Non-ChartSpace."); } @@ -362,12 +358,12 @@ impl Chart { } #[inline] - pub(crate) fn get_col(&self) -> &u32 { + pub(crate) fn get_col(&self) -> u32 { self.two_cell_anchor.get_from_marker().get_col() } #[inline] - pub(crate) fn get_row(&self) -> &u32 { + pub(crate) fn get_row(&self) -> u32 { self.two_cell_anchor.get_from_marker().get_row() } @@ -2209,10 +2205,10 @@ impl AdjustmentCoordinate for Chart { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.two_cell_anchor.as_mut().adjustment_insert_coordinate( root_col_num, @@ -2225,10 +2221,10 @@ impl AdjustmentCoordinate for Chart { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.two_cell_anchor.as_mut().adjustment_remove_coordinate( root_col_num, @@ -2241,10 +2237,10 @@ impl AdjustmentCoordinate for Chart { #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { self.two_cell_anchor.as_ref().is_remove_coordinate( root_col_num, @@ -2259,10 +2255,10 @@ impl AdjustmentCoordinateWithSheet for Chart { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.two_cell_anchor .as_mut() @@ -2279,10 +2275,10 @@ impl AdjustmentCoordinateWithSheet for Chart { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.two_cell_anchor .as_mut() diff --git a/src/structs/color.rs b/src/structs/color.rs index 564edf7a..385f04de 100644 --- a/src/structs/color.rs +++ b/src/structs/color.rs @@ -101,9 +101,8 @@ impl Color { /// In that case, use get_argb_with_theme(&self, theme: &Theme). pub fn get_argb(&self) -> &str { if self.indexed.has_value() { - match INDEXED_COLORS.get(self.indexed.get_value().clone() as usize) { - Some(v) => return v, - None => {} + if let Some(v) = INDEXED_COLORS.get(self.indexed.get_value() as usize) { + return v; } } self.argb.get_value_str() @@ -121,20 +120,17 @@ impl Color { return self.get_argb().to_owned().into(); } if self.theme_index.has_value() { - let key = self.theme_index.get_value().clone(); - match theme + let key = self.theme_index.get_value(); + if let Some(v) = theme .get_theme_elements() .get_color_scheme() .get_color_map() .get(key as usize) { - Some(v) => { - if self.tint.has_value() { - return calc_tint(v, self.tint.get_value()).into(); - } - return v.to_string().into(); + if self.tint.has_value() { + return calc_tint(v, self.tint.get_value()).into(); } - None => {} + return v.to_string().into(); } } self.argb.get_value_str().to_string().into() @@ -158,7 +154,7 @@ impl Color { } #[inline] - pub fn get_indexed(&self) -> &u32 { + pub fn get_indexed(&self) -> u32 { self.indexed.get_value() } @@ -171,7 +167,7 @@ impl Color { } #[inline] - pub fn get_theme_index(&self) -> &u32 { + pub fn get_theme_index(&self) -> u32 { self.theme_index.get_value() } @@ -184,7 +180,7 @@ impl Color { } #[inline] - pub fn get_tint(&self) -> &f64 { + pub fn get_tint(&self) -> f64 { self.tint.get_value() } @@ -228,28 +224,25 @@ impl Color { e: &BytesStart, empty_flg: bool, ) { - for a in e.attributes().with_checks(false) { - match a { - Ok(ref attr) => match attr.key.0 { - b"indexed" => { - self.indexed - .set_value_string(get_attribute_value(attr).unwrap()); - } - b"theme" => { - self.theme_index - .set_value_string(get_attribute_value(attr).unwrap()); - } - b"rgb" => { - self.argb - .set_value_string(get_attribute_value(attr).unwrap()); - } - b"tint" => { - self.tint - .set_value_string(get_attribute_value(attr).unwrap()); - } - _ => {} - }, - Err(_) => {} + for attr in e.attributes().with_checks(false).flatten() { + match attr.key.0 { + b"indexed" => { + self.indexed + .set_value_string(get_attribute_value(&attr).unwrap()); + } + b"theme" => { + self.theme_index + .set_value_string(get_attribute_value(&attr).unwrap()); + } + b"rgb" => { + self.argb + .set_value_string(get_attribute_value(&attr).unwrap()); + } + b"tint" => { + self.tint + .set_value_string(get_attribute_value(&attr).unwrap()); + } + _ => {} } } @@ -336,7 +329,7 @@ mod tests { let mut obj = Color::default(); obj.set_argb("FFFF8080"); - assert_eq!(obj.get_indexed(), &21); + assert_eq!(obj.get_indexed(), 21); assert_eq!(obj.get_argb(), "FFFF8080"); let mut obj = Color::default(); diff --git a/src/structs/column.rs b/src/structs/column.rs index d40e66f9..9852a6af 100644 --- a/src/structs/column.rs +++ b/src/structs/column.rs @@ -53,7 +53,7 @@ impl Default for Column { impl Column { #[inline] - pub fn get_col_num(&self) -> &u32 { + pub fn get_col_num(&self) -> u32 { self.col_num.get_value() } @@ -64,7 +64,7 @@ impl Column { } #[inline] - pub fn get_width(&self) -> &f64 { + pub fn get_width(&self) -> f64 { self.width.get_value() } @@ -75,7 +75,7 @@ impl Column { } #[inline] - pub fn get_hidden(&self) -> &bool { + pub fn get_hidden(&self) -> bool { self.hidden.get_value() } @@ -86,7 +86,7 @@ impl Column { } #[inline] - pub fn get_best_fit(&self) -> &bool { + pub fn get_best_fit(&self) -> bool { self.best_fit.get_value() } @@ -113,7 +113,7 @@ impl Column { } #[inline] - pub fn get_auto_width(&self) -> &bool { + pub fn get_auto_width(&self) -> bool { self.auto_width.get_value() } @@ -124,7 +124,7 @@ impl Column { } pub(crate) fn calculation_auto_width(&mut self, cells: &Cells) -> &mut Self { - if !*self.get_auto_width() { + if !self.get_auto_width() { return self; } @@ -132,7 +132,7 @@ impl Column { // default font size len. let column_font_size = match self.get_style().get_font() { - Some(font) => *font.get_font_size().get_val(), + Some(font) => font.get_font_size().get_val(), None => 11f64, }; @@ -140,10 +140,10 @@ impl Column { cell_list.sort_by(|a, b| { a.get_coordinate() .get_row_num() - .cmp(b.get_coordinate().get_row_num()) + .cmp(&b.get_coordinate().get_row_num()) }); for cell in cell_list { - let column_width = cell.get_width_point(&column_font_size); + let column_width = cell.get_width_point(column_font_size); if column_width > column_width_max { column_width_max = column_width; @@ -161,7 +161,7 @@ impl Column { #[inline] pub(crate) fn has_style(&self) -> bool { - &*self.style != &Style::default() + *self.style != Style::default() } #[inline] @@ -195,7 +195,7 @@ impl Column { } impl AdjustmentValue for Column { #[inline] - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { if self.col_num.get_value() >= root_num { self.col_num .set_value(self.col_num.get_value() + offset_num); @@ -203,7 +203,7 @@ impl AdjustmentValue for Column { } #[inline] - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { if self.col_num.get_value() >= root_num { self.col_num .set_value(self.col_num.get_value() - offset_num); @@ -211,8 +211,7 @@ impl AdjustmentValue for Column { } #[inline] - fn is_remove_value(&self, root_num: &u32, offset_num: &u32) -> bool { - self.col_num.get_value() >= root_num - && self.col_num.get_value() <= &(root_num + offset_num - 1) + fn is_remove_value(&self, root_num: u32, offset_num: u32) -> bool { + self.col_num.get_value() >= root_num && self.col_num.get_value() < root_num + offset_num } } diff --git a/src/structs/column_breaks.rs b/src/structs/column_breaks.rs index b105ad62..dbf55227 100644 --- a/src/structs/column_breaks.rs +++ b/src/structs/column_breaks.rs @@ -65,7 +65,7 @@ impl ColumnBreaks { let mut manual_count = 0; for obj in self.get_break_list() { count += 1; - if *obj.get_manual_page_break() { + if obj.get_manual_page_break() { manual_count += 1; } } diff --git a/src/structs/column_fields.rs b/src/structs/column_fields.rs index ffa3a907..988433bf 100644 --- a/src/structs/column_fields.rs +++ b/src/structs/column_fields.rs @@ -30,6 +30,7 @@ impl ColumnFields { } #[inline] + #[allow(unused_variables)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -54,6 +55,7 @@ impl ColumnFields { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // colFields write_start_tag( diff --git a/src/structs/column_items.rs b/src/structs/column_items.rs index b55316d0..1b01e71d 100644 --- a/src/structs/column_items.rs +++ b/src/structs/column_items.rs @@ -30,6 +30,7 @@ impl ColumnItems { } #[inline] + #[allow(unused_variables)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -61,6 +62,7 @@ impl ColumnItems { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // colItems write_start_tag( diff --git a/src/structs/column_reference.rs b/src/structs/column_reference.rs index 7d4ee4b0..5c65f7aa 100644 --- a/src/structs/column_reference.rs +++ b/src/structs/column_reference.rs @@ -19,8 +19,8 @@ impl Default for ColumnReference { impl ColumnReference { #[inline] - pub fn get_num(&self) -> &u32 { - &self.num + pub fn get_num(&self) -> u32 { + self.num } #[inline] @@ -53,8 +53,8 @@ impl ColumnReference { } #[inline] - pub fn get_is_lock(&self) -> &bool { - &self.is_lock + pub fn get_is_lock(&self) -> bool { + self.is_lock } #[inline] @@ -74,23 +74,23 @@ impl ColumnReference { format!( "{}{}", if self.is_lock { "$" } else { "" }, - string_from_column_index(&self.num), + string_from_column_index(self.num), ) } } impl AdjustmentValue for ColumnReference { #[inline] - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { - self.num = adjustment_insert_coordinate(&self.num, root_num, offset_num); + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { + self.num = adjustment_insert_coordinate(self.num, root_num, offset_num); } #[inline] - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { - self.num = adjustment_remove_coordinate(&self.num, root_num, offset_num); + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { + self.num = adjustment_remove_coordinate(self.num, root_num, offset_num); } #[inline] - fn is_remove_value(&self, root_num: &u32, offset_num: &u32) -> bool { - is_remove_coordinate(&self.num, root_num, offset_num) + fn is_remove_value(&self, root_num: u32, offset_num: u32) -> bool { + is_remove_coordinate(self.num, root_num, offset_num) } } diff --git a/src/structs/columns.rs b/src/structs/columns.rs index 96df9e71..cc39df44 100644 --- a/src/structs/columns.rs +++ b/src/structs/columns.rs @@ -29,16 +29,16 @@ impl Columns { } #[inline] - pub(crate) fn get_column(&self, value: &u32) -> Option<&Column> { + pub(crate) fn get_column(&self, value: u32) -> Option<&Column> { self.column .iter() .find(|&column| value == column.get_col_num()) } - pub(crate) fn get_column_mut(&mut self, value: &u32) -> &mut Column { + pub(crate) fn get_column_mut(&mut self, value: u32) -> &mut Column { if self.get_column(value).is_none() { let mut obj = Column::default(); - obj.set_col_num(*value); + obj.set_col_num(value); self.set_column(obj); } for column in self.get_column_collection_mut() { @@ -114,31 +114,31 @@ impl Columns { // col let mut column_copy = self.column.clone(); - column_copy.sort_by(|a, b| a.get_col_num().cmp(b.get_col_num())); + column_copy.sort_by_key(|a| a.get_col_num()); let mut column_iter = column_copy.iter(); let mut column_raw = column_iter.next(); let mut obj = column_raw.unwrap(); - let mut min = *obj.get_col_num(); + let mut min = obj.get_col_num(); let mut max = min; loop { column_raw = column_iter.next(); match column_raw { Some(column) => { - if column.get_col_num() == &(max + 1) + if column.get_col_num() == max + 1 && column.get_hash_code() == obj.get_hash_code() && column.get_style() == obj.get_style() { max += 1; } else { - self.write_to_column(writer, &min, &max, obj, stylesheet); + self.write_to_column(writer, min, max, obj, stylesheet); obj = column; - min = *obj.get_col_num(); + min = obj.get_col_num(); max = min; } } None => { - self.write_to_column(writer, &min, &max, obj, stylesheet); + self.write_to_column(writer, min, max, obj, stylesheet); break; } } @@ -150,8 +150,8 @@ impl Columns { pub(crate) fn write_to_column( &self, writer: &mut Writer>>, - min: &u32, - max: &u32, + min: u32, + max: u32, column: &Column, stylesheet: &mut Stylesheet, ) { @@ -163,10 +163,10 @@ impl Columns { attributes.push(("max", max_str.as_str())); let width = column.width.get_value_string(); attributes.push(("width", &width)); - if *column.hidden.get_value() { + if column.hidden.get_value() { attributes.push(("hidden", column.hidden.get_value_string())); } - if *column.best_fit.get_value() { + if column.best_fit.get_value() { attributes.push(("bestFit", column.best_fit.get_value_string())); } attributes.push(("customWidth", "1")); @@ -180,13 +180,13 @@ impl Columns { } } impl AdjustmentValue for Columns { - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { for column_dimension in &mut self.column { column_dimension.adjustment_insert_value(root_num, offset_num); } } - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { self.get_column_collection_mut() .retain(|x| !(x.is_remove_value(root_num, offset_num))); for column_dimension in &mut self.column { diff --git a/src/structs/comment.rs b/src/structs/comment.rs index 26fd770a..cced0222 100644 --- a/src/structs/comment.rs +++ b/src/structs/comment.rs @@ -11,7 +11,6 @@ use super::vml::Path; use super::vml::Shadow; use super::vml::TextBox; use super::Coordinate; -use super::Fill; use super::RichText; use crate::helper::coordinate::*; use crate::reader::driver::*; @@ -207,10 +206,10 @@ impl AdjustmentCoordinate for Comment { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.coordinate.adjustment_insert_coordinate( root_col_num, @@ -229,10 +228,10 @@ impl AdjustmentCoordinate for Comment { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.coordinate.adjustment_remove_coordinate( root_col_num, @@ -251,10 +250,10 @@ impl AdjustmentCoordinate for Comment { #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { self.coordinate.is_remove_coordinate( root_col_num, diff --git a/src/structs/conditional_formatting.rs b/src/structs/conditional_formatting.rs index 0e9e397a..1d39b95a 100644 --- a/src/structs/conditional_formatting.rs +++ b/src/structs/conditional_formatting.rs @@ -123,10 +123,10 @@ impl AdjustmentCoordinate for ConditionalFormatting { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.sequence_of_references.adjustment_insert_coordinate( root_col_num, @@ -139,10 +139,10 @@ impl AdjustmentCoordinate for ConditionalFormatting { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.sequence_of_references.adjustment_remove_coordinate( root_col_num, @@ -155,10 +155,10 @@ impl AdjustmentCoordinate for ConditionalFormatting { #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { self.sequence_of_references.is_remove_coordinate( root_col_num, diff --git a/src/structs/conditional_formatting_rule.rs b/src/structs/conditional_formatting_rule.rs index 73a253d3..6e029032 100644 --- a/src/structs/conditional_formatting_rule.rs +++ b/src/structs/conditional_formatting_rule.rs @@ -76,7 +76,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_priority(&self) -> &i32 { + pub fn get_priority(&self) -> i32 { self.priority.get_value() } @@ -87,7 +87,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_percent(&self) -> &bool { + pub fn get_percent(&self) -> bool { self.percent.get_value() } @@ -98,7 +98,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_bottom(&self) -> &bool { + pub fn get_bottom(&self) -> bool { self.bottom.get_value() } @@ -109,7 +109,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_rank(&self) -> &u32 { + pub fn get_rank(&self) -> u32 { self.rank.get_value() } @@ -120,7 +120,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_stop_if_true(&self) -> &bool { + pub fn get_stop_if_true(&self) -> bool { self.stop_if_true.get_value() } @@ -131,7 +131,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_std_dev(&self) -> &i32 { + pub fn get_std_dev(&self) -> i32 { self.std_dev.get_value() } @@ -142,7 +142,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_above_average(&self) -> &bool { + pub fn get_above_average(&self) -> bool { self.above_average.get_value() } @@ -153,7 +153,7 @@ impl ConditionalFormattingRule { } #[inline] - pub fn get_equal_average(&self) -> &bool { + pub fn get_equal_average(&self) -> bool { self.equal_average.get_value() } diff --git a/src/structs/coordinate.rs b/src/structs/coordinate.rs index 2ce97523..c34f2033 100644 --- a/src/structs/coordinate.rs +++ b/src/structs/coordinate.rs @@ -1,3 +1,5 @@ +use std::fmt; + use super::ColumnReference; use super::RowReference; use crate::helper::coordinate::*; @@ -10,21 +12,25 @@ pub struct Coordinate { row: RowReference, } -impl ToString for Coordinate { - #[inline] - fn to_string(&self) -> String { - coordinate_from_index_with_lock( - self.column.get_num(), - self.row.get_num(), - self.column.get_is_lock(), - self.row.get_is_lock(), +impl fmt::Display for Coordinate { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "{}", + coordinate_from_index_with_lock( + self.column.get_num(), + self.row.get_num(), + self.column.get_is_lock(), + self.row.get_is_lock(), + ) ) } } impl Coordinate { #[inline] - pub fn get_col_num(&self) -> &u32 { + pub fn get_col_num(&self) -> u32 { self.column.get_num() } @@ -41,7 +47,7 @@ impl Coordinate { } #[inline] - pub fn get_row_num(&self) -> &u32 { + pub fn get_row_num(&self) -> u32 { self.row.get_num() } @@ -58,7 +64,7 @@ impl Coordinate { } #[inline] - pub fn get_is_lock_col(&self) -> &bool { + pub fn get_is_lock_col(&self) -> bool { self.column.get_is_lock() } @@ -69,7 +75,7 @@ impl Coordinate { } #[inline] - pub fn get_is_lock_row(&self) -> &bool { + pub fn get_is_lock_row(&self) -> bool { self.row.get_is_lock() } @@ -107,10 +113,10 @@ impl AdjustmentCoordinate for Coordinate { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.column .adjustment_insert_value(root_col_num, offset_col_num); @@ -121,10 +127,10 @@ impl AdjustmentCoordinate for Coordinate { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.column .adjustment_remove_value(root_col_num, offset_col_num); @@ -135,10 +141,10 @@ impl AdjustmentCoordinate for Coordinate { #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { self.column.is_remove_value(root_col_num, offset_col_num) || self.row.is_remove_value(root_row_num, offset_row_num) diff --git a/src/structs/csv_writer_option.rs b/src/structs/csv_writer_option.rs index 11511529..1e74239b 100644 --- a/src/structs/csv_writer_option.rs +++ b/src/structs/csv_writer_option.rs @@ -31,8 +31,8 @@ impl CsvWriterOption { } #[inline] - pub fn get_do_trim(&self) -> &bool { - &self.do_trim + pub fn get_do_trim(&self) -> bool { + self.do_trim } #[inline] diff --git a/src/structs/custom_properties/custom_document_property.rs b/src/structs/custom_properties/custom_document_property.rs index 929a57fc..7241d400 100644 --- a/src/structs/custom_properties/custom_document_property.rs +++ b/src/structs/custom_properties/custom_document_property.rs @@ -124,7 +124,7 @@ impl CustomDocumentProperty { ); } - pub(crate) fn write_to(&self, writer: &mut Writer>>, pid: &i32) { + pub(crate) fn write_to(&self, writer: &mut Writer>>, pid: i32) { let is_inner = self.custom_document_property_value.get_tag().is_some(); // property diff --git a/src/structs/custom_properties/properties.rs b/src/structs/custom_properties/properties.rs index e0b63bb8..885ef447 100644 --- a/src/structs/custom_properties/properties.rs +++ b/src/structs/custom_properties/properties.rs @@ -6,7 +6,6 @@ use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; use quick_xml::Writer; -use std::borrow::Cow; use std::io::Cursor; use thin_vec::ThinVec; @@ -49,7 +48,7 @@ impl Properties { #[inline] pub fn remove_custom_document_property_list( &mut self, - value: CustomDocumentProperty, + _value: CustomDocumentProperty, ) -> &mut Self { self.custom_document_property_list.clear(); self @@ -60,7 +59,6 @@ impl Properties { reader: &mut Reader, _e: &BytesStart, ) { - let mut value: String = String::from(""); xml_read_loop!( reader, Event::Empty(ref e) => { @@ -95,7 +93,7 @@ impl Properties { ); let mut pid = 2; for v in &self.custom_document_property_list { - v.write_to(writer, &pid); + v.write_to(writer, pid); pid += 1; } write_end_tag(writer, "Properties"); diff --git a/src/structs/data_field.rs b/src/structs/data_field.rs index 9381d810..af81a301 100644 --- a/src/structs/data_field.rs +++ b/src/structs/data_field.rs @@ -1,12 +1,10 @@ // dataField use crate::reader::driver::*; -use crate::structs::BooleanValue; use crate::structs::Int32Value; -use crate::structs::Location; use crate::structs::StringValue; use crate::structs::UInt32Value; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -21,17 +19,18 @@ pub struct DataField { impl DataField { #[inline] pub fn get_name(&self) -> &str { - &self.name.get_value_str() + self.name.get_value_str() } #[inline] + #[allow(dead_code)] pub(crate) fn set_name>(&mut self, value: S) -> &mut Self { self.name.set_value(value); self } #[inline] - pub fn get_fie_id(&self) -> &u32 { + pub fn get_fie_id(&self) -> u32 { self.fie_id.get_value() } @@ -42,7 +41,7 @@ impl DataField { } #[inline] - pub fn get_base_fie_id(&self) -> &i32 { + pub fn get_base_fie_id(&self) -> i32 { self.base_fie_id.get_value() } @@ -53,7 +52,7 @@ impl DataField { } #[inline] - pub fn get_base_item(&self) -> &u32 { + pub fn get_base_item(&self) -> u32 { self.base_item.get_value() } @@ -76,6 +75,7 @@ impl DataField { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // dataField write_start_tag( diff --git a/src/structs/data_fields.rs b/src/structs/data_fields.rs index 78b32f86..145d5d58 100644 --- a/src/structs/data_fields.rs +++ b/src/structs/data_fields.rs @@ -30,6 +30,7 @@ impl DataFields { } #[inline] + #[allow(unused_variables)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -54,6 +55,7 @@ impl DataFields { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // dataFields write_start_tag( diff --git a/src/structs/data_validation.rs b/src/structs/data_validation.rs index 781ecc1f..6b3c2ef1 100644 --- a/src/structs/data_validation.rs +++ b/src/structs/data_validation.rs @@ -50,7 +50,7 @@ impl DataValidation { } #[inline] - pub fn get_allow_blank(&self) -> &bool { + pub fn get_allow_blank(&self) -> bool { self.allow_blank.get_value() } @@ -61,7 +61,7 @@ impl DataValidation { } #[inline] - pub fn get_show_input_message(&self) -> &bool { + pub fn get_show_input_message(&self) -> bool { self.show_input_message.get_value() } @@ -72,7 +72,7 @@ impl DataValidation { } #[inline] - pub fn get_show_error_message(&self) -> &bool { + pub fn get_show_error_message(&self) -> bool { self.show_error_message.get_value() } diff --git a/src/structs/defined_name.rs b/src/structs/defined_name.rs index 2152d220..16acfa8e 100644 --- a/src/structs/defined_name.rs +++ b/src/structs/defined_name.rs @@ -23,7 +23,7 @@ pub struct DefinedName { impl DefinedName { #[inline] pub fn get_name(&self) -> &str { - &self.name.get_value_str() + self.name.get_value_str() } #[inline] @@ -46,7 +46,7 @@ impl DefinedName { pub fn set_address>(&mut self, value: S) -> &mut Self { let list = self.split_str(value); for v in &list { - if is_address(&v) { + if is_address(v) { self.add_address(v); } else { self.set_string_value(v); @@ -64,6 +64,7 @@ impl DefinedName { self } + #[allow(dead_code)] pub(crate) fn get_sheet_name_crate(&self) -> String { if self.string_value.has_value() { return String::from(""); @@ -81,6 +82,7 @@ impl DefinedName { } #[inline] + #[allow(dead_code)] pub(crate) fn get_address_obj_mut(&mut self) -> &mut ThinVec
{ &mut self.address } @@ -98,8 +100,8 @@ impl DefinedName { } #[inline] - pub fn get_local_sheet_id(&self) -> &u32 { - &self.local_sheet_id.get_value() + pub fn get_local_sheet_id(&self) -> u32 { + self.local_sheet_id.get_value() } #[inline] @@ -108,8 +110,8 @@ impl DefinedName { } #[inline] - pub fn get_hidden(&self) -> &bool { - &self.hidden.get_value() + pub fn get_hidden(&self) -> bool { + self.hidden.get_value() } #[inline] @@ -206,7 +208,7 @@ impl DefinedName { } let hidden_str = self.hidden.get_value_string(); if self.hidden.has_value() { - attributes.push(("hidden", &hidden_str)); + attributes.push(("hidden", hidden_str)); } write_start_tag(writer, "definedName", attributes, false); write_text_node_conversion(writer, self.get_address()); @@ -217,10 +219,10 @@ impl AdjustmentCoordinateWithSheet for DefinedName { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for address in &mut self.address { address.adjustment_insert_coordinate_with_sheet( @@ -236,10 +238,10 @@ impl AdjustmentCoordinateWithSheet for DefinedName { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.address.retain(|x| { !(x.is_remove_coordinate_with_sheet( @@ -262,13 +264,14 @@ impl AdjustmentCoordinateWithSheet for DefinedName { } #[inline] + #[allow(unused_variables)] fn is_remove_coordinate_with_sheet( &self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { if self.string_value.has_value() { return false; diff --git a/src/structs/double_value.rs b/src/structs/double_value.rs index d1607310..b6aaa177 100644 --- a/src/structs/double_value.rs +++ b/src/structs/double_value.rs @@ -4,11 +4,8 @@ pub struct DoubleValue { } impl DoubleValue { #[inline] - pub(crate) fn get_value(&self) -> &f64 { - match &self.value { - Some(v) => v, - None => &0f64, - } + pub(crate) fn get_value(&self) -> f64 { + self.value.unwrap_or(0f64) } #[inline] diff --git a/src/structs/drawing/bevel_bottom.rs b/src/structs/drawing/bevel_bottom.rs index 248302ba..c2ece966 100644 --- a/src/structs/drawing/bevel_bottom.rs +++ b/src/structs/drawing/bevel_bottom.rs @@ -18,7 +18,7 @@ pub struct BevelBottom { impl BevelBottom { #[inline] - pub fn get_width(&self) -> &i64 { + pub fn get_width(&self) -> i64 { self.width.get_value() } @@ -29,7 +29,7 @@ impl BevelBottom { } #[inline] - pub fn get_height(&self) -> &i64 { + pub fn get_height(&self) -> i64 { self.height.get_value() } diff --git a/src/structs/drawing/bevel_top.rs b/src/structs/drawing/bevel_top.rs index 04a86b6f..1f71ca5a 100644 --- a/src/structs/drawing/bevel_top.rs +++ b/src/structs/drawing/bevel_top.rs @@ -18,7 +18,7 @@ pub struct BevelTop { impl BevelTop { #[inline] - pub fn get_width(&self) -> &i64 { + pub fn get_width(&self) -> i64 { self.width.get_value() } @@ -29,7 +29,7 @@ impl BevelTop { } #[inline] - pub fn get_height(&self) -> &i64 { + pub fn get_height(&self) -> i64 { self.height.get_value() } diff --git a/src/structs/drawing/blip.rs b/src/structs/drawing/blip.rs index f46c117b..061c1d3a 100644 --- a/src/structs/drawing/blip.rs +++ b/src/structs/drawing/blip.rs @@ -59,7 +59,7 @@ impl Blip { self.get_image_mut() .set_image_name(relationship.get_raw_file().get_file_name()); self.get_image_mut() - .set_image_data(relationship.get_raw_file().get_file_data().clone()); + .set_image_data(relationship.get_raw_file().get_file_data()); if empty_flag { return; diff --git a/src/structs/drawing/blip_fill.rs b/src/structs/drawing/blip_fill.rs index f3442e71..a7c3b9a2 100644 --- a/src/structs/drawing/blip_fill.rs +++ b/src/structs/drawing/blip_fill.rs @@ -21,7 +21,7 @@ pub struct BlipFill { impl BlipFill { #[inline] - pub fn get_rotate_with_shape(&self) -> &bool { + pub fn get_rotate_with_shape(&self) -> bool { self.rotate_with_shape.get_value() } diff --git a/src/structs/drawing/body_properties.rs b/src/structs/drawing/body_properties.rs index dfd45b9f..fe696a65 100644 --- a/src/structs/drawing/body_properties.rs +++ b/src/structs/drawing/body_properties.rs @@ -82,7 +82,7 @@ impl BodyProperties { } #[inline] - pub fn get_left_inset(&self) -> &i32 { + pub fn get_left_inset(&self) -> i32 { self.left_inset.get_value() } @@ -92,7 +92,7 @@ impl BodyProperties { } #[inline] - pub fn get_top_inset(&self) -> &i32 { + pub fn get_top_inset(&self) -> i32 { self.top_inset.get_value() } @@ -102,7 +102,7 @@ impl BodyProperties { } #[inline] - pub fn get_right_inset(&self) -> &i32 { + pub fn get_right_inset(&self) -> i32 { self.right_inset.get_value() } @@ -112,7 +112,7 @@ impl BodyProperties { } #[inline] - pub fn get_bottom_inset(&self) -> &i32 { + pub fn get_bottom_inset(&self) -> i32 { self.bottom_inset.get_value() } @@ -138,40 +138,38 @@ impl BodyProperties { e: &BytesStart, empty_flag: bool, ) { - for attr in e.attributes().with_checks(false) { - if let Ok(attr) = attr { - let key = attr.key.into_inner(); - let value = get_attribute_value(&attr).unwrap(); - match key { - b"vertOverflow" => { - self.set_vert_overflow(value); - } - b"horzOverflow" => { - self.set_horz_overflow(value); - } - b"rtlCol" => { - self.set_rtl_col(value); - } - b"anchor" => { - self.set_anchor(value); - } - b"wrap" => { - self.wrap.set_value_string(value); - } - b"lIns" => { - self.left_inset.set_value_string(value); - } - b"tIns" => { - self.top_inset.set_value_string(value); - } - b"rIns" => { - self.right_inset.set_value_string(value); - } - b"bIns" => { - self.bottom_inset.set_value_string(value); - } - _ => {} + for attr in e.attributes().with_checks(false).flatten() { + let key = attr.key.into_inner(); + let value = get_attribute_value(&attr).unwrap(); + match key { + b"vertOverflow" => { + self.set_vert_overflow(value); } + b"horzOverflow" => { + self.set_horz_overflow(value); + } + b"rtlCol" => { + self.set_rtl_col(value); + } + b"anchor" => { + self.set_anchor(value); + } + b"wrap" => { + self.wrap.set_value_string(value); + } + b"lIns" => { + self.left_inset.set_value_string(value); + } + b"tIns" => { + self.top_inset.set_value_string(value); + } + b"rIns" => { + self.right_inset.set_value_string(value); + } + b"bIns" => { + self.bottom_inset.set_value_string(value); + } + _ => {} } } diff --git a/src/structs/drawing/charts/auto_labeled.rs b/src/structs/drawing/charts/auto_labeled.rs index b146f0a3..e05bb02d 100644 --- a/src/structs/drawing/charts/auto_labeled.rs +++ b/src/structs/drawing/charts/auto_labeled.rs @@ -12,7 +12,7 @@ pub struct AutoLabeled { val: BooleanValue, } impl AutoLabeled { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/auto_title_deleted.rs b/src/structs/drawing/charts/auto_title_deleted.rs index 680205e4..16345cbf 100644 --- a/src/structs/drawing/charts/auto_title_deleted.rs +++ b/src/structs/drawing/charts/auto_title_deleted.rs @@ -12,7 +12,7 @@ pub struct AutoTitleDeleted { val: BooleanValue, } impl AutoTitleDeleted { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/axis_id.rs b/src/structs/drawing/charts/axis_id.rs index 6c730a07..159b7e83 100644 --- a/src/structs/drawing/charts/axis_id.rs +++ b/src/structs/drawing/charts/axis_id.rs @@ -12,7 +12,7 @@ pub struct AxisId { val: UInt32Value, } impl AxisId { - pub fn get_val(&self) -> &u32 { + pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/bubble_3d.rs b/src/structs/drawing/charts/bubble_3d.rs index e0fb9a31..417ee1ad 100644 --- a/src/structs/drawing/charts/bubble_3d.rs +++ b/src/structs/drawing/charts/bubble_3d.rs @@ -12,7 +12,7 @@ pub struct Bubble3D { val: BooleanValue, } impl Bubble3D { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/bubble_scale.rs b/src/structs/drawing/charts/bubble_scale.rs index e3068a69..39107b3b 100644 --- a/src/structs/drawing/charts/bubble_scale.rs +++ b/src/structs/drawing/charts/bubble_scale.rs @@ -12,7 +12,7 @@ pub struct BubbleScale { val: UInt32Value, } impl BubbleScale { - pub fn get_val(&self) -> &u32 { + pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/chart.rs b/src/structs/drawing/charts/chart.rs index 53c42c94..39288e06 100644 --- a/src/structs/drawing/charts/chart.rs +++ b/src/structs/drawing/charts/chart.rs @@ -307,10 +307,10 @@ impl AdjustmentCoordinateWithSheet for Chart { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.plot_area.adjustment_insert_coordinate_with_sheet( sheet_name, @@ -324,10 +324,10 @@ impl AdjustmentCoordinateWithSheet for Chart { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.plot_area.adjustment_remove_coordinate_with_sheet( sheet_name, diff --git a/src/structs/drawing/charts/chart_space.rs b/src/structs/drawing/charts/chart_space.rs index d7185373..b229aa47 100644 --- a/src/structs/drawing/charts/chart_space.rs +++ b/src/structs/drawing/charts/chart_space.rs @@ -214,10 +214,10 @@ impl AdjustmentCoordinateWithSheet for ChartSpace { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.chart.adjustment_insert_coordinate_with_sheet( sheet_name, @@ -231,10 +231,10 @@ impl AdjustmentCoordinateWithSheet for ChartSpace { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.chart.adjustment_remove_coordinate_with_sheet( sheet_name, diff --git a/src/structs/drawing/charts/crossing_axis.rs b/src/structs/drawing/charts/crossing_axis.rs index d921a55d..fb576309 100644 --- a/src/structs/drawing/charts/crossing_axis.rs +++ b/src/structs/drawing/charts/crossing_axis.rs @@ -12,7 +12,7 @@ pub struct CrossingAxis { val: UInt32Value, } impl CrossingAxis { - pub fn get_val(&self) -> &u32 { + pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/date1904.rs b/src/structs/drawing/charts/date1904.rs index 07a5af05..fabc9b09 100644 --- a/src/structs/drawing/charts/date1904.rs +++ b/src/structs/drawing/charts/date1904.rs @@ -12,7 +12,7 @@ pub struct Date1904 { val: BooleanValue, } impl Date1904 { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/delete.rs b/src/structs/drawing/charts/delete.rs index 86932db2..54d12f55 100644 --- a/src/structs/drawing/charts/delete.rs +++ b/src/structs/drawing/charts/delete.rs @@ -12,7 +12,7 @@ pub struct Delete { val: BooleanValue, } impl Delete { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/explosion.rs b/src/structs/drawing/charts/explosion.rs index 3f2ee653..4c95d3c7 100644 --- a/src/structs/drawing/charts/explosion.rs +++ b/src/structs/drawing/charts/explosion.rs @@ -12,7 +12,7 @@ pub struct Explosion { val: UInt32Value, } impl Explosion { - pub fn get_val(&self) -> &u32 { + pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/first_slice_angle.rs b/src/structs/drawing/charts/first_slice_angle.rs index 10de1c76..71721f7a 100644 --- a/src/structs/drawing/charts/first_slice_angle.rs +++ b/src/structs/drawing/charts/first_slice_angle.rs @@ -12,7 +12,7 @@ pub struct FirstSliceAngle { val: UInt16Value, } impl FirstSliceAngle { - pub fn get_val(&self) -> &u16 { + pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/formula.rs b/src/structs/drawing/charts/formula.rs index 090c221b..568fa1af 100644 --- a/src/structs/drawing/charts/formula.rs +++ b/src/structs/drawing/charts/formula.rs @@ -85,10 +85,10 @@ impl AdjustmentCoordinateWithSheet for Formula { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.address.adjustment_insert_coordinate_with_sheet( sheet_name, @@ -102,10 +102,10 @@ impl AdjustmentCoordinateWithSheet for Formula { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.address.adjustment_remove_coordinate_with_sheet( sheet_name, diff --git a/src/structs/drawing/charts/gap_width.rs b/src/structs/drawing/charts/gap_width.rs index e55f3fa2..77c784a3 100644 --- a/src/structs/drawing/charts/gap_width.rs +++ b/src/structs/drawing/charts/gap_width.rs @@ -12,7 +12,7 @@ pub struct GapWidth { val: UInt16Value, } impl GapWidth { - pub fn get_val(&self) -> &u16 { + pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/height.rs b/src/structs/drawing/charts/height.rs index 1d97469c..675d1a4a 100644 --- a/src/structs/drawing/charts/height.rs +++ b/src/structs/drawing/charts/height.rs @@ -12,7 +12,7 @@ pub struct Height { val: DoubleValue, } impl Height { - pub fn get_val(&self) -> &f64 { + pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/hole_size.rs b/src/structs/drawing/charts/hole_size.rs index 9222239b..e791dfe8 100644 --- a/src/structs/drawing/charts/hole_size.rs +++ b/src/structs/drawing/charts/hole_size.rs @@ -12,7 +12,7 @@ pub struct HoleSize { val: ByteValue, } impl HoleSize { - pub fn get_val(&self) -> &u8 { + pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/index.rs b/src/structs/drawing/charts/index.rs index c1f258af..cbd4cd0d 100644 --- a/src/structs/drawing/charts/index.rs +++ b/src/structs/drawing/charts/index.rs @@ -12,7 +12,7 @@ pub struct Index { val: UInt32Value, } impl Index { - pub fn get_val(&self) -> &u32 { + pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/invert_if_negative.rs b/src/structs/drawing/charts/invert_if_negative.rs index 20d72afb..03f3644a 100644 --- a/src/structs/drawing/charts/invert_if_negative.rs +++ b/src/structs/drawing/charts/invert_if_negative.rs @@ -12,7 +12,7 @@ pub struct InvertIfNegative { val: DoubleValue, } impl InvertIfNegative { - pub fn get_val(&self) -> &f64 { + pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/label_offset.rs b/src/structs/drawing/charts/label_offset.rs index 19a87578..259831ad 100644 --- a/src/structs/drawing/charts/label_offset.rs +++ b/src/structs/drawing/charts/label_offset.rs @@ -12,7 +12,7 @@ pub struct LabelOffset { val: UInt16Value, } impl LabelOffset { - pub fn get_val(&self) -> &u16 { + pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/left.rs b/src/structs/drawing/charts/left.rs index 0755bcd6..bd34445f 100644 --- a/src/structs/drawing/charts/left.rs +++ b/src/structs/drawing/charts/left.rs @@ -12,7 +12,7 @@ pub struct Left { val: DoubleValue, } impl Left { - pub fn get_val(&self) -> &f64 { + pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/no_multi_level_labels.rs b/src/structs/drawing/charts/no_multi_level_labels.rs index 5058e807..71294dd9 100644 --- a/src/structs/drawing/charts/no_multi_level_labels.rs +++ b/src/structs/drawing/charts/no_multi_level_labels.rs @@ -12,7 +12,7 @@ pub struct NoMultiLevelLabels { val: BooleanValue, } impl NoMultiLevelLabels { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/numbering_format.rs b/src/structs/drawing/charts/numbering_format.rs index 83833218..2416654c 100644 --- a/src/structs/drawing/charts/numbering_format.rs +++ b/src/structs/drawing/charts/numbering_format.rs @@ -23,7 +23,7 @@ impl NumberingFormat { self } - pub fn get_source_linked(&self) -> &bool { + pub fn get_source_linked(&self) -> bool { self.source_linked.get_value() } diff --git a/src/structs/drawing/charts/order.rs b/src/structs/drawing/charts/order.rs index b0957cc2..64064aa9 100644 --- a/src/structs/drawing/charts/order.rs +++ b/src/structs/drawing/charts/order.rs @@ -12,7 +12,7 @@ pub struct Order { val: UInt32Value, } impl Order { - pub fn get_val(&self) -> &u32 { + pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/overlap.rs b/src/structs/drawing/charts/overlap.rs index 44b9eb88..c48edb57 100644 --- a/src/structs/drawing/charts/overlap.rs +++ b/src/structs/drawing/charts/overlap.rs @@ -12,7 +12,7 @@ pub struct Overlap { val: SByteValue, } impl Overlap { - pub fn get_val(&self) -> &i8 { + pub fn get_val(&self) -> i8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/overlay.rs b/src/structs/drawing/charts/overlay.rs index 44a7db33..81a30815 100644 --- a/src/structs/drawing/charts/overlay.rs +++ b/src/structs/drawing/charts/overlay.rs @@ -12,7 +12,7 @@ pub struct Overlay { val: BooleanValue, } impl Overlay { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/page_margins.rs b/src/structs/drawing/charts/page_margins.rs index 3cd941a3..918ad2ec 100644 --- a/src/structs/drawing/charts/page_margins.rs +++ b/src/structs/drawing/charts/page_margins.rs @@ -17,7 +17,7 @@ pub struct PageMargins { footer: DoubleValue, } impl PageMargins { - pub fn get_bottom(&self) -> &f64 { + pub fn get_bottom(&self) -> f64 { self.bottom.get_value() } @@ -26,7 +26,7 @@ impl PageMargins { self } - pub fn get_left(&self) -> &f64 { + pub fn get_left(&self) -> f64 { self.left.get_value() } @@ -35,7 +35,7 @@ impl PageMargins { self } - pub fn get_right(&self) -> &f64 { + pub fn get_right(&self) -> f64 { self.right.get_value() } @@ -44,7 +44,7 @@ impl PageMargins { self } - pub fn get_top(&self) -> &f64 { + pub fn get_top(&self) -> f64 { self.top.get_value() } @@ -53,7 +53,7 @@ impl PageMargins { self } - pub fn get_header(&self) -> &f64 { + pub fn get_header(&self) -> f64 { self.header.get_value() } @@ -62,7 +62,7 @@ impl PageMargins { self } - pub fn get_footer(&self) -> &f64 { + pub fn get_footer(&self) -> f64 { self.footer.get_value() } diff --git a/src/structs/drawing/charts/perspective.rs b/src/structs/drawing/charts/perspective.rs index 7c4c7fe8..688456d3 100644 --- a/src/structs/drawing/charts/perspective.rs +++ b/src/structs/drawing/charts/perspective.rs @@ -12,7 +12,7 @@ pub struct Perspective { val: ByteValue, } impl Perspective { - pub fn get_val(&self) -> &u8 { + pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/plot_area.rs b/src/structs/drawing/charts/plot_area.rs index cde527f5..cd75887a 100644 --- a/src/structs/drawing/charts/plot_area.rs +++ b/src/structs/drawing/charts/plot_area.rs @@ -730,10 +730,10 @@ impl AdjustmentCoordinateWithSheet for PlotArea { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for formula in self.get_formula_mut() { formula.adjustment_insert_coordinate_with_sheet( @@ -749,10 +749,10 @@ impl AdjustmentCoordinateWithSheet for PlotArea { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for formula in self.get_formula_mut() { formula.adjustment_remove_coordinate_with_sheet( diff --git a/src/structs/drawing/charts/plot_visible_only.rs b/src/structs/drawing/charts/plot_visible_only.rs index 867079ac..d0000904 100644 --- a/src/structs/drawing/charts/plot_visible_only.rs +++ b/src/structs/drawing/charts/plot_visible_only.rs @@ -12,7 +12,7 @@ pub struct PlotVisibleOnly { val: BooleanValue, } impl PlotVisibleOnly { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/right_angle_axes.rs b/src/structs/drawing/charts/right_angle_axes.rs index 4de10dfc..ca627150 100644 --- a/src/structs/drawing/charts/right_angle_axes.rs +++ b/src/structs/drawing/charts/right_angle_axes.rs @@ -12,7 +12,7 @@ pub struct RightAngleAxes { val: BooleanValue, } impl RightAngleAxes { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/rotate_x.rs b/src/structs/drawing/charts/rotate_x.rs index d54325ee..8f8cd58d 100644 --- a/src/structs/drawing/charts/rotate_x.rs +++ b/src/structs/drawing/charts/rotate_x.rs @@ -12,7 +12,7 @@ pub struct RotateX { val: SByteValue, } impl RotateX { - pub fn get_val(&self) -> &i8 { + pub fn get_val(&self) -> i8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/rotate_y.rs b/src/structs/drawing/charts/rotate_y.rs index 065d1980..76071e7f 100644 --- a/src/structs/drawing/charts/rotate_y.rs +++ b/src/structs/drawing/charts/rotate_y.rs @@ -12,7 +12,7 @@ pub struct RotateY { val: UInt16Value, } impl RotateY { - pub fn get_val(&self) -> &u16 { + pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/rounded_corners.rs b/src/structs/drawing/charts/rounded_corners.rs index a0daf8f3..f0551ee7 100644 --- a/src/structs/drawing/charts/rounded_corners.rs +++ b/src/structs/drawing/charts/rounded_corners.rs @@ -12,7 +12,7 @@ pub struct RoundedCorners { val: BooleanValue, } impl RoundedCorners { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/second_pie_size.rs b/src/structs/drawing/charts/second_pie_size.rs index 3cf4b8ac..dbedca60 100644 --- a/src/structs/drawing/charts/second_pie_size.rs +++ b/src/structs/drawing/charts/second_pie_size.rs @@ -12,7 +12,7 @@ pub struct SecondPieSize { val: UInt16Value, } impl SecondPieSize { - pub fn get_val(&self) -> &u16 { + pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_bubble_size.rs b/src/structs/drawing/charts/show_bubble_size.rs index e4d287c1..5cf0dbe5 100644 --- a/src/structs/drawing/charts/show_bubble_size.rs +++ b/src/structs/drawing/charts/show_bubble_size.rs @@ -12,7 +12,7 @@ pub struct ShowBubbleSize { val: BooleanValue, } impl ShowBubbleSize { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_category_name.rs b/src/structs/drawing/charts/show_category_name.rs index f6b272b4..2d7d4705 100644 --- a/src/structs/drawing/charts/show_category_name.rs +++ b/src/structs/drawing/charts/show_category_name.rs @@ -12,7 +12,7 @@ pub struct ShowCategoryName { val: BooleanValue, } impl ShowCategoryName { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_data_labels_over_maximum.rs b/src/structs/drawing/charts/show_data_labels_over_maximum.rs index 076e41ee..9fc2b5b6 100644 --- a/src/structs/drawing/charts/show_data_labels_over_maximum.rs +++ b/src/structs/drawing/charts/show_data_labels_over_maximum.rs @@ -12,7 +12,7 @@ pub struct ShowDataLabelsOverMaximum { val: BooleanValue, } impl ShowDataLabelsOverMaximum { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_leader_lines.rs b/src/structs/drawing/charts/show_leader_lines.rs index 67c9f517..b15be991 100644 --- a/src/structs/drawing/charts/show_leader_lines.rs +++ b/src/structs/drawing/charts/show_leader_lines.rs @@ -12,7 +12,7 @@ pub struct ShowLeaderLines { val: BooleanValue, } impl ShowLeaderLines { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_legend_key.rs b/src/structs/drawing/charts/show_legend_key.rs index f8c07a5d..b4a28eb2 100644 --- a/src/structs/drawing/charts/show_legend_key.rs +++ b/src/structs/drawing/charts/show_legend_key.rs @@ -12,7 +12,7 @@ pub struct ShowLegendKey { val: BooleanValue, } impl ShowLegendKey { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_marker.rs b/src/structs/drawing/charts/show_marker.rs index 7d5385f4..901ad61f 100644 --- a/src/structs/drawing/charts/show_marker.rs +++ b/src/structs/drawing/charts/show_marker.rs @@ -12,7 +12,7 @@ pub struct ShowMarker { val: BooleanValue, } impl ShowMarker { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_negative_bubbles.rs b/src/structs/drawing/charts/show_negative_bubbles.rs index 7226d219..8ed58dfc 100644 --- a/src/structs/drawing/charts/show_negative_bubbles.rs +++ b/src/structs/drawing/charts/show_negative_bubbles.rs @@ -12,7 +12,7 @@ pub struct ShowNegativeBubbles { val: BooleanValue, } impl ShowNegativeBubbles { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_percent.rs b/src/structs/drawing/charts/show_percent.rs index af061071..94654381 100644 --- a/src/structs/drawing/charts/show_percent.rs +++ b/src/structs/drawing/charts/show_percent.rs @@ -12,7 +12,7 @@ pub struct ShowPercent { val: BooleanValue, } impl ShowPercent { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_series_name.rs b/src/structs/drawing/charts/show_series_name.rs index 58fc5e01..e33ab0ab 100644 --- a/src/structs/drawing/charts/show_series_name.rs +++ b/src/structs/drawing/charts/show_series_name.rs @@ -12,7 +12,7 @@ pub struct ShowSeriesName { val: BooleanValue, } impl ShowSeriesName { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_value.rs b/src/structs/drawing/charts/show_value.rs index 949765fe..b7cb86a6 100644 --- a/src/structs/drawing/charts/show_value.rs +++ b/src/structs/drawing/charts/show_value.rs @@ -12,7 +12,7 @@ pub struct ShowValue { val: BooleanValue, } impl ShowValue { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/smooth.rs b/src/structs/drawing/charts/smooth.rs index 2216865e..b6875119 100644 --- a/src/structs/drawing/charts/smooth.rs +++ b/src/structs/drawing/charts/smooth.rs @@ -12,7 +12,7 @@ pub struct Smooth { val: BooleanValue, } impl Smooth { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/string_literal.rs b/src/structs/drawing/charts/string_literal.rs index 64462650..906930b2 100644 --- a/src/structs/drawing/charts/string_literal.rs +++ b/src/structs/drawing/charts/string_literal.rs @@ -60,7 +60,7 @@ impl StringLiteral { // c:pt for (index, obj) in self.string_point_list.iter().enumerate() { - obj.write_to(writer, &(index as u32)); + obj.write_to(writer, index as u32); } write_end_tag(writer, "c:strLit"); diff --git a/src/structs/drawing/charts/string_point.rs b/src/structs/drawing/charts/string_point.rs index 14e8b1f9..c5654f80 100644 --- a/src/structs/drawing/charts/string_point.rs +++ b/src/structs/drawing/charts/string_point.rs @@ -48,7 +48,7 @@ impl StringPoint { ); } - pub(crate) fn write_to(&self, writer: &mut Writer>>, index: &u32) { + pub(crate) fn write_to(&self, writer: &mut Writer>>, index: u32) { // c:pt let index_str = index.to_string(); write_start_tag(writer, "c:pt", vec![("idx", index_str.as_str())], false); diff --git a/src/structs/drawing/charts/style.rs b/src/structs/drawing/charts/style.rs index 9e53400f..a612d2a3 100644 --- a/src/structs/drawing/charts/style.rs +++ b/src/structs/drawing/charts/style.rs @@ -13,7 +13,7 @@ pub struct Style { } impl Style { - pub fn get_val(&self) -> &u8 { + pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/thickness.rs b/src/structs/drawing/charts/thickness.rs index d9408a0d..828e19ac 100644 --- a/src/structs/drawing/charts/thickness.rs +++ b/src/structs/drawing/charts/thickness.rs @@ -12,7 +12,7 @@ pub struct Thickness { val: ByteValue, } impl Thickness { - pub fn get_val(&self) -> &u8 { + pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/top.rs b/src/structs/drawing/charts/top.rs index 6e1ffde1..1d699953 100644 --- a/src/structs/drawing/charts/top.rs +++ b/src/structs/drawing/charts/top.rs @@ -12,7 +12,7 @@ pub struct Top { val: DoubleValue, } impl Top { - pub fn get_val(&self) -> &f64 { + pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/vary_colors.rs b/src/structs/drawing/charts/vary_colors.rs index 58134170..90eeab14 100644 --- a/src/structs/drawing/charts/vary_colors.rs +++ b/src/structs/drawing/charts/vary_colors.rs @@ -12,7 +12,7 @@ pub struct VaryColors { val: BooleanValue, } impl VaryColors { - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/width.rs b/src/structs/drawing/charts/width.rs index fe8180ae..a7d71fe6 100644 --- a/src/structs/drawing/charts/width.rs +++ b/src/structs/drawing/charts/width.rs @@ -12,7 +12,7 @@ pub struct Width { val: DoubleValue, } impl Width { - pub fn get_val(&self) -> &f64 { + pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/end_connection.rs b/src/structs/drawing/end_connection.rs index 128d3f88..4a84b1f5 100644 --- a/src/structs/drawing/end_connection.rs +++ b/src/structs/drawing/end_connection.rs @@ -14,7 +14,7 @@ pub struct EndConnection { } impl EndConnection { #[inline] - pub fn get_id(&self) -> &u32 { + pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -24,7 +24,7 @@ impl EndConnection { } #[inline] - pub fn get_index(&self) -> &u32 { + pub fn get_index(&self) -> u32 { self.index.get_value() } diff --git a/src/structs/drawing/extension_list.rs b/src/structs/drawing/extension_list.rs index a297f3ba..0e8760b4 100644 --- a/src/structs/drawing/extension_list.rs +++ b/src/structs/drawing/extension_list.rs @@ -1,6 +1,5 @@ // a:extLst use crate::reader::driver::*; -use crate::writer::driver::*; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -27,6 +26,7 @@ impl ExtensionList { ); } + #[allow(dead_code)] #[inline] - pub(crate) fn write_to(&self, writer: &mut Writer>>) {} + pub(crate) fn write_to(&self, _writer: &mut Writer>>) {} } diff --git a/src/structs/drawing/extents.rs b/src/structs/drawing/extents.rs index 4bbbe7a2..181f9ee8 100644 --- a/src/structs/drawing/extents.rs +++ b/src/structs/drawing/extents.rs @@ -14,7 +14,7 @@ pub struct Extents { } impl Extents { #[inline] - pub fn get_cx(&self) -> &i64 { + pub fn get_cx(&self) -> i64 { self.cx.get_value() } @@ -25,7 +25,7 @@ impl Extents { } #[inline] - pub fn get_cy(&self) -> &i64 { + pub fn get_cy(&self) -> i64 { self.cy.get_value() } diff --git a/src/structs/drawing/fill_rectangle.rs b/src/structs/drawing/fill_rectangle.rs index 7e94b023..e18c4041 100644 --- a/src/structs/drawing/fill_rectangle.rs +++ b/src/structs/drawing/fill_rectangle.rs @@ -14,8 +14,8 @@ pub struct FillRectangle { } impl FillRectangle { #[inline] - pub fn get_bottom(&self) -> &usize { - &self.bottom + pub fn get_bottom(&self) -> usize { + self.bottom } #[inline] @@ -24,8 +24,8 @@ impl FillRectangle { } #[inline] - pub fn get_left(&self) -> &usize { - &self.left + pub fn get_left(&self) -> usize { + self.left } #[inline] @@ -34,8 +34,8 @@ impl FillRectangle { } #[inline] - pub fn get_right(&self) -> &usize { - &self.right + pub fn get_right(&self) -> usize { + self.right } #[inline] @@ -44,8 +44,8 @@ impl FillRectangle { } #[inline] - pub fn get_top(&self) -> &usize { - &self.top + pub fn get_top(&self) -> usize { + self.top } #[inline] diff --git a/src/structs/drawing/glow.rs b/src/structs/drawing/glow.rs index 973b56c4..fe6a0e2c 100644 --- a/src/structs/drawing/glow.rs +++ b/src/structs/drawing/glow.rs @@ -16,7 +16,7 @@ pub struct Glow { impl Glow { #[inline] - pub fn get_radius(&self) -> &i64 { + pub fn get_radius(&self) -> i64 { self.radius.get_value() } diff --git a/src/structs/drawing/gradient_fill.rs b/src/structs/drawing/gradient_fill.rs index af022390..80754d84 100644 --- a/src/structs/drawing/gradient_fill.rs +++ b/src/structs/drawing/gradient_fill.rs @@ -34,7 +34,7 @@ impl GradientFill { } #[inline] - pub fn get_rotate_with_shape(&self) -> &bool { + pub fn get_rotate_with_shape(&self) -> bool { self.rotate_with_shape.get_value() } diff --git a/src/structs/drawing/gradient_stop.rs b/src/structs/drawing/gradient_stop.rs index a4acad6d..53d0911b 100644 --- a/src/structs/drawing/gradient_stop.rs +++ b/src/structs/drawing/gradient_stop.rs @@ -17,8 +17,8 @@ pub struct GradientStop { impl GradientStop { #[inline] - pub fn get_position(&self) -> &i32 { - &self.position + pub fn get_position(&self) -> i32 { + self.position } #[inline] @@ -119,12 +119,12 @@ impl GradientStop { ); // a:schemeClr - for v in &self.scheme_color { + if let Some(v) = &self.scheme_color { v.write_to(writer); } // a:srgbClr - for v in &self.rgb_color_model_hex { + if let Some(v) = &self.rgb_color_model_hex { v.write_to(writer); } diff --git a/src/structs/drawing/graphic.rs b/src/structs/drawing/graphic.rs index 5bd44251..3b368a9e 100644 --- a/src/structs/drawing/graphic.rs +++ b/src/structs/drawing/graphic.rs @@ -73,10 +73,10 @@ impl AdjustmentCoordinateWithSheet for Graphic { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.graphic_data.adjustment_insert_coordinate_with_sheet( sheet_name, @@ -91,10 +91,10 @@ impl AdjustmentCoordinateWithSheet for Graphic { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.graphic_data.adjustment_remove_coordinate_with_sheet( sheet_name, diff --git a/src/structs/drawing/graphic_data.rs b/src/structs/drawing/graphic_data.rs index 8f841baa..abe36cb9 100644 --- a/src/structs/drawing/graphic_data.rs +++ b/src/structs/drawing/graphic_data.rs @@ -47,7 +47,7 @@ impl GraphicData { let relationship = drawing_relationships .unwrap() .get_relationship_by_rid(&chart_id); - chart::read(relationship.get_raw_file(), &mut self.chart_space); + chart::read(relationship.get_raw_file(), &mut self.chart_space).unwrap(); } }, Event::End(ref e) => { @@ -93,10 +93,10 @@ impl AdjustmentCoordinateWithSheet for GraphicData { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.chart_space.adjustment_insert_coordinate_with_sheet( sheet_name, @@ -111,10 +111,10 @@ impl AdjustmentCoordinateWithSheet for GraphicData { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.chart_space.adjustment_remove_coordinate_with_sheet( sheet_name, diff --git a/src/structs/drawing/group_shape_locks.rs b/src/structs/drawing/group_shape_locks.rs index 32d54801..3528b50e 100644 --- a/src/structs/drawing/group_shape_locks.rs +++ b/src/structs/drawing/group_shape_locks.rs @@ -20,7 +20,7 @@ pub struct GroupShapeLocks { impl GroupShapeLocks { #[inline] - pub fn get_no_change_aspect(&self) -> &bool { + pub fn get_no_change_aspect(&self) -> bool { self.no_change_aspect.get_value() } @@ -49,37 +49,37 @@ impl GroupShapeLocks { let no_change_aspect_str = self.no_change_aspect.get_value_string(); if self.no_change_aspect.has_value() { - attributes.push(("noChangeAspect", &no_change_aspect_str)); + attributes.push(("noChangeAspect", no_change_aspect_str)); } let no_grouping_str = self.no_grouping.get_value_string(); if self.no_grouping.has_value() { - attributes.push(("noGrp", &no_grouping_str)); + attributes.push(("noGrp", no_grouping_str)); } let no_move_str = self.no_move.get_value_string(); if self.no_move.has_value() { - attributes.push(("noMove", &no_move_str)); + attributes.push(("noMove", no_move_str)); } let no_resize_str = self.no_resize.get_value_string(); if self.no_resize.has_value() { - attributes.push(("noResize", &no_resize_str)); + attributes.push(("noResize", no_resize_str)); } let no_rotation_str = self.no_rotation.get_value_string(); if self.no_rotation.has_value() { - attributes.push(("noRot", &no_rotation_str)); + attributes.push(("noRot", no_rotation_str)); } let no_selection_str = self.no_selection.get_value_string(); if self.no_selection.has_value() { - attributes.push(("noSelect", &no_selection_str)); + attributes.push(("noSelect", no_selection_str)); } let no_ungrouping_str = self.no_ungrouping.get_value_string(); if self.no_ungrouping.has_value() { - attributes.push(("noUngrp", &no_ungrouping_str)); + attributes.push(("noUngrp", no_ungrouping_str)); } write_start_tag(writer, "a:grpSpLocks", attributes, true); diff --git a/src/structs/drawing/linear_gradient_fill.rs b/src/structs/drawing/linear_gradient_fill.rs index 88342b1a..3e23c569 100644 --- a/src/structs/drawing/linear_gradient_fill.rs +++ b/src/structs/drawing/linear_gradient_fill.rs @@ -16,7 +16,7 @@ pub struct LinearGradientFill { impl LinearGradientFill { #[inline] - pub fn get_angle(&self) -> &i32 { + pub fn get_angle(&self) -> i32 { self.angle.get_value() } @@ -27,7 +27,7 @@ impl LinearGradientFill { } #[inline] - pub fn get_scaled(&self) -> &bool { + pub fn get_scaled(&self) -> bool { self.scaled.get_value() } diff --git a/src/structs/drawing/list_style.rs b/src/structs/drawing/list_style.rs index 803a3ebc..fe7d35bb 100644 --- a/src/structs/drawing/list_style.rs +++ b/src/structs/drawing/list_style.rs @@ -378,83 +378,53 @@ impl ListStyle { write_start_tag(writer, "a:lstStyle", vec![], is_empty); // a:defPPr - match &self.text_paragraph_properties_type.get("def") { - Some(v) => { - v.write_to_default(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("def") { + v.write_to_default(writer); } // a:lvl1pPr - match &self.text_paragraph_properties_type.get("lv1") { - Some(v) => { - v.write_to_lvl1(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv1") { + v.write_to_lvl1(writer); } // a:lvl2pPr - match &self.text_paragraph_properties_type.get("lv2") { - Some(v) => { - v.write_to_lvl2(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv2") { + v.write_to_lvl2(writer); } // a:lvl3pPr - match &self.text_paragraph_properties_type.get("lv3") { - Some(v) => { - v.write_to_lvl3(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv3") { + v.write_to_lvl3(writer); } // a:lvl4pPr - match &self.text_paragraph_properties_type.get("lv4") { - Some(v) => { - v.write_to_lvl4(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv4") { + v.write_to_lvl4(writer); } // a:lvl5pPr - match &self.text_paragraph_properties_type.get("lv5") { - Some(v) => { - v.write_to_lvl5(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv5") { + v.write_to_lvl5(writer); } // a:lvl6pPr - match &self.text_paragraph_properties_type.get("lv6") { - Some(v) => { - v.write_to_lvl6(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv6") { + v.write_to_lvl6(writer); } // a:lvl7pPr - match &self.text_paragraph_properties_type.get("lv7") { - Some(v) => { - v.write_to_lvl7(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv7") { + v.write_to_lvl7(writer); } // a:lvl8pPr - match &self.text_paragraph_properties_type.get("lv8") { - Some(v) => { - v.write_to_lvl8(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv8") { + v.write_to_lvl8(writer); } // a:lvl9pPr - match &self.text_paragraph_properties_type.get("lv9") { - Some(v) => { - v.write_to_lvl9(writer); - } - None => {} + if let Some(v) = &self.text_paragraph_properties_type.get("lv9") { + v.write_to_lvl9(writer); } if !is_empty { diff --git a/src/structs/drawing/miter.rs b/src/structs/drawing/miter.rs index 2685eba9..d367580d 100644 --- a/src/structs/drawing/miter.rs +++ b/src/structs/drawing/miter.rs @@ -14,7 +14,7 @@ pub struct Miter { impl Miter { #[inline] - pub fn get_limit(&self) -> &i32 { + pub fn get_limit(&self) -> i32 { self.limit.get_value() } diff --git a/src/structs/drawing/offset.rs b/src/structs/drawing/offset.rs index 6bf1855e..636bf1f3 100644 --- a/src/structs/drawing/offset.rs +++ b/src/structs/drawing/offset.rs @@ -14,7 +14,7 @@ pub struct Offset { } impl Offset { #[inline] - pub fn get_x(&self) -> &i64 { + pub fn get_x(&self) -> i64 { self.x.get_value() } @@ -24,7 +24,7 @@ impl Offset { } #[inline] - pub fn get_y(&self) -> &i64 { + pub fn get_y(&self) -> i64 { self.y.get_value() } diff --git a/src/structs/drawing/outline.rs b/src/structs/drawing/outline.rs index 5f77f0ed..820edde2 100644 --- a/src/structs/drawing/outline.rs +++ b/src/structs/drawing/outline.rs @@ -36,7 +36,7 @@ pub struct Outline { impl Outline { #[inline] - pub fn get_width(&self) -> &u32 { + pub fn get_width(&self) -> u32 { self.width.get_value() } diff --git a/src/structs/drawing/percentage_type.rs b/src/structs/drawing/percentage_type.rs index cabaacdc..d36038a9 100644 --- a/src/structs/drawing/percentage_type.rs +++ b/src/structs/drawing/percentage_type.rs @@ -13,7 +13,7 @@ pub struct PercentageType { impl PercentageType { #[inline] - pub fn get_val(&self) -> &i32 { + pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/drawing/picture_locks.rs b/src/structs/drawing/picture_locks.rs index a67d0c1b..170ddbc1 100644 --- a/src/structs/drawing/picture_locks.rs +++ b/src/structs/drawing/picture_locks.rs @@ -13,8 +13,8 @@ pub struct PictureLocks { impl PictureLocks { #[inline] - pub fn get_no_change_aspect(&self) -> &bool { - &self.no_change_aspect + pub fn get_no_change_aspect(&self) -> bool { + self.no_change_aspect } #[inline] diff --git a/src/structs/drawing/point_2d_type.rs b/src/structs/drawing/point_2d_type.rs index 00135b21..f1eba176 100644 --- a/src/structs/drawing/point_2d_type.rs +++ b/src/structs/drawing/point_2d_type.rs @@ -3,7 +3,7 @@ use crate::reader::driver::*; use crate::structs::Int64Value; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -16,8 +16,8 @@ pub struct Point2DType { impl Point2DType { #[inline] - pub fn get_x(&self) -> &i64 { - &self.x.get_value() + pub fn get_x(&self) -> i64 { + self.x.get_value() } #[inline] @@ -26,8 +26,8 @@ impl Point2DType { } #[inline] - pub fn get_y(&self) -> &i64 { - &self.y.get_value() + pub fn get_y(&self) -> i64 { + self.y.get_value() } #[inline] diff --git a/src/structs/drawing/positive_fixed_percentage_type.rs b/src/structs/drawing/positive_fixed_percentage_type.rs index 1b33ae42..8d40fcd5 100644 --- a/src/structs/drawing/positive_fixed_percentage_type.rs +++ b/src/structs/drawing/positive_fixed_percentage_type.rs @@ -13,7 +13,7 @@ pub struct PositiveFixedPercentageType { impl PositiveFixedPercentageType { #[inline] - pub fn get_val(&self) -> &i32 { + pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/drawing/positive_size_2d_type.rs b/src/structs/drawing/positive_size_2d_type.rs index e076e141..a5b8824a 100644 --- a/src/structs/drawing/positive_size_2d_type.rs +++ b/src/structs/drawing/positive_size_2d_type.rs @@ -3,7 +3,7 @@ use crate::reader::driver::*; use crate::structs::Int64Value; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -16,8 +16,8 @@ pub struct PositiveSize2DType { impl PositiveSize2DType { #[inline] - pub fn get_cx(&self) -> &i64 { - &self.cx.get_value() + pub fn get_cx(&self) -> i64 { + self.cx.get_value() } #[inline] @@ -26,8 +26,8 @@ impl PositiveSize2DType { } #[inline] - pub fn get_cy(&self) -> &i64 { - &self.cy.get_value() + pub fn get_cy(&self) -> i64 { + self.cy.get_value() } #[inline] diff --git a/src/structs/drawing/rotation.rs b/src/structs/drawing/rotation.rs index 6651c3ad..5fd87c9b 100644 --- a/src/structs/drawing/rotation.rs +++ b/src/structs/drawing/rotation.rs @@ -16,7 +16,7 @@ pub struct Rotation { impl Rotation { #[inline] - pub fn get_latitude(&self) -> &i32 { + pub fn get_latitude(&self) -> i32 { self.latitude.get_value() } @@ -27,7 +27,7 @@ impl Rotation { } #[inline] - pub fn get_longitude(&self) -> &i32 { + pub fn get_longitude(&self) -> i32 { self.longitude.get_value() } @@ -38,7 +38,7 @@ impl Rotation { } #[inline] - pub fn get_revolution(&self) -> &i32 { + pub fn get_revolution(&self) -> i32 { self.revolution.get_value() } diff --git a/src/structs/drawing/run_properties.rs b/src/structs/drawing/run_properties.rs index 5357c4a7..630ceb20 100644 --- a/src/structs/drawing/run_properties.rs +++ b/src/structs/drawing/run_properties.rs @@ -126,7 +126,7 @@ impl RunProperties { } #[inline] - pub fn get_spacing(&self) -> &i32 { + pub fn get_spacing(&self) -> i32 { self.spacing.get_value() } diff --git a/src/structs/drawing/soft_edge.rs b/src/structs/drawing/soft_edge.rs index e44c8c57..d15d20d6 100644 --- a/src/structs/drawing/soft_edge.rs +++ b/src/structs/drawing/soft_edge.rs @@ -13,7 +13,7 @@ pub struct SoftEdge { } impl SoftEdge { #[inline] - pub fn get_radius(&self) -> &i64 { + pub fn get_radius(&self) -> i64 { self.radius.get_value() } diff --git a/src/structs/drawing/source_rectangle.rs b/src/structs/drawing/source_rectangle.rs index aa728ac3..cb879573 100644 --- a/src/structs/drawing/source_rectangle.rs +++ b/src/structs/drawing/source_rectangle.rs @@ -60,15 +60,13 @@ impl SourceRectangle { _reader: &mut Reader, e: &BytesStart, ) { - for a in e.attributes().with_checks(false) { - if let Ok(attr) = a { - match attr.key.0 { - b"t" => self.set_t(get_attribute_value(&attr).unwrap()), - b"l" => self.set_l(get_attribute_value(&attr).unwrap()), - b"r" => self.set_r(get_attribute_value(&attr).unwrap()), - b"b" => self.set_b(get_attribute_value(&attr).unwrap()), - _ => {} - } + for attr in e.attributes().with_checks(false).flatten() { + match attr.key.0 { + b"t" => self.set_t(get_attribute_value(&attr).unwrap()), + b"l" => self.set_l(get_attribute_value(&attr).unwrap()), + b"r" => self.set_r(get_attribute_value(&attr).unwrap()), + b"b" => self.set_b(get_attribute_value(&attr).unwrap()), + _ => {} } } } diff --git a/src/structs/drawing/spacing_percent.rs b/src/structs/drawing/spacing_percent.rs index e9916d3d..fc796ac6 100644 --- a/src/structs/drawing/spacing_percent.rs +++ b/src/structs/drawing/spacing_percent.rs @@ -13,7 +13,7 @@ pub struct SpacingPercent { } impl SpacingPercent { #[inline] - pub fn get_val(&self) -> &i32 { + pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/drawing/spreadsheet/blip_fill.rs b/src/structs/drawing/spreadsheet/blip_fill.rs index b2d904d6..56726e46 100644 --- a/src/structs/drawing/spreadsheet/blip_fill.rs +++ b/src/structs/drawing/spreadsheet/blip_fill.rs @@ -21,7 +21,7 @@ pub struct BlipFill { impl BlipFill { #[inline] - pub fn get_rotate_with_shape(&self) -> &bool { + pub fn get_rotate_with_shape(&self) -> bool { self.rotate_with_shape.get_value() } diff --git a/src/structs/drawing/spreadsheet/extent.rs b/src/structs/drawing/spreadsheet/extent.rs index dc201832..20f03f27 100644 --- a/src/structs/drawing/spreadsheet/extent.rs +++ b/src/structs/drawing/spreadsheet/extent.rs @@ -15,7 +15,7 @@ pub struct Extent { impl Extent { #[inline] - pub fn get_cx(&self) -> &i64 { + pub fn get_cx(&self) -> i64 { self.cx.get_value() } @@ -26,7 +26,7 @@ impl Extent { } #[inline] - pub fn get_cy(&self) -> &i64 { + pub fn get_cy(&self) -> i64 { self.cy.get_value() } diff --git a/src/structs/drawing/spreadsheet/from_marker.rs b/src/structs/drawing/spreadsheet/from_marker.rs index 24dadfea..de3db6c8 100644 --- a/src/structs/drawing/spreadsheet/from_marker.rs +++ b/src/structs/drawing/spreadsheet/from_marker.rs @@ -14,7 +14,7 @@ pub struct FromMarker { } impl FromMarker { #[inline] - pub fn get_col(&self) -> &usize { + pub fn get_col(&self) -> usize { &self.col } @@ -25,7 +25,7 @@ impl FromMarker { } #[inline] - pub fn get_col_off(&self) -> &usize { + pub fn get_col_off(&self) -> usize { &self.col_off } @@ -36,7 +36,7 @@ impl FromMarker { } #[inline] - pub fn get_row(&self) -> &usize { + pub fn get_row(&self) -> usize { &self.row } @@ -47,7 +47,7 @@ impl FromMarker { } #[inline] - pub fn get_row_off(&self) -> &usize { + pub fn get_row_off(&self) -> usize { &self.row_off } @@ -58,17 +58,17 @@ impl FromMarker { } #[inline] - pub(crate) fn adjustment_insert_row(&mut self, num_rows: &usize) { + pub(crate) fn adjustment_insert_row(&mut self, num_rows: usize) { self.row += num_rows; } #[inline] - pub(crate) fn adjustment_insert_column(&mut self, num_cols: &usize) { + pub(crate) fn adjustment_insert_column(&mut self, num_cols: usize) { self.col += num_cols; } #[inline] - pub(crate) fn adjustment_remove_row(&mut self, num_rows: &usize) { + pub(crate) fn adjustment_remove_row(&mut self, num_rows: usize) { self.row = if &self.row > num_rows { self.row - num_rows } else { @@ -77,7 +77,7 @@ impl FromMarker { } #[inline] - pub(crate) fn adjustment_remove_column(&mut self, num_cols: &usize) { + pub(crate) fn adjustment_remove_column(&mut self, num_cols: usize) { self.col = if &self.col > num_cols { self.col - num_cols } else { diff --git a/src/structs/drawing/spreadsheet/graphic_frame.rs b/src/structs/drawing/spreadsheet/graphic_frame.rs index f48d5e65..319b2a8b 100644 --- a/src/structs/drawing/spreadsheet/graphic_frame.rs +++ b/src/structs/drawing/spreadsheet/graphic_frame.rs @@ -150,10 +150,10 @@ impl AdjustmentCoordinateWithSheet for GraphicFrame { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.graphic.adjustment_insert_coordinate_with_sheet( sheet_name, @@ -168,10 +168,10 @@ impl AdjustmentCoordinateWithSheet for GraphicFrame { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.graphic.adjustment_remove_coordinate_with_sheet( sheet_name, diff --git a/src/structs/drawing/spreadsheet/group_shape.rs b/src/structs/drawing/spreadsheet/group_shape.rs index 75ce123c..d32b4f93 100644 --- a/src/structs/drawing/spreadsheet/group_shape.rs +++ b/src/structs/drawing/spreadsheet/group_shape.rs @@ -130,10 +130,10 @@ impl GroupShape { write_start_tag(writer, "xdr:grpSp", vec![], false); // xdr:nvGrpSpPr - &self.non_visual_group_shape_properties.write_to(writer); + self.non_visual_group_shape_properties.write_to(writer); // xdr:grpSpPr - &self.group_shape_properties.write_to(writer); + self.group_shape_properties.write_to(writer); // xdr:pic for obj in &self.picture_collection { @@ -142,7 +142,7 @@ impl GroupShape { // xdr:sp for obj in &self.shape_collection { - obj.write_to(writer, rel_list, &0); + obj.write_to(writer, rel_list, 0); } write_end_tag(writer, "xdr:grpSp"); diff --git a/src/structs/drawing/spreadsheet/group_shape_properties.rs b/src/structs/drawing/spreadsheet/group_shape_properties.rs index 56a83deb..de0cc34b 100644 --- a/src/structs/drawing/spreadsheet/group_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/group_shape_properties.rs @@ -37,13 +37,10 @@ impl GroupShapeProperties { xml_read_loop!( reader, Event::Start(ref e) => { - match e.name().0 { - b"a:xfrm" => { - let mut obj = Transform2D::default(); - obj.set_attributes(reader, e); - self.set_transform2d(obj); - } - _ => (), + if e.name().0 == b"a:xfrm" { + let mut obj = Transform2D::default(); + obj.set_attributes(reader, e); + self.set_transform2d(obj); } }, Event::End(ref e) => { diff --git a/src/structs/drawing/spreadsheet/marker_type.rs b/src/structs/drawing/spreadsheet/marker_type.rs index 8e1c049d..02d4142c 100644 --- a/src/structs/drawing/spreadsheet/marker_type.rs +++ b/src/structs/drawing/spreadsheet/marker_type.rs @@ -16,8 +16,8 @@ pub struct MarkerType { } impl MarkerType { #[inline] - pub fn get_col(&self) -> &u32 { - &self.col + pub fn get_col(&self) -> u32 { + self.col } #[inline] @@ -27,8 +27,8 @@ impl MarkerType { } #[inline] - pub fn get_col_off(&self) -> &i32 { - &self.col_off + pub fn get_col_off(&self) -> i32 { + self.col_off } #[inline] @@ -44,8 +44,8 @@ impl MarkerType { } #[inline] - pub fn get_row(&self) -> &u32 { - &self.row + pub fn get_row(&self) -> u32 { + self.row } #[inline] @@ -55,8 +55,8 @@ impl MarkerType { } #[inline] - pub fn get_row_off(&self) -> &i32 { - &self.row_off + pub fn get_row_off(&self) -> i32 { + self.row_off } #[inline] @@ -73,7 +73,7 @@ impl MarkerType { #[inline] pub fn get_coordinate(&self) -> String { - coordinate_from_index(&(&self.col + 1), &(&self.row + 1)) + coordinate_from_index(self.col + 1, self.row + 1) } #[inline] @@ -133,22 +133,22 @@ impl MarkerType { // xdr:col write_start_tag(writer, "xdr:col", vec![], false); - write_text_node(writer, &self.col.to_string()); + write_text_node(writer, self.col.to_string()); write_end_tag(writer, "xdr:col"); // xdr:colOff write_start_tag(writer, "xdr:colOff", vec![], false); - write_text_node(writer, &self.col_off.to_string()); + write_text_node(writer, self.col_off.to_string()); write_end_tag(writer, "xdr:colOff"); // xdr:row write_start_tag(writer, "xdr:row", vec![], false); - write_text_node(writer, &self.row.to_string()); + write_text_node(writer, self.row.to_string()); write_end_tag(writer, "xdr:row"); // xdr:rowOff write_start_tag(writer, "xdr:rowOff", vec![], false); - write_text_node(writer, &self.row_off.to_string()); + write_text_node(writer, self.row_off.to_string()); write_end_tag(writer, "xdr:rowOff"); write_end_tag(writer, tag_name); @@ -158,36 +158,36 @@ impl AdjustmentCoordinate for MarkerType { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - self.col = adjustment_insert_coordinate(&(&self.col + 1), root_col_num, offset_col_num) - 1; - self.row = adjustment_insert_coordinate(&(&self.row + 1), root_row_num, offset_row_num) - 1; + self.col = adjustment_insert_coordinate(self.col + 1, root_col_num, offset_col_num) - 1; + self.row = adjustment_insert_coordinate(self.row + 1, root_row_num, offset_row_num) - 1; } #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - self.col = adjustment_remove_coordinate(&(&self.col + 1), root_col_num, offset_col_num) - 1; - self.row = adjustment_remove_coordinate(&(&self.row + 1), root_row_num, offset_row_num) - 1; + self.col = adjustment_remove_coordinate(self.col + 1, root_col_num, offset_col_num) - 1; + self.row = adjustment_remove_coordinate(self.row + 1, root_row_num, offset_row_num) - 1; } #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { - is_remove_coordinate(&(&self.col + 1), root_col_num, offset_col_num) - || is_remove_coordinate(&(&self.row + 1), root_row_num, offset_row_num) + is_remove_coordinate(self.col + 1, root_col_num, offset_col_num) + || is_remove_coordinate(self.row + 1, root_row_num, offset_row_num) } } diff --git a/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs b/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs index c9f5c9a6..6fdebac6 100644 --- a/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs @@ -90,7 +90,7 @@ impl NonVisualConnectionShapeProperties { write_start_tag(writer, "xdr:nvCxnSpPr", vec![], false); // xdr:cNvPr - self.non_visual_drawing_properties.write_to(writer, &0); + self.non_visual_drawing_properties.write_to(writer, 0); // xdr:cNvCxnSpPr self.non_visual_connector_shape_drawing_properties diff --git a/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs index af6148bc..d6ac338a 100644 --- a/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs @@ -18,7 +18,7 @@ pub struct NonVisualDrawingProperties { impl NonVisualDrawingProperties { #[inline] - pub fn get_id(&self) -> &u32 { + pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -40,7 +40,7 @@ impl NonVisualDrawingProperties { } #[inline] - pub fn get_hidden(&self) -> &bool { + pub fn get_hidden(&self) -> bool { self.hidden.get_value() } @@ -76,8 +76,8 @@ impl NonVisualDrawingProperties { ); } - pub(crate) fn write_to(&self, writer: &mut Writer>>, ole_id: &usize) { - let with_inner = ole_id > &0; + pub(crate) fn write_to(&self, writer: &mut Writer>>, ole_id: usize) { + let with_inner = ole_id > 0; // xdr:cNvPr let mut attributes: Vec<(&str, &str)> = Vec::new(); let id = self.id.get_value_string(); diff --git a/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs b/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs index 9f24326d..5c231e6a 100644 --- a/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs @@ -97,7 +97,7 @@ impl NonVisualGraphicFrameProperties { write_start_tag(writer, "xdr:nvGraphicFramePr", vec![], false); // xdr:cNvPr - self.non_visual_drawing_properties.write_to(writer, &0); + self.non_visual_drawing_properties.write_to(writer, 0); // xdr:cNvGraphicFramePr self.non_visual_graphic_frame_drawing_properties diff --git a/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs index c399d263..3de684c2 100644 --- a/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs @@ -1,6 +1,5 @@ // xdr:cNvGrpSpPr use super::super::GroupShapeLocks; -use super::NonVisualDrawingProperties; use crate::reader::driver::*; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; @@ -64,11 +63,8 @@ impl NonVisualGroupShapeDrawingProperties { write_start_tag(writer, "xdr:cNvGrpSpPr", vec![], is_empty); // a:grpSpLocks - match &self.group_shape_locks { - Some(v) => { - v.write_to(writer); - } - None => {} + if let Some(v) = &self.group_shape_locks { + v.write_to(writer); } if !is_empty { diff --git a/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs b/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs index 8eef8678..245a89b7 100644 --- a/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs @@ -104,7 +104,7 @@ impl NonVisualGroupShapeProperties { write_start_tag(writer, "xdr:nvGrpSpPr", vec![], false); // xdr:cNvPr - self.non_visual_drawing_properties.write_to(writer, &0); + self.non_visual_drawing_properties.write_to(writer, 0); // xdr:cNvGrpSpPr self.non_visual_group_shape_drawing_properties diff --git a/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs index c9fc1bbe..74ddad77 100644 --- a/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs @@ -16,7 +16,7 @@ pub struct NonVisualPictureDrawingProperties { impl NonVisualPictureDrawingProperties { #[inline] - pub fn get_prefer_relative_resize(&self) -> &bool { + pub fn get_prefer_relative_resize(&self) -> bool { self.prefer_relative_resize.get_value() } diff --git a/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs b/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs index 23867b05..652e39fe 100644 --- a/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs @@ -97,7 +97,7 @@ impl NonVisualPictureProperties { write_start_tag(writer, "xdr:nvPicPr", vec![], false); // xdr:cNvPr - self.non_visual_drawing_properties.write_to(writer, &0); + self.non_visual_drawing_properties.write_to(writer, 0); // xdr:cNvPicPr self.non_visual_picture_drawing_properties.write_to(writer); diff --git a/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs b/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs index e12edb7b..fc0e3e83 100644 --- a/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs @@ -56,7 +56,7 @@ impl NonVisualShapeProperties { ); } - pub(crate) fn write_to(&self, writer: &mut Writer>>, ole_id: &usize) { + pub(crate) fn write_to(&self, writer: &mut Writer>>, ole_id: usize) { // xdr:nvSpPr write_start_tag(writer, "xdr:nvSpPr", vec![], false); diff --git a/src/structs/drawing/spreadsheet/one_cell_anchor.rs b/src/structs/drawing/spreadsheet/one_cell_anchor.rs index 46f90852..98c66d4a 100644 --- a/src/structs/drawing/spreadsheet/one_cell_anchor.rs +++ b/src/structs/drawing/spreadsheet/one_cell_anchor.rs @@ -174,7 +174,7 @@ impl OneCellAnchor { // xdr:sp if let Some(v) = &self.shape { - v.write_to(writer, rel_list, &0); + v.write_to(writer, rel_list, 0); } // xdr:pic @@ -192,10 +192,10 @@ impl AdjustmentCoordinate for OneCellAnchor { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.from_marker.adjustment_insert_coordinate( root_col_num, @@ -208,10 +208,10 @@ impl AdjustmentCoordinate for OneCellAnchor { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.from_marker.adjustment_remove_coordinate( root_col_num, @@ -224,10 +224,10 @@ impl AdjustmentCoordinate for OneCellAnchor { #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { self.from_marker.is_remove_coordinate( root_col_num, diff --git a/src/structs/drawing/spreadsheet/shape.rs b/src/structs/drawing/spreadsheet/shape.rs index 0f9e8295..7470af76 100644 --- a/src/structs/drawing/spreadsheet/shape.rs +++ b/src/structs/drawing/spreadsheet/shape.rs @@ -137,7 +137,7 @@ impl Shape { &self, writer: &mut Writer>>, rel_list: &mut Vec<(String, String)>, - ole_id: &usize, + ole_id: usize, ) { // xdr:sp write_start_tag( diff --git a/src/structs/drawing/spreadsheet/to_marker.rs b/src/structs/drawing/spreadsheet/to_marker.rs index 7ce46a97..966a42d9 100644 --- a/src/structs/drawing/spreadsheet/to_marker.rs +++ b/src/structs/drawing/spreadsheet/to_marker.rs @@ -14,7 +14,7 @@ pub struct ToMarker { } impl ToMarker { #[inline] - pub fn get_col(&self) -> &usize { + pub fn get_col(&self) -> usize { &self.col } @@ -25,7 +25,7 @@ impl ToMarker { } #[inline] - pub fn get_col_off(&self) -> &usize { + pub fn get_col_off(&self) -> usize { &self.col_off } @@ -36,7 +36,7 @@ impl ToMarker { } #[inline] - pub fn get_row(&self) -> &usize { + pub fn get_row(&self) -> usize { &self.row } @@ -47,7 +47,7 @@ impl ToMarker { } #[inline] - pub fn get_row_off(&self) -> &usize { + pub fn get_row_off(&self) -> usize { &self.row_off } @@ -58,17 +58,17 @@ impl ToMarker { } #[inline] - pub(crate) fn adjustment_insert_row(&mut self, num_rows: &usize) { + pub(crate) fn adjustment_insert_row(&mut self, num_rows: usize) { self.row += num_rows; } #[inline] - pub(crate) fn adjustment_insert_column(&mut self, num_cols: &usize) { + pub(crate) fn adjustment_insert_column(&mut self, num_cols: usize) { self.col += num_cols; } #[inline] - pub(crate) fn adjustment_remove_row(&mut self, num_rows: &usize) { + pub(crate) fn adjustment_remove_row(&mut self, num_rows: usize) { self.row = if &self.row > num_rows { self.row - num_rows } else { @@ -77,7 +77,7 @@ impl ToMarker { } #[inline] - pub(crate) fn adjustment_remove_column(&mut self, num_cols: &usize) { + pub(crate) fn adjustment_remove_column(&mut self, num_cols: usize) { self.col = if &self.col > num_cols { self.col - num_cols } else { diff --git a/src/structs/drawing/spreadsheet/transform.rs b/src/structs/drawing/spreadsheet/transform.rs index b5882de1..35f9368e 100644 --- a/src/structs/drawing/spreadsheet/transform.rs +++ b/src/structs/drawing/spreadsheet/transform.rs @@ -51,7 +51,7 @@ impl Transform { } #[inline] - pub fn get_rotation(&self) -> &i32 { + pub fn get_rotation(&self) -> i32 { self.rotation.get_value() } @@ -61,7 +61,7 @@ impl Transform { } #[inline] - pub fn get_vertical_flip(&self) -> &bool { + pub fn get_vertical_flip(&self) -> bool { self.vertical_flip.get_value() } @@ -71,7 +71,7 @@ impl Transform { } #[inline] - pub fn get_horizontal_flip(&self) -> &bool { + pub fn get_horizontal_flip(&self) -> bool { self.horizontal_flip.get_value() } diff --git a/src/structs/drawing/spreadsheet/two_cell_anchor.rs b/src/structs/drawing/spreadsheet/two_cell_anchor.rs index 95736162..eedaaf21 100644 --- a/src/structs/drawing/spreadsheet/two_cell_anchor.rs +++ b/src/structs/drawing/spreadsheet/two_cell_anchor.rs @@ -158,7 +158,7 @@ impl TwoCellAnchor { } #[inline] - pub fn get_is_alternate_content(&self) -> &bool { + pub fn get_is_alternate_content(&self) -> bool { self.is_alternate_content.get_value() } @@ -249,9 +249,9 @@ impl TwoCellAnchor { &self, writer: &mut Writer>>, rel_list: &mut Vec<(String, String)>, - ole_id: &usize, + ole_id: usize, ) { - if *self.get_is_alternate_content() { + if self.get_is_alternate_content() { // mc:AlternateContent write_start_tag( writer, @@ -312,7 +312,7 @@ impl TwoCellAnchor { write_end_tag(writer, "xdr:twoCellAnchor"); - if *self.get_is_alternate_content() { + if self.get_is_alternate_content() { write_end_tag(writer, "mc:Choice"); // mc:Fallback @@ -326,10 +326,10 @@ impl AdjustmentCoordinate for TwoCellAnchor { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.from_marker.adjustment_insert_coordinate( root_col_num, @@ -348,10 +348,10 @@ impl AdjustmentCoordinate for TwoCellAnchor { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.from_marker.adjustment_remove_coordinate( root_col_num, @@ -370,10 +370,10 @@ impl AdjustmentCoordinate for TwoCellAnchor { #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { self.from_marker.is_remove_coordinate( root_col_num, @@ -393,22 +393,19 @@ impl AdjustmentCoordinateWithSheet for TwoCellAnchor { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - match &mut self.graphic_frame { - Some(v) => { - v.adjustment_insert_coordinate_with_sheet( - sheet_name, - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(v) = &mut self.graphic_frame { + v.adjustment_insert_coordinate_with_sheet( + sheet_name, + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } } @@ -416,22 +413,19 @@ impl AdjustmentCoordinateWithSheet for TwoCellAnchor { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - match &mut self.graphic_frame { - Some(v) => { - v.adjustment_remove_coordinate_with_sheet( - sheet_name, - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(v) = &mut self.graphic_frame { + v.adjustment_remove_coordinate_with_sheet( + sheet_name, + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } } } diff --git a/src/structs/drawing/spreadsheet/worksheet_drawing.rs b/src/structs/drawing/spreadsheet/worksheet_drawing.rs index 72798f06..0d75e0d1 100644 --- a/src/structs/drawing/spreadsheet/worksheet_drawing.rs +++ b/src/structs/drawing/spreadsheet/worksheet_drawing.rs @@ -46,33 +46,33 @@ impl WorksheetDrawing { } #[inline] - pub fn get_image(&self, col: &u32, row: &u32) -> Option<&Image> { + pub fn get_image(&self, col: u32, row: u32) -> Option<&Image> { self.image_collection .iter() - .find(|&image| image.get_col() == &(col - 1) && image.get_row() == &(row - 1)) + .find(|&image| image.get_col() == col - 1 && image.get_row() == row - 1) } #[inline] - pub fn get_image_mut(&mut self, col: &u32, row: &u32) -> Option<&mut Image> { + pub fn get_image_mut(&mut self, col: u32, row: u32) -> Option<&mut Image> { self.image_collection .iter_mut() - .find(|image| image.get_col() == &(col - 1) && image.get_row() == &(row - 1)) + .find(|image| image.get_col() == col - 1 && image.get_row() == row - 1) } - pub fn get_images(&self, col: &u32, row: &u32) -> Vec<&Image> { + pub fn get_images(&self, col: u32, row: u32) -> Vec<&Image> { let mut result: Vec<&Image> = Vec::new(); for image in &self.image_collection { - if image.get_col() == &(col - 1) && image.get_row() == &(row - 1) { + if image.get_col() == col - 1 && image.get_row() == row - 1 { result.push(image); } } result } - pub fn get_images_mut(&mut self, col: &u32, row: &u32) -> Vec<&mut Image> { + pub fn get_images_mut(&mut self, col: u32, row: u32) -> Vec<&mut Image> { let mut result: Vec<&mut Image> = Vec::new(); for image in &mut self.image_collection { - if image.get_col() == &(col - 1) && image.get_row() == &(row - 1) { + if image.get_col() == col - 1 && image.get_row() == row - 1 { result.push(image); } } @@ -96,33 +96,33 @@ impl WorksheetDrawing { } #[inline] - pub fn get_chart(&self, col: &u32, row: &u32) -> Option<&Chart> { + pub fn get_chart(&self, col: u32, row: u32) -> Option<&Chart> { self.chart_collection .iter() - .find(|&chart| chart.get_col() == &(col - 1) && chart.get_row() == &(row - 1)) + .find(|&chart| chart.get_col() == col - 1 && chart.get_row() == row - 1) } #[inline] - pub fn get_chart_mut(&mut self, col: &u32, row: &u32) -> Option<&mut Chart> { + pub fn get_chart_mut(&mut self, col: u32, row: u32) -> Option<&mut Chart> { self.chart_collection .iter_mut() - .find(|chart| chart.get_col() == &(col - 1) && chart.get_row() == &(row - 1)) + .find(|chart| chart.get_col() == col - 1 && chart.get_row() == row - 1) } - pub fn get_charts(&self, col: &u32, row: &u32) -> Vec<&Chart> { + pub fn get_charts(&self, col: u32, row: u32) -> Vec<&Chart> { let mut result: Vec<&Chart> = Vec::new(); for chart in &self.chart_collection { - if chart.get_col() == &(col - 1) && chart.get_row() == &(row - 1) { + if chart.get_col() == col - 1 && chart.get_row() == row - 1 { result.push(chart); } } result } - pub fn get_charts_mut(&mut self, col: &u32, row: &u32) -> Vec<&mut Chart> { + pub fn get_charts_mut(&mut self, col: u32, row: u32) -> Vec<&mut Chart> { let mut result: Vec<&mut Chart> = Vec::new(); for chart in &mut self.chart_collection { - if chart.get_col() == &(col - 1) && chart.get_row() == &(row - 1) { + if chart.get_col() == col - 1 && chart.get_row() == row - 1 { result.push(chart); } } @@ -245,11 +245,8 @@ impl WorksheetDrawing { result.push(anchor); } for image in &mut self.image_collection { - match image.get_one_cell_anchor_mut() { - Some(anchor) => { - result.push(anchor); - } - None => {} + if let Some(anchor) = image.get_one_cell_anchor_mut() { + result.push(anchor); } } result @@ -261,15 +258,12 @@ impl WorksheetDrawing { result.push(anchor); } for chart in &mut self.chart_collection { - let mut anchor = chart.get_two_cell_anchor_mut(); + let anchor = chart.get_two_cell_anchor_mut(); result.push(anchor); } for image in &mut self.image_collection { - match image.get_two_cell_anchor_mut() { - Some(anchor) => { - result.push(anchor); - } - None => {} + if let Some(anchor) = image.get_two_cell_anchor_mut() { + result.push(anchor); } } result @@ -383,13 +377,13 @@ impl WorksheetDrawing { // xdr:twoCellAnchor for chart in &self.chart_collection { - chart.get_two_cell_anchor().write_to(writer, rel_list, &0); + chart.get_two_cell_anchor().write_to(writer, rel_list, 0); } for image in &self.image_collection { image.write_to(writer, rel_list); } for two_cell_anchor in &self.two_cell_anchor_collection { - two_cell_anchor.write_to(writer, rel_list, &0); + two_cell_anchor.write_to(writer, rel_list, 0); } // xdr:oneCellAnchor @@ -398,12 +392,12 @@ impl WorksheetDrawing { } // mc:AlternateContent - let mut ole_id = 1000 + 25; + // let mut ole_id = 1000 + 25; for ole_object in ole_objects.get_ole_object() { ole_object .get_two_cell_anchor() - .write_to(writer, rel_list, &0); - ole_id += 1; + .write_to(writer, rel_list, 0); + // ole_id += 1; } write_end_tag(writer, "xdr:wsDr"); @@ -412,10 +406,10 @@ impl WorksheetDrawing { impl AdjustmentCoordinate for WorksheetDrawing { fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for anchor in &mut self.one_cell_anchor_collection { anchor.adjustment_insert_coordinate( @@ -453,12 +447,12 @@ impl AdjustmentCoordinate for WorksheetDrawing { fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - &mut self.one_cell_anchor_collection.retain(|k| { + self.one_cell_anchor_collection.retain(|k| { !(k.is_remove_coordinate(root_col_num, offset_col_num, root_row_num, offset_row_num)) }); for anchor in &mut self.one_cell_anchor_collection { @@ -469,7 +463,7 @@ impl AdjustmentCoordinate for WorksheetDrawing { offset_row_num, ); } - &mut self.two_cell_anchor_collection.retain(|k| { + self.two_cell_anchor_collection.retain(|k| { !(k.is_remove_coordinate(root_col_num, offset_col_num, root_row_num, offset_row_num)) }); for anchor in &mut self.two_cell_anchor_collection { @@ -480,7 +474,7 @@ impl AdjustmentCoordinate for WorksheetDrawing { offset_row_num, ); } - &mut self.chart_collection.retain(|k| { + self.chart_collection.retain(|k| { !(k.is_remove_coordinate(root_col_num, offset_col_num, root_row_num, offset_row_num)) }); for chart in &mut self.chart_collection { @@ -491,7 +485,7 @@ impl AdjustmentCoordinate for WorksheetDrawing { offset_row_num, ); } - &mut self.image_collection.retain(|k| { + self.image_collection.retain(|k| { !(k.is_remove_coordinate(root_col_num, offset_col_num, root_row_num, offset_row_num)) }); for image in &mut self.image_collection { @@ -508,10 +502,10 @@ impl AdjustmentCoordinateWithSheet for WorksheetDrawing { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { // chart for chart in &mut self.chart_collection { @@ -528,10 +522,10 @@ impl AdjustmentCoordinateWithSheet for WorksheetDrawing { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { // chart for chart in &mut self.chart_collection { diff --git a/src/structs/drawing/start_connection.rs b/src/structs/drawing/start_connection.rs index 6a8fe2ac..6bcbc12b 100644 --- a/src/structs/drawing/start_connection.rs +++ b/src/structs/drawing/start_connection.rs @@ -14,7 +14,7 @@ pub struct StartConnection { } impl StartConnection { #[inline] - pub fn get_id(&self) -> &u32 { + pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -24,7 +24,7 @@ impl StartConnection { } #[inline] - pub fn get_index(&self) -> &u32 { + pub fn get_index(&self) -> u32 { self.index.get_value() } diff --git a/src/structs/drawing/text_paragraph_properties_type.rs b/src/structs/drawing/text_paragraph_properties_type.rs index ab2728e3..b87a2789 100644 --- a/src/structs/drawing/text_paragraph_properties_type.rs +++ b/src/structs/drawing/text_paragraph_properties_type.rs @@ -24,7 +24,7 @@ pub struct TextParagraphPropertiesType { } impl TextParagraphPropertiesType { #[inline] - pub fn get_right_to_left(&self) -> &bool { + pub fn get_right_to_left(&self) -> bool { self.right_to_left.get_value() } @@ -116,13 +116,10 @@ impl TextParagraphPropertiesType { xml_read_loop!( reader, Event::Empty(ref e) => { - match e.name().into_inner() { - b"a:defRPr" => { - let mut obj = RunProperties::default(); - obj.set_attributes(reader, e, true); - self.set_default_run_properties(obj); - } - _ => (), + if e.name().into_inner() == b"a:defRPr" { + let mut obj = RunProperties::default(); + obj.set_attributes(reader, e, true); + self.set_default_run_properties(obj); } }, Event::Start(ref e) => { @@ -229,27 +226,18 @@ impl TextParagraphPropertiesType { write_start_tag(writer, tag_name, attributes, false); // a:spcBef - match &self.space_before { - Some(v) => { - v.write_to(writer); - } - None => {} + if let Some(v) = &self.space_before { + v.write_to(writer); } // a:spcAft - match &self.space_after { - Some(v) => { - v.write_to(writer); - } - None => {} + if let Some(v) = &self.space_after { + v.write_to(writer); } // a:defRPr - match &self.default_run_properties { - Some(v) => { - v.write_to_def_rpr(writer); - } - None => {} + if let Some(v) = &self.default_run_properties { + v.write_to_def_rpr(writer); } write_end_tag(writer, tag_name); diff --git a/src/structs/drawing/transform2d.rs b/src/structs/drawing/transform2d.rs index 86cb47e6..f331b5a8 100644 --- a/src/structs/drawing/transform2d.rs +++ b/src/structs/drawing/transform2d.rs @@ -181,19 +181,13 @@ impl Transform2D { self.extents.write_to_ext(writer); // a:chOff - match &self.child_offset { - Some(v) => { - v.write_to_ch_off(writer); - } - None => {} + if let Some(v) = &self.child_offset { + v.write_to_ch_off(writer); } // a:chExt - match &self.child_extents { - Some(v) => { - v.write_to_ch_ext(writer); - } - None => {} + if let Some(v) = &self.child_extents { + v.write_to_ch_ext(writer); } write_end_tag(writer, "a:xfrm"); diff --git a/src/structs/embedded_object_properties.rs b/src/structs/embedded_object_properties.rs index d9f4825a..5545c8b5 100644 --- a/src/structs/embedded_object_properties.rs +++ b/src/structs/embedded_object_properties.rs @@ -34,7 +34,7 @@ impl EmbeddedObjectProperties { } #[inline] - pub fn get_shape_id(&self) -> &u32 { + pub fn get_shape_id(&self) -> u32 { self.shape_id.get_value() } @@ -60,7 +60,7 @@ impl EmbeddedObjectProperties { } #[inline] - pub fn get_default_size(&self) -> &bool { + pub fn get_default_size(&self) -> bool { self.default_size.get_value() } @@ -71,7 +71,7 @@ impl EmbeddedObjectProperties { } #[inline] - pub fn get_auto_pict(&self) -> &bool { + pub fn get_auto_pict(&self) -> bool { self.auto_pict.get_value() } @@ -109,7 +109,7 @@ impl EmbeddedObjectProperties { self.get_image_mut() .set_image_name(attached_file.get_file_name()); self.get_image_mut() - .set_image_data(attached_file.get_file_data().clone()); + .set_image_data(attached_file.get_file_data()); set_string_from_xml!(self, e, default_size, "defaultSize"); set_string_from_xml!(self, e, auto_pict, "autoPict"); @@ -130,7 +130,7 @@ impl EmbeddedObjectProperties { ); } - pub(crate) fn write_to(&self, writer: &mut Writer>>, r_id: &usize) { + pub(crate) fn write_to(&self, writer: &mut Writer>>, r_id: usize) { // objectPr let mut attributes: Vec<(&str, &str)> = Vec::new(); if self.default_size.has_value() { diff --git a/src/structs/field.rs b/src/structs/field.rs index 9f9e8b37..e489d5fa 100644 --- a/src/structs/field.rs +++ b/src/structs/field.rs @@ -2,7 +2,7 @@ use crate::reader::driver::*; use crate::structs::Int32Value; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -12,7 +12,7 @@ pub struct Field { x: Int32Value, } impl Field { - pub fn get_data_field(&self) -> &i32 { + pub fn get_data_field(&self) -> i32 { self.x.get_value() } diff --git a/src/structs/fills.rs b/src/structs/fills.rs index 98ba4343..e702c9e4 100644 --- a/src/structs/fills.rs +++ b/src/structs/fills.rs @@ -21,6 +21,7 @@ impl Fills { } #[inline] + #[allow(dead_code)] pub(crate) fn get_fill_mut(&mut self) -> &mut ThinVec { &mut self.fill } diff --git a/src/structs/font.rs b/src/structs/font.rs index 36a9582e..b3d22930 100644 --- a/src/structs/font.rs +++ b/src/structs/font.rs @@ -116,7 +116,7 @@ impl Font { } #[inline] - pub fn get_size(&self) -> &f64 { + pub fn get_size(&self) -> f64 { self.font_size.get_val() } @@ -143,7 +143,7 @@ impl Font { } #[inline] - pub fn get_family(&self) -> &i32 { + pub fn get_family(&self) -> i32 { self.font_family_numbering.get_val() } @@ -170,7 +170,7 @@ impl Font { } #[inline] - pub fn get_bold(&self) -> &bool { + pub fn get_bold(&self) -> bool { self.font_bold.get_val() } @@ -197,7 +197,7 @@ impl Font { } #[inline] - pub fn get_italic(&self) -> &bool { + pub fn get_italic(&self) -> bool { self.font_italic.get_val() } @@ -253,7 +253,7 @@ impl Font { } #[inline] - pub fn get_strikethrough(&self) -> &bool { + pub fn get_strikethrough(&self) -> bool { self.font_strike.get_val() } @@ -296,7 +296,7 @@ impl Font { } #[inline] - pub fn get_charset(&self) -> &i32 { + pub fn get_charset(&self) -> i32 { self.font_char_set.get_val() } diff --git a/src/structs/font_char_set.rs b/src/structs/font_char_set.rs index 0eed3f7a..babab491 100644 --- a/src/structs/font_char_set.rs +++ b/src/structs/font_char_set.rs @@ -14,7 +14,7 @@ pub struct FontCharSet { impl FontCharSet { #[inline] - pub fn get_val(&self) -> &i32 { + pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/font_family_numbering.rs b/src/structs/font_family_numbering.rs index d600c941..a62ec884 100644 --- a/src/structs/font_family_numbering.rs +++ b/src/structs/font_family_numbering.rs @@ -14,7 +14,7 @@ pub struct FontFamilyNumbering { impl FontFamilyNumbering { #[inline] - pub fn get_val(&self) -> &i32 { + pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/font_size.rs b/src/structs/font_size.rs index 93879436..699ffec7 100644 --- a/src/structs/font_size.rs +++ b/src/structs/font_size.rs @@ -14,7 +14,7 @@ pub struct FontSize { impl FontSize { #[inline] - pub fn get_val(&self) -> &f64 { + pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/fonts.rs b/src/structs/fonts.rs index 74a128c6..3d0f90b2 100644 --- a/src/structs/fonts.rs +++ b/src/structs/fonts.rs @@ -21,6 +21,7 @@ impl Fonts { } #[inline] + #[allow(dead_code)] pub(crate) fn get_font_mut(&mut self) -> &mut ThinVec { &mut self.font } diff --git a/src/structs/from_marker.rs b/src/structs/from_marker.rs index 3242b938..4323c042 100644 --- a/src/structs/from_marker.rs +++ b/src/structs/from_marker.rs @@ -16,8 +16,8 @@ pub struct FromMarker { impl FromMarker { #[inline] - pub fn get_col(&self) -> &usize { - &self.col + pub fn get_col(&self) -> usize { + self.col } #[inline] @@ -27,8 +27,8 @@ impl FromMarker { } #[inline] - pub fn get_col_off(&self) -> &usize { - &self.col_off + pub fn get_col_off(&self) -> usize { + self.col_off } #[inline] @@ -38,8 +38,8 @@ impl FromMarker { } #[inline] - pub fn get_row(&self) -> &usize { - &self.row + pub fn get_row(&self) -> usize { + self.row } #[inline] @@ -49,8 +49,8 @@ impl FromMarker { } #[inline] - pub fn get_row_off(&self) -> &usize { - &self.row_off + pub fn get_row_off(&self) -> usize { + self.row_off } #[inline] @@ -60,18 +60,18 @@ impl FromMarker { } #[inline] - pub(crate) fn _adjustment_insert_row(&mut self, num_rows: &usize) { + pub(crate) fn _adjustment_insert_row(&mut self, num_rows: usize) { self.row += num_rows; } #[inline] - pub(crate) fn _adjustment_insert_column(&mut self, num_cols: &usize) { + pub(crate) fn _adjustment_insert_column(&mut self, num_cols: usize) { self.col += num_cols; } #[inline] - pub(crate) fn _adjustment_remove_row(&mut self, num_rows: &usize) { - self.row = if &self.row > num_rows { + pub(crate) fn _adjustment_remove_row(&mut self, num_rows: usize) { + self.row = if self.row > num_rows { self.row - num_rows } else { 1 @@ -79,8 +79,8 @@ impl FromMarker { } #[inline] - pub(crate) fn _adjustment_remove_column(&mut self, num_cols: &usize) { - self.col = if &self.col > num_cols { + pub(crate) fn _adjustment_remove_column(&mut self, num_cols: usize) { + self.col = if self.col > num_cols { self.col - num_cols } else { 1 @@ -122,22 +122,22 @@ impl FromMarker { // xdr:col write_start_tag(writer, "xdr:col", vec![], false); - write_text_node(writer, &self.col.to_string()); + write_text_node(writer, self.col.to_string()); write_end_tag(writer, "xdr:col"); // xdr:colOff write_start_tag(writer, "xdr:colOff", vec![], false); - write_text_node(writer, &self.col_off.to_string()); + write_text_node(writer, self.col_off.to_string()); write_end_tag(writer, "xdr:colOff"); // xdr:row write_start_tag(writer, "xdr:row", vec![], false); - write_text_node(writer, &self.row.to_string()); + write_text_node(writer, self.row.to_string()); write_end_tag(writer, "xdr:row"); // xdr:rowOff write_start_tag(writer, "xdr:rowOff", vec![], false); - write_text_node(writer, &self.row_off.to_string()); + write_text_node(writer, self.row_off.to_string()); write_end_tag(writer, "xdr:rowOff"); write_end_tag(writer, "from"); diff --git a/src/structs/gradient_fill.rs b/src/structs/gradient_fill.rs index b94f02b7..05199af0 100644 --- a/src/structs/gradient_fill.rs +++ b/src/structs/gradient_fill.rs @@ -19,7 +19,7 @@ pub struct GradientFill { impl GradientFill { #[inline] - pub fn get_degree(&self) -> &f64 { + pub fn get_degree(&self) -> f64 { self.degree.get_value() } diff --git a/src/structs/gradient_stop.rs b/src/structs/gradient_stop.rs index 742dddd7..7be5e6fb 100644 --- a/src/structs/gradient_stop.rs +++ b/src/structs/gradient_stop.rs @@ -17,7 +17,7 @@ pub struct GradientStop { impl GradientStop { #[inline] - pub fn get_position(&self) -> &f64 { + pub fn get_position(&self) -> f64 { self.position.get_value() } diff --git a/src/structs/hyperlink.rs b/src/structs/hyperlink.rs index d537b56c..b82051d6 100644 --- a/src/structs/hyperlink.rs +++ b/src/structs/hyperlink.rs @@ -28,8 +28,8 @@ impl Hyperlink { } #[inline] - pub fn get_location(&self) -> &bool { - &self.location + pub fn get_location(&self) -> bool { + self.location } #[inline] diff --git a/src/structs/image.rs b/src/structs/image.rs index aa8ec07f..7e3bbc66 100644 --- a/src/structs/image.rs +++ b/src/structs/image.rs @@ -40,15 +40,15 @@ pub struct Image { /// // Get Image by Worksheet. /// let worksheet = book.get_sheet_by_name_mut("Sheet1").unwrap(); /// let image = worksheet.get_image("B3"); -/// let image = worksheet.get_image_by_column_and_row(&2, &1); +/// let image = worksheet.get_image_by_column_and_row(&2, 1); /// let image = worksheet.get_image_mut("B3"); -/// let image = worksheet.get_image_by_column_and_row_mut(&2, &1); +/// let image = worksheet.get_image_by_column_and_row_mut(&2, 1); /// /// // Use this if there are multiple Images in a given cell. /// let images = worksheet.get_images("B3"); -/// let images = worksheet.get_images_by_column_and_row(&2, &1); +/// let images = worksheet.get_images_by_column_and_row(&2, 1); /// let images = worksheet.get_images_mut("B3"); -/// let images = worksheet.get_images_by_column_and_row_mut(&2, &1); +/// let images = worksheet.get_images_by_column_and_row_mut(&2, 1); /// /// // Download Image /// book.get_sheet_by_name("Sheet1").unwrap() @@ -221,12 +221,12 @@ impl Image { } #[inline] - pub fn get_col(&self) -> &u32 { + pub fn get_col(&self) -> u32 { self.get_from_marker_type().get_col() } #[inline] - pub fn get_row(&self) -> &u32 { + pub fn get_row(&self) -> u32 { self.get_from_marker_type().get_row() } @@ -305,7 +305,7 @@ impl Image { rel_list: &mut Vec<(String, String)>, ) { if let Some(anchor) = self.get_two_cell_anchor() { - anchor.write_to(writer, rel_list, &0); + anchor.write_to(writer, rel_list, 0); } if let Some(anchor) = self.get_one_cell_anchor() { anchor.write_to(writer, rel_list); @@ -316,102 +316,84 @@ impl AdjustmentCoordinate for Image { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { // one_cell_anchor - match self.one_cell_anchor.as_mut() { - Some(anchor) => { - anchor.adjustment_insert_coordinate( - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(anchor) = self.one_cell_anchor.as_mut() { + anchor.adjustment_insert_coordinate( + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } // two_cell_anchor - match self.two_cell_anchor.as_mut() { - Some(anchor) => { - anchor.adjustment_insert_coordinate( - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(anchor) = self.two_cell_anchor.as_mut() { + anchor.adjustment_insert_coordinate( + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } } #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { // one_cell_anchor - match self.one_cell_anchor.as_mut() { - Some(anchor) => { - anchor.adjustment_remove_coordinate( - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(anchor) = self.one_cell_anchor.as_mut() { + anchor.adjustment_remove_coordinate( + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } // two_cell_anchor - match self.two_cell_anchor.as_mut() { - Some(anchor) => { - anchor.adjustment_remove_coordinate( - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(anchor) = self.two_cell_anchor.as_mut() { + anchor.adjustment_remove_coordinate( + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } } #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { - match self.one_cell_anchor.as_ref() { - Some(anchor) => { - return anchor.is_remove_coordinate( - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(anchor) = self.one_cell_anchor.as_ref() { + return anchor.is_remove_coordinate( + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } - match self.two_cell_anchor.as_ref() { - Some(anchor) => { - return anchor.is_remove_coordinate( - root_col_num, - offset_col_num, - root_row_num, - offset_row_num, - ); - } - None => {} + if let Some(anchor) = self.two_cell_anchor.as_ref() { + return anchor.is_remove_coordinate( + root_col_num, + offset_col_num, + root_row_num, + offset_row_num, + ); } false } diff --git a/src/structs/int16_value.rs b/src/structs/int16_value.rs index cddf7ce7..7408c272 100644 --- a/src/structs/int16_value.rs +++ b/src/structs/int16_value.rs @@ -5,11 +5,8 @@ pub struct Int16Value { } impl Int16Value { #[inline] - pub(crate) fn _get_value(&self) -> &i16 { - match &self.value { - Some(v) => v, - None => &0, - } + pub(crate) fn _get_value(&self) -> i16 { + self.value.unwrap_or(0) } #[inline] diff --git a/src/structs/int32_value.rs b/src/structs/int32_value.rs index cb8af4d7..de354323 100644 --- a/src/structs/int32_value.rs +++ b/src/structs/int32_value.rs @@ -4,11 +4,8 @@ pub struct Int32Value { } impl Int32Value { #[inline] - pub(crate) fn get_value(&self) -> &i32 { - match &self.value { - Some(v) => v, - None => &0, - } + pub(crate) fn get_value(&self) -> i32 { + self.value.unwrap_or(0) } #[inline] diff --git a/src/structs/int64_value.rs b/src/structs/int64_value.rs index 7124d2c7..424aad7e 100644 --- a/src/structs/int64_value.rs +++ b/src/structs/int64_value.rs @@ -4,11 +4,8 @@ pub struct Int64Value { } impl Int64Value { #[inline] - pub(crate) fn get_value(&self) -> &i64 { - match &self.value { - Some(v) => v, - None => &0, - } + pub(crate) fn get_value(&self) -> i64 { + self.value.unwrap_or(0) } #[inline] diff --git a/src/structs/italic.rs b/src/structs/italic.rs index 2290c706..19ae4a6d 100644 --- a/src/structs/italic.rs +++ b/src/structs/italic.rs @@ -14,7 +14,7 @@ pub struct Italic { impl Italic { #[inline] - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } @@ -37,7 +37,7 @@ impl Italic { #[inline] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // i - if *self.val.get_value() { + if self.val.get_value() { write_start_tag(writer, "i", vec![], true); } } diff --git a/src/structs/location.rs b/src/structs/location.rs index b8fc92c5..666c2c2c 100644 --- a/src/structs/location.rs +++ b/src/structs/location.rs @@ -24,7 +24,7 @@ impl Location { self } - pub fn get_first_header_row(&self) -> &u32 { + pub fn get_first_header_row(&self) -> u32 { self.first_header_row.get_value() } @@ -33,7 +33,7 @@ impl Location { self } - pub fn get_first_data_row(&self) -> &u32 { + pub fn get_first_data_row(&self) -> u32 { self.first_data_row.get_value() } @@ -42,7 +42,7 @@ impl Location { self } - pub fn get_first_data_col(&self) -> &u32 { + pub fn get_first_data_col(&self) -> u32 { self.first_data_col.get_value() } @@ -62,6 +62,7 @@ impl Location { set_string_from_xml!(self, e, first_data_col, "firstDataCol"); } + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // location write_start_tag( diff --git a/src/structs/media_object.rs b/src/structs/media_object.rs index 029f978f..9b06fb20 100644 --- a/src/structs/media_object.rs +++ b/src/structs/media_object.rs @@ -45,10 +45,10 @@ impl MediaObject { .iter() .position(|(k, v)| k == "IMAGE" && v == &*self.image_name); match find { - Some(v) => return (v + 1) as i32, + Some(v) => (v + 1) as i32, None => { rel_list.push((String::from("IMAGE"), self.image_name.to_string())); - return rel_list.len() as i32; + rel_list.len() as i32 } } } diff --git a/src/structs/member_property_index.rs b/src/structs/member_property_index.rs index 7b8996a7..2e10a692 100644 --- a/src/structs/member_property_index.rs +++ b/src/structs/member_property_index.rs @@ -13,7 +13,7 @@ pub struct MemberPropertyIndex { } impl MemberPropertyIndex { - pub fn get_val(&self) -> &i32 { + pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/merge_cells.rs b/src/structs/merge_cells.rs index a8505372..dc273528 100644 --- a/src/structs/merge_cells.rs +++ b/src/structs/merge_cells.rs @@ -33,7 +33,7 @@ impl MergeCells { self } - pub(crate) fn _has_vertical(&self, row_num: &u32) -> bool { + pub(crate) fn _has_vertical(&self, row_num: u32) -> bool { self.get_range_collection().iter().any(|range| { let start_num = range .get_coordinate_start_row() @@ -45,7 +45,7 @@ impl MergeCells { }) } - pub(crate) fn has_horizontal(&self, col_num: &u32) -> bool { + pub(crate) fn has_horizontal(&self, col_num: u32) -> bool { self.get_range_collection().iter().any(|range| { let start_num = range .get_coordinate_start_col() diff --git a/src/structs/numbering_format.rs b/src/structs/numbering_format.rs index 1ac3a0bf..6b1c276a 100644 --- a/src/structs/numbering_format.rs +++ b/src/structs/numbering_format.rs @@ -73,8 +73,8 @@ impl NumberingFormat { r#"_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)"#; #[inline] - pub fn get_number_format_id(&self) -> &u32 { - &self.number_format_id + pub fn get_number_format_id(&self) -> u32 { + self.number_format_id } pub fn set_number_format_id(&mut self, value: u32) -> &mut Self { @@ -106,7 +106,7 @@ impl NumberingFormat { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// let _ = worksheet.get_style_mut("C30") /// .get_number_format_mut() /// .set_format_code(umya_spreadsheet::NumberingFormat::FORMAT_DATE_XLSX17); @@ -137,8 +137,8 @@ impl NumberingFormat { } #[inline] - pub(crate) fn get_is_build_in(&self) -> &bool { - &self.is_build_in + pub(crate) fn get_is_build_in(&self) -> bool { + self.is_build_in } #[inline] @@ -162,7 +162,7 @@ impl NumberingFormat { self.is_build_in = false; } - pub(crate) fn write_to(&self, writer: &mut Writer>>, number_format_id: &u32) { + pub(crate) fn write_to(&self, writer: &mut Writer>>, number_format_id: u32) { // numFmt write_start_tag( writer, diff --git a/src/structs/numbering_formats.rs b/src/structs/numbering_formats.rs index 3cfdebdf..2ad99648 100644 --- a/src/structs/numbering_formats.rs +++ b/src/structs/numbering_formats.rs @@ -28,7 +28,7 @@ impl NumberingFormats { #[inline] pub(crate) fn set_numbering_format(&mut self, value: NumberingFormat) -> &mut Self { let number_format_id = value.get_number_format_id(); - self.numbering_format.insert(*number_format_id, value); + self.numbering_format.insert(number_format_id, value); self } @@ -50,8 +50,8 @@ impl NumberingFormats { pub(crate) fn set_style(&mut self, style: &Style) -> u32 { match style.get_numbering_format() { Some(v) => { - if *v.get_is_build_in() { - return *v.get_number_format_id(); + if v.get_is_build_in() { + return v.get_number_format_id(); } let hash_code = v.get_hash_code(); @@ -102,7 +102,7 @@ impl NumberingFormats { let formats_to_write: HashMap<_, _> = self .numbering_format .iter() - .filter(|(k, v)| !*v.get_is_build_in()) + .filter(|(_, v)| !v.get_is_build_in()) .collect(); if formats_to_write.is_empty() { return; @@ -114,9 +114,8 @@ impl NumberingFormats { formats_to_write .into_iter() - .enumerate() - .for_each(|(_, (index, numbering_format))| { - numbering_format.write_to(writer, index); + .for_each(|(index, numbering_format)| { + numbering_format.write_to(writer, *index); }); write_end_tag(writer, "numFmts"); diff --git a/src/structs/object_anchor.rs b/src/structs/object_anchor.rs index 64583381..6b890cb9 100644 --- a/src/structs/object_anchor.rs +++ b/src/structs/object_anchor.rs @@ -17,7 +17,7 @@ pub struct ObjectAnchor { impl ObjectAnchor { #[inline] - pub fn get_move_with_cells(&self) -> &bool { + pub fn get_move_with_cells(&self) -> bool { self.move_with_cells.get_value() } @@ -60,25 +60,25 @@ impl ObjectAnchor { } #[inline] - pub(crate) fn _adjustment_insert_row(&mut self, num_rows: &usize) { + pub(crate) fn _adjustment_insert_row(&mut self, num_rows: usize) { self.from_marker._adjustment_insert_row(num_rows); self.to_marker._adjustment_insert_row(num_rows); } #[inline] - pub(crate) fn _adjustment_insert_column(&mut self, num_cols: &usize) { + pub(crate) fn _adjustment_insert_column(&mut self, num_cols: usize) { self.from_marker._adjustment_insert_column(num_cols); self.to_marker._adjustment_insert_column(num_cols); } #[inline] - pub(crate) fn _adjustment_remove_row(&mut self, num_rows: &usize) { + pub(crate) fn _adjustment_remove_row(&mut self, num_rows: usize) { self.from_marker._adjustment_remove_row(num_rows); self.to_marker._adjustment_remove_row(num_rows); } #[inline] - pub(crate) fn _adjustment_remove_column(&mut self, num_cols: &usize) { + pub(crate) fn _adjustment_remove_column(&mut self, num_cols: usize) { self.from_marker._adjustment_remove_column(num_cols); self.to_marker._adjustment_remove_column(num_cols); } diff --git a/src/structs/office/excel/formula.rs b/src/structs/office/excel/formula.rs index 84bf66e0..5659ac96 100644 --- a/src/structs/office/excel/formula.rs +++ b/src/structs/office/excel/formula.rs @@ -1,5 +1,4 @@ // xm:f -use crate::reader::driver::*; use crate::structs::Address; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; @@ -41,16 +40,14 @@ impl Formula { Ok(Event::Text(e)) => { value = e.unescape().unwrap().to_string(); } - Ok(Event::End(ref e)) => match e.name().into_inner() { - b"xm:f" => { + Ok(Event::End(ref e)) => { + if e.name().into_inner() == b"xm:f" { let mut obj = Address::default(); obj.set_address(value); self.value = obj; - value = String::from(""); return; } - _ => (), - }, + } Ok(Event::Eof) => panic!("Error: Could not find {} end element", "xm:f"), Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e), _ => (), @@ -62,7 +59,7 @@ impl Formula { #[inline] pub(crate) fn write_to(&self, writer: &mut Writer>>) { write_start_tag(writer, "xm:f", vec![], false); - write_text_node(writer, &self.value.get_address()); + write_text_node(writer, self.value.get_address()); write_end_tag(writer, "xm:f"); } } diff --git a/src/structs/office/excel/reference_sequence.rs b/src/structs/office/excel/reference_sequence.rs index 41c96a75..8e92e0e0 100644 --- a/src/structs/office/excel/reference_sequence.rs +++ b/src/structs/office/excel/reference_sequence.rs @@ -1,6 +1,4 @@ // xm:sqref -use crate::reader::driver::*; -use crate::structs::Coordinate; use crate::structs::Range; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; @@ -73,14 +71,12 @@ impl ReferenceSequence { Ok(Event::Text(e)) => { value = e.unescape().unwrap().to_string(); } - Ok(Event::End(ref e)) => match e.name().into_inner() { - b"xm:sqref" => { + Ok(Event::End(ref e)) => { + if e.name().into_inner() == b"xm:sqref" { self.set_sqref(value); - value = String::from(""); return; } - _ => (), - }, + } Ok(Event::Eof) => panic!("Error: Could not find {} end element", "xm:sqref"), Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e), _ => (), @@ -92,7 +88,7 @@ impl ReferenceSequence { #[inline] pub(crate) fn write_to(&self, writer: &mut Writer>>) { write_start_tag(writer, "xm:sqref", vec![], false); - write_text_node(writer, &self.get_sqref()); + write_text_node(writer, self.get_sqref()); write_end_tag(writer, "xm:sqref"); } } diff --git a/src/structs/office2010/excel/data_validation.rs b/src/structs/office2010/excel/data_validation.rs index be113f6f..e525bb29 100644 --- a/src/structs/office2010/excel/data_validation.rs +++ b/src/structs/office2010/excel/data_validation.rs @@ -13,7 +13,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use std::vec; #[derive(Default, Debug, Clone)] pub struct DataValidation { @@ -52,7 +51,7 @@ impl DataValidation { } #[inline] - pub fn get_allow_blank(&self) -> &bool { + pub fn get_allow_blank(&self) -> bool { self.allow_blank.get_value() } @@ -63,7 +62,7 @@ impl DataValidation { } #[inline] - pub fn get_show_input_message(&self) -> &bool { + pub fn get_show_input_message(&self) -> bool { self.show_input_message.get_value() } @@ -74,7 +73,7 @@ impl DataValidation { } #[inline] - pub fn get_show_error_message(&self) -> &bool { + pub fn get_show_error_message(&self) -> bool { self.show_error_message.get_value() } @@ -225,10 +224,11 @@ impl DataValidation { } _ => (), }, - Ok(Event::End(ref e)) => match e.name().into_inner() { - b"x14:dataValidation" => return, - _ => (), - }, + Ok(Event::End(ref e)) => { + if e.name().into_inner() == b"x14:dataValidation" { + return; + } + } Ok(Event::Eof) => { panic!("Error: Could not find {} end element", "x14:dataValidation") } @@ -278,13 +278,11 @@ impl DataValidation { } write_start_tag(writer, "x14:dataValidation", attributes, false); - match &self.formula1 { - Some(v) => v.write_to(writer), - None => {} + if let Some(v) = &self.formula1 { + v.write_to(writer) } - match &self.formula2 { - Some(v) => v.write_to(writer), - None => {} + if let Some(v) = &self.formula2 { + v.write_to(writer) } self.reference_sequence.write_to(writer); write_end_tag(writer, "x14:dataValidation"); diff --git a/src/structs/office2010/excel/data_validation_forumla1.rs b/src/structs/office2010/excel/data_validation_forumla1.rs index 95eec429..d469f291 100644 --- a/src/structs/office2010/excel/data_validation_forumla1.rs +++ b/src/structs/office2010/excel/data_validation_forumla1.rs @@ -1,7 +1,5 @@ // x14:formula1 -use crate::reader::driver::*; use crate::structs::office::excel::Formula; -use crate::structs::Coordinate; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -38,19 +36,19 @@ impl DataValidationForumla1 { let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf) { - Ok(Event::Start(ref e)) => match e.name().into_inner() { - b"xm:f" => { + Ok(Event::Start(ref e)) => { + if e.name().into_inner() == b"xm:f" { let mut obj = Formula::default(); obj.set_attributes(reader, e); self.value = obj; return; } - _ => (), - }, - Ok(Event::End(ref e)) => match e.name().into_inner() { - b"x14:formula1" => return, - _ => (), - }, + } + Ok(Event::End(ref e)) => { + if e.name().into_inner() == b"x14:formula1" { + return; + } + } Ok(Event::Eof) => panic!("Error: Could not find {} end element", "x14:formula1"), Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e), _ => (), @@ -62,7 +60,7 @@ impl DataValidationForumla1 { #[inline] pub(crate) fn write_to(&self, writer: &mut Writer>>) { write_start_tag(writer, "x14:formula1", vec![], false); - &self.value.write_to(writer); + self.value.write_to(writer); write_end_tag(writer, "x14:formula1"); } } diff --git a/src/structs/office2010/excel/data_validation_forumla2.rs b/src/structs/office2010/excel/data_validation_forumla2.rs index 69d2c580..42a6b629 100644 --- a/src/structs/office2010/excel/data_validation_forumla2.rs +++ b/src/structs/office2010/excel/data_validation_forumla2.rs @@ -1,7 +1,5 @@ // x14:formula2 -use crate::reader::driver::*; use crate::structs::office::excel::Formula; -use crate::structs::Coordinate; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -38,19 +36,19 @@ impl DataValidationForumla2 { let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf) { - Ok(Event::Start(ref e)) => match e.name().into_inner() { - b"xm:f" => { + Ok(Event::Start(ref e)) => { + if e.name().into_inner() == b"xm:f" { let mut obj = Formula::default(); obj.set_attributes(reader, e); self.value = obj; return; } - _ => (), - }, - Ok(Event::End(ref e)) => match e.name().into_inner() { - b"x14:formula2" => return, - _ => (), - }, + } + Ok(Event::End(ref e)) => { + if e.name().into_inner() == b"x14:formula2" { + return; + } + } Ok(Event::Eof) => panic!("Error: Could not find {} end element", "x14:formula2"), Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e), _ => (), @@ -62,7 +60,7 @@ impl DataValidationForumla2 { #[inline] pub(crate) fn write_to(&self, writer: &mut Writer>>) { write_start_tag(writer, "x14:formula2", vec![], false); - &self.value.write_to(writer); + self.value.write_to(writer); write_end_tag(writer, "x14:formula2"); } } diff --git a/src/structs/office2010/excel/data_validations.rs b/src/structs/office2010/excel/data_validations.rs index e546cb33..a81370ab 100644 --- a/src/structs/office2010/excel/data_validations.rs +++ b/src/structs/office2010/excel/data_validations.rs @@ -72,9 +72,11 @@ impl DataValidations { pub(crate) fn write_to(&self, writer: &mut Writer>>) { // ext - let mut attributes: Vec<(&str, &str)> = Vec::new(); - attributes.push(("uri", "{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}")); - attributes.push(("xmlns:x14", SHEET_MS_MAIN_NS)); + let attributes = vec![ + ("uri", "{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}"), + ("xmlns:x14", SHEET_MS_MAIN_NS), + ]; + write_start_tag(writer, "ext", attributes, false); // dataValidations diff --git a/src/structs/ole_object.rs b/src/structs/ole_object.rs index 6aa90a99..11c24dff 100644 --- a/src/structs/ole_object.rs +++ b/src/structs/ole_object.rs @@ -158,7 +158,7 @@ impl OleObject { let attached_file = relationships.get_relationship_by_rid(&r_id).get_raw_file(); self.set_object_extension(attached_file.get_extension()); - self.set_object_data(attached_file.get_file_data().clone()); + self.set_object_data(attached_file.get_file_data()); } } b"objectPr" => { @@ -181,8 +181,8 @@ impl OleObject { pub(crate) fn write_to( &self, writer: &mut Writer>>, - r_id: &usize, - ole_id: &usize, + r_id: usize, + ole_id: usize, ) { // mc:AlternateContent write_start_tag( @@ -211,8 +211,7 @@ impl OleObject { write_start_tag(writer, "oleObject", attributes, false); // objectPr - self.embedded_object_properties - .write_to(writer, &(r_id + 1)); + self.embedded_object_properties.write_to(writer, r_id + 1); write_end_tag(writer, "oleObject"); diff --git a/src/structs/ole_objects.rs b/src/structs/ole_objects.rs index 83bded13..c8cc3d7c 100644 --- a/src/structs/ole_objects.rs +++ b/src/structs/ole_objects.rs @@ -58,18 +58,18 @@ impl OleObjects { pub(crate) fn write_to( &self, writer: &mut Writer>>, - r_id: &usize, - ole_id: &usize, + r_id: usize, + ole_id: usize, ) { if !self.ole_object.is_empty() { // oleObjects write_start_tag(writer, "oleObjects", vec![], false); // mc:AlternateContent - let mut r = *r_id; - let mut o = *ole_id; + let mut r = r_id; + let mut o = ole_id; for obj in &self.ole_object { - obj.write_to(writer, &r, &o); + obj.write_to(writer, r, o); r += 2; o += 1; } diff --git a/src/structs/page_margins.rs b/src/structs/page_margins.rs index 7de064ca..34a9c446 100644 --- a/src/structs/page_margins.rs +++ b/src/structs/page_margins.rs @@ -18,7 +18,7 @@ pub struct PageMargins { } impl PageMargins { #[inline] - pub fn get_left(&self) -> &f64 { + pub fn get_left(&self) -> f64 { self.left.get_value() } @@ -29,7 +29,7 @@ impl PageMargins { } #[inline] - pub fn get_right(&self) -> &f64 { + pub fn get_right(&self) -> f64 { self.right.get_value() } @@ -40,7 +40,7 @@ impl PageMargins { } #[inline] - pub fn get_top(&self) -> &f64 { + pub fn get_top(&self) -> f64 { self.top.get_value() } @@ -51,7 +51,7 @@ impl PageMargins { } #[inline] - pub fn get_bottom(&self) -> &f64 { + pub fn get_bottom(&self) -> f64 { self.bottom.get_value() } @@ -62,7 +62,7 @@ impl PageMargins { } #[inline] - pub fn get_header(&self) -> &f64 { + pub fn get_header(&self) -> f64 { self.header.get_value() } @@ -73,7 +73,7 @@ impl PageMargins { } #[inline] - pub fn get_footer(&self) -> &f64 { + pub fn get_footer(&self) -> f64 { self.footer.get_value() } diff --git a/src/structs/page_setup.rs b/src/structs/page_setup.rs index 4b6192f6..53fc3cbf 100644 --- a/src/structs/page_setup.rs +++ b/src/structs/page_setup.rs @@ -24,7 +24,7 @@ pub struct PageSetup { impl PageSetup { #[inline] - pub fn get_paper_size(&self) -> &u32 { + pub fn get_paper_size(&self) -> u32 { self.paper_size.get_value() } @@ -46,7 +46,7 @@ impl PageSetup { } #[inline] - pub fn get_scale(&self) -> &u32 { + pub fn get_scale(&self) -> u32 { self.scale.get_value() } @@ -57,7 +57,7 @@ impl PageSetup { } #[inline] - pub fn get_fit_to_height(&self) -> &u32 { + pub fn get_fit_to_height(&self) -> u32 { self.fit_to_height.get_value() } @@ -68,7 +68,7 @@ impl PageSetup { } #[inline] - pub fn get_fit_to_width(&self) -> &u32 { + pub fn get_fit_to_width(&self) -> u32 { self.fit_to_width.get_value() } @@ -79,7 +79,7 @@ impl PageSetup { } #[inline] - pub fn get_horizontal_dpi(&self) -> &u32 { + pub fn get_horizontal_dpi(&self) -> u32 { self.horizontal_dpi.get_value() } @@ -90,7 +90,7 @@ impl PageSetup { } #[inline] - pub fn get_vertical_dpi(&self) -> &u32 { + pub fn get_vertical_dpi(&self) -> u32 { self.vertical_dpi.get_value() } @@ -147,7 +147,7 @@ impl PageSetup { .unwrap() .get_relationship_by_rid(&r_id) .get_raw_file(); - self.set_object_data(attached_file.get_file_data().clone()); + self.set_object_data(attached_file.get_file_data()); } } diff --git a/src/structs/pane.rs b/src/structs/pane.rs index 56f152fa..a36f6e08 100644 --- a/src/structs/pane.rs +++ b/src/structs/pane.rs @@ -21,7 +21,7 @@ pub struct Pane { impl Pane { #[inline] - pub fn get_horizontal_split(&self) -> &f64 { + pub fn get_horizontal_split(&self) -> f64 { self.horizontal_split.get_value() } @@ -32,7 +32,7 @@ impl Pane { } #[inline] - pub fn get_vertical_split(&self) -> &f64 { + pub fn get_vertical_split(&self) -> f64 { self.vertical_split.get_value() } diff --git a/src/structs/pivot_cache_definition.rs b/src/structs/pivot_cache_definition.rs index 94d743b2..bc283120 100644 --- a/src/structs/pivot_cache_definition.rs +++ b/src/structs/pivot_cache_definition.rs @@ -50,7 +50,7 @@ impl PivotCacheDefinition { } #[inline] - pub fn get_refreshed_date(&self) -> &f64 { + pub fn get_refreshed_date(&self) -> f64 { self.refreshed_date.get_value() } @@ -61,7 +61,7 @@ impl PivotCacheDefinition { } #[inline] - pub fn get_created_version(&self) -> &u8 { + pub fn get_created_version(&self) -> u8 { self.created_version.get_value() } @@ -72,7 +72,7 @@ impl PivotCacheDefinition { } #[inline] - pub fn get_refreshed_version(&self) -> &u8 { + pub fn get_refreshed_version(&self) -> u8 { self.refreshed_version.get_value() } @@ -83,7 +83,7 @@ impl PivotCacheDefinition { } #[inline] - pub fn get_min_refreshable_version(&self) -> &u8 { + pub fn get_min_refreshable_version(&self) -> u8 { self.min_refreshable_version.get_value() } @@ -94,7 +94,7 @@ impl PivotCacheDefinition { } #[inline] - pub fn get_record_count(&self) -> &u32 { + pub fn get_record_count(&self) -> u32 { self.record_count.get_value() } @@ -137,6 +137,7 @@ impl PivotCacheDefinition { } #[inline] + #[allow(dead_code)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -181,14 +182,16 @@ impl PivotCacheDefinition { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // pivotTableDefinition - let mut attributes: Vec<(&str, &str)> = Vec::new(); - attributes.push(("xmlns", SHEET_MAIN_NS)); - attributes.push(("xmlns:r", REL_OFC_NS)); - attributes.push(("xmlns:mc", MC_NS)); - attributes.push(("mc:Ignorable", "xr")); - attributes.push(("xmlns:xr", SHEET_MS_REVISION_NS)); + let mut attributes = vec![ + ("xmlns", SHEET_MAIN_NS), + ("xmlns:r", REL_OFC_NS), + ("xmlns:mc", MC_NS), + ("mc:Ignorable", "xr"), + ("xmlns:xr", SHEET_MS_REVISION_NS), + ]; if self.id.has_value() { attributes.push(("r:id", self.id.get_value_str())); diff --git a/src/structs/pivot_field.rs b/src/structs/pivot_field.rs index 8d17bfb6..c8ac08de 100644 --- a/src/structs/pivot_field.rs +++ b/src/structs/pivot_field.rs @@ -1,12 +1,8 @@ // pivotField use crate::reader::driver::*; use crate::structs::BooleanValue; -use crate::structs::ByteValue; -use crate::structs::Location; -use crate::structs::StringValue; -use crate::structs::UInt32Value; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -18,7 +14,7 @@ pub struct PivotField { } impl PivotField { #[inline] - pub fn get_data_field(&self) -> &bool { + pub fn get_data_field(&self) -> bool { self.data_field.get_value() } @@ -29,7 +25,7 @@ impl PivotField { } #[inline] - pub fn get_show_all(&self) -> &bool { + pub fn get_show_all(&self) -> bool { self.show_all.get_value() } @@ -50,6 +46,7 @@ impl PivotField { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // pivotField write_start_tag( diff --git a/src/structs/pivot_fields.rs b/src/structs/pivot_fields.rs index 81ce8e6f..9ba6006f 100644 --- a/src/structs/pivot_fields.rs +++ b/src/structs/pivot_fields.rs @@ -1,10 +1,6 @@ // pivotFields use crate::reader::driver::*; -use crate::structs::BooleanValue; -use crate::structs::ByteValue; use crate::structs::PivotField; -use crate::structs::StringValue; -use crate::structs::UInt32Value; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -34,6 +30,7 @@ impl PivotFields { } #[inline] + #[allow(unused_variables)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -58,6 +55,7 @@ impl PivotFields { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // pivotFields write_start_tag( diff --git a/src/structs/pivot_table.rs b/src/structs/pivot_table.rs index ee8bb276..b7db294e 100644 --- a/src/structs/pivot_table.rs +++ b/src/structs/pivot_table.rs @@ -1,12 +1,5 @@ -use super::SheetView; -use crate::reader::driver::*; use crate::structs::PivotCacheDefinition; use crate::structs::PivotTableDefinition; -use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; -use quick_xml::Reader; -use quick_xml::Writer; -use std::io::Cursor; #[derive(Clone, Default, Debug)] pub struct PivotTable { diff --git a/src/structs/pivot_table_definition.rs b/src/structs/pivot_table_definition.rs index d732e73e..2a70284d 100644 --- a/src/structs/pivot_table_definition.rs +++ b/src/structs/pivot_table_definition.rs @@ -49,7 +49,7 @@ pub struct PivotTableDefinition { } impl PivotTableDefinition { #[inline] - pub fn get_apply_number_formats(&self) -> &bool { + pub fn get_apply_number_formats(&self) -> bool { self.apply_number_formats.get_value() } @@ -60,7 +60,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_apply_border_formats(&self) -> &bool { + pub fn get_apply_border_formats(&self) -> bool { self.apply_border_formats.get_value() } @@ -71,7 +71,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_apply_font_formats(&self) -> &bool { + pub fn get_apply_font_formats(&self) -> bool { self.apply_font_formats.get_value() } @@ -82,7 +82,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_apply_pattern_formats(&self) -> &bool { + pub fn get_apply_pattern_formats(&self) -> bool { self.apply_pattern_formats.get_value() } @@ -93,7 +93,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_apply_alignment_formats(&self) -> &bool { + pub fn get_apply_alignment_formats(&self) -> bool { self.apply_alignment_formats.get_value() } @@ -104,7 +104,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_apply_width_height_formats(&self) -> &bool { + pub fn get_apply_width_height_formats(&self) -> bool { self.apply_width_height_formats.get_value() } @@ -115,7 +115,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_use_auto_formatting(&self) -> &bool { + pub fn get_use_auto_formatting(&self) -> bool { self.use_auto_formatting.get_value() } @@ -126,7 +126,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_item_print_titles(&self) -> &bool { + pub fn get_item_print_titles(&self) -> bool { self.item_print_titles.get_value() } @@ -137,7 +137,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_outline(&self) -> &bool { + pub fn get_outline(&self) -> bool { self.outline.get_value() } @@ -148,7 +148,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_outline_data(&self) -> &bool { + pub fn get_outline_data(&self) -> bool { self.outline_data.get_value() } @@ -159,7 +159,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_multiple_field_filters(&self) -> &bool { + pub fn get_multiple_field_filters(&self) -> bool { self.multiple_field_filters.get_value() } @@ -181,7 +181,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_cache_id(&self) -> &u32 { + pub fn get_cache_id(&self) -> u32 { self.cache_id.get_value() } @@ -192,7 +192,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_indent(&self) -> &u32 { + pub fn get_indent(&self) -> u32 { self.indent.get_value() } @@ -225,7 +225,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_updated_version(&self) -> &u8 { + pub fn get_updated_version(&self) -> u8 { self.updated_version.get_value() } @@ -236,7 +236,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_min_refreshable_version(&self) -> &u8 { + pub fn get_min_refreshable_version(&self) -> u8 { self.min_refreshable_version.get_value() } @@ -247,7 +247,7 @@ impl PivotTableDefinition { } #[inline] - pub fn get_created_version(&self) -> &u8 { + pub fn get_created_version(&self) -> u8 { self.created_version.get_value() } @@ -450,13 +450,16 @@ impl PivotTableDefinition { } #[inline] + #[allow(dead_code)] pub(crate) fn write_to(&self, writer: &mut Writer>>) { // pivotTableDefinition - let mut attributes: Vec<(&str, &str)> = Vec::new(); - attributes.push(("xmlns", SHEET_MAIN_NS)); - attributes.push(("xmlns:mc", MC_NS)); - attributes.push(("mc:Ignorable", "xr")); - attributes.push(("xmlns:xr", SHEET_MS_REVISION_NS)); + let mut attributes = vec![ + ("xmlns", SHEET_MAIN_NS), + ("xmlns:mc", MC_NS), + ("mc:Ignorable", "xr"), + ("xmlns:xr", SHEET_MS_REVISION_NS), + ]; + if self.name.has_value() { attributes.push(("name", self.name.get_value_str())); } diff --git a/src/structs/pivot_table_style.rs b/src/structs/pivot_table_style.rs index a0931c47..db538428 100644 --- a/src/structs/pivot_table_style.rs +++ b/src/structs/pivot_table_style.rs @@ -1,12 +1,9 @@ // pivotTableStyleInfo use crate::reader::driver::*; use crate::structs::BooleanValue; -use crate::structs::ByteValue; -use crate::structs::Location; use crate::structs::StringValue; -use crate::structs::UInt32Value; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -23,17 +20,18 @@ pub struct PivotTableStyle { impl PivotTableStyle { #[inline] pub fn get_name(&self) -> &str { - &self.name.get_value_str() + self.name.get_value_str() } #[inline] + #[allow(dead_code)] pub(crate) fn set_name>(&mut self, value: S) -> &mut Self { self.name.set_value(value); self } #[inline] - pub fn get_show_row_headers(&self) -> &bool { + pub fn get_show_row_headers(&self) -> bool { self.show_row_headers.get_value() } @@ -44,7 +42,7 @@ impl PivotTableStyle { } #[inline] - pub fn get_show_column_headers(&self) -> &bool { + pub fn get_show_column_headers(&self) -> bool { self.show_column_headers.get_value() } @@ -55,7 +53,7 @@ impl PivotTableStyle { } #[inline] - pub fn get_show_row_stripes(&self) -> &bool { + pub fn get_show_row_stripes(&self) -> bool { self.show_row_stripes.get_value() } @@ -66,7 +64,7 @@ impl PivotTableStyle { } #[inline] - pub fn get_show_column_stripes(&self) -> &bool { + pub fn get_show_column_stripes(&self) -> bool { self.show_column_stripes.get_value() } @@ -77,7 +75,7 @@ impl PivotTableStyle { } #[inline] - pub fn get_show_last_column(&self) -> &bool { + pub fn get_show_last_column(&self) -> bool { self.show_last_column.get_value() } diff --git a/src/structs/print_options.rs b/src/structs/print_options.rs index 08a4de67..8a97159e 100644 --- a/src/structs/print_options.rs +++ b/src/structs/print_options.rs @@ -14,7 +14,7 @@ pub struct PrintOptions { impl PrintOptions { #[inline] - pub fn get_horizontal_centered(&self) -> &bool { + pub fn get_horizontal_centered(&self) -> bool { self.horizontal_centered.get_value() } @@ -25,7 +25,7 @@ impl PrintOptions { } #[inline] - pub fn get_vertical_centered(&self) -> &bool { + pub fn get_vertical_centered(&self) -> bool { self.vertical_centered.get_value() } diff --git a/src/structs/properties.rs b/src/structs/properties.rs index 3b66334f..d43a0ef0 100644 --- a/src/structs/properties.rs +++ b/src/structs/properties.rs @@ -8,7 +8,6 @@ use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; use quick_xml::Writer; -use std::borrow::Cow; use std::io::Cursor; #[derive(Clone, Debug)] @@ -56,7 +55,7 @@ impl Default for Properties { impl Properties { #[inline] pub fn get_creator(&self) -> &str { - &self.creator.get_value_str() + self.creator.get_value_str() } #[inline] @@ -67,7 +66,7 @@ impl Properties { #[inline] pub fn get_last_modified_by(&self) -> &str { - &self.last_modified_by.get_value_str() + self.last_modified_by.get_value_str() } #[inline] @@ -78,7 +77,7 @@ impl Properties { #[inline] pub fn get_created(&self) -> &str { - &self.created.get_value_str() + self.created.get_value_str() } #[inline] @@ -89,7 +88,7 @@ impl Properties { #[inline] pub fn get_modified(&self) -> &str { - &self.modified.get_value_str() + self.modified.get_value_str() } #[inline] @@ -100,7 +99,7 @@ impl Properties { #[inline] pub fn get_title(&self) -> &str { - &self.title.get_value_str() + self.title.get_value_str() } #[inline] @@ -111,7 +110,7 @@ impl Properties { #[inline] pub fn get_description(&self) -> &str { - &self.description.get_value_str() + self.description.get_value_str() } #[inline] @@ -122,7 +121,7 @@ impl Properties { #[inline] pub fn get_subject(&self) -> &str { - &self.subject.get_value_str() + self.subject.get_value_str() } #[inline] @@ -133,7 +132,7 @@ impl Properties { #[inline] pub fn get_keywords(&self) -> &str { - &self.keywords.get_value_str() + self.keywords.get_value_str() } #[inline] @@ -144,7 +143,7 @@ impl Properties { #[inline] pub fn get_revision(&self) -> &str { - &self.revision.get_value_str() + self.revision.get_value_str() } #[inline] @@ -155,7 +154,7 @@ impl Properties { #[inline] pub fn get_category(&self) -> &str { - &self.category.get_value_str() + self.category.get_value_str() } #[inline] @@ -166,7 +165,7 @@ impl Properties { #[inline] pub fn get_version(&self) -> &str { - &self.version.get_value_str() + self.version.get_value_str() } #[inline] @@ -177,7 +176,7 @@ impl Properties { #[inline] pub fn get_manager(&self) -> &str { - &self.manager.get_value_str() + self.manager.get_value_str() } #[inline] @@ -188,7 +187,7 @@ impl Properties { #[inline] pub fn get_company(&self) -> &str { - &self.company.get_value_str() + self.company.get_value_str() } #[inline] diff --git a/src/structs/protection.rs b/src/structs/protection.rs index 3b06132a..400d221f 100644 --- a/src/structs/protection.rs +++ b/src/structs/protection.rs @@ -16,7 +16,7 @@ pub struct Protection { impl Protection { #[inline] - pub fn get_locked(&self) -> &bool { + pub fn get_locked(&self) -> bool { self.locked.get_value() } @@ -26,7 +26,7 @@ impl Protection { } #[inline] - pub fn get_hidden(&mut self) -> &bool { + pub fn get_hidden(&mut self) -> bool { self.hidden.get_value() } @@ -36,6 +36,7 @@ impl Protection { } #[inline] + #[allow(dead_code)] pub(crate) fn get_hash_code(&self) -> String { format!( "{:x}", diff --git a/src/structs/range.rs b/src/structs/range.rs index 706af158..0e351845 100644 --- a/src/structs/range.rs +++ b/src/structs/range.rs @@ -139,10 +139,10 @@ impl AdjustmentCoordinate for Range { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if let Some(v) = &mut self.start_col { v.adjustment_insert_value(root_col_num, offset_col_num); @@ -161,10 +161,10 @@ impl AdjustmentCoordinate for Range { #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { if let Some(v) = &mut self.start_col { v.adjustment_remove_value(root_col_num, offset_col_num); @@ -183,10 +183,10 @@ impl AdjustmentCoordinate for Range { #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { let start_col_result = match &self.start_col { Some(v) => v.is_remove_value(root_col_num, offset_col_num), diff --git a/src/structs/raw/raw_relationships.rs b/src/structs/raw/raw_relationships.rs index 49a52e78..a4be7e2a 100644 --- a/src/structs/raw/raw_relationships.rs +++ b/src/structs/raw/raw_relationships.rs @@ -111,11 +111,13 @@ impl RawRelationships { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // relationships diff --git a/src/structs/raw/raw_worksheet.rs b/src/structs/raw/raw_worksheet.rs index e7c758c9..978bd79a 100644 --- a/src/structs/raw/raw_worksheet.rs +++ b/src/structs/raw/raw_worksheet.rs @@ -93,7 +93,7 @@ impl RawWorksheet { pub(crate) fn write( &self, - sheet_no: &i32, + sheet_no: i32, writer_mng: &mut WriterManager, ) -> Result<(), XlsxError> { // Add worksheet diff --git a/src/structs/rich_text.rs b/src/structs/rich_text.rs index bcee0518..75012cfb 100644 --- a/src/structs/rich_text.rs +++ b/src/structs/rich_text.rs @@ -59,7 +59,7 @@ impl RichText { pub(crate) fn get_hash_code(&self) -> String { let mut value = String::from(""); for ele in &self.rich_text_elements { - write!(value, "{}", ele.get_hash_code()); + write!(value, "{}", ele.get_hash_code()).unwrap(); } format!("{:x}", md5::Md5::digest(&value)) } diff --git a/src/structs/row.rs b/src/structs/row.rs index 16ad98fc..e04be53c 100644 --- a/src/structs/row.rs +++ b/src/structs/row.rs @@ -42,7 +42,7 @@ impl Default for Row { } impl Row { #[inline] - pub fn get_row_num(&self) -> &u32 { + pub fn get_row_num(&self) -> u32 { self.row_num.get_value() } @@ -53,7 +53,7 @@ impl Row { } #[inline] - pub fn get_height(&self) -> &f64 { + pub fn get_height(&self) -> f64 { self.height.get_value() } @@ -65,7 +65,7 @@ impl Row { } #[inline] - pub fn get_descent(&self) -> &f64 { + pub fn get_descent(&self) -> f64 { self.descent.get_value() } @@ -76,7 +76,7 @@ impl Row { } #[inline] - pub fn get_thick_bot(&self) -> &bool { + pub fn get_thick_bot(&self) -> bool { self.thick_bot.get_value() } @@ -87,7 +87,7 @@ impl Row { } #[inline] - pub fn get_custom_height(&self) -> &bool { + pub fn get_custom_height(&self) -> bool { self.custom_height.get_value() } @@ -98,7 +98,7 @@ impl Row { } #[inline] - pub fn get_hidden(&self) -> &bool { + pub fn get_hidden(&self) -> bool { self.hidden.get_value() } @@ -126,9 +126,10 @@ impl Row { #[inline] pub(crate) fn has_style(&self) -> bool { - &*self.style != &Style::default() + *self.style != Style::default() } + #[allow(clippy::too_many_arguments)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, @@ -203,19 +204,19 @@ impl Row { attributes.push(("spans", &spans)); } let height = self.height.get_value_string(); - if self.height.get_value() != &0f64 { + if self.height.get_value() != 0f64 { attributes.push(("ht", &height)); } - if *self.thick_bot.get_value() { + if self.thick_bot.get_value() { attributes.push(("thickBot", self.thick_bot.get_value_string())); } - if *self.custom_height.get_value() { + if self.custom_height.get_value() { attributes.push(("customHeight", self.custom_height.get_value_string())); } if xf_index > 0 { attributes.push(("customFormat", "1")); } - if *self.hidden.get_value() { + if self.hidden.get_value() { attributes.push(("hidden", self.hidden.get_value_string())); } let descent = self.descent.get_value_string(); @@ -233,7 +234,7 @@ impl Row { } impl AdjustmentValue for Row { #[inline] - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { if self.row_num.get_value() >= root_num { self.row_num .set_value(self.row_num.get_value() + offset_num); @@ -241,7 +242,7 @@ impl AdjustmentValue for Row { } #[inline] - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { if self.row_num.get_value() >= root_num { self.row_num .set_value(self.row_num.get_value() - offset_num); @@ -249,8 +250,7 @@ impl AdjustmentValue for Row { } #[inline] - fn is_remove_value(&self, root_num: &u32, offset_num: &u32) -> bool { - self.row_num.get_value() >= root_num - && self.row_num.get_value() <= &(root_num + offset_num - 1) + fn is_remove_value(&self, root_num: u32, offset_num: u32) -> bool { + self.row_num.get_value() >= root_num && self.row_num.get_value() < root_num + offset_num } } diff --git a/src/structs/row_breaks.rs b/src/structs/row_breaks.rs index 46e9de17..e556268c 100644 --- a/src/structs/row_breaks.rs +++ b/src/structs/row_breaks.rs @@ -67,7 +67,7 @@ impl RowBreaks { let mut manual_count = 0; for obj in self.get_break_list() { count += 1; - if *obj.get_manual_page_break() { + if obj.get_manual_page_break() { manual_count += 1; } } diff --git a/src/structs/row_item.rs b/src/structs/row_item.rs index e302586d..f7bdbaa7 100644 --- a/src/structs/row_item.rs +++ b/src/structs/row_item.rs @@ -19,7 +19,7 @@ pub struct RowItem { } impl RowItem { #[inline] - pub fn get_index(&self) -> &u32 { + pub fn get_index(&self) -> u32 { self.index.get_value() } @@ -41,7 +41,7 @@ impl RowItem { } #[inline] - pub fn get_repeated_item_count(&self) -> &u32 { + pub fn get_repeated_item_count(&self) -> u32 { self.repeated_item_count.get_value() } @@ -117,7 +117,7 @@ impl RowItem { attributes.push(("r", repeated_item_count_str.as_str())); } write_start_tag(writer, "i", attributes, empty_flg); - if empty_flg == false { + if !empty_flg { if let Some(v) = &self.member_property_index { v.write_to(writer); } diff --git a/src/structs/row_items.rs b/src/structs/row_items.rs index 22142cb7..4c107c0e 100644 --- a/src/structs/row_items.rs +++ b/src/structs/row_items.rs @@ -1,10 +1,6 @@ // rowItems use crate::reader::driver::*; -use crate::structs::BooleanValue; -use crate::structs::ByteValue; use crate::structs::RowItem; -use crate::structs::StringValue; -use crate::structs::UInt32Value; use crate::writer::driver::*; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -34,6 +30,7 @@ impl RowItems { } #[inline] + #[allow(unused_variables)] pub(crate) fn set_attributes( &mut self, reader: &mut Reader, diff --git a/src/structs/row_reference.rs b/src/structs/row_reference.rs index 0718ba0e..21da3d6f 100644 --- a/src/structs/row_reference.rs +++ b/src/structs/row_reference.rs @@ -19,8 +19,8 @@ impl Default for RowReference { impl RowReference { #[inline] - pub fn get_num(&self) -> &u32 { - &self.num + pub fn get_num(&self) -> u32 { + self.num } #[inline] @@ -53,8 +53,8 @@ impl RowReference { } #[inline] - pub fn get_is_lock(&self) -> &bool { - &self.is_lock + pub fn get_is_lock(&self) -> bool { + self.is_lock } #[inline] @@ -76,17 +76,17 @@ impl RowReference { } impl AdjustmentValue for RowReference { #[inline] - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { - self.num = adjustment_insert_coordinate(&self.num, root_num, offset_num); + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { + self.num = adjustment_insert_coordinate(self.num, root_num, offset_num); } #[inline] - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { - self.num = adjustment_remove_coordinate(&self.num, root_num, offset_num); + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { + self.num = adjustment_remove_coordinate(self.num, root_num, offset_num); } #[inline] - fn is_remove_value(&self, root_num: &u32, offset_num: &u32) -> bool { - is_remove_coordinate(&self.num, root_num, offset_num) + fn is_remove_value(&self, root_num: u32, offset_num: u32) -> bool { + is_remove_coordinate(self.num, root_num, offset_num) } } diff --git a/src/structs/rows.rs b/src/structs/rows.rs index e74e9885..b2625e7b 100644 --- a/src/structs/rows.rs +++ b/src/structs/rows.rs @@ -37,16 +37,16 @@ impl Rows { /// Get Row Dimension. #[inline] - pub(crate) fn get_row_dimension(&self, row: &u32) -> Option<&Row> { - self.rows.get(row).map(Box::as_ref) + pub(crate) fn get_row_dimension(&self, row: u32) -> Option<&Row> { + self.rows.get(&row).map(Box::as_ref) } /// Get Row Dimension in mutable. #[inline] - pub(crate) fn get_row_dimension_mut(&mut self, row: &u32) -> &mut Row { + pub(crate) fn get_row_dimension_mut(&mut self, row: u32) -> &mut Row { self.rows.entry(row.to_owned()).or_insert_with(|| { let mut obj = Row::default(); - obj.set_row_num(*row); + obj.set_row_num(row); Box::new(obj) }) } @@ -65,19 +65,19 @@ impl Rows { self.rows = self .get_row_dimensions_to_hashmap_mut() .iter_mut() - .map(|(_, row)| (*row.get_row_num(), std::mem::take(row))) + .map(|(_, row)| (row.get_row_num(), std::mem::take(row))) .collect(); } } impl AdjustmentValue for Rows { - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { for row_dimension in self.get_row_dimensions_mut() { row_dimension.adjustment_insert_value(root_num, offset_num); } self.rebuild_map(); } - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { self.get_row_dimensions_to_hashmap_mut() .retain(|_, k| !(k.is_remove_value(root_num, offset_num))); for row_dimension in self.get_row_dimensions_mut() { diff --git a/src/structs/s_byte_value.rs b/src/structs/s_byte_value.rs index cbcc9acb..d5b9c495 100644 --- a/src/structs/s_byte_value.rs +++ b/src/structs/s_byte_value.rs @@ -4,8 +4,8 @@ pub struct SByteValue { } impl SByteValue { #[inline] - pub(crate) fn get_value(&self) -> &i8 { - self.value.as_ref().unwrap_or(&0) + pub(crate) fn get_value(&self) -> i8 { + self.value.unwrap_or(0) } #[inline] diff --git a/src/structs/sequence_of_references.rs b/src/structs/sequence_of_references.rs index 42842797..093b46d5 100644 --- a/src/structs/sequence_of_references.rs +++ b/src/structs/sequence_of_references.rs @@ -57,10 +57,10 @@ impl SequenceOfReferences { impl AdjustmentCoordinate for SequenceOfReferences { fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for range in &mut self.range_collection { range.adjustment_insert_coordinate( @@ -74,10 +74,10 @@ impl AdjustmentCoordinate for SequenceOfReferences { fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { for range in &mut self.range_collection { range.adjustment_remove_coordinate( @@ -91,10 +91,10 @@ impl AdjustmentCoordinate for SequenceOfReferences { fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { for range in &self.range_collection { if range.is_remove_coordinate( diff --git a/src/structs/shared_items.rs b/src/structs/shared_items.rs index 995e0d77..3825b43d 100644 --- a/src/structs/shared_items.rs +++ b/src/structs/shared_items.rs @@ -3,7 +3,7 @@ use crate::reader::driver::*; use crate::structs::BooleanValue; use crate::structs::DoubleValue; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -18,7 +18,7 @@ pub struct SharedItems { max_value: DoubleValue, } impl SharedItems { - pub fn get_contains_semi_mixed_types(&self) -> &bool { + pub fn get_contains_semi_mixed_types(&self) -> bool { self.contains_semi_mixed_types.get_value() } @@ -27,7 +27,7 @@ impl SharedItems { self } - pub fn get_contains_string(&self) -> &bool { + pub fn get_contains_string(&self) -> bool { self.contains_string.get_value() } @@ -36,7 +36,7 @@ impl SharedItems { self } - pub fn get_contains_number(&self) -> &bool { + pub fn get_contains_number(&self) -> bool { self.contains_number.get_value() } @@ -45,7 +45,7 @@ impl SharedItems { self } - pub fn get_contains_integer(&self) -> &bool { + pub fn get_contains_integer(&self) -> bool { self.contains_integer.get_value() } @@ -54,7 +54,7 @@ impl SharedItems { self } - pub fn get_min_value(&self) -> &f64 { + pub fn get_min_value(&self) -> f64 { self.min_value.get_value() } @@ -63,7 +63,7 @@ impl SharedItems { self } - pub fn get_max_value(&self) -> &f64 { + pub fn get_max_value(&self) -> f64 { self.max_value.get_value() } diff --git a/src/structs/shared_string_item.rs b/src/structs/shared_string_item.rs index e887090d..fcaa6b26 100644 --- a/src/structs/shared_string_item.rs +++ b/src/structs/shared_string_item.rs @@ -5,7 +5,6 @@ use super::Text; use super::TextElement; use crate::reader::driver::*; use crate::writer::driver::*; -use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -49,6 +48,7 @@ impl SharedStringItem { } #[inline] + #[allow(dead_code)] pub(crate) fn get_rich_text_mut(&mut self) -> Option<&mut RichText> { self.rich_text.as_mut() } diff --git a/src/structs/shared_string_table.rs b/src/structs/shared_string_table.rs index e9131646..bb9a9058 100644 --- a/src/structs/shared_string_table.rs +++ b/src/structs/shared_string_table.rs @@ -1,8 +1,6 @@ // sst -use super::drawing::Theme; use super::CellValue; use super::SharedStringItem; -use crate::drawing::charts::View3D; use crate::helper::const_str::*; use crate::reader::driver::*; use crate::writer::driver::*; @@ -27,6 +25,7 @@ impl SharedStringTable { } #[inline] + #[allow(dead_code)] pub(crate) fn get_shared_string_item_mut(&mut self) -> &mut ThinVec { &mut self.shared_string_item } diff --git a/src/structs/sheet_format_properties.rs b/src/structs/sheet_format_properties.rs index 90059a7a..df8dc879 100644 --- a/src/structs/sheet_format_properties.rs +++ b/src/structs/sheet_format_properties.rs @@ -25,7 +25,7 @@ pub struct SheetFormatProperties { impl SheetFormatProperties { #[inline] - pub fn get_base_column_width(&self) -> &u32 { + pub fn get_base_column_width(&self) -> u32 { self.base_column_width.get_value() } @@ -36,7 +36,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_custom_height(&self) -> &bool { + pub fn get_custom_height(&self) -> bool { self.custom_height.get_value() } @@ -47,7 +47,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_default_column_width(&self) -> &f64 { + pub fn get_default_column_width(&self) -> f64 { self.default_column_width.get_value() } @@ -58,7 +58,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_default_row_height(&self) -> &f64 { + pub fn get_default_row_height(&self) -> f64 { self.default_row_height.get_value() } @@ -69,7 +69,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_dy_descent(&self) -> &f64 { + pub fn get_dy_descent(&self) -> f64 { self.dy_descent.get_value() } @@ -80,7 +80,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_outline_level_column(&self) -> &u8 { + pub fn get_outline_level_column(&self) -> u8 { self.outline_level_column.get_value() } @@ -91,7 +91,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_outline_level_row(&self) -> &u8 { + pub fn get_outline_level_row(&self) -> u8 { self.outline_level_row.get_value() } @@ -102,7 +102,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_thick_bottom(&self) -> &bool { + pub fn get_thick_bottom(&self) -> bool { self.thick_bottom.get_value() } @@ -113,7 +113,7 @@ impl SheetFormatProperties { } #[inline] - pub fn get_thick_top(&self) -> &bool { + pub fn get_thick_top(&self) -> bool { self.thick_top.get_value() } @@ -156,7 +156,7 @@ impl SheetFormatProperties { let str_custom_height = self.custom_height.get_value_string(); if self.custom_height.has_value() { - attributes.push(("customHeight", &str_custom_height)); + attributes.push(("customHeight", str_custom_height)); } let str_default_column_width = self.default_column_width.get_value_string(); @@ -186,12 +186,12 @@ impl SheetFormatProperties { let str_thick_bottom = self.thick_bottom.get_value_string(); if self.thick_bottom.has_value() { - attributes.push(("thickBottom", &str_thick_bottom)); + attributes.push(("thickBottom", str_thick_bottom)); } let str_thick_top = self.thick_top.get_value_string(); if self.thick_top.has_value() { - attributes.push(("thickTop", &str_thick_top)); + attributes.push(("thickTop", str_thick_top)); } write_start_tag(writer, "sheetFormatPr", attributes, true); diff --git a/src/structs/sheet_protection.rs b/src/structs/sheet_protection.rs index 8faf3e8c..223864f3 100644 --- a/src/structs/sheet_protection.rs +++ b/src/structs/sheet_protection.rs @@ -5,8 +5,7 @@ use super::UInt32Value; use crate::helper::crypt::*; use crate::reader::driver::*; use crate::writer::driver::*; -use md5::Digest; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -70,7 +69,7 @@ impl SheetProtection { } #[inline] - pub fn get_spin_count(&self) -> &u32 { + pub fn get_spin_count(&self) -> u32 { self.spin_count.get_value() } @@ -98,7 +97,7 @@ impl SheetProtection { } #[inline] - pub fn get_sheet(&self) -> &bool { + pub fn get_sheet(&self) -> bool { self.sheet.get_value() } @@ -109,7 +108,7 @@ impl SheetProtection { } #[inline] - pub fn get_objects(&self) -> &bool { + pub fn get_objects(&self) -> bool { self.objects.get_value() } @@ -120,7 +119,7 @@ impl SheetProtection { } #[inline] - pub fn get_delete_rows(&self) -> &bool { + pub fn get_delete_rows(&self) -> bool { self.delete_rows.get_value() } @@ -131,7 +130,7 @@ impl SheetProtection { } #[inline] - pub fn get_insert_columns(&self) -> &bool { + pub fn get_insert_columns(&self) -> bool { self.insert_columns.get_value() } @@ -142,7 +141,7 @@ impl SheetProtection { } #[inline] - pub fn get_delete_columns(&self) -> &bool { + pub fn get_delete_columns(&self) -> bool { self.delete_columns.get_value() } @@ -153,7 +152,7 @@ impl SheetProtection { } #[inline] - pub fn get_insert_hyperlinks(&self) -> &bool { + pub fn get_insert_hyperlinks(&self) -> bool { self.insert_hyperlinks.get_value() } @@ -164,7 +163,7 @@ impl SheetProtection { } #[inline] - pub fn get_auto_filter(&self) -> &bool { + pub fn get_auto_filter(&self) -> bool { self.auto_filter.get_value() } @@ -175,7 +174,7 @@ impl SheetProtection { } #[inline] - pub fn get_scenarios(&self) -> &bool { + pub fn get_scenarios(&self) -> bool { self.scenarios.get_value() } @@ -186,7 +185,7 @@ impl SheetProtection { } #[inline] - pub fn get_format_cells(&self) -> &bool { + pub fn get_format_cells(&self) -> bool { self.format_cells.get_value() } @@ -197,7 +196,7 @@ impl SheetProtection { } #[inline] - pub fn get_format_columns(&self) -> &bool { + pub fn get_format_columns(&self) -> bool { self.format_columns.get_value() } @@ -208,7 +207,7 @@ impl SheetProtection { } #[inline] - pub fn get_insert_rows(&self) -> &bool { + pub fn get_insert_rows(&self) -> bool { self.insert_rows.get_value() } @@ -219,7 +218,7 @@ impl SheetProtection { } #[inline] - pub fn get_format_rows(&self) -> &bool { + pub fn get_format_rows(&self) -> bool { self.format_rows.get_value() } @@ -230,7 +229,7 @@ impl SheetProtection { } #[inline] - pub fn get_pivot_tables(&self) -> &bool { + pub fn get_pivot_tables(&self) -> bool { self.pivot_tables.get_value() } @@ -241,7 +240,7 @@ impl SheetProtection { } #[inline] - pub fn get_select_locked_cells(&self) -> &bool { + pub fn get_select_locked_cells(&self) -> bool { self.select_locked_cells.get_value() } @@ -252,7 +251,7 @@ impl SheetProtection { } #[inline] - pub fn get_select_unlocked_cells(&self) -> &bool { + pub fn get_select_unlocked_cells(&self) -> bool { self.select_unlocked_cells.get_value() } @@ -263,7 +262,7 @@ impl SheetProtection { } #[inline] - pub fn get_sort(&self) -> &bool { + pub fn get_sort(&self) -> bool { self.sort.get_value() } diff --git a/src/structs/sheet_view.rs b/src/structs/sheet_view.rs index b76495b7..5646a349 100644 --- a/src/structs/sheet_view.rs +++ b/src/structs/sheet_view.rs @@ -31,7 +31,7 @@ pub struct SheetView { impl SheetView { #[inline] - pub fn get_show_grid_lines(&self) -> &bool { + pub fn get_show_grid_lines(&self) -> bool { self.show_grid_lines.get_value() } @@ -42,7 +42,7 @@ impl SheetView { } #[inline] - pub fn get_tab_selected(&self) -> &bool { + pub fn get_tab_selected(&self) -> bool { self.tab_selected.get_value() } @@ -53,7 +53,7 @@ impl SheetView { } #[inline] - pub fn get_workbook_view_id(&self) -> &u32 { + pub fn get_workbook_view_id(&self) -> u32 { self.workbook_view_id.get_value() } @@ -91,7 +91,7 @@ impl SheetView { } #[inline] - pub fn get_zoom_scale(&self) -> &u32 { + pub fn get_zoom_scale(&self) -> u32 { self.zoom_scale.get_value() } @@ -102,7 +102,7 @@ impl SheetView { } #[inline] - pub fn get_zoom_scale_normal(&self) -> &u32 { + pub fn get_zoom_scale_normal(&self) -> u32 { self.zoom_scale_normal.get_value() } @@ -113,7 +113,7 @@ impl SheetView { } #[inline] - pub fn get_zoom_scale_page_layout_view(&self) -> &u32 { + pub fn get_zoom_scale_page_layout_view(&self) -> u32 { self.zoom_scale_page_layout_view.get_value() } @@ -124,7 +124,7 @@ impl SheetView { } #[inline] - pub fn get_zoom_scale_sheet_layout_view(&self) -> &u32 { + pub fn get_zoom_scale_sheet_layout_view(&self) -> u32 { self.zoom_scale_sheet_layout_view.get_value() } @@ -225,7 +225,7 @@ impl SheetView { if self.show_grid_lines.has_value() { attributes.push(("showGridLines", self.show_grid_lines.get_value_string())); } - if *self.tab_selected.get_value() { + if self.tab_selected.get_value() { attributes.push(("tabSelected", self.tab_selected.get_value_string())); } if self.view.has_value() { @@ -249,7 +249,7 @@ impl SheetView { } let top_left_cell = self.top_left_cell.get_value_str(); if self.top_left_cell.has_value() { - attributes.push(("topLeftCell", &top_left_cell)); + attributes.push(("topLeftCell", top_left_cell)); } let workbook_view_id = self.workbook_view_id.get_value_string(); attributes.push(("workbookViewId", &workbook_view_id)); diff --git a/src/structs/spreadsheet.rs b/src/structs/spreadsheet.rs index 467fa468..c1bd0ddb 100644 --- a/src/structs/spreadsheet.rs +++ b/src/structs/spreadsheet.rs @@ -53,8 +53,8 @@ impl Spreadsheet { /// book.insert_new_row("Sheet1", &2, &3); /// ``` #[inline] - pub fn insert_new_row(&mut self, sheet_name: &str, row_index: &u32, num_rows: &u32) { - self.adjustment_insert_coordinate_with_sheet(sheet_name, &0, &0, row_index, num_rows); + pub fn insert_new_row(&mut self, sheet_name: &str, row_index: u32, num_rows: u32) { + self.adjustment_insert_coordinate_with_sheet(sheet_name, 0, 0, row_index, num_rows); } /// Insert new columns. @@ -68,10 +68,10 @@ impl Spreadsheet { /// book.insert_new_column("Sheet1", "B", &3); /// ``` #[inline] - pub fn insert_new_column(&mut self, sheet_name: &str, column: &str, num_columns: &u32) { + pub fn insert_new_column(&mut self, sheet_name: &str, column: &str, num_columns: u32) { let column_upper = column.to_uppercase(); let column_index = column_index_from_string(column_upper); - self.insert_new_column_by_index(sheet_name, &column_index, num_columns); + self.insert_new_column_by_index(sheet_name, column_index, num_columns); } /// Insert new columns. @@ -88,16 +88,16 @@ impl Spreadsheet { pub fn insert_new_column_by_index( &mut self, sheet_name: &str, - column_index: &u32, - num_columns: &u32, + column_index: u32, + num_columns: u32, ) { - self.adjustment_insert_coordinate_with_sheet(sheet_name, column_index, num_columns, &0, &0); + self.adjustment_insert_coordinate_with_sheet(sheet_name, column_index, num_columns, 0, 0); } /// Remove rows. /// # Arguments /// * `sheet_name` - Specify the sheet name. ex) "Sheet1" - /// * `row_index` - Specify point of remove. ex) &1 + /// * `row_index` - Specify point of remove. ex) 1 /// * `num_rows` - Specify number to remove. ex) &2 /// # Examples /// ``` @@ -105,8 +105,8 @@ impl Spreadsheet { /// book.remove_row("Sheet1", &2, &3); /// ``` #[inline] - pub fn remove_row(&mut self, sheet_name: &str, row_index: &u32, num_rows: &u32) { - self.adjustment_remove_coordinate_with_sheet(sheet_name, &0, &0, row_index, num_rows); + pub fn remove_row(&mut self, sheet_name: &str, row_index: u32, num_rows: u32) { + self.adjustment_remove_coordinate_with_sheet(sheet_name, 0, 0, row_index, num_rows); } /// Remove columns. @@ -120,10 +120,10 @@ impl Spreadsheet { /// book.remove_column("Sheet1", "B", &3); /// ``` #[inline] - pub fn remove_column(&mut self, sheet_name: &str, column: &str, num_columns: &u32) { + pub fn remove_column(&mut self, sheet_name: &str, column: &str, num_columns: u32) { let column_upper = column.to_uppercase(); let column_index = column_index_from_string(column_upper); - self.remove_column_by_index(sheet_name, &column_index, num_columns); + self.remove_column_by_index(sheet_name, column_index, num_columns); } /// Remove columns. @@ -140,10 +140,10 @@ impl Spreadsheet { pub fn remove_column_by_index( &mut self, sheet_name: &str, - column_index: &u32, - num_columns: &u32, + column_index: u32, + num_columns: u32, ) { - self.adjustment_remove_coordinate_with_sheet(sheet_name, column_index, num_columns, &0, &0); + self.adjustment_remove_coordinate_with_sheet(sheet_name, column_index, num_columns, 0, 0); } /// Gets the cell value by specifying an address. @@ -159,9 +159,9 @@ impl Spreadsheet { #[inline] pub fn get_cell_value_by_address(&self, address: &str) -> Vec<&CellValue> { let (sheet_name, range) = split_address(address); - self.get_sheet_by_name(&sheet_name) + self.get_sheet_by_name(sheet_name) .unwrap() - .get_cell_value_by_range(&range) + .get_cell_value_by_range(range) } /// (This method is crate only.) @@ -385,12 +385,11 @@ impl Spreadsheet { /// # Return value /// * `Option<&Worksheet>`. #[inline] - pub fn get_sheet(&self, index: &usize) -> Option<&Worksheet> { + pub fn get_sheet(&self, index: usize) -> Option<&Worksheet> { self.work_sheet_collection - .get(*index) - .map(|v| { + .get(index) + .inspect(|v| { assert!(v.is_deserialized(),"This Worksheet is Not Deserialized. Please exec to read_sheet(&mut self, index: usize);"); - v }) } @@ -402,13 +401,13 @@ impl Spreadsheet { #[inline] pub fn get_sheet_by_name(&self, sheet_name: &str) -> Option<&Worksheet> { self.find_sheet_index_by_name(sheet_name) - .and_then(|index| self.get_sheet(&index)) + .and_then(|index| self.get_sheet(index)) } - pub fn get_lazy_read_sheet_cells(&self, index: &usize) -> Result { + pub fn get_lazy_read_sheet_cells(&self, index: usize) -> Result { let shared_string_table = self.get_shared_string_table(); self.work_sheet_collection - .get(*index) + .get(index) .map(|v| { v.get_cell_collection_stream( &shared_string_table.read().unwrap(), @@ -423,10 +422,11 @@ impl Spreadsheet { /// * `index` - sheet index /// # Return value /// * `Option<&mut Worksheet>`. - pub fn get_sheet_mut(&mut self, index: &usize) -> Option<&mut Worksheet> { + #[allow(clippy::manual_inspect)] + pub fn get_sheet_mut(&mut self, index: usize) -> Option<&mut Worksheet> { let shared_string_table = self.get_shared_string_table(); let stylesheet = self.get_stylesheet().clone(); - self.work_sheet_collection.get_mut(*index).map(|v| { + self.work_sheet_collection.get_mut(index).map(|v| { raw_to_deserialize_by_worksheet(v, shared_string_table, &stylesheet); v }) @@ -440,7 +440,7 @@ impl Spreadsheet { #[inline] pub fn get_sheet_by_name_mut(&mut self, sheet_name: &str) -> Option<&mut Worksheet> { self.find_sheet_index_by_name(sheet_name) - .and_then(move |index| self.get_sheet_mut(&index)) + .and_then(move |index| self.get_sheet_mut(index)) } #[inline] @@ -454,8 +454,8 @@ impl Spreadsheet { /// * `&Worksheet` - Work sheet. #[inline] pub fn get_active_sheet(&self) -> &Worksheet { - let index = *self.get_workbook_view().get_active_tab(); - self.get_sheet(&(index as usize)).unwrap() + let index = self.get_workbook_view().get_active_tab(); + self.get_sheet(index as usize).unwrap() } /// Get Active Work Sheet in mutable. @@ -463,8 +463,8 @@ impl Spreadsheet { /// * `&mut Worksheet` - Work sheet. #[inline] pub fn get_active_sheet_mut(&mut self) -> &mut Worksheet { - let index = *self.get_workbook_view().get_active_tab(); - self.get_sheet_mut(&(index as usize)).unwrap() + let index = self.get_workbook_view().get_active_tab(); + self.get_sheet_mut(index as usize).unwrap() } /// Add Work Sheet. @@ -670,7 +670,7 @@ impl Spreadsheet { #[inline] pub(crate) fn update_pivot_caches(&mut self, key: String, value: String) -> &mut Self { self.pivot_caches.iter_mut().for_each(|(val1, _, val3)| { - if &**val1 == &key { + if **val1 == key { *val3 = value.clone().into_boxed_str() }; }); @@ -732,10 +732,10 @@ impl AdjustmentCoordinateWithSheet for Spreadsheet { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.read_sheet_collection(); for worksheet in &mut self.work_sheet_collection { @@ -758,10 +758,10 @@ impl AdjustmentCoordinateWithSheet for Spreadsheet { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.read_sheet_collection(); for worksheet in &mut self.work_sheet_collection { diff --git a/src/structs/strike.rs b/src/structs/strike.rs index f29b5af9..994c4784 100644 --- a/src/structs/strike.rs +++ b/src/structs/strike.rs @@ -14,7 +14,7 @@ pub struct Strike { impl Strike { #[inline] - pub fn get_val(&self) -> &bool { + pub fn get_val(&self) -> bool { self.val.get_value() } @@ -41,7 +41,7 @@ impl Strike { } let mut attributes: Vec<(&str, &str)> = Vec::new(); - if !*self.val.get_value() { + if !self.val.get_value() { attributes.push(("val", self.val.get_value_string())); } write_start_tag(writer, "strike", attributes, true); diff --git a/src/structs/style.rs b/src/structs/style.rs index 87439616..8cb14300 100644 --- a/src/structs/style.rs +++ b/src/structs/style.rs @@ -7,9 +7,6 @@ use crate::structs::NumberingFormat; use crate::structs::PatternValues; use crate::structs::Protection; use crate::structs::UInt32Value; -use md5::Digest; - -use crate::BooleanValue; /// # Examples /// ## add border @@ -260,7 +257,7 @@ impl Style { } #[inline] - pub fn get_format_id(&self) -> &u32 { + pub fn get_format_id(&self) -> u32 { self.format_id.get_value() } @@ -293,6 +290,7 @@ impl Style { } #[inline] + #[allow(dead_code)] pub(crate) fn set_protection_crate(&mut self, value: Option) -> &mut Self { self.protection = value; self diff --git a/src/structs/stylesheet.rs b/src/structs/stylesheet.rs index a64be1c3..88efd816 100644 --- a/src/structs/stylesheet.rs +++ b/src/structs/stylesheet.rs @@ -9,7 +9,6 @@ use super::DifferentialFormats; use super::Fills; use super::Fonts; use super::NumberingFormats; -use super::Protection; use super::Style; use crate::helper::const_str::*; use crate::reader::driver::*; @@ -57,6 +56,7 @@ impl Stylesheet { } #[inline] + #[allow(dead_code)] pub(crate) fn get_fonts_mut(&mut self) -> &mut Fonts { &mut self.fonts } @@ -73,6 +73,7 @@ impl Stylesheet { } #[inline] + #[allow(dead_code)] pub(crate) fn get_fills_mut(&mut self) -> &mut Fills { &mut self.fills } @@ -89,6 +90,7 @@ impl Stylesheet { } #[inline] + #[allow(dead_code)] pub(crate) fn get_borders_mut(&mut self) -> &mut BordersCrate { &mut self.borders } @@ -189,7 +191,7 @@ impl Stylesheet { let def_cell_format = self .cell_style_formats .get_cell_format() - .get(*cell_format.get_format_id() as usize) + .get(cell_format.get_format_id() as usize) .cloned() .unwrap_or_default(); @@ -210,14 +212,14 @@ impl Stylesheet { // number_format let mut apply = true; if def_cell_format.has_apply_number_format() { - apply = *def_cell_format.get_apply_number_format(); + apply = def_cell_format.get_apply_number_format(); } if cell_format.has_apply_number_format() { - apply = *cell_format.get_apply_number_format(); + apply = cell_format.get_apply_number_format(); } if apply { let id = cell_format.get_number_format_id(); - if let Some(obj) = self.numbering_formats.get_numbering_format().get(id) { + if let Some(obj) = self.numbering_formats.get_numbering_format().get(&id) { style.set_numbering_format(obj.clone()); } } @@ -225,13 +227,13 @@ impl Stylesheet { // font let mut apply = true; if def_cell_format.has_apply_font() { - apply = *def_cell_format.get_apply_font(); + apply = def_cell_format.get_apply_font(); } if cell_format.has_apply_font() { - apply = *cell_format.get_apply_font(); + apply = cell_format.get_apply_font(); } if apply { - let id = *cell_format.get_font_id() as usize; + let id = cell_format.get_font_id() as usize; let obj = self.fonts.get_font().get(id).unwrap(); style.set_font(obj.clone()); } @@ -239,13 +241,13 @@ impl Stylesheet { // fill let mut apply = true; if def_cell_format.has_apply_fill() { - apply = *def_cell_format.get_apply_fill(); + apply = def_cell_format.get_apply_fill(); } if cell_format.has_apply_fill() { - apply = *cell_format.get_apply_fill(); + apply = cell_format.get_apply_fill(); } if apply { - let id = *cell_format.get_fill_id() as usize; + let id = cell_format.get_fill_id() as usize; let obj = self.fills.get_fill().get(id).unwrap(); style.set_fill(obj.clone()); } @@ -253,27 +255,27 @@ impl Stylesheet { // borders let mut apply = true; if def_cell_format.has_apply_border() { - apply = *def_cell_format.get_apply_border(); + apply = def_cell_format.get_apply_border(); } if cell_format.has_apply_border() { - apply = *cell_format.get_apply_border(); + apply = cell_format.get_apply_border(); } if apply { - let id = *cell_format.get_border_id() as usize; + let id = cell_format.get_border_id() as usize; let obj = self.borders.get_borders().get(id).unwrap(); style.set_borders(obj.clone()); } // format_id - style.set_format_id(*cell_format.get_format_id()); + style.set_format_id(cell_format.get_format_id()); // alignment let mut apply = true; if def_cell_format.has_apply_alignment() { - apply = *def_cell_format.get_apply_alignment(); + apply = def_cell_format.get_apply_alignment(); } if cell_format.has_apply_alignment() { - apply = *cell_format.get_apply_alignment(); + apply = cell_format.get_apply_alignment(); } if apply { if let Some(v) = def_cell_format.get_alignment() { @@ -287,10 +289,10 @@ impl Stylesheet { // protection let mut apply = true; if def_cell_format.has_apply_protection() { - apply = *def_cell_format.get_apply_protection(); + apply = def_cell_format.get_apply_protection(); } if cell_format.has_apply_protection() { - apply = *cell_format.get_apply_protection(); + apply = cell_format.get_apply_protection(); } if !apply { return; diff --git a/src/structs/tab_color.rs b/src/structs/tab_color.rs index 65b673c9..13b33062 100644 --- a/src/structs/tab_color.rs +++ b/src/structs/tab_color.rs @@ -107,7 +107,7 @@ impl TabColor { } #[inline] - pub fn get_indexed(&self) -> &u32 { + pub fn get_indexed(&self) -> u32 { &self.indexed.get_value() } @@ -123,7 +123,7 @@ impl TabColor { } #[inline] - pub fn get_theme_index(&self) -> &u32 { + pub fn get_theme_index(&self) -> u32 { &self.theme_index.get_value() } @@ -151,7 +151,7 @@ impl TabColor { } #[inline] - pub fn get_tint(&self) -> &f64 { + pub fn get_tint(&self) -> f64 { &self.tint.get_value() } diff --git a/src/structs/table.rs b/src/structs/table.rs index bc81fbf7..28178951 100644 --- a/src/structs/table.rs +++ b/src/structs/table.rs @@ -1,10 +1,3 @@ -use std::default; - -use quick_xml::{ - events::{BytesStart, Event}, - Reader, -}; - use super::{ coordinate::*, BooleanValue, EnumValue, StringValue, TotalsRowFunctionValues, UInt32Value, }; @@ -46,10 +39,10 @@ impl Table { pub fn is_ok(&self) -> bool { !(self.name.is_empty() || self.display_name.is_empty() - || self.area.0.get_col_num() == &0 - || self.area.0.get_row_num() == &0 - || self.area.1.get_col_num() == &0 - || self.area.1.get_row_num() == &0 + || self.area.0.get_col_num() == 0 + || self.area.0.get_row_num() == 0 + || self.area.1.get_col_num() == 0 + || self.area.1.get_row_num() == 0 || self.area.0.get_col_num() > self.area.1.get_col_num() || self.area.0.get_row_num() > self.area.1.get_row_num()) } @@ -123,7 +116,7 @@ impl Table { } #[inline] - pub fn get_totals_row_shown(&self) -> &bool { + pub fn get_totals_row_shown(&self) -> bool { self.totals_row_shown.get_value() } @@ -148,7 +141,7 @@ impl Table { } #[inline] - pub fn get_totals_row_count(&self) -> &u32 { + pub fn get_totals_row_count(&self) -> u32 { self.totals_row_count.get_value() } @@ -209,6 +202,7 @@ impl TableColumn { } #[inline] + #[allow(dead_code)] pub(crate) fn has_totals_row_label(&self) -> bool { self.totals_row_label.has_value() } @@ -234,6 +228,7 @@ impl TableColumn { } #[inline] + #[allow(dead_code)] pub(crate) fn has_totals_row_function(&self) -> bool { self.totals_row_function.has_value() } diff --git a/src/structs/text_element.rs b/src/structs/text_element.rs index 23f22dd4..942ff3ab 100644 --- a/src/structs/text_element.rs +++ b/src/structs/text_element.rs @@ -42,6 +42,7 @@ impl TextElement { } #[inline] + #[allow(dead_code)] pub(crate) fn get_run_properties_crate(&mut self) -> Option<&mut Font> { self.run_properties.as_deref_mut() } diff --git a/src/structs/to_marker.rs b/src/structs/to_marker.rs index 6b4eb2a3..c1e348eb 100644 --- a/src/structs/to_marker.rs +++ b/src/structs/to_marker.rs @@ -14,8 +14,8 @@ pub struct ToMarker { } impl ToMarker { #[inline] - pub fn get_col(&self) -> &usize { - &self.col + pub fn get_col(&self) -> usize { + self.col } #[inline] @@ -25,8 +25,8 @@ impl ToMarker { } #[inline] - pub fn get_col_off(&self) -> &usize { - &self.col_off + pub fn get_col_off(&self) -> usize { + self.col_off } #[inline] @@ -36,8 +36,8 @@ impl ToMarker { } #[inline] - pub fn get_row(&self) -> &usize { - &self.row + pub fn get_row(&self) -> usize { + self.row } #[inline] @@ -47,8 +47,8 @@ impl ToMarker { } #[inline] - pub fn get_row_off(&self) -> &usize { - &self.row_off + pub fn get_row_off(&self) -> usize { + self.row_off } #[inline] @@ -58,23 +58,23 @@ impl ToMarker { } #[inline] - pub(crate) fn _adjustment_insert_row(&mut self, num_rows: &usize) { + pub(crate) fn _adjustment_insert_row(&mut self, num_rows: usize) { self.row += num_rows; } #[inline] - pub(crate) fn _adjustment_insert_column(&mut self, num_cols: &usize) { + pub(crate) fn _adjustment_insert_column(&mut self, num_cols: usize) { self.col += num_cols; } #[inline] - pub(crate) fn _adjustment_remove_row(&mut self, num_rows: &usize) { - self.row = self.row.saturating_sub(*num_rows).max(1); + pub(crate) fn _adjustment_remove_row(&mut self, num_rows: usize) { + self.row = self.row.saturating_sub(num_rows).max(1); } #[inline] - pub(crate) fn _adjustment_remove_column(&mut self, num_cols: &usize) { - self.col = self.col.saturating_sub(*num_cols).max(1); + pub(crate) fn _adjustment_remove_column(&mut self, num_cols: usize) { + self.col = self.col.saturating_sub(num_cols).max(1); } pub(crate) fn set_attributes( @@ -117,22 +117,22 @@ impl ToMarker { // xdr:col write_start_tag(writer, "xdr:col", vec![], false); - write_text_node(writer, &self.col.to_string()); + write_text_node(writer, self.col.to_string()); write_end_tag(writer, "xdr:col"); // xdr:colOff write_start_tag(writer, "xdr:colOff", vec![], false); - write_text_node(writer, &self.col_off.to_string()); + write_text_node(writer, self.col_off.to_string()); write_end_tag(writer, "xdr:colOff"); // xdr:row write_start_tag(writer, "xdr:row", vec![], false); - write_text_node(writer, &self.row.to_string()); + write_text_node(writer, self.row.to_string()); write_end_tag(writer, "xdr:row"); // xdr:rowOff write_start_tag(writer, "xdr:rowOff", vec![], false); - write_text_node(writer, &self.row_off.to_string()); + write_text_node(writer, self.row_off.to_string()); write_end_tag(writer, "xdr:rowOff"); write_end_tag(writer, "to"); diff --git a/src/structs/true_false_blank_value.rs b/src/structs/true_false_blank_value.rs index fd094133..62b1752f 100644 --- a/src/structs/true_false_blank_value.rs +++ b/src/structs/true_false_blank_value.rs @@ -4,19 +4,19 @@ pub struct TrueFalseBlankValue { } impl TrueFalseBlankValue { #[inline] - pub(crate) fn get_value(&self) -> Option<&bool> { - self.value.as_ref() + pub(crate) fn get_value(&self) -> Option { + self.value } #[inline] pub(crate) fn _get_value_str(&self) -> &str { - self.get_value().map_or("", |v| if *v { "t" } else { "f" }) + self.get_value().map_or("", |v| if v { "t" } else { "f" }) } #[inline] pub(crate) fn get_value_string2(&self) -> &str { self.get_value() - .map_or("", |v| if *v { "True" } else { "False" }) + .map_or("", |v| if v { "True" } else { "False" }) } #[inline] diff --git a/src/structs/true_false_value.rs b/src/structs/true_false_value.rs index 2a085ca5..13b9088f 100644 --- a/src/structs/true_false_value.rs +++ b/src/structs/true_false_value.rs @@ -5,8 +5,8 @@ pub struct TrueFalseValue { } impl TrueFalseValue { #[inline] - pub(crate) fn get_value(&self) -> &bool { - self.value.as_ref().unwrap_or(&self.value_default) + pub(crate) fn get_value(&self) -> bool { + self.value.unwrap_or(self.value_default) } #[inline] diff --git a/src/structs/u_int16_value.rs b/src/structs/u_int16_value.rs index 79da6fa9..c207eb92 100644 --- a/src/structs/u_int16_value.rs +++ b/src/structs/u_int16_value.rs @@ -4,8 +4,8 @@ pub struct UInt16Value { } impl UInt16Value { #[inline] - pub(crate) fn get_value(&self) -> &u16 { - self.value.as_ref().unwrap_or(&0) + pub(crate) fn get_value(&self) -> u16 { + self.value.unwrap_or(0) } #[inline] diff --git a/src/structs/u_int32_value.rs b/src/structs/u_int32_value.rs index 8cda971f..641a837c 100644 --- a/src/structs/u_int32_value.rs +++ b/src/structs/u_int32_value.rs @@ -4,8 +4,8 @@ pub struct UInt32Value { } impl UInt32Value { #[inline] - pub(crate) fn get_value(&self) -> &u32 { - self.value.as_ref().unwrap_or(&0) + pub(crate) fn get_value(&self) -> u32 { + self.value.unwrap_or(0) } #[inline] diff --git a/src/structs/vml/fill.rs b/src/structs/vml/fill.rs index 06cf26cb..ed7bcaf2 100644 --- a/src/structs/vml/fill.rs +++ b/src/structs/vml/fill.rs @@ -42,7 +42,7 @@ impl Fill { } #[inline] - pub fn get_on(&self) -> &bool { + pub fn get_on(&self) -> bool { self.on.get_value() } @@ -97,7 +97,7 @@ impl Fill { let mut obj = MediaObject::default(); obj.set_image_title(get_attribute(e, b"o:title").unwrap()); obj.set_image_name(relationship.get_raw_file().get_file_name()); - obj.set_image_data(relationship.get_raw_file().get_file_data().clone()); + obj.set_image_data(relationship.get_raw_file().get_file_data()); self.set_image(obj); } } @@ -123,12 +123,12 @@ impl Fill { if self.focus_size.has_value() { attributes.push(("focussize", self.focus_size.get_value_str())); } - let mut r_id_str = String::from(""); + let mut _r_id_str = String::from(""); if let Some(image) = &self.image { let r_id = image.get_rid(rel_list); - r_id_str = format!("rId{}", r_id); + _r_id_str = format!("rId{}", r_id); attributes.push(("o:title", image.get_image_title())); - attributes.push(("o:relid", r_id_str.as_str())); + attributes.push(("o:relid", _r_id_str.as_str())); attributes.push(("recolor", "t")); attributes.push(("rotate", "t")); attributes.push(("type", "frame")); diff --git a/src/structs/vml/image_data.rs b/src/structs/vml/image_data.rs index 82b0dc70..84a76b58 100644 --- a/src/structs/vml/image_data.rs +++ b/src/structs/vml/image_data.rs @@ -52,7 +52,7 @@ impl ImageData { self.get_image_mut() .set_image_name(relationship.get_raw_file().get_file_name()); self.get_image_mut() - .set_image_data(relationship.get_raw_file().get_file_data().clone()); + .set_image_data(relationship.get_raw_file().get_file_data()); } } @@ -66,10 +66,10 @@ impl ImageData { ) { // v:imagedata let mut attributes: Vec<(&str, &str)> = Vec::new(); - let mut r_id_str = String::from(""); + let mut _r_id_str = String::from(""); let r_id = &self.image.get_rid(rel_list); - r_id_str = format!("rId{}", r_id); - attributes.push(("o:relid", r_id_str.as_str())); + _r_id_str = format!("rId{}", r_id); + attributes.push(("o:relid", _r_id_str.as_str())); if self.title.has_value() { attributes.push(("o:title", self.title.get_value_str())); } diff --git a/src/structs/vml/shadow.rs b/src/structs/vml/shadow.rs index 0bbffa29..28671e4c 100644 --- a/src/structs/vml/shadow.rs +++ b/src/structs/vml/shadow.rs @@ -14,7 +14,7 @@ pub struct Shadow { obscured: TrueFalseValue, } impl Shadow { - pub fn get_on(&self) -> &bool { + pub fn get_on(&self) -> bool { self.on.get_value() } @@ -32,7 +32,7 @@ impl Shadow { self } - pub fn get_obscured(&self) -> &bool { + pub fn get_obscured(&self) -> bool { self.obscured.get_value() } diff --git a/src/structs/vml/shape.rs b/src/structs/vml/shape.rs index 1c976657..8180acc9 100644 --- a/src/structs/vml/shape.rs +++ b/src/structs/vml/shape.rs @@ -59,7 +59,7 @@ impl Shape { self } - pub fn get_filled(&self) -> &bool { + pub fn get_filled(&self) -> bool { self.filled.get_value() } @@ -77,7 +77,7 @@ impl Shape { self } - pub fn get_stroked(&self) -> &bool { + pub fn get_stroked(&self) -> bool { self.stroked.get_value() } @@ -204,7 +204,7 @@ impl Shape { self } - pub fn get_optional_number(&self) -> &i32 { + pub fn get_optional_number(&self) -> i32 { self.optional_number.get_value() } @@ -298,7 +298,7 @@ impl Shape { pub(crate) fn write_to( &self, writer: &mut Writer>>, - id: &usize, + id: usize, rel_list: &mut Vec<(String, String)>, ) { // v:shape @@ -377,10 +377,10 @@ impl Shape { impl AdjustmentCoordinate for Shape { fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.client_data.adjustment_insert_coordinate( root_col_num, @@ -392,10 +392,10 @@ impl AdjustmentCoordinate for Shape { fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.client_data.adjustment_remove_coordinate( root_col_num, diff --git a/src/structs/vml/spreadsheet/anchor.rs b/src/structs/vml/spreadsheet/anchor.rs index d4b39ade..561ff82a 100644 --- a/src/structs/vml/spreadsheet/anchor.rs +++ b/src/structs/vml/spreadsheet/anchor.rs @@ -21,8 +21,8 @@ pub struct Anchor { impl Anchor { #[inline] - pub fn get_left_column(&self) -> &u32 { - &self.left_column + pub fn get_left_column(&self) -> u32 { + self.left_column } #[inline] @@ -32,8 +32,8 @@ impl Anchor { } #[inline] - pub fn get_left_offset(&self) -> &u32 { - &self.left_offset + pub fn get_left_offset(&self) -> u32 { + self.left_offset } #[inline] @@ -43,8 +43,8 @@ impl Anchor { } #[inline] - pub fn get_top_row(&self) -> &u32 { - &self.top_row + pub fn get_top_row(&self) -> u32 { + self.top_row } #[inline] @@ -54,8 +54,8 @@ impl Anchor { } #[inline] - pub fn get_top_offset(&self) -> &u32 { - &self.top_offset + pub fn get_top_offset(&self) -> u32 { + self.top_offset } #[inline] @@ -65,8 +65,8 @@ impl Anchor { } #[inline] - pub fn get_right_column(&self) -> &u32 { - &self.right_column + pub fn get_right_column(&self) -> u32 { + self.right_column } #[inline] @@ -76,8 +76,8 @@ impl Anchor { } #[inline] - pub fn get_right_offset(&self) -> &u32 { - &self.right_offset + pub fn get_right_offset(&self) -> u32 { + self.right_offset } #[inline] @@ -87,8 +87,8 @@ impl Anchor { } #[inline] - pub fn get_bottom_row(&self) -> &u32 { - &self.bottom_row + pub fn get_bottom_row(&self) -> u32 { + self.bottom_row } #[inline] @@ -98,8 +98,8 @@ impl Anchor { } #[inline] - pub fn get_bottom_offset(&self) -> &u32 { - &self.bottom_offset + pub fn get_bottom_offset(&self) -> u32 { + self.bottom_offset } #[inline] @@ -109,25 +109,28 @@ impl Anchor { } #[inline] - pub(crate) fn adjustment_insert_row(&mut self, num_rows: &u32) { + #[allow(dead_code)] + pub(crate) fn adjustment_insert_row(&mut self, num_rows: u32) { self.top_row += num_rows; self.bottom_row += num_rows; } #[inline] - pub(crate) fn adjustment_insert_column(&mut self, num_cols: &u32) { + #[allow(dead_code)] + pub(crate) fn adjustment_insert_column(&mut self, num_cols: u32) { self.left_column += num_cols; self.right_column += num_cols; } #[inline] - pub(crate) fn adjustment_remove_row(&mut self, num_rows: &u32) { - self.top_row = if &self.top_row > num_rows { + #[allow(dead_code)] + pub(crate) fn adjustment_remove_row(&mut self, num_rows: u32) { + self.top_row = if self.top_row > num_rows { self.top_row - num_rows } else { 1 }; - self.bottom_row = if &self.bottom_row > num_rows { + self.bottom_row = if self.bottom_row > num_rows { self.bottom_row - num_rows } else { 1 @@ -135,13 +138,14 @@ impl Anchor { } #[inline] - pub(crate) fn adjustment_remove_column(&mut self, num_cols: &u32) { - self.left_column = if &self.left_column > num_cols { + #[allow(dead_code)] + pub(crate) fn adjustment_remove_column(&mut self, num_cols: u32) { + self.left_column = if self.left_column > num_cols { self.left_column - num_cols } else { 1 }; - self.right_column = if &self.right_column > num_cols { + self.right_column = if self.right_column > num_cols { self.right_column - num_cols } else { 1 @@ -208,56 +212,52 @@ impl AdjustmentCoordinate for Anchor { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.left_column = - adjustment_insert_coordinate(&(&self.left_column + 1), root_col_num, offset_col_num) - - 1; + adjustment_insert_coordinate(self.left_column + 1, root_col_num, offset_col_num) - 1; self.right_column = - adjustment_insert_coordinate(&(&self.right_column + 1), root_col_num, offset_col_num) - - 1; + adjustment_insert_coordinate(self.right_column + 1, root_col_num, offset_col_num) - 1; self.top_row = - adjustment_insert_coordinate(&(&self.top_row + 1), root_row_num, offset_row_num) - 1; + adjustment_insert_coordinate(self.top_row + 1, root_row_num, offset_row_num) - 1; self.bottom_row = - adjustment_insert_coordinate(&(&self.bottom_row + 1), root_row_num, offset_row_num) - 1; + adjustment_insert_coordinate(self.bottom_row + 1, root_row_num, offset_row_num) - 1; } #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.left_column = - adjustment_remove_coordinate(&(&self.left_column + 1), root_col_num, offset_col_num) - - 1; + adjustment_remove_coordinate(self.left_column + 1, root_col_num, offset_col_num) - 1; self.right_column = - adjustment_remove_coordinate(&(&self.right_column + 1), root_col_num, offset_col_num) - - 1; + adjustment_remove_coordinate(self.right_column + 1, root_col_num, offset_col_num) - 1; self.top_row = - adjustment_remove_coordinate(&(&self.top_row + 1), root_row_num, offset_row_num) - 1; + adjustment_remove_coordinate(self.top_row + 1, root_row_num, offset_row_num) - 1; self.bottom_row = - adjustment_remove_coordinate(&(&self.bottom_row + 1), root_row_num, offset_row_num) - 1; + adjustment_remove_coordinate(self.bottom_row + 1, root_row_num, offset_row_num) - 1; } #[inline] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { - is_remove_coordinate(&(&self.left_column + 1), root_col_num, offset_col_num) - || is_remove_coordinate(&(&self.right_column + 1), root_col_num, offset_col_num) - || is_remove_coordinate(&(&self.top_row + 1), root_row_num, offset_row_num) - || is_remove_coordinate(&(&self.bottom_row + 1), root_row_num, offset_row_num) + is_remove_coordinate(self.left_column + 1, root_col_num, offset_col_num) + || is_remove_coordinate(self.right_column + 1, root_col_num, offset_col_num) + || is_remove_coordinate(self.top_row + 1, root_row_num, offset_row_num) + || is_remove_coordinate(self.bottom_row + 1, root_row_num, offset_row_num) } } diff --git a/src/structs/vml/spreadsheet/auto_fill.rs b/src/structs/vml/spreadsheet/auto_fill.rs index 82bb88f0..aa83c7ad 100644 --- a/src/structs/vml/spreadsheet/auto_fill.rs +++ b/src/structs/vml/spreadsheet/auto_fill.rs @@ -13,7 +13,7 @@ pub struct AutoFill { impl AutoFill { #[inline] - pub fn get_value(&self) -> Option<&bool> { + pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/auto_size_picture.rs b/src/structs/vml/spreadsheet/auto_size_picture.rs index 5e671160..8e9efd7c 100644 --- a/src/structs/vml/spreadsheet/auto_size_picture.rs +++ b/src/structs/vml/spreadsheet/auto_size_picture.rs @@ -13,7 +13,7 @@ pub struct AutoSizePicture { impl AutoSizePicture { #[inline] - pub fn get_value(&self) -> Option<&bool> { + pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/client_data.rs b/src/structs/vml/spreadsheet/client_data.rs index f008aede..9922a3b8 100644 --- a/src/structs/vml/spreadsheet/client_data.rs +++ b/src/structs/vml/spreadsheet/client_data.rs @@ -347,10 +347,10 @@ impl AdjustmentCoordinate for ClientData { #[inline] fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.anchor.adjustment_insert_coordinate( root_col_num, @@ -358,27 +358,21 @@ impl AdjustmentCoordinate for ClientData { root_row_num, offset_row_num, ); - match &mut self.comment_column_target { - Some(v) => { - v.adjustment_insert_value(root_col_num, offset_col_num); - } - None => {} + if let Some(v) = &mut self.comment_column_target { + v.adjustment_insert_value(root_col_num, offset_col_num); } - match &mut self.comment_row_target { - Some(v) => { - v.adjustment_insert_value(root_row_num, offset_row_num); - } - None => {} + if let Some(v) = &mut self.comment_row_target { + v.adjustment_insert_value(root_row_num, offset_row_num); } } #[inline] fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { self.anchor.adjustment_remove_coordinate( root_col_num, @@ -386,17 +380,11 @@ impl AdjustmentCoordinate for ClientData { root_row_num, offset_row_num, ); - match &mut self.comment_column_target { - Some(v) => { - v.adjustment_remove_value(root_col_num, offset_col_num); - } - None => {} + if let Some(v) = &mut self.comment_column_target { + v.adjustment_remove_value(root_col_num, offset_col_num); } - match &mut self.comment_row_target { - Some(v) => { - v.adjustment_remove_value(root_row_num, offset_row_num); - } - None => {} + if let Some(v) = &mut self.comment_row_target { + v.adjustment_remove_value(root_row_num, offset_row_num); } } } diff --git a/src/structs/vml/spreadsheet/comment_column_target.rs b/src/structs/vml/spreadsheet/comment_column_target.rs index 76c582e6..8b1f6419 100644 --- a/src/structs/vml/spreadsheet/comment_column_target.rs +++ b/src/structs/vml/spreadsheet/comment_column_target.rs @@ -15,7 +15,7 @@ pub struct CommentColumnTarget { impl CommentColumnTarget { #[inline] - pub fn get_value(&self) -> &u32 { + pub fn get_value(&self) -> u32 { self.value.get_value() } @@ -55,21 +55,21 @@ impl CommentColumnTarget { } impl AdjustmentValue for CommentColumnTarget { #[inline] - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { self.value.set_value( - adjustment_insert_coordinate(&(self.value.get_value() + &1), root_num, offset_num) - 1, + adjustment_insert_coordinate(self.value.get_value() + 1, root_num, offset_num) - 1, ); } #[inline] - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { self.value.set_value( - adjustment_remove_coordinate(&(self.value.get_value() + &1), root_num, offset_num) - 1, + adjustment_remove_coordinate(self.value.get_value() + 1, root_num, offset_num) - 1, ); } #[inline] - fn is_remove_value(&self, root_num: &u32, offset_num: &u32) -> bool { - is_remove_coordinate(&(self.value.get_value() + 1), root_num, offset_num) + fn is_remove_value(&self, root_num: u32, offset_num: u32) -> bool { + is_remove_coordinate(self.value.get_value() + 1, root_num, offset_num) } } diff --git a/src/structs/vml/spreadsheet/comment_row_target.rs b/src/structs/vml/spreadsheet/comment_row_target.rs index f5de1576..0c0f68e0 100644 --- a/src/structs/vml/spreadsheet/comment_row_target.rs +++ b/src/structs/vml/spreadsheet/comment_row_target.rs @@ -15,7 +15,7 @@ pub struct CommentRowTarget { impl CommentRowTarget { #[inline] - pub fn get_value(&self) -> &u32 { + pub fn get_value(&self) -> u32 { self.value.get_value() } @@ -26,13 +26,15 @@ impl CommentRowTarget { } #[inline] - pub(crate) fn adjustment_insert_row(&mut self, num_rows: &u32) { + #[allow(dead_code)] + pub(crate) fn adjustment_insert_row(&mut self, num_rows: u32) { let value = self.value.get_value() + num_rows; self.value.set_value(value); } #[inline] - pub(crate) fn adjustment_remove_row(&mut self, num_row: &u32) { + #[allow(dead_code)] + pub(crate) fn adjustment_remove_row(&mut self, num_row: u32) { if self.value.get_value() > num_row { let value = self.value.get_value() - num_row; self.value.set_value(value); @@ -71,21 +73,21 @@ impl CommentRowTarget { } impl AdjustmentValue for CommentRowTarget { #[inline] - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32) { self.value.set_value( - adjustment_insert_coordinate(&(self.value.get_value() + &1), root_num, offset_num) - 1, + adjustment_insert_coordinate(self.value.get_value() + 1, root_num, offset_num) - 1, ); } #[inline] - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32) { + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32) { self.value.set_value( - adjustment_remove_coordinate(&(self.value.get_value() + &1), root_num, offset_num) - 1, + adjustment_remove_coordinate(self.value.get_value() + 1, root_num, offset_num) - 1, ); } #[inline] - fn is_remove_value(&self, root_num: &u32, offset_num: &u32) -> bool { - is_remove_coordinate(&(self.value.get_value() + 1), root_num, offset_num) + fn is_remove_value(&self, root_num: u32, offset_num: u32) -> bool { + is_remove_coordinate(self.value.get_value() + 1, root_num, offset_num) } } diff --git a/src/structs/vml/spreadsheet/move_with_cells.rs b/src/structs/vml/spreadsheet/move_with_cells.rs index ed74b44e..ba6615d4 100644 --- a/src/structs/vml/spreadsheet/move_with_cells.rs +++ b/src/structs/vml/spreadsheet/move_with_cells.rs @@ -13,7 +13,7 @@ pub struct MoveWithCells { impl MoveWithCells { #[inline] - pub fn get_value(&self) -> Option<&bool> { + pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/resize_with_cells.rs b/src/structs/vml/spreadsheet/resize_with_cells.rs index 2dec52cf..fb597caf 100644 --- a/src/structs/vml/spreadsheet/resize_with_cells.rs +++ b/src/structs/vml/spreadsheet/resize_with_cells.rs @@ -13,7 +13,7 @@ pub struct ResizeWithCells { impl ResizeWithCells { #[inline] - pub fn get_value(&self) -> Option<&bool> { + pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/visible.rs b/src/structs/vml/spreadsheet/visible.rs index 1bc0cf01..343711bf 100644 --- a/src/structs/vml/spreadsheet/visible.rs +++ b/src/structs/vml/spreadsheet/visible.rs @@ -13,7 +13,7 @@ pub struct Visible { impl Visible { #[inline] - pub fn get_value(&self) -> Option<&bool> { + pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/workbook_protection.rs b/src/structs/workbook_protection.rs index 752e3c3e..e790e8c9 100644 --- a/src/structs/workbook_protection.rs +++ b/src/structs/workbook_protection.rs @@ -5,8 +5,7 @@ use super::UInt32Value; use crate::helper::crypt::*; use crate::reader::driver::*; use crate::writer::driver::*; -use md5::Digest; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; @@ -62,7 +61,7 @@ impl WorkbookProtection { } #[inline] - pub fn get_workbook_spin_count(&self) -> &u32 { + pub fn get_workbook_spin_count(&self) -> u32 { self.workbook_spin_count.get_value() } @@ -123,7 +122,7 @@ impl WorkbookProtection { } #[inline] - pub fn get_revisions_spin_count(&self) -> &u32 { + pub fn get_revisions_spin_count(&self) -> u32 { self.revisions_spin_count.get_value() } @@ -151,7 +150,7 @@ impl WorkbookProtection { } #[inline] - pub fn get_lock_revision(&self) -> &bool { + pub fn get_lock_revision(&self) -> bool { self.lock_revision.get_value() } @@ -162,7 +161,7 @@ impl WorkbookProtection { } #[inline] - pub fn get_lock_structure(&self) -> &bool { + pub fn get_lock_structure(&self) -> bool { self.lock_structure.get_value() } @@ -173,7 +172,7 @@ impl WorkbookProtection { } #[inline] - pub fn get_lock_windows(&self) -> &bool { + pub fn get_lock_windows(&self) -> bool { self.lock_windows.get_value() } diff --git a/src/structs/workbook_view.rs b/src/structs/workbook_view.rs index 54b577ff..33b03a55 100644 --- a/src/structs/workbook_view.rs +++ b/src/structs/workbook_view.rs @@ -13,7 +13,7 @@ pub struct WorkbookView { impl WorkbookView { #[inline] - pub fn get_active_tab(&self) -> &u32 { + pub fn get_active_tab(&self) -> u32 { self.active_tab.get_value() } diff --git a/src/structs/worksheet.rs b/src/structs/worksheet.rs index aab891d4..33e5ca74 100644 --- a/src/structs/worksheet.rs +++ b/src/structs/worksheet.rs @@ -41,7 +41,6 @@ use crate::structs::SheetViews; use crate::structs::Style; use crate::structs::Stylesheet; use crate::structs::Table; -use crate::traits; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWith2Sheet; use crate::traits::AdjustmentCoordinateWithSheet; @@ -50,8 +49,6 @@ use crate::StringValue; use std::collections::HashMap; use thin_vec::ThinVec; -use super::EnumTrait; - /// A Worksheet Object. #[derive(Clone, Debug, Default)] pub struct Worksheet { @@ -96,13 +93,13 @@ impl Worksheet { /// Get value. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `String` - Value of the specified cell. /// # Examples /// ``` /// let book = umya_spreadsheet::new_file(); - /// let worksheet = book.get_sheet(&0).unwrap(); + /// let worksheet = book.get_sheet(0).unwrap(); /// let value = worksheet.get_value("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let value = worksheet.get_value((1, 1)); @@ -126,7 +123,7 @@ impl Worksheet { /// # Examples /// ``` /// let book = umya_spreadsheet::new_file(); - /// let worksheet = book.get_sheet(&0).unwrap(); + /// let worksheet = book.get_sheet(0).unwrap(); /// let value = worksheet.get_value_number("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let value = worksheet.get_value_number((1, 1)); @@ -142,13 +139,13 @@ impl Worksheet { /// Get formatted value. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `String` - Formatted value of the specified cell. /// # Examples /// ``` /// let book = umya_spreadsheet::new_file(); - /// let worksheet = book.get_sheet(&0).unwrap(); + /// let worksheet = book.get_sheet(0).unwrap(); /// let value = worksheet.get_formatted_value("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let value = worksheet.get_formatted_value((1, 1)); @@ -160,7 +157,7 @@ impl Worksheet { { let CellCoordinates { col, row } = coordinate.into(); self.cell_collection - .get_formatted_value_by_column_and_row(&col, &row) + .get_formatted_value_by_column_and_row(col, row) } // ************************ @@ -226,13 +223,13 @@ impl Worksheet { /// # Note /// Cells with unset Value and Style will return None. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `Option` - Cell in the Some. /// # Examples /// ``` /// let book = umya_spreadsheet::new_file(); - /// let worksheet = book.get_sheet(&0).unwrap(); + /// let worksheet = book.get_sheet(0).unwrap(); /// let cell = worksheet.get_cell("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let cell = worksheet.get_cell((1, 1)); @@ -247,13 +244,13 @@ impl Worksheet { /// Get cell with mutable. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `&mut Cell` - Cell with mutable. /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// let cell = worksheet.get_cell_mut("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let cell = worksheet.get_cell_mut((1, 1)); @@ -263,31 +260,31 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_row_dimension_mut(&row); - let row_dimenshon = self.get_row_dimension_mut(&row).clone(); - let col_dimenshon = self.get_column_dimension_by_number_mut(&col).clone(); + self.get_row_dimension_mut(row); + let row_dimension = self.get_row_dimension_mut(row).clone(); + let col_dimension = self.get_column_dimension_by_number_mut(col).clone(); self.cell_collection - .get_mut((col, row), &row_dimenshon, &col_dimenshon) + .get_mut((col, row), &row_dimension, &col_dimension) } #[inline] - pub fn get_collection_by_column(&self, column_num: &u32) -> Vec<&Cell> { + pub fn get_collection_by_column(&self, column_num: u32) -> Vec<&Cell> { self.cell_collection.get_collection_by_column(column_num) } #[inline] - pub fn get_collection_by_row(&self, row_num: &u32) -> Vec<&Cell> { + pub fn get_collection_by_row(&self, row_num: u32) -> Vec<&Cell> { self.cell_collection.get_collection_by_row(row_num) } #[inline] - pub fn get_collection_by_column_to_hashmap(&self, column_num: &u32) -> HashMap { + pub fn get_collection_by_column_to_hashmap(&self, column_num: u32) -> HashMap { self.cell_collection .get_collection_by_column_to_hashmap(column_num) } #[inline] - pub fn get_collection_by_row_to_hashmap(&self, row_num: &u32) -> HashMap { + pub fn get_collection_by_row_to_hashmap(&self, row_num: u32) -> HashMap { self.cell_collection .get_collection_by_row_to_hashmap(row_num) } @@ -296,20 +293,20 @@ impl Worksheet { /// # Arguments /// * `cell` - Cell pub fn set_cell(&mut self, cell: Cell) -> &mut Self { - let row_dimenshon = self + let row_dimension = self .get_row_dimension_mut(cell.get_coordinate().get_row_num()) .clone(); - let col_dimenshon = self + let col_dimension = self .get_column_dimension_by_number_mut(cell.get_coordinate().get_col_num()) .clone(); self.cell_collection - .set(cell, &row_dimenshon, &col_dimenshon); + .set(cell, &row_dimension, &col_dimension); self } /// Remove Cell /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Examples /// ``` /// worksheet.remove_cell("A1"); @@ -322,18 +319,18 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.cell_collection.remove(&col, &row) + self.cell_collection.remove(col, row) } /// Get cell value. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `&CellValue` - CellValue. /// # Examples /// ``` /// let book = umya_spreadsheet::new_file(); - /// let worksheet = book.get_sheet(&0).unwrap(); + /// let worksheet = book.get_sheet(0).unwrap(); /// let cell_value = worksheet.get_cell_value("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let cell_value = worksheet.get_cell_value((1, 1)); @@ -348,13 +345,13 @@ impl Worksheet { /// Get cell value with mutable. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `&mut CellValue` - CellValue with mutable. /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// let cell_value = worksheet.get_cell_value_mut("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let cell_value = worksheet.get_cell_value_mut((1, 1)); @@ -375,7 +372,7 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// let mut cell_value_List = worksheet.get_cell_value_by_range("A1:C5"); /// ``` #[inline] @@ -385,13 +382,13 @@ impl Worksheet { /// Get style. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `&Style` - Style. /// # Examples /// ``` /// let book = umya_spreadsheet::new_file(); - /// let worksheet = book.get_sheet(&0).unwrap(); + /// let worksheet = book.get_sheet(0).unwrap(); /// let style = worksheet.get_style("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let style = worksheet.get_style((1, 1)); @@ -406,13 +403,13 @@ impl Worksheet { /// Get style with mutable. /// # Arguments - /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(&1, &1)` + /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value /// * `&mut Style` - Style with mutable. /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// let style = worksheet.get_style_mut("A1"); /// // or pass in a tuple `(col, row)`, both col and row starting at `1` /// let style = worksheet.get_style_mut((1, 1)); @@ -443,7 +440,7 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// let mut style = umya_spreadsheet::Style::default(); /// style.get_borders_mut().get_bottom_mut().set_border_style(umya_spreadsheet::Border::BORDER_MEDIUM); /// worksheet.set_style_by_range("A1:A3", style); @@ -456,15 +453,14 @@ impl Worksheet { if col_num_start == 0 { let (_, row_num_end) = coordinate_list[1]; for row_num in row_num_start..=row_num_end { - self.get_row_dimension_mut(&row_num) - .set_style(style.clone()); + self.get_row_dimension_mut(row_num).set_style(style.clone()); } return self; } if row_num_start == 0 { let (col_num_end, _) = coordinate_list[1]; for col_num in col_num_start..=col_num_end { - self.get_column_dimension_by_number_mut(&col_num) + self.get_column_dimension_by_number_mut(col_num) .set_style(style.clone()); } return self; @@ -599,7 +595,7 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.add_merge_cells("A1:C5"); /// ``` #[inline] @@ -643,7 +639,7 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.set_auto_filter("A2:K2"); /// ``` #[inline] @@ -691,7 +687,7 @@ impl Worksheet { pub fn get_column_dimension(&self, column: &str) -> Option<&Column> { let column_upper = column.to_uppercase(); let col = column_index_from_string(column_upper); - self.get_column_dimension_by_number(&col) + self.get_column_dimension_by_number(col) } /// Get Column Dimension in mutable. @@ -701,14 +697,14 @@ impl Worksheet { pub fn get_column_dimension_mut(&mut self, column: &str) -> &mut Column { let column_upper = column.to_uppercase(); let col = column_index_from_string(column_upper); - self.get_column_dimension_by_number_mut(&col) + self.get_column_dimension_by_number_mut(col) } /// Get Column Dimension. /// # Arguments /// * `col` - Column Number. #[inline] - pub fn get_column_dimension_by_number(&self, col: &u32) -> Option<&Column> { + pub fn get_column_dimension_by_number(&self, col: u32) -> Option<&Column> { self.get_column_dimensions_crate().get_column(col) } @@ -716,7 +712,7 @@ impl Worksheet { /// # Arguments /// * `col` - Column Number. #[inline] - pub fn get_column_dimension_by_number_mut(&mut self, col: &u32) -> &mut Column { + pub fn get_column_dimension_by_number_mut(&mut self, col: u32) -> &mut Column { self.get_column_dimensions_crate_mut().get_column_mut(col) } @@ -775,13 +771,13 @@ impl Worksheet { /// Get Row Dimension. #[inline] - pub fn get_row_dimension(&self, row: &u32) -> Option<&Row> { + pub fn get_row_dimension(&self, row: u32) -> Option<&Row> { self.row_dimensions.get_row_dimension(row) } /// Get Row Dimension in mutable. #[inline] - pub fn get_row_dimension_mut(&mut self, row: &u32) -> &mut Row { + pub fn get_row_dimension_mut(&mut self, row: u32) -> &mut Row { self.row_dimensions.get_row_dimension_mut(row) } @@ -846,14 +842,14 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.insert_new_row(&2, &3); /// ``` #[inline] - pub fn insert_new_row(&mut self, row_index: &u32, num_rows: &u32) { + pub fn insert_new_row(&mut self, row_index: u32, num_rows: u32) { let title = &*self.title.clone(); - self.adjustment_insert_coordinate(&0, &0, row_index, num_rows); - self.adjustment_insert_coordinate_with_sheet(title, &0, &0, row_index, num_rows); + self.adjustment_insert_coordinate(0, 0, row_index, num_rows); + self.adjustment_insert_coordinate_with_sheet(title, 0, 0, row_index, num_rows); } /// Adjust for references to other sheets. @@ -861,11 +857,11 @@ impl Worksheet { pub fn insert_new_row_from_other_sheet( &mut self, sheet_name: &str, - row_index: &u32, - num_rows: &u32, + row_index: u32, + num_rows: u32, ) { - self.adjustment_insert_coordinate(&0, &0, row_index, num_rows); - self.adjustment_insert_coordinate_with_sheet(sheet_name, &0, &0, row_index, num_rows); + self.adjustment_insert_coordinate(0, 0, row_index, num_rows); + self.adjustment_insert_coordinate_with_sheet(sheet_name, 0, 0, row_index, num_rows); } /// Insert new columns. @@ -875,14 +871,14 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.insert_new_column("B", &3); /// ``` #[inline] - pub fn insert_new_column(&mut self, column: &str, num_columns: &u32) { + pub fn insert_new_column(&mut self, column: &str, num_columns: u32) { let column_upper = column.to_uppercase(); let column_index = column_index_from_string(column_upper); - self.insert_new_column_by_index(&column_index, num_columns); + self.insert_new_column_by_index(column_index, num_columns); } /// Adjust for references to other sheets. @@ -891,11 +887,11 @@ impl Worksheet { &mut self, sheet_name: &str, column: &str, - num_columns: &u32, + num_columns: u32, ) { let column_upper = column.to_uppercase(); let column_index = column_index_from_string(column_upper); - self.insert_new_column_by_index_from_other_sheet(sheet_name, &column_index, num_columns); + self.insert_new_column_by_index_from_other_sheet(sheet_name, column_index, num_columns); } /// Insert new columns. @@ -905,14 +901,14 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.insert_new_column_by_index(&2, &3); /// ``` #[inline] - pub fn insert_new_column_by_index(&mut self, column_index: &u32, num_columns: &u32) { + pub fn insert_new_column_by_index(&mut self, column_index: u32, num_columns: u32) { let title = &*self.title.clone(); - self.adjustment_insert_coordinate(column_index, num_columns, &0, &0); - self.adjustment_insert_coordinate_with_sheet(title, column_index, num_columns, &0, &0); + self.adjustment_insert_coordinate(column_index, num_columns, 0, 0); + self.adjustment_insert_coordinate_with_sheet(title, column_index, num_columns, 0, 0); } /// Adjust for references to other sheets. @@ -920,11 +916,11 @@ impl Worksheet { pub fn insert_new_column_by_index_from_other_sheet( &mut self, sheet_name: &str, - column_index: &u32, - num_columns: &u32, + column_index: u32, + num_columns: u32, ) { - self.adjustment_insert_coordinate(column_index, num_columns, &0, &0); - self.adjustment_insert_coordinate_with_sheet(sheet_name, column_index, num_columns, &0, &0); + self.adjustment_insert_coordinate(column_index, num_columns, 0, 0); + self.adjustment_insert_coordinate_with_sheet(sheet_name, column_index, num_columns, 0, 0); } /// Remove rows. @@ -934,26 +930,21 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.remove_row(&2, &3); /// ``` #[inline] - pub fn remove_row(&mut self, row_index: &u32, num_rows: &u32) { + pub fn remove_row(&mut self, row_index: u32, num_rows: u32) { let title = &*self.title.clone(); - self.adjustment_remove_coordinate(&0, &0, row_index, num_rows); - self.adjustment_remove_coordinate_with_sheet(title, &0, &0, row_index, num_rows); + self.adjustment_remove_coordinate(0, 0, row_index, num_rows); + self.adjustment_remove_coordinate_with_sheet(title, 0, 0, row_index, num_rows); } /// Adjust for references to other sheets. #[inline] - pub fn remove_row_from_other_sheet( - &mut self, - sheet_name: &str, - row_index: &u32, - num_rows: &u32, - ) { - self.adjustment_remove_coordinate(&0, &0, row_index, num_rows); - self.adjustment_remove_coordinate_with_sheet(sheet_name, &0, &0, row_index, num_rows); + pub fn remove_row_from_other_sheet(&mut self, sheet_name: &str, row_index: u32, num_rows: u32) { + self.adjustment_remove_coordinate(0, 0, row_index, num_rows); + self.adjustment_remove_coordinate_with_sheet(sheet_name, 0, 0, row_index, num_rows); } /// Remove columns. @@ -964,14 +955,14 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.remove_column("B", &3); /// ``` #[inline] - pub fn remove_column(&mut self, column: &str, num_columns: &u32) { + pub fn remove_column(&mut self, column: &str, num_columns: u32) { let column_upper = column.to_uppercase(); let column_index = column_index_from_string(column_upper); - self.remove_column_by_index(&column_index, num_columns); + self.remove_column_by_index(column_index, num_columns); } /// Adjust for references to other sheets. @@ -980,11 +971,11 @@ impl Worksheet { &mut self, sheet_name: &str, column: &str, - num_columns: &u32, + num_columns: u32, ) { let column_upper = column.to_uppercase(); let column_index = column_index_from_string(column_upper); - self.remove_column_by_index_from_other_sheet(sheet_name, &column_index, num_columns); + self.remove_column_by_index_from_other_sheet(sheet_name, column_index, num_columns); } /// Remove columns. @@ -994,14 +985,14 @@ impl Worksheet { /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); - /// let mut worksheet = book.get_sheet_mut(&0).unwrap(); + /// let mut worksheet = book.get_sheet_mut(0).unwrap(); /// worksheet.remove_column_by_index(&2, &3); /// ``` #[inline] - pub fn remove_column_by_index(&mut self, column_index: &u32, num_columns: &u32) { + pub fn remove_column_by_index(&mut self, column_index: u32, num_columns: u32) { let title = &*self.title.clone(); - self.adjustment_remove_coordinate(column_index, num_columns, &0, &0); - self.adjustment_remove_coordinate_with_sheet(title, column_index, num_columns, &0, &0); + self.adjustment_remove_coordinate(column_index, num_columns, 0, 0); + self.adjustment_remove_coordinate_with_sheet(title, column_index, num_columns, 0, 0); } /// Adjust for references to other sheets. @@ -1009,11 +1000,11 @@ impl Worksheet { pub fn remove_column_by_index_from_other_sheet( &mut self, sheet_name: &str, - column_index: &u32, - num_columns: &u32, + column_index: u32, + num_columns: u32, ) { - self.adjustment_remove_coordinate(column_index, num_columns, &0, &0); - self.adjustment_remove_coordinate_with_sheet(sheet_name, column_index, num_columns, &0, &0); + self.adjustment_remove_coordinate(column_index, num_columns, 0, 0); + self.adjustment_remove_coordinate_with_sheet(sheet_name, column_index, num_columns, 0, 0); } /// Get Code Name. @@ -1135,7 +1126,7 @@ impl Worksheet { if row == 0 { return "A1".to_string(); } - let column_str = string_from_column_index(&column); + let column_str = string_from_column_index(column); format!("A1:{}{}", column_str, row) } @@ -1536,7 +1527,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing().get_image(&col, &row) + self.get_worksheet_drawing().get_image(col, row) } #[inline] @@ -1545,11 +1536,11 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing_mut().get_image_mut(&col, &row) + self.get_worksheet_drawing_mut().get_image_mut(col, row) } #[inline] - pub fn get_image_by_column_and_row_mut(&mut self, col: &u32, row: &u32) -> Option<&mut Image> { + pub fn get_image_by_column_and_row_mut(&mut self, col: u32, row: u32) -> Option<&mut Image> { self.get_worksheet_drawing_mut().get_image_mut(col, row) } @@ -1559,7 +1550,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing().get_images(&col, &row) + self.get_worksheet_drawing().get_images(col, row) } #[inline] @@ -1568,7 +1559,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing_mut().get_images_mut(&col, &row) + self.get_worksheet_drawing_mut().get_images_mut(col, row) } /// Outputs all Charts contained in the worksheet. @@ -1599,7 +1590,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing().get_chart(&col, &row) + self.get_worksheet_drawing().get_chart(col, row) } #[inline] @@ -1608,7 +1599,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing_mut().get_chart_mut(&col, &row) + self.get_worksheet_drawing_mut().get_chart_mut(col, row) } #[inline] @@ -1617,7 +1608,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing().get_charts(&col, &row) + self.get_worksheet_drawing().get_charts(col, row) } #[inline] @@ -1626,7 +1617,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_worksheet_drawing_mut().get_charts_mut(&col, &row) + self.get_worksheet_drawing_mut().get_charts_mut(col, row) } /// Outputs all media contained in the worksheet. @@ -1769,8 +1760,8 @@ impl Worksheet { /// 'row' - The number of rows to move by (negative numbers mean move 'left') /// 'column' - the number of columns to move by (negative numbers mean move 'up') #[inline] - pub fn move_range(&mut self, range: &str, row: &i32, column: &i32) -> &mut Self { - self.move_or_copy_range(&range, &row, &column, true) + pub fn move_range(&mut self, range: &str, row: i32, column: i32) -> &mut Self { + self.move_or_copy_range(range, row, column, true) } /// Copying a section of the sheet @@ -1779,8 +1770,8 @@ impl Worksheet { /// 'row' - The number of rows to move by (negative numbers mean move 'left') /// 'column' - the number of columns to move by (negative numbers mean move 'up') #[inline] - pub fn copy_range(&mut self, range: &str, row: &i32, column: &i32) -> &mut Self { - self.move_or_copy_range(&range, &row, &column, false) + pub fn copy_range(&mut self, range: &str, row: i32, column: i32) -> &mut Self { + self.move_or_copy_range(range, row, column, false) } // Moving or copying a section of the sheet @@ -1788,8 +1779,8 @@ impl Worksheet { fn move_or_copy_range( &mut self, range: &str, - row: &i32, - column: &i32, + row: i32, + column: i32, is_move: bool, ) -> &mut Self { // Check to ensure coordinates to move are within range (eg: moving A1 cells to the left is @@ -1811,29 +1802,25 @@ impl Worksheet { // Iterate row by row, collecting cell information (do I copy) let cells = self.cell_collection.get_cell_by_range(range); - let mut copy_cells: Vec = cells - .into_iter() - .flatten() - .map(|cell| cell.clone()) - .collect(); + let mut copy_cells: Vec = cells.into_iter().flatten().cloned().collect(); // Delete cell information as iterating through in move mode if is_move { get_coordinate_list(&range_upper) .iter() .for_each(|(col_num, row_num)| { - self.cell_collection.remove(col_num, row_num); + self.cell_collection.remove(*col_num, *row_num); self.cell_collection.remove( - &((*col_num as i32 + column) as u32), - &((*row_num as i32 + row) as u32), + (*col_num as i32 + column) as u32, + (*row_num as i32 + row) as u32, ); }); } // repaste by setting cell values for cell in &mut copy_cells { - cell.get_coordinate_mut().offset_col_num(*column); - cell.get_coordinate_mut().offset_row_num(*row); + cell.get_coordinate_mut().offset_col_num(column); + cell.get_coordinate_mut().offset_row_num(row); self.set_cell(cell.clone()); } @@ -1847,17 +1834,17 @@ impl Worksheet { pub fn cleanup(&mut self) { let (_, max_row) = self.get_highest_column_and_row(); for row in (1..(max_row + 1)).rev() { - if self.row_dimensions.get_row_dimension(&row).is_some() { + if self.row_dimensions.get_row_dimension(row).is_some() { let mut indexes: Vec<(u32, u32)> = Vec::new(); { - let cells: Vec<&Cell> = self.cell_collection.get_collection_by_row(&row); + let cells: Vec<&Cell> = self.cell_collection.get_collection_by_row(row); for cell in cells { if !cell.is_visually_empty() { return; } indexes.push(( - cell.get_coordinate().get_row_num().clone(), - cell.get_coordinate().get_col_num().clone(), + cell.get_coordinate().get_row_num(), + cell.get_coordinate().get_col_num(), )); } } @@ -1866,7 +1853,7 @@ impl Worksheet { .get_row_dimensions_to_hashmap_mut() .remove(&row); for (i_row, i_col) in indexes { - self.cell_collection.remove(&i_col, &i_row); + self.cell_collection.remove(i_col, i_row); } } } @@ -1890,15 +1877,15 @@ impl Worksheet { #[inline] pub fn copy_row_styling( &mut self, - source_row_no: &u32, - target_row_no: &u32, - start_col: Option<&u32>, - end_col: Option<&u32>, + source_row_no: u32, + target_row_no: u32, + start_col: Option, + end_col: Option, ) { - let mut start_no = start_col.unwrap_or(&1).clone(); - let mut end_no = end_col.unwrap_or(&self.get_highest_column()).clone(); + let start_no = start_col.unwrap_or(1); + let end_no = end_col.unwrap_or(self.get_highest_column()); for col_no in start_no..=end_no { - self.copy_cell_styling((&col_no, source_row_no), (&col_no, target_row_no)); + self.copy_cell_styling((col_no, source_row_no), (col_no, target_row_no)); } } @@ -1911,37 +1898,37 @@ impl Worksheet { #[inline] pub fn copy_col_styling( &mut self, - source_col_no: &u32, - target_col_no: &u32, - start_row: Option<&u32>, - end_row: Option<&u32>, + source_col_no: u32, + target_col_no: u32, + start_row: Option, + end_row: Option, ) { - let mut start_no = start_row.unwrap_or(&1).clone(); - let mut end_no = end_row.unwrap_or(&self.get_highest_row()).clone(); + let start_no = start_row.unwrap_or(1); + let end_no = end_row.unwrap_or(self.get_highest_row()); for row_no in start_no..=end_no { - self.copy_cell_styling((source_col_no, &row_no), (target_col_no, &row_no)); + self.copy_cell_styling((source_col_no, row_no), (target_col_no, row_no)); } } } impl AdjustmentCoordinate for Worksheet { fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - if offset_col_num != &0 { + if offset_col_num != 0 { // column dimensions self.column_dimensions .adjustment_insert_value(root_col_num, offset_col_num); } - if offset_row_num != &0 { + if offset_row_num != 0 { // row dimensions self.get_row_dimensions_crate_mut() .adjustment_insert_value(root_row_num, offset_row_num); } - if (offset_col_num == &0 && offset_row_num == &0) { + if offset_col_num == 0 && offset_row_num == 0 { return; } @@ -2017,22 +2004,22 @@ impl AdjustmentCoordinate for Worksheet { fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - if offset_col_num != &0 { + if offset_col_num != 0 { // column dimensions self.column_dimensions .adjustment_remove_value(root_col_num, offset_col_num); } - if offset_row_num != &0 { + if offset_row_num != 0 { // row dimensions self.get_row_dimensions_crate_mut() .adjustment_remove_value(root_row_num, offset_row_num); } - if (offset_col_num == &0 && offset_row_num == &0) { + if offset_col_num == 0 && offset_row_num == 0 { return; } @@ -2040,7 +2027,7 @@ impl AdjustmentCoordinate for Worksheet { let title = &self.title; self.defined_names.retain(|defined_name| { !defined_name.is_remove_coordinate_with_sheet( - &title, + title, root_col_num, offset_col_num, root_row_num, @@ -2142,12 +2129,12 @@ impl AdjustmentCoordinateWithSheet for Worksheet { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - if (offset_col_num == &0 && offset_row_num == &0) { + if offset_col_num == 0 && offset_row_num == 0 { return; } @@ -2177,12 +2164,12 @@ impl AdjustmentCoordinateWithSheet for Worksheet { fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) { - if (offset_col_num == &0 && offset_row_num == &0) { + if offset_col_num == 0 && offset_row_num == 0 { return; } diff --git a/src/structs/worksheet_source.rs b/src/structs/worksheet_source.rs index e30a043e..326b89c6 100644 --- a/src/structs/worksheet_source.rs +++ b/src/structs/worksheet_source.rs @@ -1,9 +1,8 @@ // worksheetSource -use crate::helper::const_str::*; use crate::reader::driver::*; use crate::structs::Address; use crate::writer::driver::*; -use quick_xml::events::{BytesStart, Event}; +use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; diff --git a/src/structs/writer_manager.rs b/src/structs/writer_manager.rs index e7880af8..3ee97e18 100644 --- a/src/structs/writer_manager.rs +++ b/src/structs/writer_manager.rs @@ -30,8 +30,8 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { } #[inline] - pub fn get_is_light(&self) -> &bool { - &self.is_light + pub fn get_is_light(&self) -> bool { + self.is_light } #[inline] @@ -52,7 +52,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { writer: Writer>>, ) -> Result<(), XlsxError> { if !self.check_file_exist(target) { - make_file_from_writer(target, self.arv, writer, None, &self.is_light)?; + make_file_from_writer(target, self.arv, writer, None, self.is_light)?; self.files.push(target.to_string()); } Ok(()) @@ -61,7 +61,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { #[inline] pub(crate) fn add_bin(&mut self, target: &str, data: &[u8]) -> Result<(), XlsxError> { if !self.check_file_exist(target) { - make_file_from_bin(target, &mut self.arv, data, None, &self.is_light)?; + make_file_from_bin(target, self.arv, data, None, self.is_light)?; self.files.push(target.to_string()); } Ok(()) @@ -69,7 +69,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { #[inline] pub(crate) fn get_arv_mut(&mut self) -> &mut zip::ZipWriter { - &mut self.arv + self.arv } #[inline] @@ -188,7 +188,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { ) -> Result { let file_path = format!("{}/table{}.xml", PKG_TABLES, table_no); self.add_writer(&file_path, writer)?; - return Ok(table_no); + Ok(table_no) } #[inline] @@ -284,7 +284,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { // Override Unsupported if content_type.is_empty() { for (old_part_name, old_content_type) in spreadsheet.get_backup_context_types() { - if &**old_part_name == &file { + if **old_part_name == file { content_type = old_content_type; } } diff --git a/src/traits.rs b/src/traits.rs index 1f11d361..c4bf9d39 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,13 +1,17 @@ //! store structs. mod adjustment_coordinate_with_sheet; +#[allow(unused_imports)] pub use self::adjustment_coordinate_with_sheet::*; mod adjustment_coordinate; +#[allow(unused_imports)] pub use self::adjustment_coordinate::*; mod adjustment_coordinate_with_2sheet; +#[allow(unused_imports)] pub use self::adjustment_coordinate_with_2sheet::*; mod adjustment_value; +#[allow(unused_imports)] pub use self::adjustment_value::*; diff --git a/src/traits/adjustment_coordinate.rs b/src/traits/adjustment_coordinate.rs index 506b0ae0..5189df24 100644 --- a/src/traits/adjustment_coordinate.rs +++ b/src/traits/adjustment_coordinate.rs @@ -1,26 +1,27 @@ pub(crate) trait AdjustmentCoordinate { fn adjustment_insert_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ); fn adjustment_remove_coordinate( &mut self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ); + #[allow(unused_variables)] fn is_remove_coordinate( &self, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { false } diff --git a/src/traits/adjustment_coordinate_with_2sheet.rs b/src/traits/adjustment_coordinate_with_2sheet.rs index 6897793b..7c608787 100644 --- a/src/traits/adjustment_coordinate_with_2sheet.rs +++ b/src/traits/adjustment_coordinate_with_2sheet.rs @@ -3,29 +3,31 @@ pub(crate) trait AdjustmentCoordinateWith2Sheet { &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ); fn adjustment_remove_coordinate_with_2sheet( &mut self, self_sheet_name: &str, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ); + #[allow(dead_code)] + #[allow(unused_variables)] fn is_remove_coordinate_with_2sheet( &self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { false } diff --git a/src/traits/adjustment_coordinate_with_sheet.rs b/src/traits/adjustment_coordinate_with_sheet.rs index 027cecd0..65f749d3 100644 --- a/src/traits/adjustment_coordinate_with_sheet.rs +++ b/src/traits/adjustment_coordinate_with_sheet.rs @@ -2,28 +2,29 @@ pub(crate) trait AdjustmentCoordinateWithSheet { fn adjustment_insert_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ); fn adjustment_remove_coordinate_with_sheet( &mut self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ); + #[allow(unused_variables)] fn is_remove_coordinate_with_sheet( &self, sheet_name: &str, - root_col_num: &u32, - offset_col_num: &u32, - root_row_num: &u32, - offset_row_num: &u32, + root_col_num: u32, + offset_col_num: u32, + root_row_num: u32, + offset_row_num: u32, ) -> bool { false } diff --git a/src/traits/adjustment_value.rs b/src/traits/adjustment_value.rs index 34bf5ee0..755b7920 100644 --- a/src/traits/adjustment_value.rs +++ b/src/traits/adjustment_value.rs @@ -1,9 +1,10 @@ pub(crate) trait AdjustmentValue { - fn adjustment_insert_value(&mut self, root_num: &u32, offset_num: &u32); + fn adjustment_insert_value(&mut self, root_num: u32, offset_num: u32); - fn adjustment_remove_value(&mut self, root_num: &u32, offset_num: &u32); + fn adjustment_remove_value(&mut self, root_num: u32, offset_num: u32); - fn is_remove_value(&self, root_num: &u32, offset_num: &u32) -> bool { + #[allow(unused_variables)] + fn is_remove_value(&self, root_num: u32, offset_num: u32) -> bool { false } } diff --git a/src/writer/csv.rs b/src/writer/csv.rs index 8d97b3e0..110f0517 100644 --- a/src/writer/csv.rs +++ b/src/writer/csv.rs @@ -1,7 +1,6 @@ use std::fs; use std::io; use std::path::Path; -use std::string::FromUtf8Error; use crate::structs::CsvEncodeValues; use crate::structs::CsvWriterOption; @@ -36,7 +35,7 @@ pub fn write_writer( None => String::from(""), }; // do trim. - if *option.get_do_trim() { + if option.get_do_trim() { value = value.trim().to_string(); } // wrap_with_char. @@ -50,7 +49,6 @@ pub fn write_writer( } // encoding. - let res_into: Vec; let data_bytes = match *option.get_csv_encode_value() { CsvEncodeValues::ShiftJis => encoding_rs::SHIFT_JIS.encode(&data).0.into_owned(), CsvEncodeValues::Koi8u => encoding_rs::KOI8_U.encode(&data).0.into_owned(), diff --git a/src/writer/driver.rs b/src/writer/driver.rs index 45c5ab59..85047dfb 100644 --- a/src/writer/driver.rs +++ b/src/writer/driver.rs @@ -19,9 +19,9 @@ pub(crate) fn write_start_tag<'a, S>( elem.extend_attributes(attributes); if empty_flag { - writer.write_event(Event::Empty(elem)); + writer.write_event(Event::Empty(elem)).unwrap(); } else { - writer.write_event(Event::Start(elem)); + writer.write_event(Event::Start(elem)).unwrap(); } } @@ -30,7 +30,9 @@ pub(crate) fn write_end_tag<'a, S>(writer: &mut Writer>>, tag_nam where S: Into>, { - writer.write_event(Event::End(BytesEnd::new(tag_name.into()))); + writer + .write_event(Event::End(BytesEnd::new(tag_name.into()))) + .unwrap(); } #[inline] @@ -38,7 +40,9 @@ pub(crate) fn write_text_node<'a, S>(writer: &mut Writer>>, data: where S: Into>, { - writer.write_event(Event::Text(BytesText::new(&data.into()))); + writer + .write_event(Event::Text(BytesText::new(&data.into()))) + .unwrap(); } #[inline] @@ -46,7 +50,7 @@ pub(crate) fn write_text_node_no_escape<'a, S>(writer: &mut Writer>, { - writer.get_mut().write(data.into().as_bytes()); + writer.get_mut().write_all(data.into().as_bytes()).unwrap(); } #[inline] @@ -70,7 +74,7 @@ pub(crate) fn make_file_from_writer( arv: &mut zip::ZipWriter, writer: Writer>>, dir: Option<&str>, - is_light: &bool, + is_light: bool, ) -> Result<(), io::Error> { make_file_from_bin(path, arv, &writer.into_inner().into_inner(), dir, is_light) } @@ -81,9 +85,9 @@ pub(crate) fn make_file_from_bin( arv: &mut zip::ZipWriter, writer: &[u8], dir: Option<&str>, - is_light: &bool, + is_light: bool, ) -> Result<(), io::Error> { - let zip_opt = if *is_light { + let zip_opt = if is_light { zip::write::SimpleFileOptions::default().compression_method(zip::CompressionMethod::Stored) } else { zip::write::SimpleFileOptions::default().compression_method(zip::CompressionMethod::DEFLATE) diff --git a/src/writer/xlsx.rs b/src/writer/xlsx.rs index 66f78094..345240f3 100644 --- a/src/writer/xlsx.rs +++ b/src/writer/xlsx.rs @@ -3,14 +3,11 @@ use crate::helper::crypt::*; use crate::structs::Spreadsheet; use crate::structs::WriterManager; use crate::XlsxError; -use std::fmt; use std::fs; use std::fs::File; use std::io; use std::io::Read; -use std::io::Write; use std::path::Path; -use std::string::FromUtf8Error; mod chart; mod comment; @@ -67,7 +64,7 @@ fn make_buffer(spreadsheet: &Spreadsheet, is_light: bool) -> Result Result( ) -> Result { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // c:chartSpace diff --git a/src/writer/xlsx/comment.rs b/src/writer/xlsx/comment.rs index 33ca4d9c..b54430f7 100644 --- a/src/writer/xlsx/comment.rs +++ b/src/writer/xlsx/comment.rs @@ -17,11 +17,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // comments diff --git a/src/writer/xlsx/content_types.rs b/src/writer/xlsx/content_types.rs index a46cb986..966b48c5 100644 --- a/src/writer/xlsx/content_types.rs +++ b/src/writer/xlsx/content_types.rs @@ -12,14 +12,16 @@ pub(crate) fn write( spreadsheet: &Spreadsheet, writer_mng: &mut WriterManager, ) -> Result<(), XlsxError> { - let is_light = *writer_mng.get_is_light(); + let is_light = writer_mng.get_is_light(); let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // Types @@ -137,7 +139,7 @@ pub(crate) fn write( writer_mng.get_arv_mut(), writer, None, - &is_light, + is_light, )?; Ok(()) } diff --git a/src/writer/xlsx/doc_props_app.rs b/src/writer/xlsx/doc_props_app.rs index 1298bfdb..ba42457e 100644 --- a/src/writer/xlsx/doc_props_app.rs +++ b/src/writer/xlsx/doc_props_app.rs @@ -14,11 +14,13 @@ pub(crate) fn write( ) -> Result<(), XlsxError> { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // Properties diff --git a/src/writer/xlsx/doc_props_core.rs b/src/writer/xlsx/doc_props_core.rs index 1daf036a..63e7746d 100644 --- a/src/writer/xlsx/doc_props_core.rs +++ b/src/writer/xlsx/doc_props_core.rs @@ -14,11 +14,13 @@ pub(crate) fn write( ) -> Result<(), XlsxError> { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // cp:coreProperties diff --git a/src/writer/xlsx/doc_props_custom.rs b/src/writer/xlsx/doc_props_custom.rs index 459044e9..725f549c 100644 --- a/src/writer/xlsx/doc_props_custom.rs +++ b/src/writer/xlsx/doc_props_custom.rs @@ -23,11 +23,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // Properties diff --git a/src/writer/xlsx/drawing.rs b/src/writer/xlsx/drawing.rs index 325e6d11..43ed52bd 100644 --- a/src/writer/xlsx/drawing.rs +++ b/src/writer/xlsx/drawing.rs @@ -19,11 +19,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); worksheet.get_worksheet_drawing().write_to( diff --git a/src/writer/xlsx/drawing_rels.rs b/src/writer/xlsx/drawing_rels.rs index a32a45fd..9fb72a5e 100644 --- a/src/writer/xlsx/drawing_rels.rs +++ b/src/writer/xlsx/drawing_rels.rs @@ -9,7 +9,7 @@ use crate::structs::Worksheet; use crate::structs::WriterManager; pub(crate) fn write( - worksheet: &Worksheet, + _worksheet: &Worksheet, drawing_no: &str, chart_no_list: &[String], rel_list: &[(String, String)], @@ -19,11 +19,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // relationships @@ -33,7 +35,7 @@ pub(crate) fn write( for chart_no in chart_no_list { is_write = write_relationship( &mut writer, - &r_id, + r_id, CHART_NS, format!("../charts/chart{}.xml", chart_no).as_str(), "", @@ -46,7 +48,7 @@ pub(crate) fn write( if key == "IMAGE" { is_write = write_relationship( &mut writer, - &r_id, + r_id, IMAGE_NS, format!("../media/{}", value).as_str(), "", @@ -65,7 +67,7 @@ pub(crate) fn write( fn write_relationship( writer: &mut Writer>>, - r_id: &i32, + r_id: i32, p_type: &str, p_target: &str, p_target_mode: &str, diff --git a/src/writer/xlsx/rels.rs b/src/writer/xlsx/rels.rs index bc8c59ac..e1fa3d16 100644 --- a/src/writer/xlsx/rels.rs +++ b/src/writer/xlsx/rels.rs @@ -14,11 +14,13 @@ pub(crate) fn write( ) -> Result<(), XlsxError> { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // relationships @@ -34,12 +36,11 @@ pub(crate) fn write( write_relationship(&mut writer, "1", OFCDOC_NS, PKG_WORKBOOK, ""); // relationship docProps/custom.xml - if spreadsheet + if !spreadsheet .get_properties() .get_custom_properties() .get_custom_document_property_list() - .len() - > 0 + .is_empty() { write_relationship(&mut writer, "4", CUSTOM_PROPS_REL, ARC_CUSTOM, ""); } diff --git a/src/writer/xlsx/shared_strings.rs b/src/writer/xlsx/shared_strings.rs index 622535a0..bc2f5adb 100644 --- a/src/writer/xlsx/shared_strings.rs +++ b/src/writer/xlsx/shared_strings.rs @@ -25,11 +25,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); shared_string_table.write().unwrap().write_to(&mut writer); diff --git a/src/writer/xlsx/styles.rs b/src/writer/xlsx/styles.rs index a51e8828..9b9a69a1 100644 --- a/src/writer/xlsx/styles.rs +++ b/src/writer/xlsx/styles.rs @@ -13,11 +13,13 @@ pub(crate) fn write( ) -> Result<(), XlsxError> { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); stylesheet.write_to(&mut writer); diff --git a/src/writer/xlsx/table.rs b/src/writer/xlsx/table.rs index d60c486d..32183c7c 100644 --- a/src/writer/xlsx/table.rs +++ b/src/writer/xlsx/table.rs @@ -17,32 +17,32 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // table area coordinates let area_coords = table.get_area(); - let area = format!( - "{}:{}", - area_coords.0.to_string(), - area_coords.1.to_string() - ); + let area = format!("{}:{}", area_coords.0, area_coords.1); // table start let table_no = writer_mng.next_table_no(); let table_no_str = table_no.to_string(); - let mut attributes: Vec<(&str, &str)> = Vec::new(); - attributes.push(("xmlns", SHEET_MAIN_NS)); - attributes.push(("id", &table_no_str)); - attributes.push(("name", table.get_name())); - attributes.push(("displayName", table.get_display_name())); - attributes.push(("ref", &area)); + let mut attributes = vec![ + ("xmlns", SHEET_MAIN_NS), + ("id", &table_no_str), + ("name", table.get_name()), + ("displayName", table.get_display_name()), + ("ref", &area), + ]; + if table.has_totals_row_shown() { - attributes.push(("totalsRowShown", &table.get_totals_row_shown_str())); + attributes.push(("totalsRowShown", table.get_totals_row_shown_str())); } let totals_row_count_str = table.get_totals_row_count_str(); if table.has_totals_row_count() { diff --git a/src/writer/xlsx/theme.rs b/src/writer/xlsx/theme.rs index 98f1777e..57164a31 100644 --- a/src/writer/xlsx/theme.rs +++ b/src/writer/xlsx/theme.rs @@ -14,11 +14,13 @@ pub(crate) fn write( ) -> Result<(), XlsxError> { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // a:theme diff --git a/src/writer/xlsx/vml_drawing.rs b/src/writer/xlsx/vml_drawing.rs index 8fd4ae12..23707ee5 100644 --- a/src/writer/xlsx/vml_drawing.rs +++ b/src/writer/xlsx/vml_drawing.rs @@ -127,13 +127,11 @@ pub(crate) fn write( write_end_tag(&mut writer, "v:shapetype"); - let mut r_id = 1; for ole_object in worksheet.get_ole_objects().get_ole_object() { // v:shape ole_object .get_shape() - .write_to(&mut writer, &id, &mut rel_list); - r_id += 1; + .write_to(&mut writer, id, &mut rel_list); id += 1; } } @@ -168,9 +166,7 @@ pub(crate) fn write( for comment in worksheet.get_comments() { // v:shape - comment - .get_shape() - .write_to(&mut writer, &id, &mut rel_list); + comment.get_shape().write_to(&mut writer, id, &mut rel_list); id += 1; } } diff --git a/src/writer/xlsx/vml_drawing_rels.rs b/src/writer/xlsx/vml_drawing_rels.rs index ed00e9f3..cf560b4f 100644 --- a/src/writer/xlsx/vml_drawing_rels.rs +++ b/src/writer/xlsx/vml_drawing_rels.rs @@ -9,7 +9,7 @@ use crate::structs::Worksheet; use crate::structs::WriterManager; pub(crate) fn write( - worksheet: &Worksheet, + _worksheet: &Worksheet, vml_drawing_no: &str, rel_list: &[(String, String)], writer_mng: &mut WriterManager, @@ -18,11 +18,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // relationships @@ -33,7 +35,7 @@ pub(crate) fn write( if key == "IMAGE" { is_write = write_relationship( &mut writer, - &r_id, + r_id, IMAGE_NS, format!("../media/{}", value).as_str(), "", @@ -53,7 +55,7 @@ pub(crate) fn write( fn write_relationship( writer: &mut Writer>>, - r_id: &i32, + r_id: i32, p_type: &str, p_target: &str, p_target_mode: &str, diff --git a/src/writer/xlsx/workbook.rs b/src/writer/xlsx/workbook.rs index b88c4cf1..31f8ec6a 100644 --- a/src/writer/xlsx/workbook.rs +++ b/src/writer/xlsx/workbook.rs @@ -14,11 +14,13 @@ pub(crate) fn write( ) -> Result<(), XlsxError> { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // workbook @@ -49,7 +51,7 @@ pub(crate) fn write( if spreadsheet.get_has_macros() { attributes.push(( "codeName", - &spreadsheet.get_code_name().unwrap_or("ThisWorkbook"), + spreadsheet.get_code_name().unwrap_or("ThisWorkbook"), )); } write_start_tag(&mut writer, "workbookPr", attributes, true); diff --git a/src/writer/xlsx/workbook_rels.rs b/src/writer/xlsx/workbook_rels.rs index 6e3e3b26..12c39db5 100644 --- a/src/writer/xlsx/workbook_rels.rs +++ b/src/writer/xlsx/workbook_rels.rs @@ -13,14 +13,16 @@ pub(crate) fn write( has_shared_string_table: bool, writer_mng: &mut WriterManager, ) -> Result<(), XlsxError> { - let is_light = *writer_mng.get_is_light(); + let is_light = writer_mng.get_is_light(); let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // relationships @@ -92,7 +94,7 @@ pub(crate) fn write( writer_mng.get_arv_mut(), writer, None, - &is_light, + is_light, )?; Ok(()) } diff --git a/src/writer/xlsx/worksheet.rs b/src/writer/xlsx/worksheet.rs index 2c760891..ad6a1325 100644 --- a/src/writer/xlsx/worksheet.rs +++ b/src/writer/xlsx/worksheet.rs @@ -14,7 +14,7 @@ use std::sync::Arc; use std::sync::RwLock; pub(crate) fn write( - sheet_no: &i32, + sheet_no: i32, worksheet: &Worksheet, shared_string_table: Arc>, stylesheet: &mut Stylesheet, @@ -24,11 +24,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // worksheet @@ -107,17 +109,17 @@ pub(crate) fn write( // row dimensions sort. let mut row_dimensions = worksheet.get_row_dimensions(); - row_dimensions.sort_by(|a, b| a.get_row_num().cmp(b.get_row_num())); + row_dimensions.sort_by_key(|a| a.get_row_num()); // it's faster than get cell collection by row. // cells sort. - let mut cells = worksheet.get_cell_collection_sorted(); + let cells = worksheet.get_cell_collection_sorted(); // make formula shared list - let mut formula_shared_list: HashMap<&u32, (String, Option)> = HashMap::new(); + let mut formula_shared_list: HashMap)> = HashMap::new(); for cell in &cells { if let Some(si) = cell.get_formula_shared_index() { - match formula_shared_list.get(si) { + match formula_shared_list.get(&si) { Some((start_cell, _)) => { formula_shared_list.insert( si, @@ -220,7 +222,7 @@ pub(crate) fn write( let r_id_str = format!("rId{}", &r_id); let mut attributes: Vec<(&str, &str)> = Vec::new(); attributes.push(("ref", &coordition)); - if *hyperlink.get_location() { + if hyperlink.get_location() { attributes.push(("location", hyperlink.get_url())); } else { attributes.push(("r:id", r_id_str.as_str())); @@ -285,7 +287,7 @@ pub(crate) fn write( vec![("count", &tables.len().to_string())], false, ); - for table in worksheet.get_tables().iter() { + for _table in worksheet.get_tables().iter() { let r_id_str = format!("rId{}", &r_id); write_start_tag( &mut writer, @@ -302,16 +304,13 @@ pub(crate) fn write( let ole_id = 1000 + 25; worksheet .get_ole_objects() - .write_to(&mut writer, &r_id, &ole_id); + .write_to(&mut writer, r_id, ole_id); // extLst if worksheet.get_data_validations_2010().is_some() { write_start_tag(&mut writer, "extLst", vec![], false); - match worksheet.get_data_validations_2010() { - Some(v) => { - v.write_to(&mut writer); - } - None => {} + if let Some(v) = worksheet.get_data_validations_2010() { + v.write_to(&mut writer); } write_end_tag(&mut writer, "extLst"); } diff --git a/src/writer/xlsx/worksheet_rels.rs b/src/writer/xlsx/worksheet_rels.rs index 49734573..89897642 100644 --- a/src/writer/xlsx/worksheet_rels.rs +++ b/src/writer/xlsx/worksheet_rels.rs @@ -25,11 +25,13 @@ pub(crate) fn write( let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header - writer.write_event(Event::Decl(BytesDecl::new( - "1.0", - Some("UTF-8"), - Some("yes"), - ))); + writer + .write_event(Event::Decl(BytesDecl::new( + "1.0", + Some("UTF-8"), + Some("yes"), + ))) + .unwrap(); write_new_line(&mut writer); // relationships @@ -39,7 +41,7 @@ pub(crate) fn write( // Write hyperlink relationships for (_, hyperlink) in worksheet.get_hyperlink_collection_to_hashmap() { - if !*hyperlink.get_location() { + if !hyperlink.get_location() { is_write = write_relationship( &mut writer, r_id.to_string().as_str(), diff --git a/tests/integration_test.rs b/tests/integration_test.rs index cbb3e339..d3f0e7c9 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -117,8 +117,8 @@ fn lazy_read_and_wite_no_edit() { let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); let book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); - let cells = book.get_lazy_read_sheet_cells(&0).unwrap(); - assert_eq!("英語", cells.get_cell_value((&5, &12)).get_value()); + let cells = book.get_lazy_read_sheet_cells(0).unwrap(); + assert_eq!("英語", cells.get_cell_value((5, 12)).get_value()); assert_eq!("英語", cells.get_cell_value("E12").get_value()); // writer @@ -128,86 +128,77 @@ fn lazy_read_and_wite_no_edit() { fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { let _ = book - .get_sheet_mut(&0) + .get_sheet_mut(0) .unwrap() .get_cell_mut("A1") .set_value("TEST1"); - let a1_value = book.get_sheet(&0).unwrap().get_value("A1"); + let a1_value = book.get_sheet(0).unwrap().get_value("A1"); assert_eq!("TEST1", a1_value); - let _ = book.get_sheet_mut(&0).unwrap().remove_cell((&1, &1)); - let a1 = book.get_sheet(&0).unwrap().get_cell("A1"); + let _ = book.get_sheet_mut(0).unwrap().remove_cell((1, 1)); + let a1 = book.get_sheet(0).unwrap().get_cell("A1"); assert_eq!(a1, None); - let _ = book.get_sheet_mut(&0).unwrap().remove_cell((&1, &2)); - let a2_value = book.get_sheet(&0).unwrap().get_value("A2"); + let _ = book.get_sheet_mut(0).unwrap().remove_cell((1, 2)); + let a2_value = book.get_sheet(0).unwrap().get_value("A2"); assert_eq!(a2_value, ""); - let b5_value = book.get_sheet(&0).unwrap().get_value("B5"); + let b5_value = book.get_sheet(0).unwrap().get_value("B5"); assert_eq!(" ", b5_value); assert_eq!( "1.0000", - book.get_sheet(&0).unwrap().get_formatted_value((&2, &20)) + book.get_sheet(0).unwrap().get_formatted_value((2, 20)) ); assert_eq!( "$3,333.0000", - book.get_sheet(&0).unwrap().get_formatted_value("B21") + book.get_sheet(0).unwrap().get_formatted_value("B21") ); assert_eq!( "$ 333.00", - book.get_sheet(&0).unwrap().get_formatted_value("B22") + book.get_sheet(0).unwrap().get_formatted_value("B22") ); assert_eq!( "2020å¹´3月", - book.get_sheet(&0).unwrap().get_formatted_value("B23") + book.get_sheet(0).unwrap().get_formatted_value("B23") ); assert_eq!( "2:33 pm", - book.get_sheet(&0).unwrap().get_formatted_value("B24") + book.get_sheet(0).unwrap().get_formatted_value("B24") ); assert_eq!( "5.00%", - book.get_sheet(&0).unwrap().get_formatted_value("B25") - ); - assert_eq!( - "1/2", - book.get_sheet(&0).unwrap().get_formatted_value("B26") + book.get_sheet(0).unwrap().get_formatted_value("B25") ); + assert_eq!("1/2", book.get_sheet(0).unwrap().get_formatted_value("B26")); assert_eq!( "12/15/2020 14:01", - book.get_sheet(&0).unwrap().get_formatted_value("B27") - ); - assert_eq!( - "444", - book.get_sheet(&0).unwrap().get_formatted_value("B28") + book.get_sheet(0).unwrap().get_formatted_value("B27") ); + assert_eq!("444", book.get_sheet(0).unwrap().get_formatted_value("B28")); assert_eq!( "14-Dec-20", - book.get_sheet(&0).unwrap().get_formatted_value("B29") + book.get_sheet(0).unwrap().get_formatted_value("B29") ); assert_eq!( "2020å¹´10月1æ—¥", - book.get_sheet(&0).unwrap().get_formatted_value("B30") + book.get_sheet(0).unwrap().get_formatted_value("B30") ); assert_eq!( "1.2345", - book.get_sheet(&0).unwrap().get_formatted_value("B31") - ); - assert_eq!( - "1.2", - book.get_sheet(&0).unwrap().get_formatted_value("B32") + book.get_sheet(0).unwrap().get_formatted_value("B31") ); + assert_eq!("1.2", book.get_sheet(0).unwrap().get_formatted_value("B32")); assert_eq!( "12,345,675,544.00", - book.get_sheet(&0).unwrap().get_formatted_value("B33") + book.get_sheet(0).unwrap().get_formatted_value("B33") ); assert_eq!( "1.235", - book.get_sheet(&0).unwrap().get_formatted_value("B34") + book.get_sheet(0).unwrap().get_formatted_value("B34") ); - assert_eq!("1", book.get_sheet(&0).unwrap().get_formatted_value("B35")); - assert_eq!("", book.get_sheet(&0).unwrap().get_formatted_value("B36")); + assert_eq!("1", book.get_sheet(0).unwrap().get_formatted_value("B35")); + assert_eq!("", book.get_sheet(0).unwrap().get_formatted_value("B36")); assert_eq!( "123456789012345678", - book.get_sheet(&0).unwrap().get_formatted_value("B37") + book.get_sheet(0).unwrap().get_formatted_value("B37") ); let _ = book @@ -237,7 +228,7 @@ fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { .to_owned(); book.get_sheet_by_name_mut("Sheet5") .unwrap() - .get_row_dimension_mut(&5u32) + .get_row_dimension_mut(5u32) .get_style_mut() .get_fill_mut() .set_pattern_fill(fill); @@ -246,7 +237,7 @@ fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { .to_owned(); book.get_sheet_by_name_mut("Sheet5") .unwrap() - .get_row_dimension_mut(&5u32) + .get_row_dimension_mut(5u32) .get_style_mut() .get_font_mut() .set_color(font_color); @@ -261,7 +252,7 @@ fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { book.get_sheet_by_name_mut("Sheet1") .unwrap() - .get_row_dimension_mut(&3) + .get_row_dimension_mut(3) .set_height(46.0); } @@ -339,25 +330,25 @@ fn lazy_read_and_wite_xlsm_no_edit() { fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { let _ = book - .get_sheet_mut(&0) + .get_sheet_mut(0) .unwrap() .get_cell_mut((1, 1)) .set_value("TEST1"); let a1_value = book - .get_sheet(&0) + .get_sheet(0) .unwrap() - .get_cell((&1, &1)) + .get_cell((1, 1)) .unwrap() .get_value(); assert_eq!("TEST1", a1_value); // copy sheet - let mut clone_sheet = book.get_sheet(&0).unwrap().clone(); + let mut clone_sheet = book.get_sheet(0).unwrap().clone(); clone_sheet.set_name("New Sheet"); let _ = book.add_sheet(clone_sheet); // remove sheet - let mut clone_sheet = book.get_sheet(&0).unwrap().clone(); + let mut clone_sheet = book.get_sheet(0).unwrap().clone(); clone_sheet.set_name("DeletedSheet"); let _ = book.add_sheet(clone_sheet); book.get_sheet_by_name("DeletedSheet").unwrap(); @@ -727,12 +718,12 @@ fn insert_and_remove_cells() { let path = std::path::Path::new("./tests/test_files/aaa_insertCell.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - book.insert_new_row("Sheet1", &2, &3); - book.insert_new_column("Sheet1", "B", &3); - book.insert_new_column_by_index("Sheet1", &2, &3); + book.insert_new_row("Sheet1", 2, 3); + book.insert_new_column("Sheet1", "B", 3); + book.insert_new_column_by_index("Sheet1", 2, 3); - book.remove_row("Sheet1", &6, &2); - book.remove_column_by_index("Sheet1", &6, &2); + book.remove_row("Sheet1", 6, 2); + book.remove_column_by_index("Sheet1", 6, 2); // writer let path = std::path::Path::new("./tests/result_files/bbb_insertCell.xlsx"); @@ -825,7 +816,7 @@ fn new_file_and_edit() { let a1_value = book .get_sheet_by_name("Sheet2") .unwrap() - .get_cell((&2, &2)) + .get_cell((2, 2)) .unwrap() .get_value(); assert_eq!("1", a1_value); @@ -837,7 +828,7 @@ fn new_file_and_edit() { let a1_value = book .get_sheet_by_name("Sheet2") .unwrap() - .get_cell((&2, &2)) + .get_cell((2, 2)) .unwrap() .get_value(); assert_eq!("1", a1_value); @@ -849,7 +840,7 @@ fn new_file_and_edit() { let a1_value = book .get_sheet_by_name("Sheet2") .unwrap() - .get_cell((&3, &3)) + .get_cell((3, 3)) .unwrap() .get_value(); assert_eq!("TRUE", a1_value); @@ -861,7 +852,7 @@ fn new_file_and_edit() { let a1_value = book .get_sheet_by_name("Sheet2") .unwrap() - .get_cell((&3, &3)) + .get_cell((3, 3)) .unwrap() .get_value(); assert_eq!("TRUE", a1_value); @@ -875,7 +866,7 @@ fn new_file_and_edit() { .set_border_style(umya_spreadsheet::Border::BORDER_MEDIUM); book.get_sheet_by_name_mut("Sheet2") .unwrap() - .get_style_mut((&3, &2)) + .get_style_mut((3, 2)) .get_borders_mut() .get_left_mut() .set_border_style(umya_spreadsheet::Border::BORDER_THIN); @@ -1141,16 +1132,16 @@ fn move_range_test() { let column = 4; book.get_sheet_by_name_mut(sheet_name) .unwrap() - .move_range(range, &row, &column); + .move_range(range, row, column); // Checking to ensure cells that move into another cell overwrites it let range_2 = "A14:A14"; book.get_sheet_by_name_mut(sheet_name) .unwrap() - .move_range(range, &row, &column); + .move_range(range, row, column); book.get_sheet_by_name_mut(sheet_name) .unwrap() - .move_range(range_2, &0, &1); + .move_range(range_2, 0, 1); let path = std::path::Path::new("./tests/result_files/bbb_move_range.xlsx"); let _ = umya_spreadsheet::writer::xlsx::write_light(&book, path); @@ -1180,8 +1171,8 @@ fn issue_129() { //dbg!(img.get_two_cell_anchor().is_some()); assert_eq!(img.get_image_name(), "image1.png"); assert_eq!(img.get_coordinate(), "M17"); - assert_eq!(img.get_col(), &12); - assert_eq!(img.get_row(), &16); + assert_eq!(img.get_col(), 12); + assert_eq!(img.get_row(), 16); let path = std::path::Path::new("./tests/result_files/issue_129.xlsx"); let _ = umya_spreadsheet::writer::xlsx::write(&book, path); @@ -1217,7 +1208,7 @@ fn sheetlock_test() { let path = std::path::Path::new("./tests/test_files/sheet_lock.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let mut sheet = book.get_sheet_mut(&2).unwrap(); + let mut sheet = book.get_sheet_mut(2).unwrap(); sheet .get_sheet_protection_mut() .set_password("password") @@ -1244,11 +1235,11 @@ fn issue_147() { let path = std::path::Path::new("./tests/test_files/issue_147.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let from_sheet = book.get_sheet(&0).unwrap(); + let from_sheet = book.get_sheet(0).unwrap(); let source_cell = from_sheet.get_cell((2, 3)).unwrap(); let mut target_cell = source_cell.clone(); - let mut to_sheet = book.get_sheet_mut(&1).unwrap(); + let mut to_sheet = book.get_sheet_mut(1).unwrap(); to_sheet.set_cell(target_cell); let path = std::path::Path::new("./tests/result_files/issue_147.xlsx"); @@ -1291,7 +1282,7 @@ fn issue_172() { numbering_format.set_format_code("dd-mmm-yy"); let mut book = umya_spreadsheet::new_file(); - let mut sheet = book.get_sheet_mut(&0).unwrap(); + let mut sheet = book.get_sheet_mut(0).unwrap(); sheet.get_cell_mut("A1").set_value_number(value); sheet .get_style_mut("A1") @@ -1323,11 +1314,11 @@ fn issue_181() { let path = std::path::Path::new("./tests/test_files/issue_181.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); let mut sheet = book.get_sheet_by_name_mut("LOV").unwrap(); - sheet.remove_row(&2, &1); + sheet.remove_row(2, 1); for (key, row) in sheet.get_row_dimensions_to_hashmap() { assert_eq!(key, &1); - assert_eq!(row.get_row_num(), &1); - assert_eq!(row.get_height(), &35.0); + assert_eq!(row.get_row_num(), 1); + assert_eq!(row.get_height(), 35.0); } let path = std::path::Path::new("./tests/result_files/issue_181.xlsx"); let _ = umya_spreadsheet::writer::xlsx::write(&book, path); @@ -1338,15 +1329,15 @@ fn issue_181_2() { let path = std::path::Path::new("./tests/test_files/issue_181_2.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let shee1: &mut umya_spreadsheet::structs::Worksheet = book.get_sheet_mut(&0).unwrap(); + let shee1: &mut umya_spreadsheet::structs::Worksheet = book.get_sheet_mut(0).unwrap(); let new_row_index = 4; - shee1.insert_new_row(&new_row_index, &5); + shee1.insert_new_row(new_row_index, 5); shee1.get_cell_mut((1, new_row_index)).set_value("123"); let template_row_index = 3; - shee1.remove_row(&template_row_index, &1); + shee1.remove_row(template_row_index, 1); - shee1.remove_column("B", &1); + shee1.remove_column("B", 1); let path = std::path::Path::new("./tests/result_files/issue_181_2.xlsx"); let _ = umya_spreadsheet::writer::xlsx::write(&book, path); @@ -1367,7 +1358,7 @@ fn issue_185() { let path = std::path::Path::new("./tests/test_files/issue_185.xlsx"); let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("A1") .unwrap() @@ -1380,7 +1371,7 @@ fn issue_185() { fn issue_187() { let path = std::path::Path::new("./tests/test_files/issue_187.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let mut sheet = book.get_sheet_mut(&0).unwrap(); + let mut sheet = book.get_sheet_mut(0).unwrap(); let mut cell = sheet.get_cell("C4").unwrap().clone(); cell.set_coordinate("B5"); @@ -1430,7 +1421,7 @@ fn expect_red_indexed_color() { let path = std::path::Path::new("./tests/test_files/red_indexed_color.xlsx"); let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let cell = book.get_sheet(&0).unwrap().get_cell("A1").unwrap(); + let cell = book.get_sheet(0).unwrap().get_cell("A1").unwrap(); let color = cell.get_style().get_font().unwrap().get_color().get_argb(); @@ -1443,12 +1434,12 @@ fn issue_190() { let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); // remove - book.get_sheet_mut(&0).unwrap().remove_column("E", &1); - book.get_sheet_mut(&0).unwrap().remove_row(&4, &1); + book.get_sheet_mut(0).unwrap().remove_column("E", 1); + book.get_sheet_mut(0).unwrap().remove_row(4, 1); // insert - book.get_sheet_mut(&1).unwrap().insert_new_column("E", &1); - book.get_sheet_mut(&1).unwrap().insert_new_row(&4, &1); + book.get_sheet_mut(1).unwrap().insert_new_column("E", 1); + book.get_sheet_mut(1).unwrap().insert_new_row(4, 1); let path = std::path::Path::new("./tests/result_files/issue_190.xlsx"); let _ = umya_spreadsheet::writer::xlsx::write(&book, path); @@ -1458,10 +1449,10 @@ fn issue_190() { fn issue_194() { let path = std::path::Path::new("./tests/test_files/issue_194.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - book.get_sheet_mut(&0).unwrap().insert_new_column("D", &1); + book.get_sheet_mut(0).unwrap().insert_new_column("D", 1); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("B2") .unwrap() @@ -1469,7 +1460,7 @@ fn issue_194() { "SUM(B1)" ); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("C2") .unwrap() @@ -1477,7 +1468,7 @@ fn issue_194() { "SUM(C1)" ); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("E2") .unwrap() @@ -1502,7 +1493,7 @@ fn issue_200() { fn issue_201() { let path = std::path::Path::new("./tests/test_files/issue_201.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let mut cell = book.get_sheet_mut(&0).unwrap().get_cell_mut("B1"); + let mut cell = book.get_sheet_mut(0).unwrap().get_cell_mut("B1"); cell.set_formula_result_default(""); let path = std::path::Path::new("./tests/result_files/issue_201.xlsx"); @@ -1542,7 +1533,7 @@ fn issue_184() { let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); let theme = book.get_theme(); let color = book - .get_sheet(&0) + .get_sheet(0) .unwrap() .get_cell("A1") .unwrap() @@ -1560,7 +1551,7 @@ fn issue_188_4() { let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("H4") .unwrap() @@ -1568,7 +1559,7 @@ fn issue_188_4() { "SUM(B4:G4)" ); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("H5") .unwrap() @@ -1577,10 +1568,10 @@ fn issue_188_4() { ); // remove - book.get_sheet_mut(&0).unwrap().remove_column("E", &1); + book.get_sheet_mut(0).unwrap().remove_column("E", 1); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("G4") .unwrap() @@ -1588,7 +1579,7 @@ fn issue_188_4() { "SUM(B4:F4)" ); assert_eq!( - book.get_sheet(&0) + book.get_sheet(0) .unwrap() .get_cell("G5") .unwrap() @@ -1604,7 +1595,7 @@ fn issue_188_4() { fn issue_210() { let path = std::path::Path::new("./tests/test_files/issue_210.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let sheet = book.get_sheet(&0).unwrap(); + let sheet = book.get_sheet(0).unwrap(); for cell in sheet.get_cell_collection() { if let Some(varA) = cell.get_style().get_alignment() { let horizontal = varA.get_horizontal().get_value_string(); @@ -1668,7 +1659,7 @@ fn issue_184_2() { for (coordinate, result) in data { let color = book - .get_sheet(&0) + .get_sheet(0) .unwrap() .get_cell(coordinate) .unwrap() @@ -1698,7 +1689,7 @@ fn issue_216() { fn issue_217() { let path = std::path::Path::new("./tests/test_files/issue_217.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - book.get_sheet_mut(&2) + book.get_sheet_mut(2) .unwrap() .set_state(umya_spreadsheet::SheetStateValues::Hidden); let path = std::path::Path::new("./tests/result_files/issue_217.xlsx"); @@ -1756,22 +1747,22 @@ fn issue_220() { let path = std::path::Path::new("./tests/test_files/issue_220.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - book.get_sheet_mut(&0) + book.get_sheet_mut(0) .unwrap() .get_cell_mut("A1") .set_value("TEST1"); - book.get_sheet_mut(&0) + book.get_sheet_mut(0) .unwrap() .get_cell_mut("B1") .set_value("TEST1"); - book.get_sheet_mut(&0) + book.get_sheet_mut(0) .unwrap() .get_cell_mut("B2") .set_value("TEST1"); - book.get_sheet_mut(&0) + book.get_sheet_mut(0) .unwrap() .get_cell_mut("A2") .set_value("TEST1"); @@ -1792,7 +1783,7 @@ fn issue_222() { #[test] fn issue_224() { let mut book = umya_spreadsheet::new_file(); - let mut sheet = book.get_sheet_mut(&0).unwrap(); + let mut sheet = book.get_sheet_mut(0).unwrap(); let mut num = NumberingFormat::default(); num.set_format_code("[<1]0;0"); sheet @@ -1824,7 +1815,7 @@ fn issue_227() { #[test] fn issue_230() { let mut wb = new_file(); - let sheet = wb.get_sheet_mut(&0).unwrap(); + let sheet = wb.get_sheet_mut(0).unwrap(); sheet.get_cell_mut("A1").set_value("12"); sheet .get_style_mut("A1") @@ -1847,7 +1838,7 @@ fn issue_233() { let path = std::path::Path::new("./tests/test_files/issue_233.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - // book.get_sheet_mut(&0).unwrap().cleanup(); + // book.get_sheet_mut(0).unwrap().cleanup(); let path = std::path::Path::new("./tests/result_files/issue_233.xlsx"); let _ = umya_spreadsheet::writer::xlsx::write(&book, path); @@ -1857,7 +1848,7 @@ fn issue_233() { fn issue_244() { let path = std::path::Path::new("./tests/test_files/issue_244.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let sheet = book.get_sheet_mut(&0).unwrap(); + let sheet = book.get_sheet_mut(0).unwrap(); let mut comment = Comment::default(); comment.new_comment("B2"); @@ -1880,13 +1871,13 @@ fn issue_244() { fn issue_246() { let path = std::path::Path::new("./tests/test_files/issue_246.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let sheet = book.get_sheet_mut(&0).unwrap(); + let sheet = book.get_sheet_mut(0).unwrap(); - sheet.copy_row_styling(&3, &5, None, None); - sheet.copy_row_styling(&3, &6, Some(&4), Some(&6)); + sheet.copy_row_styling(3, 5, None, None); + sheet.copy_row_styling(3, 6, Some(4), Some(6)); - sheet.copy_col_styling(&10, &12, None, None); - sheet.copy_col_styling(&10, &13, Some(&11), Some(&15)); + sheet.copy_col_styling(10, 12, None, None); + sheet.copy_col_styling(10, 13, Some(11), Some(15)); let path = std::path::Path::new("./tests/result_files/issue_246.xlsx"); let _ = umya_spreadsheet::writer::xlsx::write(&book, path); @@ -1895,7 +1886,7 @@ fn issue_246() { #[test] fn issue_248() { let mut book = new_file(); - let mut sheet = book.get_sheet_mut(&0).unwrap(); + let mut sheet = book.get_sheet_mut(0).unwrap(); sheet .get_sheet_views_mut() .get_sheet_view_list_mut() From 48b864bc3217b84586cdb7787819001118e53e8d Mon Sep 17 00:00:00 2001 From: mxsr Date: Sat, 21 Dec 2024 17:36:42 +0100 Subject: [PATCH 002/167] style: enable more lints --- Cargo.toml | 31 ++ README.md | 8 +- src/helper/address.rs | 9 +- src/helper/binary.rs | 6 +- src/helper/color.rs | 33 +- src/helper/coordinate.rs | 3 + src/helper/crypt.rs | 17 +- src/helper/date.rs | 9 +- src/helper/formula.rs | 126 ++--- src/helper/html.rs | 11 +- src/helper/number_format.rs | 21 +- src/helper/number_format/date_formater.rs | 6 +- src/helper/number_format/fraction_formater.rs | 2 +- src/helper/number_format/number_formater.rs | 18 +- src/helper/range.rs | 6 +- src/helper/string_helper.rs | 2 +- src/lib.rs | 31 +- src/reader/driver.rs | 4 +- src/reader/xlsx.rs | 2 +- src/reader/xlsx/chart.rs | 6 +- src/reader/xlsx/comment.rs | 10 +- src/reader/xlsx/content_types.rs | 8 +- src/reader/xlsx/doc_props_app.rs | 6 +- src/reader/xlsx/doc_props_core.rs | 6 +- src/reader/xlsx/doc_props_custom.rs | 6 +- src/reader/xlsx/drawing.rs | 3 +- src/reader/xlsx/pivot_table.rs | 6 +- src/reader/xlsx/shared_strings.rs | 6 +- src/reader/xlsx/styles.rs | 6 +- src/reader/xlsx/table.rs | 12 +- src/reader/xlsx/theme.rs | 6 +- src/reader/xlsx/vba_project_bin.rs | 8 +- src/reader/xlsx/vml_drawing.rs | 32 +- src/reader/xlsx/workbook.rs | 10 +- src/reader/xlsx/workbook_rels.rs | 10 +- src/reader/xlsx/worksheet.rs | 4 +- src/structs/address.rs | 15 +- src/structs/alignment.rs | 8 +- src/structs/anchor.rs | 8 + src/structs/auto_filter.rs | 1 + src/structs/bold.rs | 5 +- src/structs/border.rs | 7 +- src/structs/borders.rs | 4 +- src/structs/borders_crate.rs | 4 +- src/structs/break.rs | 7 +- src/structs/cache_field.rs | 7 +- src/structs/cache_fields.rs | 5 +- src/structs/cache_source.rs | 8 +- src/structs/cell.rs | 36 +- src/structs/cell_format.rs | 4 +- src/structs/cell_formats.rs | 4 +- src/structs/cell_formula.rs | 34 +- src/structs/cell_raw_value.rs | 4 + src/structs/cell_style.rs | 7 +- src/structs/cell_style_formats.rs | 4 +- src/structs/cell_styles.rs | 4 +- src/structs/cell_value.rs | 9 + src/structs/cells.rs | 23 +- src/structs/chart.rs | 44 +- src/structs/color.rs | 28 +- src/structs/color_scale.rs | 6 +- src/structs/colors.rs | 4 +- src/structs/column.rs | 8 +- src/structs/column_breaks.rs | 5 +- src/structs/column_fields.rs | 5 +- src/structs/column_items.rs | 5 +- src/structs/column_reference.rs | 7 +- src/structs/columns.rs | 35 +- src/structs/comment.rs | 9 +- .../conditional_format_value_object.rs | 6 +- src/structs/conditional_formatting.rs | 6 +- src/structs/conditional_formatting_rule.rs | 29 +- src/structs/coordinate.rs | 7 +- src/structs/csv_writer_option.rs | 3 + .../custom_document_property.rs | 15 +- .../custom_document_property_value.rs | 4 +- src/structs/custom_properties/properties.rs | 7 +- src/structs/data_bar.rs | 6 +- src/structs/data_field.rs | 8 +- src/structs/data_fields.rs | 5 +- src/structs/data_validation.rs | 14 +- src/structs/data_validations.rs | 5 +- src/structs/defined_name.rs | 17 +- src/structs/differential_format.rs | 4 +- src/structs/differential_formats.rs | 4 +- src/structs/drawing/adjust_value_list.rs | 5 +- src/structs/drawing/alpha.rs | 5 +- src/structs/drawing/background_color.rs | 5 +- .../drawing/background_fill_style_list.rs | 6 +- src/structs/drawing/bevel.rs | 2 +- src/structs/drawing/bevel_bottom.rs | 7 +- src/structs/drawing/bevel_top.rs | 7 +- src/structs/drawing/blip.rs | 10 +- src/structs/drawing/blip_fill.rs | 10 +- src/structs/drawing/body_properties.rs | 14 +- src/structs/drawing/camera.rs | 6 +- src/structs/drawing/charts/area_3d_chart.rs | 9 +- src/structs/drawing/charts/area_chart.rs | 9 +- .../drawing/charts/area_chart_series.rs | 17 +- .../drawing/charts/area_chart_series_list.rs | 1 + src/structs/drawing/charts/auto_labeled.rs | 5 +- .../drawing/charts/auto_title_deleted.rs | 5 +- src/structs/drawing/charts/axis_id.rs | 5 +- src/structs/drawing/charts/axis_position.rs | 5 +- src/structs/drawing/charts/back_wall.rs | 6 +- src/structs/drawing/charts/bar_3d_chart.rs | 12 +- src/structs/drawing/charts/bar_chart.rs | 12 +- src/structs/drawing/charts/bar_direction.rs | 5 +- src/structs/drawing/charts/bubble_3d.rs | 5 +- src/structs/drawing/charts/bubble_chart.rs | 10 +- src/structs/drawing/charts/bubble_scale.rs | 5 +- src/structs/drawing/charts/bubble_size.rs | 5 +- src/structs/drawing/charts/category_axis.rs | 19 +- .../drawing/charts/category_axis_data.rs | 6 +- src/structs/drawing/charts/chart.rs | 13 +- src/structs/drawing/charts/chart_space.rs | 11 +- src/structs/drawing/charts/chart_text.rs | 3 +- src/structs/drawing/charts/cross_between.rs | 5 +- src/structs/drawing/charts/crosses.rs | 5 +- src/structs/drawing/charts/crossing_axis.rs | 5 +- src/structs/drawing/charts/data_labels.rs | 12 +- src/structs/drawing/charts/date1904.rs | 5 +- src/structs/drawing/charts/delete.rs | 5 +- .../drawing/charts/display_blanks_as.rs | 5 +- src/structs/drawing/charts/doughnut_chart.rs | 9 +- .../drawing/charts/editing_language.rs | 5 +- src/structs/drawing/charts/explosion.rs | 5 +- .../drawing/charts/first_slice_angle.rs | 5 +- src/structs/drawing/charts/floor.rs | 6 +- src/structs/drawing/charts/format_code.rs | 3 +- src/structs/drawing/charts/formula.rs | 6 +- src/structs/drawing/charts/gap_width.rs | 5 +- src/structs/drawing/charts/grouping.rs | 5 +- src/structs/drawing/charts/header_footer.rs | 2 +- src/structs/drawing/charts/height.rs | 5 +- src/structs/drawing/charts/height_mode.rs | 5 +- src/structs/drawing/charts/hole_size.rs | 5 +- src/structs/drawing/charts/index.rs | 5 +- .../drawing/charts/invert_if_negative.rs | 5 +- src/structs/drawing/charts/label_alignment.rs | 5 +- src/structs/drawing/charts/label_offset.rs | 5 +- src/structs/drawing/charts/layout.rs | 4 +- src/structs/drawing/charts/layout_target.rs | 5 +- src/structs/drawing/charts/left.rs | 5 +- src/structs/drawing/charts/left_mode.rs | 5 +- src/structs/drawing/charts/legend.rs | 7 +- src/structs/drawing/charts/legend_position.rs | 5 +- src/structs/drawing/charts/line_3d_chart.rs | 9 +- src/structs/drawing/charts/line_chart.rs | 9 +- src/structs/drawing/charts/major_gridlines.rs | 5 +- src/structs/drawing/charts/major_tick_mark.rs | 5 +- src/structs/drawing/charts/manual_layout.rs | 12 +- src/structs/drawing/charts/marker.rs | 5 +- src/structs/drawing/charts/minor_tick_mark.rs | 5 +- .../drawing/charts/no_multi_level_labels.rs | 5 +- .../drawing/charts/number_reference.rs | 4 +- src/structs/drawing/charts/numbering_cache.rs | 3 +- .../drawing/charts/numbering_format.rs | 6 +- src/structs/drawing/charts/numeric_value.rs | 3 +- src/structs/drawing/charts/of_pie_chart.rs | 11 +- src/structs/drawing/charts/of_pie_type.rs | 5 +- src/structs/drawing/charts/order.rs | 5 +- src/structs/drawing/charts/orientation.rs | 5 +- src/structs/drawing/charts/overlap.rs | 5 +- src/structs/drawing/charts/overlay.rs | 5 +- src/structs/drawing/charts/page_margins.rs | 10 +- src/structs/drawing/charts/page_setup.rs | 2 +- src/structs/drawing/charts/perspective.rs | 5 +- src/structs/drawing/charts/pie_3d_chart.rs | 7 +- src/structs/drawing/charts/pie_chart.rs | 8 +- src/structs/drawing/charts/plot_area.rs | 20 +- .../drawing/charts/plot_visible_only.rs | 5 +- src/structs/drawing/charts/print_settings.rs | 7 +- src/structs/drawing/charts/radar_chart.rs | 9 +- src/structs/drawing/charts/radar_style.rs | 5 +- src/structs/drawing/charts/rich_text.rs | 5 +- .../drawing/charts/right_angle_axes.rs | 5 +- src/structs/drawing/charts/rotate_x.rs | 5 +- src/structs/drawing/charts/rotate_y.rs | 5 +- src/structs/drawing/charts/rounded_corners.rs | 5 +- src/structs/drawing/charts/scaling.rs | 5 +- src/structs/drawing/charts/scatter_chart.rs | 9 +- src/structs/drawing/charts/scatter_style.rs | 5 +- src/structs/drawing/charts/second_pie_size.rs | 5 +- src/structs/drawing/charts/series_axis.rs | 15 +- src/structs/drawing/charts/series_lines.rs | 2 +- src/structs/drawing/charts/series_text.rs | 5 +- src/structs/drawing/charts/shape.rs | 5 +- .../drawing/charts/shape_properties.rs | 13 +- .../drawing/charts/show_bubble_size.rs | 5 +- .../drawing/charts/show_category_name.rs | 5 +- .../charts/show_data_labels_over_maximum.rs | 5 +- .../drawing/charts/show_leader_lines.rs | 5 +- src/structs/drawing/charts/show_legend_key.rs | 5 +- src/structs/drawing/charts/show_marker.rs | 5 +- .../drawing/charts/show_negative_bubbles.rs | 5 +- src/structs/drawing/charts/show_percent.rs | 5 +- .../drawing/charts/show_series_name.rs | 5 +- src/structs/drawing/charts/show_value.rs | 5 +- src/structs/drawing/charts/side_wall.rs | 6 +- src/structs/drawing/charts/smooth.rs | 5 +- src/structs/drawing/charts/string_cache.rs | 4 +- src/structs/drawing/charts/string_literal.rs | 5 +- src/structs/drawing/charts/string_point.rs | 3 +- .../drawing/charts/string_reference.rs | 4 +- src/structs/drawing/charts/style.rs | 5 +- src/structs/drawing/charts/symbol.rs | 5 +- src/structs/drawing/charts/text_properties.rs | 7 +- src/structs/drawing/charts/thickness.rs | 5 +- .../drawing/charts/tick_label_position.rs | 5 +- src/structs/drawing/charts/title.rs | 5 +- src/structs/drawing/charts/top.rs | 5 +- src/structs/drawing/charts/top_mode.rs | 5 +- src/structs/drawing/charts/value_axis.rs | 19 +- src/structs/drawing/charts/values.rs | 3 +- src/structs/drawing/charts/vary_colors.rs | 5 +- src/structs/drawing/charts/view_3d.rs | 8 +- src/structs/drawing/charts/width.rs | 5 +- src/structs/drawing/charts/width_mode.rs | 5 +- src/structs/drawing/charts/x_values.rs | 5 +- src/structs/drawing/charts/y_values.rs | 5 +- src/structs/drawing/color2_type.rs | 9 +- src/structs/drawing/color_scheme.rs | 18 +- src/structs/drawing/effect_list.rs | 7 +- src/structs/drawing/effect_style.rs | 7 +- src/structs/drawing/effect_style_list.rs | 5 +- src/structs/drawing/end_connection.rs | 6 +- src/structs/drawing/extension_list.rs | 2 +- src/structs/drawing/extents.rs | 6 +- src/structs/drawing/fill_rectangle.rs | 6 +- src/structs/drawing/fill_style_list.rs | 6 +- src/structs/drawing/font_collection_type.rs | 10 +- src/structs/drawing/font_scheme.rs | 7 +- src/structs/drawing/foreground_color.rs | 5 +- src/structs/drawing/format_scheme.rs | 9 +- src/structs/drawing/glow.rs | 6 +- src/structs/drawing/gradient_fill.rs | 9 +- src/structs/drawing/gradient_stop.rs | 7 +- src/structs/drawing/gradient_stop_list.rs | 5 +- src/structs/drawing/graphic.rs | 5 +- src/structs/drawing/graphic_data.rs | 9 +- src/structs/drawing/group_shape_locks.rs | 5 +- src/structs/drawing/light_rig.rs | 7 +- src/structs/drawing/line_spacing.rs | 5 +- src/structs/drawing/line_style_list.rs | 5 +- src/structs/drawing/linear_gradient_fill.rs | 6 +- src/structs/drawing/list_style.rs | 5 +- src/structs/drawing/miter.rs | 5 +- src/structs/drawing/no_fill.rs | 2 +- src/structs/drawing/offset.rs | 6 +- src/structs/drawing/outer_shadow.rs | 14 +- src/structs/drawing/outline.rs | 16 +- src/structs/drawing/paragraph.rs | 7 +- src/structs/drawing/paragraph_properties.rs | 12 +- src/structs/drawing/pattern_fill.rs | 7 +- src/structs/drawing/percentage_type.rs | 15 +- src/structs/drawing/picture_locks.rs | 5 +- src/structs/drawing/point_2d_type.rs | 6 +- .../drawing/positive_fixed_percentage_type.rs | 11 +- src/structs/drawing/positive_size_2d_type.rs | 6 +- src/structs/drawing/preset_color.rs | 8 +- src/structs/drawing/preset_dash.rs | 5 +- src/structs/drawing/preset_geometry.rs | 6 +- src/structs/drawing/rgb_color_model_hex.rs | 13 +- src/structs/drawing/rotation.rs | 7 +- src/structs/drawing/round.rs | 2 +- src/structs/drawing/run.rs | 6 +- src/structs/drawing/run_properties.rs | 39 +- src/structs/drawing/scene_3d_type.rs | 6 +- src/structs/drawing/scheme_color.rs | 13 +- src/structs/drawing/shape_3d_type.rs | 11 +- src/structs/drawing/shape_auto_fit.rs | 2 +- src/structs/drawing/shape_guide.rs | 4 +- src/structs/drawing/soft_edge.rs | 5 +- src/structs/drawing/solid_fill.rs | 6 +- src/structs/drawing/source_rectangle.rs | 16 +- src/structs/drawing/space_after.rs | 5 +- src/structs/drawing/space_before.rs | 5 +- src/structs/drawing/spacing_percent.rs | 5 +- src/structs/drawing/spreadsheet/blip_fill.rs | 10 +- .../drawing/spreadsheet/connection_shape.rs | 8 +- src/structs/drawing/spreadsheet/extent.rs | 6 +- .../drawing/spreadsheet/graphic_frame.rs | 8 +- .../drawing/spreadsheet/group_shape.rs | 8 +- .../spreadsheet/group_shape_properties.rs | 5 +- .../drawing/spreadsheet/marker_type.rs | 14 +- .../non_visual_connection_shape_properties.rs | 6 +- ...sual_connector_shape_drawing_properties.rs | 6 +- .../non_visual_drawing_properties.rs | 9 +- ...visual_graphic_frame_drawing_properties.rs | 2 +- .../non_visual_graphic_frame_properties.rs | 6 +- ...n_visual_group_shape_drawing_properties.rs | 5 +- .../non_visual_group_shape_properties.rs | 6 +- .../non_visual_picture_drawing_properties.rs | 6 +- .../non_visual_picture_properties.rs | 6 +- .../non_visual_shape_properties.rs | 5 +- .../drawing/spreadsheet/one_cell_anchor.rs | 9 +- src/structs/drawing/spreadsheet/picture.rs | 7 +- src/structs/drawing/spreadsheet/shape.rs | 9 +- .../drawing/spreadsheet/shape_properties.rs | 12 +- .../drawing/spreadsheet/shape_style.rs | 8 +- src/structs/drawing/spreadsheet/text_body.rs | 7 +- src/structs/drawing/spreadsheet/transform.rs | 9 +- .../drawing/spreadsheet/two_cell_anchor.rs | 19 +- .../drawing/spreadsheet/worksheet_drawing.rs | 19 +- src/structs/drawing/start_connection.rs | 6 +- src/structs/drawing/stretch.rs | 5 +- .../drawing/style_matrix_reference_type.rs | 6 +- src/structs/drawing/supplemental_font.rs | 6 +- src/structs/drawing/system_color.rs | 6 +- src/structs/drawing/tail_end.rs | 7 +- src/structs/drawing/text_font_type.rs | 8 +- .../drawing/text_paragraph_properties_type.rs | 30 +- src/structs/drawing/theme.rs | 8 +- src/structs/drawing/theme_elements.rs | 7 +- src/structs/drawing/tile_rectangle.rs | 2 +- src/structs/drawing/transform2d.rs | 17 +- src/structs/embedded_object_properties.rs | 12 +- src/structs/error.rs | 10 +- src/structs/field.rs | 5 +- src/structs/fill.rs | 6 +- src/structs/fills.rs | 4 +- src/structs/font.rs | 22 +- src/structs/font_char_set.rs | 5 +- src/structs/font_family_numbering.rs | 5 +- src/structs/font_name.rs | 5 +- src/structs/font_scheme.rs | 5 +- src/structs/font_size.rs | 5 +- src/structs/fonts.rs | 4 +- src/structs/formula.rs | 8 +- src/structs/from_marker.rs | 10 +- src/structs/gradient_fill.rs | 8 +- src/structs/gradient_stop.rs | 6 +- src/structs/header_footer.rs | 6 +- src/structs/hyperlink.rs | 3 + src/structs/icon_set.rs | 6 +- src/structs/image.rs | 19 +- src/structs/italic.rs | 5 +- src/structs/location.rs | 8 +- src/structs/media_object.rs | 11 +- src/structs/member_property_index.rs | 5 +- src/structs/merge_cells.rs | 12 +- src/structs/mru_colors.rs | 4 +- src/structs/numbering_format.rs | 12 +- src/structs/numbering_formats.rs | 12 +- src/structs/object_anchor.rs | 7 +- src/structs/odd_footer.rs | 5 +- src/structs/odd_header.rs | 5 +- src/structs/office/excel/formula.rs | 5 +- .../office/excel/reference_sequence.rs | 8 +- .../office2010/drawing/charts/style.rs | 6 +- .../office2010/excel/data_validation.rs | 18 +- .../excel/data_validation_forumla1.rs | 3 +- .../excel/data_validation_forumla2.rs | 3 +- .../office2010/excel/data_validations.rs | 7 +- src/structs/ole_object.rs | 17 +- src/structs/ole_objects.rs | 5 +- src/structs/page_margins.rs | 10 +- src/structs/page_setup.rs | 14 +- src/structs/pane.rs | 9 +- src/structs/pattern_fill.rs | 10 +- src/structs/phonetic_run.rs | 2 +- src/structs/pivot_cache_definition.rs | 15 +- src/structs/pivot_field.rs | 6 +- src/structs/pivot_fields.rs | 5 +- src/structs/pivot_table.rs | 2 + src/structs/pivot_table_definition.rs | 32 +- src/structs/pivot_table_style.rs | 10 +- src/structs/print_options.rs | 6 +- src/structs/properties.rs | 30 +- src/structs/protection.rs | 5 +- src/structs/range.rs | 11 +- src/structs/raw.rs | 2 +- src/structs/raw/raw_file.rs | 6 +- src/structs/raw/raw_relationship.rs | 6 +- src/structs/raw/raw_relationships.rs | 14 +- src/structs/raw/raw_worksheet.rs | 6 +- src/structs/rich_text.rs | 10 +- src/structs/row.rs | 13 +- src/structs/row_breaks.rs | 5 +- src/structs/row_item.rs | 8 +- src/structs/row_items.rs | 5 +- src/structs/row_reference.rs | 7 +- src/structs/selection.rs | 9 +- src/structs/sequence_of_references.rs | 4 +- src/structs/shared_items.rs | 10 +- src/structs/shared_string_item.rs | 8 +- src/structs/shared_string_table.rs | 21 +- src/structs/sheet_format_properties.rs | 13 +- src/structs/sheet_protection.rs | 27 +- src/structs/sheet_view.rs | 17 +- src/structs/sheet_views.rs | 5 +- src/structs/spreadsheet.rs | 33 +- src/structs/strike.rs | 5 +- src/structs/style.rs | 10 + src/structs/stylesheet.rs | 6 +- src/structs/table.rs | 24 +- src/structs/text.rs | 4 +- src/structs/text_element.rs | 7 +- src/structs/to_marker.rs | 8 +- src/structs/underline.rs | 7 +- src/structs/vertical_text_alignment.rs | 5 +- src/structs/vml/fill.rs | 13 +- src/structs/vml/image_data.rs | 10 +- src/structs/vml/path.rs | 5 +- src/structs/vml/shadow.rs | 7 +- src/structs/vml/shape.rs | 23 +- src/structs/vml/spreadsheet/anchor.rs | 18 +- src/structs/vml/spreadsheet/auto_fill.rs | 5 +- .../vml/spreadsheet/auto_size_picture.rs | 5 +- src/structs/vml/spreadsheet/client_data.rs | 14 +- .../vml/spreadsheet/clipboard_format.rs | 5 +- .../vml/spreadsheet/comment_column_target.rs | 9 +- .../vml/spreadsheet/comment_row_target.rs | 9 +- .../vml/spreadsheet/move_with_cells.rs | 5 +- .../vml/spreadsheet/resize_with_cells.rs | 5 +- src/structs/vml/spreadsheet/visible.rs | 5 +- src/structs/vml/stroke.rs | 7 +- src/structs/vml/text_box.rs | 20 +- src/structs/workbook_protection.rs | 19 +- src/structs/workbook_view.rs | 7 +- src/structs/worksheet.rs | 152 ++++-- src/structs/worksheet_source.rs | 5 +- src/structs/writer_manager.rs | 31 +- src/writer/csv.rs | 8 +- src/writer/driver.rs | 8 +- src/writer/xlsx.rs | 22 +- src/writer/xlsx/chart.rs | 2 +- src/writer/xlsx/comment.rs | 4 +- src/writer/xlsx/content_types.rs | 6 +- src/writer/xlsx/doc_props_app.rs | 4 +- src/writer/xlsx/doc_props_core.rs | 4 +- src/writer/xlsx/doc_props_custom.rs | 4 +- src/writer/xlsx/drawing.rs | 4 +- src/writer/xlsx/drawing_rels.rs | 12 +- src/writer/xlsx/media.rs | 2 +- src/writer/xlsx/rels.rs | 9 +- src/writer/xlsx/shared_strings.rs | 7 +- src/writer/xlsx/styles.rs | 4 +- src/writer/xlsx/table.rs | 19 +- src/writer/xlsx/theme.rs | 4 +- src/writer/xlsx/vba_project_bin.rs | 2 +- src/writer/xlsx/vml_drawing.rs | 6 +- src/writer/xlsx/vml_drawing_rels.rs | 10 +- src/writer/xlsx/workbook.rs | 8 +- src/writer/xlsx/workbook_rels.rs | 11 +- src/writer/xlsx/worksheet.rs | 10 +- src/writer/xlsx/worksheet_rels.rs | 27 +- tests/integration_test.rs | 464 +++++++++--------- 449 files changed, 2883 insertions(+), 1563 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ab6c07e8..b5d6e81c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,3 +40,34 @@ doctest = false [features] js = ["getrandom/js"] default = ["image"] + +[lints] +workspace = true + +[workspace.lints.rust] +explicit_outlives_requirements = "deny" +let-underscore-drop = "deny" +meta-variable-misuse = "deny" +non_ascii_idents = "deny" +non-local-definitions = "deny" +redundant-imports = "deny" +redundant-lifetimes = "deny" +single-use-lifetimes = "deny" +trivial-casts = "deny" +trivial_numeric_casts = "deny" +unit-bindings = "deny" +unsafe-code = "deny" # Will only be allowed in platform-specific modules +unused-import-braces = "deny" +unused-lifetimes = "deny" +unused-macro-rules = "deny" +unused_qualifications = "deny" +variant_size_differences = "deny" + +[workspace.lints.clippy] +correctness = { level = "deny", priority = -1 } +style = { level = "warn", priority = -1 } +complexity = { level = "warn", priority = -1 } +perf = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +cargo = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } \ No newline at end of file diff --git a/README.md b/README.md index 90c7e279..fe9b9b5f 100644 --- a/README.md +++ b/README.md @@ -77,17 +77,17 @@ let mut book = umya_spreadsheet::new_file(); ### Write file ```rust let path = std::path::Path::new("./tests/result_files/bbb.xlsx"); -let _ = umya_spreadsheet::writer::xlsx::write(&book, path); +let _unused = umya_spreadsheet::writer::xlsx::write(&book, path); ``` ### Write file with password ```rust let path = std::path::Path::new("./tests/result_files/bbb.xlsx"); -let _ = umya_spreadsheet::writer::xlsx::write_with_password(&book, path, "password"); +let _unused = umya_spreadsheet::writer::xlsx::write_with_password(&book, path, "password"); ``` ```rust let from_path = std::path::Path::new("./tests/test_files/aaa.xlsx"); let to_path = std::path::Path::new("./tests/result_files/bbb.xlsx"); -let _ = umya_spreadsheet::writer::xlsx::set_password(&from_path, &to_path, "password"); +let _unused = umya_spreadsheet::writer::xlsx::set_password(&from_path, &to_path, "password"); ``` ### Read Value ```rust @@ -147,7 +147,7 @@ Pass the book as a ```Spreadsheet``` to modify it in other functions. ```rust let mut book = umya_spreadsheet::new_file(); -let _ = book.new_sheet("Sheet2"); +let _unused = book.new_sheet("Sheet2"); update_excel(&mut book); fn update_excel(book: &mut Spreadsheet) { diff --git a/src/helper/address.rs b/src/helper/address.rs index 1189d820..eaf852b7 100644 --- a/src/helper/address.rs +++ b/src/helper/address.rs @@ -1,17 +1,20 @@ use fancy_regex::Regex; +#[must_use] pub fn split_address(address: &str) -> (&str, &str) { address .rsplit_once('!') - .map(|(sheet_name, range)| (sheet_name.trim_matches(&['\'', '"'][..]), range)) - .unwrap_or(("", address)) + .map_or(("", address), |(sheet_name, range)| { + (sheet_name.trim_matches(&['\'', '"'][..]), range) + }) } +#[must_use] pub fn join_address(sheet_name: &str, address: &str) -> String { if sheet_name.is_empty() { return address.to_string(); } - format!("{}!{}", sheet_name, address) + format!("{sheet_name}!{address}") } #[test] diff --git a/src/helper/binary.rs b/src/helper/binary.rs index f067e954..d205ebec 100644 --- a/src/helper/binary.rs +++ b/src/helper/binary.rs @@ -4,6 +4,7 @@ use std::io::BufReader; use std::io::Read; #[inline] +#[must_use] pub fn get_binary_data(path: &str) -> Vec { let path = std::path::Path::new(path); let mut buf = Vec::new(); @@ -14,11 +15,12 @@ pub fn get_binary_data(path: &str) -> Vec { } #[inline] +#[must_use] pub fn make_media_object(path: &str) -> MediaObject { - let name = path.split("/").last().unwrap(); + let name = path.split('/').last().unwrap(); let mut obj = MediaObject::default(); obj.set_image_data(get_binary_data(path)); obj.set_image_name(name); - obj.set_image_title(name.split(".").next().unwrap_or("")); + obj.set_image_title(name.split('.').next().unwrap_or("")); obj } diff --git a/src/helper/color.rs b/src/helper/color.rs index dd140396..121a3d06 100644 --- a/src/helper/color.rs +++ b/src/helper/color.rs @@ -1,5 +1,5 @@ /** - * https://ciintelligence.blogspot.com/2012/02/converting-excel-theme-color-and-tint.html + * */ #[derive(Default, Debug, Clone, PartialEq, PartialOrd)] @@ -19,12 +19,14 @@ pub struct MsHlsColor { const RGBMAX: f64 = 255.0; const HLSMAX: f64 = 255.0; +#[must_use] pub fn calc_tint(rgb: &str, tint: f64) -> String { let mut ms_hls = convert_rgb_to_ms_hls(rgb); - ms_hls.l = calculate_final_lum_value(tint, ms_hls.l as f64); + ms_hls.l = calculate_final_lum_value(tint, f64::from(ms_hls.l)); convert_ms_hls_to_rgb(&ms_hls) } +#[must_use] pub fn calculate_final_lum_value(tint: f64, lum: f64) -> i32 { let lum1 = if tint < 0.0 { lum * (1.0 + tint) @@ -35,6 +37,7 @@ pub fn calculate_final_lum_value(tint: f64, lum: f64) -> i32 { to_i32(lum1) } +#[must_use] pub fn split_rgb(rgb: &str) -> (i32, i32, i32) { let r = i32::from_str_radix(&rgb[0..2], 16).unwrap(); let g = i32::from_str_radix(&rgb[2..4], 16).unwrap(); @@ -43,27 +46,30 @@ pub fn split_rgb(rgb: &str) -> (i32, i32, i32) { } #[inline] +#[must_use] pub fn join_rgb(r: i32, g: i32, b: i32) -> String { - format!("{:02X}{:02X}{:02X}", r, g, b) + format!("{r:02X}{g:02X}{b:02X}") } +#[must_use] pub fn convert_rgb_to_ms_hls(rgb: &str) -> MsHlsColor { let hls = convert_rgb_to_hls(rgb); MsHlsColor { - h: to_i32(hls.h * self::HLSMAX), - l: to_i32(hls.l * self::HLSMAX), - s: to_i32(hls.s * self::HLSMAX), + h: to_i32(hls.h * HLSMAX), + l: to_i32(hls.l * HLSMAX), + s: to_i32(hls.s * HLSMAX), } } +#[must_use] pub fn convert_rgb_to_hls(rgb: &str) -> HlsColor { let mut hls = HlsColor::default(); let (r_i, g_i, b_i) = split_rgb(rgb); - let r = r_i as f64 / RGBMAX; - let g = g_i as f64 / RGBMAX; - let b = b_i as f64 / RGBMAX; + let r = f64::from(r_i) / RGBMAX; + let g = f64::from(g_i) / RGBMAX; + let b = f64::from(b_i) / RGBMAX; let mut min = r; if min > g { @@ -115,15 +121,17 @@ pub fn convert_rgb_to_hls(rgb: &str) -> HlsColor { hls } +#[must_use] pub fn convert_ms_hls_to_rgb(ms_hls: &MsHlsColor) -> String { let hls = HlsColor { - h: (ms_hls.h as f64 / self::HLSMAX), - l: (ms_hls.l as f64 / self::HLSMAX), - s: (ms_hls.s as f64 / self::HLSMAX), + h: (f64::from(ms_hls.h) / HLSMAX), + l: (f64::from(ms_hls.l) / HLSMAX), + s: (f64::from(ms_hls.s) / HLSMAX), }; convert_hls_to_rgb(&hls) } +#[must_use] pub fn convert_hls_to_rgb(hls: &HlsColor) -> String { if hls.s == 0.0 { let rtn_l = to_i32(hls.l * RGBMAX); @@ -151,6 +159,7 @@ pub fn convert_hls_to_rgb(hls: &HlsColor) -> String { join_rgb(rtn_r, rtn_g, rtn_b) } +#[must_use] pub fn set_color(t1: f64, t2: f64, t3: f64) -> f64 { let t3 = positive_decimal_part(t3); diff --git a/src/helper/coordinate.rs b/src/helper/coordinate.rs index 96620bb1..a518f8a7 100644 --- a/src/helper/coordinate.rs +++ b/src/helper/coordinate.rs @@ -53,6 +53,7 @@ pub fn column_index_from_string>(column: S) -> u32 { } #[inline] +#[must_use] pub fn string_from_column_index(column_index: u32) -> String { assert!(column_index >= 1u32, "Column number starts from 1."); @@ -94,10 +95,12 @@ where } #[inline] +#[must_use] pub fn coordinate_from_index(col: u32, row: u32) -> String { format!("{}{}", string_from_column_index(col), row) } +#[must_use] pub fn coordinate_from_index_with_lock( col: u32, row: u32, diff --git a/src/helper/crypt.rs b/src/helper/crypt.rs index 8e90d90c..1560a703 100644 --- a/src/helper/crypt.rs +++ b/src/helper/crypt.rs @@ -1,11 +1,10 @@ -use super::const_str::*; +use super::const_str::{CERTIFICATE_NS, ENCRYPTION_NS, PASSWORD_NS}; use crate::structs::SheetProtection; use crate::structs::WorkbookProtection; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_new_line, write_start_tag}; use aes::cipher::{block_padding::NoPadding, BlockEncryptMut, KeyIvInit}; use base64::{engine::general_purpose::STANDARD, Engine as _}; use byteorder::{ByteOrder, LittleEndian}; -use cfb; use hmac::{Hmac, Mac}; use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; @@ -387,7 +386,7 @@ fn hmac(algorithm: &str, key: &[u8], buffers: Vec<&[u8]>) -> Result, Str HmacSha512::new_from_slice(key).unwrap() } _ => { - return Err(format!("algorithm {} not supported!", algorithm)); + return Err(format!("algorithm {algorithm} not supported!")); } }; mac.update(&buffer_concat(buffers)); @@ -470,7 +469,7 @@ fn hash(algorithm: &str, buffers: Vec<&[u8]>) -> Result, String> { let mut digest = match algorithm { "SHA512" | "SHA-512" => Sha512::new(), _ => { - return Err(format!("algorithm {} not supported!", algorithm)); + return Err(format!("algorithm {algorithm} not supported!")); } }; digest.update(&buffer_concat(buffers)[..]); @@ -633,7 +632,7 @@ fn build_encryption_info( write_end_tag(&mut writer, "keyEncryptors"); write_end_tag(&mut writer, "encryption"); - let result = writer.into_inner().into_inner().to_vec(); + let result = writer.into_inner().into_inner().clone(); buffer_concat(vec![ENCRYPTION_INFO_PREFIX, &result]) } @@ -656,7 +655,7 @@ fn buffer_concat(buffers: Vec<&[u8]>) -> Vec { } fn buffer_copy(buffer1: &mut [u8], buffer2: &[u8]) { for (i, byte) in buffer2.iter().enumerate() { - let _ = std::mem::replace(&mut buffer1[i], *byte); + let _unused = std::mem::replace(&mut buffer1[i], *byte); } } @@ -696,7 +695,7 @@ mod tests { fn test_encrypt() { let mut file = File::open("./tests/test_files/aaa.xlsx").unwrap(); let mut data = Vec::new(); - let _ = file.read_to_end(&mut data).unwrap(); + let _unused = file.read_to_end(&mut data).unwrap(); let password = "password"; @@ -869,7 +868,7 @@ mod tests { //assert_eq!(&converted, "0d9c888111b40b630b739c95a5f5b6be67c8f96acdd1bee185bd808b507f652760a2e77f63a6ad0c46f985f2bb8dab4fcf9b86d6a40d9c21299bb4ddf788b250"); // XML - let _ = build_encryption_info( + let _unused = build_encryption_info( &package_salt_value, package_block_size, package_key_bits, diff --git a/src/helper/date.rs b/src/helper/date.rs index c07066c9..d3d3ec43 100644 --- a/src/helper/date.rs +++ b/src/helper/date.rs @@ -3,6 +3,7 @@ use chrono::{Duration, NaiveDateTime}; pub const CALENDAR_WINDOWS_1900: &str = "1900"; pub const CALENDAR_MAC_1904: &str = "1904"; +#[must_use] pub fn excel_to_date_time_object(excel_timestamp: f64, time_zone: Option) -> NaiveDateTime { let _time_zone = match time_zone { Some(v) => v, @@ -42,6 +43,7 @@ fn get_default_timezone() -> String { } #[inline] +#[must_use] pub fn convert_date( year: i32, month: i32, @@ -54,6 +56,7 @@ pub fn convert_date( } #[inline] +#[must_use] pub fn convert_date_windows_1900( year: i32, month: i32, @@ -66,6 +69,7 @@ pub fn convert_date_windows_1900( } #[inline] +#[must_use] pub fn convert_date_mac_1904( year: i32, month: i32, @@ -77,6 +81,7 @@ pub fn convert_date_mac_1904( convert_date_crate(year, month, day, hours, minutes, seconds, false) } +#[must_use] pub fn convert_date_crate( year: i32, month: i32, @@ -114,8 +119,8 @@ pub fn convert_date_crate( + is_leap_year; // Calculate the time portion of the date - let time_in_days = ((hours * 3600 + minutes * 60 + seconds) as f64) / 86400.0; + let time_in_days = f64::from(hours * 3600 + minutes * 60 + seconds) / 86400.0; // Return the final Excel date and time - julian_date as f64 + time_in_days + f64::from(julian_date) + time_in_days } diff --git a/src/helper/formula.rs b/src/helper/formula.rs index 642aebe7..a3051ef6 100644 --- a/src/helper/formula.rs +++ b/src/helper/formula.rs @@ -1,13 +1,16 @@ -use crate::helper::address::*; -use crate::helper::coordinate::*; -use crate::helper::range::*; +use crate::helper::address::{join_address, split_address}; +use crate::helper::coordinate::{ + adjustment_insert_coordinate, adjustment_remove_coordinate, coordinate_from_index_with_lock, + index_from_coordinate, +}; +use crate::helper::range::{get_join_range, get_split_range}; use crate::structs::StringValue; use fancy_regex::Regex; /** PARTLY BASED ON: */ /** Copyright (c) 2007 E. W. Bachtal, Inc. */ -/** https://ewbi.blogs.com/develops/2007/03/excel_formula_p.html */ -/** https://ewbi.blogs.com/develops/2004/12/excel_formula_p.html */ +/** */ +/** */ #[derive(Clone, Debug, PartialEq)] pub enum FormulaTokenTypes { @@ -57,6 +60,7 @@ impl Default for FormulaToken { } impl FormulaToken { #[inline] + #[must_use] pub fn get_value(&self) -> &str { self.value.get_value_str() } @@ -68,6 +72,7 @@ impl FormulaToken { } #[inline] + #[must_use] pub fn get_token_type(&self) -> &FormulaTokenTypes { &self.token_type } @@ -79,6 +84,7 @@ impl FormulaToken { } #[inline] + #[must_use] pub fn get_token_sub_type(&self) -> &FormulaTokenSubTypes { &self.token_sub_type } @@ -113,7 +119,7 @@ pub const ERRORS: &[&str] = &[ const COMPARATORS_MULTI: &[&str] = &[">=", "<=", "<>"]; lazy_static! { - pub static ref SCIENTIFIC_REGEX: Regex = Regex::new(r#"/^[1-9]{1}(\\.\\d+)?E{1}$/"#).unwrap(); + pub static ref SCIENTIFIC_REGEX: Regex = Regex::new(r"/^[1-9]{1}(\\.\\d+)?E{1}$/").unwrap(); } pub(crate) fn parse_to_tokens>(formula: S) -> Vec { @@ -136,18 +142,18 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec let mut in_error = false; let mut index = 1; - let mut value = String::from(""); + let mut value = String::new(); while index < formula_length { // double-quoted strings // embeds are doubled // end marks token if in_string { - if formula.chars().nth(index).unwrap() == self::QUOTE_DOUBLE { + if formula.chars().nth(index).unwrap() == QUOTE_DOUBLE { if ((index + 2) <= formula_length) - && (formula.chars().nth(index + 1).unwrap() == self::QUOTE_DOUBLE) + && (formula.chars().nth(index + 1).unwrap() == QUOTE_DOUBLE) { - value = format!("{}{}", value, self::QUOTE_DOUBLE); + value = format!("{value}{QUOTE_DOUBLE}"); index += 1; } else { in_string = false; @@ -156,7 +162,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec obj.set_token_type(FormulaTokenTypes::Operand); obj.set_token_sub_type(FormulaTokenSubTypes::Text); tokens1.push(obj); - value = String::from(""); + value = String::new(); } } else { value = format!("{}{}", value, formula.chars().nth(index).unwrap()); @@ -170,11 +176,11 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // embeds are double // end does not mark a token if in_path { - if formula.chars().nth(index).unwrap() == self::QUOTE_SINGLE { + if formula.chars().nth(index).unwrap() == QUOTE_SINGLE { if ((index + 2) <= formula_length) - && (formula.chars().nth(index + 1).unwrap() == self::QUOTE_SINGLE) + && (formula.chars().nth(index + 1).unwrap() == QUOTE_SINGLE) { - value = format!("{}{}", value, self::QUOTE_SINGLE); + value = format!("{value}{QUOTE_SINGLE}"); index += 1; } else { in_path = false; @@ -191,7 +197,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // no embeds (changed to "()" by Excel) // end does not mark a token if in_range { - if formula.chars().nth(index).unwrap() == self::BRACKET_CLOSE { + if formula.chars().nth(index).unwrap() == BRACKET_CLOSE { in_range = false; } value = format!("{}{}", value, formula.chars().nth(index).unwrap()); @@ -204,14 +210,14 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec if in_error { value = format!("{}{}", value, formula.chars().nth(index).unwrap()); index += 1; - if self::ERRORS.iter().any(|&x| x == value.as_str()) { + if ERRORS.iter().any(|&x| x == value.as_str()) { in_error = false; let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); obj.set_token_sub_type(FormulaTokenSubTypes::Error); tokens1.push(obj); - value = String::from(""); + value = String::new(); } continue; @@ -219,7 +225,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // scientific notation check if let Some(current_char) = formula.chars().nth(index) { - if self::OPERATORS_SN.contains(current_char) + if OPERATORS_SN.contains(current_char) && value.len() > 1 && SCIENTIFIC_REGEX .is_match(¤t_char.to_string()) @@ -234,14 +240,14 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec // independent character evaluation (order not important) // establish state-dependent character evaluations - if formula.chars().nth(index).unwrap() == self::QUOTE_DOUBLE { + if formula.chars().nth(index).unwrap() == QUOTE_DOUBLE { if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Unknown); tokens1.push(obj); - value = String::from(""); + value = String::new(); } in_string = true; index += 1; @@ -249,14 +255,14 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec continue; } - if formula.chars().nth(index).unwrap() == self::QUOTE_SINGLE { + if formula.chars().nth(index).unwrap() == QUOTE_SINGLE { if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Unknown); tokens1.push(obj); - value = String::from(""); + value = String::new(); } in_string = true; index += 1; @@ -264,39 +270,39 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec continue; } - if formula.chars().nth(index).unwrap() == self::BRACKET_OPEN { + if formula.chars().nth(index).unwrap() == BRACKET_OPEN { in_range = true; - value = format!("{}{}", value, self::BRACKET_OPEN); + value = format!("{value}{BRACKET_OPEN}"); index += 1; continue; } - if formula.chars().nth(index).unwrap() == self::ERROR_START { + if formula.chars().nth(index).unwrap() == ERROR_START { if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Unknown); tokens1.push(obj); - value = String::from(""); + value = String::new(); } in_error = true; - value = format!("{}{}", value, self::ERROR_START); + value = format!("{value}{ERROR_START}"); index += 1; continue; } // mark start and end of arrays and array rows - if formula.chars().nth(index).unwrap() == self::BRACE_OPEN { + if formula.chars().nth(index).unwrap() == BRACE_OPEN { if !value.is_empty() { // unexpected let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Unknown); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = FormulaToken::default(); @@ -318,13 +324,13 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec continue; } - if formula.chars().nth(index).unwrap() == self::SEMICOLON { + if formula.chars().nth(index).unwrap() == SEMICOLON { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = stack.pop().unwrap(); @@ -349,13 +355,13 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec continue; } - if formula.chars().nth(index).unwrap() == self::BRACE_CLOSE { + if formula.chars().nth(index).unwrap() == BRACE_CLOSE { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = stack.pop().unwrap().clone(); @@ -374,22 +380,20 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // trim white-space - if formula.chars().nth(index).unwrap() == self::WHITESPACE { + if formula.chars().nth(index).unwrap() == WHITESPACE { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = FormulaToken::default(); obj.set_value(""); obj.set_token_type(FormulaTokenTypes::Whitespace); tokens1.push(obj); index += 1; - while (formula.chars().nth(index).unwrap() == self::WHITESPACE) - && (index < formula_length) - { + while (formula.chars().nth(index).unwrap() == WHITESPACE) && (index < formula_length) { index += 1; } @@ -407,7 +411,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = FormulaToken::default(); obj.set_value(formula.chars().skip(index).take(2).collect::()); @@ -420,13 +424,13 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // standard infix operators - if self::OPERATORS_INFIX.contains(formula.chars().nth(index).unwrap()) { + if OPERATORS_INFIX.contains(formula.chars().nth(index).unwrap()) { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = FormulaToken::default(); obj.set_value(formula.chars().nth(index).unwrap()); @@ -438,13 +442,13 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // standard postfix operators (only one) - if self::OPERATORS_POSTFIX.contains(formula.chars().nth(index).unwrap()) { + if OPERATORS_POSTFIX.contains(formula.chars().nth(index).unwrap()) { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = FormulaToken::default(); obj.set_value(formula.chars().nth(index).unwrap()); @@ -456,7 +460,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // start subexpression or function - if formula.chars().nth(index).unwrap() == self::PAREN_OPEN { + if formula.chars().nth(index).unwrap() == PAREN_OPEN { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); @@ -464,7 +468,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec obj.set_token_sub_type(FormulaTokenSubTypes::Start); tokens1.push(obj.clone()); stack.push(obj); - value = String::from(""); + value = String::new(); } else { let mut obj = FormulaToken::default(); obj.set_value(""); @@ -479,13 +483,13 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // function, subexpression, or array parameters, or operand unions - if formula.chars().nth(index).unwrap() == self::COMMA { + if formula.chars().nth(index).unwrap() == COMMA { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = stack.pop().unwrap(); @@ -511,13 +515,13 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } // stop subexpression - if formula.chars().nth(index).unwrap() == self::PAREN_CLOSE { + if formula.chars().nth(index).unwrap() == PAREN_CLOSE { if !value.is_empty() { let mut obj = FormulaToken::default(); obj.set_value(value); obj.set_token_type(FormulaTokenTypes::Operand); tokens1.push(obj); - value = String::from(""); + value = String::new(); } let mut obj = stack.pop().unwrap(); @@ -615,7 +619,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec obj.set_token_type(FormulaTokenTypes::OperatorInfix); obj.set_token_sub_type(FormulaTokenSubTypes::Intersection); tokens2.push(obj); - value = String::from(""); + value = String::new(); } // move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators @@ -737,35 +741,35 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec } pub(crate) fn render(formula_token_list: &[FormulaToken]) -> String { - let mut result = String::from(""); + let mut result = String::new(); for token in formula_token_list { if token.get_token_type() == &FormulaTokenTypes::Function && token.get_token_sub_type() == &FormulaTokenSubTypes::Start { result = format!("{}{}", result, token.get_value()); - result = format!("{}{}", result, self::PAREN_OPEN); + result = format!("{result}{PAREN_OPEN}"); } else if token.get_token_type() == &FormulaTokenTypes::Function && token.get_token_sub_type() == &FormulaTokenSubTypes::Stop { - result = format!("{}{}", result, self::PAREN_CLOSE); + result = format!("{result}{PAREN_CLOSE}"); } else if token.get_token_type() == &FormulaTokenTypes::Subexpression && token.get_token_sub_type() == &FormulaTokenSubTypes::Start { - result = format!("{}{}", result, self::PAREN_OPEN); + result = format!("{result}{PAREN_OPEN}"); } else if token.get_token_type() == &FormulaTokenTypes::Subexpression && token.get_token_sub_type() == &FormulaTokenSubTypes::Stop { - result = format!("{}{}", result, self::PAREN_CLOSE); + result = format!("{result}{PAREN_CLOSE}"); } else if token.get_token_type() == &FormulaTokenTypes::Operand && token.get_token_sub_type() == &FormulaTokenSubTypes::Text { - result = format!("{}{}", result, self::QUOTE_DOUBLE); + result = format!("{result}{QUOTE_DOUBLE}"); result = format!("{}{}", result, token.get_value()); - result = format!("{}{}", result, self::QUOTE_DOUBLE); + result = format!("{result}{QUOTE_DOUBLE}"); } else if token.get_token_type() == &FormulaTokenTypes::OperatorInfix && token.get_token_sub_type() == &FormulaTokenSubTypes::Intersection { - result = format!("{}{}", result, self::WHITESPACE); + result = format!("{result}{WHITESPACE}"); } else { result = format!("{}{}", result, token.get_value()); } @@ -815,7 +819,7 @@ pub fn adjustment_formula_coordinate( coordinate_from_index_with_lock(col_num, row_num, is_lock_col, is_lock_row); coordinate_list_new.push(new_corrdinate); } else { - coordinate_list_new.push(coordinate.to_string()); + coordinate_list_new.push((*coordinate).to_string()); } } if has_error { @@ -874,7 +878,7 @@ pub fn adjustment_insert_formula_coordinate( ); coordinate_list_new.push(new_corrdinate); } else { - coordinate_list_new.push(coordinate.to_string()); + coordinate_list_new.push((*coordinate).to_string()); } } let new_value = join_address(sheet_name, &get_join_range(&coordinate_list_new)); @@ -930,7 +934,7 @@ pub fn adjustment_remove_formula_coordinate( ); coordinate_list_new.push(new_corrdinate); } else { - coordinate_list_new.push(coordinate.to_string()); + coordinate_list_new.push((*coordinate).to_string()); } } let new_value = join_address(sheet_name, &get_join_range(&coordinate_list_new)); diff --git a/src/helper/html.rs b/src/helper/html.rs index 5ea25a92..2ad3239a 100644 --- a/src/helper/html.rs +++ b/src/helper/html.rs @@ -86,7 +86,7 @@ fn read_node(node_list: &Vec, parent_element: &[HfdElement]) -> ThinVec bool { self.name == name } #[inline] + #[must_use] pub fn get_by_name_and_attribute(&self, name: &str, attribute: &str) -> Option<&str> { self.attributes .get(attribute) .and_then(|v| (self.name == name).then_some(v)) - .map(|x| x.as_str()) + .map(String::as_str) } #[inline] + #[must_use] pub fn contains_class(&self, class: &str) -> bool { self.classes.contains(&class.to_string()) } @@ -239,7 +242,7 @@ impl AnalysisMethod for DataAnalysis { html_flat_data .element .iter() - .flat_map(|element| element.get_by_name_and_attribute("font", "color")) + .filter_map(|element| element.get_by_name_and_attribute("font", "color")) .find_map(|v| { let color = v.trim_start_matches('#').to_uppercase(); COLOR_MAP @@ -813,5 +816,5 @@ const COLOR_MAP: &[(&str, &str)] = &[ #[test] fn convert_test() { let html = r#"test
TEST
TEST
"#; - let _ = html_to_richtext(html).unwrap(); + let _unused = html_to_richtext(html).unwrap(); } diff --git a/src/helper/number_format.rs b/src/helper/number_format.rs index 6458ec8d..1d80afcd 100644 --- a/src/helper/number_format.rs +++ b/src/helper/number_format.rs @@ -16,6 +16,7 @@ pub struct Split<'r, 't> { } #[inline] +#[must_use] pub fn split<'r, 't>(regex: &'r Regex, text: &'t str) -> Split<'r, 't> { Split { finder: regex.find_iter(text), @@ -128,18 +129,18 @@ fn split_format(sections: Vec<&str>, value: f64) -> (String, String, String) { let cond_re = Regex::new(cond_regex).unwrap(); let mut colors = [ - String::from(""), - String::from(""), - String::from(""), - String::from(""), - String::from(""), + String::new(), + String::new(), + String::new(), + String::new(), + String::new(), ]; let mut condops = [ - String::from(""), - String::from(""), - String::from(""), - String::from(""), - String::from(""), + String::new(), + String::new(), + String::new(), + String::new(), + String::new(), ]; let mut condvals = [ String::from("0"), diff --git a/src/helper/number_format/date_formater.rs b/src/helper/number_format/date_formater.rs index 383df289..c5d1d5e7 100644 --- a/src/helper/number_format/date_formater.rs +++ b/src/helper/number_format/date_formater.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::helper::date::*; +use crate::helper::date::excel_to_date_time_object; use fancy_regex::Captures; use fancy_regex::Regex; @@ -61,7 +61,7 @@ pub(crate) fn format_as_date(value: f64, format: &str) -> Cow { // language info is in hexadecimal // strip off chinese part like [DBNum1][$-804] let re = Regex::new(r"^(\[[0-9A-Za-z]*\])*(\[\$[A-Z]*-[0-9A-F]*\])").unwrap(); - let format = re.replace_all(&format, r#""#); + let format = re.replace_all(&format, r""); // OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case; // but we don't want to change any quoted strings @@ -102,7 +102,7 @@ pub(crate) fn format_as_date(value: f64, format: &str) -> Cow { converted_blocks.push(block); i += 1; } - format = Cow::Owned(converted_blocks.join(r#""#)); + format = Cow::Owned(converted_blocks.join(r"")); // escape any quoted characters so that DateTime format() will render them correctly let re = Regex::new(r#""(.*)""#).unwrap(); diff --git a/src/helper/number_format/fraction_formater.rs b/src/helper/number_format/fraction_formater.rs index 34ac7ea0..48db0cfa 100644 --- a/src/helper/number_format/fraction_formater.rs +++ b/src/helper/number_format/fraction_formater.rs @@ -42,7 +42,7 @@ pub(crate) fn format_as_fraction(value: f64, format: &str) -> String { if check_format == "? ?" { let mut integer_part_str = integer_part.to_string(); if integer_part == 0f64 { - integer_part_str = String::from(""); + integer_part_str = String::new(); } result = format!( "{}{} {}/{}", diff --git a/src/helper/number_format/number_formater.rs b/src/helper/number_format/number_formater.rs index c9631166..7b84fac8 100644 --- a/src/helper/number_format/number_formater.rs +++ b/src/helper/number_format/number_formater.rs @@ -1,12 +1,12 @@ -use super::fraction_formater::*; +use super::fraction_formater::format_as_fraction; use fancy_regex::Regex; use std::borrow::Cow; use thousands::Separable; pub(crate) fn format_as_number(value: f64, format: &str) -> Cow { lazy_static! { - static ref THOUSANDS_SEP_REGEX: Regex = Regex::new(r#"(#,#|0,0)"#).unwrap(); - static ref SCALE_REGEX: Regex = Regex::new(r#"(#|0)(,+)"#).unwrap(); + static ref THOUSANDS_SEP_REGEX: Regex = Regex::new(r"(#,#|0,0)").unwrap(); + static ref SCALE_REGEX: Regex = Regex::new(r"(#|0)(,+)").unwrap(); static ref TRAILING_COMMA_REGEX: Regex = Regex::new("(#|0),+").unwrap(); static ref FRACTION_REGEX: Regex = Regex::new(r"#?.*\?{1,2}\/\?{1,2}").unwrap(); static ref SQUARE_BRACKET_REGEX: Regex = Regex::new(r"\[[^\]]+\]").unwrap(); @@ -45,10 +45,10 @@ pub(crate) fn format_as_number(value: f64, format: &str) -> Cow { for ite in SCALE_REGEX.captures(&format).ok().flatten().unwrap().iter() { matches.push(ite.unwrap().as_str().to_string()); } - scale = 1000i32.pow(matches[2].len() as u32) as f64; + scale = f64::from(1000i32.pow(matches[2].len() as u32)); // strip the commas - format = TRAILING_COMMA_REGEX.replace_all(&format, "$1").into() + format = TRAILING_COMMA_REGEX.replace_all(&format, "$1").into(); } if FRACTION_REGEX.is_match(&format).unwrap_or(false) { if value.parse::().is_err() { @@ -117,9 +117,9 @@ fn format_straight_numeric_value( value = value.parse::().unwrap().separate_with_commas(); } let blocks: Vec<&str> = value.split('.').collect(); - let left_value = blocks.first().unwrap().to_string(); + let left_value = (*blocks.first().unwrap()).to_string(); let mut right_value = match blocks.get(1) { - Some(v) => v.to_string(), + Some(v) => (*v).to_string(), None => String::from("0"), }; if right.is_empty() { @@ -141,7 +141,7 @@ fn format_straight_numeric_value( right_value = right_value_conv; } } - value = format!("{}.{}", left_value, right_value); + value = format!("{left_value}.{right_value}"); value // if use_thousands == true { @@ -189,7 +189,7 @@ fn merge_complex_number_format_masks(numbers: &[String], masks: &[String]) -> Ve fn process_complex_number_format_mask(number: f64, mask: &str) -> String { let mut result = number.to_string(); let mut mask = mask.to_string(); - let re = Regex::new(r#"0+"#).unwrap(); + let re = Regex::new(r"0+").unwrap(); let mut masking_blocks: Vec<(String, usize)> = Vec::new(); let mut masking_str: Vec = Vec::new(); let mut masking_beg: Vec = Vec::new(); diff --git a/src/helper/range.rs b/src/helper/range.rs index 24e29eed..de7c9cee 100644 --- a/src/helper/range.rs +++ b/src/helper/range.rs @@ -1,10 +1,11 @@ -use crate::helper::coordinate::*; +use crate::helper::coordinate::index_from_coordinate; /// `(col, row)` pub type BasicCellIndex = (u32, u32); /// # Returns /// `Vec<(col, row)>` +#[must_use] pub fn get_coordinate_list(range_str: &str) -> Vec { let (row_start, row_end, col_start, col_end) = get_start_and_end_point(range_str); @@ -13,6 +14,7 @@ pub fn get_coordinate_list(range_str: &str) -> Vec { .collect() } +#[must_use] pub fn get_start_and_end_point(range_str: &str) -> (u32, u32, u32, u32) { let coordinate_collection: Vec<&str> = range_str.split(':').collect(); @@ -65,11 +67,13 @@ pub fn get_start_and_end_point(range_str: &str) -> (u32, u32, u32, u32) { } #[inline] +#[must_use] pub fn get_split_range(range: &str) -> Vec<&str> { range.split(':').collect() } #[inline] +#[must_use] pub fn get_join_range(coordinate_list: &[String]) -> String { coordinate_list.join(":") } diff --git a/src/helper/string_helper.rs b/src/helper/string_helper.rs index f35830f8..b10b51c4 100644 --- a/src/helper/string_helper.rs +++ b/src/helper/string_helper.rs @@ -1,6 +1,6 @@ #[inline] pub(crate) fn _get_currency_code() -> String { - String::from("") + String::new() } #[inline] diff --git a/src/lib.rs b/src/lib.rs index 8f58c107..7b377c3b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ //! let mut book = new_file(); //! //! // new worksheet -//! let _ = book.new_sheet("Sheet2"); +//! let _unused = book.new_sheet("Sheet2"); //! ``` //! ### Copy worksheet //! ```rust @@ -31,13 +31,13 @@ //! //! let mut clone_sheet = book.get_sheet(0).unwrap().clone(); //! clone_sheet.set_name("New Sheet"); -//! let _ = book.add_sheet(clone_sheet); +//! let _unused = book.add_sheet(clone_sheet); //! ``` //! ### Change value //! ```rust //! use umya_spreadsheet::*; //! let mut book = new_file(); -//! let _ = book.new_sheet("Sheet2"); +//! let _unused = book.new_sheet("Sheet2"); //! //! // change value //! book.get_sheet_by_name_mut("Sheet2").unwrap().get_cell_mut("A1").set_value("TEST1"); @@ -52,7 +52,7 @@ //! ```rust //! use umya_spreadsheet::*; //! let mut book = new_file(); -//! let _ = book.new_sheet("Sheet2"); +//! let _unused = book.new_sheet("Sheet2"); //! book.get_sheet_by_name_mut("Sheet2").unwrap().get_cell_mut("A1").set_value("TEST1"); //! //! // read value @@ -68,7 +68,7 @@ //! ```rust //! use umya_spreadsheet::*; //! let mut book = new_file(); -//! let _ = book.new_sheet("Sheet2"); +//! let _unused = book.new_sheet("Sheet2"); //! //! // add bottom border //! book.get_sheet_by_name_mut("Sheet2").unwrap() @@ -109,16 +109,13 @@ //! ```rust //! use umya_spreadsheet::*; //! let mut book = new_file(); -//! let _ = book.new_sheet("Sheet2"); +//! let _unused = book.new_sheet("Sheet2"); //! //! // writer //! let path = std::path::Path::new("C:/spread_test_data/ccc.xlsx"); -//! let _ = writer::xlsx::write(&book, path); +//! let _unused = writer::xlsx::write(&book, path); //! ``` -#![deny(clippy::correctness)] -#![warn(clippy::style, clippy::complexity, clippy::perf, clippy::trivially_copy_pass_by_ref)] - extern crate chrono; extern crate fancy_regex; #[cfg(feature = "image")] @@ -158,9 +155,10 @@ pub use self::structs::*; /// ``` /// let mut book = umya_spreadsheet::new_file(); /// ``` -pub fn new_file() -> structs::Spreadsheet { - let mut spreadsheet = structs::Spreadsheet::default(); - spreadsheet.set_theme(structs::drawing::Theme::get_default_value()); +#[must_use] +pub fn new_file() -> Spreadsheet { + let mut spreadsheet = Spreadsheet::default(); + spreadsheet.set_theme(drawing::Theme::get_default_value()); spreadsheet.set_stylesheet_defalut_value(); let worksheet = spreadsheet.new_sheet("Sheet1").unwrap(); worksheet.set_active_cell("A1"); @@ -184,9 +182,10 @@ pub fn new_file() -> structs::Spreadsheet { /// ``` /// let mut book = umya_spreadsheet::new_file_empty_worksheet(); /// ``` -pub fn new_file_empty_worksheet() -> structs::Spreadsheet { - let mut spreadsheet = structs::Spreadsheet::default(); - spreadsheet.set_theme(structs::drawing::Theme::get_default_value()); +#[must_use] +pub fn new_file_empty_worksheet() -> Spreadsheet { + let mut spreadsheet = Spreadsheet::default(); + spreadsheet.set_theme(drawing::Theme::get_default_value()); spreadsheet.set_stylesheet_defalut_value(); spreadsheet } diff --git a/src/reader/driver.rs b/src/reader/driver.rs index 6f41b3f1..ffbf1105 100644 --- a/src/reader/driver.rs +++ b/src/reader/driver.rs @@ -38,7 +38,7 @@ pub(crate) use crate::set_string_from_xml; pub(crate) fn normalize_path(path: &str) -> PathBuf { let path = Path::new(path); let mut components = path.components().peekable(); - let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() { + let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() { components.next(); PathBuf::from(c.as_os_str()) } else { @@ -67,7 +67,7 @@ pub(crate) fn normalize_path(path: &str) -> PathBuf { pub(crate) fn join_paths(base_path: &str, target: &str) -> String { match target.split_once('/') { Some(("", target)) => normalize_path_to_str(target), - _ => normalize_path_to_str(&format!("{}/{}", base_path, target)), + _ => normalize_path_to_str(&format!("{base_path}/{target}")), } } diff --git a/src/reader/xlsx.rs b/src/reader/xlsx.rs index fe110411..0a1462e6 100644 --- a/src/reader/xlsx.rs +++ b/src/reader/xlsx.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use std::sync::RwLock; use super::driver; -use crate::helper::const_str::*; +use crate::helper::const_str::{COMMENTS_NS, DRAWINGS_NS, TABLE_NS, THEME_NS, VML_DRAWING_NS}; use crate::structs::drawing::Theme; use crate::structs::raw::RawWorksheet; use crate::structs::SharedStringTable; diff --git a/src/reader/xlsx/chart.rs b/src/reader/xlsx/chart.rs index 2d47ba74..638df392 100644 --- a/src/reader/xlsx/chart.rs +++ b/src/reader/xlsx/chart.rs @@ -4,12 +4,8 @@ use crate::structs::raw::RawFile; use crate::xml_read_loop; use quick_xml::events::Event; use quick_xml::Reader; -use std::result; -pub(crate) fn read( - raw_file: &RawFile, - chart_space: &mut ChartSpace, -) -> result::Result<(), XlsxError> { +pub(crate) fn read(raw_file: &RawFile, chart_space: &mut ChartSpace) -> Result<(), XlsxError> { let data = std::io::Cursor::new(raw_file.get_file_data()); let mut reader = Reader::from_reader(data); diff --git a/src/reader/xlsx/comment.rs b/src/reader/xlsx/comment.rs index 7145e3a8..3b471b27 100644 --- a/src/reader/xlsx/comment.rs +++ b/src/reader/xlsx/comment.rs @@ -5,23 +5,19 @@ use crate::structs::Worksheet; use crate::xml_read_loop; use quick_xml::events::Event; use quick_xml::Reader; -use std::result; -pub(crate) fn read( - worksheet: &mut Worksheet, - drawing_file: &RawFile, -) -> result::Result<(), XlsxError> { +pub(crate) fn read(worksheet: &mut Worksheet, drawing_file: &RawFile) -> Result<(), XlsxError> { let data = std::io::Cursor::new(drawing_file.get_file_data()); let mut reader = Reader::from_reader(data); reader.config_mut().trim_text(false); let mut authors: Vec = Vec::new(); - let mut value: String = String::from(""); + let mut value: String = String::new(); xml_read_loop!( reader, Event::Empty(ref e) => { if e.name().into_inner() == b"author" { - authors.push(String::from("")); + authors.push(String::new()); } }, Event::Start(ref e) => { diff --git a/src/reader/xlsx/content_types.rs b/src/reader/xlsx/content_types.rs index 197261ac..c0ee4f06 100644 --- a/src/reader/xlsx/content_types.rs +++ b/src/reader/xlsx/content_types.rs @@ -1,15 +1,15 @@ -use super::driver::*; +use super::driver::{get_attribute, xml_read_loop}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::CONTENT_TYPES; use crate::structs::Spreadsheet; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; pub(crate) fn read( arv: &mut zip::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let r = io::BufReader::new(arv.by_name(CONTENT_TYPES)?); let mut reader = Reader::from_reader(r); reader.config_mut().trim_text(true); diff --git a/src/reader/xlsx/doc_props_app.rs b/src/reader/xlsx/doc_props_app.rs index ad8a9263..0b1acb74 100644 --- a/src/reader/xlsx/doc_props_app.rs +++ b/src/reader/xlsx/doc_props_app.rs @@ -1,15 +1,15 @@ use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::ARC_APP; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; use crate::structs::Spreadsheet; pub(crate) fn read( arv: &mut zip::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let r = io::BufReader::new(match arv.by_name(ARC_APP) { Ok(v) => v, Err(zip::result::ZipError::FileNotFound) => { diff --git a/src/reader/xlsx/doc_props_core.rs b/src/reader/xlsx/doc_props_core.rs index 37bdd699..2781b0ad 100644 --- a/src/reader/xlsx/doc_props_core.rs +++ b/src/reader/xlsx/doc_props_core.rs @@ -1,15 +1,15 @@ use super::XlsxError; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; -use crate::helper::const_str::*; +use crate::helper::const_str::ARC_CORE; use crate::structs::Spreadsheet; pub(crate) fn read( arv: &mut zip::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let r = io::BufReader::new(match arv.by_name(ARC_CORE) { Ok(v) => v, Err(zip::result::ZipError::FileNotFound) => { diff --git a/src/reader/xlsx/doc_props_custom.rs b/src/reader/xlsx/doc_props_custom.rs index 28d3e184..81cc9dcf 100644 --- a/src/reader/xlsx/doc_props_custom.rs +++ b/src/reader/xlsx/doc_props_custom.rs @@ -1,15 +1,15 @@ use super::XlsxError; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; -use crate::helper::const_str::*; +use crate::helper::const_str::ARC_CUSTOM; use crate::structs::Spreadsheet; pub(crate) fn read( arv: &mut zip::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let r = io::BufReader::new(match arv.by_name(ARC_CUSTOM) { Ok(v) => v, Err(zip::result::ZipError::FileNotFound) => { diff --git a/src/reader/xlsx/drawing.rs b/src/reader/xlsx/drawing.rs index 107a3185..bacee034 100644 --- a/src/reader/xlsx/drawing.rs +++ b/src/reader/xlsx/drawing.rs @@ -6,13 +6,12 @@ use crate::structs::raw::RawRelationships; use crate::structs::Worksheet; use quick_xml::events::Event; use quick_xml::Reader; -use std::result; pub(crate) fn read( worksheet: &mut Worksheet, drawing_file: &RawFile, drawing_relationships: Option<&RawRelationships>, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let data = std::io::Cursor::new(drawing_file.get_file_data()); let mut reader = Reader::from_reader(data); reader.config_mut().trim_text(true); diff --git a/src/reader/xlsx/pivot_table.rs b/src/reader/xlsx/pivot_table.rs index 38f71b69..b8cd4bdd 100644 --- a/src/reader/xlsx/pivot_table.rs +++ b/src/reader/xlsx/pivot_table.rs @@ -5,13 +5,9 @@ use crate::structs::PivotTableDefinition; use crate::structs::Worksheet; use quick_xml::events::Event; use quick_xml::Reader; -use std::result; #[allow(dead_code)] -pub(crate) fn read( - worksheet: &mut Worksheet, - pivot_table_file: &RawFile, -) -> result::Result<(), XlsxError> { +pub(crate) fn read(worksheet: &mut Worksheet, pivot_table_file: &RawFile) -> Result<(), XlsxError> { let data = std::io::Cursor::new(pivot_table_file.get_file_data()); let mut reader = Reader::from_reader(data); reader.config_mut().trim_text(false); diff --git a/src/reader/xlsx/shared_strings.rs b/src/reader/xlsx/shared_strings.rs index 03ea1e8e..474d94a4 100644 --- a/src/reader/xlsx/shared_strings.rs +++ b/src/reader/xlsx/shared_strings.rs @@ -1,17 +1,17 @@ use crate::xml_read_loop; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_SHARED_STRINGS; use crate::structs::SharedStringTable; use crate::structs::Spreadsheet; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; pub(crate) fn read( arv: &mut zip::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let r = io::BufReader::new(match arv.by_name(PKG_SHARED_STRINGS) { Ok(v) => v, Err(zip::result::ZipError::FileNotFound) => { diff --git a/src/reader/xlsx/styles.rs b/src/reader/xlsx/styles.rs index 57918213..e8f53a2e 100644 --- a/src/reader/xlsx/styles.rs +++ b/src/reader/xlsx/styles.rs @@ -1,17 +1,17 @@ use crate::xml_read_loop; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_STYLES; use crate::structs::Spreadsheet; use crate::structs::Stylesheet; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; pub fn read( arv: &mut zip::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let r = io::BufReader::new(arv.by_name(PKG_STYLES)?); let mut reader = Reader::from_reader(r); reader.config_mut().trim_text(true); diff --git a/src/reader/xlsx/table.rs b/src/reader/xlsx/table.rs index e530ed93..a6a72125 100644 --- a/src/reader/xlsx/table.rs +++ b/src/reader/xlsx/table.rs @@ -1,23 +1,19 @@ -use super::driver::*; +use super::driver::get_attribute_value; use super::XlsxError; use crate::structs::raw::RawFile; use crate::structs::Worksheet; use crate::structs::{Table, TableColumn, TableStyleInfo}; use quick_xml::events::Event; use quick_xml::Reader; -use std::result; -pub(crate) fn read( - worksheet: &mut Worksheet, - table_file: &RawFile, -) -> result::Result<(), XlsxError> { +pub(crate) fn read(worksheet: &mut Worksheet, table_file: &RawFile) -> Result<(), XlsxError> { let data = std::io::Cursor::new(table_file.get_file_data()); let mut reader = Reader::from_reader(data); reader.config_mut().trim_text(false); let mut buf = Vec::new(); let mut table = Table::default(); let mut table_column = TableColumn::default(); - let mut string_value = String::from(""); + let mut string_value = String::new(); loop { match reader.read_event_into(&mut buf) { Ok(Event::Empty(ref e)) => match e.name().into_inner() { @@ -138,7 +134,7 @@ pub(crate) fn read( Ok(Event::End(ref e)) => match e.name().into_inner() { b"calculatedColumnFormula" => { table_column.set_calculated_column_formula(string_value); - string_value = String::from(""); + string_value = String::new(); } b"tableColumn" => { // add column to table (if it has a name) diff --git a/src/reader/xlsx/theme.rs b/src/reader/xlsx/theme.rs index 0fd302ff..0d067f87 100644 --- a/src/reader/xlsx/theme.rs +++ b/src/reader/xlsx/theme.rs @@ -3,13 +3,13 @@ use crate::structs::drawing::Theme; use crate::xml_read_loop; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; pub fn read( arv: &mut zip::ZipArchive, target: &str, -) -> result::Result { - let r = io::BufReader::new(arv.by_name(&format!("xl/{}", target))?); +) -> Result { + let r = io::BufReader::new(arv.by_name(&format!("xl/{target}"))?); let mut reader = Reader::from_reader(r); reader.config_mut().trim_text(true); diff --git a/src/reader/xlsx/vba_project_bin.rs b/src/reader/xlsx/vba_project_bin.rs index b0b3fd5d..7f1a8e1b 100644 --- a/src/reader/xlsx/vba_project_bin.rs +++ b/src/reader/xlsx/vba_project_bin.rs @@ -1,14 +1,14 @@ use super::XlsxError; +use std::io; use std::io::Read; -use std::{io, result}; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_VBA_PROJECT; use crate::structs::Spreadsheet; -pub(crate) fn read( +pub(crate) fn read( arv: &mut zip::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let mut r = io::BufReader::new(match arv.by_name(PKG_VBA_PROJECT) { Ok(v) => v, Err(zip::result::ZipError::FileNotFound) => { diff --git a/src/reader/xlsx/vml_drawing.rs b/src/reader/xlsx/vml_drawing.rs index 3d2a2875..41d2e759 100644 --- a/src/reader/xlsx/vml_drawing.rs +++ b/src/reader/xlsx/vml_drawing.rs @@ -6,13 +6,12 @@ use crate::structs::Worksheet; use crate::xml_read_loop; use quick_xml::events::Event; use quick_xml::Reader; -use std::result; pub(crate) fn read( worksheet: &mut Worksheet, drawing_file: &RawFile, drawing_relationships: Option<&RawRelationships>, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { let data = std::io::Cursor::new(drawing_file.get_file_data()); let mut reader = Reader::from_reader(data); reader.config_mut().trim_text(true); @@ -26,22 +25,19 @@ pub(crate) fn read( if e.name().into_inner() == b"v:shape" { let mut obj = Shape::default(); obj.set_attributes(&mut reader, e, drawing_relationships); - match obj.get_client_data().get_comment_column_target() { - Some(_) => { - worksheet - .get_comments_mut() - .get_mut(comment_index) - .map(|comment| comment.set_shape(obj)); - comment_index += 1; - } - None => { - worksheet - .get_ole_objects_mut() - .get_ole_object_mut() - .get_mut(ole_index) - .map(|ole_obj| ole_obj.set_shape(obj)); - ole_index += 1; - } + if obj.get_client_data().get_comment_column_target().is_some() { + worksheet + .get_comments_mut() + .get_mut(comment_index) + .map(|comment| comment.set_shape(obj)); + comment_index += 1; + } else { + worksheet + .get_ole_objects_mut() + .get_ole_object_mut() + .get_mut(ole_index) + .map(|ole_obj| ole_obj.set_shape(obj)); + ole_index += 1; } } }, diff --git a/src/reader/xlsx/workbook.rs b/src/reader/xlsx/workbook.rs index 8acb89b6..32414b25 100644 --- a/src/reader/xlsx/workbook.rs +++ b/src/reader/xlsx/workbook.rs @@ -1,13 +1,13 @@ use crate::xml_read_loop; -use super::driver::*; +use super::driver::get_attribute; use super::XlsxError; use quick_xml::escape; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_WORKBOOK; use crate::structs::DefinedName; use crate::structs::Spreadsheet; use crate::structs::WorkbookProtection; @@ -16,7 +16,7 @@ use crate::structs::Worksheet; pub(crate) fn read( arv: &mut zip::read::ZipArchive, -) -> result::Result { +) -> Result { let r = io::BufReader::new(arv.by_name(PKG_WORKBOOK)?); let mut reader = Reader::from_reader(r); reader.config_mut().trim_text(true); @@ -55,7 +55,7 @@ pub(crate) fn read( b"pivotCache" => { let cache_id = get_attribute(e, b"cacheId").unwrap(); let r_id = get_attribute(e, b"r:id").unwrap(); - spreadsheet.add_pivot_caches((r_id, cache_id, String::from(""))); + spreadsheet.add_pivot_caches((r_id, cache_id, String::new())); } _ => (), } diff --git a/src/reader/xlsx/workbook_rels.rs b/src/reader/xlsx/workbook_rels.rs index d1210582..53909f0d 100644 --- a/src/reader/xlsx/workbook_rels.rs +++ b/src/reader/xlsx/workbook_rels.rs @@ -1,15 +1,15 @@ -use super::driver::*; +use super::driver::{get_attribute, xml_read_loop}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{PIVOT_CACHE_DEF_NS, PKG_WORKBOOK_RELS}; use crate::structs::Spreadsheet; use quick_xml::events::Event; use quick_xml::Reader; -use std::{io, result}; +use std::io; pub(crate) fn read( arv: &mut zip::read::ZipArchive, spreadsheet: &mut Spreadsheet, -) -> result::Result, XlsxError> { +) -> Result, XlsxError> { let r = io::BufReader::new(arv.by_name(PKG_WORKBOOK_RELS)?); let mut reader = Reader::from_reader(r); reader.config_mut().trim_text(true); @@ -25,7 +25,7 @@ pub(crate) fn read( let target_value = get_attribute(e, b"Target").unwrap(); let target_value = target_value .strip_prefix("/xl/") - .map(|t| t.to_owned()) + .map(ToOwned::to_owned) .unwrap_or(target_value); if type_value == PIVOT_CACHE_DEF_NS { spreadsheet.update_pivot_caches(id_value, target_value); diff --git a/src/reader/xlsx/worksheet.rs b/src/reader/xlsx/worksheet.rs index 553dfd7c..9c279b7a 100644 --- a/src/reader/xlsx/worksheet.rs +++ b/src/reader/xlsx/worksheet.rs @@ -1,10 +1,10 @@ -use super::driver::*; +use super::driver::{get_attribute, get_attribute_value, xml_read_loop}; use super::XlsxError; use quick_xml::events::Event; use quick_xml::Reader; use std::collections::HashMap; -use crate::helper::formula::*; +use crate::helper::formula::FormulaToken; use crate::structs::office2010::excel::DataValidations as DataValidations2010; use crate::structs::raw::RawRelationships; use crate::structs::raw::RawWorksheet; diff --git a/src/structs/address.rs b/src/structs/address.rs index feaa19f8..b1973046 100644 --- a/src/structs/address.rs +++ b/src/structs/address.rs @@ -1,6 +1,6 @@ use super::Range; -use crate::helper::address::*; -use crate::helper::coordinate::*; +use crate::helper::address::split_address; +use crate::helper::coordinate::index_from_coordinate; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWithSheet; use fancy_regex::Regex; @@ -13,6 +13,7 @@ pub struct Address { impl Address { #[inline] + #[must_use] pub fn get_sheet_name(&self) -> &str { &self.sheet_name } @@ -24,6 +25,7 @@ impl Address { } #[inline] + #[must_use] pub fn get_range(&self) -> &Range { &self.range } @@ -50,6 +52,7 @@ impl Address { } #[inline] + #[must_use] pub fn get_address(&self) -> String { self.get_address_crate(false) } @@ -70,14 +73,14 @@ impl Address { with_space_char = "'"; } if is_ptn2 { - if sheet_name.contains("!") { + if sheet_name.contains('!') { with_space_char = "'"; } - if sheet_name.contains("'") { + if sheet_name.contains('\'') { with_space_char = "'"; - sheet_name = sheet_name.replace("'", "''").into_boxed_str(); + sheet_name = sheet_name.replace('\'', "''").into_boxed_str(); } - if sheet_name.contains(r#"""#) { + if sheet_name.contains('"') { with_space_char = "'"; } if with_space_char.is_empty() { diff --git a/src/structs/alignment.rs b/src/structs/alignment.rs index 91c9cc9c..d664b323 100644 --- a/src/structs/alignment.rs +++ b/src/structs/alignment.rs @@ -4,8 +4,8 @@ use super::EnumValue; use super::HorizontalAlignmentValues; use super::UInt32Value; use super::VerticalAlignmentValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use md5::Digest; use quick_xml::events::BytesStart; use quick_xml::Reader; @@ -22,6 +22,7 @@ pub struct Alignment { impl Alignment { #[inline] + #[must_use] pub fn get_horizontal(&self) -> &HorizontalAlignmentValues { self.horizontal.get_value() } @@ -32,6 +33,7 @@ impl Alignment { } #[inline] + #[must_use] pub fn get_vertical(&self) -> &VerticalAlignmentValues { self.vertical.get_value() } @@ -42,6 +44,7 @@ impl Alignment { } #[inline] + #[must_use] pub fn get_wrap_text(&self) -> bool { self.wrap_text.get_value() } @@ -52,6 +55,7 @@ impl Alignment { } #[inline] + #[must_use] pub fn get_text_rotation(&self) -> u32 { self.text_rotation.get_value() } diff --git a/src/structs/anchor.rs b/src/structs/anchor.rs index f97327f9..f42f5b75 100644 --- a/src/structs/anchor.rs +++ b/src/structs/anchor.rs @@ -12,6 +12,7 @@ pub struct Anchor { impl Anchor { #[inline] + #[must_use] pub fn get_left_column(&self) -> u32 { self.left_column } @@ -22,6 +23,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_left_offset(&self) -> u32 { self.left_offset } @@ -32,6 +34,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_top_row(&self) -> u32 { self.top_row } @@ -42,6 +45,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_top_offset(&self) -> u32 { self.top_offset } @@ -52,6 +56,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_right_column(&self) -> u32 { self.right_column } @@ -62,6 +67,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_right_offset(&self) -> u32 { self.right_offset } @@ -72,6 +78,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_bottom_row(&self) -> u32 { self.bottom_row } @@ -82,6 +89,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_bottom_offset(&self) -> u32 { self.bottom_offset } diff --git a/src/structs/auto_filter.rs b/src/structs/auto_filter.rs index 0051968e..f8f66bc7 100644 --- a/src/structs/auto_filter.rs +++ b/src/structs/auto_filter.rs @@ -8,6 +8,7 @@ pub struct AutoFilter { impl AutoFilter { #[inline] + #[must_use] pub fn get_range(&self) -> &Range { &self.range } diff --git a/src/structs/bold.rs b/src/structs/bold.rs index 9c3f00a9..9148892c 100644 --- a/src/structs/bold.rs +++ b/src/structs/bold.rs @@ -1,7 +1,7 @@ // b use super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Bold { impl Bold { #[inline] + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/border.rs b/src/structs/border.rs index 5e0150d3..fe014201 100644 --- a/src/structs/border.rs +++ b/src/structs/border.rs @@ -2,8 +2,8 @@ use super::BorderStyleValues; use super::Color; use super::EnumValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -18,6 +18,7 @@ pub struct Border { impl Border { #[inline] + #[must_use] pub fn get_color(&self) -> &Color { &self.color } @@ -34,6 +35,7 @@ impl Border { } #[inline] + #[must_use] pub fn get_style(&self) -> &BorderStyleValues { self.style.get_value() } @@ -61,6 +63,7 @@ impl Border { pub const BORDER_THIN: &'static str = "thin"; #[inline] + #[must_use] pub fn get_border_style(&self) -> &str { self.style.get_value_string() } diff --git a/src/structs/borders.rs b/src/structs/borders.rs index e3c19295..6bc23cf1 100644 --- a/src/structs/borders.rs +++ b/src/structs/borders.rs @@ -1,8 +1,8 @@ // border use super::BooleanValue; use super::Border; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; diff --git a/src/structs/borders_crate.rs b/src/structs/borders_crate.rs index 516d1688..ade63bd1 100644 --- a/src/structs/borders_crate.rs +++ b/src/structs/borders_crate.rs @@ -1,8 +1,8 @@ // borders use super::Borders; use super::Style; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/break.rs b/src/structs/break.rs index 0ca210d0..267f42f6 100644 --- a/src/structs/break.rs +++ b/src/structs/break.rs @@ -1,8 +1,8 @@ // brk -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::BooleanValue; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct Break { impl Break { #[inline] + #[must_use] pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -29,6 +30,7 @@ impl Break { } #[inline] + #[must_use] pub fn get_max(&self) -> u32 { self.max.get_value() } @@ -40,6 +42,7 @@ impl Break { } #[inline] + #[must_use] pub fn get_manual_page_break(&self) -> bool { self.manual_page_break.get_value() } diff --git a/src/structs/cache_field.rs b/src/structs/cache_field.rs index 2ea0cac9..deaeff4f 100644 --- a/src/structs/cache_field.rs +++ b/src/structs/cache_field.rs @@ -1,9 +1,9 @@ // cacheField -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::SharedItems; use crate::structs::StringValue; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct CacheField { shared_items: SharedItems, } impl CacheField { + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -26,6 +27,7 @@ impl CacheField { self } + #[must_use] pub fn get_number_format_id(&self) -> u32 { self.number_format_id.get_value() } @@ -35,6 +37,7 @@ impl CacheField { self } + #[must_use] pub fn get_shared_items(&self) -> &SharedItems { &self.shared_items } diff --git a/src/structs/cache_fields.rs b/src/structs/cache_fields.rs index 853b8ade..74f89909 100644 --- a/src/structs/cache_fields.rs +++ b/src/structs/cache_fields.rs @@ -1,7 +1,7 @@ // cacheFields -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::CacheField; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct CacheFields { list: Vec, } impl CacheFields { + #[must_use] pub fn get_list(&self) -> &Vec { &self.list } diff --git a/src/structs/cache_source.rs b/src/structs/cache_source.rs index 00a9253e..7c25c370 100644 --- a/src/structs/cache_source.rs +++ b/src/structs/cache_source.rs @@ -3,8 +3,8 @@ use crate::structs::EnumValue; use crate::structs::SourceValues; use crate::structs::WorksheetSource; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct CacheSource { } impl CacheSource { + #[must_use] pub fn get_type(&self) -> &SourceValues { self.r#type.get_value() } @@ -26,6 +27,7 @@ impl CacheSource { self } + #[must_use] pub fn get_worksheet_source(&self) -> Option<&WorksheetSource> { self.worksheet_source.as_ref() } @@ -81,7 +83,7 @@ impl CacheSource { if !empty_flg { // worksheetSource if let Some(v) = &self.worksheet_source { - v.write_to(writer) + v.write_to(writer); } write_end_tag(writer, "cacheSource"); } diff --git a/src/structs/cell.rs b/src/structs/cell.rs index 9b623e60..e232db30 100644 --- a/src/structs/cell.rs +++ b/src/structs/cell.rs @@ -1,7 +1,9 @@ -use crate::helper::coordinate::*; -use crate::helper::formula::*; -use crate::helper::number_format::*; -use crate::reader::driver::*; +use crate::helper::coordinate::CellCoordinates; +use crate::helper::formula::{ + adjustment_formula_coordinate, parse_to_tokens, render, FormulaToken, +}; +use crate::helper::number_format::to_formatted_string; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::CellFormula; use crate::structs::CellFormulaValues; use crate::structs::CellRawValue; @@ -17,7 +19,9 @@ use crate::structs::Stylesheet; use crate::structs::UInt32Value; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWith2Sheet; -use crate::writer::driver::*; +use crate::writer::driver::{ + write_end_tag, write_start_tag, write_text_node, write_text_node_conversion, +}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -36,6 +40,7 @@ pub struct Cell { } impl Cell { #[inline] + #[must_use] pub fn get_cell_value(&self) -> &CellValue { &self.cell_value } @@ -52,6 +57,7 @@ impl Cell { } #[inline] + #[must_use] pub fn get_style(&self) -> &Style { &self.style } @@ -68,6 +74,7 @@ impl Cell { } #[inline] + #[must_use] pub fn get_coordinate(&self) -> &Coordinate { &self.coordinate } @@ -91,7 +98,7 @@ impl Cell { let org_row_num = self.coordinate.get_row_num(); let offset_col_num = col as i32 - org_col_num as i32; let offset_row_num = row as i32 - org_row_num as i32; - let mut tokens = parse_to_tokens(format!("={}", formula)); + let mut tokens = parse_to_tokens(format!("={formula}")); adjustment_formula_coordinate(&mut tokens, offset_col_num, offset_row_num); let result_formula = render(tokens.as_ref()); self.cell_value.set_formula(result_formula); @@ -102,6 +109,7 @@ impl Cell { } #[inline] + #[must_use] pub fn get_hyperlink(&self) -> Option<&Hyperlink> { self.hyperlink.as_deref() } @@ -122,6 +130,7 @@ impl Cell { } #[inline] + #[must_use] pub fn get_cell_meta_index(&self) -> u32 { self.cell_meta_index.get_value() } @@ -133,11 +142,13 @@ impl Cell { } #[inline] + #[must_use] pub fn get_value(&self) -> Cow<'static, str> { self.cell_value.get_value() } #[inline] + #[must_use] pub fn get_value_number(&self) -> Option { self.cell_value.get_value_number() } @@ -243,11 +254,13 @@ impl Cell { } #[inline] + #[must_use] pub fn get_data_type(&self) -> &str { self.cell_value.get_data_type() } #[inline] + #[must_use] pub fn get_raw_value(&self) -> &CellRawValue { self.cell_value.get_raw_value() } @@ -258,21 +271,25 @@ impl Cell { } #[inline] + #[must_use] pub fn is_formula(&self) -> bool { self.cell_value.is_formula() } #[inline] + #[must_use] pub fn get_formula(&self) -> &str { self.cell_value.get_formula() } #[inline] + #[must_use] pub fn get_formula_obj(&self) -> Option<&CellFormula> { self.cell_value.get_formula_obj() } #[inline] + #[must_use] pub fn get_formula_shared_index(&self) -> Option { if let Some(v) = self.get_formula_obj() { if v.get_formula_type() == &CellFormulaValues::Shared { @@ -315,6 +332,7 @@ impl Cell { }) } + #[must_use] pub fn get_formatted_value(&self) -> String { let value = self.get_value(); @@ -351,8 +369,8 @@ impl Cell { empty_flag: bool, formula_shared_list: &mut HashMap)>, ) { - let mut type_value: String = String::from(""); - let mut cell_reference: String = String::from(""); + let mut type_value: String = String::new(); + let mut cell_reference: String = String::new(); if let Some(v) = get_attribute(e, b"r") { cell_reference = v; @@ -374,7 +392,7 @@ impl Cell { return; } - let mut string_value: String = String::from(""); + let mut string_value: String = String::new(); let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf) { diff --git a/src/structs/cell_format.rs b/src/structs/cell_format.rs index 0f3d00c8..a115c479 100644 --- a/src/structs/cell_format.rs +++ b/src/structs/cell_format.rs @@ -3,8 +3,8 @@ use super::Alignment; use super::BooleanValue; use super::Protection; use super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/cell_formats.rs b/src/structs/cell_formats.rs index df1a70b4..9bf3213b 100644 --- a/src/structs/cell_formats.rs +++ b/src/structs/cell_formats.rs @@ -1,7 +1,7 @@ // cellXfs use super::CellFormat; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/cell_formula.rs b/src/structs/cell_formula.rs index 6ae7a71a..c91bee15 100644 --- a/src/structs/cell_formula.rs +++ b/src/structs/cell_formula.rs @@ -1,13 +1,16 @@ -use crate::helper::coordinate::*; -use crate::helper::formula::*; -use crate::reader::driver::*; +use crate::helper::coordinate::index_from_coordinate; +use crate::helper::formula::{ + adjustment_insert_formula_coordinate, adjustment_remove_formula_coordinate, parse_to_tokens, + FormulaToken, +}; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::BooleanValue; use crate::structs::CellFormulaValues; use crate::structs::EnumValue; use crate::structs::StringValue; use crate::structs::UInt32Value; use crate::traits::AdjustmentCoordinateWith2Sheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node_conversion}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -31,6 +34,7 @@ pub struct CellFormula { } impl CellFormula { #[inline] + #[must_use] pub fn get_bx(&self) -> bool { self.bx.get_value() } @@ -42,6 +46,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_data_table_2d(&self) -> bool { self.data_table_2d.get_value() } @@ -53,6 +58,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_data_table_row(&self) -> bool { self.data_table_row.get_value() } @@ -64,6 +70,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_formula_type(&self) -> &CellFormulaValues { self.formula_type.get_value() } @@ -74,6 +81,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_input_1deleted(&self) -> bool { self.input_1deleted.get_value() } @@ -85,6 +93,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_input_2deleted(&self) -> bool { self.input_2deleted.get_value() } @@ -96,6 +105,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_r1(&self) -> &str { self.r1.get_value_str() } @@ -107,6 +117,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_r2(&self) -> &str { self.r2.get_value_str() } @@ -118,6 +129,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_reference(&self) -> &str { self.reference.get_value_str() } @@ -129,6 +141,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_shared_index(&self) -> u32 { self.shared_index.get_value() } @@ -140,6 +153,7 @@ impl CellFormula { } #[inline] + #[must_use] pub fn get_text(&self) -> &str { if self.text_view.has_value() { return self.text_view.get_value_str(); @@ -285,13 +299,13 @@ impl CellFormula { } #[allow(unused_assignments)] - let mut reference_str = String::from(""); + let mut reference_str = String::new(); if let Some((start_col, end_col)) = formula_shared_list.get(&self.shared_index.get_value()) { if coordinate == start_col { reference_str = match end_col { Some(v) => { - format!("{}:{}", start_col, v) + format!("{start_col}:{v}") } None => start_col.to_string(), }; @@ -321,7 +335,7 @@ impl AdjustmentCoordinateWith2Sheet for CellFormula { ) { if let Some(v) = self.text.get_value() { let formula = adjustment_insert_formula_coordinate( - &mut parse_to_tokens(format!("={}", v)), + &mut parse_to_tokens(format!("={v}")), root_col_num, offset_col_num, root_row_num, @@ -334,7 +348,7 @@ impl AdjustmentCoordinateWith2Sheet for CellFormula { } if let Some(v) = self.text_view.get_value() { let formula = adjustment_insert_formula_coordinate( - &mut parse_to_tokens(format!("={}", v)), + &mut parse_to_tokens(format!("={v}")), root_col_num, offset_col_num, root_row_num, @@ -358,7 +372,7 @@ impl AdjustmentCoordinateWith2Sheet for CellFormula { ) { if let Some(v) = self.text.get_value() { let formula = adjustment_remove_formula_coordinate( - &mut parse_to_tokens(format!("={}", v)), + &mut parse_to_tokens(format!("={v}")), root_col_num, offset_col_num, root_row_num, @@ -371,7 +385,7 @@ impl AdjustmentCoordinateWith2Sheet for CellFormula { } if let Some(v) = self.text_view.get_value() { let formula = adjustment_remove_formula_coordinate( - &mut parse_to_tokens(format!("={}", v)), + &mut parse_to_tokens(format!("={v}")), root_col_num, offset_col_num, root_row_num, diff --git a/src/structs/cell_raw_value.rs b/src/structs/cell_raw_value.rs index 907bdeed..42809239 100644 --- a/src/structs/cell_raw_value.rs +++ b/src/structs/cell_raw_value.rs @@ -30,6 +30,7 @@ impl fmt::Display for CellRawValue { impl CellRawValue { #[inline] + #[must_use] pub fn get_data_type(&self) -> &str { match self { Self::String(_) => "s", @@ -64,6 +65,7 @@ impl CellRawValue { } #[inline] + #[must_use] pub fn get_rich_text(&self) -> Option { match self { Self::RichText(v) => Some(v.clone()), @@ -72,11 +74,13 @@ impl CellRawValue { } #[inline] + #[must_use] pub fn is_error(&self) -> bool { matches!(*self, CellRawValue::Error(_)) } #[inline] + #[must_use] pub fn is_empty(&self) -> bool { matches!(*self, CellRawValue::Empty) } diff --git a/src/structs/cell_style.rs b/src/structs/cell_style.rs index 78844c1e..52a160d2 100644 --- a/src/structs/cell_style.rs +++ b/src/structs/cell_style.rs @@ -1,8 +1,8 @@ // cellStyle -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::StringValue; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct CellStyle { impl CellStyle { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -28,6 +29,7 @@ impl CellStyle { } #[inline] + #[must_use] pub fn get_builtin_id(&self) -> u32 { self.builtin_id.get_value() } @@ -39,6 +41,7 @@ impl CellStyle { } #[inline] + #[must_use] pub fn get_format_id(&self) -> u32 { self.format_id.get_value() } diff --git a/src/structs/cell_style_formats.rs b/src/structs/cell_style_formats.rs index 53376106..5706cc26 100644 --- a/src/structs/cell_style_formats.rs +++ b/src/structs/cell_style_formats.rs @@ -1,7 +1,7 @@ // cellStyleXfs use super::CellFormat; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/cell_styles.rs b/src/structs/cell_styles.rs index aada1437..997f4c8a 100644 --- a/src/structs/cell_styles.rs +++ b/src/structs/cell_styles.rs @@ -1,7 +1,7 @@ // cellStyles use super::CellStyle; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/cell_value.rs b/src/structs/cell_value.rs index 23958d6d..2761e6d9 100644 --- a/src/structs/cell_value.rs +++ b/src/structs/cell_value.rs @@ -15,11 +15,13 @@ pub struct CellValue { } impl CellValue { #[inline] + #[must_use] pub fn get_data_type(&self) -> &str { self.raw_value.get_data_type() } #[inline] + #[must_use] pub fn get_raw_value(&self) -> &CellRawValue { &self.raw_value } @@ -33,11 +35,13 @@ impl CellValue { } #[inline] + #[must_use] pub fn get_value(&self) -> Cow<'static, str> { self.raw_value.to_string().into() } #[inline] + #[must_use] pub fn get_value_number(&self) -> Option { self.raw_value.get_number() } @@ -139,11 +143,13 @@ impl CellValue { } #[inline] + #[must_use] pub fn is_formula(&self) -> bool { self.formula.is_some() } #[inline] + #[must_use] pub fn get_formula(&self) -> &str { match &self.formula { Some(v) => v.get_text(), @@ -152,6 +158,7 @@ impl CellValue { } #[inline] + #[must_use] pub fn get_formula_obj(&self) -> Option<&CellFormula> { self.formula.as_deref() } @@ -189,6 +196,7 @@ impl CellValue { } #[inline] + #[must_use] pub fn is_error(&self) -> bool { self.raw_value.is_error() } @@ -225,6 +233,7 @@ impl CellValue { } #[inline] + #[must_use] pub fn is_empty(&self) -> bool { self.is_value_empty() && self.is_formula_empty() } diff --git a/src/structs/cells.rs b/src/structs/cells.rs index 706ead7a..01f576e5 100644 --- a/src/structs/cells.rs +++ b/src/structs/cells.rs @@ -1,8 +1,8 @@ use super::Cell; use super::CellValue; use super::Style; -use crate::helper::coordinate::*; -use crate::helper::range::*; +use crate::helper::coordinate::CellCoordinates; +use crate::helper::range::get_coordinate_list; use crate::structs::Column; use crate::structs::Row; use crate::traits::AdjustmentCoordinate; @@ -21,6 +21,7 @@ impl Cells { self.map.values().map(Box::as_ref).collect() } + #[must_use] pub fn get_collection_sorted(&self) -> Vec<&Cell> { let mut cells = self.get_collection(); cells.sort_by(|a, b| { @@ -42,6 +43,7 @@ impl Cells { } #[inline] + #[must_use] pub fn get_collection_to_hashmap(&self) -> &HashMap<(u32, u32), Box> { &self.map } @@ -65,6 +67,7 @@ impl Cells { } #[inline] + #[must_use] pub fn get_collection_by_column_to_hashmap(&self, column_num: u32) -> HashMap { self.map .iter() @@ -74,6 +77,7 @@ impl Cells { } #[inline] + #[must_use] pub fn get_collection_by_row_to_hashmap(&self, row_num: u32) -> HashMap { self.map .iter() @@ -87,6 +91,7 @@ impl Cells { &mut self.map } + #[must_use] pub fn get_highest_column_and_row(&self) -> (u32, u32) { let mut col_max: u32 = 0; let mut row_max: u32 = 0; @@ -103,6 +108,7 @@ impl Cells { /// Has Hyperlink #[inline] + #[must_use] pub fn has_hyperlink(&self) -> bool { self.map.values().any(|c| c.get_hyperlink().is_some()) } @@ -152,8 +158,7 @@ impl Cells { let CellCoordinates { col, row } = coordinate.into(); self.map .get(&(row.to_owned(), col.to_owned())) - .map(|c| c.get_cell_value()) - .unwrap_or(&self.default_cell_value) + .map_or(&self.default_cell_value, |c| c.get_cell_value()) } #[inline] @@ -164,8 +169,7 @@ impl Cells { let CellCoordinates { col, row } = coordinate.into(); self.map .get(&(row.to_owned(), col.to_owned())) - .map(|c| c.get_style()) - .unwrap_or(&self.default_style) + .map_or(&self.default_style, |c| c.get_style()) } #[inline] @@ -202,6 +206,7 @@ impl Cells { self.map.remove(&k).is_some() } + #[must_use] pub fn get_cell_by_range(&self, range: &str) -> Vec> { let mut result: Vec> = Vec::new(); let range_upper = range.to_uppercase(); @@ -212,6 +217,7 @@ impl Cells { result } + #[must_use] pub fn get_cell_value_by_range(&self, range: &str) -> Vec<&CellValue> { let mut result: Vec<&CellValue> = Vec::new(); let range_upper = range.to_uppercase(); @@ -223,10 +229,11 @@ impl Cells { } #[inline] + #[must_use] pub fn get_formatted_value_by_column_and_row(&self, col_num: u32, row_num: u32) -> String { match self.get((col_num, row_num)) { Some(v) => v.get_formatted_value(), - None => "".into(), + None => String::new(), } } @@ -243,7 +250,7 @@ impl Cells { std::mem::take(cell), ) }) - .collect() + .collect(); } } impl AdjustmentCoordinate for Cells { diff --git a/src/structs/chart.rs b/src/structs/chart.rs index 84cd5f98..173e0c22 100644 --- a/src/structs/chart.rs +++ b/src/structs/chart.rs @@ -63,18 +63,18 @@ use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWithSheet; /// ## Supported chart types -/// * AreaChart -/// * Area3DChart -/// * BarChart -/// * Bar3DChart -/// * BubbleChart -/// * DoughnutChart -/// * LineChart -/// * Line3DChart -/// * OfPieChart -/// * PieChart -/// * RadarChart -/// * ScatterChart +/// * `AreaChart` +/// * `Area3DChart` +/// * `BarChart` +/// * `Bar3DChart` +/// * `BubbleChart` +/// * `DoughnutChart` +/// * `LineChart` +/// * `Line3DChart` +/// * `OfPieChart` +/// * `PieChart` +/// * `RadarChart` +/// * `ScatterChart` /// /// Other types will be supported sequentially. /// @@ -224,16 +224,13 @@ impl Chart { .get_area_chart_series_list_mut() .get_area_chart_series_mut() { - match series.get_category_axis_data_mut() { - Some(v) => { - v.remove_string_reference(); - v.set_string_literal(string_literal.clone()); - } - None => { - let mut obj = CategoryAxisData::default(); - obj.set_string_literal(string_literal.clone()); - series.set_category_axis_data(obj); - } + if let Some(v) = series.get_category_axis_data_mut() { + v.remove_string_reference(); + v.set_string_literal(string_literal.clone()); + } else { + let mut obj = CategoryAxisData::default(); + obj.set_string_literal(string_literal.clone()); + series.set_category_axis_data(obj); } } self @@ -255,6 +252,7 @@ impl Chart { } #[inline] + #[must_use] pub fn get_two_cell_anchor(&self) -> &TwoCellAnchor { &self.two_cell_anchor } @@ -276,6 +274,7 @@ impl Chart { self } + #[must_use] pub fn get_chart_space(&self) -> &ChartSpace { match self.two_cell_anchor.get_graphic_frame() { Some(v) => v.get_graphic().get_graphic_data().get_chart_space(), @@ -353,6 +352,7 @@ impl Chart { } #[inline] + #[must_use] pub fn get_coordinate(&self) -> String { self.two_cell_anchor.get_from_marker().get_coordinate() } diff --git a/src/structs/color.rs b/src/structs/color.rs index 385f04de..0ab34ade 100644 --- a/src/structs/color.rs +++ b/src/structs/color.rs @@ -2,10 +2,10 @@ use super::DoubleValue; use super::StringValue; use super::UInt32Value; -use crate::helper::color::*; -use crate::reader::driver::*; +use crate::helper::color::calc_tint; +use crate::reader::driver::get_attribute_value; use crate::structs::drawing::Theme; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -98,7 +98,8 @@ impl Color { /// Get Argb. /// If the color is based on the theme, it cannot be obtained with this function. - /// In that case, use get_argb_with_theme(&self, theme: &Theme). + /// In that case, use `get_argb_with_theme(&self`, theme: &Theme). + #[must_use] pub fn get_argb(&self) -> &str { if self.indexed.has_value() { if let Some(v) = INDEXED_COLORS.get(self.indexed.get_value() as usize) { @@ -115,6 +116,7 @@ impl Color { /// let mut book = umya_spreadsheet::new_file(); /// let theme = book.get_theme(); /// ``` + #[must_use] pub fn get_argb_with_theme(&self, theme: &Theme) -> Cow<'static, str> { if self.indexed.has_value() { return self.get_argb().to_owned().into(); @@ -139,21 +141,19 @@ impl Color { pub fn set_argb>(&mut self, value: S) -> &mut Self { let argb = value.into(); let indexed = INDEXED_COLORS.iter().position(|&r| r == argb); - match indexed { - Some(v) => { - self.indexed.set_value(v as u32); - self.argb.remove_value(); - } - None => { - self.indexed.remove_value(); - self.argb.set_value(argb); - } + if let Some(v) = indexed { + self.indexed.set_value(v as u32); + self.argb.remove_value(); + } else { + self.indexed.remove_value(); + self.argb.set_value(argb); } self.theme_index.remove_value(); self } #[inline] + #[must_use] pub fn get_indexed(&self) -> u32 { self.indexed.get_value() } @@ -167,6 +167,7 @@ impl Color { } #[inline] + #[must_use] pub fn get_theme_index(&self) -> u32 { self.theme_index.get_value() } @@ -180,6 +181,7 @@ impl Color { } #[inline] + #[must_use] pub fn get_tint(&self) -> f64 { self.tint.get_value() } diff --git a/src/structs/color_scale.rs b/src/structs/color_scale.rs index 8e007105..7c7f9056 100644 --- a/src/structs/color_scale.rs +++ b/src/structs/color_scale.rs @@ -1,7 +1,7 @@ use super::Color; use super::ConditionalFormatValueObject; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -17,6 +17,7 @@ pub struct ColorScale { impl ColorScale { #[inline] + #[must_use] pub fn get_cfvo_collection(&self) -> &[ConditionalFormatValueObject] { &self.cfvo_collection } @@ -37,6 +38,7 @@ impl ColorScale { } #[inline] + #[must_use] pub fn get_color_collection(&self) -> &[Color] { &self.color_collection } diff --git a/src/structs/colors.rs b/src/structs/colors.rs index f1b58510..51b5f841 100644 --- a/src/structs/colors.rs +++ b/src/structs/colors.rs @@ -1,7 +1,7 @@ // colors use super::MruColors; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/column.rs b/src/structs/column.rs index 9852a6af..e6709412 100644 --- a/src/structs/column.rs +++ b/src/structs/column.rs @@ -3,7 +3,7 @@ use super::DoubleValue; use super::Style; use super::Stylesheet; use super::UInt32Value; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::Cells; use crate::traits::AdjustmentValue; use md5::Digest; @@ -53,6 +53,7 @@ impl Default for Column { impl Column { #[inline] + #[must_use] pub fn get_col_num(&self) -> u32 { self.col_num.get_value() } @@ -64,6 +65,7 @@ impl Column { } #[inline] + #[must_use] pub fn get_width(&self) -> f64 { self.width.get_value() } @@ -75,6 +77,7 @@ impl Column { } #[inline] + #[must_use] pub fn get_hidden(&self) -> bool { self.hidden.get_value() } @@ -86,6 +89,7 @@ impl Column { } #[inline] + #[must_use] pub fn get_best_fit(&self) -> bool { self.best_fit.get_value() } @@ -97,6 +101,7 @@ impl Column { } #[inline] + #[must_use] pub fn get_style(&self) -> &Style { &self.style } @@ -113,6 +118,7 @@ impl Column { } #[inline] + #[must_use] pub fn get_auto_width(&self) -> bool { self.auto_width.get_value() } diff --git a/src/structs/column_breaks.rs b/src/structs/column_breaks.rs index dbf55227..14368311 100644 --- a/src/structs/column_breaks.rs +++ b/src/structs/column_breaks.rs @@ -1,7 +1,7 @@ // colBreaks -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Break; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct ColumnBreaks { impl ColumnBreaks { #[inline] + #[must_use] pub fn get_break_list(&self) -> &[Break] { &self.break_list } diff --git a/src/structs/column_fields.rs b/src/structs/column_fields.rs index 988433bf..71931653 100644 --- a/src/structs/column_fields.rs +++ b/src/structs/column_fields.rs @@ -1,7 +1,7 @@ // colFields -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Field; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct ColumnFields { } impl ColumnFields { #[inline] + #[must_use] pub fn get_list(&self) -> &[Field] { &self.list } diff --git a/src/structs/column_items.rs b/src/structs/column_items.rs index 1b01e71d..63ced6d4 100644 --- a/src/structs/column_items.rs +++ b/src/structs/column_items.rs @@ -1,7 +1,7 @@ // colItems -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::RowItem; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct ColumnItems { } impl ColumnItems { #[inline] + #[must_use] pub fn get_list(&self) -> &[RowItem] { &self.list } diff --git a/src/structs/column_reference.rs b/src/structs/column_reference.rs index 5c65f7aa..2d033417 100644 --- a/src/structs/column_reference.rs +++ b/src/structs/column_reference.rs @@ -1,4 +1,7 @@ -use crate::helper::coordinate::*; +use crate::helper::coordinate::{ + adjustment_insert_coordinate, adjustment_remove_coordinate, is_remove_coordinate, + string_from_column_index, +}; use crate::traits::AdjustmentValue; #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] @@ -19,6 +22,7 @@ impl Default for ColumnReference { impl ColumnReference { #[inline] + #[must_use] pub fn get_num(&self) -> u32 { self.num } @@ -53,6 +57,7 @@ impl ColumnReference { } #[inline] + #[must_use] pub fn get_is_lock(&self) -> bool { self.is_lock } diff --git a/src/structs/columns.rs b/src/structs/columns.rs index cc39df44..7ddf6765 100644 --- a/src/structs/columns.rs +++ b/src/structs/columns.rs @@ -1,11 +1,11 @@ // fills -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; use crate::structs::Cells; use crate::structs::Column; use crate::structs::MergeCells; use crate::structs::Stylesheet; use crate::traits::AdjustmentValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -114,7 +114,7 @@ impl Columns { // col let mut column_copy = self.column.clone(); - column_copy.sort_by_key(|a| a.get_col_num()); + column_copy.sort_by_key(Column::get_col_num); let mut column_iter = column_copy.iter(); let mut column_raw = column_iter.next(); let mut obj = column_raw.unwrap(); @@ -123,24 +123,21 @@ impl Columns { loop { column_raw = column_iter.next(); - match column_raw { - Some(column) => { - if column.get_col_num() == max + 1 - && column.get_hash_code() == obj.get_hash_code() - && column.get_style() == obj.get_style() - { - max += 1; - } else { - self.write_to_column(writer, min, max, obj, stylesheet); - obj = column; - min = obj.get_col_num(); - max = min; - } - } - None => { + if let Some(column) = column_raw { + if column.get_col_num() == max + 1 + && column.get_hash_code() == obj.get_hash_code() + && column.get_style() == obj.get_style() + { + max += 1; + } else { self.write_to_column(writer, min, max, obj, stylesheet); - break; + obj = column; + min = obj.get_col_num(); + max = min; } + } else { + self.write_to_column(writer, min, max, obj, stylesheet); + break; } } diff --git a/src/structs/comment.rs b/src/structs/comment.rs index cced0222..87cf8c95 100644 --- a/src/structs/comment.rs +++ b/src/structs/comment.rs @@ -12,8 +12,8 @@ use super::vml::Shadow; use super::vml::TextBox; use super::Coordinate; use super::RichText; -use crate::helper::coordinate::*; -use crate::reader::driver::*; +use crate::helper::coordinate::CellCoordinates; +use crate::reader::driver::get_attribute; use crate::structs::vml::Shape; use crate::traits::AdjustmentCoordinate; use quick_xml::events::{BytesStart, Event}; @@ -29,6 +29,7 @@ pub struct Comment { impl Comment { #[inline] + #[must_use] pub fn get_coordinate(&self) -> &Coordinate { &self.coordinate } @@ -39,6 +40,7 @@ impl Comment { } #[inline] + #[must_use] pub fn get_author(&self) -> &str { &self.author } @@ -50,6 +52,7 @@ impl Comment { } #[inline] + #[must_use] pub fn get_text(&self) -> &RichText { &self.text } @@ -72,6 +75,7 @@ impl Comment { } #[inline] + #[must_use] pub fn get_anchor(&self) -> &Anchor { self.shape.get_client_data().get_anchor() } @@ -88,6 +92,7 @@ impl Comment { } #[inline] + #[must_use] pub fn get_shape(&self) -> &Shape { &self.shape } diff --git a/src/structs/conditional_format_value_object.rs b/src/structs/conditional_format_value_object.rs index 9e34186f..26ea7ec8 100644 --- a/src/structs/conditional_format_value_object.rs +++ b/src/structs/conditional_format_value_object.rs @@ -1,8 +1,8 @@ use super::ConditionalFormatValueObjectValues; use super::EnumValue; use super::StringValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::write_start_tag; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct ConditionalFormatValueObject { impl ConditionalFormatValueObject { #[inline] + #[must_use] pub fn get_type(&self) -> &ConditionalFormatValueObjectValues { self.r#type.get_value() } @@ -27,6 +28,7 @@ impl ConditionalFormatValueObject { } #[inline] + #[must_use] pub fn get_val(&self) -> &str { self.val.get_value_str() } diff --git a/src/structs/conditional_formatting.rs b/src/structs/conditional_formatting.rs index 1d39b95a..5b89f108 100644 --- a/src/structs/conditional_formatting.rs +++ b/src/structs/conditional_formatting.rs @@ -1,9 +1,9 @@ use super::ConditionalFormattingRule; use super::DifferentialFormats; use super::SequenceOfReferences; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; use crate::traits::AdjustmentCoordinate; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -19,6 +19,7 @@ pub struct ConditionalFormatting { impl ConditionalFormatting { #[inline] + #[must_use] pub fn get_sequence_of_references(&self) -> &SequenceOfReferences { &self.sequence_of_references } @@ -35,6 +36,7 @@ impl ConditionalFormatting { } #[inline] + #[must_use] pub fn get_conditional_collection(&self) -> &[ConditionalFormattingRule] { &self.conditional_collection } diff --git a/src/structs/conditional_formatting_rule.rs b/src/structs/conditional_formatting_rule.rs index 6e029032..39393a10 100644 --- a/src/structs/conditional_formatting_rule.rs +++ b/src/structs/conditional_formatting_rule.rs @@ -12,8 +12,8 @@ use super::StringValue; use super::Style; use super::TimePeriodValues; use super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -43,6 +43,7 @@ pub struct ConditionalFormattingRule { impl ConditionalFormattingRule { #[inline] + #[must_use] pub fn get_type(&self) -> &ConditionalFormatValues { self.r#type.get_value() } @@ -54,6 +55,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_operator(&self) -> &ConditionalFormattingOperatorValues { self.operator.get_value() } @@ -65,6 +67,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_text(&self) -> &str { self.text.get_value_str() } @@ -76,6 +79,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_priority(&self) -> i32 { self.priority.get_value() } @@ -87,6 +91,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_percent(&self) -> bool { self.percent.get_value() } @@ -98,6 +103,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_bottom(&self) -> bool { self.bottom.get_value() } @@ -109,6 +115,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_rank(&self) -> u32 { self.rank.get_value() } @@ -120,6 +127,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_stop_if_true(&self) -> bool { self.stop_if_true.get_value() } @@ -131,6 +139,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_std_dev(&self) -> i32 { self.std_dev.get_value() } @@ -142,6 +151,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_above_average(&self) -> bool { self.above_average.get_value() } @@ -153,6 +163,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_equal_average(&self) -> bool { self.equal_average.get_value() } @@ -164,6 +175,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_time_period(&self) -> &TimePeriodValues { self.time_period.get_value() } @@ -175,6 +187,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_style(&self) -> Option<&Style> { self.style.as_deref() } @@ -192,6 +205,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_color_scale(&self) -> Option<&ColorScale> { self.color_scale.as_ref() } @@ -209,6 +223,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_data_bar(&self) -> Option<&DataBar> { self.data_bar.as_ref() } @@ -226,6 +241,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_icon_set(&self) -> Option<&IconSet> { self.icon_set.as_ref() } @@ -243,6 +259,7 @@ impl ConditionalFormattingRule { } #[inline] + #[must_use] pub fn get_formula(&self) -> Option<&Formula> { self.formula.as_deref() } @@ -405,22 +422,22 @@ impl ConditionalFormattingRule { if is_inner { // colorScale if let Some(v) = &self.color_scale { - v.write_to(writer) + v.write_to(writer); } // dataBar if let Some(v) = &self.data_bar { - v.write_to(writer) + v.write_to(writer); } // iconSet if let Some(v) = &self.icon_set { - v.write_to(writer) + v.write_to(writer); } // formula if let Some(v) = &self.formula { - v.write_to(writer) + v.write_to(writer); } write_end_tag(writer, "cfRule"); diff --git a/src/structs/coordinate.rs b/src/structs/coordinate.rs index c34f2033..0d9173ec 100644 --- a/src/structs/coordinate.rs +++ b/src/structs/coordinate.rs @@ -2,7 +2,7 @@ use std::fmt; use super::ColumnReference; use super::RowReference; -use crate::helper::coordinate::*; +use crate::helper::coordinate::{coordinate_from_index_with_lock, index_from_coordinate}; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentValue; @@ -30,6 +30,7 @@ impl fmt::Display for Coordinate { impl Coordinate { #[inline] + #[must_use] pub fn get_col_num(&self) -> u32 { self.column.get_num() } @@ -47,6 +48,7 @@ impl Coordinate { } #[inline] + #[must_use] pub fn get_row_num(&self) -> u32 { self.row.get_num() } @@ -64,6 +66,7 @@ impl Coordinate { } #[inline] + #[must_use] pub fn get_is_lock_col(&self) -> bool { self.column.get_is_lock() } @@ -75,6 +78,7 @@ impl Coordinate { } #[inline] + #[must_use] pub fn get_is_lock_row(&self) -> bool { self.row.get_is_lock() } @@ -100,6 +104,7 @@ impl Coordinate { } #[inline] + #[must_use] pub fn get_coordinate(&self) -> String { coordinate_from_index_with_lock( self.column.get_num(), diff --git a/src/structs/csv_writer_option.rs b/src/structs/csv_writer_option.rs index 1e74239b..be843304 100644 --- a/src/structs/csv_writer_option.rs +++ b/src/structs/csv_writer_option.rs @@ -9,6 +9,7 @@ pub struct CsvWriterOption { } impl CsvWriterOption { #[inline] + #[must_use] pub fn get_csv_encode_value(&self) -> &CsvEncodeValues { self.csv_encode_values.get_value() } @@ -20,6 +21,7 @@ impl CsvWriterOption { } #[inline] + #[must_use] pub fn get_wrap_with_char(&self) -> &str { &self.wrap_with_char } @@ -31,6 +33,7 @@ impl CsvWriterOption { } #[inline] + #[must_use] pub fn get_do_trim(&self) -> bool { self.do_trim } diff --git a/src/structs/custom_properties/custom_document_property.rs b/src/structs/custom_properties/custom_document_property.rs index 7241d400..2404547d 100644 --- a/src/structs/custom_properties/custom_document_property.rs +++ b/src/structs/custom_properties/custom_document_property.rs @@ -1,7 +1,7 @@ -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::custom_properties::CustomDocumentPropertyValue; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -18,6 +18,7 @@ pub struct CustomDocumentProperty { impl CustomDocumentProperty { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -29,6 +30,7 @@ impl CustomDocumentProperty { } #[inline] + #[must_use] pub fn get_link_target(&self) -> &str { self.link_target.get_value_str() } @@ -40,16 +42,19 @@ impl CustomDocumentProperty { } #[inline] + #[must_use] pub fn get_value(&self) -> Cow<'static, str> { self.custom_document_property_value.to_string().into() } #[inline] + #[must_use] pub fn get_value_number(&self) -> Option { self.custom_document_property_value.get_number() } #[inline] + #[must_use] pub fn get_value_bool(&self) -> Option { self.custom_document_property_value.get_bool() } @@ -72,7 +77,7 @@ impl CustomDocumentProperty { #[inline] pub fn set_value_date(&mut self, year: i32, month: i32, day: i32) -> &mut Self { - let value = format!("{:>04}-{:>02}-{:>02}T10:00:00Z", year, month, day); + let value = format!("{year:>04}-{month:>02}-{day:>02}T10:00:00Z"); self.custom_document_property_value = CustomDocumentPropertyValue::Date(value.into_boxed_str()); self @@ -104,7 +109,7 @@ impl CustomDocumentProperty { return; } - let mut value: String = String::from(""); + let mut value: String = String::new(); xml_read_loop!( reader, Event::Text(e) => { @@ -130,7 +135,7 @@ impl CustomDocumentProperty { // property let mut attributes: Vec<(&str, &str)> = Vec::new(); - attributes.push(("fmtid", r#"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"#)); + attributes.push(("fmtid", r"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")); let pid_str = pid.to_string(); attributes.push(("pid", &pid_str)); diff --git a/src/structs/custom_properties/custom_document_property_value.rs b/src/structs/custom_properties/custom_document_property_value.rs index ef42a7b0..935cdfbc 100644 --- a/src/structs/custom_properties/custom_document_property_value.rs +++ b/src/structs/custom_properties/custom_document_property_value.rs @@ -12,8 +12,8 @@ impl fmt::Display for CustomDocumentPropertyValue { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Self::String(v) => write!(f, "{}", v), - Self::Date(v) => write!(f, "{}", v), + Self::String(v) => write!(f, "{v}"), + Self::Date(v) => write!(f, "{v}"), Self::Numeric(v) => write!(f, "{}", &v), Self::Bool(v) => write!(f, "{}", if *v { "true" } else { "false" }), _ => write!(f, ""), diff --git a/src/structs/custom_properties/properties.rs b/src/structs/custom_properties/properties.rs index 885ef447..cc9304ab 100644 --- a/src/structs/custom_properties/properties.rs +++ b/src/structs/custom_properties/properties.rs @@ -1,7 +1,7 @@ -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{CUSTOM_PROPS_NS, VTYPES_NS}; +use crate::reader::driver::xml_read_loop; use crate::structs::custom_properties::CustomDocumentProperty; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -16,6 +16,7 @@ pub struct Properties { impl Properties { #[inline] + #[must_use] pub fn get_custom_document_property_list(&self) -> &[CustomDocumentProperty] { &self.custom_document_property_list } diff --git a/src/structs/data_bar.rs b/src/structs/data_bar.rs index d05257fd..c5a89b9f 100644 --- a/src/structs/data_bar.rs +++ b/src/structs/data_bar.rs @@ -1,7 +1,7 @@ use super::Color; use super::ConditionalFormatValueObject; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -17,6 +17,7 @@ pub struct DataBar { impl DataBar { #[inline] + #[must_use] pub fn get_cfvo_collection(&self) -> &[ConditionalFormatValueObject] { &self.cfvo_collection } @@ -37,6 +38,7 @@ impl DataBar { } #[inline] + #[must_use] pub fn get_color_collection(&self) -> &[Color] { &self.color_collection } diff --git a/src/structs/data_field.rs b/src/structs/data_field.rs index af81a301..8badf534 100644 --- a/src/structs/data_field.rs +++ b/src/structs/data_field.rs @@ -1,9 +1,9 @@ // dataField -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::Int32Value; use crate::structs::StringValue; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct DataField { } impl DataField { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -30,6 +31,7 @@ impl DataField { } #[inline] + #[must_use] pub fn get_fie_id(&self) -> u32 { self.fie_id.get_value() } @@ -41,6 +43,7 @@ impl DataField { } #[inline] + #[must_use] pub fn get_base_fie_id(&self) -> i32 { self.base_fie_id.get_value() } @@ -52,6 +55,7 @@ impl DataField { } #[inline] + #[must_use] pub fn get_base_item(&self) -> u32 { self.base_item.get_value() } diff --git a/src/structs/data_fields.rs b/src/structs/data_fields.rs index 145d5d58..0d476602 100644 --- a/src/structs/data_fields.rs +++ b/src/structs/data_fields.rs @@ -1,7 +1,7 @@ // dataFields -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::DataField; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct DataFields { } impl DataFields { #[inline] + #[must_use] pub fn get_list(&self) -> &[DataField] { &self.list } diff --git a/src/structs/data_validation.rs b/src/structs/data_validation.rs index 6b3c2ef1..e8f9a4cf 100644 --- a/src/structs/data_validation.rs +++ b/src/structs/data_validation.rs @@ -5,8 +5,8 @@ use super::DataValidationValues; use super::EnumValue; use super::SequenceOfReferences; use super::StringValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -28,6 +28,7 @@ pub struct DataValidation { } impl DataValidation { #[inline] + #[must_use] pub fn get_type(&self) -> &DataValidationValues { self.r#type.get_value() } @@ -39,6 +40,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_operator(&self) -> &DataValidationOperatorValues { self.operator.get_value() } @@ -50,6 +52,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_allow_blank(&self) -> bool { self.allow_blank.get_value() } @@ -61,6 +64,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_show_input_message(&self) -> bool { self.show_input_message.get_value() } @@ -72,6 +76,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_show_error_message(&self) -> bool { self.show_error_message.get_value() } @@ -83,6 +88,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_prompt_title(&self) -> &str { self.prompt_title.get_value_str() } @@ -94,6 +100,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_prompt(&self) -> &str { self.prompt.get_value_str() } @@ -105,6 +112,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_sequence_of_references(&self) -> &SequenceOfReferences { &self.sequence_of_references } @@ -121,6 +129,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_formula1(&self) -> &str { self.formula1.get_value_str() } @@ -132,6 +141,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_formula2(&self) -> &str { self.formula2.get_value_str() } diff --git a/src/structs/data_validations.rs b/src/structs/data_validations.rs index 8b5c339d..71cdfd60 100644 --- a/src/structs/data_validations.rs +++ b/src/structs/data_validations.rs @@ -1,7 +1,7 @@ // dataValidations use super::DataValidation; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct DataValidations { impl DataValidations { #[inline] + #[must_use] pub fn get_data_validation_list(&self) -> &[DataValidation] { &self.data_validation_list } diff --git a/src/structs/defined_name.rs b/src/structs/defined_name.rs index 16acfa8e..10502902 100644 --- a/src/structs/defined_name.rs +++ b/src/structs/defined_name.rs @@ -2,10 +2,10 @@ use super::Address; use super::BooleanValue; use super::StringValue; use super::UInt32Value; -use crate::helper::address::*; -use crate::reader::driver::*; +use crate::helper::address::is_address; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node_conversion}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -22,6 +22,7 @@ pub struct DefinedName { } impl DefinedName { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -32,6 +33,7 @@ impl DefinedName { self } + #[must_use] pub fn get_address(&self) -> String { if self.string_value.has_value() { return self.string_value.get_value_str().to_string(); @@ -67,7 +69,7 @@ impl DefinedName { #[allow(dead_code)] pub(crate) fn get_sheet_name_crate(&self) -> String { if self.string_value.has_value() { - return String::from(""); + return String::new(); } self.address .first() @@ -95,11 +97,13 @@ impl DefinedName { } #[inline] + #[must_use] pub fn has_local_sheet_id(&self) -> bool { self.local_sheet_id.has_value() } #[inline] + #[must_use] pub fn get_local_sheet_id(&self) -> u32 { self.local_sheet_id.get_value() } @@ -110,6 +114,7 @@ impl DefinedName { } #[inline] + #[must_use] pub fn get_hidden(&self) -> bool { self.hidden.get_value() } @@ -126,7 +131,7 @@ impl DefinedName { let mut is_pass_d = false; let mut is_pass_b = 0; let mut result: Vec = Vec::new(); - let mut string = String::from(""); + let mut string = String::new(); for c in &char_list { match c { '(' => { @@ -182,7 +187,7 @@ impl DefinedName { set_string_from_xml!(self, e, local_sheet_id, "localSheetId"); set_string_from_xml!(self, e, hidden, "hidden"); - let mut value: String = String::from(""); + let mut value: String = String::new(); xml_read_loop!( reader, Event::Text(e) => { diff --git a/src/structs/differential_format.rs b/src/structs/differential_format.rs index c2e45165..22f1df5b 100644 --- a/src/structs/differential_format.rs +++ b/src/structs/differential_format.rs @@ -4,8 +4,8 @@ use super::Borders; use super::Fill; use super::Font; use super::Style; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; diff --git a/src/structs/differential_formats.rs b/src/structs/differential_formats.rs index bda8a29f..a6e4d0d8 100644 --- a/src/structs/differential_formats.rs +++ b/src/structs/differential_formats.rs @@ -1,8 +1,8 @@ // dxfs use super::DifferentialFormat; use super::Style; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/adjust_value_list.rs b/src/structs/drawing/adjust_value_list.rs index 4615cf13..aa766779 100644 --- a/src/structs/drawing/adjust_value_list.rs +++ b/src/structs/drawing/adjust_value_list.rs @@ -1,7 +1,7 @@ // a:avLst use super::shape_guide::ShapeGuide; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct AdjustValueList { impl AdjustValueList { #[inline] + #[must_use] pub fn get_shape_guide_collection(&self) -> &[ShapeGuide] { &self.shape_guide_collection } diff --git a/src/structs/drawing/alpha.rs b/src/structs/drawing/alpha.rs index d493bd16..61059784 100644 --- a/src/structs/drawing/alpha.rs +++ b/src/structs/drawing/alpha.rs @@ -1,6 +1,6 @@ // a:alpha -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Alpha { } impl Alpha { #[inline] + #[must_use] pub fn get_val(&self) -> &str { &self.val } diff --git a/src/structs/drawing/background_color.rs b/src/structs/drawing/background_color.rs index ee116662..29f5d94e 100644 --- a/src/structs/drawing/background_color.rs +++ b/src/structs/drawing/background_color.rs @@ -1,7 +1,7 @@ // a:bgClr use super::SchemeColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct BackgroundColor { impl BackgroundColor { #[inline] + #[must_use] pub fn get_scheme_color(&self) -> &SchemeColor { &self.scheme_color } diff --git a/src/structs/drawing/background_fill_style_list.rs b/src/structs/drawing/background_fill_style_list.rs index 7537a3b4..c34fc996 100644 --- a/src/structs/drawing/background_fill_style_list.rs +++ b/src/structs/drawing/background_fill_style_list.rs @@ -1,7 +1,7 @@ use super::GradientFill; use super::SolidFill; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct BackgroundFillStyleList { impl BackgroundFillStyleList { #[inline] + #[must_use] pub fn get_solid_fill(&self) -> &[SolidFill] { &self.solid_fill } @@ -38,6 +39,7 @@ impl BackgroundFillStyleList { } #[inline] + #[must_use] pub fn get_gradient_fill_collection(&self) -> &[GradientFill] { &self.gradient_fill_collection } diff --git a/src/structs/drawing/bevel.rs b/src/structs/drawing/bevel.rs index 72889188..88bff51e 100644 --- a/src/structs/drawing/bevel.rs +++ b/src/structs/drawing/bevel.rs @@ -1,5 +1,5 @@ // a:bevel -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/bevel_bottom.rs b/src/structs/drawing/bevel_bottom.rs index c2ece966..5ae7cc90 100644 --- a/src/structs/drawing/bevel_bottom.rs +++ b/src/structs/drawing/bevel_bottom.rs @@ -2,8 +2,8 @@ use super::super::EnumValue; use super::super::Int64Value; use super::BevelPresetValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct BevelBottom { impl BevelBottom { #[inline] + #[must_use] pub fn get_width(&self) -> i64 { self.width.get_value() } @@ -29,6 +30,7 @@ impl BevelBottom { } #[inline] + #[must_use] pub fn get_height(&self) -> i64 { self.height.get_value() } @@ -40,6 +42,7 @@ impl BevelBottom { } #[inline] + #[must_use] pub fn get_preset(&self) -> &BevelPresetValues { self.preset.get_value() } diff --git a/src/structs/drawing/bevel_top.rs b/src/structs/drawing/bevel_top.rs index 1f71ca5a..20880cb2 100644 --- a/src/structs/drawing/bevel_top.rs +++ b/src/structs/drawing/bevel_top.rs @@ -2,8 +2,8 @@ use super::super::EnumValue; use super::super::Int64Value; use super::BevelPresetValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct BevelTop { impl BevelTop { #[inline] + #[must_use] pub fn get_width(&self) -> i64 { self.width.get_value() } @@ -29,6 +30,7 @@ impl BevelTop { } #[inline] + #[must_use] pub fn get_height(&self) -> i64 { self.height.get_value() } @@ -40,6 +42,7 @@ impl BevelTop { } #[inline] + #[must_use] pub fn get_preset(&self) -> &BevelPresetValues { self.preset.get_value() } diff --git a/src/structs/drawing/blip.rs b/src/structs/drawing/blip.rs index 061c1d3a..3f55b638 100644 --- a/src/structs/drawing/blip.rs +++ b/src/structs/drawing/blip.rs @@ -1,9 +1,9 @@ // a:blip -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{DRAWING_MAIN_NS, REL_OFC_NS}; +use crate::reader::driver::{get_attribute, xml_read_loop}; use crate::structs::raw::RawRelationships; use crate::structs::MediaObject; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct Blip { impl Blip { #[inline] + #[must_use] pub fn get_image(&self) -> &MediaObject { &self.image } @@ -33,6 +34,7 @@ impl Blip { } #[inline] + #[must_use] pub fn get_cstate(&self) -> &str { &self.cstate } @@ -83,7 +85,7 @@ impl Blip { ) { // a:blip let r_id = self.image.get_rid(rel_list); - let r_id_str = format!("rId{}", r_id); + let r_id_str = format!("rId{r_id}"); let mut attributes: Vec<(&str, &str)> = Vec::new(); attributes.push(("xmlns:r", REL_OFC_NS)); attributes.push(("r:embed", r_id_str.as_str())); diff --git a/src/structs/drawing/blip_fill.rs b/src/structs/drawing/blip_fill.rs index a7c3b9a2..e81cd41b 100644 --- a/src/structs/drawing/blip_fill.rs +++ b/src/structs/drawing/blip_fill.rs @@ -3,9 +3,9 @@ use super::super::super::BooleanValue; use super::Blip; use super::SourceRectangle; use super::Stretch; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -21,6 +21,7 @@ pub struct BlipFill { impl BlipFill { #[inline] + #[must_use] pub fn get_rotate_with_shape(&self) -> bool { self.rotate_with_shape.get_value() } @@ -32,6 +33,7 @@ impl BlipFill { } #[inline] + #[must_use] pub fn get_source_rectangle(&self) -> Option<&SourceRectangle> { self.source_rectangle.as_deref() } @@ -48,6 +50,7 @@ impl BlipFill { } #[inline] + #[must_use] pub fn get_blip(&self) -> &Blip { &self.blip } @@ -64,6 +67,7 @@ impl BlipFill { } #[inline] + #[must_use] pub fn get_stretch(&self) -> &Stretch { &self.stretch } @@ -132,7 +136,7 @@ impl BlipFill { // 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())) + attributes.push(("rotWithShape", self.rotate_with_shape.get_value_string())); } write_start_tag(writer, "a:blipFill", attributes, false); diff --git a/src/structs/drawing/body_properties.rs b/src/structs/drawing/body_properties.rs index fe696a65..58279be1 100644 --- a/src/structs/drawing/body_properties.rs +++ b/src/structs/drawing/body_properties.rs @@ -3,8 +3,8 @@ use super::super::EnumValue; use super::super::Int32Value; use super::ShapeAutoFit; use super::TextWrappingValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute_value, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::StringValue; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -27,6 +27,7 @@ pub struct BodyProperties { impl BodyProperties { #[inline] + #[must_use] pub fn get_vert_overflow(&self) -> Option<&str> { self.vert_overflow.get_value() } @@ -38,6 +39,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_horz_overflow(&self) -> Option<&str> { self.horz_overflow.get_value() } @@ -49,6 +51,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_rtl_col(&self) -> Option<&str> { self.rtl_col.get_value() } @@ -60,6 +63,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_anchor(&self) -> Option<&str> { self.anchor.get_value() } @@ -71,6 +75,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_wrap(&self) -> &TextWrappingValues { self.wrap.get_value() } @@ -82,6 +87,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_left_inset(&self) -> i32 { self.left_inset.get_value() } @@ -92,6 +98,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_top_inset(&self) -> i32 { self.top_inset.get_value() } @@ -102,6 +109,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_right_inset(&self) -> i32 { self.right_inset.get_value() } @@ -112,6 +120,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_bottom_inset(&self) -> i32 { self.bottom_inset.get_value() } @@ -122,6 +131,7 @@ impl BodyProperties { } #[inline] + #[must_use] pub fn get_shape_auto_fit(&self) -> Option<&ShapeAutoFit> { self.shape_auto_fit.as_ref() } diff --git a/src/structs/drawing/camera.rs b/src/structs/drawing/camera.rs index b3a5025d..10c2db43 100644 --- a/src/structs/drawing/camera.rs +++ b/src/structs/drawing/camera.rs @@ -2,8 +2,8 @@ use super::super::EnumValue; use super::PresetCameraValues; use super::Rotation; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct Camera { impl Camera { #[inline] + #[must_use] pub fn get_preset(&self) -> &PresetCameraValues { self.preset.get_value() } @@ -28,6 +29,7 @@ impl Camera { } #[inline] + #[must_use] pub fn get_rotation(&self) -> Option<&Rotation> { self.rotation.as_deref() } diff --git a/src/structs/drawing/charts/area_3d_chart.rs b/src/structs/drawing/charts/area_3d_chart.rs index 6cf7e5cf..0e4400e8 100644 --- a/src/structs/drawing/charts/area_3d_chart.rs +++ b/src/structs/drawing/charts/area_3d_chart.rs @@ -5,9 +5,9 @@ use super::AxisId; use super::DataLabels; use super::Grouping; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct Area3DChart { } impl Area3DChart { + #[must_use] pub fn get_grouping(&self) -> &Grouping { &self.grouping } @@ -37,6 +38,7 @@ impl Area3DChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -50,6 +52,7 @@ impl Area3DChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -63,6 +66,7 @@ impl Area3DChart { self } + #[must_use] pub fn get_data_labels(&self) -> Option<&DataLabels> { self.data_labels.as_deref() } @@ -76,6 +80,7 @@ impl Area3DChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/area_chart.rs b/src/structs/drawing/charts/area_chart.rs index 7351abec..a2597b41 100644 --- a/src/structs/drawing/charts/area_chart.rs +++ b/src/structs/drawing/charts/area_chart.rs @@ -5,9 +5,9 @@ use super::AxisId; use super::DataLabels; use super::Grouping; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct AreaChart { } impl AreaChart { + #[must_use] pub fn get_grouping(&self) -> &Grouping { &self.grouping } @@ -37,6 +38,7 @@ impl AreaChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -50,6 +52,7 @@ impl AreaChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -63,6 +66,7 @@ impl AreaChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -76,6 +80,7 @@ impl AreaChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/area_chart_series.rs b/src/structs/drawing/charts/area_chart_series.rs index 8085b7e7..8dadb60b 100644 --- a/src/structs/drawing/charts/area_chart_series.rs +++ b/src/structs/drawing/charts/area_chart_series.rs @@ -16,7 +16,7 @@ use super::Values; use super::XValues; use super::YValues; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -43,6 +43,7 @@ pub struct AreaChartSeries { } impl AreaChartSeries { + #[must_use] pub fn get_index(&self) -> &Index { &self.index } @@ -56,6 +57,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_order(&self) -> &Order { &self.order } @@ -69,6 +71,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_series_text(&self) -> Option<&SeriesText> { self.series_text.as_ref() } @@ -82,6 +85,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_explosion(&self) -> Option<&Explosion> { self.explosion.as_ref() } @@ -95,6 +99,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_invert_if_negative(&self) -> Option<&InvertIfNegative> { self.invert_if_negative.as_ref() } @@ -108,6 +113,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_marker(&self) -> Option<&Marker> { self.marker.as_ref() } @@ -121,6 +127,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } @@ -134,6 +141,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_category_axis_data(&self) -> Option<&CategoryAxisData> { self.category_axis_data.as_ref() } @@ -147,6 +155,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_values(&self) -> Option<&Values> { self.values.as_ref() } @@ -160,6 +169,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_x_values(&self) -> Option<&XValues> { self.x_values.as_ref() } @@ -173,6 +183,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_y_values(&self) -> Option<&YValues> { self.y_values.as_ref() } @@ -186,6 +197,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_bubble_size(&self) -> Option<&BubbleSize> { self.bubble_size.as_ref() } @@ -199,6 +211,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_bubble_3d(&self) -> Option<&Bubble3D> { self.bubble_3d.as_ref() } @@ -212,6 +225,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_smooth(&self) -> Option<&Smooth> { self.smooth.as_ref() } @@ -225,6 +239,7 @@ impl AreaChartSeries { self } + #[must_use] pub fn get_data_labels(&self) -> Option<&DataLabels> { self.data_labels.as_ref() } diff --git a/src/structs/drawing/charts/area_chart_series_list.rs b/src/structs/drawing/charts/area_chart_series_list.rs index 855eb33a..30d5b4b6 100644 --- a/src/structs/drawing/charts/area_chart_series_list.rs +++ b/src/structs/drawing/charts/area_chart_series_list.rs @@ -6,6 +6,7 @@ pub struct AreaChartSeriesList { area_chart_series: ThinVec, } impl AreaChartSeriesList { + #[must_use] pub fn get_area_chart_series(&self) -> &[AreaChartSeries] { &self.area_chart_series } diff --git a/src/structs/drawing/charts/auto_labeled.rs b/src/structs/drawing/charts/auto_labeled.rs index e05bb02d..17bfcca2 100644 --- a/src/structs/drawing/charts/auto_labeled.rs +++ b/src/structs/drawing/charts/auto_labeled.rs @@ -1,7 +1,7 @@ // c:auto use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct AutoLabeled { val: BooleanValue, } impl AutoLabeled { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/auto_title_deleted.rs b/src/structs/drawing/charts/auto_title_deleted.rs index 16345cbf..cc6afe0d 100644 --- a/src/structs/drawing/charts/auto_title_deleted.rs +++ b/src/structs/drawing/charts/auto_title_deleted.rs @@ -1,7 +1,7 @@ // c:autoTitleDeleted use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct AutoTitleDeleted { val: BooleanValue, } impl AutoTitleDeleted { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/axis_id.rs b/src/structs/drawing/charts/axis_id.rs index 159b7e83..da74cbd6 100644 --- a/src/structs/drawing/charts/axis_id.rs +++ b/src/structs/drawing/charts/axis_id.rs @@ -1,7 +1,7 @@ // c:axId use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct AxisId { val: UInt32Value, } impl AxisId { + #[must_use] pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/axis_position.rs b/src/structs/drawing/charts/axis_position.rs index 819503e6..23187083 100644 --- a/src/structs/drawing/charts/axis_position.rs +++ b/src/structs/drawing/charts/axis_position.rs @@ -1,8 +1,8 @@ // c:axPos use super::super::super::EnumValue; use super::AxisPositionValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct AxisPosition { val: EnumValue, } impl AxisPosition { + #[must_use] pub fn get_val(&self) -> &AxisPositionValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/back_wall.rs b/src/structs/drawing/charts/back_wall.rs index 7210bb23..bfc35ceb 100644 --- a/src/structs/drawing/charts/back_wall.rs +++ b/src/structs/drawing/charts/back_wall.rs @@ -1,8 +1,8 @@ // c:backWall use super::ShapeProperties; use super::Thickness; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct BackWall { } impl BackWall { + #[must_use] pub fn get_thickness(&self) -> Option<&Thickness> { self.thickness.as_ref() } @@ -28,6 +29,7 @@ impl BackWall { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } diff --git a/src/structs/drawing/charts/bar_3d_chart.rs b/src/structs/drawing/charts/bar_3d_chart.rs index 93e7a8af..81fcc311 100644 --- a/src/structs/drawing/charts/bar_3d_chart.rs +++ b/src/structs/drawing/charts/bar_3d_chart.rs @@ -8,9 +8,9 @@ use super::GapWidth; use super::Grouping; use super::Shape; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -30,6 +30,7 @@ pub struct Bar3DChart { } impl Bar3DChart { + #[must_use] pub fn get_bar_direction(&self) -> &BarDirection { &self.bar_direction } @@ -43,6 +44,7 @@ impl Bar3DChart { self } + #[must_use] pub fn get_grouping(&self) -> &Grouping { &self.grouping } @@ -56,6 +58,7 @@ impl Bar3DChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -69,6 +72,7 @@ impl Bar3DChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -82,6 +86,7 @@ impl Bar3DChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -95,6 +100,7 @@ impl Bar3DChart { self } + #[must_use] pub fn get_gap_width(&self) -> &GapWidth { &self.gap_width } @@ -108,6 +114,7 @@ impl Bar3DChart { self } + #[must_use] pub fn get_shape(&self) -> &Shape { &self.shape } @@ -121,6 +128,7 @@ impl Bar3DChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/bar_chart.rs b/src/structs/drawing/charts/bar_chart.rs index c3c06279..3747cc5b 100644 --- a/src/structs/drawing/charts/bar_chart.rs +++ b/src/structs/drawing/charts/bar_chart.rs @@ -8,9 +8,9 @@ use super::GapWidth; use super::Grouping; use super::Overlap; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -30,6 +30,7 @@ pub struct BarChart { } impl BarChart { + #[must_use] pub fn get_bar_direction(&self) -> &BarDirection { &self.bar_direction } @@ -43,6 +44,7 @@ impl BarChart { self } + #[must_use] pub fn get_grouping(&self) -> &Grouping { &self.grouping } @@ -56,6 +58,7 @@ impl BarChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -69,6 +72,7 @@ impl BarChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -82,6 +86,7 @@ impl BarChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -95,6 +100,7 @@ impl BarChart { self } + #[must_use] pub fn get_gap_width(&self) -> &GapWidth { &self.gap_width } @@ -108,6 +114,7 @@ impl BarChart { self } + #[must_use] pub fn get_overlap(&self) -> &Overlap { &self.overlap } @@ -121,6 +128,7 @@ impl BarChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/bar_direction.rs b/src/structs/drawing/charts/bar_direction.rs index 81434780..d474da4b 100644 --- a/src/structs/drawing/charts/bar_direction.rs +++ b/src/structs/drawing/charts/bar_direction.rs @@ -1,8 +1,8 @@ // c:barDir use super::super::super::EnumValue; use super::BarDirectionValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct BarDirection { val: EnumValue, } impl BarDirection { + #[must_use] pub fn get_val(&self) -> &BarDirectionValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/bubble_3d.rs b/src/structs/drawing/charts/bubble_3d.rs index 417ee1ad..eb35c8f3 100644 --- a/src/structs/drawing/charts/bubble_3d.rs +++ b/src/structs/drawing/charts/bubble_3d.rs @@ -1,7 +1,7 @@ // c:bubble3D use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Bubble3D { val: BooleanValue, } impl Bubble3D { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/bubble_chart.rs b/src/structs/drawing/charts/bubble_chart.rs index 5f14e444..46386f33 100644 --- a/src/structs/drawing/charts/bubble_chart.rs +++ b/src/structs/drawing/charts/bubble_chart.rs @@ -6,9 +6,9 @@ use super::BubbleScale; use super::DataLabels; use super::ShowNegativeBubbles; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -26,6 +26,7 @@ pub struct BubbleChart { } impl BubbleChart { + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -39,6 +40,7 @@ impl BubbleChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -52,6 +54,7 @@ impl BubbleChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -65,6 +68,7 @@ impl BubbleChart { self } + #[must_use] pub fn get_bubble_scale(&self) -> &BubbleScale { &self.bubble_scale } @@ -78,6 +82,7 @@ impl BubbleChart { self } + #[must_use] pub fn get_show_negative_bubbles(&self) -> &ShowNegativeBubbles { &self.show_negative_bubbles } @@ -91,6 +96,7 @@ impl BubbleChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/bubble_scale.rs b/src/structs/drawing/charts/bubble_scale.rs index 39107b3b..334e6747 100644 --- a/src/structs/drawing/charts/bubble_scale.rs +++ b/src/structs/drawing/charts/bubble_scale.rs @@ -1,7 +1,7 @@ // c:bubbleScale use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct BubbleScale { val: UInt32Value, } impl BubbleScale { + #[must_use] pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/bubble_size.rs b/src/structs/drawing/charts/bubble_size.rs index 04d11029..ff1d74bf 100644 --- a/src/structs/drawing/charts/bubble_size.rs +++ b/src/structs/drawing/charts/bubble_size.rs @@ -1,8 +1,8 @@ // c:bubbleSize use super::NumberReference; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct BubbleSize { } impl BubbleSize { + #[must_use] pub fn get_number_reference(&self) -> &NumberReference { &self.number_reference } diff --git a/src/structs/drawing/charts/category_axis.rs b/src/structs/drawing/charts/category_axis.rs index 8ecaff2b..eb90d491 100644 --- a/src/structs/drawing/charts/category_axis.rs +++ b/src/structs/drawing/charts/category_axis.rs @@ -18,7 +18,7 @@ use super::ShapeProperties; use super::TextProperties; use super::TickLabelPosition; use super::Title; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -46,6 +46,7 @@ pub struct CategoryAxis { } impl CategoryAxis { + #[must_use] pub fn get_axis_id(&self) -> &AxisId { &self.axis_id } @@ -59,6 +60,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_scaling(&self) -> &Scaling { &self.scaling } @@ -72,6 +74,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_delete(&self) -> &Delete { &self.delete } @@ -85,6 +88,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_axis_position(&self) -> &AxisPosition { &self.axis_position } @@ -98,6 +102,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_title(&self) -> Option<&Title> { self.title.as_ref() } @@ -111,6 +116,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_major_gridlines(&self) -> Option<&MajorGridlines> { self.major_gridlines.as_ref() } @@ -124,6 +130,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_major_tick_mark(&self) -> &MajorTickMark { &self.major_tick_mark } @@ -137,6 +144,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_minor_tick_mark(&self) -> &MinorTickMark { &self.minor_tick_mark } @@ -150,6 +158,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_tick_label_position(&self) -> &TickLabelPosition { &self.tick_label_position } @@ -163,6 +172,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_tick_crossing_axis(&self) -> &CrossingAxis { &self.crossing_axis } @@ -176,6 +186,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_crosses(&self) -> &Crosses { &self.crosses } @@ -189,6 +200,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_auto_labeled(&self) -> &AutoLabeled { &self.auto_labeled } @@ -202,6 +214,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_label_alignment(&self) -> &LabelAlignment { &self.label_alignment } @@ -215,6 +228,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_label_offset(&self) -> &LabelOffset { &self.label_offset } @@ -228,6 +242,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_no_multi_level_labels(&self) -> &NoMultiLevelLabels { &self.no_multi_level_labels } @@ -241,6 +256,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } @@ -254,6 +270,7 @@ impl CategoryAxis { self } + #[must_use] pub fn get_text_properties(&self) -> Option<&TextProperties> { self.text_properties.as_ref() } diff --git a/src/structs/drawing/charts/category_axis_data.rs b/src/structs/drawing/charts/category_axis_data.rs index 40ab62eb..c05e2166 100644 --- a/src/structs/drawing/charts/category_axis_data.rs +++ b/src/structs/drawing/charts/category_axis_data.rs @@ -1,9 +1,9 @@ // c:cat use super::StringLiteral; use super::StringReference; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct CategoryAxisData { } impl CategoryAxisData { + #[must_use] pub fn get_string_reference(&self) -> Option<&StringReference> { self.string_reference.as_ref() } @@ -34,6 +35,7 @@ impl CategoryAxisData { self } + #[must_use] pub fn get_string_literal(&self) -> Option<&StringLiteral> { self.string_literal.as_ref() } diff --git a/src/structs/drawing/charts/chart.rs b/src/structs/drawing/charts/chart.rs index 39288e06..bf32fcfa 100644 --- a/src/structs/drawing/charts/chart.rs +++ b/src/structs/drawing/charts/chart.rs @@ -12,7 +12,7 @@ use super::Title; use super::View3D; use crate::structs::Spreadsheet; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -38,6 +38,7 @@ impl Chart { pub const LANG_EN_GB: &'static str = "en_GB"; pub const LANG_JA_JP: &'static str = "ja-JP"; + #[must_use] pub fn get_title(&self) -> Option<&Title> { self.title.as_ref() } @@ -51,6 +52,7 @@ impl Chart { self } + #[must_use] pub fn get_auto_title_deleted(&self) -> &AutoTitleDeleted { &self.auto_title_deleted } @@ -64,6 +66,7 @@ impl Chart { self } + #[must_use] pub fn get_view_3d(&self) -> Option<&View3D> { self.view_3d.as_ref() } @@ -77,6 +80,7 @@ impl Chart { self } + #[must_use] pub fn get_floor(&self) -> Option<&Floor> { self.floor.as_ref() } @@ -90,6 +94,7 @@ impl Chart { self } + #[must_use] pub fn get_side_wall(&self) -> Option<&SideWall> { self.side_wall.as_ref() } @@ -103,6 +108,7 @@ impl Chart { self } + #[must_use] pub fn get_back_wall(&self) -> Option<&BackWall> { self.back_wall.as_ref() } @@ -116,6 +122,7 @@ impl Chart { self } + #[must_use] pub fn get_plot_area(&self) -> &PlotArea { &self.plot_area } @@ -129,6 +136,7 @@ impl Chart { self } + #[must_use] pub fn get_legend(&self) -> &Legend { &self.legend } @@ -142,6 +150,7 @@ impl Chart { self } + #[must_use] pub fn get_plot_visible_only(&self) -> &PlotVisibleOnly { &self.plot_visible_only } @@ -155,6 +164,7 @@ impl Chart { self } + #[must_use] pub fn get_display_blanks_as(&self) -> &DisplayBlanksAs { &self.display_blanks_as } @@ -168,6 +178,7 @@ impl Chart { self } + #[must_use] pub fn get_show_data_labels_over_maximum(&self) -> &ShowDataLabelsOverMaximum { &self.show_data_labels_over_maximum } diff --git a/src/structs/drawing/charts/chart_space.rs b/src/structs/drawing/charts/chart_space.rs index b229aa47..3a234b66 100644 --- a/src/structs/drawing/charts/chart_space.rs +++ b/src/structs/drawing/charts/chart_space.rs @@ -7,11 +7,11 @@ use super::EditingLanguage; use super::PrintSettings; use super::RoundedCorners; use super::ShapeProperties; -use crate::helper::const_str::*; +use crate::helper::const_str::{DRAWINGML_CHART_NS, DRAWINGML_MAIN_NS, REL_OFC_NS}; use crate::structs::office2010::drawing::charts::Style; use crate::structs::Spreadsheet; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -29,6 +29,7 @@ pub struct ChartSpace { } impl ChartSpace { + #[must_use] pub fn get_date1904(&self) -> &Date1904 { &self.date1904 } @@ -42,6 +43,7 @@ impl ChartSpace { self } + #[must_use] pub fn get_editing_language(&self) -> &EditingLanguage { &self.editing_language } @@ -55,6 +57,7 @@ impl ChartSpace { self } + #[must_use] pub fn get_rounded_corners(&self) -> &RoundedCorners { &self.rounded_corners } @@ -68,6 +71,7 @@ impl ChartSpace { self } + #[must_use] pub fn get_style(&self) -> &Style { &self.style } @@ -81,6 +85,7 @@ impl ChartSpace { self } + #[must_use] pub fn get_chart(&self) -> &Chart { &self.chart } @@ -94,6 +99,7 @@ impl ChartSpace { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } @@ -107,6 +113,7 @@ impl ChartSpace { self } + #[must_use] pub fn get_print_settings(&self) -> Option<&PrintSettings> { self.print_settings.as_ref() } diff --git a/src/structs/drawing/charts/chart_text.rs b/src/structs/drawing/charts/chart_text.rs index 31a60732..3cf5ba4c 100644 --- a/src/structs/drawing/charts/chart_text.rs +++ b/src/structs/drawing/charts/chart_text.rs @@ -1,6 +1,6 @@ // c:tx use super::RichText; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -13,6 +13,7 @@ pub struct ChartText { } impl ChartText { + #[must_use] pub fn get_rich_text(&self) -> &RichText { &self.rich_text } diff --git a/src/structs/drawing/charts/cross_between.rs b/src/structs/drawing/charts/cross_between.rs index 850a55bb..01315aaf 100644 --- a/src/structs/drawing/charts/cross_between.rs +++ b/src/structs/drawing/charts/cross_between.rs @@ -1,8 +1,8 @@ // c:crossBetween use super::super::super::EnumValue; use super::CrossBetweenValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct CrossBetween { val: EnumValue, } impl CrossBetween { + #[must_use] pub fn get_val(&self) -> &CrossBetweenValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/crosses.rs b/src/structs/drawing/charts/crosses.rs index 785aab13..b98eb7f1 100644 --- a/src/structs/drawing/charts/crosses.rs +++ b/src/structs/drawing/charts/crosses.rs @@ -1,8 +1,8 @@ // c:crosses use super::super::super::EnumValue; use super::CrossesValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Crosses { val: EnumValue, } impl Crosses { + #[must_use] pub fn get_val(&self) -> &CrossesValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/crossing_axis.rs b/src/structs/drawing/charts/crossing_axis.rs index fb576309..bb40bf14 100644 --- a/src/structs/drawing/charts/crossing_axis.rs +++ b/src/structs/drawing/charts/crossing_axis.rs @@ -1,7 +1,7 @@ // c:crossAx use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct CrossingAxis { val: UInt32Value, } impl CrossingAxis { + #[must_use] pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/data_labels.rs b/src/structs/drawing/charts/data_labels.rs index eb4a8bdb..235d431b 100644 --- a/src/structs/drawing/charts/data_labels.rs +++ b/src/structs/drawing/charts/data_labels.rs @@ -7,8 +7,8 @@ use super::ShowPercent; use super::ShowSeriesName; use super::ShowValue; use super::TextProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -27,6 +27,7 @@ pub struct DataLabels { } impl DataLabels { + #[must_use] pub fn get_show_legend_key(&self) -> &ShowLegendKey { &self.show_legend_key } @@ -40,6 +41,7 @@ impl DataLabels { self } + #[must_use] pub fn get_show_value(&self) -> &ShowValue { &self.show_value } @@ -53,6 +55,7 @@ impl DataLabels { self } + #[must_use] pub fn get_show_category_name(&self) -> &ShowCategoryName { &self.show_category_name } @@ -66,6 +69,7 @@ impl DataLabels { self } + #[must_use] pub fn get_show_series_name(&self) -> &ShowSeriesName { &self.show_series_name } @@ -79,6 +83,7 @@ impl DataLabels { self } + #[must_use] pub fn get_show_percent(&self) -> &ShowPercent { &self.show_percent } @@ -92,6 +97,7 @@ impl DataLabels { self } + #[must_use] pub fn get_show_bubble_size(&self) -> &ShowBubbleSize { &self.show_bubble_size } @@ -105,6 +111,7 @@ impl DataLabels { self } + #[must_use] pub fn get_show_leader_lines(&self) -> Option<&ShowLeaderLines> { self.show_leader_lines.as_ref() } @@ -118,6 +125,7 @@ impl DataLabels { self } + #[must_use] pub fn get_text_properties(&self) -> Option<&TextProperties> { self.text_properties.as_ref() } diff --git a/src/structs/drawing/charts/date1904.rs b/src/structs/drawing/charts/date1904.rs index fabc9b09..5ffc7994 100644 --- a/src/structs/drawing/charts/date1904.rs +++ b/src/structs/drawing/charts/date1904.rs @@ -1,7 +1,7 @@ // c:h use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Date1904 { val: BooleanValue, } impl Date1904 { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/delete.rs b/src/structs/drawing/charts/delete.rs index 54d12f55..40dd1441 100644 --- a/src/structs/drawing/charts/delete.rs +++ b/src/structs/drawing/charts/delete.rs @@ -1,7 +1,7 @@ // c:delete use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Delete { val: BooleanValue, } impl Delete { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/display_blanks_as.rs b/src/structs/drawing/charts/display_blanks_as.rs index b44c202f..bd4d67e3 100644 --- a/src/structs/drawing/charts/display_blanks_as.rs +++ b/src/structs/drawing/charts/display_blanks_as.rs @@ -1,8 +1,8 @@ // c:dispBlanksAs use super::super::super::EnumValue; use super::DisplayBlanksAsValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct DisplayBlanksAs { val: EnumValue, } impl DisplayBlanksAs { + #[must_use] pub fn get_val(&self) -> &DisplayBlanksAsValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/doughnut_chart.rs b/src/structs/drawing/charts/doughnut_chart.rs index 53d510e6..ee61060f 100644 --- a/src/structs/drawing/charts/doughnut_chart.rs +++ b/src/structs/drawing/charts/doughnut_chart.rs @@ -5,9 +5,9 @@ use super::DataLabels; use super::FirstSliceAngle; use super::HoleSize; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -23,6 +23,7 @@ pub struct DoughnutChart { } impl DoughnutChart { + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -36,6 +37,7 @@ impl DoughnutChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -49,6 +51,7 @@ impl DoughnutChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -62,6 +65,7 @@ impl DoughnutChart { self } + #[must_use] pub fn get_first_slice_angle(&self) -> &FirstSliceAngle { &self.first_slice_angle } @@ -75,6 +79,7 @@ impl DoughnutChart { self } + #[must_use] pub fn get_hole_size(&self) -> &HoleSize { &self.hole_size } diff --git a/src/structs/drawing/charts/editing_language.rs b/src/structs/drawing/charts/editing_language.rs index 5bc17cad..bc124d5e 100644 --- a/src/structs/drawing/charts/editing_language.rs +++ b/src/structs/drawing/charts/editing_language.rs @@ -1,7 +1,7 @@ // c:lang use super::super::super::StringValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct EditingLanguage { val: StringValue, } impl EditingLanguage { + #[must_use] pub fn get_val(&self) -> &str { self.val.get_value_str() } diff --git a/src/structs/drawing/charts/explosion.rs b/src/structs/drawing/charts/explosion.rs index 4c95d3c7..7c067d51 100644 --- a/src/structs/drawing/charts/explosion.rs +++ b/src/structs/drawing/charts/explosion.rs @@ -1,7 +1,7 @@ // c:explosion use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Explosion { val: UInt32Value, } impl Explosion { + #[must_use] pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/first_slice_angle.rs b/src/structs/drawing/charts/first_slice_angle.rs index 71721f7a..f0683da0 100644 --- a/src/structs/drawing/charts/first_slice_angle.rs +++ b/src/structs/drawing/charts/first_slice_angle.rs @@ -1,7 +1,7 @@ // c:firstSliceAng use super::super::super::UInt16Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct FirstSliceAngle { val: UInt16Value, } impl FirstSliceAngle { + #[must_use] pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/floor.rs b/src/structs/drawing/charts/floor.rs index 4ed34d78..12bba039 100644 --- a/src/structs/drawing/charts/floor.rs +++ b/src/structs/drawing/charts/floor.rs @@ -1,8 +1,8 @@ // c:marker use super::ShapeProperties; use super::Thickness; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct Floor { } impl Floor { + #[must_use] pub fn get_thickness(&self) -> Option<&Thickness> { self.thickness.as_ref() } @@ -28,6 +29,7 @@ impl Floor { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_deref() } diff --git a/src/structs/drawing/charts/format_code.rs b/src/structs/drawing/charts/format_code.rs index d5b1f478..4142a0c5 100644 --- a/src/structs/drawing/charts/format_code.rs +++ b/src/structs/drawing/charts/format_code.rs @@ -1,5 +1,5 @@ // c:formatCode -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct FormatCode { } impl FormatCode { + #[must_use] pub fn get_text(&self) -> &str { &self.text } diff --git a/src/structs/drawing/charts/formula.rs b/src/structs/drawing/charts/formula.rs index 568fa1af..b2e8d24f 100644 --- a/src/structs/drawing/charts/formula.rs +++ b/src/structs/drawing/charts/formula.rs @@ -3,9 +3,9 @@ use crate::xml_read_loop; // c:f use super::super::super::Address; use super::super::super::StringValue; -use crate::helper::address::*; +use crate::helper::address::is_address; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node_no_escape}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct Formula { } impl Formula { + #[must_use] pub fn get_address(&self) -> &Address { &self.address } @@ -26,6 +27,7 @@ impl Formula { &mut self.address } + #[must_use] pub fn get_address_str(&self) -> String { if self.string_value.has_value() { return self.string_value.get_value_str().to_string(); diff --git a/src/structs/drawing/charts/gap_width.rs b/src/structs/drawing/charts/gap_width.rs index 77c784a3..10ed3f32 100644 --- a/src/structs/drawing/charts/gap_width.rs +++ b/src/structs/drawing/charts/gap_width.rs @@ -1,7 +1,7 @@ // c:gapWidth use super::super::super::UInt16Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct GapWidth { val: UInt16Value, } impl GapWidth { + #[must_use] pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/grouping.rs b/src/structs/drawing/charts/grouping.rs index 78576e9e..fb17ce42 100644 --- a/src/structs/drawing/charts/grouping.rs +++ b/src/structs/drawing/charts/grouping.rs @@ -1,8 +1,8 @@ // c:grouping use super::super::super::EnumValue; use super::GroupingValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Grouping { val: EnumValue, } impl Grouping { + #[must_use] pub fn get_val(&self) -> &GroupingValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/header_footer.rs b/src/structs/drawing/charts/header_footer.rs index 601e905b..750d07a3 100644 --- a/src/structs/drawing/charts/header_footer.rs +++ b/src/structs/drawing/charts/header_footer.rs @@ -1,5 +1,5 @@ // c:headerFooter -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/charts/height.rs b/src/structs/drawing/charts/height.rs index 675d1a4a..b70c37de 100644 --- a/src/structs/drawing/charts/height.rs +++ b/src/structs/drawing/charts/height.rs @@ -1,7 +1,7 @@ // c:h use super::super::super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Height { val: DoubleValue, } impl Height { + #[must_use] pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/height_mode.rs b/src/structs/drawing/charts/height_mode.rs index 5ddd6f52..e7518e66 100644 --- a/src/structs/drawing/charts/height_mode.rs +++ b/src/structs/drawing/charts/height_mode.rs @@ -1,8 +1,8 @@ // c:hMode use super::super::super::EnumValue; use super::LayoutModeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct HeightMode { val: EnumValue, } impl HeightMode { + #[must_use] pub fn get_val(&self) -> &LayoutModeValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/hole_size.rs b/src/structs/drawing/charts/hole_size.rs index e791dfe8..67d8f9db 100644 --- a/src/structs/drawing/charts/hole_size.rs +++ b/src/structs/drawing/charts/hole_size.rs @@ -1,7 +1,7 @@ // c:holeSize use super::super::super::ByteValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct HoleSize { val: ByteValue, } impl HoleSize { + #[must_use] pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/index.rs b/src/structs/drawing/charts/index.rs index cbd4cd0d..c86b79f1 100644 --- a/src/structs/drawing/charts/index.rs +++ b/src/structs/drawing/charts/index.rs @@ -1,7 +1,7 @@ // c:idx use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Index { val: UInt32Value, } impl Index { + #[must_use] pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/invert_if_negative.rs b/src/structs/drawing/charts/invert_if_negative.rs index 03f3644a..61ab6db1 100644 --- a/src/structs/drawing/charts/invert_if_negative.rs +++ b/src/structs/drawing/charts/invert_if_negative.rs @@ -1,7 +1,7 @@ // c:invertIfNegative use super::super::super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct InvertIfNegative { val: DoubleValue, } impl InvertIfNegative { + #[must_use] pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/label_alignment.rs b/src/structs/drawing/charts/label_alignment.rs index db8bd280..8e7ef8a2 100644 --- a/src/structs/drawing/charts/label_alignment.rs +++ b/src/structs/drawing/charts/label_alignment.rs @@ -1,8 +1,8 @@ // c:lblAlgn use super::super::super::EnumValue; use super::LabelAlignmentValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct LabelAlignment { val: EnumValue, } impl LabelAlignment { + #[must_use] pub fn get_val(&self) -> &LabelAlignmentValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/label_offset.rs b/src/structs/drawing/charts/label_offset.rs index 259831ad..580775f6 100644 --- a/src/structs/drawing/charts/label_offset.rs +++ b/src/structs/drawing/charts/label_offset.rs @@ -1,7 +1,7 @@ // c:lblOffset use super::super::super::UInt16Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct LabelOffset { val: UInt16Value, } impl LabelOffset { + #[must_use] pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/layout.rs b/src/structs/drawing/charts/layout.rs index 74b249fc..1f6af069 100644 --- a/src/structs/drawing/charts/layout.rs +++ b/src/structs/drawing/charts/layout.rs @@ -1,6 +1,6 @@ // c:layout use super::ManualLayout; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -13,6 +13,7 @@ pub struct Layout { } impl Layout { + #[must_use] pub fn get_manual_layout(&self) -> Option<&ManualLayout> { self.manual_layout.as_ref() } @@ -26,6 +27,7 @@ impl Layout { self } + #[must_use] pub fn is_empty(&self) -> bool { self.manual_layout.is_none() } diff --git a/src/structs/drawing/charts/layout_target.rs b/src/structs/drawing/charts/layout_target.rs index f7538a47..0e8c26aa 100644 --- a/src/structs/drawing/charts/layout_target.rs +++ b/src/structs/drawing/charts/layout_target.rs @@ -1,8 +1,8 @@ // c:layoutTarget use super::super::super::EnumValue; use super::LayoutTargetValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct LayoutTarget { val: EnumValue, } impl LayoutTarget { + #[must_use] pub fn get_val(&self) -> &LayoutTargetValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/left.rs b/src/structs/drawing/charts/left.rs index bd34445f..69feab44 100644 --- a/src/structs/drawing/charts/left.rs +++ b/src/structs/drawing/charts/left.rs @@ -1,7 +1,7 @@ // c:x use super::super::super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Left { val: DoubleValue, } impl Left { + #[must_use] pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/left_mode.rs b/src/structs/drawing/charts/left_mode.rs index 55b2e43c..82ae92e9 100644 --- a/src/structs/drawing/charts/left_mode.rs +++ b/src/structs/drawing/charts/left_mode.rs @@ -1,8 +1,8 @@ // c:xMode use super::super::super::EnumValue; use super::LayoutModeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct LeftMode { val: EnumValue, } impl LeftMode { + #[must_use] pub fn get_val(&self) -> &LayoutModeValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/legend.rs b/src/structs/drawing/charts/legend.rs index a2963ea9..a4650984 100644 --- a/src/structs/drawing/charts/legend.rs +++ b/src/structs/drawing/charts/legend.rs @@ -5,7 +5,7 @@ use super::LegendPosition; use super::Overlay; use super::ShapeProperties; use super::TextProperties; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -21,6 +21,7 @@ pub struct Legend { } impl Legend { + #[must_use] pub fn get_legend_position(&self) -> &LegendPosition { &self.legend_position } @@ -34,6 +35,7 @@ impl Legend { self } + #[must_use] pub fn get_layout(&self) -> Option<&Layout> { self.layout.as_deref() } @@ -47,6 +49,7 @@ impl Legend { self } + #[must_use] pub fn get_overlay(&self) -> &Overlay { &self.overlay } @@ -60,6 +63,7 @@ impl Legend { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_deref() } @@ -73,6 +77,7 @@ impl Legend { self } + #[must_use] pub fn get_text_properties(&self) -> Option<&TextProperties> { self.text_properties.as_deref() } diff --git a/src/structs/drawing/charts/legend_position.rs b/src/structs/drawing/charts/legend_position.rs index 75cf8133..66253417 100644 --- a/src/structs/drawing/charts/legend_position.rs +++ b/src/structs/drawing/charts/legend_position.rs @@ -1,8 +1,8 @@ // c:legendPos use super::super::super::EnumValue; use super::LegendPositionValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct LegendPosition { val: EnumValue, } impl LegendPosition { + #[must_use] pub fn get_val(&self) -> &LegendPositionValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/line_3d_chart.rs b/src/structs/drawing/charts/line_3d_chart.rs index d1ba58d6..bd69e9ed 100644 --- a/src/structs/drawing/charts/line_3d_chart.rs +++ b/src/structs/drawing/charts/line_3d_chart.rs @@ -5,9 +5,9 @@ use super::AxisId; use super::DataLabels; use super::Grouping; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct Line3DChart { } impl Line3DChart { + #[must_use] pub fn get_grouping(&self) -> &Grouping { &self.grouping } @@ -37,6 +38,7 @@ impl Line3DChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -50,6 +52,7 @@ impl Line3DChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -63,6 +66,7 @@ impl Line3DChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -76,6 +80,7 @@ impl Line3DChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/line_chart.rs b/src/structs/drawing/charts/line_chart.rs index e4cf015b..64709541 100644 --- a/src/structs/drawing/charts/line_chart.rs +++ b/src/structs/drawing/charts/line_chart.rs @@ -10,7 +10,7 @@ use super::ShowMarker; use super::Smooth; use super::VaryColors; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -29,6 +29,7 @@ pub struct LineChart { } impl LineChart { + #[must_use] pub fn get_grouping(&self) -> &Grouping { &self.grouping } @@ -42,6 +43,7 @@ impl LineChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -55,6 +57,7 @@ impl LineChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -68,6 +71,7 @@ impl LineChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -81,6 +85,7 @@ impl LineChart { self } + #[must_use] pub fn get_show_marker(&self) -> &ShowMarker { &self.show_marker } @@ -94,6 +99,7 @@ impl LineChart { self } + #[must_use] pub fn get_smooth(&self) -> &Smooth { &self.smooth } @@ -107,6 +113,7 @@ impl LineChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/major_gridlines.rs b/src/structs/drawing/charts/major_gridlines.rs index ff8ecba6..7ec0c955 100644 --- a/src/structs/drawing/charts/major_gridlines.rs +++ b/src/structs/drawing/charts/major_gridlines.rs @@ -1,7 +1,7 @@ // c:majorGridlines use super::ShapeProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct MajorGridlines { } impl MajorGridlines { + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } diff --git a/src/structs/drawing/charts/major_tick_mark.rs b/src/structs/drawing/charts/major_tick_mark.rs index a1dfebbb..f77773b5 100644 --- a/src/structs/drawing/charts/major_tick_mark.rs +++ b/src/structs/drawing/charts/major_tick_mark.rs @@ -1,8 +1,8 @@ // c:majorTickMark use super::super::super::EnumValue; use super::TickMarkValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct MajorTickMark { val: EnumValue, } impl MajorTickMark { + #[must_use] pub fn get_val(&self) -> &TickMarkValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/manual_layout.rs b/src/structs/drawing/charts/manual_layout.rs index e085de8b..5e732f6d 100644 --- a/src/structs/drawing/charts/manual_layout.rs +++ b/src/structs/drawing/charts/manual_layout.rs @@ -8,7 +8,7 @@ use super::Top; use super::TopMode; use super::Width; use super::WidthMode; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -29,6 +29,7 @@ pub struct ManualLayout { } impl ManualLayout { + #[must_use] pub fn get_height(&self) -> Option<&Height> { self.height.as_ref() } @@ -42,6 +43,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_height_mode(&self) -> Option<&HeightMode> { self.height_mode.as_ref() } @@ -55,6 +57,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_layout_target(&self) -> Option<&LayoutTarget> { self.layout_target.as_ref() } @@ -68,6 +71,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_left(&self) -> Option<&Left> { self.left.as_ref() } @@ -81,6 +85,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_left_mode(&self) -> Option<&LeftMode> { self.left_mode.as_ref() } @@ -94,6 +99,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_top(&self) -> Option<&Top> { self.top.as_ref() } @@ -107,6 +113,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_top_mode(&self) -> Option<&TopMode> { self.top_mode.as_ref() } @@ -120,6 +127,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_width(&self) -> Option<&Width> { self.width.as_ref() } @@ -133,6 +141,7 @@ impl ManualLayout { self } + #[must_use] pub fn get_width_mode(&self) -> Option<&WidthMode> { self.width_mode.as_ref() } @@ -146,6 +155,7 @@ impl ManualLayout { self } + #[must_use] pub fn is_empty(&self) -> bool { self.height.is_none() && self.height_mode.is_none() diff --git a/src/structs/drawing/charts/marker.rs b/src/structs/drawing/charts/marker.rs index 9ec960b8..ce043735 100644 --- a/src/structs/drawing/charts/marker.rs +++ b/src/structs/drawing/charts/marker.rs @@ -1,7 +1,7 @@ // c:marker use super::Symbol; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Marker { } impl Marker { + #[must_use] pub fn get_symbol(&self) -> Option<&Symbol> { self.symbol.as_ref() } diff --git a/src/structs/drawing/charts/minor_tick_mark.rs b/src/structs/drawing/charts/minor_tick_mark.rs index 6b7db178..c9d828f5 100644 --- a/src/structs/drawing/charts/minor_tick_mark.rs +++ b/src/structs/drawing/charts/minor_tick_mark.rs @@ -1,8 +1,8 @@ // c:minorTickMark use super::super::super::EnumValue; use super::TickMarkValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct MinorTickMark { val: EnumValue, } impl MinorTickMark { + #[must_use] pub fn get_val(&self) -> &TickMarkValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/no_multi_level_labels.rs b/src/structs/drawing/charts/no_multi_level_labels.rs index 71294dd9..0a5af9f5 100644 --- a/src/structs/drawing/charts/no_multi_level_labels.rs +++ b/src/structs/drawing/charts/no_multi_level_labels.rs @@ -1,7 +1,7 @@ // c:noMultiLvlLbl use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct NoMultiLevelLabels { val: BooleanValue, } impl NoMultiLevelLabels { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/number_reference.rs b/src/structs/drawing/charts/number_reference.rs index 39096718..fcce0d3d 100644 --- a/src/structs/drawing/charts/number_reference.rs +++ b/src/structs/drawing/charts/number_reference.rs @@ -4,7 +4,7 @@ use crate::xml_read_loop; use super::Formula; use super::NumberingCache; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct NumberReference { } impl NumberReference { + #[must_use] pub fn get_formula(&self) -> &Formula { &self.formula } @@ -30,6 +31,7 @@ impl NumberReference { self } + #[must_use] pub fn get_numbering_cache(&self) -> &NumberingCache { &self.numbering_cache } diff --git a/src/structs/drawing/charts/numbering_cache.rs b/src/structs/drawing/charts/numbering_cache.rs index c46ff165..d3feb67b 100644 --- a/src/structs/drawing/charts/numbering_cache.rs +++ b/src/structs/drawing/charts/numbering_cache.rs @@ -2,7 +2,7 @@ use super::FormatCode; use crate::structs::Address; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -15,6 +15,7 @@ pub struct NumberingCache { } impl NumberingCache { + #[must_use] pub fn get_format_code(&self) -> &FormatCode { &self.format_code } diff --git a/src/structs/drawing/charts/numbering_format.rs b/src/structs/drawing/charts/numbering_format.rs index 2416654c..c7890392 100644 --- a/src/structs/drawing/charts/numbering_format.rs +++ b/src/structs/drawing/charts/numbering_format.rs @@ -1,8 +1,8 @@ // c:numFmt use super::super::super::BooleanValue; use super::super::super::StringValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct NumberingFormat { source_linked: BooleanValue, } impl NumberingFormat { + #[must_use] pub fn get_format_code(&self) -> &str { self.format_code.get_value_str() } @@ -23,6 +24,7 @@ impl NumberingFormat { self } + #[must_use] pub fn get_source_linked(&self) -> bool { self.source_linked.get_value() } diff --git a/src/structs/drawing/charts/numeric_value.rs b/src/structs/drawing/charts/numeric_value.rs index fb339abb..a9eb2824 100644 --- a/src/structs/drawing/charts/numeric_value.rs +++ b/src/structs/drawing/charts/numeric_value.rs @@ -1,5 +1,5 @@ // c:v -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -12,6 +12,7 @@ pub struct NumericValue { } impl NumericValue { + #[must_use] pub fn get_text(&self) -> &str { &self.text } diff --git a/src/structs/drawing/charts/of_pie_chart.rs b/src/structs/drawing/charts/of_pie_chart.rs index d36eae28..4a002e7c 100644 --- a/src/structs/drawing/charts/of_pie_chart.rs +++ b/src/structs/drawing/charts/of_pie_chart.rs @@ -7,9 +7,9 @@ use super::OfPieType; use super::SecondPieSize; use super::SeriesLines; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -27,6 +27,7 @@ pub struct OfPieChart { } impl OfPieChart { + #[must_use] pub fn get_of_pie_type(&self) -> &OfPieType { &self.of_pie_type } @@ -40,6 +41,7 @@ impl OfPieChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -53,6 +55,7 @@ impl OfPieChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -66,6 +69,7 @@ impl OfPieChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -79,6 +83,7 @@ impl OfPieChart { self } + #[must_use] pub fn get_gap_width(&self) -> &GapWidth { &self.gap_width } @@ -92,6 +97,7 @@ impl OfPieChart { self } + #[must_use] pub fn get_second_pie_size(&self) -> &SecondPieSize { &self.second_pie_size } @@ -105,6 +111,7 @@ impl OfPieChart { self } + #[must_use] pub fn get_series_lines(&self) -> &SeriesLines { &self.series_lines } diff --git a/src/structs/drawing/charts/of_pie_type.rs b/src/structs/drawing/charts/of_pie_type.rs index 685b7c31..d7b8ea70 100644 --- a/src/structs/drawing/charts/of_pie_type.rs +++ b/src/structs/drawing/charts/of_pie_type.rs @@ -1,8 +1,8 @@ // c:ofPieType use super::super::super::EnumValue; use super::OfPieValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct OfPieType { val: EnumValue, } impl OfPieType { + #[must_use] pub fn get_val(&self) -> &OfPieValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/order.rs b/src/structs/drawing/charts/order.rs index 64064aa9..da4bb16c 100644 --- a/src/structs/drawing/charts/order.rs +++ b/src/structs/drawing/charts/order.rs @@ -1,7 +1,7 @@ // c:order use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Order { val: UInt32Value, } impl Order { + #[must_use] pub fn get_val(&self) -> u32 { self.val.get_value() } diff --git a/src/structs/drawing/charts/orientation.rs b/src/structs/drawing/charts/orientation.rs index 2ffa934a..54d91f10 100644 --- a/src/structs/drawing/charts/orientation.rs +++ b/src/structs/drawing/charts/orientation.rs @@ -1,8 +1,8 @@ // c:orientation use super::super::super::EnumValue; use super::OrientationValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Orientation { val: EnumValue, } impl Orientation { + #[must_use] pub fn get_val(&self) -> &OrientationValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/overlap.rs b/src/structs/drawing/charts/overlap.rs index c48edb57..61562fa8 100644 --- a/src/structs/drawing/charts/overlap.rs +++ b/src/structs/drawing/charts/overlap.rs @@ -1,7 +1,7 @@ // c:overlap use super::super::super::SByteValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Overlap { val: SByteValue, } impl Overlap { + #[must_use] pub fn get_val(&self) -> i8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/overlay.rs b/src/structs/drawing/charts/overlay.rs index 81a30815..07213163 100644 --- a/src/structs/drawing/charts/overlay.rs +++ b/src/structs/drawing/charts/overlay.rs @@ -1,7 +1,7 @@ // c:overlay use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Overlay { val: BooleanValue, } impl Overlay { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/page_margins.rs b/src/structs/drawing/charts/page_margins.rs index 918ad2ec..7e758add 100644 --- a/src/structs/drawing/charts/page_margins.rs +++ b/src/structs/drawing/charts/page_margins.rs @@ -1,7 +1,7 @@ // c:pageMargins use super::super::super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct PageMargins { footer: DoubleValue, } impl PageMargins { + #[must_use] pub fn get_bottom(&self) -> f64 { self.bottom.get_value() } @@ -26,6 +27,7 @@ impl PageMargins { self } + #[must_use] pub fn get_left(&self) -> f64 { self.left.get_value() } @@ -35,6 +37,7 @@ impl PageMargins { self } + #[must_use] pub fn get_right(&self) -> f64 { self.right.get_value() } @@ -44,6 +47,7 @@ impl PageMargins { self } + #[must_use] pub fn get_top(&self) -> f64 { self.top.get_value() } @@ -53,6 +57,7 @@ impl PageMargins { self } + #[must_use] pub fn get_header(&self) -> f64 { self.header.get_value() } @@ -62,6 +67,7 @@ impl PageMargins { self } + #[must_use] pub fn get_footer(&self) -> f64 { self.footer.get_value() } diff --git a/src/structs/drawing/charts/page_setup.rs b/src/structs/drawing/charts/page_setup.rs index 5114e6c4..3896e3a6 100644 --- a/src/structs/drawing/charts/page_setup.rs +++ b/src/structs/drawing/charts/page_setup.rs @@ -1,5 +1,5 @@ // c:pageSetup -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/charts/perspective.rs b/src/structs/drawing/charts/perspective.rs index 688456d3..36ac88cf 100644 --- a/src/structs/drawing/charts/perspective.rs +++ b/src/structs/drawing/charts/perspective.rs @@ -1,7 +1,7 @@ // c:perspective use super::super::super::ByteValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Perspective { val: ByteValue, } impl Perspective { + #[must_use] pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/pie_3d_chart.rs b/src/structs/drawing/charts/pie_3d_chart.rs index d8333140..eb6761d5 100644 --- a/src/structs/drawing/charts/pie_3d_chart.rs +++ b/src/structs/drawing/charts/pie_3d_chart.rs @@ -3,9 +3,9 @@ use super::AreaChartSeries; use super::AreaChartSeriesList; use super::DataLabels; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct Pie3DChart { } impl Pie3DChart { + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -32,6 +33,7 @@ impl Pie3DChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -45,6 +47,7 @@ impl Pie3DChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } diff --git a/src/structs/drawing/charts/pie_chart.rs b/src/structs/drawing/charts/pie_chart.rs index 8f26a5fa..4e0f3459 100644 --- a/src/structs/drawing/charts/pie_chart.rs +++ b/src/structs/drawing/charts/pie_chart.rs @@ -4,9 +4,9 @@ use super::AreaChartSeriesList; use super::DataLabels; use super::FirstSliceAngle; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -21,6 +21,7 @@ pub struct PieChart { } impl PieChart { + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -34,6 +35,7 @@ impl PieChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -47,6 +49,7 @@ impl PieChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -60,6 +63,7 @@ impl PieChart { self } + #[must_use] pub fn get_first_slice_angle(&self) -> &FirstSliceAngle { &self.first_slice_angle } diff --git a/src/structs/drawing/charts/plot_area.rs b/src/structs/drawing/charts/plot_area.rs index cd75887a..b507a7b5 100644 --- a/src/structs/drawing/charts/plot_area.rs +++ b/src/structs/drawing/charts/plot_area.rs @@ -22,7 +22,7 @@ use super::ShapeProperties; use super::ValueAxis; use crate::structs::Spreadsheet; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -53,6 +53,7 @@ pub struct PlotArea { } impl PlotArea { + #[must_use] pub fn get_layout(&self) -> &Layout { &self.layout } @@ -66,6 +67,7 @@ impl PlotArea { self } + #[must_use] pub fn get_line_chart(&self) -> Option<&LineChart> { self.line_chart.as_ref() } @@ -79,6 +81,7 @@ impl PlotArea { self } + #[must_use] pub fn get_line_3d_chart(&self) -> Option<&Line3DChart> { self.line_3d_chart.as_ref() } @@ -92,6 +95,7 @@ impl PlotArea { self } + #[must_use] pub fn get_pie_chart(&self) -> Option<&PieChart> { self.pie_chart.as_ref() } @@ -105,6 +109,7 @@ impl PlotArea { self } + #[must_use] pub fn get_pie_3d_chart(&self) -> Option<&Pie3DChart> { self.pie_3d_chart.as_ref() } @@ -118,6 +123,7 @@ impl PlotArea { self } + #[must_use] pub fn get_doughnut_chart(&self) -> Option<&DoughnutChart> { self.doughnut_chart.as_ref() } @@ -131,6 +137,7 @@ impl PlotArea { self } + #[must_use] pub fn get_scatter_chart(&self) -> Option<&ScatterChart> { self.scatter_chart.as_ref() } @@ -144,6 +151,7 @@ impl PlotArea { self } + #[must_use] pub fn get_bar_chart(&self) -> Option<&BarChart> { self.bar_chart.as_ref() } @@ -157,6 +165,7 @@ impl PlotArea { self } + #[must_use] pub fn get_bar_3d_chart(&self) -> Option<&Bar3DChart> { self.bar_3d_chart.as_ref() } @@ -170,6 +179,7 @@ impl PlotArea { self } + #[must_use] pub fn get_radar_chart(&self) -> Option<&RadarChart> { self.radar_chart.as_ref() } @@ -183,6 +193,7 @@ impl PlotArea { self } + #[must_use] pub fn get_bubble_chart(&self) -> Option<&BubbleChart> { self.bubble_chart.as_ref() } @@ -196,6 +207,7 @@ impl PlotArea { self } + #[must_use] pub fn get_area_chart(&self) -> Option<&AreaChart> { self.area_chart.as_ref() } @@ -209,6 +221,7 @@ impl PlotArea { self } + #[must_use] pub fn get_area_3d_chart(&self) -> Option<&Area3DChart> { self.area_3d_chart.as_ref() } @@ -222,6 +235,7 @@ impl PlotArea { self } + #[must_use] pub fn get_of_pie_chart(&self) -> Option<&OfPieChart> { self.of_pie_chart.as_ref() } @@ -235,6 +249,7 @@ impl PlotArea { self } + #[must_use] pub fn get_category_axis(&self) -> &[CategoryAxis] { &self.category_axis } @@ -253,6 +268,7 @@ impl PlotArea { self } + #[must_use] pub fn get_value_axis(&self) -> &[ValueAxis] { &self.value_axis } @@ -271,6 +287,7 @@ impl PlotArea { self } + #[must_use] pub fn get_series_axis(&self) -> &[SeriesAxis] { &self.series_axis } @@ -289,6 +306,7 @@ impl PlotArea { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } diff --git a/src/structs/drawing/charts/plot_visible_only.rs b/src/structs/drawing/charts/plot_visible_only.rs index d0000904..057672a0 100644 --- a/src/structs/drawing/charts/plot_visible_only.rs +++ b/src/structs/drawing/charts/plot_visible_only.rs @@ -1,7 +1,7 @@ // c:plotVisOnly use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct PlotVisibleOnly { val: BooleanValue, } impl PlotVisibleOnly { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/print_settings.rs b/src/structs/drawing/charts/print_settings.rs index d8042d65..b90b8bef 100644 --- a/src/structs/drawing/charts/print_settings.rs +++ b/src/structs/drawing/charts/print_settings.rs @@ -2,8 +2,8 @@ use super::HeaderFooter; use super::PageMargins; use super::PageSetup; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct PrintSettings { } impl PrintSettings { + #[must_use] pub fn get_header_footer(&self) -> &HeaderFooter { &self.header_footer } @@ -30,6 +31,7 @@ impl PrintSettings { self } + #[must_use] pub fn get_page_margins(&self) -> &PageMargins { &self.page_margins } @@ -43,6 +45,7 @@ impl PrintSettings { self } + #[must_use] pub fn get_page_setup(&self) -> &PageSetup { &self.page_setup } diff --git a/src/structs/drawing/charts/radar_chart.rs b/src/structs/drawing/charts/radar_chart.rs index 60d53dc5..3e753cc9 100644 --- a/src/structs/drawing/charts/radar_chart.rs +++ b/src/structs/drawing/charts/radar_chart.rs @@ -5,9 +5,9 @@ use super::AxisId; use super::DataLabels; use super::RadarStyle; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct RadarChart { } impl RadarChart { + #[must_use] pub fn get_radar_style(&self) -> &RadarStyle { &self.radar_style } @@ -37,6 +38,7 @@ impl RadarChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -50,6 +52,7 @@ impl RadarChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -63,6 +66,7 @@ impl RadarChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -76,6 +80,7 @@ impl RadarChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/radar_style.rs b/src/structs/drawing/charts/radar_style.rs index 148fda9f..29d7466b 100644 --- a/src/structs/drawing/charts/radar_style.rs +++ b/src/structs/drawing/charts/radar_style.rs @@ -1,8 +1,8 @@ // c:radarStyle use super::super::super::EnumValue; use super::RadarStyleValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct RadarStyle { val: EnumValue, } impl RadarStyle { + #[must_use] pub fn get_val(&self) -> &RadarStyleValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/rich_text.rs b/src/structs/drawing/charts/rich_text.rs index e22cca13..90bed6af 100644 --- a/src/structs/drawing/charts/rich_text.rs +++ b/src/structs/drawing/charts/rich_text.rs @@ -2,7 +2,7 @@ use super::super::BodyProperties; use super::super::ListStyle; use super::super::Paragraph; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -18,6 +18,7 @@ pub struct RichText { } impl RichText { + #[must_use] pub fn get_body_properties(&self) -> &BodyProperties { &self.body_properties } @@ -30,6 +31,7 @@ impl RichText { self.body_properties = value; } + #[must_use] pub fn get_list_style(&self) -> &ListStyle { &self.list_style } @@ -42,6 +44,7 @@ impl RichText { self.list_style = value; } + #[must_use] pub fn get_paragraph(&self) -> &[Paragraph] { &self.paragraph } diff --git a/src/structs/drawing/charts/right_angle_axes.rs b/src/structs/drawing/charts/right_angle_axes.rs index ca627150..a56a9031 100644 --- a/src/structs/drawing/charts/right_angle_axes.rs +++ b/src/structs/drawing/charts/right_angle_axes.rs @@ -1,7 +1,7 @@ // c:rAngAx use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct RightAngleAxes { val: BooleanValue, } impl RightAngleAxes { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/rotate_x.rs b/src/structs/drawing/charts/rotate_x.rs index 8f8cd58d..5b63e7dc 100644 --- a/src/structs/drawing/charts/rotate_x.rs +++ b/src/structs/drawing/charts/rotate_x.rs @@ -1,7 +1,7 @@ // c:rotX use super::super::super::SByteValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct RotateX { val: SByteValue, } impl RotateX { + #[must_use] pub fn get_val(&self) -> i8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/rotate_y.rs b/src/structs/drawing/charts/rotate_y.rs index 76071e7f..c7dd49ab 100644 --- a/src/structs/drawing/charts/rotate_y.rs +++ b/src/structs/drawing/charts/rotate_y.rs @@ -1,7 +1,7 @@ // c:rotY use super::super::super::UInt16Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct RotateY { val: UInt16Value, } impl RotateY { + #[must_use] pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/rounded_corners.rs b/src/structs/drawing/charts/rounded_corners.rs index f0551ee7..44b70d58 100644 --- a/src/structs/drawing/charts/rounded_corners.rs +++ b/src/structs/drawing/charts/rounded_corners.rs @@ -1,7 +1,7 @@ // c:roundedCorners use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct RoundedCorners { val: BooleanValue, } impl RoundedCorners { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/scaling.rs b/src/structs/drawing/charts/scaling.rs index bc803aac..8f12ffe7 100644 --- a/src/structs/drawing/charts/scaling.rs +++ b/src/structs/drawing/charts/scaling.rs @@ -1,7 +1,7 @@ // c:scaling use super::Orientation; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Scaling { } impl Scaling { + #[must_use] pub fn get_orientation(&self) -> &Orientation { &self.orientation } diff --git a/src/structs/drawing/charts/scatter_chart.rs b/src/structs/drawing/charts/scatter_chart.rs index 669f9fce..a22216b7 100644 --- a/src/structs/drawing/charts/scatter_chart.rs +++ b/src/structs/drawing/charts/scatter_chart.rs @@ -5,9 +5,9 @@ use super::AxisId; use super::DataLabels; use super::ScatterStyle; use super::VaryColors; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct ScatterChart { } impl ScatterChart { + #[must_use] pub fn get_scatter_style(&self) -> &ScatterStyle { &self.scatter_style } @@ -37,6 +38,7 @@ impl ScatterChart { self } + #[must_use] pub fn get_vary_colors(&self) -> &VaryColors { &self.vary_colors } @@ -50,6 +52,7 @@ impl ScatterChart { self } + #[must_use] pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList { &self.area_chart_series_list } @@ -63,6 +66,7 @@ impl ScatterChart { self } + #[must_use] pub fn get_data_labels(&self) -> &DataLabels { &self.data_labels } @@ -76,6 +80,7 @@ impl ScatterChart { self } + #[must_use] pub fn get_axis_id(&self) -> &[AxisId] { &self.axis_id } diff --git a/src/structs/drawing/charts/scatter_style.rs b/src/structs/drawing/charts/scatter_style.rs index 9c1427fd..a9b82158 100644 --- a/src/structs/drawing/charts/scatter_style.rs +++ b/src/structs/drawing/charts/scatter_style.rs @@ -1,8 +1,8 @@ // c:scatterStyle use super::super::super::EnumValue; use super::ScatterStyleValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct ScatterStyle { val: EnumValue, } impl ScatterStyle { + #[must_use] pub fn get_val(&self) -> &ScatterStyleValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/second_pie_size.rs b/src/structs/drawing/charts/second_pie_size.rs index dbedca60..0cb35d72 100644 --- a/src/structs/drawing/charts/second_pie_size.rs +++ b/src/structs/drawing/charts/second_pie_size.rs @@ -1,7 +1,7 @@ // c:secondPieSize use super::super::super::UInt16Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct SecondPieSize { val: UInt16Value, } impl SecondPieSize { + #[must_use] pub fn get_val(&self) -> u16 { self.val.get_value() } diff --git a/src/structs/drawing/charts/series_axis.rs b/src/structs/drawing/charts/series_axis.rs index 7021ccd7..b3eb6a78 100644 --- a/src/structs/drawing/charts/series_axis.rs +++ b/src/structs/drawing/charts/series_axis.rs @@ -10,8 +10,8 @@ use super::MinorTickMark; use super::Scaling; use super::TickLabelPosition; use super::Title; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -33,6 +33,7 @@ pub struct SeriesAxis { } impl SeriesAxis { + #[must_use] pub fn get_axis_id(&self) -> &AxisId { &self.axis_id } @@ -46,6 +47,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_scaling(&self) -> &Scaling { &self.scaling } @@ -59,6 +61,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_delete(&self) -> &Delete { &self.delete } @@ -72,6 +75,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_axis_position(&self) -> &AxisPosition { &self.axis_position } @@ -85,6 +89,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_major_gridlines(&self) -> Option<&MajorGridlines> { self.major_gridlines.as_deref() } @@ -98,6 +103,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_title(&self) -> Option<&Title> { self.title.as_ref() } @@ -111,6 +117,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_major_tick_mark(&self) -> &MajorTickMark { &self.major_tick_mark } @@ -124,6 +131,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_minor_tick_mark(&self) -> &MinorTickMark { &self.minor_tick_mark } @@ -137,6 +145,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_tick_label_position(&self) -> &TickLabelPosition { &self.tick_label_position } @@ -150,6 +159,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_tick_crossing_axis(&self) -> &CrossingAxis { &self.crossing_axis } @@ -163,6 +173,7 @@ impl SeriesAxis { self } + #[must_use] pub fn get_crosses(&self) -> &Crosses { &self.crosses } diff --git a/src/structs/drawing/charts/series_lines.rs b/src/structs/drawing/charts/series_lines.rs index 5e05c65e..d930b5be 100644 --- a/src/structs/drawing/charts/series_lines.rs +++ b/src/structs/drawing/charts/series_lines.rs @@ -1,5 +1,5 @@ // c:serLines -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/charts/series_text.rs b/src/structs/drawing/charts/series_text.rs index 75fb7bb5..fe6dacd0 100644 --- a/src/structs/drawing/charts/series_text.rs +++ b/src/structs/drawing/charts/series_text.rs @@ -1,7 +1,7 @@ // c:tx -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct SeriesText { } impl SeriesText { + #[must_use] pub fn get_value(&self) -> &str { self.value.get_value_str() } diff --git a/src/structs/drawing/charts/shape.rs b/src/structs/drawing/charts/shape.rs index c40012fc..9ddb9b14 100644 --- a/src/structs/drawing/charts/shape.rs +++ b/src/structs/drawing/charts/shape.rs @@ -1,8 +1,8 @@ // c:shape use super::super::super::EnumValue; use super::ShapeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Shape { val: EnumValue, } impl Shape { + #[must_use] pub fn get_val(&self) -> &ShapeValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/shape_properties.rs b/src/structs/drawing/charts/shape_properties.rs index 115331be..b1b8c77e 100644 --- a/src/structs/drawing/charts/shape_properties.rs +++ b/src/structs/drawing/charts/shape_properties.rs @@ -8,8 +8,8 @@ use super::super::Scene3DType; use super::super::Shape3DType; use super::super::SolidFill; use super::super::Transform2D; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -29,6 +29,7 @@ pub struct ShapeProperties { } impl ShapeProperties { + #[must_use] pub fn get_pattern_fill(&self) -> Option<&PatternFill> { self.pattern_fill.as_ref() } @@ -42,6 +43,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_transform2d(&self) -> Option<&Transform2D> { self.transform2d.as_ref() } @@ -55,6 +57,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_geometry(&self) -> Option<&PresetGeometry> { self.preset_geometry.as_ref() } @@ -68,6 +71,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_solid_fill(&self) -> Option<&SolidFill> { self.solid_fill.as_ref() } @@ -81,6 +85,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_no_fill(&self) -> Option<&NoFill> { self.no_fill.as_ref() } @@ -94,6 +99,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_outline(&self) -> Option<&Outline> { self.outline.as_ref() } @@ -107,6 +113,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_effect_list(&self) -> Option<&EffectList> { self.effect_list.as_ref() } @@ -120,6 +127,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_scene_3d_type(&self) -> Option<&Scene3DType> { self.scene_3d_type.as_ref() } @@ -133,6 +141,7 @@ impl ShapeProperties { self } + #[must_use] pub fn get_shape_3d_type(&self) -> Option<&Shape3DType> { self.shape_3d_type.as_ref() } diff --git a/src/structs/drawing/charts/show_bubble_size.rs b/src/structs/drawing/charts/show_bubble_size.rs index 5cf0dbe5..f092c806 100644 --- a/src/structs/drawing/charts/show_bubble_size.rs +++ b/src/structs/drawing/charts/show_bubble_size.rs @@ -1,7 +1,7 @@ // c:showBubbleSize use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowBubbleSize { val: BooleanValue, } impl ShowBubbleSize { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_category_name.rs b/src/structs/drawing/charts/show_category_name.rs index 2d7d4705..d5b7ac22 100644 --- a/src/structs/drawing/charts/show_category_name.rs +++ b/src/structs/drawing/charts/show_category_name.rs @@ -1,7 +1,7 @@ // c:showCatName use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowCategoryName { val: BooleanValue, } impl ShowCategoryName { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_data_labels_over_maximum.rs b/src/structs/drawing/charts/show_data_labels_over_maximum.rs index 9fc2b5b6..3093aea0 100644 --- a/src/structs/drawing/charts/show_data_labels_over_maximum.rs +++ b/src/structs/drawing/charts/show_data_labels_over_maximum.rs @@ -1,7 +1,7 @@ // c:showDLblsOverMax use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowDataLabelsOverMaximum { val: BooleanValue, } impl ShowDataLabelsOverMaximum { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_leader_lines.rs b/src/structs/drawing/charts/show_leader_lines.rs index b15be991..c5dc21af 100644 --- a/src/structs/drawing/charts/show_leader_lines.rs +++ b/src/structs/drawing/charts/show_leader_lines.rs @@ -1,7 +1,7 @@ // c:showLeaderLines use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowLeaderLines { val: BooleanValue, } impl ShowLeaderLines { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_legend_key.rs b/src/structs/drawing/charts/show_legend_key.rs index b4a28eb2..b3aacb85 100644 --- a/src/structs/drawing/charts/show_legend_key.rs +++ b/src/structs/drawing/charts/show_legend_key.rs @@ -1,7 +1,7 @@ // c:showLegendKey use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowLegendKey { val: BooleanValue, } impl ShowLegendKey { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_marker.rs b/src/structs/drawing/charts/show_marker.rs index 901ad61f..b6359fdb 100644 --- a/src/structs/drawing/charts/show_marker.rs +++ b/src/structs/drawing/charts/show_marker.rs @@ -1,7 +1,7 @@ // c:marker use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowMarker { val: BooleanValue, } impl ShowMarker { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_negative_bubbles.rs b/src/structs/drawing/charts/show_negative_bubbles.rs index 8ed58dfc..c0777320 100644 --- a/src/structs/drawing/charts/show_negative_bubbles.rs +++ b/src/structs/drawing/charts/show_negative_bubbles.rs @@ -1,7 +1,7 @@ // c:showNegBubbles use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowNegativeBubbles { val: BooleanValue, } impl ShowNegativeBubbles { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_percent.rs b/src/structs/drawing/charts/show_percent.rs index 94654381..8b4ef6e5 100644 --- a/src/structs/drawing/charts/show_percent.rs +++ b/src/structs/drawing/charts/show_percent.rs @@ -1,7 +1,7 @@ // c:showPercent use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowPercent { val: BooleanValue, } impl ShowPercent { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_series_name.rs b/src/structs/drawing/charts/show_series_name.rs index e33ab0ab..70e843a9 100644 --- a/src/structs/drawing/charts/show_series_name.rs +++ b/src/structs/drawing/charts/show_series_name.rs @@ -1,7 +1,7 @@ // c:showSerName use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowSeriesName { val: BooleanValue, } impl ShowSeriesName { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/show_value.rs b/src/structs/drawing/charts/show_value.rs index b7cb86a6..49e25b30 100644 --- a/src/structs/drawing/charts/show_value.rs +++ b/src/structs/drawing/charts/show_value.rs @@ -1,7 +1,7 @@ // c:showVal use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct ShowValue { val: BooleanValue, } impl ShowValue { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/side_wall.rs b/src/structs/drawing/charts/side_wall.rs index 513b6b5a..a11aa50d 100644 --- a/src/structs/drawing/charts/side_wall.rs +++ b/src/structs/drawing/charts/side_wall.rs @@ -1,8 +1,8 @@ // c:sideWall use super::ShapeProperties; use super::Thickness; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct SideWall { } impl SideWall { + #[must_use] pub fn get_thickness(&self) -> Option<&Thickness> { self.thickness.as_ref() } @@ -28,6 +29,7 @@ impl SideWall { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } diff --git a/src/structs/drawing/charts/smooth.rs b/src/structs/drawing/charts/smooth.rs index b6875119..3e4fdc43 100644 --- a/src/structs/drawing/charts/smooth.rs +++ b/src/structs/drawing/charts/smooth.rs @@ -1,7 +1,7 @@ // c:smooth use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Smooth { val: BooleanValue, } impl Smooth { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/string_cache.rs b/src/structs/drawing/charts/string_cache.rs index 5b8f4522..a12206eb 100644 --- a/src/structs/drawing/charts/string_cache.rs +++ b/src/structs/drawing/charts/string_cache.rs @@ -1,8 +1,8 @@ // c:strCache -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Address; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/charts/string_literal.rs b/src/structs/drawing/charts/string_literal.rs index 906930b2..4d1eb416 100644 --- a/src/structs/drawing/charts/string_literal.rs +++ b/src/structs/drawing/charts/string_literal.rs @@ -1,7 +1,7 @@ // c:strLit use super::StringPoint; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct StringLiteral { } impl StringLiteral { + #[must_use] pub fn get_string_point_list(&self) -> &[StringPoint] { &self.string_point_list } diff --git a/src/structs/drawing/charts/string_point.rs b/src/structs/drawing/charts/string_point.rs index c5654f80..7010bd21 100644 --- a/src/structs/drawing/charts/string_point.rs +++ b/src/structs/drawing/charts/string_point.rs @@ -2,7 +2,7 @@ use crate::xml_read_loop; // c:pt use super::NumericValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct StringPoint { } impl StringPoint { + #[must_use] pub fn get_numeric_value(&self) -> &NumericValue { &self.numeric_value } diff --git a/src/structs/drawing/charts/string_reference.rs b/src/structs/drawing/charts/string_reference.rs index b4c528b6..e646057b 100644 --- a/src/structs/drawing/charts/string_reference.rs +++ b/src/structs/drawing/charts/string_reference.rs @@ -4,7 +4,7 @@ use crate::xml_read_loop; use super::Formula; use super::StringCache; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct StringReference { } impl StringReference { + #[must_use] pub fn get_formula(&self) -> &Formula { &self.formula } @@ -30,6 +31,7 @@ impl StringReference { self } + #[must_use] pub fn get_string_cache(&self) -> &StringCache { &self.string_cache } diff --git a/src/structs/drawing/charts/style.rs b/src/structs/drawing/charts/style.rs index a612d2a3..6ae18f68 100644 --- a/src/structs/drawing/charts/style.rs +++ b/src/structs/drawing/charts/style.rs @@ -1,7 +1,7 @@ // c:style use super::super::super::ByteValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Style { } impl Style { + #[must_use] pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/symbol.rs b/src/structs/drawing/charts/symbol.rs index 0850ba4e..0550ea89 100644 --- a/src/structs/drawing/charts/symbol.rs +++ b/src/structs/drawing/charts/symbol.rs @@ -1,8 +1,8 @@ // c:symbol use super::super::super::EnumValue; use super::MarkerStyleValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Symbol { val: EnumValue, } impl Symbol { + #[must_use] pub fn get_val(&self) -> &MarkerStyleValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/text_properties.rs b/src/structs/drawing/charts/text_properties.rs index f47190d6..74ad8fc7 100644 --- a/src/structs/drawing/charts/text_properties.rs +++ b/src/structs/drawing/charts/text_properties.rs @@ -2,8 +2,8 @@ use super::super::BodyProperties; use super::super::ListStyle; use super::super::Paragraph; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct TextProperties { } impl TextProperties { + #[must_use] pub fn get_body_properties(&self) -> &BodyProperties { &self.body_properties } @@ -31,6 +32,7 @@ impl TextProperties { self } + #[must_use] pub fn get_list_style(&self) -> &ListStyle { &self.list_style } @@ -44,6 +46,7 @@ impl TextProperties { self } + #[must_use] pub fn get_paragraph(&self) -> &[Paragraph] { &self.paragraph } diff --git a/src/structs/drawing/charts/thickness.rs b/src/structs/drawing/charts/thickness.rs index 828e19ac..99918663 100644 --- a/src/structs/drawing/charts/thickness.rs +++ b/src/structs/drawing/charts/thickness.rs @@ -1,7 +1,7 @@ // c:thickness use super::super::super::ByteValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Thickness { val: ByteValue, } impl Thickness { + #[must_use] pub fn get_val(&self) -> u8 { self.val.get_value() } diff --git a/src/structs/drawing/charts/tick_label_position.rs b/src/structs/drawing/charts/tick_label_position.rs index c9f79524..903b1446 100644 --- a/src/structs/drawing/charts/tick_label_position.rs +++ b/src/structs/drawing/charts/tick_label_position.rs @@ -1,8 +1,8 @@ // c:tickLblPos use super::super::super::EnumValue; use super::TickLabelPositionValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct TickLabelPosition { val: EnumValue, } impl TickLabelPosition { + #[must_use] pub fn get_val(&self) -> &TickLabelPositionValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/title.rs b/src/structs/drawing/charts/title.rs index 039d2622..036c9832 100644 --- a/src/structs/drawing/charts/title.rs +++ b/src/structs/drawing/charts/title.rs @@ -2,7 +2,7 @@ use super::ChartText; use super::Layout; use super::Overlay; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -17,6 +17,7 @@ pub struct Title { } impl Title { + #[must_use] pub fn get_chart_text(&self) -> Option<&ChartText> { self.chart_text.as_ref() } @@ -30,6 +31,7 @@ impl Title { self } + #[must_use] pub fn get_layout(&self) -> Option<&Layout> { self.layout.as_ref() } @@ -43,6 +45,7 @@ impl Title { self } + #[must_use] pub fn get_overlay(&self) -> &Overlay { &self.overlay } diff --git a/src/structs/drawing/charts/top.rs b/src/structs/drawing/charts/top.rs index 1d699953..1397dec8 100644 --- a/src/structs/drawing/charts/top.rs +++ b/src/structs/drawing/charts/top.rs @@ -1,7 +1,7 @@ // c:y use super::super::super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Top { val: DoubleValue, } impl Top { + #[must_use] pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/top_mode.rs b/src/structs/drawing/charts/top_mode.rs index 88c0ed93..9eb495a1 100644 --- a/src/structs/drawing/charts/top_mode.rs +++ b/src/structs/drawing/charts/top_mode.rs @@ -1,8 +1,8 @@ // c:yMode use super::super::super::EnumValue; use super::LayoutModeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct TopMode { val: EnumValue, } impl TopMode { + #[must_use] pub fn get_val(&self) -> &LayoutModeValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/value_axis.rs b/src/structs/drawing/charts/value_axis.rs index e72ba44e..7846a3f9 100644 --- a/src/structs/drawing/charts/value_axis.rs +++ b/src/structs/drawing/charts/value_axis.rs @@ -14,8 +14,8 @@ use super::ShapeProperties; use super::TextProperties; use super::TickLabelPosition; use super::Title; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -41,6 +41,7 @@ pub struct ValueAxis { } impl ValueAxis { + #[must_use] pub fn get_axis_id(&self) -> &AxisId { &self.axis_id } @@ -54,6 +55,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_scaling(&self) -> &Scaling { &self.scaling } @@ -67,6 +69,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_delete(&self) -> &Delete { &self.delete } @@ -80,6 +83,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_axis_position(&self) -> &AxisPosition { &self.axis_position } @@ -93,6 +97,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_major_gridlines(&self) -> Option<&MajorGridlines> { self.major_gridlines.as_ref() } @@ -106,6 +111,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_title(&self) -> Option<&Title> { self.title.as_ref() } @@ -119,6 +125,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_numbering_format(&self) -> &NumberingFormat { &self.numbering_format } @@ -132,6 +139,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_major_tick_mark(&self) -> &MajorTickMark { &self.major_tick_mark } @@ -145,6 +153,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_minor_tick_mark(&self) -> &MinorTickMark { &self.minor_tick_mark } @@ -158,6 +167,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_tick_label_position(&self) -> &TickLabelPosition { &self.tick_label_position } @@ -171,6 +181,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_tick_crossing_axis(&self) -> &CrossingAxis { &self.crossing_axis } @@ -184,6 +195,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_crosses(&self) -> &Crosses { &self.crosses } @@ -197,6 +209,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_cross_between(&self) -> &CrossBetween { &self.cross_between } @@ -210,6 +223,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_shape_properties(&self) -> Option<&ShapeProperties> { self.shape_properties.as_ref() } @@ -223,6 +237,7 @@ impl ValueAxis { self } + #[must_use] pub fn get_text_properties(&self) -> Option<&TextProperties> { self.text_properties.as_ref() } diff --git a/src/structs/drawing/charts/values.rs b/src/structs/drawing/charts/values.rs index 69b9af68..e18f178f 100644 --- a/src/structs/drawing/charts/values.rs +++ b/src/structs/drawing/charts/values.rs @@ -3,7 +3,7 @@ use crate::xml_read_loop; // c:val use super::NumberReference; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct Values { } impl Values { + #[must_use] pub fn get_number_reference(&self) -> &NumberReference { &self.number_reference } diff --git a/src/structs/drawing/charts/vary_colors.rs b/src/structs/drawing/charts/vary_colors.rs index 90eeab14..e6fadff1 100644 --- a/src/structs/drawing/charts/vary_colors.rs +++ b/src/structs/drawing/charts/vary_colors.rs @@ -1,7 +1,7 @@ // c:varyColors use super::super::super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct VaryColors { val: BooleanValue, } impl VaryColors { + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/drawing/charts/view_3d.rs b/src/structs/drawing/charts/view_3d.rs index 085ddf1a..842c7e67 100644 --- a/src/structs/drawing/charts/view_3d.rs +++ b/src/structs/drawing/charts/view_3d.rs @@ -3,8 +3,8 @@ use super::Perspective; use super::RightAngleAxes; use super::RotateX; use super::RotateY; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct View3D { } impl View3D { + #[must_use] pub fn get_rotate_x(&self) -> Option<&RotateX> { self.rotate_x.as_ref() } @@ -32,6 +33,7 @@ impl View3D { self } + #[must_use] pub fn get_rotate_y(&self) -> Option<&RotateY> { self.rotate_y.as_ref() } @@ -45,6 +47,7 @@ impl View3D { self } + #[must_use] pub fn get_right_angle_axes(&self) -> Option<&RightAngleAxes> { self.right_angle_axes.as_ref() } @@ -58,6 +61,7 @@ impl View3D { self } + #[must_use] pub fn get_perspective(&self) -> Option<&Perspective> { self.perspective.as_ref() } diff --git a/src/structs/drawing/charts/width.rs b/src/structs/drawing/charts/width.rs index a7d71fe6..d80d809d 100644 --- a/src/structs/drawing/charts/width.rs +++ b/src/structs/drawing/charts/width.rs @@ -1,7 +1,7 @@ // c:w use super::super::super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Width { val: DoubleValue, } impl Width { + #[must_use] pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/drawing/charts/width_mode.rs b/src/structs/drawing/charts/width_mode.rs index e06fdcd3..a5e538b0 100644 --- a/src/structs/drawing/charts/width_mode.rs +++ b/src/structs/drawing/charts/width_mode.rs @@ -1,8 +1,8 @@ // c:wMode use super::super::super::EnumValue; use super::LayoutModeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct WidthMode { val: EnumValue, } impl WidthMode { + #[must_use] pub fn get_val(&self) -> &LayoutModeValues { self.val.get_value() } diff --git a/src/structs/drawing/charts/x_values.rs b/src/structs/drawing/charts/x_values.rs index d955a595..7d5351c2 100644 --- a/src/structs/drawing/charts/x_values.rs +++ b/src/structs/drawing/charts/x_values.rs @@ -1,8 +1,8 @@ // c:xVal use super::NumberReference; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct XValues { } impl XValues { + #[must_use] pub fn get_number_reference(&self) -> &NumberReference { &self.number_reference } diff --git a/src/structs/drawing/charts/y_values.rs b/src/structs/drawing/charts/y_values.rs index 97b1e4b8..548bb9b3 100644 --- a/src/structs/drawing/charts/y_values.rs +++ b/src/structs/drawing/charts/y_values.rs @@ -1,8 +1,8 @@ // c:yVal use super::NumberReference; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Spreadsheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct YValues { } impl YValues { + #[must_use] pub fn get_number_reference(&self) -> &NumberReference { &self.number_reference } diff --git a/src/structs/drawing/color2_type.rs b/src/structs/drawing/color2_type.rs index 7922bbb0..d4b96d15 100644 --- a/src/structs/drawing/color2_type.rs +++ b/src/structs/drawing/color2_type.rs @@ -1,7 +1,7 @@ use super::RgbColorModelHex; use super::SystemColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -20,6 +20,7 @@ impl Color2Type { } #[inline] + #[must_use] pub fn get_rgb_color_model_hex(&self) -> Option<&RgbColorModelHex> { self.rgb_color_model_hex.as_deref() } @@ -35,6 +36,7 @@ impl Color2Type { } #[inline] + #[must_use] pub fn get_system_color(&self) -> Option<&SystemColor> { self.system_color.as_deref() } @@ -45,6 +47,7 @@ impl Color2Type { } #[inline] + #[must_use] pub fn get_val(&self) -> String { if let Some(v) = &self.rgb_color_model_hex { return v.get_val().to_string(); @@ -52,7 +55,7 @@ impl Color2Type { if let Some(v) = &self.system_color { return v.get_last_color().to_string(); } - String::from("") + String::new() } pub(crate) fn set_attributes( diff --git a/src/structs/drawing/color_scheme.rs b/src/structs/drawing/color_scheme.rs index 9ca2dd01..20919beb 100644 --- a/src/structs/drawing/color_scheme.rs +++ b/src/structs/drawing/color_scheme.rs @@ -1,8 +1,8 @@ // a:clrScheme use super::super::StringValue; use super::Color2Type; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -27,6 +27,7 @@ pub struct ColorScheme { impl ColorScheme { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -43,6 +44,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_accent1(&self) -> &Color2Type { &self.accent1 } @@ -58,6 +60,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_accent2(&self) -> &Color2Type { &self.accent2 } @@ -73,6 +76,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_accent3(&self) -> &Color2Type { &self.accent3 } @@ -88,6 +92,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_accent4(&self) -> &Color2Type { &self.accent4 } @@ -103,6 +108,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_accent5(&self) -> &Color2Type { &self.accent5 } @@ -118,6 +124,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_accent6(&self) -> &Color2Type { &self.accent6 } @@ -133,6 +140,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_dk1(&self) -> &Color2Type { &self.dk1 } @@ -148,6 +156,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_dk2(&self) -> &Color2Type { &self.dk2 } @@ -163,6 +172,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_fol_hlink(&self) -> &Color2Type { &self.fol_hlink } @@ -178,6 +188,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_hlink(&self) -> &Color2Type { &self.hlink } @@ -193,6 +204,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_lt1(&self) -> &Color2Type { &self.lt1 } @@ -208,6 +220,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_lt2(&self) -> &Color2Type { &self.lt2 } @@ -218,6 +231,7 @@ impl ColorScheme { } #[inline] + #[must_use] pub fn get_color_map(&self) -> Vec { vec![ self.lt1.get_val(), diff --git a/src/structs/drawing/effect_list.rs b/src/structs/drawing/effect_list.rs index 50e20a3b..b151bd10 100644 --- a/src/structs/drawing/effect_list.rs +++ b/src/structs/drawing/effect_list.rs @@ -2,8 +2,8 @@ use super::Glow; use super::OuterShadow; use super::SoftEdge; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct EffectList { impl EffectList { #[inline] + #[must_use] pub fn get_glow(&self) -> Option<&Glow> { self.glow.as_deref() } @@ -33,6 +34,7 @@ impl EffectList { } #[inline] + #[must_use] pub fn get_outer_shadow(&self) -> Option<&OuterShadow> { self.outer_shadow.as_deref() } @@ -48,6 +50,7 @@ impl EffectList { } #[inline] + #[must_use] pub fn get_soft_edge(&self) -> Option<&SoftEdge> { self.soft_edge.as_deref() } diff --git a/src/structs/drawing/effect_style.rs b/src/structs/drawing/effect_style.rs index 9349c219..28721ede 100644 --- a/src/structs/drawing/effect_style.rs +++ b/src/structs/drawing/effect_style.rs @@ -1,8 +1,8 @@ use super::EffectList; use super::Scene3DType; use super::Shape3DType; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct EffectStyle { impl EffectStyle { #[inline] + #[must_use] pub fn get_effect_list(&self) -> Option<&EffectList> { self.effect_list.as_deref() } @@ -34,6 +35,7 @@ impl EffectStyle { } #[inline] + #[must_use] pub fn get_scene_3d_type(&self) -> Option<&Scene3DType> { self.scene_3d_type.as_deref() } @@ -50,6 +52,7 @@ impl EffectStyle { } #[inline] + #[must_use] pub fn get_shape_3d_type(&self) -> Option<&Shape3DType> { self.shape_3d_type.as_deref() } diff --git a/src/structs/drawing/effect_style_list.rs b/src/structs/drawing/effect_style_list.rs index f05f9e3a..b8bf6b0c 100644 --- a/src/structs/drawing/effect_style_list.rs +++ b/src/structs/drawing/effect_style_list.rs @@ -1,6 +1,6 @@ use super::EffectStyle; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct EffectStyleList { impl EffectStyleList { #[inline] + #[must_use] pub fn get_effect_style_collection(&self) -> &[EffectStyle] { &self.effect_style_collection } diff --git a/src/structs/drawing/end_connection.rs b/src/structs/drawing/end_connection.rs index 4a84b1f5..91132aa1 100644 --- a/src/structs/drawing/end_connection.rs +++ b/src/structs/drawing/end_connection.rs @@ -1,7 +1,7 @@ // a:endCxn use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct EndConnection { } impl EndConnection { #[inline] + #[must_use] pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -24,6 +25,7 @@ impl EndConnection { } #[inline] + #[must_use] pub fn get_index(&self) -> u32 { self.index.get_value() } diff --git a/src/structs/drawing/extension_list.rs b/src/structs/drawing/extension_list.rs index 0e8760b4..4265601e 100644 --- a/src/structs/drawing/extension_list.rs +++ b/src/structs/drawing/extension_list.rs @@ -1,5 +1,5 @@ // a:extLst -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; diff --git a/src/structs/drawing/extents.rs b/src/structs/drawing/extents.rs index 181f9ee8..66e54a43 100644 --- a/src/structs/drawing/extents.rs +++ b/src/structs/drawing/extents.rs @@ -1,7 +1,7 @@ // a:ext use super::super::super::Int64Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Extents { } impl Extents { #[inline] + #[must_use] pub fn get_cx(&self) -> i64 { self.cx.get_value() } @@ -25,6 +26,7 @@ impl Extents { } #[inline] + #[must_use] pub fn get_cy(&self) -> i64 { self.cy.get_value() } diff --git a/src/structs/drawing/fill_rectangle.rs b/src/structs/drawing/fill_rectangle.rs index e18c4041..b2300bb8 100644 --- a/src/structs/drawing/fill_rectangle.rs +++ b/src/structs/drawing/fill_rectangle.rs @@ -1,5 +1,5 @@ // a:fillRect -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct FillRectangle { } impl FillRectangle { #[inline] + #[must_use] pub fn get_bottom(&self) -> usize { self.bottom } @@ -24,6 +25,7 @@ impl FillRectangle { } #[inline] + #[must_use] pub fn get_left(&self) -> usize { self.left } @@ -34,6 +36,7 @@ impl FillRectangle { } #[inline] + #[must_use] pub fn get_right(&self) -> usize { self.right } @@ -44,6 +47,7 @@ impl FillRectangle { } #[inline] + #[must_use] pub fn get_top(&self) -> usize { self.top } diff --git a/src/structs/drawing/fill_style_list.rs b/src/structs/drawing/fill_style_list.rs index 8112d8f9..f495e3c8 100644 --- a/src/structs/drawing/fill_style_list.rs +++ b/src/structs/drawing/fill_style_list.rs @@ -1,7 +1,7 @@ use super::GradientFill; use super::SolidFill; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct FillStyleList { impl FillStyleList { #[inline] + #[must_use] pub fn get_solid_fill(&self) -> &[SolidFill] { &self.solid_fill } @@ -38,6 +39,7 @@ impl FillStyleList { } #[inline] + #[must_use] pub fn get_gradient_fill_collection(&self) -> &[GradientFill] { &self.gradient_fill_collection } diff --git a/src/structs/drawing/font_collection_type.rs b/src/structs/drawing/font_collection_type.rs index 2d1440ac..5f777147 100644 --- a/src/structs/drawing/font_collection_type.rs +++ b/src/structs/drawing/font_collection_type.rs @@ -2,7 +2,7 @@ // a:minorFont use super::SupplementalFont; use super::TextFontType; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct FontCollectionType { } impl FontCollectionType { #[inline] + #[must_use] pub fn get_latin_font(&self) -> &TextFontType { &self.latin_font } @@ -34,6 +35,7 @@ impl FontCollectionType { } #[inline] + #[must_use] pub fn get_east_asian_font(&self) -> &TextFontType { &self.east_asian_font } @@ -50,6 +52,7 @@ impl FontCollectionType { } #[inline] + #[must_use] pub fn get_complex_script_font(&self) -> &TextFontType { &self.complex_script_font } @@ -66,6 +69,7 @@ impl FontCollectionType { } #[inline] + #[must_use] pub fn get_supplemental_font_list(&self) -> &[SupplementalFont] { &self.supplemental_font_list } @@ -95,7 +99,7 @@ impl FontCollectionType { self.latin_font.set_panose("020F0302020204030204"); self.east_asian_font.set_typeface(""); self.complex_script_font.set_typeface(""); - for (font_script, typeface) in self::MAJOR_FONTS { + for (font_script, typeface) in MAJOR_FONTS { let mut obj = SupplementalFont::default(); obj.set_script(*font_script).set_typeface(*typeface); self.supplemental_font_list.push(obj); @@ -108,7 +112,7 @@ impl FontCollectionType { self.latin_font.set_panose("020F0502020204030204"); self.east_asian_font.set_typeface(""); self.complex_script_font.set_typeface(""); - for (font_script, typeface) in self::MINOR_FONTS { + for (font_script, typeface) in MINOR_FONTS { let mut obj = SupplementalFont::default(); obj.set_script(*font_script).set_typeface(*typeface); self.supplemental_font_list.push(obj); diff --git a/src/structs/drawing/font_scheme.rs b/src/structs/drawing/font_scheme.rs index 308d45ea..e8931df1 100644 --- a/src/structs/drawing/font_scheme.rs +++ b/src/structs/drawing/font_scheme.rs @@ -1,8 +1,8 @@ // a:fontScheme use super::super::StringValue; use super::FontCollectionType; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct FontScheme { impl FontScheme { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -28,6 +29,7 @@ impl FontScheme { } #[inline] + #[must_use] pub fn get_major_font(&self) -> &FontCollectionType { &self.major_font } @@ -44,6 +46,7 @@ impl FontScheme { } #[inline] + #[must_use] pub fn get_minor_font(&self) -> &FontCollectionType { &self.minor_font } diff --git a/src/structs/drawing/foreground_color.rs b/src/structs/drawing/foreground_color.rs index 52315781..a85fb32f 100644 --- a/src/structs/drawing/foreground_color.rs +++ b/src/structs/drawing/foreground_color.rs @@ -1,7 +1,7 @@ // a:fgClr use super::SchemeColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct ForegroundColor { impl ForegroundColor { #[inline] + #[must_use] pub fn get_scheme_color(&self) -> &SchemeColor { &self.scheme_color } diff --git a/src/structs/drawing/format_scheme.rs b/src/structs/drawing/format_scheme.rs index d22fea5c..aa55b775 100644 --- a/src/structs/drawing/format_scheme.rs +++ b/src/structs/drawing/format_scheme.rs @@ -4,8 +4,8 @@ use super::BackgroundFillStyleList; use super::EffectStyleList; use super::FillStyleList; use super::LineStyleList; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -22,6 +22,7 @@ pub struct FormatScheme { impl FormatScheme { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -33,6 +34,7 @@ impl FormatScheme { } #[inline] + #[must_use] pub fn get_fill_style_list(&self) -> &FillStyleList { &self.fill_style_list } @@ -48,6 +50,7 @@ impl FormatScheme { } #[inline] + #[must_use] pub fn get_line_style_list(&self) -> &LineStyleList { &self.line_style_list } @@ -63,6 +66,7 @@ impl FormatScheme { } #[inline] + #[must_use] pub fn get_effect_style_list(&self) -> &EffectStyleList { &self.effect_style_list } @@ -78,6 +82,7 @@ impl FormatScheme { } #[inline] + #[must_use] pub fn get_background_fill_style_list(&self) -> &BackgroundFillStyleList { &self.background_fill_style_list } diff --git a/src/structs/drawing/glow.rs b/src/structs/drawing/glow.rs index fe6a0e2c..c76b4651 100644 --- a/src/structs/drawing/glow.rs +++ b/src/structs/drawing/glow.rs @@ -1,8 +1,8 @@ // a:glow use super::super::super::Int64Value; use super::SchemeColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct Glow { impl Glow { #[inline] + #[must_use] pub fn get_radius(&self) -> i64 { self.radius.get_value() } @@ -27,6 +28,7 @@ impl Glow { } #[inline] + #[must_use] pub fn get_scheme_color(&self) -> Option<&SchemeColor> { self.scheme_color.as_deref() } diff --git a/src/structs/drawing/gradient_fill.rs b/src/structs/drawing/gradient_fill.rs index 80754d84..8c30128b 100644 --- a/src/structs/drawing/gradient_fill.rs +++ b/src/structs/drawing/gradient_fill.rs @@ -5,8 +5,8 @@ use super::GradientStopList; use super::LinearGradientFill; use super::TileFlipValues; use super::TileRectangle; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -23,6 +23,7 @@ pub struct GradientFill { impl GradientFill { #[inline] + #[must_use] pub fn get_flip(&self) -> &TileFlipValues { self.flip.get_value() } @@ -34,6 +35,7 @@ impl GradientFill { } #[inline] + #[must_use] pub fn get_rotate_with_shape(&self) -> bool { self.rotate_with_shape.get_value() } @@ -45,6 +47,7 @@ impl GradientFill { } #[inline] + #[must_use] pub fn get_gradient_stop_list(&self) -> &GradientStopList { &self.gradient_stop_list } @@ -61,6 +64,7 @@ impl GradientFill { } #[inline] + #[must_use] pub fn get_linear_gradient_fill(&self) -> Option<&LinearGradientFill> { self.linear_gradient_fill.as_deref() } @@ -77,6 +81,7 @@ impl GradientFill { } #[inline] + #[must_use] pub fn get_tile_rectangle(&self) -> Option<&TileRectangle> { self.tile_rectangle.as_deref() } diff --git a/src/structs/drawing/gradient_stop.rs b/src/structs/drawing/gradient_stop.rs index 53d0911b..20742a33 100644 --- a/src/structs/drawing/gradient_stop.rs +++ b/src/structs/drawing/gradient_stop.rs @@ -1,8 +1,8 @@ // a:gs use super::RgbColorModelHex; use super::SchemeColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct GradientStop { impl GradientStop { #[inline] + #[must_use] pub fn get_position(&self) -> i32 { self.position } @@ -28,6 +29,7 @@ impl GradientStop { } #[inline] + #[must_use] pub fn get_scheme_color(&self) -> Option<&SchemeColor> { self.scheme_color.as_deref() } @@ -44,6 +46,7 @@ impl GradientStop { } #[inline] + #[must_use] pub fn get_rgb_color_model_hex(&self) -> Option<&RgbColorModelHex> { self.rgb_color_model_hex.as_deref() } diff --git a/src/structs/drawing/gradient_stop_list.rs b/src/structs/drawing/gradient_stop_list.rs index f6f9b587..0543ea25 100644 --- a/src/structs/drawing/gradient_stop_list.rs +++ b/src/structs/drawing/gradient_stop_list.rs @@ -1,7 +1,7 @@ // a:gsLst use super::GradientStop; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct GradientStopList { impl GradientStopList { #[inline] + #[must_use] pub fn get_gradient_stop(&self) -> &[GradientStop] { &self.gradient_stop } diff --git a/src/structs/drawing/graphic.rs b/src/structs/drawing/graphic.rs index 3b368a9e..27cb8604 100644 --- a/src/structs/drawing/graphic.rs +++ b/src/structs/drawing/graphic.rs @@ -1,9 +1,9 @@ // a:graphic use super::GraphicData; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct Graphic { impl Graphic { #[inline] + #[must_use] pub fn get_graphic_data(&self) -> &GraphicData { &self.graphic_data } diff --git a/src/structs/drawing/graphic_data.rs b/src/structs/drawing/graphic_data.rs index abe36cb9..679d7932 100644 --- a/src/structs/drawing/graphic_data.rs +++ b/src/structs/drawing/graphic_data.rs @@ -1,11 +1,11 @@ // *:graphicData use super::charts::ChartSpace; -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{DRAWINGML_CHART_NS, REL_OFC_NS}; +use crate::reader::driver::{get_attribute, xml_read_loop}; use crate::reader::xlsx::chart; use crate::structs::raw::RawRelationships; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct GraphicData { impl GraphicData { #[inline] + #[must_use] pub fn get_chart_space(&self) -> &ChartSpace { &self.chart_space } @@ -73,7 +74,7 @@ impl GraphicData { ); // c:chart - rel_list.push((String::from("CHART"), String::from(""))); + rel_list.push((String::from("CHART"), String::new())); write_start_tag( writer, "c:chart", diff --git a/src/structs/drawing/group_shape_locks.rs b/src/structs/drawing/group_shape_locks.rs index 3528b50e..f27e60bc 100644 --- a/src/structs/drawing/group_shape_locks.rs +++ b/src/structs/drawing/group_shape_locks.rs @@ -1,7 +1,7 @@ // a:grpSpLocks -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::BooleanValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -20,6 +20,7 @@ pub struct GroupShapeLocks { impl GroupShapeLocks { #[inline] + #[must_use] pub fn get_no_change_aspect(&self) -> bool { self.no_change_aspect.get_value() } diff --git a/src/structs/drawing/light_rig.rs b/src/structs/drawing/light_rig.rs index 6ae8d8ed..a3cd7bca 100644 --- a/src/structs/drawing/light_rig.rs +++ b/src/structs/drawing/light_rig.rs @@ -3,8 +3,8 @@ use super::super::EnumValue; use super::LightRigDirectionValues; use super::LightRigValues; use super::Rotation; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct LightRig { impl LightRig { #[inline] + #[must_use] pub fn get_rig(&self) -> &LightRigValues { self.rig.get_value() } @@ -30,6 +31,7 @@ impl LightRig { } #[inline] + #[must_use] pub fn get_definition(&self) -> &LightRigDirectionValues { self.definition.get_value() } @@ -41,6 +43,7 @@ impl LightRig { } #[inline] + #[must_use] pub fn get_rotation(&self) -> Option<&Rotation> { self.rotation.as_deref() } diff --git a/src/structs/drawing/line_spacing.rs b/src/structs/drawing/line_spacing.rs index 32eea214..3659fd63 100644 --- a/src/structs/drawing/line_spacing.rs +++ b/src/structs/drawing/line_spacing.rs @@ -1,7 +1,7 @@ // a:lnSpc use super::SpacingPercent; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct LineSpacing { impl LineSpacing { #[inline] + #[must_use] pub fn get_spacing_percent(&self) -> Option<&SpacingPercent> { self.spacing_percent.as_ref() } diff --git a/src/structs/drawing/line_style_list.rs b/src/structs/drawing/line_style_list.rs index 32678b53..814db86c 100644 --- a/src/structs/drawing/line_style_list.rs +++ b/src/structs/drawing/line_style_list.rs @@ -1,6 +1,6 @@ use super::Outline; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct LineStyleList { impl LineStyleList { #[inline] + #[must_use] pub fn get_outline_collection(&self) -> &[Outline] { &self.outline_collection } diff --git a/src/structs/drawing/linear_gradient_fill.rs b/src/structs/drawing/linear_gradient_fill.rs index 3e23c569..db71b919 100644 --- a/src/structs/drawing/linear_gradient_fill.rs +++ b/src/structs/drawing/linear_gradient_fill.rs @@ -1,8 +1,8 @@ // a:lin use super::super::super::BooleanValue; use super::super::super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct LinearGradientFill { impl LinearGradientFill { #[inline] + #[must_use] pub fn get_angle(&self) -> i32 { self.angle.get_value() } @@ -27,6 +28,7 @@ impl LinearGradientFill { } #[inline] + #[must_use] pub fn get_scaled(&self) -> bool { self.scaled.get_value() } diff --git a/src/structs/drawing/list_style.rs b/src/structs/drawing/list_style.rs index fe7d35bb..ed052786 100644 --- a/src/structs/drawing/list_style.rs +++ b/src/structs/drawing/list_style.rs @@ -1,8 +1,8 @@ // a:lstStyle use super::EffectList; use super::TextParagraphPropertiesType; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct ListStyle { impl ListStyle { #[inline] + #[must_use] pub fn get_effect_list(&self) -> Option<&EffectList> { self.effect_list.as_deref() } diff --git a/src/structs/drawing/miter.rs b/src/structs/drawing/miter.rs index d367580d..25c7e08f 100644 --- a/src/structs/drawing/miter.rs +++ b/src/structs/drawing/miter.rs @@ -1,6 +1,6 @@ // a:miter -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use crate::Int32Value; use quick_xml::events::BytesStart; use quick_xml::Reader; @@ -14,6 +14,7 @@ pub struct Miter { impl Miter { #[inline] + #[must_use] pub fn get_limit(&self) -> i32 { self.limit.get_value() } diff --git a/src/structs/drawing/no_fill.rs b/src/structs/drawing/no_fill.rs index e8ec34cb..4a6cc78f 100644 --- a/src/structs/drawing/no_fill.rs +++ b/src/structs/drawing/no_fill.rs @@ -1,5 +1,5 @@ // a:noFill -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/offset.rs b/src/structs/drawing/offset.rs index 636bf1f3..02c87737 100644 --- a/src/structs/drawing/offset.rs +++ b/src/structs/drawing/offset.rs @@ -1,7 +1,7 @@ // a:off use super::super::super::Int64Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Offset { } impl Offset { #[inline] + #[must_use] pub fn get_x(&self) -> i64 { self.x.get_value() } @@ -24,6 +25,7 @@ impl Offset { } #[inline] + #[must_use] pub fn get_y(&self) -> i64 { self.y.get_value() } diff --git a/src/structs/drawing/outer_shadow.rs b/src/structs/drawing/outer_shadow.rs index f7501717..985ccbe9 100644 --- a/src/structs/drawing/outer_shadow.rs +++ b/src/structs/drawing/outer_shadow.rs @@ -2,8 +2,8 @@ use super::PresetColor; use super::RgbColorModelHex; use super::SchemeColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::StringValue; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -26,6 +26,7 @@ pub struct OuterShadow { impl OuterShadow { #[inline] + #[must_use] pub fn get_blur_radius(&self) -> Option<&str> { self.blur_radius.get_value() } @@ -37,6 +38,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_horizontal_ratio(&self) -> Option<&str> { self.horizontal_ratio.get_value() } @@ -48,6 +50,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_vertical_ratio(&self) -> Option<&str> { self.vertical_ratio.get_value() } @@ -59,6 +62,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_alignment(&self) -> Option<&str> { self.alignment.get_value() } @@ -70,6 +74,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_direction(&self) -> Option<&str> { self.direction.get_value() } @@ -81,6 +86,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_distance(&self) -> Option<&str> { self.distance.get_value() } @@ -91,6 +97,7 @@ impl OuterShadow { self } + #[must_use] pub fn get_rotate_with_shape(&self) -> Option<&str> { self.rotate_with_shape.get_value() } @@ -102,6 +109,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_preset_color(&self) -> Option<&PresetColor> { self.preset_color.as_deref() } @@ -118,6 +126,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_scheme_color(&self) -> Option<&SchemeColor> { self.scheme_color.as_deref() } @@ -134,6 +143,7 @@ impl OuterShadow { } #[inline] + #[must_use] pub fn get_rgb_color_model_hex(&self) -> Option<&RgbColorModelHex> { self.rgb_color_model_hex.as_deref() } diff --git a/src/structs/drawing/outline.rs b/src/structs/drawing/outline.rs index 820edde2..723ef4a5 100644 --- a/src/structs/drawing/outline.rs +++ b/src/structs/drawing/outline.rs @@ -8,10 +8,10 @@ use super::PresetDash; use super::Round; use super::SolidFill; use super::TailEnd; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::EnumValue; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::StringValue; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -36,6 +36,7 @@ pub struct Outline { impl Outline { #[inline] + #[must_use] pub fn get_width(&self) -> u32 { self.width.get_value() } @@ -47,6 +48,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_cap_type(&self) -> Option<&str> { self.cap_type.get_value() } @@ -58,6 +60,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_compound_line_type(&self) -> Option<&str> { self.compound_line_type.get_value() } @@ -69,6 +72,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_solid_fill(&self) -> Option<&SolidFill> { self.solid_fill.as_deref() } @@ -85,6 +89,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_gradient_fill(&self) -> Option<&GradientFill> { self.gradient_fill.as_deref() } @@ -101,6 +106,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_tail_end(&self) -> Option<&TailEnd> { self.tail_end.as_deref() } @@ -117,6 +123,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_no_fill(&self) -> Option<&NoFill> { self.no_fill.as_ref() } @@ -133,6 +140,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_bevel(&self) -> Option<&Bevel> { self.bevel.as_deref() } @@ -149,6 +157,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_preset_dash(&self) -> Option<&PresetDash> { self.preset_dash.as_ref() } @@ -165,6 +174,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_miter(&self) -> Option<&Miter> { self.miter.as_ref() } @@ -181,6 +191,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_round(&self) -> Option<&Round> { self.round.as_ref() } @@ -197,6 +208,7 @@ impl Outline { } #[inline] + #[must_use] pub fn get_alignment(&self) -> &PenAlignmentValues { self.alignment.get_value() } diff --git a/src/structs/drawing/paragraph.rs b/src/structs/drawing/paragraph.rs index 56f372cc..b93dfb41 100644 --- a/src/structs/drawing/paragraph.rs +++ b/src/structs/drawing/paragraph.rs @@ -2,8 +2,8 @@ use super::ParagraphProperties; use super::Run; use super::RunProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct Paragraph { impl Paragraph { #[inline] + #[must_use] pub fn get_paragraph_properties(&self) -> &ParagraphProperties { &self.paragraph_properties } @@ -35,6 +36,7 @@ impl Paragraph { } #[inline] + #[must_use] pub fn get_run(&self) -> &[Run] { &self.run } @@ -45,6 +47,7 @@ impl Paragraph { } #[inline] + #[must_use] pub fn get_end_para_run_properties(&self) -> Option<&RunProperties> { self.end_para_run_properties.as_deref() } diff --git a/src/structs/drawing/paragraph_properties.rs b/src/structs/drawing/paragraph_properties.rs index 055f4d29..c198b0bf 100644 --- a/src/structs/drawing/paragraph_properties.rs +++ b/src/structs/drawing/paragraph_properties.rs @@ -3,8 +3,8 @@ use super::super::EnumValue; use super::LineSpacing; use super::RunProperties; use super::TextAlignmentTypeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::StringValue; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -21,6 +21,7 @@ pub struct ParagraphProperties { impl ParagraphProperties { #[inline] + #[must_use] pub fn get_right_to_left(&self) -> Option<&str> { self.right_to_left.get_value() } @@ -32,6 +33,7 @@ impl ParagraphProperties { } #[inline] + #[must_use] pub fn get_alignment(&self) -> &TextAlignmentTypeValues { self.alignment.get_value() } @@ -43,6 +45,7 @@ impl ParagraphProperties { } #[inline] + #[must_use] pub fn get_default_run_properties(&self) -> Option<&RunProperties> { self.default_run_properties.as_deref() } @@ -59,6 +62,7 @@ impl ParagraphProperties { } #[inline] + #[must_use] pub fn get_line_spacing(&self) -> Option<&LineSpacing> { self.line_spacing.as_ref() } @@ -138,12 +142,12 @@ impl ParagraphProperties { if !empty_flag { // a:defRPr if let Some(v) = &self.default_run_properties { - v.write_to_def_rpr(writer) + v.write_to_def_rpr(writer); } // a:lnSpc if let Some(v) = &self.line_spacing { - v.write_to(writer) + v.write_to(writer); } write_end_tag(writer, "a:pPr"); diff --git a/src/structs/drawing/pattern_fill.rs b/src/structs/drawing/pattern_fill.rs index 8e7fdd46..8a1fea8b 100644 --- a/src/structs/drawing/pattern_fill.rs +++ b/src/structs/drawing/pattern_fill.rs @@ -1,8 +1,8 @@ // a:pattFill use super::BackgroundColor; use super::ForegroundColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -28,6 +28,7 @@ impl Default for PatternFill { impl PatternFill { #[inline] + #[must_use] pub fn get_preset(&self) -> &str { &self.preset } @@ -39,6 +40,7 @@ impl PatternFill { } #[inline] + #[must_use] pub fn get_foreground_color(&self) -> &ForegroundColor { &self.foreground_color } @@ -55,6 +57,7 @@ impl PatternFill { } #[inline] + #[must_use] pub fn get_background_color(&self) -> &BackgroundColor { &self.background_color } diff --git a/src/structs/drawing/percentage_type.rs b/src/structs/drawing/percentage_type.rs index d36038a9..a615aa5f 100644 --- a/src/structs/drawing/percentage_type.rs +++ b/src/structs/drawing/percentage_type.rs @@ -1,6 +1,6 @@ use super::super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct PercentageType { impl PercentageType { #[inline] + #[must_use] pub fn get_val(&self) -> i32 { self.val.get_value() } @@ -34,27 +35,27 @@ impl PercentageType { #[inline] pub(crate) fn write_to_lum(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lum") + self.write_to(writer, "a:lum"); } #[inline] pub(crate) fn write_to_lum_mod(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lumMod") + self.write_to(writer, "a:lumMod"); } #[inline] pub(crate) fn write_to_lum_off(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lumOff") + self.write_to(writer, "a:lumOff"); } #[inline] pub(crate) fn write_to_sat(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:sat") + self.write_to(writer, "a:sat"); } #[inline] pub(crate) fn write_to_sat_mod(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:satMod") + self.write_to(writer, "a:satMod"); } fn write_to(&self, writer: &mut Writer>>, tab_name: &str) { diff --git a/src/structs/drawing/picture_locks.rs b/src/structs/drawing/picture_locks.rs index 170ddbc1..52fc8b90 100644 --- a/src/structs/drawing/picture_locks.rs +++ b/src/structs/drawing/picture_locks.rs @@ -1,6 +1,6 @@ // a:picLocks -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct PictureLocks { impl PictureLocks { #[inline] + #[must_use] pub fn get_no_change_aspect(&self) -> bool { self.no_change_aspect } diff --git a/src/structs/drawing/point_2d_type.rs b/src/structs/drawing/point_2d_type.rs index f1eba176..47932363 100644 --- a/src/structs/drawing/point_2d_type.rs +++ b/src/structs/drawing/point_2d_type.rs @@ -1,8 +1,8 @@ // a:off // a:chOff -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::Int64Value; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct Point2DType { impl Point2DType { #[inline] + #[must_use] pub fn get_x(&self) -> i64 { self.x.get_value() } @@ -26,6 +27,7 @@ impl Point2DType { } #[inline] + #[must_use] pub fn get_y(&self) -> i64 { self.y.get_value() } diff --git a/src/structs/drawing/positive_fixed_percentage_type.rs b/src/structs/drawing/positive_fixed_percentage_type.rs index 8d40fcd5..7acd30c5 100644 --- a/src/structs/drawing/positive_fixed_percentage_type.rs +++ b/src/structs/drawing/positive_fixed_percentage_type.rs @@ -1,6 +1,6 @@ use super::super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct PositiveFixedPercentageType { impl PositiveFixedPercentageType { #[inline] + #[must_use] pub fn get_val(&self) -> i32 { self.val.get_value() } @@ -34,17 +35,17 @@ impl PositiveFixedPercentageType { #[inline] pub(crate) fn write_to_shade(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:shade") + self.write_to(writer, "a:shade"); } #[inline] pub(crate) fn write_to_alpha(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:alpha") + self.write_to(writer, "a:alpha"); } #[inline] pub(crate) fn write_to_tint(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:tint") + self.write_to(writer, "a:tint"); } fn write_to(&self, writer: &mut Writer>>, tab_name: &str) { diff --git a/src/structs/drawing/positive_size_2d_type.rs b/src/structs/drawing/positive_size_2d_type.rs index a5b8824a..5f56a706 100644 --- a/src/structs/drawing/positive_size_2d_type.rs +++ b/src/structs/drawing/positive_size_2d_type.rs @@ -1,8 +1,8 @@ // a:ext // a:chExt -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::Int64Value; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct PositiveSize2DType { impl PositiveSize2DType { #[inline] + #[must_use] pub fn get_cx(&self) -> i64 { self.cx.get_value() } @@ -26,6 +27,7 @@ impl PositiveSize2DType { } #[inline] + #[must_use] pub fn get_cy(&self) -> i64 { self.cy.get_value() } diff --git a/src/structs/drawing/preset_color.rs b/src/structs/drawing/preset_color.rs index 27a69d76..ccaa5e75 100644 --- a/src/structs/drawing/preset_color.rs +++ b/src/structs/drawing/preset_color.rs @@ -1,7 +1,7 @@ // a:prstClr use super::alpha::Alpha; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct PresetColor { impl PresetColor { #[inline] + #[must_use] pub fn get_val(&self) -> &str { &self.val } @@ -25,6 +26,7 @@ impl PresetColor { } #[inline] + #[must_use] pub fn get_alpha(&self) -> Option<&Alpha> { self.alpha.as_ref() } @@ -70,7 +72,7 @@ impl PresetColor { // a:alpha if let Some(v) = &self.alpha { - v.write_to(writer) + v.write_to(writer); } write_end_tag(writer, "a:prstClr"); diff --git a/src/structs/drawing/preset_dash.rs b/src/structs/drawing/preset_dash.rs index c836d9b6..191049d3 100644 --- a/src/structs/drawing/preset_dash.rs +++ b/src/structs/drawing/preset_dash.rs @@ -1,8 +1,8 @@ // a:prstDash use super::super::EnumValue; use super::PresetLineDashValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct PresetDash { } impl PresetDash { #[inline] + #[must_use] pub fn get_val(&self) -> &PresetLineDashValues { self.val.get_value() } diff --git a/src/structs/drawing/preset_geometry.rs b/src/structs/drawing/preset_geometry.rs index 950c7e2f..6764f1bc 100644 --- a/src/structs/drawing/preset_geometry.rs +++ b/src/structs/drawing/preset_geometry.rs @@ -1,7 +1,7 @@ // a:prstGeom use super::adjust_value_list::AdjustValueList; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -204,6 +204,7 @@ impl PresetGeometry { pub const GEOMETRY_WEDGEROUNDRECTCALLOUT: &'static str = "wedgeRoundRectCallout"; #[inline] + #[must_use] pub fn get_geometry(&self) -> &str { &self.geometry } @@ -214,6 +215,7 @@ impl PresetGeometry { } #[inline] + #[must_use] pub fn get_adjust_value_list(&self) -> &AdjustValueList { &self.adjust_value_list } diff --git a/src/structs/drawing/rgb_color_model_hex.rs b/src/structs/drawing/rgb_color_model_hex.rs index b6917a03..d36993c6 100644 --- a/src/structs/drawing/rgb_color_model_hex.rs +++ b/src/structs/drawing/rgb_color_model_hex.rs @@ -3,8 +3,8 @@ use super::super::StringValue; use super::PercentageType; use super::PositiveFixedPercentageType; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -25,6 +25,7 @@ pub struct RgbColorModelHex { impl RgbColorModelHex { #[inline] + #[must_use] pub fn get_val(&self) -> &str { self.val.get_value_str() } @@ -36,6 +37,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_luminance(&self) -> Option<&PercentageType> { self.luminance.as_ref() } @@ -51,6 +53,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_luminance_modulation(&self) -> Option<&PercentageType> { self.luminance_modulation.as_ref() } @@ -66,6 +69,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_luminance_offset(&self) -> Option<&PercentageType> { self.luminance_offset.as_ref() } @@ -81,6 +85,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_saturation(&self) -> Option<&PercentageType> { self.saturation.as_ref() } @@ -96,6 +101,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_saturation_modulation(&self) -> Option<&PercentageType> { self.saturation_modulation.as_ref() } @@ -111,6 +117,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_shade(&self) -> Option<&PositiveFixedPercentageType> { self.shade.as_ref() } @@ -126,6 +133,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_alpha(&self) -> Option<&PositiveFixedPercentageType> { self.alpha.as_ref() } @@ -141,6 +149,7 @@ impl RgbColorModelHex { } #[inline] + #[must_use] pub fn get_tint(&self) -> Option<&PositiveFixedPercentageType> { self.tint.as_ref() } diff --git a/src/structs/drawing/rotation.rs b/src/structs/drawing/rotation.rs index 5fd87c9b..e9b88db4 100644 --- a/src/structs/drawing/rotation.rs +++ b/src/structs/drawing/rotation.rs @@ -1,7 +1,7 @@ // a:rot use super::super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct Rotation { impl Rotation { #[inline] + #[must_use] pub fn get_latitude(&self) -> i32 { self.latitude.get_value() } @@ -27,6 +28,7 @@ impl Rotation { } #[inline] + #[must_use] pub fn get_longitude(&self) -> i32 { self.longitude.get_value() } @@ -38,6 +40,7 @@ impl Rotation { } #[inline] + #[must_use] pub fn get_revolution(&self) -> i32 { self.revolution.get_value() } diff --git a/src/structs/drawing/round.rs b/src/structs/drawing/round.rs index 8065f19d..84dfbe70 100644 --- a/src/structs/drawing/round.rs +++ b/src/structs/drawing/round.rs @@ -1,5 +1,5 @@ // a:round -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/run.rs b/src/structs/drawing/run.rs index f243c966..6538b34b 100644 --- a/src/structs/drawing/run.rs +++ b/src/structs/drawing/run.rs @@ -1,6 +1,6 @@ use super::run_properties::RunProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Run { impl Run { #[inline] + #[must_use] pub fn get_text(&self) -> &str { &self.text } @@ -24,6 +25,7 @@ impl Run { } #[inline] + #[must_use] pub fn get_run_properties(&self) -> &RunProperties { &self.run_properties } diff --git a/src/structs/drawing/run_properties.rs b/src/structs/drawing/run_properties.rs index 630ceb20..6119c1d7 100644 --- a/src/structs/drawing/run_properties.rs +++ b/src/structs/drawing/run_properties.rs @@ -7,9 +7,9 @@ use super::Outline; use super::SolidFill; use super::TextCapsValues; use super::TextFontType; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -38,6 +38,7 @@ pub struct RunProperties { impl RunProperties { #[inline] + #[must_use] pub fn get_text(&self) -> &str { &self.text } @@ -49,6 +50,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_kumimoji(&self) -> &str { self.kumimoji.get_value_str() } @@ -60,6 +62,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_language(&self) -> &str { self.language.get_value_str() } @@ -71,6 +74,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_alternative_language(&self) -> &str { self.alternative_language.get_value_str() } @@ -82,6 +86,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_bold(&self) -> &str { self.bold.get_value_str() } @@ -93,6 +98,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_sz(&self) -> &str { self.sz.get_value_str() } @@ -104,6 +110,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_italic(&self) -> &str { self.italic.get_value_str() } @@ -115,6 +122,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_capital(&self) -> &TextCapsValues { self.capital.get_value() } @@ -126,6 +134,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_spacing(&self) -> i32 { self.spacing.get_value() } @@ -137,6 +146,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_strike(&self) -> &str { self.strike.get_value_str() } @@ -148,6 +158,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_solid_fill(&self) -> Option<&SolidFill> { self.solid_fill.as_deref() } @@ -164,6 +175,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_outline(&self) -> Option<&Outline> { self.outline.as_deref() } @@ -180,6 +192,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_latin_font(&self) -> Option<&TextFontType> { self.latin_font.as_deref() } @@ -196,6 +209,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_east_asian_font(&self) -> Option<&TextFontType> { self.east_asian_font.as_deref() } @@ -212,6 +226,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_gradient_fill(&self) -> Option<&GradientFill> { self.gradient_fill.as_deref() } @@ -228,6 +243,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_no_fill(&self) -> Option<&NoFill> { self.no_fill.as_ref() } @@ -244,6 +260,7 @@ impl RunProperties { } #[inline] + #[must_use] pub fn get_effect_list(&self) -> Option<&EffectList> { self.effect_list.as_deref() } @@ -366,38 +383,38 @@ impl RunProperties { #[inline] pub(crate) fn write_to_rpr(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:rPr") + self.write_to(writer, "a:rPr"); } #[inline] pub(crate) fn write_to_end_para_rpr(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:endParaRPr") + self.write_to(writer, "a:endParaRPr"); } #[inline] pub(crate) fn write_to_def_rpr(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:defRPr") + self.write_to(writer, "a:defRPr"); } fn write_to(&self, writer: &mut Writer>>, tag_name: &str) { let mut attributes: Vec<(&str, &str)> = Vec::new(); if self.kumimoji.has_value() { - attributes.push(("kumimoji", self.kumimoji.get_value_str())) + attributes.push(("kumimoji", self.kumimoji.get_value_str())); } if self.language.has_value() { - attributes.push(("lang", self.language.get_value_str())) + attributes.push(("lang", self.language.get_value_str())); } if self.alternative_language.has_value() { - attributes.push(("altLang", self.alternative_language.get_value_str())) + attributes.push(("altLang", self.alternative_language.get_value_str())); } if self.sz.has_value() { - attributes.push(("sz", self.sz.get_value_str())) + attributes.push(("sz", self.sz.get_value_str())); } if self.bold.has_value() { - attributes.push(("b", self.bold.get_value_str())) + attributes.push(("b", self.bold.get_value_str())); } if self.italic.has_value() { - attributes.push(("i", self.italic.get_value_str())) + attributes.push(("i", self.italic.get_value_str())); } if self.capital.has_value() { attributes.push(("cap", self.capital.get_value_string())); diff --git a/src/structs/drawing/scene_3d_type.rs b/src/structs/drawing/scene_3d_type.rs index d460720f..4f8af1d0 100644 --- a/src/structs/drawing/scene_3d_type.rs +++ b/src/structs/drawing/scene_3d_type.rs @@ -1,8 +1,8 @@ // a:scene3d use super::Camera; use super::LightRig; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct Scene3DType { impl Scene3DType { #[inline] + #[must_use] pub fn get_camera(&self) -> Option<&Camera> { self.camera.as_ref() } @@ -27,6 +28,7 @@ impl Scene3DType { } #[inline] + #[must_use] pub fn get_light_rig(&self) -> Option<&LightRig> { self.light_rig.as_ref() } diff --git a/src/structs/drawing/scheme_color.rs b/src/structs/drawing/scheme_color.rs index 7c08b750..20c642ed 100644 --- a/src/structs/drawing/scheme_color.rs +++ b/src/structs/drawing/scheme_color.rs @@ -3,8 +3,8 @@ use super::super::EnumValue; use super::PercentageType; use super::PositiveFixedPercentageType; use super::SchemeColorValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -25,6 +25,7 @@ pub struct SchemeColor { impl SchemeColor { #[inline] + #[must_use] pub fn get_val(&self) -> &SchemeColorValues { self.val.get_value() } @@ -36,6 +37,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_luminance(&self) -> Option<&PercentageType> { self.luminance.as_ref() } @@ -51,6 +53,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_luminance_modulation(&self) -> Option<&PercentageType> { self.luminance_modulation.as_ref() } @@ -66,6 +69,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_luminance_offset(&self) -> Option<&PercentageType> { self.luminance_offset.as_ref() } @@ -81,6 +85,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_saturation(&self) -> Option<&PercentageType> { self.saturation.as_ref() } @@ -96,6 +101,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_saturation_modulation(&self) -> Option<&PercentageType> { self.saturation_modulation.as_ref() } @@ -111,6 +117,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_shade(&self) -> Option<&PositiveFixedPercentageType> { self.shade.as_ref() } @@ -126,6 +133,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_alpha(&self) -> Option<&PositiveFixedPercentageType> { self.alpha.as_ref() } @@ -141,6 +149,7 @@ impl SchemeColor { } #[inline] + #[must_use] pub fn get_tint(&self) -> Option<&PositiveFixedPercentageType> { self.tint.as_ref() } diff --git a/src/structs/drawing/shape_3d_type.rs b/src/structs/drawing/shape_3d_type.rs index 257e759e..3c1bf336 100644 --- a/src/structs/drawing/shape_3d_type.rs +++ b/src/structs/drawing/shape_3d_type.rs @@ -3,8 +3,8 @@ use super::super::EnumValue; use super::BevelBottom; use super::BevelTop; use super::PresetMaterialTypeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct Shape3DType { impl Shape3DType { #[inline] + #[must_use] pub fn get_preset_material(&self) -> &PresetMaterialTypeValues { self.preset_material.get_value() } @@ -30,6 +31,7 @@ impl Shape3DType { } #[inline] + #[must_use] pub fn get_bevel_top(&self) -> Option<&BevelTop> { self.bevel_top.as_deref() } @@ -45,6 +47,7 @@ impl Shape3DType { } #[inline] + #[must_use] pub fn get_bevel_bottom(&self) -> Option<&BevelBottom> { self.bevel_bottom.as_deref() } @@ -103,12 +106,12 @@ impl Shape3DType { // a:bevelT if let Some(v) = &self.bevel_top { - v.write_to(writer) + v.write_to(writer); } // a:bevelB if let Some(v) = &self.bevel_bottom { - v.write_to(writer) + v.write_to(writer); } write_end_tag(writer, "a:sp3d"); diff --git a/src/structs/drawing/shape_auto_fit.rs b/src/structs/drawing/shape_auto_fit.rs index 79d812d9..cc9aaa8f 100644 --- a/src/structs/drawing/shape_auto_fit.rs +++ b/src/structs/drawing/shape_auto_fit.rs @@ -1,5 +1,5 @@ // a:spAutoFit -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/shape_guide.rs b/src/structs/drawing/shape_guide.rs index bb802a67..ba0fea92 100644 --- a/src/structs/drawing/shape_guide.rs +++ b/src/structs/drawing/shape_guide.rs @@ -1,5 +1,5 @@ // a:gd -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::Writer; use std::io::Cursor; @@ -10,6 +10,7 @@ pub struct ShapeGuide { } impl ShapeGuide { #[inline] + #[must_use] pub fn get_name(&self) -> &str { &self.name } @@ -20,6 +21,7 @@ impl ShapeGuide { } #[inline] + #[must_use] pub fn get_fmla(&self) -> &str { &self.fmla } diff --git a/src/structs/drawing/soft_edge.rs b/src/structs/drawing/soft_edge.rs index d15d20d6..9dda4deb 100644 --- a/src/structs/drawing/soft_edge.rs +++ b/src/structs/drawing/soft_edge.rs @@ -1,7 +1,7 @@ // a:softEdge use super::super::super::Int64Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct SoftEdge { } impl SoftEdge { #[inline] + #[must_use] pub fn get_radius(&self) -> i64 { self.radius.get_value() } diff --git a/src/structs/drawing/solid_fill.rs b/src/structs/drawing/solid_fill.rs index 822aa29a..eb7b6ce1 100644 --- a/src/structs/drawing/solid_fill.rs +++ b/src/structs/drawing/solid_fill.rs @@ -1,8 +1,8 @@ // a:solidFill use super::rgb_color_model_hex::RgbColorModelHex; use super::scheme_color::SchemeColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct SolidFill { impl SolidFill { #[inline] + #[must_use] pub fn get_scheme_color(&self) -> Option<&SchemeColor> { self.scheme_color.as_deref() } @@ -31,6 +32,7 @@ impl SolidFill { } #[inline] + #[must_use] pub fn get_rgb_color_model_hex(&self) -> Option<&RgbColorModelHex> { self.rgb_color_model_hex.as_deref() } diff --git a/src/structs/drawing/source_rectangle.rs b/src/structs/drawing/source_rectangle.rs index cb879573..9d405bc6 100644 --- a/src/structs/drawing/source_rectangle.rs +++ b/src/structs/drawing/source_rectangle.rs @@ -1,6 +1,6 @@ // a:srcRect -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute_value; +use crate::writer::driver::write_start_tag; use crate::StringValue; use quick_xml::events::BytesStart; use quick_xml::Reader; @@ -21,6 +21,7 @@ impl SourceRectangle { } #[inline] + #[must_use] pub fn get_t(&self) -> Option<&str> { self.t.get_value() } @@ -31,6 +32,7 @@ impl SourceRectangle { } #[inline] + #[must_use] pub fn get_l(&self) -> Option<&str> { self.l.get_value() } @@ -41,6 +43,7 @@ impl SourceRectangle { } #[inline] + #[must_use] pub fn get_r(&self) -> Option<&str> { self.r.get_value() } @@ -51,6 +54,7 @@ impl SourceRectangle { } #[inline] + #[must_use] pub fn get_b(&self) -> Option<&str> { self.b.get_value() } @@ -76,16 +80,16 @@ impl SourceRectangle { let mut attributes: Vec<(&str, &str)> = Vec::new(); if let Some(v) = self.t.get_value() { - attributes.push(("t", v)) + attributes.push(("t", v)); } if let Some(v) = self.l.get_value() { - attributes.push(("l", v)) + attributes.push(("l", v)); } if let Some(v) = self.r.get_value() { - attributes.push(("r", v)) + attributes.push(("r", v)); } if let Some(v) = self.b.get_value() { - attributes.push(("b", v)) + attributes.push(("b", v)); } write_start_tag(writer, "a:srcRect", attributes, true); } diff --git a/src/structs/drawing/space_after.rs b/src/structs/drawing/space_after.rs index 988ca028..2adac00a 100644 --- a/src/structs/drawing/space_after.rs +++ b/src/structs/drawing/space_after.rs @@ -1,7 +1,7 @@ // a:spcAft use super::SpacingPercent; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct SpaceAfter { impl SpaceAfter { #[inline] + #[must_use] pub fn get_spacing_percent(&self) -> Option<&SpacingPercent> { self.spacing_percent.as_ref() } diff --git a/src/structs/drawing/space_before.rs b/src/structs/drawing/space_before.rs index 449e616f..f943844b 100644 --- a/src/structs/drawing/space_before.rs +++ b/src/structs/drawing/space_before.rs @@ -1,7 +1,7 @@ // a:spcBef use super::SpacingPercent; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct SpaceBefore { impl SpaceBefore { #[inline] + #[must_use] pub fn get_spacing_percent(&self) -> Option<&SpacingPercent> { self.spacing_percent.as_ref() } diff --git a/src/structs/drawing/spacing_percent.rs b/src/structs/drawing/spacing_percent.rs index fc796ac6..b910ccec 100644 --- a/src/structs/drawing/spacing_percent.rs +++ b/src/structs/drawing/spacing_percent.rs @@ -1,7 +1,7 @@ // a:spcPct use super::super::super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct SpacingPercent { } impl SpacingPercent { #[inline] + #[must_use] pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/drawing/spreadsheet/blip_fill.rs b/src/structs/drawing/spreadsheet/blip_fill.rs index 56726e46..9bb4debc 100644 --- a/src/structs/drawing/spreadsheet/blip_fill.rs +++ b/src/structs/drawing/spreadsheet/blip_fill.rs @@ -3,9 +3,9 @@ use super::super::super::BooleanValue; use super::super::Blip; use super::super::SourceRectangle; use super::super::Stretch; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -21,6 +21,7 @@ pub struct BlipFill { impl BlipFill { #[inline] + #[must_use] pub fn get_rotate_with_shape(&self) -> bool { self.rotate_with_shape.get_value() } @@ -32,6 +33,7 @@ impl BlipFill { } #[inline] + #[must_use] pub fn get_source_rectangle(&self) -> Option<&SourceRectangle> { self.source_rectangle.as_deref() } @@ -48,6 +50,7 @@ impl BlipFill { } #[inline] + #[must_use] pub fn get_blip(&self) -> &Blip { &self.blip } @@ -64,6 +67,7 @@ impl BlipFill { } #[inline] + #[must_use] pub fn get_stretch(&self) -> &Stretch { &self.stretch } @@ -132,7 +136,7 @@ impl BlipFill { // xdr: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())) + attributes.push(("rotWithShape", self.rotate_with_shape.get_value_string())); } write_start_tag(writer, "xdr:blipFill", attributes, false); diff --git a/src/structs/drawing/spreadsheet/connection_shape.rs b/src/structs/drawing/spreadsheet/connection_shape.rs index b8e11ce4..cee4050d 100644 --- a/src/structs/drawing/spreadsheet/connection_shape.rs +++ b/src/structs/drawing/spreadsheet/connection_shape.rs @@ -3,9 +3,9 @@ use super::super::super::Anchor; use super::NonVisualConnectionShapeProperties; use super::ShapeProperties; use super::ShapeStyle; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -21,6 +21,7 @@ pub struct ConnectionShape { impl ConnectionShape { #[inline] + #[must_use] pub fn get_anchor(&self) -> &Anchor { &self.anchor } @@ -36,6 +37,7 @@ impl ConnectionShape { } #[inline] + #[must_use] pub fn get_non_visual_connection_shape_properties( &self, ) -> &NonVisualConnectionShapeProperties { @@ -58,6 +60,7 @@ impl ConnectionShape { } #[inline] + #[must_use] pub fn get_shape_properties(&self) -> &ShapeProperties { &self.shape_properties } @@ -73,6 +76,7 @@ impl ConnectionShape { } #[inline] + #[must_use] pub fn get_shape_style(&self) -> &ShapeStyle { &self.shape_style } diff --git a/src/structs/drawing/spreadsheet/extent.rs b/src/structs/drawing/spreadsheet/extent.rs index 20f03f27..e3d00013 100644 --- a/src/structs/drawing/spreadsheet/extent.rs +++ b/src/structs/drawing/spreadsheet/extent.rs @@ -1,7 +1,7 @@ // xdr:ext use super::super::super::Int64Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct Extent { impl Extent { #[inline] + #[must_use] pub fn get_cx(&self) -> i64 { self.cx.get_value() } @@ -26,6 +27,7 @@ impl Extent { } #[inline] + #[must_use] pub fn get_cy(&self) -> i64 { self.cy.get_value() } diff --git a/src/structs/drawing/spreadsheet/graphic_frame.rs b/src/structs/drawing/spreadsheet/graphic_frame.rs index 319b2a8b..5ffa95f9 100644 --- a/src/structs/drawing/spreadsheet/graphic_frame.rs +++ b/src/structs/drawing/spreadsheet/graphic_frame.rs @@ -3,10 +3,10 @@ use super::super::super::StringValue; use super::super::Graphic; use super::NonVisualGraphicFrameProperties; use super::Transform; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::raw::RawRelationships; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -22,6 +22,7 @@ pub struct GraphicFrame { impl GraphicFrame { #[inline] + #[must_use] pub fn get_macro(&self) -> &str { self.r#macro.get_value_str() } @@ -33,6 +34,7 @@ impl GraphicFrame { } #[inline] + #[must_use] pub fn get_non_visual_graphic_frame_properties(&self) -> &NonVisualGraphicFrameProperties { &self.non_visual_graphic_frame_properties } @@ -54,6 +56,7 @@ impl GraphicFrame { } #[inline] + #[must_use] pub fn get_transform(&self) -> &Transform { &self.transform } @@ -70,6 +73,7 @@ impl GraphicFrame { } #[inline] + #[must_use] pub fn get_graphic(&self) -> &Graphic { &self.graphic } diff --git a/src/structs/drawing/spreadsheet/group_shape.rs b/src/structs/drawing/spreadsheet/group_shape.rs index d32b4f93..f76f2303 100644 --- a/src/structs/drawing/spreadsheet/group_shape.rs +++ b/src/structs/drawing/spreadsheet/group_shape.rs @@ -3,9 +3,9 @@ use super::GroupShapeProperties; use super::NonVisualGroupShapeProperties; use super::Picture; use super::Shape; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -22,6 +22,7 @@ pub struct GroupShape { impl GroupShape { #[inline] + #[must_use] pub fn get_non_visual_group_shape_properties(&self) -> &NonVisualGroupShapeProperties { &self.non_visual_group_shape_properties } @@ -39,6 +40,7 @@ impl GroupShape { } #[inline] + #[must_use] pub fn get_group_shape_properties(&self) -> &GroupShapeProperties { &self.group_shape_properties } @@ -54,6 +56,7 @@ impl GroupShape { } #[inline] + #[must_use] pub fn get_picture_collection(&self) -> &[Picture] { &self.picture_collection } @@ -69,6 +72,7 @@ impl GroupShape { } #[inline] + #[must_use] pub fn get_shape_collection(&self) -> &[Shape] { &self.shape_collection } diff --git a/src/structs/drawing/spreadsheet/group_shape_properties.rs b/src/structs/drawing/spreadsheet/group_shape_properties.rs index de0cc34b..6024935e 100644 --- a/src/structs/drawing/spreadsheet/group_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/group_shape_properties.rs @@ -1,7 +1,7 @@ // xdr:grpSpPr use super::super::Transform2D; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct GroupShapeProperties { impl GroupShapeProperties { #[inline] + #[must_use] pub fn get_transform2d(&self) -> Option<&Transform2D> { self.transform2d.as_ref() } diff --git a/src/structs/drawing/spreadsheet/marker_type.rs b/src/structs/drawing/spreadsheet/marker_type.rs index 02d4142c..c10c9651 100644 --- a/src/structs/drawing/spreadsheet/marker_type.rs +++ b/src/structs/drawing/spreadsheet/marker_type.rs @@ -1,7 +1,10 @@ // xdr:from,xdr:to -use crate::helper::coordinate::*; +use crate::helper::coordinate::{ + adjustment_insert_coordinate, adjustment_remove_coordinate, coordinate_from_index, + index_from_coordinate, is_remove_coordinate, +}; use crate::traits::AdjustmentCoordinate; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +19,7 @@ pub struct MarkerType { } impl MarkerType { #[inline] + #[must_use] pub fn get_col(&self) -> u32 { self.col } @@ -27,6 +31,7 @@ impl MarkerType { } #[inline] + #[must_use] pub fn get_col_off(&self) -> i32 { self.col_off } @@ -44,6 +49,7 @@ impl MarkerType { } #[inline] + #[must_use] pub fn get_row(&self) -> u32 { self.row } @@ -55,6 +61,7 @@ impl MarkerType { } #[inline] + #[must_use] pub fn get_row_off(&self) -> i32 { self.row_off } @@ -72,6 +79,7 @@ impl MarkerType { } #[inline] + #[must_use] pub fn get_coordinate(&self) -> String { coordinate_from_index(self.col + 1, self.row + 1) } @@ -88,7 +96,7 @@ impl MarkerType { reader: &mut Reader, _e: &BytesStart, ) { - let mut string_value: String = String::from(""); + let mut string_value: String = String::new(); let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf) { diff --git a/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs b/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs index 6fdebac6..89391e13 100644 --- a/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_connection_shape_properties.rs @@ -1,8 +1,8 @@ // xdr:nvCxnSpPr use super::NonVisualConnectorShapeDrawingProperties; use super::NonVisualDrawingProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct NonVisualConnectionShapeProperties { impl NonVisualConnectionShapeProperties { #[inline] + #[must_use] pub fn get_non_visual_drawing_properties(&self) -> &NonVisualDrawingProperties { &self.non_visual_drawing_properties } @@ -35,6 +36,7 @@ impl NonVisualConnectionShapeProperties { } #[inline] + #[must_use] pub fn get_non_visual_connector_shape_drawing_properties( &self, ) -> &NonVisualConnectorShapeDrawingProperties { diff --git a/src/structs/drawing/spreadsheet/non_visual_connector_shape_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_connector_shape_drawing_properties.rs index 43d317a4..9e795b6a 100644 --- a/src/structs/drawing/spreadsheet/non_visual_connector_shape_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_connector_shape_drawing_properties.rs @@ -1,8 +1,8 @@ // xdr:cNvCxnSpPr use super::super::EndConnection; use super::super::StartConnection; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct NonVisualConnectorShapeDrawingProperties { impl NonVisualConnectorShapeDrawingProperties { #[inline] + #[must_use] pub fn get_start_connection(&self) -> Option<&StartConnection> { self.start_connection.as_deref() } @@ -31,6 +32,7 @@ impl NonVisualConnectorShapeDrawingProperties { } #[inline] + #[must_use] pub fn get_end_connection(&self) -> Option<&EndConnection> { self.end_connection.as_deref() } diff --git a/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs index d6ac338a..ccfb033c 100644 --- a/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_drawing_properties.rs @@ -2,8 +2,8 @@ use super::super::super::BooleanValue; use super::super::super::StringValue; use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct NonVisualDrawingProperties { impl NonVisualDrawingProperties { #[inline] + #[must_use] pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -29,6 +30,7 @@ impl NonVisualDrawingProperties { } #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -40,6 +42,7 @@ impl NonVisualDrawingProperties { } #[inline] + #[must_use] pub fn get_hidden(&self) -> bool { self.hidden.get_value() } @@ -89,7 +92,7 @@ impl NonVisualDrawingProperties { write_start_tag(writer, "xdr:cNvPr", attributes, !with_inner); if with_inner { - let spid = format!("_x0000_s{}", ole_id); + let spid = format!("_x0000_s{ole_id}"); write_start_tag(writer, "a:extLst", vec![], false); write_start_tag( writer, diff --git a/src/structs/drawing/spreadsheet/non_visual_graphic_frame_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_graphic_frame_drawing_properties.rs index 53901e3e..62b84d46 100644 --- a/src/structs/drawing/spreadsheet/non_visual_graphic_frame_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_graphic_frame_drawing_properties.rs @@ -1,5 +1,5 @@ // xdr:cNvGraphicFramePr -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs b/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs index 5c231e6a..d9c875a1 100644 --- a/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_graphic_frame_properties.rs @@ -1,8 +1,8 @@ // xdr:nvGraphicFramePr use super::NonVisualDrawingProperties; use super::NonVisualGraphicFrameDrawingProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct NonVisualGraphicFrameProperties { impl NonVisualGraphicFrameProperties { #[inline] + #[must_use] pub fn get_non_visual_drawing_properties(&self) -> &NonVisualDrawingProperties { &self.non_visual_drawing_properties } @@ -35,6 +36,7 @@ impl NonVisualGraphicFrameProperties { } #[inline] + #[must_use] pub fn get_non_visual_graphic_frame_drawing_properties( &self, ) -> &NonVisualGraphicFrameDrawingProperties { diff --git a/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs index 3de684c2..54f8ed24 100644 --- a/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_group_shape_drawing_properties.rs @@ -1,7 +1,7 @@ // xdr:cNvGrpSpPr use super::super::GroupShapeLocks; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct NonVisualGroupShapeDrawingProperties { impl NonVisualGroupShapeDrawingProperties { #[inline] + #[must_use] pub fn get_group_shape_locks(&self) -> Option<&GroupShapeLocks> { self.group_shape_locks.as_ref() } diff --git a/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs b/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs index 245a89b7..ac1c3086 100644 --- a/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_group_shape_properties.rs @@ -1,8 +1,8 @@ // xdr:nvGrpSpPr use super::NonVisualDrawingProperties; use super::NonVisualGroupShapeDrawingProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct NonVisualGroupShapeProperties { impl NonVisualGroupShapeProperties { #[inline] + #[must_use] pub fn get_non_visual_drawing_properties(&self) -> &NonVisualDrawingProperties { &self.non_visual_drawing_properties } @@ -35,6 +36,7 @@ impl NonVisualGroupShapeProperties { } #[inline] + #[must_use] pub fn get_non_visual_group_shape_drawing_properties( &self, ) -> &NonVisualGroupShapeDrawingProperties { diff --git a/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs b/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs index 74ddad77..83ff4bcd 100644 --- a/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_picture_drawing_properties.rs @@ -1,8 +1,8 @@ //xdr:cNvPicPr use super::super::PictureLocks; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::BooleanValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct NonVisualPictureDrawingProperties { impl NonVisualPictureDrawingProperties { #[inline] + #[must_use] pub fn get_prefer_relative_resize(&self) -> bool { self.prefer_relative_resize.get_value() } @@ -26,6 +27,7 @@ impl NonVisualPictureDrawingProperties { } #[inline] + #[must_use] pub fn get_picture_locks(&self) -> Option<&PictureLocks> { self.picture_locks.as_ref() } diff --git a/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs b/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs index 652e39fe..44d98492 100644 --- a/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_picture_properties.rs @@ -1,8 +1,8 @@ //xdr:nvPicPr use super::NonVisualDrawingProperties; use super::NonVisualPictureDrawingProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct NonVisualPictureProperties { impl NonVisualPictureProperties { #[inline] + #[must_use] pub fn get_non_visual_drawing_properties(&self) -> &NonVisualDrawingProperties { &self.non_visual_drawing_properties } @@ -31,6 +32,7 @@ impl NonVisualPictureProperties { } #[inline] + #[must_use] pub fn get_non_visual_picture_drawing_properties(&self) -> &NonVisualPictureDrawingProperties { &self.non_visual_picture_drawing_properties } diff --git a/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs b/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs index fc0e3e83..45803e53 100644 --- a/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs +++ b/src/structs/drawing/spreadsheet/non_visual_shape_properties.rs @@ -1,7 +1,7 @@ // xdr:nvSpPr use super::NonVisualDrawingProperties; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct NonVisualShapeProperties { impl NonVisualShapeProperties { #[inline] + #[must_use] pub fn get_non_visual_drawing_properties(&self) -> &NonVisualDrawingProperties { &self.non_visual_drawing_properties } diff --git a/src/structs/drawing/spreadsheet/one_cell_anchor.rs b/src/structs/drawing/spreadsheet/one_cell_anchor.rs index 98c66d4a..4d4fb38f 100644 --- a/src/structs/drawing/spreadsheet/one_cell_anchor.rs +++ b/src/structs/drawing/spreadsheet/one_cell_anchor.rs @@ -4,10 +4,10 @@ use super::GroupShape; use super::MarkerType; use super::Picture; use super::Shape; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; use crate::traits::AdjustmentCoordinate; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct OneCellAnchor { impl OneCellAnchor { #[inline] + #[must_use] pub fn get_from_marker(&self) -> &MarkerType { &self.from_marker } @@ -40,6 +41,7 @@ impl OneCellAnchor { } #[inline] + #[must_use] pub fn get_extent(&self) -> &Extent { &self.extent } @@ -56,6 +58,7 @@ impl OneCellAnchor { } #[inline] + #[must_use] pub fn get_group_shape(&self) -> Option<&GroupShape> { self.group_shape.as_deref() } @@ -72,6 +75,7 @@ impl OneCellAnchor { } #[inline] + #[must_use] pub fn get_shape(&self) -> Option<&Shape> { self.shape.as_deref() } @@ -88,6 +92,7 @@ impl OneCellAnchor { } #[inline] + #[must_use] pub fn get_picture(&self) -> Option<&Picture> { self.picture.as_deref() } diff --git a/src/structs/drawing/spreadsheet/picture.rs b/src/structs/drawing/spreadsheet/picture.rs index 1be14a15..b67c3a3f 100644 --- a/src/structs/drawing/spreadsheet/picture.rs +++ b/src/structs/drawing/spreadsheet/picture.rs @@ -2,9 +2,9 @@ use super::BlipFill; use super::NonVisualPictureProperties; use super::ShapeProperties; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct Picture { impl Picture { #[inline] + #[must_use] pub fn get_non_visual_picture_properties(&self) -> &NonVisualPictureProperties { &self.non_visual_picture_properties } @@ -34,6 +35,7 @@ impl Picture { } #[inline] + #[must_use] pub fn get_blip_fill(&self) -> &BlipFill { &self.blip_fill } @@ -49,6 +51,7 @@ impl Picture { } #[inline] + #[must_use] pub fn get_shape_properties(&self) -> &ShapeProperties { &self.shape_properties } diff --git a/src/structs/drawing/spreadsheet/shape.rs b/src/structs/drawing/spreadsheet/shape.rs index 7470af76..68fb3e29 100644 --- a/src/structs/drawing/spreadsheet/shape.rs +++ b/src/structs/drawing/spreadsheet/shape.rs @@ -4,9 +4,9 @@ use super::NonVisualShapeProperties; use super::ShapeProperties; use super::ShapeStyle; use super::TextBody; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -23,6 +23,7 @@ pub struct Shape { impl Shape { #[inline] + #[must_use] pub fn get_anchor(&self) -> &Anchor { &self.anchor } @@ -38,6 +39,7 @@ impl Shape { } #[inline] + #[must_use] pub fn get_non_visual_shape_properties(&self) -> &NonVisualShapeProperties { &self.non_visual_shape_properties } @@ -52,6 +54,7 @@ impl Shape { } #[inline] + #[must_use] pub fn get_shape_properties(&self) -> &ShapeProperties { &self.shape_properties } @@ -66,6 +69,7 @@ impl Shape { self.shape_properties = value; } + #[must_use] pub fn get_shape_style(&self) -> Option<&ShapeStyle> { self.shape_style.as_deref() } @@ -81,6 +85,7 @@ impl Shape { } #[inline] + #[must_use] pub fn get_text_body(&self) -> Option<&TextBody> { self.text_body.as_deref() } diff --git a/src/structs/drawing/spreadsheet/shape_properties.rs b/src/structs/drawing/spreadsheet/shape_properties.rs index 7a380d7c..edbb8caa 100644 --- a/src/structs/drawing/spreadsheet/shape_properties.rs +++ b/src/structs/drawing/spreadsheet/shape_properties.rs @@ -7,9 +7,9 @@ use super::super::Outline; use super::super::PresetGeometry; use super::super::SolidFill; use super::super::Transform2D; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -28,6 +28,7 @@ pub struct ShapeProperties { } impl ShapeProperties { #[inline] + #[must_use] pub fn get_transform2d(&self) -> Option<&Transform2D> { self.transform2d.as_deref() } @@ -44,6 +45,7 @@ impl ShapeProperties { } #[inline] + #[must_use] pub fn get_geometry(&self) -> &PresetGeometry { &self.preset_geometry } @@ -60,6 +62,7 @@ impl ShapeProperties { } #[inline] + #[must_use] pub fn get_blip_fill(&self) -> Option<&BlipFill> { self.blip_fill.as_deref() } @@ -76,6 +79,7 @@ impl ShapeProperties { } #[inline] + #[must_use] pub fn get_solid_fill(&self) -> Option<&SolidFill> { self.solid_fill.as_deref() } @@ -92,6 +96,7 @@ impl ShapeProperties { } #[inline] + #[must_use] pub fn get_outline(&self) -> Option<&Outline> { self.outline.as_deref() } @@ -108,6 +113,7 @@ impl ShapeProperties { } #[inline] + #[must_use] pub fn get_effect_list(&self) -> Option<&EffectList> { self.effect_list.as_deref() } @@ -124,6 +130,7 @@ impl ShapeProperties { } #[inline] + #[must_use] pub fn get_no_fill(&self) -> Option<&NoFill> { self.no_fill.as_ref() } @@ -140,6 +147,7 @@ impl ShapeProperties { } #[inline] + #[must_use] pub fn get_extension_list(&self) -> Option<&ExtensionList> { self.extension_list.as_ref() } diff --git a/src/structs/drawing/spreadsheet/shape_style.rs b/src/structs/drawing/spreadsheet/shape_style.rs index 26aac113..ee979351 100644 --- a/src/structs/drawing/spreadsheet/shape_style.rs +++ b/src/structs/drawing/spreadsheet/shape_style.rs @@ -1,7 +1,7 @@ // xdr:style use super::super::StyleMatrixReferenceType; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct ShapeStyle { impl ShapeStyle { #[inline] + #[must_use] pub fn get_line_reference(&self) -> Option<&StyleMatrixReferenceType> { self.line_reference.as_deref() } @@ -27,6 +28,7 @@ impl ShapeStyle { } #[inline] + #[must_use] pub fn get_fill_reference(&self) -> Option<&StyleMatrixReferenceType> { self.fill_reference.as_deref() } @@ -37,6 +39,7 @@ impl ShapeStyle { } #[inline] + #[must_use] pub fn get_effect_reference(&self) -> Option<&StyleMatrixReferenceType> { self.effect_reference.as_deref() } @@ -47,6 +50,7 @@ impl ShapeStyle { } #[inline] + #[must_use] pub fn get_font_reference(&self) -> Option<&StyleMatrixReferenceType> { self.font_reference.as_deref() } diff --git a/src/structs/drawing/spreadsheet/text_body.rs b/src/structs/drawing/spreadsheet/text_body.rs index 869d7609..a23a1cdb 100644 --- a/src/structs/drawing/spreadsheet/text_body.rs +++ b/src/structs/drawing/spreadsheet/text_body.rs @@ -1,8 +1,8 @@ use super::super::BodyProperties; use super::super::ListStyle; use super::super::Paragraph; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct TextBody { impl TextBody { #[inline] + #[must_use] pub fn get_body_properties(&self) -> &BodyProperties { &self.body_properties } @@ -33,6 +34,7 @@ impl TextBody { } #[inline] + #[must_use] pub fn get_list_style(&self) -> &ListStyle { &self.list_style } @@ -48,6 +50,7 @@ impl TextBody { } #[inline] + #[must_use] pub fn get_paragraph(&self) -> &[Paragraph] { &self.paragraph } diff --git a/src/structs/drawing/spreadsheet/transform.rs b/src/structs/drawing/spreadsheet/transform.rs index 35f9368e..e0ca2822 100644 --- a/src/structs/drawing/spreadsheet/transform.rs +++ b/src/structs/drawing/spreadsheet/transform.rs @@ -1,7 +1,7 @@ // xdr:xfrm use super::super::{Extents, Offset}; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::{BooleanValue, Int32Value}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -19,6 +19,7 @@ pub struct Transform { impl Transform { #[inline] + #[must_use] pub fn get_offset(&self) -> &Offset { &self.offset } @@ -35,6 +36,7 @@ impl Transform { } #[inline] + #[must_use] pub fn get_extents(&self) -> &Extents { &self.extents } @@ -51,6 +53,7 @@ impl Transform { } #[inline] + #[must_use] pub fn get_rotation(&self) -> i32 { self.rotation.get_value() } @@ -61,6 +64,7 @@ impl Transform { } #[inline] + #[must_use] pub fn get_vertical_flip(&self) -> bool { self.vertical_flip.get_value() } @@ -71,6 +75,7 @@ impl Transform { } #[inline] + #[must_use] pub fn get_horizontal_flip(&self) -> bool { self.horizontal_flip.get_value() } diff --git a/src/structs/drawing/spreadsheet/two_cell_anchor.rs b/src/structs/drawing/spreadsheet/two_cell_anchor.rs index eedaaf21..c8c758c0 100644 --- a/src/structs/drawing/spreadsheet/two_cell_anchor.rs +++ b/src/structs/drawing/spreadsheet/two_cell_anchor.rs @@ -7,14 +7,14 @@ use super::GroupShape; use super::MarkerType; use super::Picture; use super::Shape; +use crate::helper::const_str::DRAWING_MAIN_NS; use crate::helper::const_str::MC_NS; -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::raw::RawRelationships; use crate::structs::BooleanValue; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -35,6 +35,7 @@ pub struct TwoCellAnchor { impl TwoCellAnchor { #[inline] + #[must_use] pub fn get_edit_as(&self) -> &EditAsValues { self.edit_as.get_value() } @@ -46,6 +47,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_from_marker(&self) -> &MarkerType { &self.from_marker } @@ -62,6 +64,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_to_marker(&self) -> &MarkerType { &self.to_marker } @@ -78,6 +81,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_group_shape(&self) -> Option<&GroupShape> { self.group_shape.as_deref() } @@ -94,6 +98,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_graphic_frame(&self) -> Option<&GraphicFrame> { self.graphic_frame.as_deref() } @@ -110,6 +115,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_shape(&self) -> Option<&Shape> { self.shape.as_deref() } @@ -126,6 +132,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_connection_shape(&self) -> Option<&ConnectionShape> { self.connection_shape.as_deref() } @@ -142,6 +149,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_picture(&self) -> Option<&Picture> { self.picture.as_deref() } @@ -158,6 +166,7 @@ impl TwoCellAnchor { } #[inline] + #[must_use] pub fn get_is_alternate_content(&self) -> bool { self.is_alternate_content.get_value() } @@ -170,7 +179,7 @@ impl TwoCellAnchor { #[inline] pub(crate) fn is_support(&self) -> bool { - self.graphic_frame.as_ref().map_or(true, |v| { + self.graphic_frame.as_ref().is_none_or(|v| { v.get_graphic() .get_graphic_data() .get_chart_space() @@ -299,7 +308,7 @@ impl TwoCellAnchor { // xdr:cxnSp if let Some(v) = &self.connection_shape { - v.write_to(writer, rel_list) + v.write_to(writer, rel_list); } // xdr:pic diff --git a/src/structs/drawing/spreadsheet/worksheet_drawing.rs b/src/structs/drawing/spreadsheet/worksheet_drawing.rs index 0d75e0d1..7d0ef6c3 100644 --- a/src/structs/drawing/spreadsheet/worksheet_drawing.rs +++ b/src/structs/drawing/spreadsheet/worksheet_drawing.rs @@ -5,15 +5,15 @@ use super::OneCellAnchor; use super::Picture; use super::Shape; use super::TwoCellAnchor; -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{DRAWINGML_MAIN_NS, SHEET_DRAWING_NS}; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; use crate::structs::Chart; use crate::structs::Image; use crate::structs::OleObjects; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWithSheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -30,6 +30,7 @@ pub struct WorksheetDrawing { impl WorksheetDrawing { #[inline] + #[must_use] pub fn get_image_collection(&self) -> &[Image] { &self.image_collection } @@ -46,6 +47,7 @@ impl WorksheetDrawing { } #[inline] + #[must_use] pub fn get_image(&self, col: u32, row: u32) -> Option<&Image> { self.image_collection .iter() @@ -59,6 +61,7 @@ impl WorksheetDrawing { .find(|image| image.get_col() == col - 1 && image.get_row() == row - 1) } + #[must_use] pub fn get_images(&self, col: u32, row: u32) -> Vec<&Image> { let mut result: Vec<&Image> = Vec::new(); for image in &self.image_collection { @@ -80,6 +83,7 @@ impl WorksheetDrawing { } #[inline] + #[must_use] pub fn get_chart_collection(&self) -> &[Chart] { &self.chart_collection } @@ -96,6 +100,7 @@ impl WorksheetDrawing { } #[inline] + #[must_use] pub fn get_chart(&self, col: u32, row: u32) -> Option<&Chart> { self.chart_collection .iter() @@ -109,6 +114,7 @@ impl WorksheetDrawing { .find(|chart| chart.get_col() == col - 1 && chart.get_row() == row - 1) } + #[must_use] pub fn get_charts(&self, col: u32, row: u32) -> Vec<&Chart> { let mut result: Vec<&Chart> = Vec::new(); for chart in &self.chart_collection { @@ -130,6 +136,7 @@ impl WorksheetDrawing { } #[inline] + #[must_use] pub fn get_one_cell_anchor_collection(&self) -> &[OneCellAnchor] { &self.one_cell_anchor_collection } @@ -146,6 +153,7 @@ impl WorksheetDrawing { } #[inline] + #[must_use] pub fn get_two_cell_anchor_collection(&self) -> &[TwoCellAnchor] { &self.two_cell_anchor_collection } @@ -162,6 +170,7 @@ impl WorksheetDrawing { } #[inline] + #[must_use] pub fn has_drawing_object(&self) -> bool { !self.chart_collection.is_empty() || !self.image_collection.is_empty() @@ -169,6 +178,7 @@ impl WorksheetDrawing { || !self.two_cell_anchor_collection.is_empty() } + #[must_use] pub fn get_graphic_frame_collection(&self) -> Vec<&GraphicFrame> { let mut result: Vec<&GraphicFrame> = Vec::new(); for two_cell_anchor in &self.two_cell_anchor_collection { @@ -189,6 +199,7 @@ impl WorksheetDrawing { result } + #[must_use] pub fn get_shape_collection(&self) -> Vec<&Shape> { let mut result: Vec<&Shape> = Vec::new(); for two_cell_anchor in &self.two_cell_anchor_collection { @@ -209,6 +220,7 @@ impl WorksheetDrawing { result } + #[must_use] pub fn get_connection_shape_collection(&self) -> Vec<&ConnectionShape> { let mut result: Vec<&ConnectionShape> = Vec::new(); for two_cell_anchor in &self.two_cell_anchor_collection { @@ -229,6 +241,7 @@ impl WorksheetDrawing { result } + #[must_use] pub fn get_picture_collection(&self) -> Vec<&Picture> { let mut result: Vec<&Picture> = Vec::new(); for two_cell_anchor in &self.two_cell_anchor_collection { diff --git a/src/structs/drawing/start_connection.rs b/src/structs/drawing/start_connection.rs index 6bcbc12b..295ab319 100644 --- a/src/structs/drawing/start_connection.rs +++ b/src/structs/drawing/start_connection.rs @@ -1,7 +1,7 @@ // a:stCxn use super::super::super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct StartConnection { } impl StartConnection { #[inline] + #[must_use] pub fn get_id(&self) -> u32 { self.id.get_value() } @@ -24,6 +25,7 @@ impl StartConnection { } #[inline] + #[must_use] pub fn get_index(&self) -> u32 { self.index.get_value() } diff --git a/src/structs/drawing/stretch.rs b/src/structs/drawing/stretch.rs index 7749f352..69380efb 100644 --- a/src/structs/drawing/stretch.rs +++ b/src/structs/drawing/stretch.rs @@ -1,7 +1,7 @@ // a:stretch use super::fill_rectangle::FillRectangle; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Stretch { impl Stretch { #[inline] + #[must_use] pub fn get_fill_rectangle(&self) -> Option<&FillRectangle> { self.fill_rectangle.as_deref() } diff --git a/src/structs/drawing/style_matrix_reference_type.rs b/src/structs/drawing/style_matrix_reference_type.rs index d5d6d708..22c596a1 100644 --- a/src/structs/drawing/style_matrix_reference_type.rs +++ b/src/structs/drawing/style_matrix_reference_type.rs @@ -1,7 +1,7 @@ // a:lnRef use super::SchemeColor; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct StyleMatrixReferenceType { impl StyleMatrixReferenceType { #[inline] + #[must_use] pub fn get_index(&self) -> &str { &self.index } @@ -25,6 +26,7 @@ impl StyleMatrixReferenceType { } #[inline] + #[must_use] pub fn get_scheme_color(&self) -> Option<&SchemeColor> { self.scheme_color.as_deref() } diff --git a/src/structs/drawing/supplemental_font.rs b/src/structs/drawing/supplemental_font.rs index 08540108..64e56f5d 100644 --- a/src/structs/drawing/supplemental_font.rs +++ b/src/structs/drawing/supplemental_font.rs @@ -1,7 +1,7 @@ // a:font -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct SupplementalFont { impl SupplementalFont { #[inline] + #[must_use] pub fn get_script(&self) -> &str { self.script.get_value_str() } @@ -26,6 +27,7 @@ impl SupplementalFont { } #[inline] + #[must_use] pub fn get_typeface(&self) -> &str { self.typeface.get_value_str() } diff --git a/src/structs/drawing/system_color.rs b/src/structs/drawing/system_color.rs index aee072f7..eeb69ddc 100644 --- a/src/structs/drawing/system_color.rs +++ b/src/structs/drawing/system_color.rs @@ -2,8 +2,8 @@ use super::super::super::EnumValue; use super::super::super::StringValue; use super::SystemColorValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct SystemColor { impl SystemColor { #[inline] + #[must_use] pub fn get_val(&self) -> &SystemColorValues { self.val.get_value() } @@ -28,6 +29,7 @@ impl SystemColor { } #[inline] + #[must_use] pub fn get_last_color(&self) -> &str { self.last_color.get_value_str() } diff --git a/src/structs/drawing/tail_end.rs b/src/structs/drawing/tail_end.rs index c2aae488..019e106f 100644 --- a/src/structs/drawing/tail_end.rs +++ b/src/structs/drawing/tail_end.rs @@ -1,7 +1,7 @@ // a:tailEnd -use crate::reader::driver::*; +use crate::reader::driver::get_attribute; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct TailEnd { impl TailEnd { #[inline] + #[must_use] pub fn get_type(&self) -> &str { self.t_type.get_value_str() } @@ -26,6 +27,7 @@ impl TailEnd { } #[inline] + #[must_use] pub fn get_width(&self) -> &str { self.width.get_value_str() } @@ -36,6 +38,7 @@ impl TailEnd { } #[inline] + #[must_use] pub fn get_length(&self) -> &str { self.length.get_value_str() } diff --git a/src/structs/drawing/text_font_type.rs b/src/structs/drawing/text_font_type.rs index 35f95086..1643ad67 100644 --- a/src/structs/drawing/text_font_type.rs +++ b/src/structs/drawing/text_font_type.rs @@ -1,6 +1,6 @@ use super::super::StringValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct TextFontType { impl TextFontType { #[inline] + #[must_use] pub fn get_typeface(&self) -> &str { self.typeface.get_value_str() } @@ -27,6 +28,7 @@ impl TextFontType { } #[inline] + #[must_use] pub fn get_pitch_family(&self) -> &str { self.pitch_family.get_value_str() } @@ -38,6 +40,7 @@ impl TextFontType { } #[inline] + #[must_use] pub fn get_charset(&self) -> &str { self.charset.get_value_str() } @@ -49,6 +52,7 @@ impl TextFontType { } #[inline] + #[must_use] pub fn get_panose(&self) -> &str { self.panose.get_value_str() } diff --git a/src/structs/drawing/text_paragraph_properties_type.rs b/src/structs/drawing/text_paragraph_properties_type.rs index b87a2789..33295b36 100644 --- a/src/structs/drawing/text_paragraph_properties_type.rs +++ b/src/structs/drawing/text_paragraph_properties_type.rs @@ -6,8 +6,8 @@ use super::SpaceAfter; use super::SpaceBefore; use super::TextAlignmentTypeValues; use super::TextFontAlignmentValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct TextParagraphPropertiesType { } impl TextParagraphPropertiesType { #[inline] + #[must_use] pub fn get_right_to_left(&self) -> bool { self.right_to_left.get_value() } @@ -35,6 +36,7 @@ impl TextParagraphPropertiesType { } #[inline] + #[must_use] pub fn get_alignment(&self) -> &TextAlignmentTypeValues { self.alignment.get_value() } @@ -46,6 +48,7 @@ impl TextParagraphPropertiesType { } #[inline] + #[must_use] pub fn get_font_alignment(&self) -> &TextFontAlignmentValues { self.font_alignment.get_value() } @@ -57,6 +60,7 @@ impl TextParagraphPropertiesType { } #[inline] + #[must_use] pub fn get_space_before(&self) -> Option<&SpaceBefore> { self.space_before.as_ref() } @@ -73,6 +77,7 @@ impl TextParagraphPropertiesType { } #[inline] + #[must_use] pub fn get_space_after(&self) -> Option<&SpaceAfter> { self.space_after.as_ref() } @@ -89,6 +94,7 @@ impl TextParagraphPropertiesType { } #[inline] + #[must_use] pub fn get_default_run_properties(&self) -> Option<&RunProperties> { self.default_run_properties.as_deref() } @@ -163,52 +169,52 @@ impl TextParagraphPropertiesType { #[inline] pub(crate) fn write_to_default(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:defPPr") + self.write_to(writer, "a:defPPr"); } #[inline] pub(crate) fn write_to_lvl1(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl1pPr") + self.write_to(writer, "a:lvl1pPr"); } #[inline] pub(crate) fn write_to_lvl2(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl2pPr") + self.write_to(writer, "a:lvl2pPr"); } #[inline] pub(crate) fn write_to_lvl3(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl3pPr") + self.write_to(writer, "a:lvl3pPr"); } #[inline] pub(crate) fn write_to_lvl4(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl4pPr") + self.write_to(writer, "a:lvl4pPr"); } #[inline] pub(crate) fn write_to_lvl5(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl5pPr") + self.write_to(writer, "a:lvl5pPr"); } #[inline] pub(crate) fn write_to_lvl6(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl6pPr") + self.write_to(writer, "a:lvl6pPr"); } #[inline] pub(crate) fn write_to_lvl7(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl7pPr") + self.write_to(writer, "a:lvl7pPr"); } #[inline] pub(crate) fn write_to_lvl8(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl8pPr") + self.write_to(writer, "a:lvl8pPr"); } #[inline] pub(crate) fn write_to_lvl9(&self, writer: &mut Writer>>) { - self.write_to(writer, "a:lvl9pPr") + self.write_to(writer, "a:lvl9pPr"); } fn write_to(&self, writer: &mut Writer>>, tag_name: &str) { diff --git a/src/structs/drawing/theme.rs b/src/structs/drawing/theme.rs index 22ec1613..8d924377 100644 --- a/src/structs/drawing/theme.rs +++ b/src/structs/drawing/theme.rs @@ -19,9 +19,9 @@ use super::SolidFill; use super::SystemColor; use super::SystemColorValues; use super::ThemeElements; -use crate::helper::const_str::*; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::helper::const_str::DRAWINGML_MAIN_NS; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -35,6 +35,7 @@ pub struct Theme { impl Theme { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -46,6 +47,7 @@ impl Theme { } #[inline] + #[must_use] pub fn get_theme_elements(&self) -> &ThemeElements { &self.theme_elements } diff --git a/src/structs/drawing/theme_elements.rs b/src/structs/drawing/theme_elements.rs index 304c21d7..374cdd4b 100644 --- a/src/structs/drawing/theme_elements.rs +++ b/src/structs/drawing/theme_elements.rs @@ -2,8 +2,8 @@ use super::ColorScheme; use super::FontScheme; use super::FormatScheme; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -23,6 +23,7 @@ impl ThemeElements { } #[inline] + #[must_use] pub fn get_color_scheme(&self) -> &ColorScheme { &self.color_scheme } @@ -38,6 +39,7 @@ impl ThemeElements { } #[inline] + #[must_use] pub fn get_font_scheme(&self) -> &FontScheme { &self.font_scheme } @@ -53,6 +55,7 @@ impl ThemeElements { } #[inline] + #[must_use] pub fn get_format_scheme(&self) -> &FormatScheme { &self.format_scheme } diff --git a/src/structs/drawing/tile_rectangle.rs b/src/structs/drawing/tile_rectangle.rs index 53215b39..c9052f55 100644 --- a/src/structs/drawing/tile_rectangle.rs +++ b/src/structs/drawing/tile_rectangle.rs @@ -1,5 +1,5 @@ // a:tileRect -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/drawing/transform2d.rs b/src/structs/drawing/transform2d.rs index f331b5a8..6b344bff 100644 --- a/src/structs/drawing/transform2d.rs +++ b/src/structs/drawing/transform2d.rs @@ -1,8 +1,8 @@ // a:xfrm -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; use crate::structs::drawing::Point2DType; use crate::structs::drawing::PositiveSize2DType; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use crate::StringValue; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -22,6 +22,7 @@ pub struct Transform2D { impl Transform2D { #[inline] + #[must_use] pub fn get_offset(&self) -> &Point2DType { &self.offset } @@ -37,6 +38,7 @@ impl Transform2D { } #[inline] + #[must_use] pub fn get_extents(&self) -> &PositiveSize2DType { &self.extents } @@ -52,6 +54,7 @@ impl Transform2D { } #[inline] + #[must_use] pub fn get_child_offset(&self) -> Option<&Point2DType> { self.child_offset.as_deref() } @@ -67,6 +70,7 @@ impl Transform2D { } #[inline] + #[must_use] pub fn get_child_extents(&self) -> Option<&PositiveSize2DType> { self.child_extents.as_deref() } @@ -82,6 +86,7 @@ impl Transform2D { } #[inline] + #[must_use] pub fn get_rot(&self) -> Option<&str> { self.rot.get_value() } @@ -92,6 +97,7 @@ impl Transform2D { } #[inline] + #[must_use] pub fn get_flip_v(&self) -> Option<&str> { self.flip_v.get_value() } @@ -102,6 +108,7 @@ impl Transform2D { } #[inline] + #[must_use] pub fn get_flip_h(&self) -> Option<&str> { self.flip_h.get_value() } @@ -164,13 +171,13 @@ impl Transform2D { // a:xfrm let mut attributes: Vec<(&str, &str)> = Vec::new(); if let Some(v) = self.rot.get_value() { - attributes.push(("rot", v)) + attributes.push(("rot", v)); } if let Some(v) = self.flip_h.get_value() { - attributes.push(("flipH", v)) + attributes.push(("flipH", v)); } if let Some(v) = self.flip_v.get_value() { - attributes.push(("flipV", v)) + attributes.push(("flipV", v)); } write_start_tag(writer, "a:xfrm", attributes, false); diff --git a/src/structs/embedded_object_properties.rs b/src/structs/embedded_object_properties.rs index 5545c8b5..cba3b951 100644 --- a/src/structs/embedded_object_properties.rs +++ b/src/structs/embedded_object_properties.rs @@ -2,10 +2,10 @@ use super::BooleanValue; use super::ObjectAnchor; use super::StringValue; use super::UInt32Value; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::raw::RawRelationships; use crate::structs::MediaObject; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -23,6 +23,7 @@ pub struct EmbeddedObjectProperties { impl EmbeddedObjectProperties { #[inline] + #[must_use] pub fn get_prog_id(&self) -> &str { self.prog_id.get_value_str() } @@ -34,6 +35,7 @@ impl EmbeddedObjectProperties { } #[inline] + #[must_use] pub fn get_shape_id(&self) -> u32 { self.shape_id.get_value() } @@ -45,6 +47,7 @@ impl EmbeddedObjectProperties { } #[inline] + #[must_use] pub fn get_image(&self) -> &MediaObject { &self.image } @@ -60,6 +63,7 @@ impl EmbeddedObjectProperties { } #[inline] + #[must_use] pub fn get_default_size(&self) -> bool { self.default_size.get_value() } @@ -71,6 +75,7 @@ impl EmbeddedObjectProperties { } #[inline] + #[must_use] pub fn get_auto_pict(&self) -> bool { self.auto_pict.get_value() } @@ -82,6 +87,7 @@ impl EmbeddedObjectProperties { } #[inline] + #[must_use] pub fn get_object_anchor(&self) -> &ObjectAnchor { &self.object_anchor } @@ -139,7 +145,7 @@ impl EmbeddedObjectProperties { if self.auto_pict.has_value() { attributes.push(("autoPict", self.auto_pict.get_value_string())); } - let r_id_str = format!("rId{}", r_id); + let r_id_str = format!("rId{r_id}"); attributes.push(("r:id", r_id_str.as_str())); write_start_tag(writer, "objectPr", attributes, false); diff --git a/src/structs/error.rs b/src/structs/error.rs index dbf3c8af..24656754 100644 --- a/src/structs/error.rs +++ b/src/structs/error.rs @@ -80,12 +80,12 @@ from_err!(std::string::FromUtf8Error, XlsxError, Uft8); impl fmt::Display for XlsxError { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use self::XlsxError::*; + use self::XlsxError::{CellError, Io, Uft8, Xml, Zip}; match self { - Io(i) => write!(f, "IoError: {}", i), - Xml(s) => write!(f, "XmlError: {}", s), - Zip(s) => write!(f, "ZipError: {}", s), - Uft8(s) => write!(f, "Uft8Error: {}", s), + Io(i) => write!(f, "IoError: {i}"), + Xml(s) => write!(f, "XmlError: {s}"), + Zip(s) => write!(f, "ZipError: {s}"), + Uft8(s) => write!(f, "Uft8Error: {s}"), CellError(e) => write!(f, "Unsupported cell error value '{e}'"), } } diff --git a/src/structs/field.rs b/src/structs/field.rs index e489d5fa..422e4336 100644 --- a/src/structs/field.rs +++ b/src/structs/field.rs @@ -1,7 +1,7 @@ // field -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::Int32Value; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Field { x: Int32Value, } impl Field { + #[must_use] pub fn get_data_field(&self) -> i32 { self.x.get_value() } diff --git a/src/structs/fill.rs b/src/structs/fill.rs index 34207d59..200d4658 100644 --- a/src/structs/fill.rs +++ b/src/structs/fill.rs @@ -1,8 +1,8 @@ use super::GradientFill; use super::PatternFill; use super::PatternValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -17,6 +17,7 @@ pub struct Fill { impl Fill { #[inline] + #[must_use] pub fn get_pattern_fill(&self) -> Option<&PatternFill> { self.pattern_fill.as_deref() } @@ -38,6 +39,7 @@ impl Fill { } #[inline] + #[must_use] pub fn get_gradient_fill(&self) -> Option<&GradientFill> { self.gradient_fill.as_deref() } diff --git a/src/structs/fills.rs b/src/structs/fills.rs index e702c9e4..0cc29a0f 100644 --- a/src/structs/fills.rs +++ b/src/structs/fills.rs @@ -1,8 +1,8 @@ // fills use super::Fill; use super::Style; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/font.rs b/src/structs/font.rs index b3d22930..0725d9b2 100644 --- a/src/structs/font.rs +++ b/src/structs/font.rs @@ -12,7 +12,7 @@ use super::Strike; use super::Underline; use super::UnderlineValues; use super::VerticalTextAlignment; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -65,6 +65,7 @@ impl Font { pub const UNDERLINE_SINGLEACCOUNTING: &'static str = "singleAccounting"; #[inline] + #[must_use] pub fn get_font_name(&self) -> &FontName { &self.font_name } @@ -81,6 +82,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.font_name.get_val() } @@ -100,6 +102,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_size(&self) -> &FontSize { &self.font_size } @@ -116,6 +119,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_size(&self) -> f64 { self.font_size.get_val() } @@ -127,6 +131,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_family_numbering(&self) -> &FontFamilyNumbering { &self.font_family_numbering } @@ -143,6 +148,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_family(&self) -> i32 { self.font_family_numbering.get_val() } @@ -154,6 +160,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_bold(&self) -> &Bold { &self.font_bold } @@ -170,6 +177,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_bold(&self) -> bool { self.font_bold.get_val() } @@ -181,6 +189,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_italic(&self) -> &Italic { &self.font_italic } @@ -197,6 +206,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_italic(&self) -> bool { self.font_italic.get_val() } @@ -208,6 +218,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_underline(&self) -> &Underline { &self.font_underline } @@ -224,6 +235,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_underline(&self) -> &str { self.font_underline.val.get_value_string() } @@ -237,6 +249,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_strike(&self) -> &Strike { &self.font_strike } @@ -253,6 +266,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_strikethrough(&self) -> bool { self.font_strike.get_val() } @@ -264,6 +278,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_color(&self) -> &Color { &self.color } @@ -280,6 +295,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_char_set(&self) -> &FontCharSet { &self.font_char_set } @@ -296,6 +312,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_charset(&self) -> i32 { self.font_char_set.get_val() } @@ -307,6 +324,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_font_scheme(&self) -> &FontScheme { &self.font_scheme } @@ -323,6 +341,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_scheme(&self) -> &str { self.font_scheme.val.get_value_string() } @@ -336,6 +355,7 @@ impl Font { } #[inline] + #[must_use] pub fn get_vertical_text_alignment(&self) -> &VerticalTextAlignment { &self.vertical_text_alignment } diff --git a/src/structs/font_char_set.rs b/src/structs/font_char_set.rs index babab491..ff4ac9cd 100644 --- a/src/structs/font_char_set.rs +++ b/src/structs/font_char_set.rs @@ -1,7 +1,7 @@ // family use super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct FontCharSet { impl FontCharSet { #[inline] + #[must_use] pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/font_family_numbering.rs b/src/structs/font_family_numbering.rs index a62ec884..94ec5593 100644 --- a/src/structs/font_family_numbering.rs +++ b/src/structs/font_family_numbering.rs @@ -1,7 +1,7 @@ // family use super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct FontFamilyNumbering { impl FontFamilyNumbering { #[inline] + #[must_use] pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/font_name.rs b/src/structs/font_name.rs index 7e8e9ef0..b0e63474 100644 --- a/src/structs/font_name.rs +++ b/src/structs/font_name.rs @@ -1,7 +1,7 @@ // name use super::StringValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct FontName { impl FontName { #[inline] + #[must_use] pub fn get_val(&self) -> &str { self.val.get_value_str() } diff --git a/src/structs/font_scheme.rs b/src/structs/font_scheme.rs index 66449546..1ffcab66 100644 --- a/src/structs/font_scheme.rs +++ b/src/structs/font_scheme.rs @@ -1,8 +1,8 @@ // scheme use super::EnumValue; use super::FontSchemeValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct FontScheme { impl FontScheme { #[inline] + #[must_use] pub fn get_val(&self) -> &FontSchemeValues { self.val.get_value() } diff --git a/src/structs/font_size.rs b/src/structs/font_size.rs index 699ffec7..52638d83 100644 --- a/src/structs/font_size.rs +++ b/src/structs/font_size.rs @@ -1,7 +1,7 @@ // sz use super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct FontSize { impl FontSize { #[inline] + #[must_use] pub fn get_val(&self) -> f64 { self.val.get_value() } diff --git a/src/structs/fonts.rs b/src/structs/fonts.rs index 3d0f90b2..921462f5 100644 --- a/src/structs/fonts.rs +++ b/src/structs/fonts.rs @@ -1,8 +1,8 @@ // fronts -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Font; use crate::structs::Style; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/formula.rs b/src/structs/formula.rs index 1c81137d..222c5de2 100644 --- a/src/structs/formula.rs +++ b/src/structs/formula.rs @@ -1,9 +1,9 @@ // formula use super::Address; use super::StringValue; -use crate::helper::address::*; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::helper::address::is_address; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct Formula { impl Formula { #[inline] + #[must_use] pub fn get_address(&self) -> &Address { &self.address } @@ -27,6 +28,7 @@ impl Formula { } #[inline] + #[must_use] pub fn get_address_str(&self) -> String { if self.string_value.has_value() { return self.string_value.get_value_str().to_string(); diff --git a/src/structs/from_marker.rs b/src/structs/from_marker.rs index 4323c042..cee1ed0b 100644 --- a/src/structs/from_marker.rs +++ b/src/structs/from_marker.rs @@ -1,6 +1,6 @@ // from -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct FromMarker { impl FromMarker { #[inline] + #[must_use] pub fn get_col(&self) -> usize { self.col } @@ -27,6 +28,7 @@ impl FromMarker { } #[inline] + #[must_use] pub fn get_col_off(&self) -> usize { self.col_off } @@ -38,6 +40,7 @@ impl FromMarker { } #[inline] + #[must_use] pub fn get_row(&self) -> usize { self.row } @@ -49,6 +52,7 @@ impl FromMarker { } #[inline] + #[must_use] pub fn get_row_off(&self) -> usize { self.row_off } @@ -92,7 +96,7 @@ impl FromMarker { reader: &mut Reader, _e: &BytesStart, ) { - let mut string_value: String = String::from(""); + let mut string_value: String = String::new(); xml_read_loop!( reader, Event::Text(e) => string_value = e.unescape().unwrap().to_string(), diff --git a/src/structs/gradient_fill.rs b/src/structs/gradient_fill.rs index 05199af0..0beabdf7 100644 --- a/src/structs/gradient_fill.rs +++ b/src/structs/gradient_fill.rs @@ -1,8 +1,8 @@ // gradientFill use super::DoubleValue; use super::GradientStop; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -19,6 +19,7 @@ pub struct GradientFill { impl GradientFill { #[inline] + #[must_use] pub fn get_degree(&self) -> f64 { self.degree.get_value() } @@ -30,6 +31,7 @@ impl GradientFill { } #[inline] + #[must_use] pub fn get_gradient_stop(&self) -> &[GradientStop] { &self.gradient_stop } @@ -46,7 +48,7 @@ impl GradientFill { } pub(crate) fn get_hash_code(&self) -> String { - let mut value = String::from(""); + let mut value = String::new(); for stop in &self.gradient_stop { write!(value, "{}", stop.get_hash_code().as_str()).unwrap(); } diff --git a/src/structs/gradient_stop.rs b/src/structs/gradient_stop.rs index 7be5e6fb..e844d769 100644 --- a/src/structs/gradient_stop.rs +++ b/src/structs/gradient_stop.rs @@ -1,8 +1,8 @@ // stop use super::Color; use super::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -17,6 +17,7 @@ pub struct GradientStop { impl GradientStop { #[inline] + #[must_use] pub fn get_position(&self) -> f64 { self.position.get_value() } @@ -28,6 +29,7 @@ impl GradientStop { } #[inline] + #[must_use] pub fn get_color(&self) -> &Color { &self.color } diff --git a/src/structs/header_footer.rs b/src/structs/header_footer.rs index f223091a..5e206c03 100644 --- a/src/structs/header_footer.rs +++ b/src/structs/header_footer.rs @@ -1,8 +1,8 @@ // headerFooter -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::OddFooter; use crate::structs::OddHeader; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct HeaderFooter { impl HeaderFooter { #[inline] + #[must_use] pub fn get_odd_header(&self) -> &OddHeader { &self.odd_header } @@ -32,6 +33,7 @@ impl HeaderFooter { } #[inline] + #[must_use] pub fn get_odd_footer(&self) -> &OddFooter { &self.odd_footer } diff --git a/src/structs/hyperlink.rs b/src/structs/hyperlink.rs index b82051d6..d347c546 100644 --- a/src/structs/hyperlink.rs +++ b/src/structs/hyperlink.rs @@ -6,6 +6,7 @@ pub struct Hyperlink { } impl Hyperlink { #[inline] + #[must_use] pub fn get_url(&self) -> &str { &self.url } @@ -17,6 +18,7 @@ impl Hyperlink { } #[inline] + #[must_use] pub fn get_tooltip(&self) -> &str { &self.tooltip } @@ -28,6 +30,7 @@ impl Hyperlink { } #[inline] + #[must_use] pub fn get_location(&self) -> bool { self.location } diff --git a/src/structs/icon_set.rs b/src/structs/icon_set.rs index a636943e..f9325c43 100644 --- a/src/structs/icon_set.rs +++ b/src/structs/icon_set.rs @@ -1,7 +1,7 @@ use super::Color; use super::ConditionalFormatValueObject; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -17,6 +17,7 @@ pub struct IconSet { impl IconSet { #[inline] + #[must_use] pub fn get_cfvo_collection(&self) -> &[ConditionalFormatValueObject] { &self.cfvo_collection } @@ -37,6 +38,7 @@ impl IconSet { } #[inline] + #[must_use] pub fn get_color_collection(&self) -> &[Color] { &self.color_collection } diff --git a/src/structs/image.rs b/src/structs/image.rs index 7e3bbc66..7128de9b 100644 --- a/src/structs/image.rs +++ b/src/structs/image.rs @@ -66,6 +66,7 @@ pub struct Image { /// ``` impl Image { #[inline] + #[must_use] pub fn get_two_cell_anchor(&self) -> Option<&TwoCellAnchor> { self.two_cell_anchor.as_deref() } @@ -88,6 +89,7 @@ impl Image { } #[inline] + #[must_use] pub fn get_one_cell_anchor(&self) -> Option<&OneCellAnchor> { self.one_cell_anchor.as_deref() } @@ -120,7 +122,7 @@ impl Image { let file = File::open(path).unwrap(); BufReader::new(file).read_to_end(&mut buf).unwrap(); - self.new_image_with_dimensions(height, width, image_name, buf, marker) + self.new_image_with_dimensions(height, width, image_name, buf, marker); } pub fn new_image_with_dimensions>>( @@ -169,8 +171,10 @@ impl Image { one_cell_anchor.set_from_marker(marker); one_cell_anchor .get_extent_mut() - .set_cy(height as i64 * 9525); - one_cell_anchor.get_extent_mut().set_cx(width as i64 * 9525); + .set_cy(i64::from(height) * 9525); + one_cell_anchor + .get_extent_mut() + .set_cx(i64::from(width) * 9525); one_cell_anchor.set_picture(picture); self.set_one_cell_anchor(one_cell_anchor); } @@ -190,11 +194,13 @@ impl Image { } #[inline] + #[must_use] pub fn has_image(&self) -> bool { !self.get_media_object().is_empty() } #[inline] + #[must_use] pub fn get_image_name(&self) -> &str { match self.get_media_object().first() { Some(v) => v.get_image_name(), @@ -203,6 +209,7 @@ impl Image { } #[inline] + #[must_use] pub fn get_image_data(&self) -> &[u8] { match self.get_media_object().first() { Some(v) => v.get_image_data(), @@ -211,26 +218,31 @@ impl Image { } #[inline] + #[must_use] pub fn get_image_data_base64(&self) -> String { STANDARD.encode(self.get_image_data()) } #[inline] + #[must_use] pub fn get_coordinate(&self) -> String { self.get_from_marker_type().get_coordinate() } #[inline] + #[must_use] pub fn get_col(&self) -> u32 { self.get_from_marker_type().get_col() } #[inline] + #[must_use] pub fn get_row(&self) -> u32 { self.get_from_marker_type().get_row() } #[inline] + #[must_use] pub fn get_from_marker_type(&self) -> &MarkerType { if let Some(anchor) = self.get_two_cell_anchor() { return anchor.get_from_marker(); @@ -242,6 +254,7 @@ impl Image { } #[inline] + #[must_use] pub fn get_to_marker_type(&self) -> Option<&MarkerType> { self.get_two_cell_anchor() .as_ref() diff --git a/src/structs/italic.rs b/src/structs/italic.rs index 19ae4a6d..6d6e0315 100644 --- a/src/structs/italic.rs +++ b/src/structs/italic.rs @@ -1,7 +1,7 @@ // i use super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Italic { impl Italic { #[inline] + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/location.rs b/src/structs/location.rs index 666c2c2c..0d478434 100644 --- a/src/structs/location.rs +++ b/src/structs/location.rs @@ -1,7 +1,7 @@ use super::StringValue; use super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct Location { first_data_col: UInt32Value, } impl Location { + #[must_use] pub fn get_reference(&self) -> &str { self.reference.get_value_str() } @@ -24,6 +25,7 @@ impl Location { self } + #[must_use] pub fn get_first_header_row(&self) -> u32 { self.first_header_row.get_value() } @@ -33,6 +35,7 @@ impl Location { self } + #[must_use] pub fn get_first_data_row(&self) -> u32 { self.first_data_row.get_value() } @@ -42,6 +45,7 @@ impl Location { self } + #[must_use] pub fn get_first_data_col(&self) -> u32 { self.first_data_col.get_value() } diff --git a/src/structs/media_object.rs b/src/structs/media_object.rs index 9b06fb20..a048dc59 100644 --- a/src/structs/media_object.rs +++ b/src/structs/media_object.rs @@ -44,12 +44,11 @@ impl MediaObject { let find = rel_list .iter() .position(|(k, v)| k == "IMAGE" && v == &*self.image_name); - match find { - Some(v) => (v + 1) as i32, - None => { - rel_list.push((String::from("IMAGE"), self.image_name.to_string())); - rel_list.len() as i32 - } + if let Some(v) = find { + (v + 1) as i32 + } else { + rel_list.push((String::from("IMAGE"), self.image_name.to_string())); + rel_list.len() as i32 } } } diff --git a/src/structs/member_property_index.rs b/src/structs/member_property_index.rs index 2e10a692..af12bd86 100644 --- a/src/structs/member_property_index.rs +++ b/src/structs/member_property_index.rs @@ -1,7 +1,7 @@ // x use super::Int32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct MemberPropertyIndex { } impl MemberPropertyIndex { + #[must_use] pub fn get_val(&self) -> i32 { self.val.get_value() } diff --git a/src/structs/merge_cells.rs b/src/structs/merge_cells.rs index dc273528..a2821844 100644 --- a/src/structs/merge_cells.rs +++ b/src/structs/merge_cells.rs @@ -1,8 +1,8 @@ // mergeCell use super::Range; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -37,10 +37,10 @@ impl MergeCells { self.get_range_collection().iter().any(|range| { let start_num = range .get_coordinate_start_row() - .map_or(true, |v| v.get_num() <= row_num); + .is_none_or(|v| v.get_num() <= row_num); let end_num = range .get_coordinate_end_row() - .map_or(true, |v| v.get_num() >= row_num); + .is_none_or(|v| v.get_num() >= row_num); start_num && end_num && start_num != end_num }) } @@ -49,10 +49,10 @@ impl MergeCells { self.get_range_collection().iter().any(|range| { let start_num = range .get_coordinate_start_col() - .map_or(true, |v| v.get_num() <= col_num); + .is_none_or(|v| v.get_num() <= col_num); let end_num = range .get_coordinate_end_col() - .map_or(true, |v| v.get_num() >= col_num); + .is_none_or(|v| v.get_num() >= col_num); start_num && end_num && start_num != end_num }) } diff --git a/src/structs/mru_colors.rs b/src/structs/mru_colors.rs index cde74c5c..a297e7ce 100644 --- a/src/structs/mru_colors.rs +++ b/src/structs/mru_colors.rs @@ -1,7 +1,7 @@ // mruColors use super::Color; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/numbering_format.rs b/src/structs/numbering_format.rs index 6b1c276a..22dab0f5 100644 --- a/src/structs/numbering_format.rs +++ b/src/structs/numbering_format.rs @@ -1,5 +1,5 @@ -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use md5::Digest; use quick_xml::escape; use quick_xml::events::BytesStart; @@ -64,7 +64,7 @@ impl NumberingFormat { pub const FORMAT_DATE_YYYYMMDDSLASH: &'static str = "yyyy/mm/dd;@"; pub const FORMAT_CURRENCY_USD_SIMPLE: &'static str = r##""$"#,##0.00_-"##; - pub const FORMAT_CURRENCY_USD: &'static str = r###"$#,##0_-"###; + pub const FORMAT_CURRENCY_USD: &'static str = r"$#,##0_-"; pub const FORMAT_CURRENCY_EUR_SIMPLE: &'static str = r#"#,##0.00_-"€""#; pub const FORMAT_CURRENCY_EUR: &'static str = r#"#,##0_-"€""#; pub const FORMAT_ACCOUNTING_USD: &'static str = @@ -73,6 +73,7 @@ impl NumberingFormat { r#"_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)"#; #[inline] + #[must_use] pub fn get_number_format_id(&self) -> u32 { self.number_format_id } @@ -102,12 +103,12 @@ impl NumberingFormat { /// Set the format code. /// # Arguments - /// * `value` - format code. (umya_spreadsheet::NumberingFormat) + /// * `value` - format code. (`umya_spreadsheet::NumberingFormat`) /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); /// let mut worksheet = book.get_sheet_mut(0).unwrap(); - /// let _ = worksheet.get_style_mut("C30") + /// let _unused = worksheet.get_style_mut("C30") /// .get_number_format_mut() /// .set_format_code(umya_spreadsheet::NumberingFormat::FORMAT_DATE_XLSX17); /// ``` @@ -132,6 +133,7 @@ impl NumberingFormat { } #[inline] + #[must_use] pub fn get_format_code(&self) -> &str { &self.format_code } diff --git a/src/structs/numbering_formats.rs b/src/structs/numbering_formats.rs index 2ad99648..26f9f662 100644 --- a/src/structs/numbering_formats.rs +++ b/src/structs/numbering_formats.rs @@ -1,8 +1,8 @@ // numFmts use super::NumberingFormat; use super::Style; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -112,11 +112,9 @@ impl NumberingFormats { let cnt_str = cnt.to_string(); write_start_tag(writer, "numFmts", vec![("count", &cnt_str)], false); - formats_to_write - .into_iter() - .for_each(|(index, numbering_format)| { - numbering_format.write_to(writer, *index); - }); + for (index, numbering_format) in formats_to_write { + numbering_format.write_to(writer, *index); + } write_end_tag(writer, "numFmts"); } diff --git a/src/structs/object_anchor.rs b/src/structs/object_anchor.rs index 6b890cb9..5b482492 100644 --- a/src/structs/object_anchor.rs +++ b/src/structs/object_anchor.rs @@ -1,8 +1,8 @@ use super::BooleanValue; use super::FromMarker; use super::ToMarker; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -17,6 +17,7 @@ pub struct ObjectAnchor { impl ObjectAnchor { #[inline] + #[must_use] pub fn get_move_with_cells(&self) -> bool { self.move_with_cells.get_value() } @@ -28,6 +29,7 @@ impl ObjectAnchor { } #[inline] + #[must_use] pub fn get_from_marker(&self) -> &FromMarker { &self.from_marker } @@ -44,6 +46,7 @@ impl ObjectAnchor { } #[inline] + #[must_use] pub fn get_to_marker(&self) -> &ToMarker { &self.to_marker } diff --git a/src/structs/odd_footer.rs b/src/structs/odd_footer.rs index cf403e73..a91224bf 100644 --- a/src/structs/odd_footer.rs +++ b/src/structs/odd_footer.rs @@ -1,7 +1,7 @@ // oddFooter -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -15,6 +15,7 @@ pub struct OddFooter { impl OddFooter { #[inline] + #[must_use] pub fn get_value(&self) -> &str { self.value.get_value_str() } diff --git a/src/structs/odd_header.rs b/src/structs/odd_header.rs index acc455c3..2c0d632d 100644 --- a/src/structs/odd_header.rs +++ b/src/structs/odd_header.rs @@ -1,7 +1,7 @@ // oddHeader -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -15,6 +15,7 @@ pub struct OddHeader { impl OddHeader { #[inline] + #[must_use] pub fn get_value(&self) -> &str { self.value.get_value_str() } diff --git a/src/structs/office/excel/formula.rs b/src/structs/office/excel/formula.rs index 5659ac96..38c569bb 100644 --- a/src/structs/office/excel/formula.rs +++ b/src/structs/office/excel/formula.rs @@ -1,6 +1,6 @@ // xm:f use crate::structs::Address; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Formula { } impl Formula { #[inline] + #[must_use] pub fn get_value(&self) -> &Address { &self.value } @@ -33,7 +34,7 @@ impl Formula { reader: &mut Reader, _e: &BytesStart, ) { - let mut value: String = String::from(""); + let mut value: String = String::new(); let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf) { diff --git a/src/structs/office/excel/reference_sequence.rs b/src/structs/office/excel/reference_sequence.rs index 8e92e0e0..887b9c1c 100644 --- a/src/structs/office/excel/reference_sequence.rs +++ b/src/structs/office/excel/reference_sequence.rs @@ -1,6 +1,6 @@ // xm:sqref use crate::structs::Range; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct ReferenceSequence { } impl ReferenceSequence { #[inline] + #[must_use] pub fn get_value(&self) -> &[Range] { &self.value } @@ -51,10 +52,11 @@ impl ReferenceSequence { } #[inline] + #[must_use] pub fn get_sqref(&self) -> String { self.value .iter() - .map(|range| range.get_range()) + .map(Range::get_range) .collect::>() .join(" ") } @@ -64,7 +66,7 @@ impl ReferenceSequence { reader: &mut Reader, _e: &BytesStart, ) { - let mut value: String = String::from(""); + let mut value: String = String::new(); let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf) { diff --git a/src/structs/office2010/drawing/charts/style.rs b/src/structs/office2010/drawing/charts/style.rs index 40b643ac..ea328870 100644 --- a/src/structs/office2010/drawing/charts/style.rs +++ b/src/structs/office2010/drawing/charts/style.rs @@ -1,7 +1,7 @@ // c14:style -use crate::helper::const_str::*; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::helper::const_str::{DRAWING_CHART_NS, MC_NS}; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/office2010/excel/data_validation.rs b/src/structs/office2010/excel/data_validation.rs index e525bb29..c4ede1bf 100644 --- a/src/structs/office2010/excel/data_validation.rs +++ b/src/structs/office2010/excel/data_validation.rs @@ -1,5 +1,5 @@ // x14:dataValidation -use crate::reader::driver::*; +use crate::reader::driver::get_attribute; use crate::structs::office::excel::ReferenceSequence; use crate::structs::office2010::excel::DataValidationForumla1; use crate::structs::office2010::excel::DataValidationForumla2; @@ -8,7 +8,7 @@ use crate::structs::DataValidationOperatorValues; use crate::structs::DataValidationValues; use crate::structs::EnumValue; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -29,6 +29,7 @@ pub struct DataValidation { } impl DataValidation { #[inline] + #[must_use] pub fn get_type(&self) -> &DataValidationValues { self.r#type.get_value() } @@ -40,6 +41,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_operator(&self) -> &DataValidationOperatorValues { self.operator.get_value() } @@ -51,6 +53,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_allow_blank(&self) -> bool { self.allow_blank.get_value() } @@ -62,6 +65,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_show_input_message(&self) -> bool { self.show_input_message.get_value() } @@ -73,6 +77,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_show_error_message(&self) -> bool { self.show_error_message.get_value() } @@ -84,6 +89,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_prompt_title(&self) -> &str { self.prompt_title.get_value_str() } @@ -95,6 +101,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_prompt(&self) -> &str { self.prompt.get_value_str() } @@ -106,6 +113,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_reference_sequence(&self) -> &ReferenceSequence { &self.reference_sequence } @@ -122,6 +130,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_formula1(&self) -> Option<&DataValidationForumla1> { self.formula1.as_deref() } @@ -144,6 +153,7 @@ impl DataValidation { } #[inline] + #[must_use] pub fn get_formula2(&self) -> Option<&DataValidationForumla2> { self.formula2.as_deref() } @@ -279,10 +289,10 @@ impl DataValidation { write_start_tag(writer, "x14:dataValidation", attributes, false); if let Some(v) = &self.formula1 { - v.write_to(writer) + v.write_to(writer); } if let Some(v) = &self.formula2 { - v.write_to(writer) + v.write_to(writer); } self.reference_sequence.write_to(writer); write_end_tag(writer, "x14:dataValidation"); diff --git a/src/structs/office2010/excel/data_validation_forumla1.rs b/src/structs/office2010/excel/data_validation_forumla1.rs index d469f291..780fba61 100644 --- a/src/structs/office2010/excel/data_validation_forumla1.rs +++ b/src/structs/office2010/excel/data_validation_forumla1.rs @@ -1,6 +1,6 @@ // x14:formula1 use crate::structs::office::excel::Formula; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct DataValidationForumla1 { } impl DataValidationForumla1 { #[inline] + #[must_use] pub fn get_value(&self) -> &Formula { &self.value } diff --git a/src/structs/office2010/excel/data_validation_forumla2.rs b/src/structs/office2010/excel/data_validation_forumla2.rs index 42a6b629..f8bfdee4 100644 --- a/src/structs/office2010/excel/data_validation_forumla2.rs +++ b/src/structs/office2010/excel/data_validation_forumla2.rs @@ -1,6 +1,6 @@ // x14:formula2 use crate::structs::office::excel::Formula; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct DataValidationForumla2 { } impl DataValidationForumla2 { #[inline] + #[must_use] pub fn get_value(&self) -> &Formula { &self.value } diff --git a/src/structs/office2010/excel/data_validations.rs b/src/structs/office2010/excel/data_validations.rs index a81370ab..097c2cb1 100644 --- a/src/structs/office2010/excel/data_validations.rs +++ b/src/structs/office2010/excel/data_validations.rs @@ -1,8 +1,8 @@ // x14:dataValidations -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{EXCEL_MAIN_NS, SHEET_MS_MAIN_NS}; +use crate::reader::driver::xml_read_loop; use crate::structs::office2010::excel::DataValidation; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct DataValidations { impl DataValidations { #[inline] + #[must_use] pub fn get_data_validation_list(&self) -> &[DataValidation] { &self.data_validation_list } diff --git a/src/structs/ole_object.rs b/src/structs/ole_object.rs index 11c24dff..bd3fe873 100644 --- a/src/structs/ole_object.rs +++ b/src/structs/ole_object.rs @@ -1,11 +1,11 @@ use super::EmbeddedObjectProperties; use super::StringValue; use crate::helper::const_str::MC_NS; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::drawing::spreadsheet::TwoCellAnchor; use crate::structs::raw::RawRelationships; use crate::structs::vml::Shape; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -25,6 +25,7 @@ pub struct OleObject { impl OleObject { #[inline] + #[must_use] pub fn get_requires(&self) -> &str { self.requires.get_value_str() } @@ -36,6 +37,7 @@ impl OleObject { } #[inline] + #[must_use] pub fn get_prog_id(&self) -> &str { self.prog_id.get_value_str() } @@ -47,6 +49,7 @@ impl OleObject { } #[inline] + #[must_use] pub fn get_object_extension(&self) -> &str { &self.object_extension } @@ -57,6 +60,7 @@ impl OleObject { } #[inline] + #[must_use] pub fn get_object_data(&self) -> Option<&[u8]> { self.object_data.as_deref() } @@ -73,6 +77,7 @@ impl OleObject { } #[inline] + #[must_use] pub fn get_embedded_object_properties(&self) -> &EmbeddedObjectProperties { &self.embedded_object_properties } @@ -89,6 +94,7 @@ impl OleObject { } #[inline] + #[must_use] pub fn get_two_cell_anchor(&self) -> &TwoCellAnchor { &self.two_cell_anchor } @@ -105,6 +111,7 @@ impl OleObject { } #[inline] + #[must_use] pub fn get_shape(&self) -> &Shape { &self.shape } @@ -201,8 +208,8 @@ impl OleObject { ); // oleObject - let r_id_str = format!("rId{}", r_id); - let shape_id_str = format!("{}", ole_id); + let r_id_str = format!("rId{r_id}"); + let shape_id_str = format!("{ole_id}"); let attributes = vec![ ("progId", self.prog_id.get_value_str()), ("shapeId", shape_id_str.as_str()), @@ -221,7 +228,7 @@ impl OleObject { write_start_tag(writer, "mc:Fallback", vec![], false); // oleObject - let r_id_str = format!("rId{}", r_id); + let r_id_str = format!("rId{r_id}"); let attributes = vec![ ("progId", self.prog_id.get_value_str()), ("shapeId", shape_id_str.as_str()), diff --git a/src/structs/ole_objects.rs b/src/structs/ole_objects.rs index c8cc3d7c..71e0dab6 100644 --- a/src/structs/ole_objects.rs +++ b/src/structs/ole_objects.rs @@ -1,8 +1,8 @@ // oleObjects use super::OleObject; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::raw::RawRelationships; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct OleObjects { impl OleObjects { #[inline] + #[must_use] pub fn get_ole_object(&self) -> &[OleObject] { &self.ole_object } diff --git a/src/structs/page_margins.rs b/src/structs/page_margins.rs index 34a9c446..a56ca449 100644 --- a/src/structs/page_margins.rs +++ b/src/structs/page_margins.rs @@ -1,7 +1,7 @@ use crate::structs::DoubleValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::get_attribute; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct PageMargins { } impl PageMargins { #[inline] + #[must_use] pub fn get_left(&self) -> f64 { self.left.get_value() } @@ -29,6 +30,7 @@ impl PageMargins { } #[inline] + #[must_use] pub fn get_right(&self) -> f64 { self.right.get_value() } @@ -40,6 +42,7 @@ impl PageMargins { } #[inline] + #[must_use] pub fn get_top(&self) -> f64 { self.top.get_value() } @@ -51,6 +54,7 @@ impl PageMargins { } #[inline] + #[must_use] pub fn get_bottom(&self) -> f64 { self.bottom.get_value() } @@ -62,6 +66,7 @@ impl PageMargins { } #[inline] + #[must_use] pub fn get_header(&self) -> f64 { self.header.get_value() } @@ -73,6 +78,7 @@ impl PageMargins { } #[inline] + #[must_use] pub fn get_footer(&self) -> f64 { self.footer.get_value() } diff --git a/src/structs/page_setup.rs b/src/structs/page_setup.rs index 53fc3cbf..260458bb 100644 --- a/src/structs/page_setup.rs +++ b/src/structs/page_setup.rs @@ -1,9 +1,9 @@ -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::raw::RawRelationships; use crate::structs::EnumValue; use crate::structs::OrientationValues; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -24,6 +24,7 @@ pub struct PageSetup { impl PageSetup { #[inline] + #[must_use] pub fn get_paper_size(&self) -> u32 { self.paper_size.get_value() } @@ -35,6 +36,7 @@ impl PageSetup { } #[inline] + #[must_use] pub fn get_orientation(&self) -> &OrientationValues { self.orientation.get_value() } @@ -46,6 +48,7 @@ impl PageSetup { } #[inline] + #[must_use] pub fn get_scale(&self) -> u32 { self.scale.get_value() } @@ -57,6 +60,7 @@ impl PageSetup { } #[inline] + #[must_use] pub fn get_fit_to_height(&self) -> u32 { self.fit_to_height.get_value() } @@ -68,6 +72,7 @@ impl PageSetup { } #[inline] + #[must_use] pub fn get_fit_to_width(&self) -> u32 { self.fit_to_width.get_value() } @@ -79,6 +84,7 @@ impl PageSetup { } #[inline] + #[must_use] pub fn get_horizontal_dpi(&self) -> u32 { self.horizontal_dpi.get_value() } @@ -90,6 +96,7 @@ impl PageSetup { } #[inline] + #[must_use] pub fn get_vertical_dpi(&self) -> u32 { self.vertical_dpi.get_value() } @@ -101,6 +108,7 @@ impl PageSetup { } #[inline] + #[must_use] pub fn get_object_data(&self) -> Option<&[u8]> { self.object_data.as_deref() } @@ -154,7 +162,7 @@ impl PageSetup { pub(crate) fn write_to(&self, writer: &mut Writer>>, r_id: &mut usize) { if self.has_param() { // pageSetup - let r_id_str = format!("rId{}", r_id); + let r_id_str = format!("rId{r_id}"); let mut attributes: Vec<(&str, &str)> = Vec::new(); let paper_size = self.paper_size.get_value_string(); if self.paper_size.has_value() { diff --git a/src/structs/pane.rs b/src/structs/pane.rs index a36f6e08..ded6a16b 100644 --- a/src/structs/pane.rs +++ b/src/structs/pane.rs @@ -3,8 +3,8 @@ use super::DoubleValue; use super::EnumValue; use super::PaneStateValues; use super::PaneValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -21,6 +21,7 @@ pub struct Pane { impl Pane { #[inline] + #[must_use] pub fn get_horizontal_split(&self) -> f64 { self.horizontal_split.get_value() } @@ -32,6 +33,7 @@ impl Pane { } #[inline] + #[must_use] pub fn get_vertical_split(&self) -> f64 { self.vertical_split.get_value() } @@ -43,6 +45,7 @@ impl Pane { } #[inline] + #[must_use] pub fn get_top_left_cell(&self) -> &Coordinate { &self.top_left_cell } @@ -59,6 +62,7 @@ impl Pane { } #[inline] + #[must_use] pub fn get_active_pane(&self) -> &PaneValues { self.active_pane.get_value() } @@ -70,6 +74,7 @@ impl Pane { } #[inline] + #[must_use] pub fn get_state(&self) -> &PaneStateValues { self.state.get_value() } diff --git a/src/structs/pattern_fill.rs b/src/structs/pattern_fill.rs index cd962301..7c8109bd 100644 --- a/src/structs/pattern_fill.rs +++ b/src/structs/pattern_fill.rs @@ -2,8 +2,8 @@ use super::Color; use super::EnumValue; use super::PatternValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -19,6 +19,7 @@ pub struct PatternFill { impl PatternFill { #[inline] + #[must_use] pub fn get_pattern_type(&self) -> &PatternValues { self.pattern_type.get_value() } @@ -41,6 +42,7 @@ impl PatternFill { } #[inline] + #[must_use] pub fn get_foreground_color(&self) -> Option<&Color> { self.foreground_color.as_deref() } @@ -65,6 +67,7 @@ impl PatternFill { } #[inline] + #[must_use] pub fn get_background_color(&self) -> Option<&Color> { self.background_color.as_deref() } @@ -100,8 +103,7 @@ impl PatternFill { format!( "{:x}", md5::Md5::digest(format!( - "{}{}{}", - pattern_type, foreground_color, background_color + "{pattern_type}{foreground_color}{background_color}" )) ) } diff --git a/src/structs/phonetic_run.rs b/src/structs/phonetic_run.rs index 824eab23..304790fb 100644 --- a/src/structs/phonetic_run.rs +++ b/src/structs/phonetic_run.rs @@ -1,5 +1,5 @@ // si -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/pivot_cache_definition.rs b/src/structs/pivot_cache_definition.rs index bc283120..15cf92d6 100644 --- a/src/structs/pivot_cache_definition.rs +++ b/src/structs/pivot_cache_definition.rs @@ -1,13 +1,13 @@ // pivotCacheDefinition -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{MC_NS, REL_OFC_NS, SHEET_MAIN_NS, SHEET_MS_REVISION_NS}; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::ByteValue; use crate::structs::CacheFields; use crate::structs::CacheSource; use crate::structs::DoubleValue; use crate::structs::StringValue; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -28,6 +28,7 @@ pub struct PivotCacheDefinition { impl PivotCacheDefinition { #[inline] + #[must_use] pub fn get_id(&self) -> &str { self.id.get_value_str() } @@ -39,6 +40,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_refreshed_by(&self) -> &str { self.refreshed_by.get_value_str() } @@ -50,6 +52,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_refreshed_date(&self) -> f64 { self.refreshed_date.get_value() } @@ -61,6 +64,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_created_version(&self) -> u8 { self.created_version.get_value() } @@ -72,6 +76,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_refreshed_version(&self) -> u8 { self.refreshed_version.get_value() } @@ -83,6 +88,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_min_refreshable_version(&self) -> u8 { self.min_refreshable_version.get_value() } @@ -94,6 +100,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_record_count(&self) -> u32 { self.record_count.get_value() } @@ -105,6 +112,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_cache_source(&self) -> &CacheSource { &self.cache_source } @@ -121,6 +129,7 @@ impl PivotCacheDefinition { } #[inline] + #[must_use] pub fn get_cache_fields(&self) -> &CacheFields { &self.cache_fields } diff --git a/src/structs/pivot_field.rs b/src/structs/pivot_field.rs index c8ac08de..7101aeab 100644 --- a/src/structs/pivot_field.rs +++ b/src/structs/pivot_field.rs @@ -1,7 +1,7 @@ // pivotField -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::BooleanValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct PivotField { } impl PivotField { #[inline] + #[must_use] pub fn get_data_field(&self) -> bool { self.data_field.get_value() } @@ -25,6 +26,7 @@ impl PivotField { } #[inline] + #[must_use] pub fn get_show_all(&self) -> bool { self.show_all.get_value() } diff --git a/src/structs/pivot_fields.rs b/src/structs/pivot_fields.rs index 9ba6006f..5b60cd03 100644 --- a/src/structs/pivot_fields.rs +++ b/src/structs/pivot_fields.rs @@ -1,7 +1,7 @@ // pivotFields -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::PivotField; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct PivotFields { } impl PivotFields { #[inline] + #[must_use] pub fn get_list(&self) -> &[PivotField] { &self.list } diff --git a/src/structs/pivot_table.rs b/src/structs/pivot_table.rs index b7db294e..e483f4f1 100644 --- a/src/structs/pivot_table.rs +++ b/src/structs/pivot_table.rs @@ -9,6 +9,7 @@ pub struct PivotTable { impl PivotTable { #[inline] + #[must_use] pub fn get_pivot_table_definition(&self) -> &PivotTableDefinition { &self.pivot_table_definition } @@ -25,6 +26,7 @@ impl PivotTable { } #[inline] + #[must_use] pub fn get_pivot_cache_definition(&self) -> &PivotCacheDefinition { &self.pivot_cache_definition } diff --git a/src/structs/pivot_table_definition.rs b/src/structs/pivot_table_definition.rs index 2a70284d..85e6da8a 100644 --- a/src/structs/pivot_table_definition.rs +++ b/src/structs/pivot_table_definition.rs @@ -1,6 +1,6 @@ // pivotTableDefinition -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{MC_NS, SHEET_MAIN_NS, SHEET_MS_REVISION_NS}; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::BooleanValue; use crate::structs::ByteValue; use crate::structs::ColumnFields; @@ -12,7 +12,7 @@ use crate::structs::PivotTableStyle; use crate::structs::RowItems; use crate::structs::StringValue; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -49,6 +49,7 @@ pub struct PivotTableDefinition { } impl PivotTableDefinition { #[inline] + #[must_use] pub fn get_apply_number_formats(&self) -> bool { self.apply_number_formats.get_value() } @@ -60,6 +61,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_apply_border_formats(&self) -> bool { self.apply_border_formats.get_value() } @@ -71,6 +73,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_apply_font_formats(&self) -> bool { self.apply_font_formats.get_value() } @@ -82,6 +85,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_apply_pattern_formats(&self) -> bool { self.apply_pattern_formats.get_value() } @@ -93,6 +97,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_apply_alignment_formats(&self) -> bool { self.apply_alignment_formats.get_value() } @@ -104,6 +109,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_apply_width_height_formats(&self) -> bool { self.apply_width_height_formats.get_value() } @@ -115,6 +121,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_use_auto_formatting(&self) -> bool { self.use_auto_formatting.get_value() } @@ -126,6 +133,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_item_print_titles(&self) -> bool { self.item_print_titles.get_value() } @@ -137,6 +145,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_outline(&self) -> bool { self.outline.get_value() } @@ -148,6 +157,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_outline_data(&self) -> bool { self.outline_data.get_value() } @@ -159,6 +169,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_multiple_field_filters(&self) -> bool { self.multiple_field_filters.get_value() } @@ -170,6 +181,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -181,6 +193,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_cache_id(&self) -> u32 { self.cache_id.get_value() } @@ -192,6 +205,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_indent(&self) -> u32 { self.indent.get_value() } @@ -203,6 +217,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_local_name(&self) -> &str { self.local_name.get_value_str() } @@ -214,6 +229,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_data_caption(&self) -> &str { self.data_caption.get_value_str() } @@ -225,6 +241,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_updated_version(&self) -> u8 { self.updated_version.get_value() } @@ -236,6 +253,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_min_refreshable_version(&self) -> u8 { self.min_refreshable_version.get_value() } @@ -247,6 +265,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_created_version(&self) -> u8 { self.created_version.get_value() } @@ -258,6 +277,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_location(&self) -> &Location { &self.location } @@ -274,6 +294,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_pivot_fields(&self) -> &PivotFields { &self.pivot_fields } @@ -290,6 +311,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_row_items(&self) -> &RowItems { &self.row_items } @@ -306,6 +328,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_column_fields(&self) -> &ColumnFields { &self.column_fields } @@ -322,6 +345,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_column_items(&self) -> &ColumnItems { &self.column_items } @@ -338,6 +362,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_data_fields(&self) -> &DataFields { &self.data_fields } @@ -354,6 +379,7 @@ impl PivotTableDefinition { } #[inline] + #[must_use] pub fn get_pivot_table_style(&self) -> &PivotTableStyle { &self.pivot_table_style } diff --git a/src/structs/pivot_table_style.rs b/src/structs/pivot_table_style.rs index db538428..a642b320 100644 --- a/src/structs/pivot_table_style.rs +++ b/src/structs/pivot_table_style.rs @@ -1,8 +1,8 @@ // pivotTableStyleInfo -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::BooleanValue; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct PivotTableStyle { } impl PivotTableStyle { #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.get_value_str() } @@ -31,6 +32,7 @@ impl PivotTableStyle { } #[inline] + #[must_use] pub fn get_show_row_headers(&self) -> bool { self.show_row_headers.get_value() } @@ -42,6 +44,7 @@ impl PivotTableStyle { } #[inline] + #[must_use] pub fn get_show_column_headers(&self) -> bool { self.show_column_headers.get_value() } @@ -53,6 +56,7 @@ impl PivotTableStyle { } #[inline] + #[must_use] pub fn get_show_row_stripes(&self) -> bool { self.show_row_stripes.get_value() } @@ -64,6 +68,7 @@ impl PivotTableStyle { } #[inline] + #[must_use] pub fn get_show_column_stripes(&self) -> bool { self.show_column_stripes.get_value() } @@ -75,6 +80,7 @@ impl PivotTableStyle { } #[inline] + #[must_use] pub fn get_show_last_column(&self) -> bool { self.show_last_column.get_value() } diff --git a/src/structs/print_options.rs b/src/structs/print_options.rs index 8a97159e..733ee8a3 100644 --- a/src/structs/print_options.rs +++ b/src/structs/print_options.rs @@ -1,6 +1,6 @@ use super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct PrintOptions { impl PrintOptions { #[inline] + #[must_use] pub fn get_horizontal_centered(&self) -> bool { self.horizontal_centered.get_value() } @@ -25,6 +26,7 @@ impl PrintOptions { } #[inline] + #[must_use] pub fn get_vertical_centered(&self) -> bool { self.vertical_centered.get_value() } diff --git a/src/structs/properties.rs b/src/structs/properties.rs index d43a0ef0..9af5e4d5 100644 --- a/src/structs/properties.rs +++ b/src/structs/properties.rs @@ -1,9 +1,11 @@ -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::{ + COREPROPS_NS, DCMITYPE_NS, DCORE_NS, DCTERMS_NS, VTYPES_NS, XPROPS_NS, XSI_NS, +}; +use crate::reader::driver::xml_read_loop; use crate::structs::custom_properties::Properties as CustomProperties; use crate::structs::StringValue; use crate::structs::Worksheet; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::BytesStart; use quick_xml::events::Event; use quick_xml::Reader; @@ -54,6 +56,7 @@ impl Default for Properties { } impl Properties { #[inline] + #[must_use] pub fn get_creator(&self) -> &str { self.creator.get_value_str() } @@ -65,6 +68,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_last_modified_by(&self) -> &str { self.last_modified_by.get_value_str() } @@ -76,6 +80,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_created(&self) -> &str { self.created.get_value_str() } @@ -87,6 +92,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_modified(&self) -> &str { self.modified.get_value_str() } @@ -98,6 +104,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_title(&self) -> &str { self.title.get_value_str() } @@ -109,6 +116,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_description(&self) -> &str { self.description.get_value_str() } @@ -120,6 +128,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_subject(&self) -> &str { self.subject.get_value_str() } @@ -131,6 +140,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_keywords(&self) -> &str { self.keywords.get_value_str() } @@ -142,6 +152,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_revision(&self) -> &str { self.revision.get_value_str() } @@ -153,6 +164,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_category(&self) -> &str { self.category.get_value_str() } @@ -164,6 +176,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_version(&self) -> &str { self.version.get_value_str() } @@ -175,6 +188,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_manager(&self) -> &str { self.manager.get_value_str() } @@ -186,6 +200,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_company(&self) -> &str { self.company.get_value_str() } @@ -197,6 +212,7 @@ impl Properties { } #[inline] + #[must_use] pub fn get_custom_properties(&self) -> &CustomProperties { &self.custom_properties } @@ -217,7 +233,7 @@ impl Properties { reader: &mut Reader, _e: &BytesStart, ) { - let mut value: String = String::from(""); + let mut value: String = String::new(); xml_read_loop!( reader, Event::Text(e) => { @@ -248,13 +264,13 @@ impl Properties { reader: &mut Reader, _e: &BytesStart, ) { - let mut value: String = String::from(""); + let mut value: String = String::new(); xml_read_loop!( reader, Event::Start(ref e) => { match e.name().into_inner(){ - b"Manager" => {value = String::from("");}, - b"Company" => {value = String::from("");}, + b"Manager" => {value = String::new();}, + b"Company" => {value = String::new();}, _ => {} } }, diff --git a/src/structs/protection.rs b/src/structs/protection.rs index 400d221f..588ece5a 100644 --- a/src/structs/protection.rs +++ b/src/structs/protection.rs @@ -1,7 +1,7 @@ // protection use super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use md5::Digest; use quick_xml::events::BytesStart; use quick_xml::Reader; @@ -16,6 +16,7 @@ pub struct Protection { impl Protection { #[inline] + #[must_use] pub fn get_locked(&self) -> bool { self.locked.get_value() } diff --git a/src/structs/range.rs b/src/structs/range.rs index 0e351845..f10f319a 100644 --- a/src/structs/range.rs +++ b/src/structs/range.rs @@ -1,6 +1,6 @@ use super::ColumnReference; use super::RowReference; -use crate::helper::coordinate::*; +use crate::helper::coordinate::index_from_coordinate; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentValue; @@ -65,6 +65,7 @@ impl Range { } #[inline] + #[must_use] pub fn get_range(&self) -> String { let mut result = self.get_coordinate_start(); if self.end_col.is_some() || self.end_row.is_some() { @@ -74,6 +75,7 @@ impl Range { } #[inline] + #[must_use] pub fn get_coordinate_start_col(&self) -> Option<&ColumnReference> { self.start_col.as_ref() } @@ -84,6 +86,7 @@ impl Range { } #[inline] + #[must_use] pub fn get_coordinate_start_row(&self) -> Option<&RowReference> { self.start_row.as_ref() } @@ -94,6 +97,7 @@ impl Range { } #[inline] + #[must_use] pub fn get_coordinate_end_col(&self) -> Option<&ColumnReference> { self.end_col.as_ref() } @@ -104,6 +108,7 @@ impl Range { } #[inline] + #[must_use] pub fn get_coordinate_end_row(&self) -> Option<&RowReference> { self.end_row.as_ref() } @@ -114,7 +119,7 @@ impl Range { } pub(crate) fn get_coordinate_start(&self) -> String { - let mut coordinate_str = "".into(); + let mut coordinate_str = String::new(); if let Some(v) = &self.start_col { coordinate_str = v.get_coordinate(); }; @@ -125,7 +130,7 @@ impl Range { } pub(crate) fn get_coordinate_end(&self) -> String { - let mut coordinate_str = "".into(); + let mut coordinate_str = String::new(); if let Some(v) = &self.end_col { coordinate_str = v.get_coordinate(); }; diff --git a/src/structs/raw.rs b/src/structs/raw.rs index c3bb5a3e..c153550b 100644 --- a/src/structs/raw.rs +++ b/src/structs/raw.rs @@ -1,4 +1,4 @@ -//! structs of raw_data. +//! structs of `raw_data`. mod raw_file; pub(crate) use self::raw_file::*; diff --git a/src/structs/raw/raw_file.rs b/src/structs/raw/raw_file.rs index dcbc82ec..625f37e9 100644 --- a/src/structs/raw/raw_file.rs +++ b/src/structs/raw/raw_file.rs @@ -1,4 +1,4 @@ -use crate::reader::driver::*; +use crate::reader::driver::join_paths; use crate::structs::StringValue; use crate::structs::WriterManager; use crate::XlsxError; @@ -16,7 +16,7 @@ impl RawFile { pub(crate) fn get_file_name(&self) -> String { let v: Vec<&str> = self.get_file_target().split('/').collect(); let object_name = v.last().unwrap(); - object_name.to_string() + (*object_name).to_string() } #[inline] @@ -66,7 +66,7 @@ impl RawFile { self } - pub(crate) fn set_attributes( + pub(crate) fn set_attributes( &mut self, arv: &mut zip::read::ZipArchive, base_path: &str, diff --git a/src/structs/raw/raw_relationship.rs b/src/structs/raw/raw_relationship.rs index 84ec2fb3..8f0f743b 100644 --- a/src/structs/raw/raw_relationship.rs +++ b/src/structs/raw/raw_relationship.rs @@ -1,9 +1,9 @@ -use crate::reader::driver::*; +use crate::reader::driver::get_attribute; use crate::structs::raw::RawFile; use crate::structs::StringValue; use crate::structs::WriterManager; use crate::structs::XlsxError; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -80,7 +80,7 @@ impl RawRelationship { self } - pub(crate) fn set_attributes( + pub(crate) fn set_attributes( &mut self, _reader: &mut Reader, e: &BytesStart, diff --git a/src/structs/raw/raw_relationships.rs b/src/structs/raw/raw_relationships.rs index a4be7e2a..d520eea5 100644 --- a/src/structs/raw/raw_relationships.rs +++ b/src/structs/raw/raw_relationships.rs @@ -1,10 +1,10 @@ -use crate::helper::const_str::*; -use crate::reader::driver::*; +use crate::helper::const_str::REL_NS; +use crate::reader::driver::{join_paths, xml_read_loop}; use crate::structs::raw::RawRelationship; use crate::structs::StringValue; use crate::structs::WriterManager; use crate::structs::XlsxError; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_new_line, write_start_tag}; use quick_xml::events::{BytesDecl, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -23,7 +23,7 @@ impl RawRelationships { pub(crate) fn _get_file_name(&self) -> String { let v: Vec<&str> = self.get_file_target().split('/').collect(); let object_name = v.last().unwrap(); - object_name.to_string() + (*object_name).to_string() } #[inline] @@ -53,7 +53,7 @@ impl RawRelationships { return relationship; } } - panic!("not found relationship as {}.", r_id); + panic!("not found relationship as {r_id}."); } #[inline] @@ -62,7 +62,7 @@ impl RawRelationships { self } - pub(crate) fn set_attributes( + pub(crate) fn set_attributes( &mut self, arv: &mut zip::read::ZipArchive, base_path: &str, @@ -80,7 +80,7 @@ impl RawRelationships { let mut r = io::BufReader::new(file_path); let mut buf = Vec::new(); r.read_to_end(&mut buf).unwrap(); - std::io::Cursor::new(buf) + io::Cursor::new(buf) }; let mut reader = Reader::from_reader(data); reader.config_mut().trim_text(true); diff --git a/src/structs/raw/raw_worksheet.rs b/src/structs/raw/raw_worksheet.rs index 978bd79a..6b2b7b37 100644 --- a/src/structs/raw/raw_worksheet.rs +++ b/src/structs/raw/raw_worksheet.rs @@ -1,4 +1,6 @@ -use crate::helper::const_str::*; +use crate::helper::const_str::{ + PKG_DRAWINGS_RELS, PKG_SHEET, PKG_SHEET_RELS, PKG_VML_DRAWING_RELS, +}; use crate::structs::raw::RawFile; use crate::structs::raw::RawRelationships; use crate::structs::WriterManager; @@ -97,7 +99,7 @@ impl RawWorksheet { writer_mng: &mut WriterManager, ) -> Result<(), XlsxError> { // Add worksheet - let target = format!("{PKG_SHEET}{}.xml", sheet_no); + let target = format!("{PKG_SHEET}{sheet_no}.xml"); writer_mng.add_bin(&target, self.get_worksheet_file().get_file_data())?; // Add worksheet rels diff --git a/src/structs/rich_text.rs b/src/structs/rich_text.rs index 75012cfb..3ab92ab1 100644 --- a/src/structs/rich_text.rs +++ b/src/structs/rich_text.rs @@ -1,6 +1,6 @@ use super::TextElement; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -17,8 +17,9 @@ pub struct RichText { impl RichText { #[inline] + #[must_use] pub fn get_text(&self) -> Cow<'static, str> { - let mut text = String::from(""); + let mut text = String::new(); for rich_text_elements in &self.rich_text_elements { text = format!("{}{}", text, rich_text_elements.get_text()); } @@ -35,6 +36,7 @@ impl RichText { } #[inline] + #[must_use] pub fn get_rich_text_elements(&self) -> &[TextElement] { &self.rich_text_elements } @@ -57,7 +59,7 @@ impl RichText { } pub(crate) fn get_hash_code(&self) -> String { - let mut value = String::from(""); + let mut value = String::new(); for ele in &self.rich_text_elements { write!(value, "{}", ele.get_hash_code()).unwrap(); } diff --git a/src/structs/row.rs b/src/structs/row.rs index e04be53c..94c018ec 100644 --- a/src/structs/row.rs +++ b/src/structs/row.rs @@ -6,10 +6,10 @@ use super::SharedStringTable; use super::Style; use super::Stylesheet; use super::UInt32Value; -use crate::helper::formula::*; -use crate::reader::driver::*; +use crate::helper::formula::FormulaToken; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::traits::AdjustmentValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -42,6 +42,7 @@ impl Default for Row { } impl Row { #[inline] + #[must_use] pub fn get_row_num(&self) -> u32 { self.row_num.get_value() } @@ -53,6 +54,7 @@ impl Row { } #[inline] + #[must_use] pub fn get_height(&self) -> f64 { self.height.get_value() } @@ -65,6 +67,7 @@ impl Row { } #[inline] + #[must_use] pub fn get_descent(&self) -> f64 { self.descent.get_value() } @@ -76,6 +79,7 @@ impl Row { } #[inline] + #[must_use] pub fn get_thick_bot(&self) -> bool { self.thick_bot.get_value() } @@ -87,6 +91,7 @@ impl Row { } #[inline] + #[must_use] pub fn get_custom_height(&self) -> bool { self.custom_height.get_value() } @@ -98,6 +103,7 @@ impl Row { } #[inline] + #[must_use] pub fn get_hidden(&self) -> bool { self.hidden.get_value() } @@ -109,6 +115,7 @@ impl Row { } #[inline] + #[must_use] pub fn get_style(&self) -> &Style { &self.style } diff --git a/src/structs/row_breaks.rs b/src/structs/row_breaks.rs index e556268c..72b3d131 100644 --- a/src/structs/row_breaks.rs +++ b/src/structs/row_breaks.rs @@ -1,7 +1,7 @@ // rowBreaks -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::Break; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct RowBreaks { impl RowBreaks { #[inline] + #[must_use] pub fn get_break_list(&self) -> &[Break] { &self.break_list } diff --git a/src/structs/row_item.rs b/src/structs/row_item.rs index f7bdbaa7..aea9f9fe 100644 --- a/src/structs/row_item.rs +++ b/src/structs/row_item.rs @@ -1,10 +1,10 @@ // i -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::EnumValue; use crate::structs::ItemValues; use crate::structs::MemberPropertyIndex; use crate::structs::UInt32Value; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -19,6 +19,7 @@ pub struct RowItem { } impl RowItem { #[inline] + #[must_use] pub fn get_index(&self) -> u32 { self.index.get_value() } @@ -30,6 +31,7 @@ impl RowItem { } #[inline] + #[must_use] pub fn get_item_type(&self) -> &ItemValues { self.item_type.get_value() } @@ -41,6 +43,7 @@ impl RowItem { } #[inline] + #[must_use] pub fn get_repeated_item_count(&self) -> u32 { self.repeated_item_count.get_value() } @@ -52,6 +55,7 @@ impl RowItem { } #[inline] + #[must_use] pub fn get_member_property_index(&self) -> Option<&MemberPropertyIndex> { self.member_property_index.as_ref() } diff --git a/src/structs/row_items.rs b/src/structs/row_items.rs index 4c107c0e..c564853c 100644 --- a/src/structs/row_items.rs +++ b/src/structs/row_items.rs @@ -1,7 +1,7 @@ // rowItems -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::RowItem; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct RowItems { } impl RowItems { #[inline] + #[must_use] pub fn get_list(&self) -> &[RowItem] { &self.list } diff --git a/src/structs/row_reference.rs b/src/structs/row_reference.rs index 21da3d6f..2d362cd1 100644 --- a/src/structs/row_reference.rs +++ b/src/structs/row_reference.rs @@ -1,4 +1,6 @@ -use crate::helper::coordinate::*; +use crate::helper::coordinate::{ + adjustment_insert_coordinate, adjustment_remove_coordinate, is_remove_coordinate, +}; use crate::traits::AdjustmentValue; #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] @@ -19,6 +21,7 @@ impl Default for RowReference { impl RowReference { #[inline] + #[must_use] pub fn get_num(&self) -> u32 { self.num } @@ -53,6 +56,7 @@ impl RowReference { } #[inline] + #[must_use] pub fn get_is_lock(&self) -> bool { self.is_lock } @@ -70,6 +74,7 @@ impl RowReference { } #[inline] + #[must_use] pub fn get_coordinate(&self) -> String { format!("{}{}", if self.is_lock { "$" } else { "" }, self.num) } diff --git a/src/structs/selection.rs b/src/structs/selection.rs index 198bcb11..4c25a3c9 100644 --- a/src/structs/selection.rs +++ b/src/structs/selection.rs @@ -2,8 +2,8 @@ use super::Coordinate; use super::EnumValue; use super::PaneValues; use super::SequenceOfReferences; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct Selection { impl Selection { #[inline] + #[must_use] pub fn get_pane(&self) -> &PaneValues { self.pane.get_value() } @@ -29,6 +30,7 @@ impl Selection { } #[inline] + #[must_use] pub fn get_active_cell(&self) -> Option<&Coordinate> { self.active_cell.as_ref() } @@ -45,6 +47,7 @@ impl Selection { } #[inline] + #[must_use] pub fn get_sequence_of_references(&self) -> &SequenceOfReferences { &self.sequence_of_references } @@ -99,7 +102,7 @@ impl Selection { let active_cell_str = match &self.active_cell { Some(active_cell) => active_cell.to_string(), - None => String::from(""), + None => String::new(), }; if !active_cell_str.is_empty() { attributes.push(("activeCell", active_cell_str.as_str())); diff --git a/src/structs/sequence_of_references.rs b/src/structs/sequence_of_references.rs index 093b46d5..03dd28da 100644 --- a/src/structs/sequence_of_references.rs +++ b/src/structs/sequence_of_references.rs @@ -9,6 +9,7 @@ pub struct SequenceOfReferences { impl SequenceOfReferences { #[inline] + #[must_use] pub fn get_range_collection(&self) -> &[Range] { &self.range_collection } @@ -46,10 +47,11 @@ impl SequenceOfReferences { } #[inline] + #[must_use] pub fn get_sqref(&self) -> String { self.range_collection .iter() - .map(|range| range.get_range()) + .map(Range::get_range) .collect::>() .join(" ") } diff --git a/src/structs/shared_items.rs b/src/structs/shared_items.rs index 3825b43d..f7f021c6 100644 --- a/src/structs/shared_items.rs +++ b/src/structs/shared_items.rs @@ -1,8 +1,8 @@ // sharedItems -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::BooleanValue; use crate::structs::DoubleValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -18,6 +18,7 @@ pub struct SharedItems { max_value: DoubleValue, } impl SharedItems { + #[must_use] pub fn get_contains_semi_mixed_types(&self) -> bool { self.contains_semi_mixed_types.get_value() } @@ -27,6 +28,7 @@ impl SharedItems { self } + #[must_use] pub fn get_contains_string(&self) -> bool { self.contains_string.get_value() } @@ -36,6 +38,7 @@ impl SharedItems { self } + #[must_use] pub fn get_contains_number(&self) -> bool { self.contains_number.get_value() } @@ -45,6 +48,7 @@ impl SharedItems { self } + #[must_use] pub fn get_contains_integer(&self) -> bool { self.contains_integer.get_value() } @@ -54,6 +58,7 @@ impl SharedItems { self } + #[must_use] pub fn get_min_value(&self) -> f64 { self.min_value.get_value() } @@ -63,6 +68,7 @@ impl SharedItems { self } + #[must_use] pub fn get_max_value(&self) -> f64 { self.max_value.get_value() } diff --git a/src/structs/shared_string_item.rs b/src/structs/shared_string_item.rs index fcaa6b26..0cfdcfcb 100644 --- a/src/structs/shared_string_item.rs +++ b/src/structs/shared_string_item.rs @@ -3,8 +3,8 @@ use super::PhoneticRun; use super::RichText; use super::Text; use super::TextElement; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -71,10 +71,10 @@ impl SharedStringItem { "{}{}", self.text .as_ref() - .map_or(String::from("NONE"), |v| v.get_hash_code()), + .map_or(String::from("NONE"), Text::get_hash_code), self.rich_text .as_ref() - .map_or(String::from("NONE"), |v| v.get_hash_code()) + .map_or(String::from("NONE"), RichText::get_hash_code) ); h.write(content.as_bytes()); h.finish() diff --git a/src/structs/shared_string_table.rs b/src/structs/shared_string_table.rs index bb9a9058..9f82c340 100644 --- a/src/structs/shared_string_table.rs +++ b/src/structs/shared_string_table.rs @@ -1,9 +1,9 @@ // sst use super::CellValue; use super::SharedStringItem; -use crate::helper::const_str::*; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::helper::const_str::SHEET_MAIN_NS; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -54,14 +54,13 @@ impl SharedStringTable { } let hash_code = shared_string_item.get_hash_u64(); - let n = match self.map.get(&hash_code) { - Some(v) => v.to_owned(), - None => { - let n = self.shared_string_item.len(); - self.map.insert(hash_code, n); - self.set_shared_string_item(shared_string_item); - n - } + let n = if let Some(v) = self.map.get(&hash_code) { + v.to_owned() + } else { + let n = self.shared_string_item.len(); + self.map.insert(hash_code, n); + self.set_shared_string_item(shared_string_item); + n }; n } diff --git a/src/structs/sheet_format_properties.rs b/src/structs/sheet_format_properties.rs index df8dc879..cf63dfd2 100644 --- a/src/structs/sheet_format_properties.rs +++ b/src/structs/sheet_format_properties.rs @@ -3,8 +3,8 @@ use super::BooleanValue; use super::ByteValue; use super::DoubleValue; use super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -25,6 +25,7 @@ pub struct SheetFormatProperties { impl SheetFormatProperties { #[inline] + #[must_use] pub fn get_base_column_width(&self) -> u32 { self.base_column_width.get_value() } @@ -36,6 +37,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_custom_height(&self) -> bool { self.custom_height.get_value() } @@ -47,6 +49,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_default_column_width(&self) -> f64 { self.default_column_width.get_value() } @@ -58,6 +61,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_default_row_height(&self) -> f64 { self.default_row_height.get_value() } @@ -69,6 +73,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_dy_descent(&self) -> f64 { self.dy_descent.get_value() } @@ -80,6 +85,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_outline_level_column(&self) -> u8 { self.outline_level_column.get_value() } @@ -91,6 +97,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_outline_level_row(&self) -> u8 { self.outline_level_row.get_value() } @@ -102,6 +109,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_thick_bottom(&self) -> bool { self.thick_bottom.get_value() } @@ -113,6 +121,7 @@ impl SheetFormatProperties { } #[inline] + #[must_use] pub fn get_thick_top(&self) -> bool { self.thick_top.get_value() } diff --git a/src/structs/sheet_protection.rs b/src/structs/sheet_protection.rs index 223864f3..d6ce782a 100644 --- a/src/structs/sheet_protection.rs +++ b/src/structs/sheet_protection.rs @@ -2,9 +2,9 @@ use super::BooleanValue; use super::StringValue; use super::UInt32Value; -use crate::helper::crypt::*; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::helper::crypt::encrypt_sheet_protection; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -36,6 +36,7 @@ pub struct SheetProtection { } impl SheetProtection { #[inline] + #[must_use] pub fn get_algorithm_name(&self) -> &str { self.algorithm_name.get_value_str() } @@ -47,6 +48,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_hash_value(&self) -> &str { self.hash_value.get_value_str() } @@ -58,6 +60,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_salt_value(&self) -> &str { self.salt_value.get_value_str() } @@ -69,6 +72,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_spin_count(&self) -> u32 { self.spin_count.get_value() } @@ -80,6 +84,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_password_raw(&self) -> &str { self.password.get_value_str() } @@ -97,6 +102,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_sheet(&self) -> bool { self.sheet.get_value() } @@ -108,6 +114,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_objects(&self) -> bool { self.objects.get_value() } @@ -119,6 +126,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_delete_rows(&self) -> bool { self.delete_rows.get_value() } @@ -130,6 +138,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_insert_columns(&self) -> bool { self.insert_columns.get_value() } @@ -141,6 +150,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_delete_columns(&self) -> bool { self.delete_columns.get_value() } @@ -152,6 +162,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_insert_hyperlinks(&self) -> bool { self.insert_hyperlinks.get_value() } @@ -163,6 +174,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_auto_filter(&self) -> bool { self.auto_filter.get_value() } @@ -174,6 +186,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_scenarios(&self) -> bool { self.scenarios.get_value() } @@ -185,6 +198,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_format_cells(&self) -> bool { self.format_cells.get_value() } @@ -196,6 +210,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_format_columns(&self) -> bool { self.format_columns.get_value() } @@ -207,6 +222,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_insert_rows(&self) -> bool { self.insert_rows.get_value() } @@ -218,6 +234,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_format_rows(&self) -> bool { self.format_rows.get_value() } @@ -229,6 +246,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_pivot_tables(&self) -> bool { self.pivot_tables.get_value() } @@ -240,6 +258,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_select_locked_cells(&self) -> bool { self.select_locked_cells.get_value() } @@ -251,6 +270,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_select_unlocked_cells(&self) -> bool { self.select_unlocked_cells.get_value() } @@ -262,6 +282,7 @@ impl SheetProtection { } #[inline] + #[must_use] pub fn get_sort(&self) -> bool { self.sort.get_value() } diff --git a/src/structs/sheet_view.rs b/src/structs/sheet_view.rs index 5646a349..be2de3b4 100644 --- a/src/structs/sheet_view.rs +++ b/src/structs/sheet_view.rs @@ -6,8 +6,8 @@ use super::Selection; use super::SheetViewValues; use super::StringValue; use super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -31,6 +31,7 @@ pub struct SheetView { impl SheetView { #[inline] + #[must_use] pub fn get_show_grid_lines(&self) -> bool { self.show_grid_lines.get_value() } @@ -42,6 +43,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_tab_selected(&self) -> bool { self.tab_selected.get_value() } @@ -53,6 +55,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_workbook_view_id(&self) -> u32 { self.workbook_view_id.get_value() } @@ -64,6 +67,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_pane(&self) -> Option<&Pane> { self.pane.as_deref() } @@ -80,6 +84,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_view(&self) -> &SheetViewValues { self.view.get_value() } @@ -91,6 +96,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_zoom_scale(&self) -> u32 { self.zoom_scale.get_value() } @@ -102,6 +108,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_zoom_scale_normal(&self) -> u32 { self.zoom_scale_normal.get_value() } @@ -113,6 +120,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_zoom_scale_page_layout_view(&self) -> u32 { self.zoom_scale_page_layout_view.get_value() } @@ -124,6 +132,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_zoom_scale_sheet_layout_view(&self) -> u32 { self.zoom_scale_sheet_layout_view.get_value() } @@ -135,6 +144,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_top_left_cell(&self) -> &str { self.top_left_cell.get_value_str() } @@ -146,6 +156,7 @@ impl SheetView { } #[inline] + #[must_use] pub fn get_selection(&self) -> &[Selection] { &self.selection } @@ -261,7 +272,7 @@ impl SheetView { } // pane if let Some(v) = &self.pane { - v.write_to(writer) + v.write_to(writer); } // selection for obj in &self.selection { diff --git a/src/structs/sheet_views.rs b/src/structs/sheet_views.rs index 728a9db9..0f42db39 100644 --- a/src/structs/sheet_views.rs +++ b/src/structs/sheet_views.rs @@ -1,7 +1,7 @@ // sheetViews use super::SheetView; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct SheetViews { impl SheetViews { #[inline] + #[must_use] pub fn get_sheet_view_list(&self) -> &[SheetView] { &self.sheet_view_list } diff --git a/src/structs/spreadsheet.rs b/src/structs/spreadsheet.rs index c1bd0ddb..e33baf8d 100644 --- a/src/structs/spreadsheet.rs +++ b/src/structs/spreadsheet.rs @@ -1,6 +1,6 @@ -use crate::helper::address::*; -use crate::helper::coordinate::*; -use crate::reader::xlsx::*; +use crate::helper::address::split_address; +use crate::helper::coordinate::column_index_from_string; +use crate::reader::xlsx::raw_to_deserialize_by_worksheet; use crate::structs::drawing::Theme; use crate::structs::Address; use crate::structs::CellValue; @@ -150,13 +150,14 @@ impl Spreadsheet { /// # Arguments /// * `address` - address. ex) "Sheet1!A1:C5" /// # Return value - /// *`Vec<&CellValue>` - CellValue List. + /// *`Vec<&CellValue>` - `CellValue` List. /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); /// let mut cell_value_List = book.get_cell_value_by_address("Sheet1!A1:C5"); /// ``` #[inline] + #[must_use] pub fn get_cell_value_by_address(&self, address: &str) -> Vec<&CellValue> { let (sheet_name, range) = split_address(address); self.get_sheet_by_name(sheet_name) @@ -169,7 +170,7 @@ impl Spreadsheet { /// # Arguments /// * `address` - Address Object /// # Return value - /// *`Vec<&CellValue>` - CellValue List. + /// *`Vec<&CellValue>` - `CellValue` List. #[inline] pub(crate) fn get_cell_value_by_address_crate(&self, address: &Address) -> Vec<&CellValue> { self.get_sheet_by_name(address.get_sheet_name()) @@ -179,6 +180,7 @@ impl Spreadsheet { /// Get Theme. #[inline] + #[must_use] pub fn get_theme(&self) -> &Theme { &self.theme } @@ -200,6 +202,7 @@ impl Spreadsheet { /// Get Properties. #[inline] + #[must_use] pub fn get_properties(&self) -> &Properties { &self.properties } @@ -223,6 +226,7 @@ impl Spreadsheet { /// # Return value /// * `Option<&Vec>` - Macros Code Raw Data. #[inline] + #[must_use] pub fn get_macros_code(&self) -> Option<&[u8]> { self.macros_code.as_deref() } @@ -245,6 +249,7 @@ impl Spreadsheet { /// Has Macros Code #[inline] + #[must_use] pub fn get_has_macros(&self) -> bool { self.macros_code.is_some() } @@ -268,6 +273,7 @@ impl Spreadsheet { /// Must to be the same in workbook with VBA/macros code from this workbook /// for that code in Workbook object to work out of the box without adjustments #[inline] + #[must_use] pub fn get_code_name(&self) -> Option<&str> { self.code_name.get_value() } @@ -315,6 +321,7 @@ impl Spreadsheet { } /// Get Work Sheet List. + #[must_use] pub fn get_sheet_collection(&self) -> &[Worksheet] { for worksheet in &self.work_sheet_collection { assert!(worksheet.is_deserialized(),"This Worksheet is Not Deserialized. Please exec to read_sheet(&mut self, index: usize);"); @@ -325,6 +332,7 @@ impl Spreadsheet { /// Get Work Sheet List. /// No check deserialized. #[inline] + #[must_use] pub fn get_sheet_collection_no_check(&self) -> &[Worksheet] { &self.work_sheet_collection } @@ -340,6 +348,7 @@ impl Spreadsheet { /// # Return value /// * `usize` - Work Sheet Count. #[inline] + #[must_use] pub fn get_sheet_count(&self) -> usize { self.work_sheet_collection.len() } @@ -385,6 +394,7 @@ impl Spreadsheet { /// # Return value /// * `Option<&Worksheet>`. #[inline] + #[must_use] pub fn get_sheet(&self, index: usize) -> Option<&Worksheet> { self.work_sheet_collection .get(index) @@ -399,6 +409,7 @@ impl Spreadsheet { /// # Return value /// * `Option<&Worksheet>. #[inline] + #[must_use] pub fn get_sheet_by_name(&self, sheet_name: &str) -> Option<&Worksheet> { self.find_sheet_index_by_name(sheet_name) .and_then(|index| self.get_sheet(index)) @@ -453,6 +464,7 @@ impl Spreadsheet { /// # Return value /// * `&Worksheet` - Work sheet. #[inline] + #[must_use] pub fn get_active_sheet(&self) -> &Worksheet { let index = self.get_workbook_view().get_active_tab(); self.get_sheet(index as usize).unwrap() @@ -591,6 +603,7 @@ impl Spreadsheet { /// Get Workbook View. #[inline] + #[must_use] pub fn get_workbook_view(&self) -> &WorkbookView { &self.workbook_view } @@ -603,7 +616,7 @@ impl Spreadsheet { /// Set Workbook View. /// # Arguments - /// * `value` - WorkbookView + /// * `value` - `WorkbookView` #[inline] pub fn set_workbook_view(&mut self, value: WorkbookView) -> &mut Self { self.workbook_view = value; @@ -619,7 +632,7 @@ impl Spreadsheet { } self.get_sheet_collection_no_check() .iter() - .any(|sheet| sheet.has_defined_names()) + .any(Worksheet::has_defined_names) } #[inline] @@ -671,13 +684,14 @@ impl Spreadsheet { pub(crate) fn update_pivot_caches(&mut self, key: String, value: String) -> &mut Self { self.pivot_caches.iter_mut().for_each(|(val1, _, val3)| { if **val1 == key { - *val3 = value.clone().into_boxed_str() + *val3 = value.clone().into_boxed_str(); }; }); self } #[inline] + #[must_use] pub fn get_workbook_protection(&self) -> Option<&WorkbookProtection> { self.workbook_protection.as_deref() } @@ -702,6 +716,7 @@ impl Spreadsheet { /// Get Defined Name (Vec). #[inline] + #[must_use] pub fn get_defined_names(&self) -> &[DefinedName] { &self.defined_names } @@ -722,7 +737,7 @@ impl Spreadsheet { /// Add Defined Name. /// # Arguments - /// * `value` - DefinedName. + /// * `value` - `DefinedName`. #[inline] pub fn add_defined_names(&mut self, value: DefinedName) { self.defined_names.push(value); diff --git a/src/structs/strike.rs b/src/structs/strike.rs index 994c4784..872582c8 100644 --- a/src/structs/strike.rs +++ b/src/structs/strike.rs @@ -1,7 +1,7 @@ // strike use super::BooleanValue; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Strike { impl Strike { #[inline] + #[must_use] pub fn get_val(&self) -> bool { self.val.get_value() } diff --git a/src/structs/style.rs b/src/structs/style.rs index 8cb14300..13d93728 100644 --- a/src/structs/style.rs +++ b/src/structs/style.rs @@ -61,6 +61,7 @@ pub struct Style { } impl Style { #[inline] + #[must_use] pub fn get_font(&self) -> Option<&Font> { self.font.as_deref() } @@ -89,6 +90,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_fill(&self) -> Option<&Fill> { self.fill.as_deref() } @@ -105,6 +107,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_background_color(&self) -> Option<&Color> { self.get_fill() .and_then(|fill| fill.get_pattern_fill()?.get_foreground_color()) @@ -157,6 +160,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_borders(&self) -> Option<&Borders> { self.borders.as_deref() } @@ -186,6 +190,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_alignment(&self) -> Option<&Alignment> { self.alignment.as_ref() } @@ -214,6 +219,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_numbering_format(&self) -> Option<&NumberingFormat> { self.numbering_format.as_deref() } @@ -237,6 +243,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_number_format(&self) -> Option<&NumberingFormat> { self.get_numbering_format() } @@ -257,6 +264,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_format_id(&self) -> u32 { self.format_id.get_value() } @@ -268,6 +276,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_protection(&self) -> Option<&Protection> { self.protection.as_ref() } @@ -317,6 +326,7 @@ impl Style { } #[inline] + #[must_use] pub fn get_default_value() -> Self { let mut def = Self::default(); def.set_font(Font::get_default_value()); diff --git a/src/structs/stylesheet.rs b/src/structs/stylesheet.rs index 88efd816..fc4118ac 100644 --- a/src/structs/stylesheet.rs +++ b/src/structs/stylesheet.rs @@ -10,9 +10,9 @@ use super::Fills; use super::Fonts; use super::NumberingFormats; use super::Style; -use crate::helper::const_str::*; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::helper::const_str::{MC_NS, SHEETML_AC_NS, SHEET_MAIN_NS, SHEET_MS_MAIN_NS}; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; diff --git a/src/structs/table.rs b/src/structs/table.rs index 28178951..d77f5855 100644 --- a/src/structs/table.rs +++ b/src/structs/table.rs @@ -1,7 +1,8 @@ use super::{ - coordinate::*, BooleanValue, EnumValue, StringValue, TotalsRowFunctionValues, UInt32Value, + coordinate::Coordinate, BooleanValue, EnumValue, StringValue, TotalsRowFunctionValues, + UInt32Value, }; -use crate::helper::coordinate::*; +use crate::helper::coordinate::CellCoordinates; use thin_vec::ThinVec; //use reader::driver::*; @@ -36,6 +37,7 @@ impl Table { } #[inline] + #[must_use] pub fn is_ok(&self) -> bool { !(self.name.is_empty() || self.display_name.is_empty() @@ -48,6 +50,7 @@ impl Table { } #[inline] + #[must_use] pub fn get_name(&self) -> &str { &self.name } @@ -61,6 +64,7 @@ impl Table { } #[inline] + #[must_use] pub fn get_display_name(&self) -> &str { &self.display_name } @@ -71,6 +75,7 @@ impl Table { } #[inline] + #[must_use] pub fn get_area(&self) -> &(Coordinate, Coordinate) { &self.area } @@ -91,6 +96,7 @@ impl Table { } #[inline] + #[must_use] pub fn get_columns(&self) -> &[TableColumn] { &self.columns } @@ -101,6 +107,7 @@ impl Table { } #[inline] + #[must_use] pub fn get_style_info(&self) -> Option<&TableStyleInfo> { self.style_info.as_deref() } @@ -116,6 +123,7 @@ impl Table { } #[inline] + #[must_use] pub fn get_totals_row_shown(&self) -> bool { self.totals_row_shown.get_value() } @@ -141,6 +149,7 @@ impl Table { } #[inline] + #[must_use] pub fn get_totals_row_count(&self) -> u32 { self.totals_row_count.get_value() } @@ -182,6 +191,7 @@ pub struct TableColumn { } impl TableColumn { #[inline] + #[must_use] pub fn new(name: &str) -> Self { Self { name: name.to_string(), @@ -192,6 +202,7 @@ impl TableColumn { } #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.as_str() } @@ -208,6 +219,7 @@ impl TableColumn { } #[inline] + #[must_use] pub fn get_totals_row_label(&self) -> Option<&str> { self.totals_row_label.get_value() } @@ -234,6 +246,7 @@ impl TableColumn { } #[inline] + #[must_use] pub fn get_totals_row_function(&self) -> &TotalsRowFunctionValues { self.totals_row_function.get_value() } @@ -254,6 +267,7 @@ impl TableColumn { } #[inline] + #[must_use] pub fn get_calculated_column_formula(&self) -> Option<&String> { self.calculated_column_formula.as_ref() } @@ -274,6 +288,7 @@ pub struct TableStyleInfo { } impl TableStyleInfo { #[inline] + #[must_use] pub fn new( name: &str, show_first_col: bool, @@ -291,26 +306,31 @@ impl TableStyleInfo { } #[inline] + #[must_use] pub fn get_name(&self) -> &str { self.name.as_str() } #[inline] + #[must_use] pub fn is_show_first_col(&self) -> bool { self.show_first_col } #[inline] + #[must_use] pub fn is_show_last_col(&self) -> bool { self.show_last_col } #[inline] + #[must_use] pub fn is_show_row_stripes(&self) -> bool { self.show_row_stripes } #[inline] + #[must_use] pub fn is_show_col_stripes(&self) -> bool { self.show_col_stripes } diff --git a/src/structs/text.rs b/src/structs/text.rs index 242ad4ce..fa2ff99f 100644 --- a/src/structs/text.rs +++ b/src/structs/text.rs @@ -1,6 +1,6 @@ // t -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; diff --git a/src/structs/text_element.rs b/src/structs/text_element.rs index 942ff3ab..24c50088 100644 --- a/src/structs/text_element.rs +++ b/src/structs/text_element.rs @@ -1,8 +1,8 @@ // r use super::Font; use super::Text; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::xml_read_loop; +use crate::writer::driver::{write_end_tag, write_start_tag}; use md5::Digest; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; @@ -17,6 +17,7 @@ pub struct TextElement { impl TextElement { #[inline] + #[must_use] pub fn get_text(&self) -> &str { self.text.get_value() } @@ -28,6 +29,7 @@ impl TextElement { } #[inline] + #[must_use] pub fn get_run_properties(&self) -> Option<&Font> { self.run_properties.as_deref() } @@ -54,6 +56,7 @@ impl TextElement { } #[inline] + #[must_use] pub fn get_font(&self) -> Option<&Font> { self.get_run_properties() } diff --git a/src/structs/to_marker.rs b/src/structs/to_marker.rs index c1e348eb..d6cd8768 100644 --- a/src/structs/to_marker.rs +++ b/src/structs/to_marker.rs @@ -1,5 +1,5 @@ // to -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct ToMarker { } impl ToMarker { #[inline] + #[must_use] pub fn get_col(&self) -> usize { self.col } @@ -25,6 +26,7 @@ impl ToMarker { } #[inline] + #[must_use] pub fn get_col_off(&self) -> usize { self.col_off } @@ -36,6 +38,7 @@ impl ToMarker { } #[inline] + #[must_use] pub fn get_row(&self) -> usize { self.row } @@ -47,6 +50,7 @@ impl ToMarker { } #[inline] + #[must_use] pub fn get_row_off(&self) -> usize { self.row_off } @@ -82,7 +86,7 @@ impl ToMarker { reader: &mut Reader, _e: &BytesStart, ) { - let mut string_value: String = String::from(""); + let mut string_value: String = String::new(); let mut buf = Vec::new(); loop { match reader.read_event_into(&mut buf) { diff --git a/src/structs/underline.rs b/src/structs/underline.rs index 65927a4b..ade9d6f1 100644 --- a/src/structs/underline.rs +++ b/src/structs/underline.rs @@ -2,8 +2,8 @@ use super::EnumTrait; use super::EnumValue; use super::UnderlineValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct Underline { impl Underline { #[inline] + #[must_use] pub fn get_val(&self) -> &UnderlineValues { if self.val.has_value() { return self.val.get_value(); @@ -36,7 +37,7 @@ impl Underline { e: &BytesStart, ) { self.set_val(UnderlineValues::default()); - set_string_from_xml!(self, e, val, "val") + set_string_from_xml!(self, e, val, "val"); } pub(crate) fn write_to(&self, writer: &mut Writer>>) { diff --git a/src/structs/vertical_text_alignment.rs b/src/structs/vertical_text_alignment.rs index 222367b0..a61f774b 100644 --- a/src/structs/vertical_text_alignment.rs +++ b/src/structs/vertical_text_alignment.rs @@ -1,8 +1,8 @@ // vertAlign use super::EnumValue; use super::VerticalAlignmentRunValues; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +15,7 @@ pub struct VerticalTextAlignment { impl VerticalTextAlignment { #[inline] + #[must_use] pub fn get_val(&self) -> &VerticalAlignmentRunValues { self.val.get_value() } diff --git a/src/structs/vml/fill.rs b/src/structs/vml/fill.rs index ed7bcaf2..176a2c3d 100644 --- a/src/structs/vml/fill.rs +++ b/src/structs/vml/fill.rs @@ -1,9 +1,9 @@ -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::raw::RawRelationships; use crate::structs::MediaObject; use crate::structs::StringValue; use crate::structs::TrueFalseValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -20,6 +20,7 @@ pub struct Fill { impl Fill { #[inline] + #[must_use] pub fn get_color(&self) -> &str { self.color.get_value_str() } @@ -31,6 +32,7 @@ impl Fill { } #[inline] + #[must_use] pub fn get_color_2(&self) -> &str { self.color_2.get_value_str() } @@ -42,6 +44,7 @@ impl Fill { } #[inline] + #[must_use] pub fn get_on(&self) -> bool { self.on.get_value() } @@ -53,6 +56,7 @@ impl Fill { } #[inline] + #[must_use] pub fn get_focus_size(&self) -> &str { self.focus_size.get_value_str() } @@ -64,6 +68,7 @@ impl Fill { } #[inline] + #[must_use] pub fn get_image(&self) -> Option<&MediaObject> { self.image.as_ref() } @@ -123,10 +128,10 @@ impl Fill { if self.focus_size.has_value() { attributes.push(("focussize", self.focus_size.get_value_str())); } - let mut _r_id_str = String::from(""); + let mut _r_id_str = String::new(); if let Some(image) = &self.image { let r_id = image.get_rid(rel_list); - _r_id_str = format!("rId{}", r_id); + _r_id_str = format!("rId{r_id}"); attributes.push(("o:title", image.get_image_title())); attributes.push(("o:relid", _r_id_str.as_str())); attributes.push(("recolor", "t")); diff --git a/src/structs/vml/image_data.rs b/src/structs/vml/image_data.rs index 84a76b58..18f9bd4a 100644 --- a/src/structs/vml/image_data.rs +++ b/src/structs/vml/image_data.rs @@ -1,8 +1,8 @@ -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::raw::RawRelationships; use crate::structs::MediaObject; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -16,6 +16,7 @@ pub struct ImageData { impl ImageData { #[inline] + #[must_use] pub fn get_image(&self) -> &MediaObject { &self.image } @@ -31,6 +32,7 @@ impl ImageData { self } + #[must_use] pub fn get_title(&self) -> &str { self.title.get_value_str() } @@ -66,9 +68,9 @@ impl ImageData { ) { // v:imagedata let mut attributes: Vec<(&str, &str)> = Vec::new(); - let mut _r_id_str = String::from(""); + let mut _r_id_str = String::new(); let r_id = &self.image.get_rid(rel_list); - _r_id_str = format!("rId{}", r_id); + _r_id_str = format!("rId{r_id}"); attributes.push(("o:relid", _r_id_str.as_str())); if self.title.has_value() { attributes.push(("o:title", self.title.get_value_str())); diff --git a/src/structs/vml/path.rs b/src/structs/vml/path.rs index 72f38526..e983605e 100644 --- a/src/structs/vml/path.rs +++ b/src/structs/vml/path.rs @@ -1,7 +1,7 @@ use super::office::ConnectValues; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::EnumValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -12,6 +12,7 @@ pub struct Path { connection_point_type: EnumValue, } impl Path { + #[must_use] pub fn get_connection_point_type(&self) -> &ConnectValues { self.connection_point_type.get_value() } diff --git a/src/structs/vml/shadow.rs b/src/structs/vml/shadow.rs index 28671e4c..fe4798a3 100644 --- a/src/structs/vml/shadow.rs +++ b/src/structs/vml/shadow.rs @@ -1,7 +1,7 @@ -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::StringValue; use crate::structs::TrueFalseValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Shadow { obscured: TrueFalseValue, } impl Shadow { + #[must_use] pub fn get_on(&self) -> bool { self.on.get_value() } @@ -23,6 +24,7 @@ impl Shadow { self } + #[must_use] pub fn get_color(&self) -> &str { self.color.get_value_str() } @@ -32,6 +34,7 @@ impl Shadow { self } + #[must_use] pub fn get_obscured(&self) -> bool { self.obscured.get_value() } diff --git a/src/structs/vml/shape.rs b/src/structs/vml/shape.rs index 8180acc9..36b014bd 100644 --- a/src/structs/vml/shape.rs +++ b/src/structs/vml/shape.rs @@ -6,14 +6,14 @@ use super::Path; use super::Shadow; use super::Stroke; use super::TextBox; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::raw::RawRelationships; use crate::structs::EnumValue; use crate::structs::Int32Value; use crate::structs::StringValue; use crate::structs::TrueFalseValue; use crate::traits::AdjustmentCoordinate; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -41,6 +41,7 @@ pub struct Shape { } impl Shape { + #[must_use] pub fn get_style(&self) -> &str { self.style.get_value_str() } @@ -50,6 +51,7 @@ impl Shape { self } + #[must_use] pub fn get_type(&self) -> &str { self.r_type.get_value_str() } @@ -59,6 +61,7 @@ impl Shape { self } + #[must_use] pub fn get_filled(&self) -> bool { self.filled.get_value() } @@ -68,6 +71,7 @@ impl Shape { self } + #[must_use] pub fn get_fill_color(&self) -> &str { self.fill_color.get_value_str() } @@ -77,6 +81,7 @@ impl Shape { self } + #[must_use] pub fn get_stroked(&self) -> bool { self.stroked.get_value() } @@ -86,6 +91,7 @@ impl Shape { self } + #[must_use] pub fn get_stroke_color(&self) -> &str { self.stroke_color.get_value_str() } @@ -95,6 +101,7 @@ impl Shape { self } + #[must_use] pub fn get_stroke_weight(&self) -> &str { self.stroke_weight.get_value_str() } @@ -104,6 +111,7 @@ impl Shape { self } + #[must_use] pub fn get_inset_mode(&self) -> &InsetMarginValues { self.inset_mode.get_value() } @@ -113,6 +121,7 @@ impl Shape { self } + #[must_use] pub fn get_fill(&self) -> Option<&Fill> { self.fill.as_deref() } @@ -126,6 +135,7 @@ impl Shape { self } + #[must_use] pub fn get_image_data(&self) -> Option<&ImageData> { self.image_data.as_deref() } @@ -139,6 +149,7 @@ impl Shape { self } + #[must_use] pub fn get_stroke(&self) -> Option<&Stroke> { self.stroke.as_deref() } @@ -152,6 +163,7 @@ impl Shape { self } + #[must_use] pub fn get_shadow(&self) -> Option<&Shadow> { self.shadow.as_deref() } @@ -165,6 +177,7 @@ impl Shape { self } + #[must_use] pub fn get_path(&self) -> Option<&Path> { self.path.as_deref() } @@ -178,6 +191,7 @@ impl Shape { self } + #[must_use] pub fn get_text_box(&self) -> Option<&TextBox> { self.text_box.as_deref() } @@ -191,6 +205,7 @@ impl Shape { self } + #[must_use] pub fn get_client_data(&self) -> &ClientData { &self.client_data } @@ -204,6 +219,7 @@ impl Shape { self } + #[must_use] pub fn get_optional_number(&self) -> i32 { self.optional_number.get_value() } @@ -213,6 +229,7 @@ impl Shape { self } + #[must_use] pub fn get_coordinate_size(&self) -> &str { self.coordinate_size.get_value_str() } @@ -302,7 +319,7 @@ impl Shape { rel_list: &mut Vec<(String, String)>, ) { // v:shape - let id_str = format!("_x0000_s{}", id); + let id_str = format!("_x0000_s{id}"); let mut attributes: Vec<(&str, &str)> = Vec::new(); attributes.push(("id", &id_str)); if self.r_type.has_value() { diff --git a/src/structs/vml/spreadsheet/anchor.rs b/src/structs/vml/spreadsheet/anchor.rs index 561ff82a..bca48d92 100644 --- a/src/structs/vml/spreadsheet/anchor.rs +++ b/src/structs/vml/spreadsheet/anchor.rs @@ -1,7 +1,9 @@ -use crate::helper::coordinate::*; -use crate::reader::driver::*; +use crate::helper::coordinate::{ + adjustment_insert_coordinate, adjustment_remove_coordinate, is_remove_coordinate, +}; +use crate::reader::driver::xml_read_loop; use crate::traits::AdjustmentCoordinate; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -21,6 +23,7 @@ pub struct Anchor { impl Anchor { #[inline] + #[must_use] pub fn get_left_column(&self) -> u32 { self.left_column } @@ -32,6 +35,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_left_offset(&self) -> u32 { self.left_offset } @@ -43,6 +47,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_top_row(&self) -> u32 { self.top_row } @@ -54,6 +59,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_top_offset(&self) -> u32 { self.top_offset } @@ -65,6 +71,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_right_column(&self) -> u32 { self.right_column } @@ -76,6 +83,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_right_offset(&self) -> u32 { self.right_offset } @@ -87,6 +95,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_bottom_row(&self) -> u32 { self.bottom_row } @@ -98,6 +107,7 @@ impl Anchor { } #[inline] + #[must_use] pub fn get_bottom_offset(&self) -> u32 { self.bottom_offset } @@ -184,7 +194,7 @@ impl Anchor { #[inline] fn get_number(value: Option<&&str>) -> u32 { match value { - Some(v) => v.to_string().trim().parse::().unwrap_or(0), + Some(v) => (*v).to_string().trim().parse::().unwrap_or(0), None => 0, } } diff --git a/src/structs/vml/spreadsheet/auto_fill.rs b/src/structs/vml/spreadsheet/auto_fill.rs index aa83c7ad..ef92c5b2 100644 --- a/src/structs/vml/spreadsheet/auto_fill.rs +++ b/src/structs/vml/spreadsheet/auto_fill.rs @@ -1,6 +1,6 @@ -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::TrueFalseBlankValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct AutoFill { impl AutoFill { #[inline] + #[must_use] pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/auto_size_picture.rs b/src/structs/vml/spreadsheet/auto_size_picture.rs index 8e9efd7c..beccca18 100644 --- a/src/structs/vml/spreadsheet/auto_size_picture.rs +++ b/src/structs/vml/spreadsheet/auto_size_picture.rs @@ -1,6 +1,6 @@ -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::TrueFalseBlankValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct AutoSizePicture { impl AutoSizePicture { #[inline] + #[must_use] pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/client_data.rs b/src/structs/vml/spreadsheet/client_data.rs index 9922a3b8..cb2d612c 100644 --- a/src/structs/vml/spreadsheet/client_data.rs +++ b/src/structs/vml/spreadsheet/client_data.rs @@ -8,11 +8,11 @@ use super::MoveWithCells; use super::ObjectValues; use super::ResizeWithCells; use super::Visible; -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml, xml_read_loop}; use crate::structs::EnumValue; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -34,6 +34,7 @@ pub struct ClientData { impl ClientData { #[inline] + #[must_use] pub fn get_object_type(&self) -> &ObjectValues { self.object_type.get_value() } @@ -45,6 +46,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_move_with_cells(&self) -> Option<&MoveWithCells> { self.move_with_cells.as_ref() } @@ -61,6 +63,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_resize_with_cells(&self) -> Option<&ResizeWithCells> { self.resize_with_cells.as_ref() } @@ -77,6 +80,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_anchor(&self) -> &Anchor { &self.anchor } @@ -93,6 +97,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_auto_fill(&self) -> Option<&AutoFill> { self.auto_fill.as_ref() } @@ -109,6 +114,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_comment_row_target(&self) -> Option<&CommentRowTarget> { self.comment_row_target.as_ref() } @@ -125,6 +131,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_comment_column_target(&self) -> Option<&CommentColumnTarget> { self.comment_column_target.as_ref() } @@ -141,6 +148,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_visible(&self) -> Option<&Visible> { self.visible.as_ref() } @@ -157,6 +165,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_clipboard_format(&self) -> Option<&ClipboardFormat> { self.clipboard_format.as_ref() } @@ -173,6 +182,7 @@ impl ClientData { } #[inline] + #[must_use] pub fn get_auto_size_picture(&self) -> Option<&AutoSizePicture> { self.auto_size_picture.as_ref() } diff --git a/src/structs/vml/spreadsheet/clipboard_format.rs b/src/structs/vml/spreadsheet/clipboard_format.rs index 5f6dc227..cc901e44 100644 --- a/src/structs/vml/spreadsheet/clipboard_format.rs +++ b/src/structs/vml/spreadsheet/clipboard_format.rs @@ -1,7 +1,7 @@ use super::ClipboardFormatValues; -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::EnumValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct ClipboardFormat { impl ClipboardFormat { #[inline] + #[must_use] pub fn get_value(&self) -> &ClipboardFormatValues { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/comment_column_target.rs b/src/structs/vml/spreadsheet/comment_column_target.rs index 8b1f6419..6862fb2b 100644 --- a/src/structs/vml/spreadsheet/comment_column_target.rs +++ b/src/structs/vml/spreadsheet/comment_column_target.rs @@ -1,8 +1,10 @@ -use crate::helper::coordinate::*; -use crate::reader::driver::*; +use crate::helper::coordinate::{ + adjustment_insert_coordinate, adjustment_remove_coordinate, is_remove_coordinate, +}; +use crate::reader::driver::xml_read_loop; use crate::structs::UInt32Value; use crate::traits::AdjustmentValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +17,7 @@ pub struct CommentColumnTarget { impl CommentColumnTarget { #[inline] + #[must_use] pub fn get_value(&self) -> u32 { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/comment_row_target.rs b/src/structs/vml/spreadsheet/comment_row_target.rs index 0c0f68e0..e05b36e4 100644 --- a/src/structs/vml/spreadsheet/comment_row_target.rs +++ b/src/structs/vml/spreadsheet/comment_row_target.rs @@ -1,8 +1,10 @@ -use crate::helper::coordinate::*; -use crate::reader::driver::*; +use crate::helper::coordinate::{ + adjustment_insert_coordinate, adjustment_remove_coordinate, is_remove_coordinate, +}; +use crate::reader::driver::xml_read_loop; use crate::structs::UInt32Value; use crate::traits::AdjustmentValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -15,6 +17,7 @@ pub struct CommentRowTarget { impl CommentRowTarget { #[inline] + #[must_use] pub fn get_value(&self) -> u32 { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/move_with_cells.rs b/src/structs/vml/spreadsheet/move_with_cells.rs index ba6615d4..107438d7 100644 --- a/src/structs/vml/spreadsheet/move_with_cells.rs +++ b/src/structs/vml/spreadsheet/move_with_cells.rs @@ -1,6 +1,6 @@ -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::TrueFalseBlankValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct MoveWithCells { impl MoveWithCells { #[inline] + #[must_use] pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/resize_with_cells.rs b/src/structs/vml/spreadsheet/resize_with_cells.rs index fb597caf..8bd7e1ac 100644 --- a/src/structs/vml/spreadsheet/resize_with_cells.rs +++ b/src/structs/vml/spreadsheet/resize_with_cells.rs @@ -1,6 +1,6 @@ -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::TrueFalseBlankValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct ResizeWithCells { impl ResizeWithCells { #[inline] + #[must_use] pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/spreadsheet/visible.rs b/src/structs/vml/spreadsheet/visible.rs index 343711bf..e9a1a246 100644 --- a/src/structs/vml/spreadsheet/visible.rs +++ b/src/structs/vml/spreadsheet/visible.rs @@ -1,6 +1,6 @@ -use crate::reader::driver::*; +use crate::reader::driver::xml_read_loop; use crate::structs::TrueFalseBlankValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct Visible { impl Visible { #[inline] + #[must_use] pub fn get_value(&self) -> Option { self.value.get_value() } diff --git a/src/structs/vml/stroke.rs b/src/structs/vml/stroke.rs index 02c953ff..d6550917 100644 --- a/src/structs/vml/stroke.rs +++ b/src/structs/vml/stroke.rs @@ -1,6 +1,6 @@ -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -14,6 +14,7 @@ pub struct Stroke { } impl Stroke { + #[must_use] pub fn get_color(&self) -> &str { self.color.get_value_str() } @@ -23,6 +24,7 @@ impl Stroke { self } + #[must_use] pub fn get_color_2(&self) -> &str { self.color_2.get_value_str() } @@ -32,6 +34,7 @@ impl Stroke { self } + #[must_use] pub fn get_dash_style(&self) -> &str { self.dash_style.get_value_str() } diff --git a/src/structs/vml/text_box.rs b/src/structs/vml/text_box.rs index 1ea5c589..865e89aa 100644 --- a/src/structs/vml/text_box.rs +++ b/src/structs/vml/text_box.rs @@ -1,6 +1,6 @@ -use crate::reader::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; use crate::structs::StringValue; -use crate::writer::driver::*; +use crate::writer::driver::{write_end_tag, write_start_tag, write_text_node_no_escape}; use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; @@ -23,6 +23,7 @@ impl Default for TextBox { } impl TextBox { + #[must_use] pub fn get_style(&self) -> &str { self.style.get_value_str() } @@ -32,6 +33,7 @@ impl TextBox { self } + #[must_use] pub fn get_innder(&self) -> &str { self.innder.get_value_str() } @@ -49,7 +51,7 @@ impl TextBox { set_string_from_xml!(self, e, style, "style"); let mut buf = Vec::new(); - let mut inner_text = String::from(""); + let mut inner_text = String::new(); reader.config_mut().check_end_names = false; loop { match reader.read_event_into(&mut buf) { @@ -69,9 +71,9 @@ impl TextBox { } }); for (key, value) in &attrs { - tag = format!("{} {}=\"{}\"", tag, key, value); + tag = format!("{tag} {key}=\"{value}\""); } - inner_text = format!("{}<{}/>", inner_text, tag); + inner_text = format!("{inner_text}<{tag}/>"); } Ok(Event::Start(ref e)) => { let mut tag = std::str::from_utf8(e.name().into_inner()) @@ -89,20 +91,20 @@ impl TextBox { } }); for (key, value) in &attrs { - tag = format!("{} {}=\"{}\"", tag, key, value); + tag = format!("{tag} {key}=\"{value}\""); } - inner_text = format!("{}<{}>", inner_text, tag); + inner_text = format!("{inner_text}<{tag}>"); } Ok(Event::Text(ref e)) => { let s = e.unescape().unwrap().to_string(); - inner_text = format!("{}{}", inner_text, s); + inner_text = format!("{inner_text}{s}"); } Ok(Event::End(ref e)) => { if e.name().into_inner() == b"v:textbox" { break; } let s = std::str::from_utf8(e.name().into_inner()).unwrap(); - inner_text = format!("{}", inner_text, s); + inner_text = format!("{inner_text}"); } Ok(Event::Eof) => break, Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e), diff --git a/src/structs/workbook_protection.rs b/src/structs/workbook_protection.rs index e790e8c9..b1ecdc1f 100644 --- a/src/structs/workbook_protection.rs +++ b/src/structs/workbook_protection.rs @@ -2,9 +2,9 @@ use super::BooleanValue; use super::StringValue; use super::UInt32Value; -use crate::helper::crypt::*; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::helper::crypt::{encrypt_revisions_protection, encrypt_workbook_protection}; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -28,6 +28,7 @@ pub struct WorkbookProtection { } impl WorkbookProtection { #[inline] + #[must_use] pub fn get_workbook_algorithm_name(&self) -> &str { self.workbook_algorithm_name.get_value_str() } @@ -39,6 +40,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_workbook_hash_value(&self) -> &str { self.workbook_hash_value.get_value_str() } @@ -50,6 +52,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_workbook_salt_value(&self) -> &str { self.workbook_salt_value.get_value_str() } @@ -61,6 +64,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_workbook_spin_count(&self) -> u32 { self.workbook_spin_count.get_value() } @@ -72,6 +76,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_workbook_password_raw(&self) -> &str { self.workbook_password.get_value_str() } @@ -89,6 +94,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_revisions_algorithm_name(&self) -> &str { self.revisions_algorithm_name.get_value_str() } @@ -100,6 +106,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_revisions_hash_value(&self) -> &str { self.revisions_hash_value.get_value_str() } @@ -111,6 +118,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_revisions_salt_value(&self) -> &str { self.revisions_salt_value.get_value_str() } @@ -122,6 +130,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_revisions_spin_count(&self) -> u32 { self.revisions_spin_count.get_value() } @@ -133,6 +142,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_revisions_password_raw(&self) -> &str { self.revisions_password.get_value_str() } @@ -150,6 +160,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_lock_revision(&self) -> bool { self.lock_revision.get_value() } @@ -161,6 +172,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_lock_structure(&self) -> bool { self.lock_structure.get_value() } @@ -172,6 +184,7 @@ impl WorkbookProtection { } #[inline] + #[must_use] pub fn get_lock_windows(&self) -> bool { self.lock_windows.get_value() } diff --git a/src/structs/workbook_view.rs b/src/structs/workbook_view.rs index 33b03a55..b2cd69d7 100644 --- a/src/structs/workbook_view.rs +++ b/src/structs/workbook_view.rs @@ -1,6 +1,6 @@ use super::UInt32Value; -use crate::reader::driver::*; -use crate::writer::driver::*; +use crate::reader::driver::{get_attribute, set_string_from_xml}; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct WorkbookView { impl WorkbookView { #[inline] + #[must_use] pub fn get_active_tab(&self) -> u32 { self.active_tab.get_value() } @@ -29,7 +30,7 @@ impl WorkbookView { _reader: &mut Reader, e: &BytesStart, ) { - set_string_from_xml!(self, e, active_tab, "activeTab") + set_string_from_xml!(self, e, active_tab, "activeTab"); } pub(crate) fn write_to(&self, writer: &mut Writer>>) { diff --git a/src/structs/worksheet.rs b/src/structs/worksheet.rs index 33e5ca74..ce494334 100644 --- a/src/structs/worksheet.rs +++ b/src/structs/worksheet.rs @@ -1,7 +1,9 @@ -use crate::helper::const_str::*; -use crate::helper::coordinate::*; -use crate::helper::range::*; -use crate::reader::xlsx::worksheet::*; +use crate::helper::const_str::PIVOT_CACHE_DEF_NS; +use crate::helper::coordinate::{ + column_index_from_string, coordinate_from_index, string_from_column_index, CellCoordinates, +}; +use crate::helper::range::{get_coordinate_list, get_start_and_end_point}; +use crate::reader::xlsx::worksheet::read_lite; use crate::structs::drawing::spreadsheet::WorksheetDrawing; use crate::structs::office2010::excel::DataValidations as DataValidations2010; use crate::structs::raw::RawWorksheet; @@ -112,7 +114,7 @@ impl Worksheet { let CellCoordinates { col, row } = coordinate.into(); self.get_cell((col, row)) .map(|v| v.get_value().into()) - .unwrap_or("".into()) + .unwrap_or_default() } /// Get value number. @@ -134,7 +136,7 @@ impl Worksheet { T: Into, { let CellCoordinates { col, row } = coordinate.into(); - self.get_cell((col, row)).and_then(|v| v.get_value_number()) + self.get_cell((col, row)).and_then(Cell::get_value_number) } /// Get formatted value. @@ -165,11 +167,13 @@ impl Worksheet { // ************************ /// Get Cell List. #[inline] + #[must_use] pub fn get_cell_collection(&self) -> Vec<&Cell> { self.cell_collection.get_collection() } #[inline] + #[must_use] pub fn get_cell_collection_sorted(&self) -> Vec<&Cell> { self.cell_collection.get_collection_sorted() } @@ -181,6 +185,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_collection_to_hashmap(&self) -> &HashMap<(u32, u32), Box> { self.cell_collection.get_collection_to_hashmap() } @@ -268,22 +273,26 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_collection_by_column(&self, column_num: u32) -> Vec<&Cell> { self.cell_collection.get_collection_by_column(column_num) } #[inline] + #[must_use] pub fn get_collection_by_row(&self, row_num: u32) -> Vec<&Cell> { self.cell_collection.get_collection_by_row(row_num) } #[inline] + #[must_use] pub fn get_collection_by_column_to_hashmap(&self, column_num: u32) -> HashMap { self.cell_collection .get_collection_by_column_to_hashmap(column_num) } #[inline] + #[must_use] pub fn get_collection_by_row_to_hashmap(&self, row_num: u32) -> HashMap { self.cell_collection .get_collection_by_row_to_hashmap(row_num) @@ -326,7 +335,7 @@ impl Worksheet { /// # Arguments /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value - /// * `&CellValue` - CellValue. + /// * `&CellValue` - `CellValue`. /// # Examples /// ``` /// let book = umya_spreadsheet::new_file(); @@ -347,7 +356,7 @@ impl Worksheet { /// # Arguments /// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)` or `(1, 1)` /// # Return value - /// * `&mut CellValue` - CellValue with mutable. + /// * `&mut CellValue` - `CellValue` with mutable. /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); @@ -368,7 +377,7 @@ impl Worksheet { /// # Arguments /// * `range` - range. ex) "A1:C5" /// # Return value - /// *`Vec<&CellValue>` - CellValue List. + /// *`Vec<&CellValue>` - `CellValue` List. /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file(); @@ -376,6 +385,7 @@ impl Worksheet { /// let mut cell_value_List = worksheet.get_cell_value_by_range("A1:C5"); /// ``` #[inline] + #[must_use] pub fn get_cell_value_by_range(&self, range: &str) -> Vec<&CellValue> { self.cell_collection.get_cell_value_by_range(range) } @@ -477,6 +487,7 @@ impl Worksheet { // ************************ /// Get Comments #[inline] + #[must_use] pub fn get_comments(&self) -> &[Comment] { &self.comments } @@ -489,6 +500,7 @@ impl Worksheet { /// Get Comments convert to hashmap. #[inline] + #[must_use] pub fn get_comments_to_hashmap(&self) -> HashMap { let mut result = HashMap::default(); for comment in &self.comments { @@ -516,6 +528,7 @@ impl Worksheet { /// Has Comments. #[inline] + #[must_use] pub fn has_comments(&self) -> bool { !self.comments.is_empty() } @@ -523,15 +536,16 @@ impl Worksheet { // ************************ // Conditional // ************************ - /// Get ConditionalFormatting list. + /// Get `ConditionalFormatting` list. #[inline] + #[must_use] pub fn get_conditional_formatting_collection(&self) -> &[ConditionalFormatting] { &self.conditional_formatting_collection } - /// Set ConditionalFormatting. + /// Set `ConditionalFormatting`. /// # Arguments - /// * `value` - ConditionalSet List (Vec) + /// * `value` - `ConditionalSet` List (Vec) #[inline] pub fn set_conditional_formatting_collection( &mut self, @@ -540,9 +554,9 @@ impl Worksheet { self.conditional_formatting_collection = value.into(); } - /// Add ConditionalFormatting. + /// Add `ConditionalFormatting`. /// # Arguments - /// * `value` - ConditionalFormatting + /// * `value` - `ConditionalFormatting` #[inline] pub fn add_conditional_formatting_collection(&mut self, value: ConditionalFormatting) { self.conditional_formatting_collection.push(value); @@ -579,6 +593,7 @@ impl Worksheet { // ************************ // Get Merge Cells #[inline] + #[must_use] pub fn get_merge_cells(&self) -> &[Range] { self.merge_cells.get_range_collection() } @@ -623,6 +638,7 @@ impl Worksheet { // ************************ // Get Auto Filter (Option). #[inline] + #[must_use] pub fn get_auto_filter(&self) -> Option<&AutoFilter> { self.auto_filter.as_ref() } @@ -660,6 +676,7 @@ impl Worksheet { // ************************ /// Get Column Dimension List. #[inline] + #[must_use] pub fn get_column_dimensions(&self) -> &[Column] { self.column_dimensions.get_column_collection() } @@ -684,6 +701,7 @@ impl Worksheet { /// # Arguments /// * `column` - Column Char. ex) "A" #[inline] + #[must_use] pub fn get_column_dimension(&self, column: &str) -> Option<&Column> { let column_upper = column.to_uppercase(); let col = column_index_from_string(column_upper); @@ -704,6 +722,7 @@ impl Worksheet { /// # Arguments /// * `col` - Column Number. #[inline] + #[must_use] pub fn get_column_dimension_by_number(&self, col: u32) -> Option<&Column> { self.get_column_dimensions_crate().get_column(col) } @@ -742,12 +761,14 @@ impl Worksheet { // Row Dimensions // ************************ #[inline] + #[must_use] pub fn has_sheet_data(&self) -> bool { self.row_dimensions.has_sheet_data() } /// Get Row Dimension List. #[inline] + #[must_use] pub fn get_row_dimensions(&self) -> Vec<&Row> { self.row_dimensions.get_row_dimensions() } @@ -760,6 +781,7 @@ impl Worksheet { /// Get Row Dimension convert Hashmap. #[inline] + #[must_use] pub fn get_row_dimensions_to_hashmap(&self) -> &HashMap> { self.row_dimensions.get_row_dimensions_to_hashmap() } @@ -771,6 +793,7 @@ impl Worksheet { /// Get Row Dimension. #[inline] + #[must_use] pub fn get_row_dimension(&self, row: u32) -> Option<&Row> { self.row_dimensions.get_row_dimension(row) } @@ -806,28 +829,30 @@ impl Worksheet { // ************************ // WorksheetDrawing // ************************ - /// Get WorksheetDrawing. + /// Get `WorksheetDrawing`. #[inline] + #[must_use] pub fn get_worksheet_drawing(&self) -> &WorksheetDrawing { &self.worksheet_drawing } - /// Get WorksheetDrawing in mutable. + /// Get `WorksheetDrawing` in mutable. #[inline] pub fn get_worksheet_drawing_mut(&mut self) -> &mut WorksheetDrawing { &mut self.worksheet_drawing } - /// Set WorksheetDrawing. + /// Set `WorksheetDrawing`. /// # Arguments - /// * `value` - WorksheetDrawing + /// * `value` - `WorksheetDrawing` #[inline] pub fn set_worksheet_drawing(&mut self, value: WorksheetDrawing) { self.worksheet_drawing = value; } - /// Has WorksheetDrawing. + /// Has `WorksheetDrawing`. #[inline] + #[must_use] pub fn has_drawing_object(&self) -> bool { self.worksheet_drawing.has_drawing_object() } @@ -1009,6 +1034,7 @@ impl Worksheet { /// Get Code Name. #[inline] + #[must_use] pub fn get_code_name(&self) -> Option<&str> { self.code_name.get_value() } @@ -1023,6 +1049,7 @@ impl Worksheet { /// Get Header Footer. #[inline] + #[must_use] pub fn get_header_footer(&self) -> &HeaderFooter { &self.header_footer } @@ -1044,6 +1071,7 @@ impl Worksheet { /// Get Active Cell. #[inline] + #[must_use] pub fn get_active_cell(&self) -> &str { &self.active_cell } @@ -1071,6 +1099,7 @@ impl Worksheet { /// Get Sheet Id. #[inline] + #[must_use] pub fn get_sheet_id(&self) -> &str { &self.sheet_id } @@ -1084,12 +1113,14 @@ impl Worksheet { /// Has Code Name. #[inline] + #[must_use] pub fn has_code_name(&self) -> bool { self.code_name.has_value() } /// Get Tab Color. #[inline] + #[must_use] pub fn get_tab_color(&self) -> Option<&Color> { self.tab_color.as_ref() } @@ -1121,25 +1152,28 @@ impl Worksheet { } /// Calculate Worksheet Dimension. + #[must_use] pub fn calculate_worksheet_dimension(&self) -> String { let (column, row) = self.cell_collection.get_highest_column_and_row(); if row == 0 { return "A1".to_string(); } let column_str = string_from_column_index(column); - format!("A1:{}{}", column_str, row) + format!("A1:{column_str}{row}") } // Get Highest Column and Row Index /// # Return value /// *`(u32, u32)` - (column, row) #[inline] + #[must_use] pub fn get_highest_column_and_row(&self) -> (u32, u32) { self.cell_collection.get_highest_column_and_row() } // Get Highest Column Index #[inline] + #[must_use] pub fn get_highest_column(&self) -> u32 { let (column, _row) = self.cell_collection.get_highest_column_and_row(); column @@ -1147,18 +1181,20 @@ impl Worksheet { // Get Highest Row Index #[inline] + #[must_use] pub fn get_highest_row(&self) -> u32 { let (_column, row) = self.cell_collection.get_highest_column_and_row(); row } - /// Get SheetName. + /// Get `SheetName`. #[inline] + #[must_use] pub fn get_name(&self) -> &str { &self.title } - /// Set SheetName. + /// Set `SheetName`. /// # Arguments /// * `sheet_name` - Sheet Name. [Caution] no duplicate other worksheet. pub fn set_name>(&mut self, sheet_name: S) -> &mut Self { @@ -1176,6 +1212,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_state(&self) -> &SheetStateValues { self.state.get_value() } @@ -1198,6 +1235,7 @@ impl Worksheet { // Get Sheet State #[inline] + #[must_use] pub fn get_sheet_state(&self) -> &str { &self.sheet_state } @@ -1213,6 +1251,7 @@ impl Worksheet { // Get Page Setup. #[inline] + #[must_use] pub fn get_page_setup(&self) -> &PageSetup { &self.page_setup } @@ -1225,7 +1264,7 @@ impl Worksheet { /// Set Page Setup. /// # Arguments - /// * `value` - PageSetup. + /// * `value` - `PageSetup`. #[inline] pub fn set_page_setup(&mut self, value: PageSetup) -> &mut Self { self.page_setup = value; @@ -1234,6 +1273,7 @@ impl Worksheet { // Get Page Margins. #[inline] + #[must_use] pub fn get_page_margins(&self) -> &PageMargins { &self.page_margins } @@ -1246,7 +1286,7 @@ impl Worksheet { /// Set Page Margins. /// # Arguments - /// * `value` - PageMargins. + /// * `value` - `PageMargins`. #[inline] pub fn set_page_margins(&mut self, value: PageMargins) -> &mut Self { self.page_margins = value; @@ -1255,6 +1295,7 @@ impl Worksheet { // Get SheetViews. #[inline] + #[must_use] pub fn get_sheets_views(&self) -> &SheetViews { &self.sheet_views } @@ -1265,9 +1306,9 @@ impl Worksheet { &mut self.sheet_views } - /// Set SheetViews. + /// Set `SheetViews`. /// # Arguments - /// * `value` - SheetViews. + /// * `value` - `SheetViews`. #[inline] pub fn set_sheets_views(&mut self, value: SheetViews) -> &mut Self { self.sheet_views = value; @@ -1276,6 +1317,7 @@ impl Worksheet { // Get Ole Objects. #[inline] + #[must_use] pub fn get_ole_objects(&self) -> &OleObjects { &self.ole_objects } @@ -1288,7 +1330,7 @@ impl Worksheet { /// Set Ole Objects. /// # Arguments - /// * `value` - OleObjects. + /// * `value` - `OleObjects`. #[inline] pub fn set_ole_objects(&mut self, value: OleObjects) -> &mut Self { self.ole_objects = value; @@ -1297,6 +1339,7 @@ impl Worksheet { /// Get Defined Name (Vec). #[inline] + #[must_use] pub fn get_defined_names(&self) -> &[DefinedName] { &self.defined_names } @@ -1317,7 +1360,7 @@ impl Worksheet { /// Add Defined Name. /// # Arguments - /// * `value` - DefinedName. + /// * `value` - `DefinedName`. #[inline] pub fn add_defined_names(&mut self, value: DefinedName) { self.defined_names.push(value); @@ -1325,7 +1368,7 @@ impl Worksheet { /// Add Defined Name. /// # Arguments - /// * `name` - Name. ex) "DefinedName01" + /// * `name` - Name. ex) "`DefinedName01`" /// * `address` - Address. ex) "A1:A2" #[inline] pub fn add_defined_name>(&mut self, name: S, address: S) -> Result<(), &str> { @@ -1338,6 +1381,7 @@ impl Worksheet { /// Get Print Options. #[inline] + #[must_use] pub fn get_print_options(&self) -> &PrintOptions { &self.print_options } @@ -1350,7 +1394,7 @@ impl Worksheet { /// Set Print Options. /// # Arguments - /// * `value` - PrintOptions. + /// * `value` - `PrintOptions`. #[inline] pub fn set_print_options(&mut self, value: PrintOptions) -> &mut Self { self.print_options = value; @@ -1359,6 +1403,7 @@ impl Worksheet { /// Get Column Breaks. #[inline] + #[must_use] pub fn get_column_breaks(&self) -> &ColumnBreaks { &self.column_breaks } @@ -1371,7 +1416,7 @@ impl Worksheet { /// Set Column Breaks. /// # Arguments - /// * `value` - ColumnBreaks. + /// * `value` - `ColumnBreaks`. #[inline] pub fn set_column_breaks(&mut self, value: ColumnBreaks) -> &mut Self { self.column_breaks = value; @@ -1380,6 +1425,7 @@ impl Worksheet { /// Get Row Breaks. #[inline] + #[must_use] pub fn get_row_breaks(&self) -> &RowBreaks { &self.row_breaks } @@ -1392,7 +1438,7 @@ impl Worksheet { /// Set Row Breaks. /// # Arguments - /// * `value` - RowBreaks. + /// * `value` - `RowBreaks`. #[inline] pub fn set_row_breaks(&mut self, value: RowBreaks) -> &mut Self { self.row_breaks = value; @@ -1400,6 +1446,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn has_table(&self) -> bool { !self.tables.is_empty() } @@ -1410,6 +1457,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_tables(&self) -> &[Table] { &self.tables } @@ -1420,6 +1468,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn has_pivot_table(&self) -> bool { !self.pivot_tables.is_empty() } @@ -1430,6 +1479,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_pivot_tables(&self) -> &[PivotTable] { &self.pivot_tables } @@ -1440,6 +1490,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_data_validations(&self) -> Option<&DataValidations> { self.data_validations.as_ref() } @@ -1462,6 +1513,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_data_validations_2010(&self) -> Option<&DataValidations2010> { self.data_validations_2010.as_ref() } @@ -1484,6 +1536,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_sheet_format_properties(&self) -> &SheetFormatProperties { &self.sheet_format_properties } @@ -1503,6 +1556,7 @@ impl Worksheet { /// # Return value /// * `&Vec` - Image Object List. #[inline] + #[must_use] pub fn get_image_collection(&self) -> &[Image] { self.get_worksheet_drawing().get_image_collection() } @@ -1566,6 +1620,7 @@ impl Worksheet { /// # Return value /// * `&Vec` - Chart Object List. #[inline] + #[must_use] pub fn get_chart_collection(&self) -> &[Chart] { self.get_worksheet_drawing().get_chart_collection() } @@ -1718,6 +1773,7 @@ impl Worksheet { } #[inline] + #[must_use] pub fn get_sheet_protection(&self) -> Option<&SheetProtection> { self.sheet_protection.as_ref() } @@ -1787,18 +1843,10 @@ impl Worksheet { // impossible) let range_upper = range.to_uppercase(); let (row_start, row_end, col_start, col_end) = get_start_and_end_point(&range_upper); - if (col_start as i32 + column) < 1 { - panic!("Out of Range."); - } - if (row_start as i32 + row) < 1 { - panic!("Out of Range."); - } - if (col_end as i32 + column) > 16384 { - panic!("Out of Range."); - } - if (row_end as i32 + row) > 1048576 { - panic!("Out of Range."); - } + assert!(((col_start as i32 + column) >= 1), "Out of Range."); + assert!(((row_start as i32 + row) >= 1), "Out of Range."); + assert!(((col_end as i32 + column) <= 16384), "Out of Range."); + assert!(((row_end as i32 + row) <= 1048576), "Out of Range."); // Iterate row by row, collecting cell information (do I copy) let cells = self.cell_collection.get_cell_by_range(range); @@ -1806,15 +1854,13 @@ impl Worksheet { // Delete cell information as iterating through in move mode if is_move { - get_coordinate_list(&range_upper) - .iter() - .for_each(|(col_num, row_num)| { - self.cell_collection.remove(*col_num, *row_num); - self.cell_collection.remove( - (*col_num as i32 + column) as u32, - (*row_num as i32 + row) as u32, - ); - }); + for (col_num, row_num) in &get_coordinate_list(&range_upper) { + self.cell_collection.remove(*col_num, *row_num); + self.cell_collection.remove( + (*col_num as i32 + column) as u32, + (*row_num as i32 + row) as u32, + ); + } } // repaste by setting cell values diff --git a/src/structs/worksheet_source.rs b/src/structs/worksheet_source.rs index 326b89c6..20efac5e 100644 --- a/src/structs/worksheet_source.rs +++ b/src/structs/worksheet_source.rs @@ -1,7 +1,7 @@ // worksheetSource -use crate::reader::driver::*; +use crate::reader::driver::get_attribute; use crate::structs::Address; -use crate::writer::driver::*; +use crate::writer::driver::write_start_tag; use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; @@ -13,6 +13,7 @@ pub struct WorksheetSource { } impl WorksheetSource { + #[must_use] pub fn get_address(&self) -> &Address { &self.address } diff --git a/src/structs/writer_manager.rs b/src/structs/writer_manager.rs index 3ee97e18..73d84ea9 100644 --- a/src/structs/writer_manager.rs +++ b/src/structs/writer_manager.rs @@ -1,7 +1,12 @@ -use crate::helper::const_str::*; +use crate::helper::const_str::{ + CHART_TYPE, COMMENTS_TYPE, CORE_PROPS_TYPE, CUSTOM_PROPS_TYPE, DRAWING_TYPE, OLE_OBJECT_TYPE, + PKG_CHARTS, PKG_DRAWINGS, PKG_EMBEDDINGS, PKG_PRNTR_SETTINGS, PKG_TABLES, SHARED_STRINGS_TYPE, + SHEET_TYPE, STYLES_TYPE, TABLE_TYPE, THEME_TYPE, VBA_TYPE, WORKBOOK_MACRO_TYPE, WORKBOOK_TYPE, + XPROPS_TYPE, +}; use crate::structs::Spreadsheet; use crate::structs::XlsxError; -use crate::writer::driver::*; +use crate::writer::driver::{make_file_from_bin, make_file_from_writer}; use quick_xml::Writer; use std::io; use std::io::Cursor; @@ -30,11 +35,13 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { } #[inline] + #[must_use] pub fn get_is_light(&self) -> bool { self.is_light } #[inline] + #[must_use] pub fn get_num_tables(&self) -> i32 { self.table_no } @@ -91,7 +98,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut index = 0; loop { index += 1; - let file_path = format!("{}/drawing{}.xml", PKG_DRAWINGS, index); + let file_path = format!("{PKG_DRAWINGS}/drawing{index}.xml"); if !self.check_file_exist(&file_path) { self.add_writer(&file_path, writer)?; return Ok(index); @@ -106,7 +113,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut index = 0; loop { index += 1; - let file_path = format!("{}/vmlDrawing{}.vml", PKG_DRAWINGS, index); + let file_path = format!("{PKG_DRAWINGS}/vmlDrawing{index}.vml"); if !self.check_file_exist(&file_path) { self.add_writer(&file_path, writer)?; return Ok(index); @@ -121,7 +128,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut index = 0; loop { index += 1; - let file_path = format!("xl/comments{}.xml", index); + let file_path = format!("xl/comments{index}.xml"); if !self.check_file_exist(&file_path) { self.add_writer(&file_path, writer)?; return Ok(index); @@ -136,7 +143,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut index = 0; loop { index += 1; - let file_path = format!("{}/chart{}.xml", PKG_CHARTS, index); + let file_path = format!("{PKG_CHARTS}/chart{index}.xml"); if !self.check_file_exist(&file_path) { self.add_writer(&file_path, writer)?; return Ok(index); @@ -148,7 +155,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut index = 0; loop { index += 1; - let file_path = format!("{}/oleObject{}.bin", PKG_EMBEDDINGS, index); + let file_path = format!("{PKG_EMBEDDINGS}/oleObject{index}.bin"); if !self.check_file_exist(&file_path) { self.add_bin(&file_path, writer)?; return Ok(index); @@ -160,7 +167,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut index = 0; loop { index += 1; - let file_path = format!("{}/Microsoft_Excel_Worksheet{}.xlsx", PKG_EMBEDDINGS, index); + let file_path = format!("{PKG_EMBEDDINGS}/Microsoft_Excel_Worksheet{index}.xlsx"); if !self.check_file_exist(&file_path) { self.add_bin(&file_path, writer)?; return Ok(index); @@ -172,7 +179,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut index = 0; loop { index += 1; - let file_path = format!("{}/printerSettings{}.bin", PKG_PRNTR_SETTINGS, index); + let file_path = format!("{PKG_PRNTR_SETTINGS}/printerSettings{index}.bin"); if !self.check_file_exist(&file_path) { self.add_bin(&file_path, writer)?; return Ok(index); @@ -186,14 +193,14 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { writer: Writer>>, table_no: i32, ) -> Result { - let file_path = format!("{}/table{}.xml", PKG_TABLES, table_no); + let file_path = format!("{PKG_TABLES}/table{table_no}.xml"); self.add_writer(&file_path, writer)?; Ok(table_no) } #[inline] pub(crate) fn has_extension(&self, extension: &str) -> bool { - let extension = format!(".{}", extension); + let extension = format!(".{extension}"); self.files.iter().any(|file| file.ends_with(&extension)) } @@ -205,7 +212,7 @@ impl<'a, W: io::Seek + io::Write> WriterManager<'a, W> { let mut list: Vec<(String, String)> = Vec::new(); for file in &self.files { - let file = format!("/{}", file); + let file = format!("/{file}"); let mut content_type = ""; // Override workbook diff --git a/src/writer/csv.rs b/src/writer/csv.rs index 110f0517..b0ee143a 100644 --- a/src/writer/csv.rs +++ b/src/writer/csv.rs @@ -25,14 +25,14 @@ pub fn write_writer( // get max column and row. let (max_column, max_row) = worksheet.get_highest_column_and_row(); - let mut data = String::from(""); + let mut data = String::new(); for row in 0u32..max_row { let mut row_vec: Vec = Vec::new(); for column in 0u32..max_column { // get value. let mut value = match worksheet.get_cell((column + 1, row + 1)) { Some(cell) => cell.get_cell_value().get_value().into(), - None => String::from(""), + None => String::new(), }; // do trim. if option.get_do_trim() { @@ -83,7 +83,7 @@ pub fn write_writer( /// option.set_csv_encode_value(structs::CsvEncodeValues::ShiftJis); /// option.set_do_trim(true); /// option.set_wrap_with_char("\""); -/// let _ = writer::csv::write(&book, path, Some(&option)); +/// let _unused = writer::csv::write(&book, path, Some(&option)); /// ``` pub fn write>( spreadsheet: &Spreadsheet, @@ -101,7 +101,7 @@ pub fn write>( }; if let Err(v) = write_writer( spreadsheet, - &mut io::BufWriter::new(fs::File::create(path_tmp.as_ref() as &Path)?), + &mut io::BufWriter::new(fs::File::create::<&Path>(path_tmp.as_ref())?), option, ) { fs::remove_file(path_tmp)?; diff --git a/src/writer/driver.rs b/src/writer/driver.rs index 85047dfb..7af4ea9c 100644 --- a/src/writer/driver.rs +++ b/src/writer/driver.rs @@ -1,4 +1,4 @@ -use quick_xml::escape::*; +use quick_xml::escape::partial_escape; use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event}; use quick_xml::Writer; use std::borrow::Cow; @@ -69,7 +69,7 @@ pub(crate) fn write_new_line(writer: &mut Writer>>) { } #[inline] -pub(crate) fn make_file_from_writer( +pub(crate) fn make_file_from_writer( path: &str, arv: &mut zip::ZipWriter, writer: Writer>>, @@ -80,7 +80,7 @@ pub(crate) fn make_file_from_writer( } #[inline] -pub(crate) fn make_file_from_bin( +pub(crate) fn make_file_from_bin( path: &str, arv: &mut zip::ZipWriter, writer: &[u8], @@ -99,7 +99,7 @@ pub(crate) fn make_file_from_bin( #[inline] pub(crate) fn to_path<'a>(path: &'a str, dir: Option<&'a str>) -> Cow<'a, str> { match dir { - Some(dir) => Cow::Owned(format!("{}/{}", dir, path)), + Some(dir) => Cow::Owned(format!("{dir}/{path}")), None => Cow::Borrowed(path), } } diff --git a/src/writer/xlsx.rs b/src/writer/xlsx.rs index 345240f3..dd8883ac 100644 --- a/src/writer/xlsx.rs +++ b/src/writer/xlsx.rs @@ -1,5 +1,5 @@ use super::driver; -use crate::helper::crypt::*; +use crate::helper::crypt::encrypt; use crate::structs::Spreadsheet; use crate::structs::WriterManager; use crate::XlsxError; @@ -33,8 +33,8 @@ mod workbook_rels; mod worksheet; mod worksheet_rels; -fn make_buffer(spreadsheet: &Spreadsheet, is_light: bool) -> Result, XlsxError> { - let mut arv = zip::ZipWriter::new(std::io::Cursor::new(Vec::new())); +fn make_buffer(spreadsheet: &Spreadsheet, is_light: bool) -> Result, XlsxError> { + let mut arv = zip::ZipWriter::new(io::Cursor::new(Vec::new())); let mut writer_manager = WriterManager::new(&mut arv); writer_manager.set_is_light(is_light); @@ -128,7 +128,7 @@ fn make_buffer(spreadsheet: &Spreadsheet, is_light: bool) -> Result printer_settings::write(worksheet, &mut writer_manager)?, - None => String::from(""), + None => String::new(), }; // Add tables @@ -213,7 +213,7 @@ pub fn write_writer_light( /// ``` /// let mut book = umya_spreadsheet::new_file(); /// let path = std::path::Path::new("./tests/result_files/zzz.xlsx"); -/// let _ = umya_spreadsheet::writer::xlsx::write(&book, path); +/// let _unused = umya_spreadsheet::writer::xlsx::write(&book, path); /// ``` pub fn write>(spreadsheet: &Spreadsheet, path: P) -> Result<(), XlsxError> { let extension = path.as_ref().extension().unwrap().to_str().unwrap(); @@ -222,7 +222,7 @@ pub fn write>(spreadsheet: &Spreadsheet, path: P) -> Result<(), X .with_extension(format!("{}{}", extension, "tmp")); if let Err(v) = write_writer( spreadsheet, - &mut io::BufWriter::new(fs::File::create(&path_tmp)?), + &mut io::BufWriter::new(File::create(&path_tmp)?), ) { fs::remove_file(path_tmp)?; return Err(v); @@ -241,7 +241,7 @@ pub fn write>(spreadsheet: &Spreadsheet, path: P) -> Result<(), X /// ``` /// let mut book = umya_spreadsheet::new_file(); /// let path = std::path::Path::new("./tests/result_files/zzz.xlsx"); -/// let _ = umya_spreadsheet::writer::xlsx::write_light(&book, path); +/// let _unused = umya_spreadsheet::writer::xlsx::write_light(&book, path); /// ``` pub fn write_light>(spreadsheet: &Spreadsheet, path: P) -> Result<(), XlsxError> { let extension = path.as_ref().extension().unwrap().to_str().unwrap(); @@ -250,7 +250,7 @@ pub fn write_light>(spreadsheet: &Spreadsheet, path: P) -> Result .with_extension(format!("{}{}", extension, "tmp")); if let Err(v) = write_writer_light( spreadsheet, - &mut io::BufWriter::new(fs::File::create(&path_tmp)?), + &mut io::BufWriter::new(File::create(&path_tmp)?), ) { fs::remove_file(path_tmp)?; return Err(v); @@ -270,7 +270,7 @@ pub fn write_light>(spreadsheet: &Spreadsheet, path: P) -> Result /// ``` /// let mut book = umya_spreadsheet::new_file(); /// let path = std::path::Path::new("./tests/result_files/zzz_password.xlsx"); -/// let _ = umya_spreadsheet::writer::xlsx::write_with_password(&book, path, "password"); +/// let _unused = umya_spreadsheet::writer::xlsx::write_with_password(&book, path, "password"); /// ``` pub fn write_with_password>( spreadsheet: &Spreadsheet, @@ -307,7 +307,7 @@ pub fn write_with_password>( /// ``` /// let mut book = umya_spreadsheet::new_file(); /// let path = std::path::Path::new("./tests/result_files/zzz_password.xlsx"); -/// let _ = umya_spreadsheet::writer::xlsx::write_with_password_light(&book, path, "password"); +/// let _unused = umya_spreadsheet::writer::xlsx::write_with_password_light(&book, path, "password"); /// ``` pub fn write_with_password_light>( spreadsheet: &Spreadsheet, @@ -344,7 +344,7 @@ pub fn write_with_password_light>( /// ``` /// let from_path = std::path::Path::new("./tests/test_files/aaa.xlsx"); /// let to_path = std::path::Path::new("./tests/result_files/zzz_password2.xlsx"); -/// let _ = umya_spreadsheet::writer::xlsx::set_password(&from_path, &to_path, "password"); +/// let _unused = umya_spreadsheet::writer::xlsx::set_password(&from_path, &to_path, "password"); /// ``` pub fn set_password>( from_path: P, diff --git a/src/writer/xlsx/chart.rs b/src/writer/xlsx/chart.rs index e11ddc88..6eb8124c 100644 --- a/src/writer/xlsx/chart.rs +++ b/src/writer/xlsx/chart.rs @@ -1,4 +1,4 @@ -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; use crate::structs::drawing::charts::ChartSpace; use crate::structs::Spreadsheet; diff --git a/src/writer/xlsx/comment.rs b/src/writer/xlsx/comment.rs index b54430f7..0ac20ccf 100644 --- a/src/writer/xlsx/comment.rs +++ b/src/writer/xlsx/comment.rs @@ -1,6 +1,6 @@ -use super::driver::*; +use super::driver::{write_end_tag, write_new_line, write_start_tag, write_text_node}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::SHEET_MAIN_NS; use crate::structs::Worksheet; use crate::structs::WriterManager; use quick_xml::events::{BytesDecl, Event}; diff --git a/src/writer/xlsx/content_types.rs b/src/writer/xlsx/content_types.rs index 966b48c5..ec1920e2 100644 --- a/src/writer/xlsx/content_types.rs +++ b/src/writer/xlsx/content_types.rs @@ -2,9 +2,11 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::{make_file_from_writer, write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{ + CONTENT_TYPES, CONTYPES_NS, PRNTR_SETTINGS_TYPE, REL_TYPE, VML_DRAWING_TYPE, WORKBOOK, +}; use crate::structs::Spreadsheet; use crate::structs::WriterManager; diff --git a/src/writer/xlsx/doc_props_app.rs b/src/writer/xlsx/doc_props_app.rs index ba42457e..212f1889 100644 --- a/src/writer/xlsx/doc_props_app.rs +++ b/src/writer/xlsx/doc_props_app.rs @@ -2,9 +2,9 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::ARC_APP; use crate::structs::Spreadsheet; use crate::structs::WriterManager; diff --git a/src/writer/xlsx/doc_props_core.rs b/src/writer/xlsx/doc_props_core.rs index 63e7746d..c020dea0 100644 --- a/src/writer/xlsx/doc_props_core.rs +++ b/src/writer/xlsx/doc_props_core.rs @@ -2,9 +2,9 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::ARC_CORE; use crate::structs::Spreadsheet; use crate::structs::WriterManager; diff --git a/src/writer/xlsx/doc_props_custom.rs b/src/writer/xlsx/doc_props_custom.rs index 725f549c..1bb216ee 100644 --- a/src/writer/xlsx/doc_props_custom.rs +++ b/src/writer/xlsx/doc_props_custom.rs @@ -2,9 +2,9 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::ARC_CUSTOM; use crate::structs::Spreadsheet; use crate::structs::WriterManager; diff --git a/src/writer/xlsx/drawing.rs b/src/writer/xlsx/drawing.rs index 43ed52bd..cf8ea7cd 100644 --- a/src/writer/xlsx/drawing.rs +++ b/src/writer/xlsx/drawing.rs @@ -2,7 +2,7 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; use crate::structs::Worksheet; use crate::structs::WriterManager; @@ -14,7 +14,7 @@ pub(crate) fn write( let mut rel_list: Vec<(String, String)> = Vec::new(); if !worksheet.has_drawing_object() { - return Ok((String::from(""), rel_list)); + return Ok((String::new(), rel_list)); } let mut writer = Writer::new(io::Cursor::new(Vec::new())); diff --git a/src/writer/xlsx/drawing_rels.rs b/src/writer/xlsx/drawing_rels.rs index 9fb72a5e..80f6a555 100644 --- a/src/writer/xlsx/drawing_rels.rs +++ b/src/writer/xlsx/drawing_rels.rs @@ -2,9 +2,9 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::{write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{CHART_NS, IMAGE_NS, PKG_DRAWINGS_RELS, REL_NS}; use crate::structs::Worksheet; use crate::structs::WriterManager; @@ -37,7 +37,7 @@ pub(crate) fn write( &mut writer, r_id, CHART_NS, - format!("../charts/chart{}.xml", chart_no).as_str(), + format!("../charts/chart{chart_no}.xml").as_str(), "", ); r_id += 1; @@ -50,7 +50,7 @@ pub(crate) fn write( &mut writer, r_id, IMAGE_NS, - format!("../media/{}", value).as_str(), + format!("../media/{value}").as_str(), "", ); } @@ -59,7 +59,7 @@ pub(crate) fn write( write_end_tag(&mut writer, "Relationships"); if is_write { - let file_path = format!("{PKG_DRAWINGS_RELS}{}.xml.rels", drawing_no); + let file_path = format!("{PKG_DRAWINGS_RELS}{drawing_no}.xml.rels"); return writer_mng.add_writer(&file_path, writer); } Ok(()) @@ -72,7 +72,7 @@ fn write_relationship( p_target: &str, p_target_mode: &str, ) -> bool { - let r_id_str = format!("rId{}", r_id); + let r_id_str = format!("rId{r_id}"); let mut attributes: Vec<(&str, &str)> = Vec::new(); attributes.push(("Id", &r_id_str)); attributes.push(("Type", p_type)); diff --git a/src/writer/xlsx/media.rs b/src/writer/xlsx/media.rs index 61dd7649..62fdc4d1 100644 --- a/src/writer/xlsx/media.rs +++ b/src/writer/xlsx/media.rs @@ -1,7 +1,7 @@ use std::io; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_MEDIA; use crate::structs::Worksheet; use crate::structs::WriterManager; diff --git a/src/writer/xlsx/rels.rs b/src/writer/xlsx/rels.rs index e1fa3d16..44b093ee 100644 --- a/src/writer/xlsx/rels.rs +++ b/src/writer/xlsx/rels.rs @@ -2,9 +2,12 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::{write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{ + ARC_APP, ARC_CORE, ARC_CUSTOM, COREPROPS_REL, CUSTOMUI_NS, CUSTOM_PROPS_REL, OFCDOC_NS, + PKG_WORKBOOK, REL_NS, XPROPS_REL, +}; use crate::structs::Spreadsheet; use crate::structs::WriterManager; @@ -71,7 +74,7 @@ fn write_relationship( ) { let tag_name = "Relationship"; let mut attributes: Vec<(&str, &str)> = Vec::new(); - let r_id = format!("rId{}", p_id); + let r_id = format!("rId{p_id}"); attributes.push(("Id", r_id.as_str())); attributes.push(("Type", p_type)); attributes.push(("Target", p_target)); diff --git a/src/writer/xlsx/shared_strings.rs b/src/writer/xlsx/shared_strings.rs index bc2f5adb..c637993d 100644 --- a/src/writer/xlsx/shared_strings.rs +++ b/src/writer/xlsx/shared_strings.rs @@ -1,19 +1,18 @@ -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_SHARED_STRINGS; use crate::structs::SharedStringTable; use crate::structs::WriterManager; use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use std::result; use std::sync::Arc; use std::sync::RwLock; pub(crate) fn write( shared_string_table: Arc>, writer_mng: &mut WriterManager, -) -> result::Result<(), XlsxError> { +) -> Result<(), XlsxError> { if shared_string_table .read() .unwrap() diff --git a/src/writer/xlsx/styles.rs b/src/writer/xlsx/styles.rs index 9b9a69a1..26ae1c14 100644 --- a/src/writer/xlsx/styles.rs +++ b/src/writer/xlsx/styles.rs @@ -1,6 +1,6 @@ -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_STYLES; use crate::structs::Stylesheet; use crate::structs::WriterManager; use quick_xml::events::{BytesDecl, Event}; diff --git a/src/writer/xlsx/table.rs b/src/writer/xlsx/table.rs index 32183c7c..eaad0329 100644 --- a/src/writer/xlsx/table.rs +++ b/src/writer/xlsx/table.rs @@ -1,7 +1,10 @@ use std::io; -use super::{driver::*, XlsxError}; -use crate::helper::const_str::*; +use super::{ + driver::{write_end_tag, write_new_line, write_start_tag, write_text_node}, + XlsxError, +}; +use crate::helper::const_str::SHEET_MAIN_NS; use crate::structs::{Worksheet, WriterManager}; use quick_xml::{ events::{BytesDecl, Event}, @@ -13,7 +16,7 @@ pub(crate) fn write( writer_mng: &mut WriterManager, ) -> Result, XlsxError> { let mut table_no_list = Vec::::new(); - for table in worksheet.get_tables().iter() { + for table in worksheet.get_tables() { let mut writer = Writer::new(io::Cursor::new(Vec::new())); // XML header @@ -62,7 +65,7 @@ pub(crate) fn write( false, ); let mut col_id = 1; - for col in cols.iter() { + for col in cols { let mut attributes: Vec<(&str, &str)> = Vec::new(); let col_id_str = col_id.to_string(); attributes.push(("id", &col_id_str)); @@ -96,19 +99,19 @@ pub(crate) fn write( ("name", style_info.get_name()), ( "showFirstColumn", - &(style_info.is_show_first_col() as i32).to_string(), + &i32::from(style_info.is_show_first_col()).to_string(), ), ( "showLastColumn", - &(style_info.is_show_last_col() as i32).to_string(), + &i32::from(style_info.is_show_last_col()).to_string(), ), ( "showRowStripes", - &(style_info.is_show_row_stripes() as i32).to_string(), + &i32::from(style_info.is_show_row_stripes()).to_string(), ), ( "showColumnStripes", - &(style_info.is_show_col_stripes() as i32).to_string(), + &i32::from(style_info.is_show_col_stripes()).to_string(), ), ], true, diff --git a/src/writer/xlsx/theme.rs b/src/writer/xlsx/theme.rs index 57164a31..0639253a 100644 --- a/src/writer/xlsx/theme.rs +++ b/src/writer/xlsx/theme.rs @@ -2,9 +2,9 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::write_new_line; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_THEME; use crate::structs::drawing::Theme; use crate::structs::WriterManager; diff --git a/src/writer/xlsx/vba_project_bin.rs b/src/writer/xlsx/vba_project_bin.rs index ddd9dddf..dcdd321c 100644 --- a/src/writer/xlsx/vba_project_bin.rs +++ b/src/writer/xlsx/vba_project_bin.rs @@ -1,7 +1,7 @@ use std::io; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::PKG_VBA_PROJECT; use crate::structs::Spreadsheet; use crate::structs::WriterManager; diff --git a/src/writer/xlsx/vml_drawing.rs b/src/writer/xlsx/vml_drawing.rs index 23707ee5..a7091a31 100644 --- a/src/writer/xlsx/vml_drawing.rs +++ b/src/writer/xlsx/vml_drawing.rs @@ -1,6 +1,6 @@ -use super::driver::*; +use super::driver::{write_end_tag, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{EXCEL_NS, OFFICE_NS, VML_NS}; use crate::structs::Worksheet; use crate::structs::WriterManager; use quick_xml::Writer; @@ -12,7 +12,7 @@ pub(crate) fn write( ) -> Result<(String, Vec<(String, String)>), XlsxError> { let mut rel_list: Vec<(String, String)> = Vec::new(); if !worksheet.has_legacy_drawing() { - return Ok((String::from(""), rel_list)); + return Ok((String::new(), rel_list)); } let mut writer = Writer::new(io::Cursor::new(Vec::new())); diff --git a/src/writer/xlsx/vml_drawing_rels.rs b/src/writer/xlsx/vml_drawing_rels.rs index cf560b4f..2b4a5e1f 100644 --- a/src/writer/xlsx/vml_drawing_rels.rs +++ b/src/writer/xlsx/vml_drawing_rels.rs @@ -2,9 +2,9 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::{write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{IMAGE_NS, PKG_VML_DRAWING_RELS, REL_NS}; use crate::structs::Worksheet; use crate::structs::WriterManager; @@ -37,7 +37,7 @@ pub(crate) fn write( &mut writer, r_id, IMAGE_NS, - format!("../media/{}", value).as_str(), + format!("../media/{value}").as_str(), "", ); } @@ -47,7 +47,7 @@ pub(crate) fn write( write_end_tag(&mut writer, "Relationships"); if is_write { - let file_path = format!("{PKG_VML_DRAWING_RELS}{}.vml.rels", vml_drawing_no); + let file_path = format!("{PKG_VML_DRAWING_RELS}{vml_drawing_no}.vml.rels"); return writer_mng.add_writer(&file_path, writer); } Ok(()) @@ -61,7 +61,7 @@ fn write_relationship( p_target_mode: &str, ) -> bool { let tag_name = "Relationship"; - let r_id_str = format!("rId{}", r_id); + let r_id_str = format!("rId{r_id}"); let mut attributes: Vec<(&str, &str)> = Vec::new(); attributes.push(("Id", &r_id_str)); attributes.push(("Type", p_type)); diff --git a/src/writer/xlsx/workbook.rs b/src/writer/xlsx/workbook.rs index 31f8ec6a..4acdbb03 100644 --- a/src/writer/xlsx/workbook.rs +++ b/src/writer/xlsx/workbook.rs @@ -2,9 +2,9 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::{write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{PKG_WORKBOOK, REL_OFC_NS, SHEET_MAIN_NS}; use crate::structs::Spreadsheet; use crate::structs::WriterManager; @@ -76,7 +76,7 @@ pub(crate) fn write( for worksheet in spreadsheet.get_sheet_collection_no_check() { let mut attributes: Vec<(&str, &str)> = Vec::new(); let id = index.to_string(); - let r_id = format!("rId{}", index); + let r_id = format!("rId{index}"); attributes.push(("name", worksheet.get_name())); attributes.push(("sheetId", &id)); attributes.push(("r:id", &r_id)); @@ -127,7 +127,7 @@ pub(crate) fn write( if !pivot_cache_definition_collection.is_empty() { write_start_tag(&mut writer, "pivotCaches", vec![], false); for (_, val2, _) in pivot_cache_definition_collection { - let r_id = format!("rId{}", index); + let r_id = format!("rId{index}"); write_start_tag( &mut writer, "pivotCache", diff --git a/src/writer/xlsx/workbook_rels.rs b/src/writer/xlsx/workbook_rels.rs index 12c39db5..a9734652 100644 --- a/src/writer/xlsx/workbook_rels.rs +++ b/src/writer/xlsx/workbook_rels.rs @@ -2,9 +2,12 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::{make_file_from_writer, write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{ + PIVOT_CACHE_DEF_NS, PKG_WORKBOOK_RELS, REL_NS, SHARED_STRINGS_NS, STYLES_NS, THEME_NS, + VBA_PROJECT_NS, WORKSHEET_NS, +}; use crate::structs::Spreadsheet; use crate::structs::WriterManager; @@ -34,7 +37,7 @@ pub(crate) fn write( // relationships worksheet for _ in spreadsheet.get_sheet_collection_no_check() { - let path_str = format!("worksheets/sheet{}.xml", index); + let path_str = format!("worksheets/sheet{index}.xml"); write_relationship(&mut writer, &index.to_string(), WORKSHEET_NS, &path_str, ""); index += 1; } @@ -108,7 +111,7 @@ fn write_relationship( ) { let tag_name = "Relationship"; let mut attributes: Vec<(&str, &str)> = Vec::new(); - let r_id = format!("rId{}", p_id); + let r_id = format!("rId{p_id}"); attributes.push(("Id", r_id.as_str())); attributes.push(("Type", p_type)); attributes.push(("Target", p_target)); diff --git a/src/writer/xlsx/worksheet.rs b/src/writer/xlsx/worksheet.rs index ad6a1325..702bc3ae 100644 --- a/src/writer/xlsx/worksheet.rs +++ b/src/writer/xlsx/worksheet.rs @@ -1,6 +1,8 @@ -use super::driver::*; +use super::driver::{write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{ + MC_NS, PKG_SHEET, REL_OFC_NS, SHEETML_AC_NS, SHEET_DRAWING_NS, SHEET_MAIN_NS, SHEET_MS_MAIN_NS, +}; use crate::structs::Cell; use crate::structs::SharedStringTable; use crate::structs::Stylesheet; @@ -287,7 +289,7 @@ pub(crate) fn write( vec![("count", &tables.len().to_string())], false, ); - for _table in worksheet.get_tables().iter() { + for _table in worksheet.get_tables() { let r_id_str = format!("rId{}", &r_id); write_start_tag( &mut writer, @@ -317,6 +319,6 @@ pub(crate) fn write( write_end_tag(&mut writer, "worksheet"); - let target = format!("{PKG_SHEET}{}.xml", sheet_no); + let target = format!("{PKG_SHEET}{sheet_no}.xml"); writer_mng.add_writer(&target, writer) } diff --git a/src/writer/xlsx/worksheet_rels.rs b/src/writer/xlsx/worksheet_rels.rs index 89897642..e63e2606 100644 --- a/src/writer/xlsx/worksheet_rels.rs +++ b/src/writer/xlsx/worksheet_rels.rs @@ -2,9 +2,12 @@ use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; use std::io; -use super::driver::*; +use super::driver::{write_end_tag, write_new_line, write_start_tag}; use super::XlsxError; -use crate::helper::const_str::*; +use crate::helper::const_str::{ + COMMENTS_NS, DRAWINGS_NS, HYPERLINK_NS, IMAGE_NS, OLE_OBJECT_NS, PACKAGE_NS, PKG_SHEET_RELS, + PRINTER_SETTINGS_NS, REL_NS, TABLE_NS, VML_DRAWING_NS, +}; use crate::structs::Worksheet; use crate::structs::WriterManager; @@ -55,12 +58,12 @@ pub(crate) fn write( // write pageSetup if worksheet.get_page_setup().get_object_data().is_some() { - let object_name = format!("printerSettings{}.bin", printer_settings_no); + let object_name = format!("printerSettings{printer_settings_no}.bin"); is_write = write_relationship( &mut writer, r_id.to_string().as_str(), PRINTER_SETTINGS_NS, - format!("../printerSettings/{}", object_name).as_str(), + format!("../printerSettings/{object_name}").as_str(), "", ); r_id += 1; @@ -95,7 +98,7 @@ pub(crate) fn write( } // write table relationships - for table_no in table_no_list.iter() { + for table_no in table_no_list { is_write = write_relationship( &mut writer, r_id.to_string().as_str(), @@ -112,24 +115,24 @@ pub(crate) fn write( for ole_object in worksheet.get_ole_objects().get_ole_object() { if ole_object.is_xlsx() { let excel_no = excel_no_list.next().unwrap(); - let object_name = format!("Microsoft_Excel_Worksheet{}.xlsx", excel_no); + let object_name = format!("Microsoft_Excel_Worksheet{excel_no}.xlsx"); write_relationship( &mut writer, r_id.to_string().as_str(), PACKAGE_NS, - format!("../embeddings/{}", object_name).as_str(), + format!("../embeddings/{object_name}").as_str(), "", ); r_id += 1; } if ole_object.is_bin() { let ole_object_no = ole_object_no_list.next().unwrap(); - let object_name = format!("oleObject{}.bin", ole_object_no); + let object_name = format!("oleObject{ole_object_no}.bin"); write_relationship( &mut writer, r_id.to_string().as_str(), OLE_OBJECT_NS, - format!("../embeddings/{}", object_name).as_str(), + format!("../embeddings/{object_name}").as_str(), "", ); r_id += 1; @@ -143,7 +146,7 @@ pub(crate) fn write( &mut writer, r_id.to_string().as_str(), IMAGE_NS, - format!("../media/{}", image_name).as_str(), + format!("../media/{image_name}").as_str(), "", ); r_id += 1; @@ -163,7 +166,7 @@ pub(crate) fn write( write_end_tag(&mut writer, "Relationships"); if is_write { - let file_path = format!("{PKG_SHEET_RELS}{}.xml.rels", worksheet_no); + let file_path = format!("{PKG_SHEET_RELS}{worksheet_no}.xml.rels"); writer_mng.add_writer(&file_path, writer)?; } Ok(()) @@ -178,7 +181,7 @@ fn write_relationship( ) -> bool { let tag_name = "Relationship"; let mut attributes: Vec<(&str, &str)> = Vec::new(); - let r_id = format!("rId{}", p_id); + let r_id = format!("rId{p_id}"); attributes.push(("Id", r_id.as_str())); attributes.push(("Type", p_type)); attributes.push(("Target", p_target)); diff --git a/tests/integration_test.rs b/tests/integration_test.rs index d3f0e7c9..57f30bcb 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -12,7 +12,7 @@ use umya_spreadsheet::*; fn read_and_wite() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); read_and_wite_method(&mut book); book.get_sheet_by_name("Sheet1") @@ -29,19 +29,19 @@ fn read_and_wite() { // writer let path = std::path::Path::new("./tests/result_files/bbb.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn read_and_wite_with_password() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); read_and_wite_method(&mut book); // writer let path = std::path::Path::new("./tests/result_files/bbb_password.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write_with_password(&book, path, "password"); + let _unused = writer::xlsx::write_with_password(&book, path, "password"); } #[test] @@ -49,37 +49,37 @@ fn wite_with_password() { // writer let from_path = std::path::Path::new("./tests/test_files/aaa.xlsx"); let to_path = std::path::Path::new("./tests/result_files/bbb_password2.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::set_password(&from_path, &to_path, "password"); + let _unused = writer::xlsx::set_password(&from_path, &to_path, "password"); } #[test] fn lazy_read_and_wite() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); read_and_wite_method(&mut book); // writer let path = std::path::Path::new("./tests/result_files/bbb_lazy.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn read_and_wite_libre2() { // reader let path = std::path::Path::new("./tests/test_files/libre2.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/libre2.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn read_large_string() { // reader let path = std::path::Path::new("./tests/test_files/aaa_large_string.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); //let _ns = book.get_sheet_by_name_mut("Sheet1").unwrap(); } @@ -88,7 +88,7 @@ fn lazy_read_and_wite_large_string() { // reader let start = Instant::now(); let path = std::path::Path::new("./tests/test_files/aaa_large_string.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); let ns = book.new_sheet("new sheet").unwrap(); let end = start.elapsed(); println!("read:{}.{:03}sec.", end.as_secs(), end.subsec_millis()); @@ -97,7 +97,7 @@ fn lazy_read_and_wite_large_string() { for r in 1..5000 { for c in 1..30 { let cell = ns.get_cell_mut((c, r)); - let _ = cell.set_value_string(format!("r{}c{}", r, c)); + let _unused = cell.set_value_string(format!("r{}c{}", r, c)); } } let end = start.elapsed(); @@ -106,7 +106,7 @@ fn lazy_read_and_wite_large_string() { // writer let start = Instant::now(); let path = std::path::Path::new("./tests/result_files/bbb_large_string.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); let end = start.elapsed(); println!("write:{}.{:03}sec.", end.as_secs(), end.subsec_millis()); } @@ -115,7 +115,7 @@ fn lazy_read_and_wite_large_string() { fn lazy_read_and_wite_no_edit() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let book = reader::xlsx::lazy_read(path).unwrap(); let cells = book.get_lazy_read_sheet_cells(0).unwrap(); assert_eq!("英語", cells.get_cell_value((5, 12)).get_value()); @@ -123,21 +123,21 @@ fn lazy_read_and_wite_no_edit() { // writer let path = std::path::Path::new("./tests/result_files/bbb_lazy_no_edit.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } -fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { - let _ = book +fn read_and_wite_method(book: &mut Spreadsheet) { + let _unused = book .get_sheet_mut(0) .unwrap() .get_cell_mut("A1") .set_value("TEST1"); let a1_value = book.get_sheet(0).unwrap().get_value("A1"); assert_eq!("TEST1", a1_value); - let _ = book.get_sheet_mut(0).unwrap().remove_cell((1, 1)); + let _unused = book.get_sheet_mut(0).unwrap().remove_cell((1, 1)); let a1 = book.get_sheet(0).unwrap().get_cell("A1"); assert_eq!(a1, None); - let _ = book.get_sheet_mut(0).unwrap().remove_cell((1, 2)); + let _unused = book.get_sheet_mut(0).unwrap().remove_cell((1, 2)); let a2_value = book.get_sheet(0).unwrap().get_value("A2"); assert_eq!(a2_value, ""); let b5_value = book.get_sheet(0).unwrap().get_value("B5"); @@ -201,18 +201,18 @@ fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { book.get_sheet(0).unwrap().get_formatted_value("B37") ); - let _ = book + let _unused = book .get_sheet_by_name_mut("Sheet1") .unwrap() .get_cell_mut("A1") .set_value("49046881.119999997"); - let _ = book + let _unused = book .get_sheet_by_name_mut("Sheet1") .unwrap() .get_style_mut("A1") .get_number_format_mut() - .set_format_code(umya_spreadsheet::NumberingFormat::FORMAT_NUMBER_COMMA_SEPARATED1); + .set_format_code(NumberingFormat::FORMAT_NUMBER_COMMA_SEPARATED1); let value = book .get_sheet_by_name_mut("Sheet1") @@ -220,21 +220,15 @@ fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { .get_formatted_value("A1"); assert_eq!("49,046,881.12", &value); - let fg = umya_spreadsheet::Color::default() - .set_argb(umya_spreadsheet::Color::COLOR_BLACK) - .to_owned(); - let fill = umya_spreadsheet::PatternFill::default() - .set_foreground_color(fg) - .to_owned(); + let fg = Color::default().set_argb(Color::COLOR_BLACK).to_owned(); + let fill = PatternFill::default().set_foreground_color(fg).to_owned(); book.get_sheet_by_name_mut("Sheet5") .unwrap() .get_row_dimension_mut(5u32) .get_style_mut() .get_fill_mut() .set_pattern_fill(fill); - let font_color = umya_spreadsheet::Color::default() - .set_argb(umya_spreadsheet::Color::COLOR_WHITE) - .to_owned(); + let font_color = Color::default().set_argb(Color::COLOR_WHITE).to_owned(); book.get_sheet_by_name_mut("Sheet5") .unwrap() .get_row_dimension_mut(5u32) @@ -242,7 +236,7 @@ fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { .get_font_mut() .set_color(font_color); - let _ = book + let _unused = book .get_sheet_by_name_mut("Sheet7") .unwrap() .get_cell_mut("A1") @@ -260,53 +254,53 @@ fn read_and_wite_method(book: &mut umya_spreadsheet::Spreadsheet) { fn read_and_wite_by_empty() { // reader let path = std::path::Path::new("./tests/test_files/aaa_empty.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/bbb_empty.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn lazy_read_and_wite_by_empty() { // reader let path = std::path::Path::new("./tests/test_files/aaa_empty.xlsx"); - let book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let book = reader::xlsx::lazy_read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/bbb_lazy_empty.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn read_and_wite_xlsm() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsm"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); read_and_wite_xlsm_method(&mut book); // writer let path = std::path::Path::new("./tests/result_files/bbb.xlsm"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn lazy_read_and_wite_xlsm() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsm"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); read_and_wite_xlsm_method(&mut book); // writer let path = std::path::Path::new("./tests/result_files/bbb_lazy.xlsm"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn lazy_read_and_wite_xlsm2() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsm"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); let sheet = book.get_sheet_by_name_mut("Sheet1").unwrap(); let cell = sheet.get_cell_mut((1, 2)); @@ -314,22 +308,22 @@ fn lazy_read_and_wite_xlsm2() { // writer let path = std::path::Path::new("./tests/result_files/bbb_lazy2.xlsm"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn lazy_read_and_wite_xlsm_no_edit() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsm"); - let book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let book = reader::xlsx::lazy_read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/bbb_lazy_no_edit.xlsm"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } -fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { - let _ = book +fn read_and_wite_xlsm_method(book: &mut Spreadsheet) { + let _unused = book .get_sheet_mut(0) .unwrap() .get_cell_mut((1, 1)) @@ -345,27 +339,27 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { // copy sheet let mut clone_sheet = book.get_sheet(0).unwrap().clone(); clone_sheet.set_name("New Sheet"); - let _ = book.add_sheet(clone_sheet); + let _unused = book.add_sheet(clone_sheet); // remove sheet let mut clone_sheet = book.get_sheet(0).unwrap().clone(); clone_sheet.set_name("DeletedSheet"); - let _ = book.add_sheet(clone_sheet); + let _unused = book.add_sheet(clone_sheet); book.get_sheet_by_name("DeletedSheet").unwrap(); book.remove_sheet_by_name("DeletedSheet").unwrap(); // add chart (line chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("A1"); to_marker.set_coordinate("B2"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::LineChart, + ChartType::LineChart, from_marker, to_marker, area_chart_series_list, @@ -376,23 +370,23 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .set_title("Chart Title") .set_horizontal_title("Horizontal Title") .set_vertical_title("Vertical Title") - .set_grouping(umya_spreadsheet::drawing::charts::GroupingValues::Standard); + .set_grouping(drawing::charts::GroupingValues::Standard); book.get_sheet_by_name_mut("Sheet7") .unwrap() .add_chart(chart); // add chart (pie chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("B1"); to_marker.set_coordinate("C2"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::PieChart, + ChartType::PieChart, from_marker, to_marker, area_chart_series_list, @@ -408,17 +402,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (doughnut chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("C1"); to_marker.set_coordinate("D2"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::DoughnutChart, + ChartType::DoughnutChart, from_marker, to_marker, area_chart_series_list, @@ -434,17 +428,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (area chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("D1"); to_marker.set_coordinate("E2"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::AreaChart, + ChartType::AreaChart, from_marker, to_marker, area_chart_series_list, @@ -460,17 +454,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (bar chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("E1"); to_marker.set_coordinate("F2"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::BarChart, + ChartType::BarChart, from_marker, to_marker, area_chart_series_list, @@ -486,17 +480,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (bar 3d chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("A2"); to_marker.set_coordinate("B3"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::Bar3DChart, + ChartType::Bar3DChart, from_marker, to_marker, area_chart_series_list, @@ -512,17 +506,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (line 3d chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("B2"); to_marker.set_coordinate("C3"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::Line3DChart, + ChartType::Line3DChart, from_marker, to_marker, area_chart_series_list, @@ -538,17 +532,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (pie 3d chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("C2"); to_marker.set_coordinate("D3"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::Pie3DChart, + ChartType::Pie3DChart, from_marker, to_marker, area_chart_series_list, @@ -564,17 +558,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (area 3d chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("D2"); to_marker.set_coordinate("E3"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::Area3DChart, + ChartType::Area3DChart, from_marker, to_marker, area_chart_series_list, @@ -590,17 +584,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (of pie chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("E2"); to_marker.set_coordinate("F3"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::OfPieChart, + ChartType::OfPieChart, from_marker, to_marker, area_chart_series_list, @@ -616,8 +610,8 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (bubble chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("A3"); to_marker.set_coordinate("B4"); let area_chart_series_list = vec![ @@ -627,10 +621,10 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { ]; let series_title_list = vec!["Line1", "Line2", "Line3"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::BubbleChart, + ChartType::BubbleChart, from_marker, to_marker, area_chart_series_list, @@ -646,8 +640,8 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (radar chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("B3"); to_marker.set_coordinate("C4"); let area_chart_series_list = vec![ @@ -657,10 +651,10 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { ]; let series_title_list = vec!["Line1", "Line2", "Line3"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::RadarChart, + ChartType::RadarChart, from_marker, to_marker, area_chart_series_list, @@ -676,17 +670,17 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // add chart (scatter chart) - let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); - let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let mut from_marker = drawing::spreadsheet::MarkerType::default(); + let mut to_marker = drawing::spreadsheet::MarkerType::default(); from_marker.set_coordinate("C3"); to_marker.set_coordinate("D4"); let area_chart_series_list = vec!["New Sheet!$G$7:$G$10", "New Sheet!$H$7:$H$10"]; let series_title_list = vec!["Line1", "Line2"]; let series_point_title_list = vec!["Point1", "Point2", "Point3", "Point4"]; - let mut chart = umya_spreadsheet::structs::Chart::default(); + let mut chart = Chart::default(); chart .new_chart( - umya_spreadsheet::structs::ChartType::ScatterChart, + ChartType::ScatterChart, from_marker, to_marker, area_chart_series_list, @@ -702,10 +696,10 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { .add_chart(chart); // Add Image - let _ = book.new_sheet("Sheet Image"); - let mut marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default(); + let _unused = book.new_sheet("Sheet Image"); + let mut marker = drawing::spreadsheet::MarkerType::default(); marker.set_coordinate("B3"); - let mut image = umya_spreadsheet::structs::Image::default(); + let mut image = Image::default(); image.new_image("./images/sample1.png", marker); book.get_sheet_by_name_mut("Sheet Image") .unwrap() @@ -716,7 +710,7 @@ fn read_and_wite_xlsm_method(book: &mut umya_spreadsheet::Spreadsheet) { fn insert_and_remove_cells() { // reader let path = std::path::Path::new("./tests/test_files/aaa_insertCell.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); book.insert_new_row("Sheet1", 2, 3); book.insert_new_column("Sheet1", "B", 3); @@ -727,7 +721,7 @@ fn insert_and_remove_cells() { // writer let path = std::path::Path::new("./tests/result_files/bbb_insertCell.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] @@ -736,12 +730,12 @@ fn new_sheet_and_edit() { const TEST_SHEET: &str = "Sheet2233"; let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); // set cell value let sheet = book.new_sheet(TEST_SHEET).unwrap(); let cell = sheet.get_cell_mut("A2"); - let _ = cell.set_value("test"); + let _unused = cell.set_value("test"); // set style by range let mut style = Style::default(); @@ -749,9 +743,9 @@ fn new_sheet_and_edit() { sheet.set_style_by_range("A3:A4", style); let path = std::path::Path::new("./tests/result_files/bbb_new_sheet_value.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); let a2_value = book .get_sheet_by_name_mut(TEST_SHEET) .unwrap() @@ -790,11 +784,11 @@ fn new_sheet_and_edit() { #[test] fn new_file_and_edit() { // new file. - let mut book = umya_spreadsheet::new_file(); + let mut book = new_file(); // new worksheet. - let _ = book.new_sheet("Sheet2"); - let _ = book.new_sheet("Sheet3"); + let _unused = book.new_sheet("Sheet2"); + let _unused = book.new_sheet("Sheet3"); // change value. book.get_sheet_by_name_mut("Sheet2") @@ -863,13 +857,13 @@ fn new_file_and_edit() { .get_style_mut("A1") .get_borders_mut() .get_bottom_mut() - .set_border_style(umya_spreadsheet::Border::BORDER_MEDIUM); + .set_border_style(Border::BORDER_MEDIUM); book.get_sheet_by_name_mut("Sheet2") .unwrap() .get_style_mut((3, 2)) .get_borders_mut() .get_left_mut() - .set_border_style(umya_spreadsheet::Border::BORDER_THIN); + .set_border_style(Border::BORDER_THIN); // change font color. book.get_sheet_by_name_mut("Sheet2") @@ -883,15 +877,15 @@ fn new_file_and_edit() { book.get_sheet_by_name_mut("Sheet2") .unwrap() .get_style_mut("A1") - .set_background_color(umya_spreadsheet::Color::COLOR_BLUE); + .set_background_color(Color::COLOR_BLUE); book.get_sheet_by_name_mut("Sheet2") .unwrap() .get_style_mut("A2") .set_background_color_with_pattern( - umya_spreadsheet::Color::COLOR_BLUE, - umya_spreadsheet::Color::COLOR_RED, - umya_spreadsheet::PatternValues::DarkGrid, + Color::COLOR_BLUE, + Color::COLOR_RED, + PatternValues::DarkGrid, ); let worksheet = book.get_sheet_by_name_mut("Sheet3").unwrap(); @@ -977,23 +971,23 @@ fn new_file_and_edit() { // writer. let path = std::path::Path::new("./tests/result_files/eee.xlsx"); - umya_spreadsheet::writer::xlsx::write(&book, path).unwrap(); + writer::xlsx::write(&book, path).unwrap(); } #[test] fn new_and_wite() { // new file. - let book = umya_spreadsheet::new_file(); + let book = new_file(); // writer. let path = std::path::Path::new("./tests/result_files/fff.xlsx"); - umya_spreadsheet::writer::xlsx::write(&book, path).unwrap(); + writer::xlsx::write(&book, path).unwrap(); } #[test] fn duplicate_sheet() { - let mut book = umya_spreadsheet::new_file(); - let _ = book.new_sheet("Sheet2"); + let mut book = new_file(); + let _unused = book.new_sheet("Sheet2"); if book.new_sheet("Sheet2").is_ok() { panic!("getting new sheet..") } @@ -1001,7 +995,7 @@ fn duplicate_sheet() { #[test] fn witer_csv() { - let mut book = umya_spreadsheet::new_file(); + let mut book = new_file(); book.set_active_sheet(1); let sheet = book.new_sheet("Sheet2").unwrap(); // --- @@ -1018,82 +1012,82 @@ fn witer_csv() { // --- // writer - let mut option = umya_spreadsheet::structs::CsvWriterOption::default(); - option.set_csv_encode_value(umya_spreadsheet::structs::CsvEncodeValues::ShiftJis); + let mut option = CsvWriterOption::default(); + option.set_csv_encode_value(CsvEncodeValues::ShiftJis); option.set_do_trim(true); option.set_wrap_with_char("\""); let path = std::path::Path::new("./tests/result_files/bbb.csv"); - let _ = umya_spreadsheet::writer::csv::write(&book, path, Some(&option)); + let _unused = writer::csv::write(&book, path, Some(&option)); } #[test] fn new_file_empty_worksheet() { let book = umya_spreadsheet::new_file_empty_worksheet(); let path = std::path::Path::new("./tests/result_files/empty_worksheet.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn google() { // reader let path = std::path::Path::new("./tests/test_files/google.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/google.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn libre() { // reader let path = std::path::Path::new("./tests/test_files/libre.xlsm"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/libre.xlsm"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn read_and_wite_theme() { // reader let path = std::path::Path::new("./tests/test_files/aaa_theme.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/bbb_theme.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn openpyxl() { let path = std::path::Path::new("./tests/test_files/openpyxl.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); let sheet = book.get_active_sheet(); assert_eq!(sheet.get_cell("A1").unwrap().get_value(), "TEST"); assert_eq!(sheet.get_cell("A2").unwrap().get_value(), " TEST "); let path = std::path::Path::new("./tests/result_files/openpyxl.xlsx"); - umya_spreadsheet::writer::xlsx::write(&book, path).unwrap(); + writer::xlsx::write(&book, path).unwrap(); } #[test] fn read_and_wite_2() { // reader let path = std::path::Path::new("./tests/test_files/aaa_2.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/bbb_2.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_110() { let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let sheet = book.get_sheet_by_name_mut("Sheet1").unwrap(); let cell = sheet.get_cell_mut("A1"); @@ -1102,29 +1096,29 @@ fn issue_110() { // work on 0.9 cell.set_value("test"); let path = std::path::Path::new("./tests/result_files/aaa_issue_110.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn compression_test() { // reader let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); // writer let path = std::path::Path::new("./tests/result_files/bbb_comp_standard.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); // writer let path = std::path::Path::new("./tests/result_files/bbb_comp_light.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write_light(&book, path); + let _unused = writer::xlsx::write_light(&book, path); } #[test] fn move_range_test() { // reader let path = std::path::Path::new("./tests/test_files/aaa_move_range.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let sheet_name = "Sheet1"; let range = "C5:F9"; @@ -1144,24 +1138,24 @@ fn move_range_test() { .move_range(range_2, 0, 1); let path = std::path::Path::new("./tests/result_files/bbb_move_range.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write_light(&book, path); + let _unused = writer::xlsx::write_light(&book, path); } #[test] fn issue_72() { let xlsx_path = std::path::Path::new("./tests/test_files/wps_comment.xlsx"); - let wb = umya_spreadsheet::reader::xlsx::read(xlsx_path).unwrap(); + let wb = reader::xlsx::read(xlsx_path).unwrap(); // save to new file let path = std::path::Path::new("./tests/result_files/wps_comment_corrupted.xlsx"); - umya_spreadsheet::writer::xlsx::write(&wb, path).unwrap(); + writer::xlsx::write(&wb, path).unwrap(); } #[test] fn issue_129() { let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); let img = book .get_sheet_by_name("Sheet1") .unwrap() @@ -1175,13 +1169,13 @@ fn issue_129() { assert_eq!(img.get_row(), 16); let path = std::path::Path::new("./tests/result_files/issue_129.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn wb_with_shared_strings() { let path = std::path::Path::new("./tests/test_files/wb_with_shared_strings.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); let sheet = book.get_sheet_by_name("Sheet To Read From").unwrap(); assert_eq!(sheet.get_cell("A2").unwrap().get_value(), "11"); @@ -1191,22 +1185,22 @@ fn wb_with_shared_strings() { assert_eq!(sheet.get_cell("A6").unwrap().get_value(), "ABCdef"); let path = std::path::Path::new("./tests/result_files/wb_with_shared_strings.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_test() { let path = std::path::Path::new("./tests/test_files/table.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/table.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn sheetlock_test() { let path = std::path::Path::new("./tests/test_files/sheet_lock.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let mut sheet = book.get_sheet_mut(2).unwrap(); sheet @@ -1215,25 +1209,25 @@ fn sheetlock_test() { .set_sheet(true); let path = std::path::Path::new("./tests/result_files/sheet_lock.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn workbooklock_test() { let path = std::path::Path::new("./tests/test_files/book_lock.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); book.get_workbook_protection_mut() .set_workbook_password("password"); let path = std::path::Path::new("./tests/result_files/book_lock.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_147() { let path = std::path::Path::new("./tests/test_files/issue_147.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let from_sheet = book.get_sheet(0).unwrap(); let source_cell = from_sheet.get_cell((2, 3)).unwrap(); @@ -1243,17 +1237,17 @@ fn issue_147() { to_sheet.set_cell(target_cell); let path = std::path::Path::new("./tests/result_files/issue_147.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn html_to_richtext_test() { let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let mut sheet = book.get_sheet_by_name_mut("Sheet1").unwrap(); let html = r##"test
TEST
TEST
"##; - let richtext = umya_spreadsheet::helper::html::html_to_richtext(html).unwrap(); + let richtext = helper::html::html_to_richtext(html).unwrap(); sheet.get_cell_mut("G16").set_rich_text(richtext); sheet @@ -1263,25 +1257,25 @@ fn html_to_richtext_test() { .set_wrap_text(true); let path = std::path::Path::new("./tests/result_files/bbb_html_to_richtext.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_162() { let path = std::path::Path::new("./tests/test_files/issue_162.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_162.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_172() { - let value = umya_spreadsheet::helper::date::convert_date(2024, 2, 3, 10, 59, 00); + let value = helper::date::convert_date(2024, 2, 3, 10, 59, 00); let mut numbering_format = NumberingFormat::default(); numbering_format.set_format_code("dd-mmm-yy"); - let mut book = umya_spreadsheet::new_file(); + let mut book = new_file(); let mut sheet = book.get_sheet_mut(0).unwrap(); sheet.get_cell_mut("A1").set_value_number(value); sheet @@ -1294,7 +1288,7 @@ fn issue_172() { #[test] fn issue_177() { - let test = umya_spreadsheet::helper::coordinate::CellCoordinates::from("A1"); + let test = helper::coordinate::CellCoordinates::from("A1"); let test2 = test.clone(); assert_eq!(test.row, test2.row); assert_eq!(test.col, test2.col); @@ -1303,16 +1297,16 @@ fn issue_177() { #[test] fn issue_178() { let path = std::path::Path::new("./tests/test_files/issue_178.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_178.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_181() { let path = std::path::Path::new("./tests/test_files/issue_181.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let mut sheet = book.get_sheet_by_name_mut("LOV").unwrap(); sheet.remove_row(2, 1); for (key, row) in sheet.get_row_dimensions_to_hashmap() { @@ -1321,15 +1315,15 @@ fn issue_181() { assert_eq!(row.get_height(), 35.0); } let path = std::path::Path::new("./tests/result_files/issue_181.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_181_2() { let path = std::path::Path::new("./tests/test_files/issue_181_2.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); - let shee1: &mut umya_spreadsheet::structs::Worksheet = book.get_sheet_mut(0).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); + let shee1: &mut Worksheet = book.get_sheet_mut(0).unwrap(); let new_row_index = 4; shee1.insert_new_row(new_row_index, 5); shee1.get_cell_mut((1, new_row_index)).set_value("123"); @@ -1340,23 +1334,23 @@ fn issue_181_2() { shee1.remove_column("B", 1); let path = std::path::Path::new("./tests/result_files/issue_181_2.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_178_2() { let path = std::path::Path::new("./tests/test_files/issue_178_2.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_178_2.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_185() { let path = std::path::Path::new("./tests/test_files/issue_185.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); assert_eq!( book.get_sheet(0) .unwrap() @@ -1370,7 +1364,7 @@ fn issue_185() { #[test] fn issue_187() { let path = std::path::Path::new("./tests/test_files/issue_187.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let mut sheet = book.get_sheet_mut(0).unwrap(); let mut cell = sheet.get_cell("C4").unwrap().clone(); @@ -1386,40 +1380,40 @@ fn issue_187() { sheet.set_cell(cell); let path = std::path::Path::new("./tests/result_files/issue_187.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_188() { let path = std::path::Path::new("./tests/test_files/issue_188.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_188.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_188_2() { let path = std::path::Path::new("./tests/test_files/issue_188_2.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_188_2.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_189() { let path = std::path::Path::new("./tests/test_files/issue_189.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_189.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn expect_red_indexed_color() { let path = std::path::Path::new("./tests/test_files/red_indexed_color.xlsx"); - let book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let book = reader::xlsx::read(path).unwrap(); let cell = book.get_sheet(0).unwrap().get_cell("A1").unwrap(); @@ -1431,7 +1425,7 @@ fn expect_red_indexed_color() { #[test] fn issue_190() { let path = std::path::Path::new("./tests/test_files/issue_190.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); // remove book.get_sheet_mut(0).unwrap().remove_column("E", 1); @@ -1442,13 +1436,13 @@ fn issue_190() { book.get_sheet_mut(1).unwrap().insert_new_row(4, 1); let path = std::path::Path::new("./tests/result_files/issue_190.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_194() { let path = std::path::Path::new("./tests/test_files/issue_194.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); book.get_sheet_mut(0).unwrap().insert_new_column("D", 1); assert_eq!( @@ -1477,60 +1471,60 @@ fn issue_194() { ); let path = std::path::Path::new("./tests/result_files/issue_194.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_200() { let input_buffer = std::fs::read("./tests/test_files/issue_200.xlsx").unwrap(); let cursor = std::io::Cursor::new(input_buffer); - let workbook = umya_spreadsheet::reader::xlsx::read_reader(cursor, true).unwrap(); + let workbook = reader::xlsx::read_reader(cursor, true).unwrap(); let output_file = std::fs::File::create("./tests/result_files/issue_200.xlsx").unwrap(); - umya_spreadsheet::writer::xlsx::write_writer(&workbook, output_file).unwrap(); + writer::xlsx::write_writer(&workbook, output_file).unwrap(); } #[test] fn issue_201() { let path = std::path::Path::new("./tests/test_files/issue_201.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let mut cell = book.get_sheet_mut(0).unwrap().get_cell_mut("B1"); cell.set_formula_result_default(""); let path = std::path::Path::new("./tests/result_files/issue_201.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_206() { let path = std::path::Path::new("./tests/test_files/issue_206.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_206.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_194_2() { let path = std::path::Path::new("./tests/test_files/issue_194_2.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_194_2.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_188_3() { let path = std::path::Path::new("./tests/test_files/issue_188_3.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_188_3.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_184() { let path = std::path::Path::new("./tests/test_files/issue_184.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let theme = book.get_theme(); let color = book .get_sheet(0) @@ -1548,7 +1542,7 @@ fn issue_184() { #[test] fn issue_188_4() { let path = std::path::Path::new("./tests/test_files/issue_188_4.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); assert_eq!( book.get_sheet(0) @@ -1588,13 +1582,13 @@ fn issue_188_4() { ); let path = std::path::Path::new("./tests/result_files/issue_188_4.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_210() { let path = std::path::Path::new("./tests/test_files/issue_210.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let sheet = book.get_sheet(0).unwrap(); for cell in sheet.get_cell_collection() { if let Some(varA) = cell.get_style().get_alignment() { @@ -1616,15 +1610,15 @@ fn issue_210() { #[test] fn issue_208() { let path = std::path::Path::new("./tests/test_files/issue_208.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_208.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_184_2() { let path = std::path::Path::new("./tests/test_files/issue_184_2.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let data = vec![ ("A1", "FFFFFF"), @@ -1674,26 +1668,26 @@ fn issue_184_2() { #[test] fn issue_215() { let path = std::path::Path::new("./tests/test_files/issue_215.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_215.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_216() { let path = std::path::Path::new("./tests/test_files/issue_216.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); } #[test] fn issue_217() { let path = std::path::Path::new("./tests/test_files/issue_217.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); book.get_sheet_mut(2) .unwrap() - .set_state(umya_spreadsheet::SheetStateValues::Hidden); + .set_state(SheetStateValues::Hidden); let path = std::path::Path::new("./tests/result_files/issue_217.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] @@ -1730,22 +1724,22 @@ fn issue_218() { out_sheet.set_conditional_formatting_collection(vec![new_cond]); let path = std::path::Path::new("./tests/result_files/issue_218.xlsx"); - let _ = writer::xlsx::write(&out_book, path); + let _unused = writer::xlsx::write(&out_book, path); } #[test] fn issue_219() { let path = std::path::Path::new("./tests/test_files/issue_219.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_219.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_220() { let path = std::path::Path::new("./tests/test_files/issue_220.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); book.get_sheet_mut(0) .unwrap() @@ -1768,21 +1762,21 @@ fn issue_220() { .set_value("TEST1"); let path = std::path::Path::new("./tests/result_files/issue_220.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_222() { let path = std::path::Path::new("./tests/test_files/issue_222.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_222.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_224() { - let mut book = umya_spreadsheet::new_file(); + let mut book = new_file(); let mut sheet = book.get_sheet_mut(0).unwrap(); let mut num = NumberingFormat::default(); num.set_format_code("[<1]0;0"); @@ -1797,16 +1791,16 @@ fn issue_224() { #[test] fn issue_225() { let path = std::path::Path::new("./tests/test_files/issue_225.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_225.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_227() { let path = std::path::Path::new("./tests/test_files/aaa.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); book.read_sheet_by_name("Sheet2"); let sheet = book.get_sheet_by_name("Sheet2").unwrap(); assert_eq!("3", sheet.get_cell("B6").unwrap().get_value()); @@ -1827,34 +1821,34 @@ fn issue_230() { #[test] fn issue_232() { let path = std::path::Path::new("./tests/test_files/issue_232.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::lazy_read(path).unwrap(); + let mut book = reader::xlsx::lazy_read(path).unwrap(); let path = std::path::Path::new("./tests/result_files/issue_232.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_233() { let path = std::path::Path::new("./tests/test_files/issue_233.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); // book.get_sheet_mut(0).unwrap().cleanup(); let path = std::path::Path::new("./tests/result_files/issue_233.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_244() { let path = std::path::Path::new("./tests/test_files/issue_244.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let sheet = book.get_sheet_mut(0).unwrap(); let mut comment = Comment::default(); comment.new_comment("B2"); comment.set_text_string("TEST"); - let media_object = umya_spreadsheet::helper::binary::make_media_object("./images/sample1.png"); + let media_object = helper::binary::make_media_object("./images/sample1.png"); comment .get_shape_mut() .get_fill_mut() @@ -1864,13 +1858,13 @@ fn issue_244() { sheet.add_comments(comment); let path = std::path::Path::new("./tests/result_files/issue_244.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] fn issue_246() { let path = std::path::Path::new("./tests/test_files/issue_246.xlsx"); - let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap(); + let mut book = reader::xlsx::read(path).unwrap(); let sheet = book.get_sheet_mut(0).unwrap(); sheet.copy_row_styling(3, 5, None, None); @@ -1880,7 +1874,7 @@ fn issue_246() { sheet.copy_col_styling(10, 13, Some(11), Some(15)); let path = std::path::Path::new("./tests/result_files/issue_246.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } #[test] @@ -1895,5 +1889,5 @@ fn issue_248() { .set_show_grid_lines(false); let path = std::path::Path::new("./tests/result_files/issue_248.xlsx"); - let _ = umya_spreadsheet::writer::xlsx::write(&book, path); + let _unused = writer::xlsx::write(&book, path); } From a317cceed76af2f55178237aafb89b0bc0229048 Mon Sep 17 00:00:00 2001 From: mxsr Date: Sat, 21 Dec 2024 18:30:26 +0100 Subject: [PATCH 003/167] refactor(crypt): replace `getrandom` with `rand` for random byte generation - Replaced `getrandom` crate with `rand` to simplify and modernize random number generation. - Updated `gen_random_*` functions to use `rand::thread_rng().fill()` for generating random bytes of specified lengths. - Adjusted encryption functions to use `gen_random_bytes` for generating random values. --- Cargo.toml | 6 +++--- src/helper/crypt.rs | 40 ++++++++++++---------------------------- src/lib.rs | 2 +- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b5d6e81c..78925227 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ cfb = "0.10.0" chrono = { version = "0.4.39", default-features = false, features = ["clock"] } encoding_rs = "0.8.35" fancy-regex = "0.14.0" -getrandom = { version = "0.2.15" } hmac = "0.12.1" html_parser = "0.7.0" image = { version = "0.25.5", optional = true } @@ -33,12 +32,13 @@ thin-vec = "0.2.13" thousands = "0.2.0" quick-xml = { version = "0.37.1", features = ["serialize"] } zip = { version = "2.2.1", default-features = false, features = ["deflate"] } +rand = "0.8.5" [lib] doctest = false [features] -js = ["getrandom/js"] +js = [] default = ["image"] [lints] @@ -70,4 +70,4 @@ complexity = { level = "warn", priority = -1 } perf = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } cargo = { level = "warn", priority = -1 } -suspicious = { level = "warn", priority = -1 } \ No newline at end of file +suspicious = { level = "warn", priority = -1 } diff --git a/src/helper/crypt.rs b/src/helper/crypt.rs index 1560a703..986612ad 100644 --- a/src/helper/crypt.rs +++ b/src/helper/crypt.rs @@ -8,6 +8,7 @@ use byteorder::{ByteOrder, LittleEndian}; use hmac::{Hmac, Mac}; use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; +use rand::Rng; use sha2::{Digest, Sha512}; use std::cmp::Ordering; use std::io; @@ -27,7 +28,7 @@ const BLOCK_VERIFIER_HASH_INPUT: &[u8] = &[0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0 const BLOCK_VERIFIER_HASH_VALUE: &[u8] = &[0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e]; pub fn encrypt_sheet_protection(password: &str, sheet_protection: &mut SheetProtection) { - let key_salt_value = gen_random_16(); + let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA-512"; let key_spin_count = 100000; @@ -49,7 +50,7 @@ pub fn encrypt_sheet_protection(password: &str, sheet_protection: &mut SheetProt } pub fn encrypt_workbook_protection(password: &str, workbook_protection: &mut WorkbookProtection) { - let key_salt_value = gen_random_16(); + let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA-512"; let key_spin_count = 100000; @@ -71,7 +72,7 @@ pub fn encrypt_workbook_protection(password: &str, workbook_protection: &mut Wor } pub fn encrypt_revisions_protection(password: &str, workbook_protection: &mut WorkbookProtection) { - let key_salt_value = gen_random_16(); + let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA-512"; let key_spin_count = 100000; @@ -94,10 +95,10 @@ pub fn encrypt_revisions_protection(password: &str, workbook_protection: &mut Wo pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { // package params - let package_key = gen_random_32(); + let package_key = gen_random_bytes(32); let package_cipher_algorithm = "AES"; let package_cipher_chaining = "ChainingModeCBC"; - let package_salt_value = gen_random_16(); + let package_salt_value = gen_random_bytes(16); let package_hash_algorithm = "SHA512"; let package_hash_size = 64; let package_block_size = 16; @@ -106,7 +107,7 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { // key params let key_cipher_algorithm = "AES"; let key_cipher_chaining = "ChainingModeCBC"; - let key_salt_value = gen_random_16(); + let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA512"; let key_hash_size = 64; let key_block_size = 16; @@ -126,7 +127,7 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { ); // hmac key - let hmac_key = gen_random_64(); + let hmac_key = gen_random_bytes(64); let hmac_key_iv = create_iv( package_hash_algorithm, &package_salt_value, @@ -181,7 +182,7 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { .unwrap(); // verifier_hash_input - let verifier_hash_input = gen_random_16(); + let verifier_hash_input = gen_random_bytes(16); let verifier_hash_input_key = convert_password_to_key( password, key_hash_algorithm, @@ -475,26 +476,9 @@ fn hash(algorithm: &str, buffers: Vec<&[u8]>) -> Result, String> { digest.update(&buffer_concat(buffers)[..]); Ok(digest.finalize().to_vec()) } - -#[inline] -fn gen_random_16() -> Vec { - let buf: &mut [u8] = &mut [0; 16]; - getrandom::getrandom(buf).unwrap(); - buf.to_vec() -} - -#[inline] -fn gen_random_32() -> Vec { - let buf: &mut [u8] = &mut [0; 32]; - getrandom::getrandom(buf).unwrap(); - buf.to_vec() -} - -#[inline] -fn gen_random_64() -> Vec { - let buf: &mut [u8] = &mut [0; 64]; - getrandom::getrandom(buf).unwrap(); - buf.to_vec() +fn gen_random_bytes(len: usize) -> Vec { + let mut rng = rand::thread_rng(); + (0..len).map(|_| rng.gen()).collect() } // Create a buffer of an integer encoded as a uint32le diff --git a/src/lib.rs b/src/lib.rs index 7b377c3b..d0be9e3e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,9 +131,9 @@ extern crate base64; extern crate byteorder; extern crate cbc; extern crate cfb; -extern crate getrandom; extern crate hmac; extern crate html_parser; +extern crate rand; extern crate sha2; #[macro_use] From 30e3e9a7df0a8ce56e1b39c7ab879f2708376897 Mon Sep 17 00:00:00 2001 From: mxsr Date: Sat, 21 Dec 2024 19:22:40 +0100 Subject: [PATCH 004/167] refactor: reimplement and cleanup `helper/crypt.rs` --- src/helper/crypt.rs | 655 +++++++++++++++++++++----------------------- 1 file changed, 308 insertions(+), 347 deletions(-) diff --git a/src/helper/crypt.rs b/src/helper/crypt.rs index 986612ad..8445e108 100644 --- a/src/helper/crypt.rs +++ b/src/helper/crypt.rs @@ -1,25 +1,30 @@ use super::const_str::{CERTIFICATE_NS, ENCRYPTION_NS, PASSWORD_NS}; -use crate::structs::SheetProtection; -use crate::structs::WorkbookProtection; +use crate::structs::{SheetProtection, WorkbookProtection}; use crate::writer::driver::{write_end_tag, write_new_line, write_start_tag}; -use aes::cipher::{block_padding::NoPadding, BlockEncryptMut, KeyIvInit}; +use aes::cipher::{block_padding::NoPadding, BlockDecryptMut, BlockEncryptMut, KeyIvInit}; +use aes::Aes256; use base64::{engine::general_purpose::STANDARD, Engine as _}; use byteorder::{ByteOrder, LittleEndian}; +use cbc::{Decryptor, Encryptor}; use hmac::{Hmac, Mac}; use quick_xml::events::{BytesDecl, Event}; use quick_xml::Writer; -use rand::Rng; +use rand::rngs::OsRng; +use rand::RngCore; use sha2::{Digest, Sha512}; use std::cmp::Ordering; -use std::io; -use std::io::Write; +use std::io::{self, Write}; use std::path::Path; -type Aes256CbcEnc = cbc::Encryptor; +type Aes256CbcEnc = Encryptor; +type Aes256CbcDec = Decryptor; -const ENCRYPTION_INFO_PREFIX: &[u8] = &[0x04, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00]; // First 4 bytes are the version number, second 4 bytes are reserved. +/// Constants used in the encryption process +const ENCRYPTION_INFO_PREFIX: &[u8] = &[0x04, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00]; // Version and reserved bytes const PACKAGE_ENCRYPTION_CHUNK_SIZE: usize = 4096; const PACKAGE_OFFSET: usize = 8; // First 8 bytes are the size of the stream + +// Block keys used in various stages of encryption const BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY: &[u8] = &[0x5f, 0xb2, 0xad, 0x01, 0x0c, 0xb9, 0xe1, 0xf6]; const BLOCK_KEYS_DATA_INTEGRITY_HMAC_VALUE: &[u8] = &[0xa0, 0x67, 0x7f, 0x02, 0xb2, 0x2c, 0x84, 0x33]; @@ -27,11 +32,14 @@ const BLOCK_KEYS_KEY: &[u8] = &[0x14, 0x6e, 0x0b, 0xe7, 0xab, 0xac, 0xd0, 0xd6]; const BLOCK_VERIFIER_HASH_INPUT: &[u8] = &[0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79]; const BLOCK_VERIFIER_HASH_VALUE: &[u8] = &[0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e]; +/// Encrypts the sheet protection using the provided password. +/// Updates the `sheet_protection` object with algorithm name, salt value, spin count, and hash value. pub fn encrypt_sheet_protection(password: &str, sheet_protection: &mut SheetProtection) { let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA-512"; - let key_spin_count = 100000; + let key_spin_count = 100_000; + // Convert the password into a hash let key = convert_password_to_hash( password, key_hash_algorithm, @@ -39,9 +47,11 @@ pub fn encrypt_sheet_protection(password: &str, sheet_protection: &mut SheetProt key_spin_count, ); - let salt_value_str = STANDARD.encode(key_salt_value); - let hash_value_str = STANDARD.encode(key); + // Encode the salt and hash value in base64 + let salt_value_str = STANDARD.encode(&key_salt_value); + let hash_value_str = STANDARD.encode(&key); + // Update the sheet_protection object sheet_protection.set_algorithm_name(key_hash_algorithm); sheet_protection.set_salt_value(salt_value_str); sheet_protection.set_spin_count(key_spin_count as u32); @@ -49,11 +59,14 @@ pub fn encrypt_sheet_protection(password: &str, sheet_protection: &mut SheetProt sheet_protection.remove_password_raw(); } +/// Encrypts the workbook protection using the provided password. +/// Updates the `workbook_protection` object with algorithm name, salt value, spin count, and hash value. pub fn encrypt_workbook_protection(password: &str, workbook_protection: &mut WorkbookProtection) { let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA-512"; - let key_spin_count = 100000; + let key_spin_count = 100_000; + // Convert the password into a hash let key = convert_password_to_hash( password, key_hash_algorithm, @@ -61,9 +74,11 @@ pub fn encrypt_workbook_protection(password: &str, workbook_protection: &mut Wor key_spin_count, ); - let salt_value_str = STANDARD.encode(key_salt_value); - let hash_value_str = STANDARD.encode(key); + // Encode the salt and hash value in base64 + let salt_value_str = STANDARD.encode(&key_salt_value); + let hash_value_str = STANDARD.encode(&key); + // Update the workbook_protection object workbook_protection.set_workbook_algorithm_name(key_hash_algorithm); workbook_protection.set_workbook_salt_value(salt_value_str); workbook_protection.set_workbook_spin_count(key_spin_count as u32); @@ -71,11 +86,14 @@ pub fn encrypt_workbook_protection(password: &str, workbook_protection: &mut Wor workbook_protection.remove_workbook_password_raw(); } +/// Encrypts the revisions protection using the provided password. +/// Updates the `workbook_protection` object with algorithm name, salt value, spin count, and hash value. pub fn encrypt_revisions_protection(password: &str, workbook_protection: &mut WorkbookProtection) { let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA-512"; - let key_spin_count = 100000; + let key_spin_count = 100_000; + // Convert the password into a hash let key = convert_password_to_hash( password, key_hash_algorithm, @@ -83,9 +101,11 @@ pub fn encrypt_revisions_protection(password: &str, workbook_protection: &mut Wo key_spin_count, ); - let salt_value_str = STANDARD.encode(key_salt_value); - let hash_value_str = STANDARD.encode(key); + // Encode the salt and hash value in base64 + let salt_value_str = STANDARD.encode(&key_salt_value); + let hash_value_str = STANDARD.encode(&key); + // Update the workbook_protection object workbook_protection.set_revisions_algorithm_name(key_hash_algorithm); workbook_protection.set_revisions_salt_value(salt_value_str); workbook_protection.set_revisions_spin_count(key_spin_count as u32); @@ -93,32 +113,44 @@ pub fn encrypt_revisions_protection(password: &str, workbook_protection: &mut Wo workbook_protection.remove_revisions_password_raw(); } +/// Concatenates multiple byte slices into a single `Vec`. +#[expect(dead_code)] +fn buffer_concat(buffers: &[&[u8]]) -> Vec { + // Calculate the total length of the resulting vector. + let total_length = buffers.iter().map(|buffer| buffer.len()).sum(); + // Preallocate the vector with the total length. + let mut result: Vec = Vec::with_capacity(total_length); + // Extend the vector with each buffer. + for buffer in buffers { + result.extend_from_slice(buffer); + } + result +} + +/// Encrypts the provided data and writes the encrypted file to the specified filepath. +/// Uses the provided password to encrypt the data. pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { - // package params + // Package parameters let package_key = gen_random_bytes(32); let package_cipher_algorithm = "AES"; - let package_cipher_chaining = "ChainingModeCBC"; - let package_salt_value = gen_random_bytes(16); let package_hash_algorithm = "SHA512"; let package_hash_size = 64; let package_block_size = 16; let package_key_bits = package_key.len() * 8; + let package_salt_value = gen_random_bytes(16); - // key params + // Key parameters let key_cipher_algorithm = "AES"; - let key_cipher_chaining = "ChainingModeCBC"; - let key_salt_value = gen_random_bytes(16); let key_hash_algorithm = "SHA512"; let key_hash_size = 64; let key_block_size = 16; - let key_spin_count = 100000; + let key_spin_count = 100_000; let key_key_bits = 256; + let key_salt_value = gen_random_bytes(16); - // encrypted_package + // Encrypt the package let encrypted_package = crypt_package( true, - package_cipher_algorithm, - package_cipher_chaining, package_hash_algorithm, package_block_size, &package_salt_value, @@ -126,7 +158,7 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { data, ); - // hmac key + // Generate HMAC key and encrypt it let hmac_key = gen_random_bytes(64); let hmac_key_iv = create_iv( package_hash_algorithm, @@ -134,35 +166,19 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { package_block_size, BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY, ); - let encrypted_hmac_key = crypt( - true, - package_cipher_algorithm, - package_cipher_chaining, - &package_key, - &hmac_key_iv, - &hmac_key, - ) - .unwrap(); + let encrypted_hmac_key = crypt(true, &package_key, &hmac_key_iv, &hmac_key).unwrap(); - // hmac value - let hmac_value = hmac(package_hash_algorithm, &hmac_key, vec![&encrypted_package]).unwrap(); + // Generate HMAC value and encrypt it + let hmac_value = hmac(package_hash_algorithm, &hmac_key, &[&encrypted_package]).unwrap(); let hmac_value_iv = create_iv( package_hash_algorithm, &package_salt_value, package_block_size, BLOCK_KEYS_DATA_INTEGRITY_HMAC_VALUE, ); - let encrypted_hmac_value = crypt( - true, - package_cipher_algorithm, - package_cipher_chaining, - &package_key, - &hmac_value_iv, - &hmac_value, - ) - .unwrap(); + let encrypted_hmac_value = crypt(true, &package_key, &hmac_value_iv, &hmac_value).unwrap(); - // key + // Convert the password to a key let key = convert_password_to_key( password, key_hash_algorithm, @@ -171,17 +187,9 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { key_key_bits, BLOCK_KEYS_KEY, ); - let encrypted_key_value = crypt( - true, - key_cipher_algorithm, - key_cipher_chaining, - &key, - &key_salt_value, - &package_key, - ) - .unwrap(); + let encrypted_key_value = crypt(true, &key, &key_salt_value, &package_key).unwrap(); - // verifier_hash_input + // Generate verifier hash input and encrypt it let verifier_hash_input = gen_random_bytes(16); let verifier_hash_input_key = convert_password_to_key( password, @@ -193,16 +201,14 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { ); let encrypted_verifier_hash_input = crypt( true, - key_cipher_algorithm, - key_cipher_chaining, &verifier_hash_input_key, &key_salt_value, &verifier_hash_input, ) .unwrap(); - // verifier_hash_value - let verifier_hash_value = hash(key_hash_algorithm, vec![&verifier_hash_input]).unwrap(); + // Generate verifier hash value and encrypt it + let verifier_hash_value = hash(key_hash_algorithm, &[&verifier_hash_input]).unwrap(); let verifier_hash_value_key = convert_password_to_key( password, key_hash_algorithm, @@ -213,22 +219,20 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { ); let encrypted_verifier_hash_value = crypt( true, - key_cipher_algorithm, - key_cipher_chaining, &verifier_hash_value_key, &key_salt_value, &verifier_hash_value, ) .unwrap(); - // XML + // Build the encryption info XML data let encryption_info_buffer = build_encryption_info( &package_salt_value, package_block_size, package_key_bits, package_hash_size, package_cipher_algorithm, - package_cipher_chaining, + "ChainingModeCBC", package_hash_algorithm, &encrypted_hmac_key, &encrypted_hmac_value, @@ -238,13 +242,14 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { key_key_bits, key_hash_size, key_cipher_algorithm, - key_cipher_chaining, + "ChainingModeCBC", key_hash_algorithm, &encrypted_verifier_hash_input, &encrypted_verifier_hash_value, &encrypted_key_value, ); + // Create compound file and write streams let mut comp = cfb::create(filepath).unwrap(); { let mut stream_info = comp.create_stream("EncryptionInfo").unwrap(); @@ -256,146 +261,154 @@ pub fn encrypt>(filepath: &P, data: &[u8], password: &str) { } } -// Encrypt/decrypt the package -#[allow(clippy::too_many_arguments)] +/// Encrypts or decrypts the package data. +/// The package is processed in chunks, encrypting or decrypting each chunk separately. fn crypt_package( encrypt: bool, - cipher_algorithm: &str, - cipher_chaining: &str, hash_algorithm: &str, block_size: usize, salt_value: &[u8], key: &[u8], input: &[u8], ) -> Vec { - // The first 8 bytes is supposed to be the length, but it seems like it is really the length - 4.. let mut output_chunks: Vec> = Vec::new(); let offset = if encrypt { 0 } else { PACKAGE_OFFSET }; - // The package is encoded in chunks. Encrypt/decrypt each and concat. + // Process the package in chunks let mut i: usize = 0; let mut end = 0; while end < input.len() { let start = end; - end = start + PACKAGE_ENCRYPTION_CHUNK_SIZE; - if end > input.len() { - end = input.len(); - }; + end = (start + PACKAGE_ENCRYPTION_CHUNK_SIZE).min(input.len()); - // Grab the next chunk - let mut input_chunk = buffer_slice(input, start + offset, end + offset); + // Get the next chunk + let mut input_chunk = input[start + offset..end + offset].to_vec(); - // Pad the chunk if it is not an integer multiple of the block size + // Pad the chunk if it is not a multiple of the block size let remainder = input_chunk.len() % block_size; if remainder > 0 { - let buffer = buffer_alloc(0, block_size - remainder); - input_chunk = buffer_concat(vec![&input_chunk, &buffer]); + input_chunk.extend(vec![0u8; block_size - remainder]); } - // Create the initialization vector - // Create the block key from the current index + // Create the initialization vector (IV) for this chunk let block_key_buffer = create_uint32_le_buffer(i as u32, None); let iv = create_iv(hash_algorithm, salt_value, block_size, &block_key_buffer); - // Encrypt/decrypt the chunk and add it to the array - let output_chunk = crypt( - encrypt, - cipher_algorithm, - cipher_chaining, - key, - &iv, - &input_chunk, - ) - .unwrap(); + // Encrypt or decrypt the chunk + let output_chunk = crypt(encrypt, key, &iv, &input_chunk).unwrap(); output_chunks.push(output_chunk); i += 1; } - // Concat all of the output chunks. - let output_chunks_as: Vec<_> = output_chunks.iter().map(AsRef::as_ref).collect(); - let mut output = buffer_concat(output_chunks_as); + // Concatenate all output chunks + let mut output = output_chunks.concat(); if encrypt { - // Put the length of the package in the first 8 bytes - let input_len = input.len(); - output = buffer_concat(vec![ - &create_uint32_le_buffer(input_len as u32, Some(PACKAGE_OFFSET)), - &output, - ]); + // Prepend the length of the package in the first 8 bytes + let input_len = input.len() as u32; + let length_buffer = create_uint32_le_buffer(input_len, Some(PACKAGE_OFFSET)); + output = [length_buffer, output].concat(); } else { - // Truncate the buffer to the size in the prefix - let length = buffer_read_u_int32_le(input, 0); - output = output[0..length as usize].to_vec(); + // Truncate the output to the size specified in the prefix + let length = LittleEndian::read_u32(&input[0..4]) as usize; + output.truncate(length); } output } -// Create an initialization vector (IV) +/// Encrypts or decrypts data using AES-256 in CBC mode with the given key and IV. +/// The `encrypt` parameter determines whether to encrypt (true) or decrypt (false). +fn crypt(encrypt: bool, key: &[u8], iv: &[u8], input: &[u8]) -> Result, String> { + match key.len() * 8 { + 256 => { + if encrypt { + // Encrypt the input data + let cipher = Aes256CbcEnc::new_from_slices(key, iv) + .map_err(|e| format!("Error creating cipher: {e}"))?; + let mut buffer = input.to_vec(); + cipher + .encrypt_padded_mut::(&mut buffer, input.len()) + .map_err(|e| format!("Encryption error: {e}"))?; + Ok(buffer) + } else { + // Decrypt the input data + let cipher = Aes256CbcDec::new_from_slices(key, iv) + .map_err(|e| format!("Error creating cipher: {e}"))?; + let mut buffer = input.to_vec(); + cipher + .decrypt_padded_mut::(&mut buffer) + .map_err(|e| format!("Decryption error: {e}"))?; + Ok(buffer) + } + } + _ => Err("Key size not supported!".to_string()), + } +} + +/// Calculates an HMAC using the specified algorithm over the concatenated buffers. +fn hmac(algorithm: &str, key: &[u8], buffers: &[&[u8]]) -> Result, String> { + match algorithm { + "SHA512" | "SHA-512" => { + type HmacSha512 = Hmac; + + let mut mac = HmacSha512::new_from_slice(key) + .map_err(|e| format!("Error creating HMAC: {e}"))?; + for buffer in buffers { + mac.update(buffer); + } + Ok(mac.finalize().into_bytes().to_vec()) + } + _ => Err(format!("Algorithm {algorithm} not supported!")), + } +} + +/// Creates an initialization vector (IV) by hashing the salt value and the block key. +/// The resulting hash is truncated or padded to match the block size. fn create_iv( hash_algorithm: &str, salt_value: &[u8], block_size: usize, block_key: &[u8], ) -> Vec { - // Create the initialization vector by hashing the salt with the block key. - // Truncate or pad as needed to meet the block size. - let mut iv = hash(hash_algorithm, vec![salt_value, block_key]).unwrap(); + // Hash the salt value and block key together + let mut iv = hash(hash_algorithm, &[salt_value, block_key]).unwrap(); + + // Adjust the IV length to match the block size match iv.len().cmp(&block_size) { Ordering::Less => { - let mut tmp = buffer_alloc(0x36, block_size); - buffer_copy(&mut tmp, &iv); - iv = tmp; + // Pad with zeros if IV is shorter than block size + iv.resize(block_size, 0); } Ordering::Greater => { - iv = buffer_slice(&iv, 0, block_size); + // Truncate if IV is longer than block size + iv.truncate(block_size); } _ => {} } + iv } -// Encrypt/decrypt input -fn crypt( - _encrypt: bool, - _cipher_algorithm: &str, - _cipher_chaining: &str, - key: &[u8], - iv: &[u8], - input: &[u8], -) -> Result, String> { - let mut buf = [0u8; 4096]; - let pt_len = input.len(); - buf[..pt_len].copy_from_slice(input); - let ct = match key.len() * 8 { - 256 => Aes256CbcEnc::new_from_slices(key, iv) - .unwrap() - .encrypt_padded_mut::(&mut buf, pt_len) - .unwrap(), +/// Calculates a hash of the concatenated buffers using the specified algorithm. +fn hash(algorithm: &str, buffers: &[&[u8]]) -> Result, String> { + let mut hasher = match algorithm { + "SHA512" | "SHA-512" => Sha512::new(), _ => { - return Err("key size not supported!".to_string()); + return Err(format!("Algorithm {algorithm} not supported!")); } }; - Ok(ct.to_vec()) -} -fn hmac(algorithm: &str, key: &[u8], buffers: Vec<&[u8]>) -> Result, String> { - let mut mac = match algorithm { - "SHA512" => { - type HmacSha512 = Hmac; - HmacSha512::new_from_slice(key).unwrap() - } - _ => { - return Err(format!("algorithm {algorithm} not supported!")); - } - }; - mac.update(&buffer_concat(buffers)); + for buffer in buffers { + hasher.update(buffer); + } - let result = mac.finalize(); - Ok(result.into_bytes()[..].to_vec()) + Ok(hasher.finalize().to_vec()) } +/// Converts the provided password into a cryptographic key using the specified hash algorithm, +/// salt value, spin count, key length, and block key. fn convert_password_to_key( password: &str, hash_algorithm: &str, @@ -404,93 +417,87 @@ fn convert_password_to_key( key_bits: usize, block_key: &[u8], ) -> Vec { - // Password must be in unicode buffer - let mut password_buffer: Vec = Vec::new(); - let v: Vec = password.encode_utf16().collect(); - for a in v { - let d = a.to_le_bytes(); - password_buffer.push(d[0]); - password_buffer.push(d[1]); - } + // Convert password to UTF-16LE bytes + let password_bytes: Vec = password + .encode_utf16() + .flat_map(u16::to_le_bytes) + .collect(); // Generate the initial hash - let mut key = hash(hash_algorithm, vec![salt_value, &password_buffer]).unwrap(); + let mut key = hash(hash_algorithm, &[salt_value, &password_bytes]).unwrap(); - // Now regenerate until spin count + // Iterate spin_count times for i in 0..spin_count { - let iterator = create_uint32_le_buffer(i as u32, None); - key = hash(hash_algorithm, vec![&iterator, &key]).unwrap(); + let i_bytes = (i as u32).to_le_bytes(); + key = hash(hash_algorithm, &[&i_bytes, &key]).unwrap(); } - // Now generate the final hash - key = hash(hash_algorithm, vec![&key, block_key]).unwrap(); + // Generate the final hash + key = hash(hash_algorithm, &[&key, block_key]).unwrap(); - // Truncate or pad as needed to get to length of keyBits + // Truncate or pad the key to the desired length let key_bytes = key_bits / 8; match key.len().cmp(&key_bytes) { Ordering::Less => { - let mut tmp = buffer_alloc(0x36, key_bytes); - buffer_copy(&mut tmp, &key); - tmp + // Pad with zeros + key.resize(key_bytes, 0); + key } - Ordering::Greater => buffer_slice(&key, 0, key_bytes), + Ordering::Greater => key[..key_bytes].to_vec(), _ => key, } } +/// Converts the provided password into a hash using the specified hash algorithm, +/// salt value, and spin count. fn convert_password_to_hash( password: &str, hash_algorithm: &str, salt_value: &[u8], spin_count: usize, ) -> Vec { - // Password must be in unicode buffer - let mut password_buffer: Vec = Vec::new(); - let v: Vec = password.encode_utf16().collect(); - for a in v { - let d = a.to_le_bytes(); - password_buffer.push(d[0]); - password_buffer.push(d[1]); - } + // Convert password to UTF-16LE bytes + let password_bytes: Vec = password + .encode_utf16() + .flat_map(u16::to_le_bytes) + .collect(); // Generate the initial hash - let mut key = hash(hash_algorithm, vec![salt_value, &password_buffer]).unwrap(); + let mut hash_value = hash(hash_algorithm, &[salt_value, &password_bytes]).unwrap(); - // Now regenerate until spin count + // Iterate spin_count times for i in 0..spin_count { - let iterator = create_uint32_le_buffer(i as u32, None); - key = hash(hash_algorithm, vec![&key, &iterator]).unwrap(); + let i_bytes = (i as u32).to_le_bytes(); + hash_value = hash(hash_algorithm, &[&hash_value, &i_bytes]).unwrap(); } - key + hash_value } -// Calculate a hash of the concatenated buffers with the given algorithm. -fn hash(algorithm: &str, buffers: Vec<&[u8]>) -> Result, String> { - let mut digest = match algorithm { - "SHA512" | "SHA-512" => Sha512::new(), - _ => { - return Err(format!("algorithm {algorithm} not supported!")); - } - }; - digest.update(&buffer_concat(buffers)[..]); - Ok(digest.finalize().to_vec()) -} +/// Generates a vector of random bytes of the specified length using a cryptographically secure random number generator. fn gen_random_bytes(len: usize) -> Vec { - let mut rng = rand::thread_rng(); - (0..len).map(|_| rng.gen()).collect() + let mut rng = OsRng; + let mut bytes = vec![0u8; len]; + rng.fill_bytes(&mut bytes); + bytes } -// Create a buffer of an integer encoded as a uint32le -#[inline] +/// Creates a byte buffer containing a 32-bit unsigned integer in little-endian format. +/// If `buffer_size` is specified and greater than 4, the buffer is padded to the specified size. fn create_uint32_le_buffer(value: u32, buffer_size: Option) -> Vec { - let bs_prm = buffer_size.unwrap_or(4); - let mut buffer = buffer_alloc(0, bs_prm); - buffer_write_u_int32_le(&mut buffer, value, 0); + let mut buffer = Vec::new(); + buffer.extend(&value.to_le_bytes()); + if let Some(size) = buffer_size { + if size > 4 { + // Pad the buffer with zeros + buffer.resize(size, 0); + } + } buffer } -#[allow(clippy::too_many_arguments)] +/// Builds the encryption info XML data. +/// Returns a vector of bytes representing the encryption info. fn build_encryption_info( package_salt_value: &[u8], package_block_size: usize, @@ -524,7 +531,7 @@ fn build_encryption_info( .unwrap(); write_new_line(&mut writer); - // Map the object into the appropriate XML structure. Buffers are encoded in base 64. + // Start encryption element write_start_tag( &mut writer, "encryption", @@ -535,122 +542,91 @@ fn build_encryption_info( ], false, ); - let str_package_salt_value_len = package_salt_value.len().to_string(); - let str_package_block_size = package_block_size.to_string(); - let str_package_key_bits = package_key_bits.to_string(); - let str_package_hash_size = package_hash_size.to_string(); - let str_package_salt_value = STANDARD.encode(package_salt_value); + + // keyData element write_start_tag( &mut writer, "keyData", vec![ - ("saltSize", &str_package_salt_value_len), - ("blockSize", &str_package_block_size), - ("keyBits", &str_package_key_bits), - ("hashSize", &str_package_hash_size), + ("saltSize", &package_salt_value.len().to_string()), + ("blockSize", &package_block_size.to_string()), + ("keyBits", &package_key_bits.to_string()), + ("hashSize", &package_hash_size.to_string()), ("cipherAlgorithm", package_cipher_algorithm), ("cipherChaining", package_cipher_chaining), ("hashAlgorithm", package_hash_algorithm), - ("saltValue", &str_package_salt_value), + ("saltValue", &STANDARD.encode(package_salt_value)), ], true, ); - let str_data_integrity_encrypted_hmac_key = STANDARD.encode(data_integrity_encrypted_hmac_key); - let str_data_integrity_encrypted_hmac_value = - STANDARD.encode(data_integrity_encrypted_hmac_value); + + // dataIntegrity element write_start_tag( &mut writer, "dataIntegrity", vec![ - ("encryptedHmacKey", &str_data_integrity_encrypted_hmac_key), + ( + "encryptedHmacKey", + &STANDARD.encode(data_integrity_encrypted_hmac_key), + ), ( "encryptedHmacValue", - &str_data_integrity_encrypted_hmac_value, + &STANDARD.encode(data_integrity_encrypted_hmac_value), ), ], true, ); + + // keyEncryptors element write_start_tag(&mut writer, "keyEncryptors", vec![], false); + + // keyEncryptor element write_start_tag( &mut writer, "keyEncryptor", vec![("uri", PASSWORD_NS)], false, ); - let str_key_spin_count = key_spin_count.to_string(); - let str_key_salt_value_len = key_salt_value.len().to_string(); - let str_key_block_size = key_block_size.to_string(); - let str_key_key_bits = key_key_bits.to_string(); - let str_key_hash_size = key_hash_size.to_string(); - let str_key_salt_value = STANDARD.encode(key_salt_value); - let str_key_encrypted_verifier_hash_input = STANDARD.encode(key_encrypted_verifier_hash_input); - let str_key_encrypted_verifier_hash_value = STANDARD.encode(key_encrypted_verifier_hash_value); - let str_key_key_encrypted_key_value = STANDARD.encode(key_encrypted_key_value); + + // p:encryptedKey element write_start_tag( &mut writer, "p:encryptedKey", vec![ - ("spinCount", &str_key_spin_count), - ("saltSize", &str_key_salt_value_len), - ("blockSize", &str_key_block_size), - ("keyBits", &str_key_key_bits), - ("hashSize", &str_key_hash_size), + ("spinCount", &key_spin_count.to_string()), + ("saltSize", &key_salt_value.len().to_string()), + ("blockSize", &key_block_size.to_string()), + ("keyBits", &key_key_bits.to_string()), + ("hashSize", &key_hash_size.to_string()), ("cipherAlgorithm", key_cipher_algorithm), ("cipherChaining", key_cipher_chaining), ("hashAlgorithm", key_hash_algorithm), - ("saltValue", &str_key_salt_value), + ("saltValue", &STANDARD.encode(key_salt_value)), ( "encryptedVerifierHashInput", - &str_key_encrypted_verifier_hash_input, + &STANDARD.encode(key_encrypted_verifier_hash_input), ), ( "encryptedVerifierHashValue", - &str_key_encrypted_verifier_hash_value, + &STANDARD.encode(key_encrypted_verifier_hash_value), + ), + ( + "encryptedKeyValue", + &STANDARD.encode(key_encrypted_key_value), ), - ("encryptedKeyValue", &str_key_key_encrypted_key_value), ], true, ); + // Close tags write_end_tag(&mut writer, "keyEncryptor"); write_end_tag(&mut writer, "keyEncryptors"); write_end_tag(&mut writer, "encryption"); let result = writer.into_inner().into_inner().clone(); - buffer_concat(vec![ENCRYPTION_INFO_PREFIX, &result]) -} -#[inline] -fn buffer_slice(buffer: &[u8], start: usize, end: usize) -> Vec { - buffer[start..end].to_vec() -} - -#[inline] -fn buffer_alloc(alloc_char: u8, size: usize) -> Vec { - vec![alloc_char; size] -} - -fn buffer_concat(buffers: Vec<&[u8]>) -> Vec { - let mut result: Vec = Vec::new(); - for buffer in buffers { - result.extend(buffer); - } - result -} -fn buffer_copy(buffer1: &mut [u8], buffer2: &[u8]) { - for (i, byte) in buffer2.iter().enumerate() { - let _unused = std::mem::replace(&mut buffer1[i], *byte); - } -} - -#[inline] -fn buffer_read_u_int32_le(buffer: &[u8], _cnt: usize) -> u32 { - LittleEndian::read_u32(buffer) -} - -#[inline] -fn buffer_write_u_int32_le(buffer: &mut [u8], value: u32, _cnt: usize) { - LittleEndian::write_u32(buffer, value); + // Combine the ENCRYPTION_INFO_PREFIX and the XML data + [ENCRYPTION_INFO_PREFIX, &result].concat() } #[cfg(test)] @@ -660,6 +636,7 @@ mod tests { use std::io::Read; use std::{fmt::Write, num::ParseIntError}; + // Helper function to decode a hex string into bytes fn decode_hex(s: &str) -> Result, ParseIntError> { (0..s.len()) .step_by(2) @@ -667,6 +644,7 @@ mod tests { .collect() } + // Helper function to encode bytes into a hex string fn encode_hex(bytes: &[u8]) -> String { let mut s = String::with_capacity(bytes.len() * 2); for &b in bytes { @@ -677,38 +655,33 @@ mod tests { #[test] fn test_encrypt() { + const PACKAGE_CIPHER_ALGORITHM: &str = "AES"; + const KEY_CIPHER_ALGORITHM: &str = "AES"; + const KEY_HASH_SIZE: usize = 64; + const KEY_BLOCK_SIZE: usize = 16; + let mut file = File::open("./tests/test_files/aaa.xlsx").unwrap(); let mut data = Vec::new(); - let _unused = file.read_to_end(&mut data).unwrap(); + file.read_to_end(&mut data).unwrap(); let password = "password"; - // package params + // Package parameters let package_key = decode_hex("cdf9defae2480933c503350e16334453d1cb8348bb2fea585db7f9e1f78fe9bf").unwrap(); - let package_cipher_algorithm = "AES"; - let package_cipher_chaining = "ChainingModeCBC"; - let package_salt_value = decode_hex("4c251b321d85cecfcb6d952ba6d81846").unwrap(); let package_hash_algorithm = "SHA512"; - let package_hash_size = 64; let package_block_size = 16; - let package_key_bits = package_key.len() * 8; + let package_salt_value = decode_hex("4c251b321d85cecfcb6d952ba6d81846").unwrap(); - // key params - let key_cipher_algorithm = "AES"; - let key_cipher_chaining = "ChainingModeCBC"; + // Key parameters let key_salt_value = decode_hex("3aa973eec73c98c4710021730ef5b513").unwrap(); let key_hash_algorithm = "SHA512"; - let key_hash_size = 64; - let key_block_size = 16; - let key_spin_count = 100000; + let key_spin_count = 100_000; let key_key_bits = 256; - // encrypted_package + // Encrypted package let encrypted_package = crypt_package( true, - package_cipher_algorithm, - package_cipher_chaining, package_hash_algorithm, package_block_size, &package_salt_value, @@ -716,7 +689,7 @@ mod tests { &data, ); - // hmac key + // HMAC key let hmac_key = decode_hex("4c6e4db6d9a60e5d41c3ca639a682aaa71da7437202fe92ec5d814bd1e9e4e6a831aee889eae3bc18bc1bebedae1f73393fddfffd0a0b6c557485fefcdb5e98b").unwrap(); let hmac_key_iv = create_iv( package_hash_algorithm, @@ -727,22 +700,15 @@ mod tests { let converted = encode_hex(&hmac_key_iv); assert_eq!(&converted, "ba1bf00eed82b07ee65e574eb1f46043"); - let encrypted_hmac_key = crypt( - true, - package_cipher_algorithm, - package_cipher_chaining, - &package_key, - &hmac_key_iv, - &hmac_key, - ) - .unwrap(); + let encrypted_hmac_key = crypt(true, &package_key, &hmac_key_iv, &hmac_key).unwrap(); let converted = encode_hex(&encrypted_hmac_key); assert_eq!(&converted, "b32b1cdc4ac1af244377c1eb57efd31a819f555a7204adcc0cfe364b394bbdb086a8daef4f4c512d52e3db6a54b1d45e1dd1dbfa3ddacc29fe35449ba5225dc7"); - // hmac value - let hmac_value = hmac(package_hash_algorithm, &hmac_key, vec![&encrypted_package]).unwrap(); - //let converted = encode_hex(&hmac_value); - //assert_eq!(&converted, "41748c1ed0bcbbc46301a0a21e00747b6fafaa52ddbe4952a77a399ed4514b40c9b7e59f1c52c4cc72881794435336cc6e42fef4498245575bb9c2343480773f"); + // HMAC value + let hmac_value = hmac(package_hash_algorithm, &hmac_key, &[&encrypted_package]).unwrap(); + // Uncomment the following lines to check the HMAC value + // let converted = encode_hex(&hmac_value); + // assert_eq!(&converted, "41748c1ed0bcbbc46301a0a21e00747b6fafaa52ddbe4952a77a399ed4514b40c9b7e59f1c52c4cc72881794435336cc6e42fef4498245575bb9c2343480773f"); let hmac_value_iv = create_iv( package_hash_algorithm, @@ -753,19 +719,12 @@ mod tests { let converted = encode_hex(&hmac_value_iv); assert_eq!(&converted, "088385b871292e7ed8414f173c5b6622"); - let encrypted_hmac_value = crypt( - true, - package_cipher_algorithm, - package_cipher_chaining, - &package_key, - &hmac_value_iv, - &hmac_value, - ) - .unwrap(); - //let converted = encode_hex(&encrypted_hmac_value); - //assert_eq!(&converted, "1f6fc2877101ac12ccee6dbb0e5ea2556cc61c2c532b89ffc701fd16c5078e7e8264034ded6dc00469039f706fce12747db817574f13b49d18e914fdf4e3e93b"); + let encrypted_hmac_value = crypt(true, &package_key, &hmac_value_iv, &hmac_value).unwrap(); + // Uncomment the following lines to check the encrypted HMAC value + // let converted = encode_hex(&encrypted_hmac_value); + // assert_eq!(&converted, "1f6fc2877101ac12ccee6dbb0e5ea2556cc61c2c532b89ffc701fd16c5078e7e8264034ded6dc00469039f706fce12747db817574f13b49d18e914fdf4e3e93b"); - // key + // Key let key = convert_password_to_key( password, key_hash_algorithm, @@ -780,23 +739,15 @@ mod tests { "8d5869311b1c1fdb59a1de6fe1e6f2ce7dccd4deb198a6dfb1f7fb55bc03487d" ); - let encrypted_key_value = crypt( - true, - key_cipher_algorithm, - key_cipher_chaining, - &key, - &key_salt_value, - &package_key, - ) - .unwrap(); + let encrypted_key_value = crypt(true, &key, &key_salt_value, &package_key).unwrap(); let converted = encode_hex(&encrypted_key_value); assert_eq!( &converted, "5017ddc6146e56dfbf76734b3e99b80f36a4c9a2e9eb21fe77695f73850cc452" ); - // verifier_hash_input - let verifier_hash_input = "8f54777cba87efa55ea2db8399873815".as_bytes().to_vec(); + // Verifier hash input + let verifier_hash_input = decode_hex("8f54777cba87efa55ea2db8399873815").unwrap(); let verifier_hash_input_key = convert_password_to_key( password, key_hash_algorithm, @@ -813,20 +764,20 @@ mod tests { let encrypted_verifier_hash_input = crypt( true, - key_cipher_algorithm, - key_cipher_chaining, &verifier_hash_input_key, &key_salt_value, &verifier_hash_input, ) .unwrap(); - //let converted = encode_hex(&encrypted_verifier_hash_input); - //assert_eq!(&converted, "2fb9eea58e227ffa549449e941f1199e"); + // Uncomment the following lines to check the encrypted verifier hash input + // let converted = encode_hex(&encrypted_verifier_hash_input); + // assert_eq!(&converted, "2fb9eea58e227ffa549449e941f1199e"); - // verifier_hash_value - let verifier_hash_value = hash(key_hash_algorithm, vec![&verifier_hash_input]).unwrap(); - //let converted = encode_hex(&verifier_hash_value); - //assert_eq!(&converted, "920b1de74f38d9cb3ccb3394119ed37e958404fdc47560b1bf647d3c49c22549625fe4a0bd36798bd68a0d98ae64f6ab64a330c9890c62bb740aa492c226ae1f"); + // Verifier hash value + let verifier_hash_value = hash(key_hash_algorithm, &[&verifier_hash_input]).unwrap(); + // Uncomment the following lines to check the verifier hash value + // let converted = encode_hex(&verifier_hash_value); + // assert_eq!(&converted, "920b1de74f38d9cb3ccb3394119ed37e958404fdc47560b1bf647d3c49c22549625fe4a0bd36798bd68a0d98ae64f6ab64a330c9890c62bb740aa492c226ae1f"); let verifier_hash_value_key = convert_password_to_key( password, @@ -836,39 +787,45 @@ mod tests { key_key_bits, BLOCK_VERIFIER_HASH_VALUE, ); - //let converted = encode_hex(&verifier_hash_value_key); - //assert_eq!(&converted, "d5515a6062e3e99551b80b92db1fe646483884cdb63e1e7595a9f2cca7532884"); + // Uncomment the following lines to check the verifier hash value key + // let converted = encode_hex(&verifier_hash_value_key); + // assert_eq!( + // &converted, + // "d5515a6062e3e99551b80b92db1fe646483884cdb63e1e7595a9f2cca7532884" + // ); let encrypted_verifier_hash_value = crypt( true, - key_cipher_algorithm, - key_cipher_chaining, &verifier_hash_value_key, &key_salt_value, &verifier_hash_value, ) .unwrap(); - //let converted = encode_hex(&encrypted_verifier_hash_value); - //assert_eq!(&converted, "0d9c888111b40b630b739c95a5f5b6be67c8f96acdd1bee185bd808b507f652760a2e77f63a6ad0c46f985f2bb8dab4fcf9b86d6a40d9c21299bb4ddf788b250"); - - // XML + // Uncomment the following lines to check the encrypted verifier hash value + // let converted = encode_hex(&encrypted_verifier_hash_value); + // assert_eq!( + // &converted, + // "0d9c888111b40b630b739c95a5f5b6be67c8f96acdd1bee185bd808b507f652760a2e77f63a6ad0c46f985f2bb8dab4fcf9b86d6a40d9c21299bb4ddf788b250" + // ); + + // Build encryption info let _unused = build_encryption_info( &package_salt_value, package_block_size, - package_key_bits, - package_hash_size, - package_cipher_algorithm, - package_cipher_chaining, + package_key.len() * 8, + 64, // package_hash_size + PACKAGE_CIPHER_ALGORITHM, + "ChainingModeCBC", package_hash_algorithm, &encrypted_hmac_key, &encrypted_hmac_value, key_spin_count, &key_salt_value, - key_block_size, + KEY_BLOCK_SIZE, key_key_bits, - key_hash_size, - key_cipher_algorithm, - key_cipher_chaining, + KEY_HASH_SIZE, + KEY_CIPHER_ALGORITHM, + "ChainingModeCBC", key_hash_algorithm, &encrypted_verifier_hash_input, &encrypted_verifier_hash_value, @@ -881,19 +838,23 @@ mod tests { let package_salt_value = decode_hex("4c251b321d85cecfcb6d952ba6d81846").unwrap(); let result = hash( "SHA512", - vec![&package_salt_value, BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY], + &[&package_salt_value, BLOCK_KEYS_DATA_INTEGRITY_HMAC_KEY], ) .unwrap(); let converted = encode_hex(&result); - assert_eq!(&converted, "ba1bf00eed82b07ee65e574eb1f460435d2a1405e81904fd01d5ed5adf43fdcfd8e9aeebad0c08065e0db20cdc8e4552744b61ad1b3cf9a3c5aad5b2a047e76b"); + assert_eq!( + &converted, + "ba1bf00eed82b07ee65e574eb1f460435d2a1405e81904fd01d5ed5adf43fdcfd8e9aeebad0c08065e0db20cdc8e4552744b61ad1b3cf9a3c5aad5b2a047e76b" + ); } #[test] fn test_buffer_slice() { + // Since buffer_slice is not defined in the new code, we can replicate its functionality inline let buffer = decode_hex("ba1bf00eed82b07ee65e574eb1f460435d2a1405e81904fd01d5ed5adf43fdcfd8e9aeebad0c08065e0db20cdc8e4552744b61ad1b3cf9a3c5aad5b2a047e76b").unwrap(); let start = 0; let end = 16; - let result = buffer_slice(&buffer, start, end); + let result = buffer[start..end].to_vec(); let converted = encode_hex(&result); assert_eq!(&converted, "ba1bf00eed82b07ee65e574eb1f46043"); } @@ -905,7 +866,7 @@ mod tests { "password", "SHA512", &key_salt_value, - 100000, + 100_000, 256, BLOCK_KEYS_KEY, ); From 71f0572d6e2cb95a2d1d840880df66967727f877 Mon Sep 17 00:00:00 2001 From: mxsr Date: Sat, 21 Dec 2024 19:31:44 +0100 Subject: [PATCH 005/167] refactor: fix typos, clippy lints --- src/helper/crypt.rs | 16 +++---- src/helper/number_format.rs | 90 ++++++++++++++++++------------------- src/lib.rs | 38 +++++++++------- src/structs/spreadsheet.rs | 2 +- 4 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/helper/crypt.rs b/src/helper/crypt.rs index 8445e108..b32f529e 100644 --- a/src/helper/crypt.rs +++ b/src/helper/crypt.rs @@ -353,8 +353,8 @@ fn hmac(algorithm: &str, key: &[u8], buffers: &[&[u8]]) -> Result, Strin "SHA512" | "SHA-512" => { type HmacSha512 = Hmac; - let mut mac = HmacSha512::new_from_slice(key) - .map_err(|e| format!("Error creating HMAC: {e}"))?; + let mut mac = + HmacSha512::new_from_slice(key).map_err(|e| format!("Error creating HMAC: {e}"))?; for buffer in buffers { mac.update(buffer); } @@ -418,10 +418,7 @@ fn convert_password_to_key( block_key: &[u8], ) -> Vec { // Convert password to UTF-16LE bytes - let password_bytes: Vec = password - .encode_utf16() - .flat_map(u16::to_le_bytes) - .collect(); + let password_bytes: Vec = password.encode_utf16().flat_map(u16::to_le_bytes).collect(); // Generate the initial hash let mut key = hash(hash_algorithm, &[salt_value, &password_bytes]).unwrap(); @@ -457,10 +454,7 @@ fn convert_password_to_hash( spin_count: usize, ) -> Vec { // Convert password to UTF-16LE bytes - let password_bytes: Vec = password - .encode_utf16() - .flat_map(u16::to_le_bytes) - .collect(); + let password_bytes: Vec = password.encode_utf16().flat_map(u16::to_le_bytes).collect(); // Generate the initial hash let mut hash_value = hash(hash_algorithm, &[salt_value, &password_bytes]).unwrap(); @@ -648,7 +642,7 @@ mod tests { fn encode_hex(bytes: &[u8]) -> String { let mut s = String::with_capacity(bytes.len() * 2); for &b in bytes { - write!(&mut s, "{:02x}", b).unwrap(); + write!(&mut s, "{b:02x}").unwrap(); } s } diff --git a/src/helper/number_format.rs b/src/helper/number_format.rs index 1d80afcd..e72faae9 100644 --- a/src/helper/number_format.rs +++ b/src/helper/number_format.rs @@ -239,182 +239,182 @@ fn split_format_compare(value: f64, cond: &str, val: f64, dfcond: &str, dfval: f fn test_to_formatted_string_date() { let value = String::from("45435"); // 2024/5/23 assert_eq!( - r#"2024-05-23"#, + r"2024-05-23", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_YYYYMMDD2) ); assert_eq!( - r#"2024-05-23"#, + r"2024-05-23", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_YYYYMMDD) ); assert_eq!( - r#"23-05-2024"#, + r"23-05-2024", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DDMMYYYY) ); assert_eq!( - r#"23/05/2024"#, + r"23/05/2024", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DDMMYYYYSLASH) ); assert_eq!( - r#"23/5/24"#, + r"23/5/24", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DMYSLASH) ); assert_eq!( - r#"23-5-24"#, + r"23-5-24", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DMYMINUS) ); assert_eq!( - r#"23-5"#, + r"23-5", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DMMINUS) ); assert_eq!( - r#"5-24"#, + r"5-24", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_MYMINUS) ); assert_eq!( - r#"05-23-24"#, + r"05-23-24", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX14) ); assert_eq!( - r#"23-May-24"#, + r"23-May-24", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX15) ); assert_eq!( - r#"23-May"#, + r"23-May", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX16) ); assert_eq!( - r#"May-24"#, + r"May-24", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX17) ); assert_eq!( - r#"5/23/24 0:00"#, + r"5/23/24 0:00", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX22) ); assert_eq!( - r#"23/5/24 0:00"#, + r"23/5/24 0:00", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DATETIME) ); assert_eq!( - r#"12:00 am"#, + r"12:00 am", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME1) ); assert_eq!( - r#"12:00:00 am"#, + r"12:00:00 am", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME2) ); assert_eq!( - r#"0:00"#, + r"0:00", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME3) ); assert_eq!( - r#"0:00:00"#, + r"0:00:00", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME4) ); assert_eq!( - r#"00:00"#, + r"00:00", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME5) ); assert_eq!( - r#"0:00:00"#, + r"0:00:00", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME6) ); assert_eq!( - r#"0:00:00"#, + r"0:00:00", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME8) ); assert_eq!( - r#"2024/05/23"#, + r"2024/05/23", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_YYYYMMDDSLASH) ); let value = String::from("44349.211134259262"); // 2021/06/02 05:04:02 assert_eq!( - r#"2021-06-02"#, + r"2021-06-02", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_YYYYMMDD2) ); assert_eq!( - r#"2021-06-02"#, + r"2021-06-02", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_YYYYMMDD) ); assert_eq!( - r#"02-06-2021"#, + r"02-06-2021", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DDMMYYYY) ); assert_eq!( - r#"02/06/2021"#, + r"02/06/2021", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DDMMYYYYSLASH) ); assert_eq!( - r#"2/6/21"#, + r"2/6/21", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DMYSLASH) ); assert_eq!( - r#"2-6-21"#, + r"2-6-21", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DMYMINUS) ); assert_eq!( - r#"2-6"#, + r"2-6", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DMMINUS) ); assert_eq!( - r#"6-21"#, + r"6-21", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_MYMINUS) ); assert_eq!( - r#"06-02-21"#, + r"06-02-21", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX14) ); assert_eq!( - r#"2-Jun-21"#, + r"2-Jun-21", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX15) ); assert_eq!( - r#"2-Jun"#, + r"2-Jun", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX16) ); assert_eq!( - r#"Jun-21"#, + r"Jun-21", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX17) ); assert_eq!( - r#"6/2/21 5:04"#, + r"6/2/21 5:04", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_XLSX22) ); assert_eq!( - r#"2/6/21 5:04"#, + r"2/6/21 5:04", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_DATETIME) ); assert_eq!( - r#"5:04 am"#, + r"5:04 am", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME1) ); assert_eq!( - r#"5:04:02 am"#, + r"5:04:02 am", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME2) ); assert_eq!( - r#"5:04"#, + r"5:04", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME3) ); assert_eq!( - r#"5:04:02"#, + r"5:04:02", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME4) ); assert_eq!( - r#"04:02"#, + r"04:02", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME5) ); assert_eq!( - r#"5:04:02"#, + r"5:04:02", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME6) ); assert_eq!( - r#"5:04:02"#, + r"5:04:02", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_TIME8) ); assert_eq!( - r#"2021/06/02"#, + r"2021/06/02", to_formatted_string(&value, NumberingFormat::FORMAT_DATE_YYYYMMDDSLASH) ); - assert_eq!(r#"2"#, to_formatted_string(&value, "d")) + assert_eq!(r"2", to_formatted_string(&value, "d")); } diff --git a/src/lib.rs b/src/lib.rs index d0be9e3e..8247f354 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,19 +147,24 @@ pub mod writer; pub use self::structs::*; -/// create new spreadsheet file. -/// # Arguments -/// # Return value -/// * Spreadsheet structs object. -/// # Examples -/// ``` -/// let mut book = umya_spreadsheet::new_file(); -/// ``` +/// Creates a new spreadsheet with default settings. +/// +/// Returns a new `Spreadsheet` instance initialized with: +/// - Default theme +/// - Default stylesheet +/// - One worksheet named "Sheet1" +/// - Active cell set to "A1" +/// - Sheet view configured with workbook view ID 0 +/// +/// # Panics +/// +/// Panics if unable to create a new worksheet named "Sheet1". This should never happen +/// with default settings since it's the first worksheet in a new spreadsheet. #[must_use] pub fn new_file() -> Spreadsheet { let mut spreadsheet = Spreadsheet::default(); spreadsheet.set_theme(drawing::Theme::get_default_value()); - spreadsheet.set_stylesheet_defalut_value(); + spreadsheet.set_stylesheet_default_value(); let worksheet = spreadsheet.new_sheet("Sheet1").unwrap(); worksheet.set_active_cell("A1"); let mut sheet_view = SheetView::default(); @@ -171,13 +176,14 @@ pub fn new_file() -> Spreadsheet { spreadsheet } -/// create new spreadsheet file. -/// not include worksheet. -/// At least one additional worksheet must be added before the correct file can be generated. +/// Creates a new empty spreadsheet without any worksheets. +/// +/// This function initializes a new spreadsheet with default theme and stylesheet settings. +/// At least one worksheet must be added before generating a valid file. +/// +/// # Returns +/// A new `Spreadsheet` instance with default configuration but no worksheets. /// -/// # Arguments -/// # Return value -/// * Spreadsheet structs object. /// # Examples /// ``` /// let mut book = umya_spreadsheet::new_file_empty_worksheet(); @@ -186,6 +192,6 @@ pub fn new_file() -> Spreadsheet { pub fn new_file_empty_worksheet() -> Spreadsheet { let mut spreadsheet = Spreadsheet::default(); spreadsheet.set_theme(drawing::Theme::get_default_value()); - spreadsheet.set_stylesheet_defalut_value(); + spreadsheet.set_stylesheet_default_value(); spreadsheet } diff --git a/src/structs/spreadsheet.rs b/src/structs/spreadsheet.rs index e33baf8d..d275bfec 100644 --- a/src/structs/spreadsheet.rs +++ b/src/structs/spreadsheet.rs @@ -298,7 +298,7 @@ impl Spreadsheet { /// (This method is crate only.) /// Set Default Value Stylesheet. #[inline] - pub(crate) fn set_stylesheet_defalut_value(&mut self) -> &mut Self { + pub(crate) fn set_stylesheet_default_value(&mut self) -> &mut Self { self.stylesheet.set_defalut_value(); self } From f3de7699e001e338867b80dc09ce454d54d1a858 Mon Sep 17 00:00:00 2001 From: mxsr Date: Sat, 21 Dec 2024 19:57:04 +0100 Subject: [PATCH 006/167] refactor(helper/coordinate.rs): remove lazy_static, add comments --- Cargo.toml | 2 + src/helper/coordinate.rs | 320 ++++++++++++++++++++++++++++++++++----- 2 files changed, 288 insertions(+), 34 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 78925227..3e3ffaf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,3 +71,5 @@ perf = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } cargo = { level = "warn", priority = -1 } suspicious = { level = "warn", priority = -1 } + +module_name_repetitions = "allow" diff --git a/src/helper/coordinate.rs b/src/helper/coordinate.rs index a518f8a7..ecf9a05e 100644 --- a/src/helper/coordinate.rs +++ b/src/helper/coordinate.rs @@ -1,12 +1,28 @@ use std::iter::successors; +use std::sync::OnceLock; -use fancy_regex::Regex; +use regex::Regex; +/// Converts a 1-based index to a string representation using letters +/// similar to Excel column naming (e.g., 1 -> "A", 27 -> "AA"). +/// +/// # Arguments +/// +/// * `index` - A 1-based index to convert to a string. Must be greater than or equal to 1. +/// +/// # Returns +/// +/// A `String` representing the column name corresponding to the given index. +/// +/// # Panics +/// +/// Panics if the `index` is less than 1. fn index_to_alpha(index: u32) -> String { + const BASE_CHAR_CODE: u32 = 'A' as u32; // char 'A' + assert!(index >= 1, "Index cannot be less than one."); - const BASE_CHAR_CODE: u32 = 'A' as u32; - // below code is based on the source code of `radix_fmt` + // Generate the sequence of characters for the given index successors(Some(index - 1), |index| match index / 26u32 { 0 => None, n => Some(n - 1), @@ -19,13 +35,29 @@ fn index_to_alpha(index: u32) -> String { .collect() } +/// Converts a string representation of a column name (e.g., "A", "AA") +/// to its corresponding 1-based index. +/// +/// # Arguments +/// +/// * `alpha` - A string slice or reference to a string representing the column name. +/// +/// # Returns +/// +/// A `u32` representing the 1-based index corresponding to the given column name. +/// +/// # Examples +/// +/// ``` +/// let index = alpha_to_index("AA"); +/// assert_eq!(index, 27); +/// ``` fn alpha_to_index(alpha: S) -> u32 where S: AsRef, { const BASE_CHAR_CODE: u32 = 'A' as u32; - // since we only allow up to three characters, we can use pre-computed - /// powers of 26 `[26^0, 26^1, 26^2]` + // Pre-computed powers of 26 for up to three characters const POSITIONAL_CONSTANTS: [u32; 3] = [1, 26, 676]; alpha @@ -36,12 +68,32 @@ where .map(|(index, v)| { let vn = (v as u32 - BASE_CHAR_CODE) + 1; - // 26u32.pow(index as u32) * vn POSITIONAL_CONSTANTS[index] * vn }) .sum::() } +/// Converts a column name string to its corresponding 1-based index, +/// returning 0 if the input is "0". +/// +/// # Arguments +/// +/// * `column` - A string slice or reference to a string representing the column name. +/// +/// # Returns +/// +/// A `u32` representing the 1-based index corresponding to the given column name, +/// or 0 if the input is "0". +/// +/// # Examples +/// +/// ``` +/// let index = column_index_from_string("AA"); +/// assert_eq!(index, 27); +/// +/// let index_zero = column_index_from_string("0"); +/// assert_eq!(index_zero, 0); +/// ``` #[inline] pub fn column_index_from_string>(column: S) -> u32 { let column_c = column.as_ref(); @@ -52,6 +104,32 @@ pub fn column_index_from_string>(column: S) -> u32 { alpha_to_index(column_c) } +/// Converts a 1-based column index to its corresponding Excel-style column label. +/// +/// This function takes a column index starting from 1 and returns a string representing +/// the column label as used in Excel (e.g., 1 -> "A", 27 -> "AA"). +/// +/// # Parameters +/// +/// - `column_index`: A 1-based column index. Must be greater than or equal to 1. +/// +/// # Returns +/// +/// A `String` representing the Excel-style column label. +/// +/// # Panics +/// +/// Panics if the `column_index` is less than 1, as column numbering starts from 1. +/// +/// # Examples +/// +/// ``` +/// let label = string_from_column_index(1); +/// assert_eq!(label, "A"); +/// +/// let label = string_from_column_index(28); +/// assert_eq!(label, "AB"); +/// ``` #[inline] #[must_use] pub fn string_from_column_index(column_index: u32) -> String { @@ -60,40 +138,90 @@ pub fn string_from_column_index(column_index: u32) -> String { index_to_alpha(column_index) } +/// Parses an Excel-style coordinate string into column and row indices, along with lock flags. +/// +/// This function takes a coordinate string, which may include column letters and row numbers, +/// and optional '$' symbols indicating locked columns or rows. It returns a tuple containing +/// the column index, row index, and optional lock flags for each. +/// +/// # Type Parameters +/// +/// - `T`: A type that can be referenced as a string slice, such as `&str` or `String`. +/// +/// # Parameters +/// +/// - `coordinate`: The coordinate string to parse. It should be in the format of Excel cell +/// references, such as "A1", "$B$2", or "C$3". /// /// # Returns -/// A tuple with the column, and row address indexes and their respective lock flags. -///
-/// i.e. `(col, row, col_lock_flg, row_lock_flg)` -/// ## Note: -/// The minimum value for `col` and `row` is 1 +/// +/// A tuple `(Option, Option, Option, Option)` where: +/// - The first element is the column index, if present, calculated using `alpha_to_index`. +/// - The second element is the row index, if present, parsed as a `u32`. +/// - The third element is a flag indicating if the column is locked, if applicable. +/// - The fourth element is a flag indicating if the row is locked, if applicable. +/// +/// # Examples +/// +/// ``` +/// let (col, row, col_lock, row_lock) = index_from_coordinate("$AB$12"); +/// assert_eq!(col, Some(28)); // 'AB' corresponds to column index 28 +/// assert_eq!(row, Some(12)); +/// assert_eq!(col_lock, Some(true)); +/// assert_eq!(row_lock, Some(true)); +/// ``` +/// +/// # Panics +/// +/// This function does not panic. It returns `None` for column or row indices if they cannot be parsed. pub fn index_from_coordinate(coordinate: T) -> CellIndex where T: AsRef, { - lazy_static! { - static ref RE: Regex = Regex::new(r"((\$)?([A-Z]{1,3}))?((\$)?([0-9]+))?").unwrap(); - } + static RE: OnceLock = OnceLock::new(); + let re = RE.get_or_init(|| Regex::new(r"((\$)?([A-Z]{1,3}))?((\$)?([0-9]+))?").unwrap()); - let caps = RE.captures(coordinate.as_ref()).ok().flatten(); + re.captures(coordinate.as_ref()) + .map(|v| { + let col = v.get(3).map(|v| alpha_to_index(v.as_str())); // col number: [A-Z]{1,3} + let row = v.get(6).and_then(|v| v.as_str().parse::().ok()); // row number: [0-9]+ - caps.map(|v| { - let col = v.get(3).map(|v| alpha_to_index(v.as_str())); // col number: [A-Z]{1,3} - let row = v.get(6).and_then(|v| v.as_str().parse::().ok()); // row number: [0-9]+ + let col_lock_flg = col.map(|_col| { + v.get(2).is_some() // col lock flag: (\$)? + }); - let col_lock_flg = col.map(|_col| { - v.get(2).is_some() // col lock flag: (\$)? - }); + let row_lock_flg = row.map(|_row| { + v.get(5).is_some() // row lock flag: (\$)? + }); - let row_lock_flg = row.map(|_row| { - v.get(5).is_some() // row lock flag: (\$)? - }); - - (col, row, col_lock_flg, row_lock_flg) - }) - .unwrap_or_default() + (col, row, col_lock_flg, row_lock_flg) + }) + .unwrap_or_default() } +/// Converts a column index and row index into an Excel-style coordinate string. +/// +/// This function takes a 1-based column index and a row index, and returns a string +/// representing the coordinate in Excel format (e.g., (1, 1) -> "A1"). +/// +/// # Parameters +/// +/// - `col`: A 1-based column index. Must be greater than or equal to 1. +/// - `row`: A 1-based row index. Must be greater than or equal to 1. +/// +/// # Returns +/// +/// A `String` representing the Excel-style coordinate. +/// +/// # Examples +/// +/// ``` +/// let coordinate = coordinate_from_index(1, 1); +/// assert_eq!(coordinate, "A1"); +/// +/// let coordinate = coordinate_from_index(28, 3); +/// assert_eq!(coordinate, "AB3"); +/// ``` #[inline] #[must_use] pub fn coordinate_from_index(col: u32, row: u32) -> String { @@ -116,6 +244,31 @@ pub fn coordinate_from_index_with_lock( ) } +/// Adjusts a coordinate index by inserting an offset if conditions are met. +/// +/// This function checks if the given `num` is greater than or equal to `root_num` +/// and if `offset_num` is not zero. If both conditions are satisfied, it returns +/// the sum of `num` and `offset_num`. Otherwise, it returns `num` unchanged. +/// +/// # Parameters +/// +/// - `num`: The original coordinate index to be adjusted. +/// - `root_num`: The threshold coordinate index for applying the offset. +/// - `offset_num`: The offset to be added to `num` if conditions are met. +/// +/// # Returns +/// +/// A `u32` representing the adjusted coordinate index. +/// +/// # Examples +/// +/// ``` +/// let adjusted = adjustment_insert_coordinate(5, 3, 2); +/// assert_eq!(adjusted, 7); // 5 + 2 since 5 >= 3 and offset is not zero +/// +/// let adjusted = adjustment_insert_coordinate(2, 3, 2); +/// assert_eq!(adjusted, 2); // No adjustment since 2 < 3 +/// ``` #[inline] pub(crate) fn adjustment_insert_coordinate(num: u32, root_num: u32, offset_num: u32) -> u32 { if num >= root_num && offset_num != 0 { @@ -125,6 +278,31 @@ pub(crate) fn adjustment_insert_coordinate(num: u32, root_num: u32, offset_num: } } +/// Adjusts a coordinate index by removing an offset if conditions are met. +/// +/// This function checks if the given `num` is greater than or equal to `root_num` +/// and if `offset_num` is not zero. If both conditions are satisfied, it returns +/// the result of subtracting `offset_num` from `num`. Otherwise, it returns `num` unchanged. +/// +/// # Parameters +/// +/// - `num`: The original coordinate index to be adjusted. +/// - `root_num`: The threshold coordinate index for applying the offset. +/// - `offset_num`: The offset to be subtracted from `num` if conditions are met. +/// +/// # Returns +/// +/// A `u32` representing the adjusted coordinate index. +/// +/// # Examples +/// +/// ``` +/// let adjusted = adjustment_remove_coordinate(5, 3, 2); +/// assert_eq!(adjusted, 3); // 5 - 2 since 5 >= 3 and offset is not zero +/// +/// let adjusted = adjustment_remove_coordinate(2, 3, 2); +/// assert_eq!(adjusted, 2); // No adjustment since 2 < 3 +/// ``` #[inline] pub(crate) fn adjustment_remove_coordinate(num: u32, root_num: u32, offset_num: u32) -> u32 { if num >= root_num && offset_num != 0 { @@ -134,6 +312,32 @@ pub(crate) fn adjustment_remove_coordinate(num: u32, root_num: u32, offset_num: } } +/// Determines if a coordinate index falls within a removable range. +/// +/// This function checks whether the given `num` is within the range defined by +/// `root_num` and `offset_num`. Specifically, it returns `true` if `num` is greater +/// than or equal to `root_num` and less than the sum of `root_num` and `offset_num`, +/// provided both `root_num` and `offset_num` are non-zero. +/// +/// # Parameters +/// +/// - `num`: The coordinate index to check. +/// - `root_num`: The starting index of the range. +/// - `offset_num`: The length of the range to be checked. +/// +/// # Returns +/// +/// A `bool` indicating whether `num` is within the removable range. +/// +/// # Examples +/// +/// ``` +/// let is_removable = is_remove_coordinate(5, 3, 2); +/// assert_eq!(is_removable, true); // 5 is within the range [3, 5) +/// +/// let is_removable = is_remove_coordinate(6, 3, 2); +/// assert_eq!(is_removable, false); // 6 is outside the range [3, 5) +/// ``` #[inline] pub(crate) fn is_remove_coordinate(num: u32, root_num: u32, offset_num: u32) -> bool { if root_num != 0 && offset_num != 0 { @@ -142,16 +346,33 @@ pub(crate) fn is_remove_coordinate(num: u32, root_num: u32, offset_num: u32) -> false } +/// Type alias for a tuple representing cell index information. +/// +/// This tuple contains: +/// - An optional column index (`Option`). +/// - An optional row index (`Option`). +/// - An optional column lock flag (`Option`). +/// - An optional row lock flag (`Option`). pub type CellIndex = (Option, Option, Option, Option); -/// Struct for representing cell coordinates with row and column numbers +/// Struct for representing cell coordinates with row and column numbers. #[derive(Clone, Debug)] pub struct CellCoordinates { - pub row: u32, - pub col: u32, + pub row: u32, // The 1-based row index of the cell. + pub col: u32, // The 1-based column index of the cell. } impl CellCoordinates { + /// Creates a new `CellCoordinates` instance with the specified column and row indices. + /// + /// # Parameters + /// + /// - `col`: The 1-based column index. + /// - `row`: The 1-based row index. + /// + /// # Returns + /// + /// A new `CellCoordinates` instance. #[inline] fn new(col: u32, row: u32) -> Self { CellCoordinates { row, col } @@ -159,6 +380,15 @@ impl CellCoordinates { } impl From<(u32, u32)> for CellCoordinates { + /// Converts a tuple of column and row indices into a `CellCoordinates` instance. + /// + /// # Parameters + /// + /// - `value`: A tuple containing the 1-based column and row indices. + /// + /// # Returns + /// + /// A `CellCoordinates` instance representing the specified indices. #[inline] fn from(value: (u32, u32)) -> Self { CellCoordinates::new(value.0, value.1) @@ -166,14 +396,36 @@ impl From<(u32, u32)> for CellCoordinates { } impl From for CellCoordinates { + /// Converts a string representation of a cell coordinate into a `CellCoordinates` instance. + /// + /// The string is expected to be in Excel-style format (e.g., "A1"). + /// + /// # Parameters + /// + /// - `value`: A string containing the cell coordinate. + /// + /// # Returns + /// + /// A `CellCoordinates` instance representing the specified coordinate. #[inline] fn from(value: String) -> Self { - let str_ref: &str = value.as_ref(); - str_ref.into() + value.as_str().into() } } impl From<&str> for CellCoordinates { + /// Converts a string slice representation of a cell coordinate into a `CellCoordinates` instance. + /// + /// The string is expected to be in Excel-style format (e.g., "A1"). The function converts + /// the string to uppercase before parsing. + /// + /// # Parameters + /// + /// - `value`: A string slice containing the cell coordinate. + /// + /// # Returns + /// + /// A `CellCoordinates` instance representing the specified coordinate. #[inline] fn from(value: &str) -> Self { let (col, row, ..) = index_from_coordinate(value.to_uppercase()); @@ -196,7 +448,7 @@ mod tests { assert_eq!(column_index_from_string("ZZ"), 702); assert_eq!(column_index_from_string("AAA"), 703); assert_eq!(column_index_from_string("LAV"), 8160); - assert_eq!(column_index_from_string("XFD"), 16384); // Max. supported by Excel 2102 + assert_eq!(column_index_from_string("XFD"), 16384); // Max. supported by Excel 2012 } #[test] From aaaec5f799546a2eba7e70e526fb92d062c9f914 Mon Sep 17 00:00:00 2001 From: mxsr Date: Sat, 21 Dec 2024 20:08:50 +0100 Subject: [PATCH 007/167] refactor: replace `lazy_static` with built-in `std::sync::OnceLock` --- Cargo.toml | 1 - src/helper/formula.rs | 10 ++- src/helper/number_format.rs | 43 +++++++++---- src/helper/number_format/number_formater.rs | 71 ++++++++------------- src/lib.rs | 3 - src/structs/address.rs | 11 ++-- src/structs/image.rs | 10 ++- src/structs/numbering_format.rs | 49 ++++++++------ src/structs/numbering_formats.rs | 2 +- 9 files changed, 110 insertions(+), 90 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e3ffaf2..294ae164 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ fancy-regex = "0.14.0" hmac = "0.12.1" html_parser = "0.7.0" image = { version = "0.25.5", optional = true } -lazy_static = "1.5.0" md-5 = "0.10.6" regex = "1.11.1" sha2 = "0.10.8" diff --git a/src/helper/formula.rs b/src/helper/formula.rs index a3051ef6..ba1c3ddf 100644 --- a/src/helper/formula.rs +++ b/src/helper/formula.rs @@ -6,6 +6,7 @@ use crate::helper::coordinate::{ use crate::helper::range::{get_join_range, get_split_range}; use crate::structs::StringValue; use fancy_regex::Regex; +use std::sync::OnceLock; /** PARTLY BASED ON: */ /** Copyright (c) 2007 E. W. Bachtal, Inc. */ @@ -118,8 +119,11 @@ pub const ERRORS: &[&str] = &[ ]; const COMPARATORS_MULTI: &[&str] = &[">=", "<=", "<>"]; -lazy_static! { - pub static ref SCIENTIFIC_REGEX: Regex = Regex::new(r"/^[1-9]{1}(\\.\\d+)?E{1}$/").unwrap(); +// Initialize the OnceLock for the Regex +static SCIENTIFIC_REGEX: OnceLock = OnceLock::new(); + +fn get_scientific_regex() -> &'static Regex { + SCIENTIFIC_REGEX.get_or_init(|| Regex::new(r"/^[1-9]{1}(\\.\\d+)?E{1}$/").unwrap()) } pub(crate) fn parse_to_tokens>(formula: S) -> Vec { @@ -227,7 +231,7 @@ pub(crate) fn parse_to_tokens>(formula: S) -> Vec if let Some(current_char) = formula.chars().nth(index) { if OPERATORS_SN.contains(current_char) && value.len() > 1 - && SCIENTIFIC_REGEX + && get_scientific_regex() .is_match(¤t_char.to_string()) .unwrap_or(false) { diff --git a/src/helper/number_format.rs b/src/helper/number_format.rs index e72faae9..4bc83098 100644 --- a/src/helper/number_format.rs +++ b/src/helper/number_format.rs @@ -4,6 +4,7 @@ mod number_formater; mod percentage_formater; use std::borrow::Cow; +use std::sync::OnceLock; use crate::structs::Color; use crate::structs::NumberingFormat; @@ -48,13 +49,30 @@ impl<'t> Iterator for Split<'_, 't> { } } -lazy_static! { - pub static ref ESCAPE_REGEX: Regex = - Regex::new(r#"(\\\(((.)(?!((AM\/PM)|(A\/P)))|([^ ])))(?=(?:[^"]|"[^"]*")*$)"#).unwrap(); - pub static ref SECTION_REGEX: Regex = Regex::new(r#"(;)(?=(?:[^"]|"[^"]*")*$)"#).unwrap(); - pub static ref DATE_TIME_REGEX: Regex = - Regex::new(r#"(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy](?=(?:[^"]|"[^"]*")*$)"#).unwrap(); - pub static ref PERCENT_DOLLAR_REGEX: Regex = Regex::new("%$").unwrap(); +// Initialize OnceLock for each Regex +static ESCAPE_REGEX: OnceLock = OnceLock::new(); +static SECTION_REGEX: OnceLock = OnceLock::new(); +static DATE_TIME_REGEX: OnceLock = OnceLock::new(); +static PERCENT_DOLLAR_REGEX: OnceLock = OnceLock::new(); + +pub fn get_escape_regex() -> &'static Regex { + ESCAPE_REGEX.get_or_init(|| { + Regex::new(r#"(\\\(((.)(?!((AM\/PM)|(A\/P)))|([^ ])))(?=(?:[^"]|"[^"]*")*$)"#).unwrap() + }) +} + +pub fn get_section_regex() -> &'static Regex { + SECTION_REGEX.get_or_init(|| Regex::new(r#"(;)(?=(?:[^"]|"[^"]*")*$)"#).unwrap()) +} + +pub fn get_date_time_regex() -> &'static Regex { + DATE_TIME_REGEX.get_or_init(|| { + Regex::new(r#"(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy](?=(?:[^"]|"[^"]*")*$)"#).unwrap() + }) +} + +pub fn get_percent_dollar_regex() -> &'static Regex { + PERCENT_DOLLAR_REGEX.get_or_init(|| Regex::new("%$").unwrap()) } pub fn to_formatted_string, P: AsRef>(value: S, format: P) -> String { @@ -78,11 +96,11 @@ pub fn to_formatted_string, P: AsRef>(value: S, format: P) -> // Convert any other escaped characters to quoted strings, e.g. (\T to "T") - let mut format = ESCAPE_REGEX.replace_all(&format, r#""$0""#); + let mut format = get_escape_regex().replace_all(&format, r#""$0""#); // Get the sections, there can be up to four sections, separated with a semi-colon (but only if not a quoted literal) - let sections: Vec<&str> = split(&SECTION_REGEX, &format).collect(); + let sections: Vec<&str> = split(&get_section_regex(), &format).collect(); let (_, split_format, split_value) = split_format(sections, value.parse::().unwrap()); format = Cow::Owned(split_format); @@ -97,13 +115,16 @@ pub fn to_formatted_string, P: AsRef>(value: S, format: P) -> // Check for date/time characters (not inside quotes) - if DATE_TIME_REGEX.is_match(&format).unwrap_or(false) { + if get_date_time_regex().is_match(&format).unwrap_or(false) { // datetime format value = date_formater::format_as_date(value.parse::().unwrap(), &format); } else if format.starts_with('"') && format.ends_with('"') { let conv_format = format.trim_matches('"').parse::().unwrap(); value = Cow::Owned(conv_format.to_string()); - } else if PERCENT_DOLLAR_REGEX.is_match(&format).unwrap_or(false) { + } else if get_percent_dollar_regex() + .is_match(&format) + .unwrap_or(false) + { // % number format value = percentage_formater::format_as_percentage(value.parse::().unwrap(), &format); } else { diff --git a/src/helper/number_format/number_formater.rs b/src/helper/number_format/number_formater.rs index 7b84fac8..13773ff2 100644 --- a/src/helper/number_format/number_formater.rs +++ b/src/helper/number_format/number_formater.rs @@ -1,79 +1,65 @@ use super::fraction_formater::format_as_fraction; use fancy_regex::Regex; use std::borrow::Cow; +use std::sync::OnceLock; use thousands::Separable; +// Initialize OnceLock for each Regex +static THOUSANDS_SEP_REGEX: OnceLock = OnceLock::new(); +static SCALE_REGEX: OnceLock = OnceLock::new(); +static TRAILING_COMMA_REGEX: OnceLock = OnceLock::new(); +static FRACTION_REGEX: OnceLock = OnceLock::new(); +static SQUARE_BRACKET_REGEX: OnceLock = OnceLock::new(); +static NUMBER_REGEX: OnceLock = OnceLock::new(); + pub(crate) fn format_as_number(value: f64, format: &str) -> Cow { - lazy_static! { - static ref THOUSANDS_SEP_REGEX: Regex = Regex::new(r"(#,#|0,0)").unwrap(); - static ref SCALE_REGEX: Regex = Regex::new(r"(#|0)(,+)").unwrap(); - static ref TRAILING_COMMA_REGEX: Regex = Regex::new("(#|0),+").unwrap(); - static ref FRACTION_REGEX: Regex = Regex::new(r"#?.*\?{1,2}\/\?{1,2}").unwrap(); - static ref SQUARE_BRACKET_REGEX: Regex = Regex::new(r"\[[^\]]+\]").unwrap(); - static ref NUMBER_REGEX: Regex = Regex::new(r"(0+)(\.?)(0*)").unwrap(); - } + // Initialize regex patterns using OnceLock + let thousands_sep_regex = THOUSANDS_SEP_REGEX.get_or_init(|| Regex::new(r"(#,#|0,0)").unwrap()); + let scale_regex = SCALE_REGEX.get_or_init(|| Regex::new(r"(#|0)(,+)").unwrap()); + let trailing_comma_regex = TRAILING_COMMA_REGEX.get_or_init(|| Regex::new("(#|0),+").unwrap()); + let fraction_regex = + FRACTION_REGEX.get_or_init(|| Regex::new(r"#?.*\?{1,2}\/\?{1,2}").unwrap()); + let square_bracket_regex = + SQUARE_BRACKET_REGEX.get_or_init(|| Regex::new(r"\[[^\]]+\]").unwrap()); + let number_regex = NUMBER_REGEX.get_or_init(|| Regex::new(r"(0+)(\.?)(0*)").unwrap()); let mut value = value.to_string(); - // The "_" in this string has already been stripped out, - // so this test is never true. Furthermore, testing - // on Excel shows this format uses Euro symbol, not "EUR". - //if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) { - // return 'EUR ' . sprintf('%1.2f', $value); - //} - - // Some non-number strings are quoted, so we'll get rid of the quotes, likewise any positional * symbols let mut format = format.replace(['"', '*'], ""); - // Find out if we need thousands separator - // This is indicated by a comma enclosed by a digit placeholder: - // #,# or 0,0 - - let use_thousands = THOUSANDS_SEP_REGEX.is_match(&format).unwrap_or(false); + let use_thousands = thousands_sep_regex.is_match(&format).unwrap_or(false); if use_thousands { format = format.replace("0,0", "00"); format = format.replace("#,#", "##"); } - // Scale thousands, millions,... - // This is indicated by a number of commas after a digit placeholder: - // #, or 0.0,, - let mut scale: f64 = 1f64; // same as no scale + let mut scale: f64 = 1f64; - if SCALE_REGEX.is_match(&format).unwrap_or(false) { + if scale_regex.is_match(&format).unwrap_or(false) { let mut matches: Vec = Vec::new(); - for ite in SCALE_REGEX.captures(&format).ok().flatten().unwrap().iter() { + for ite in scale_regex.captures(&format).ok().flatten().unwrap().iter() { matches.push(ite.unwrap().as_str().to_string()); } scale = f64::from(1000i32.pow(matches[2].len() as u32)); - // strip the commas - format = TRAILING_COMMA_REGEX.replace_all(&format, "$1").into(); + format = trailing_comma_regex.replace_all(&format, "$1").into(); } - if FRACTION_REGEX.is_match(&format).unwrap_or(false) { + if fraction_regex.is_match(&format).unwrap_or(false) { if value.parse::().is_err() { - //println!("format as fraction {} {}", value, format); value = format_as_fraction(value.parse::().unwrap(), &format); } } else { - // Handle the number itself - - // scale number value = (value.parse::().unwrap() / scale).to_string(); - // Strip # format = format.replace('#', "0"); - // Remove \ format = format.replace('\\', ""); - // Remove locale code [$-###] format = format.replace("[$-.*]", ""); - // Trim format = format.trim().to_string(); - let m = SQUARE_BRACKET_REGEX.replace_all(&format, ""); + let m = square_bracket_regex.replace_all(&format, ""); - if NUMBER_REGEX.is_match(&m).unwrap_or(false) { + if number_regex.is_match(&m).unwrap_or(false) { let mut item: Vec = Vec::new(); - for ite in NUMBER_REGEX.captures(&m).ok().flatten().unwrap().iter() { + for ite in number_regex.captures(&m).ok().flatten().unwrap().iter() { item.push(ite.unwrap().as_str().to_string()); } value = format_straight_numeric_value( @@ -93,9 +79,6 @@ pub(crate) fn format_as_number(value: f64, format: &str) -> Cow { item.push(ite.unwrap().as_str().to_string()); } value = format!("{}{}", item.first().unwrap(), value); - // // Currency or Accounting - // let currency_code = item.get(1).unwrap().to_string(); - // value = Regex::new(r#"\[\$([^\]]*)\]"#).unwrap().replace_all(&value, currency_code.as_str()).to_string(); } Cow::Owned(value) diff --git a/src/lib.rs b/src/lib.rs index 8247f354..fa3352d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -136,9 +136,6 @@ extern crate html_parser; extern crate rand; extern crate sha2; -#[macro_use] -extern crate lazy_static; - pub mod helper; pub mod reader; pub mod structs; diff --git a/src/structs/address.rs b/src/structs/address.rs index b1973046..150d310e 100644 --- a/src/structs/address.rs +++ b/src/structs/address.rs @@ -4,6 +4,10 @@ use crate::helper::coordinate::index_from_coordinate; use crate::traits::AdjustmentCoordinate; use crate::traits::AdjustmentCoordinateWithSheet; use fancy_regex::Regex; +use std::sync::OnceLock; + +// Initialize OnceLock for the Regex +static RE: OnceLock = OnceLock::new(); #[derive(Clone, Default, Debug)] pub struct Address { @@ -84,10 +88,9 @@ impl Address { with_space_char = "'"; } if with_space_char.is_empty() { - lazy_static! { - static ref RE: Regex = Regex::new(r"[^0-9a-zA-Z]").unwrap(); - } - if RE.is_match(&sheet_name).unwrap_or(false) { + // Initialize the regex pattern using OnceLock + let re = RE.get_or_init(|| Regex::new(r"[^0-9a-zA-Z]").unwrap()); + if re.is_match(&sheet_name).unwrap_or(false) { with_space_char = "'"; } } diff --git a/src/structs/image.rs b/src/structs/image.rs index 7128de9b..e39e14c7 100644 --- a/src/structs/image.rs +++ b/src/structs/image.rs @@ -14,9 +14,13 @@ use std::fs::File; use std::io::BufReader; use std::io::Cursor; use std::io::Read; +use std::sync::OnceLock; -lazy_static! { - static ref EMPTY_VEC: Vec = Vec::new(); +// Initialize OnceLock for the Vec +static EMPTY_VEC: OnceLock> = OnceLock::new(); + +fn get_empty_vec() -> &'static Vec { + EMPTY_VEC.get_or_init(|| Vec::new()) } #[derive(Clone, Default, Debug)] @@ -213,7 +217,7 @@ impl Image { pub fn get_image_data(&self) -> &[u8] { match self.get_media_object().first() { Some(v) => v.get_image_data(), - None => &EMPTY_VEC, + None => &get_empty_vec(), } } diff --git a/src/structs/numbering_format.rs b/src/structs/numbering_format.rs index 22dab0f5..05bfc18b 100644 --- a/src/structs/numbering_format.rs +++ b/src/structs/numbering_format.rs @@ -7,6 +7,7 @@ use quick_xml::Reader; use quick_xml::Writer; use std::collections::HashMap; use std::io::Cursor; +use std::sync::OnceLock; #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct NumberingFormat { @@ -79,13 +80,15 @@ impl NumberingFormat { } pub fn set_number_format_id(&mut self, value: u32) -> &mut Self { - let format_code_result = FILL_BUILT_IN_FORMAT_CODES.iter().find_map(|(key, val)| { - if key == &value { - Some(val.clone()) - } else { - None - } - }); + let format_code_result = get_fill_built_in_format_codes() + .iter() + .find_map(|(key, val)| { + if key == &value { + Some(val.clone()) + } else { + None + } + }); self.format_code = format_code_result .expect("Not Found NumberFormatId.") @@ -114,7 +117,7 @@ impl NumberingFormat { /// ``` pub fn set_format_code>(&mut self, value: S) -> &mut Self { self.format_code = value.into().into_boxed_str(); - for (index, format) in FILL_BUILT_IN_FORMAT_CODES.iter() { + for (index, format) in get_fill_built_in_format_codes().iter() { if &*self.format_code == format { self.number_format_id = *index; self.is_build_in = true; @@ -178,9 +181,12 @@ impl NumberingFormat { } } -lazy_static! { - pub(crate) static ref FILL_BUILT_IN_FORMAT_CODES: HashMap = { - let mut map:HashMap = HashMap::new(); +pub(crate) static FILL_BUILT_IN_FORMAT_CODES: OnceLock> = OnceLock::new(); + +pub(crate) fn get_fill_built_in_format_codes() -> &'static HashMap { + FILL_BUILT_IN_FORMAT_CODES.get_or_init(|| { + let mut map: HashMap = HashMap::new(); + // General map.insert(0, NumberingFormat::FORMAT_GENERAL.to_string()); map.insert(1, "0".to_string()); @@ -193,7 +199,7 @@ lazy_static! { map.insert(11, "0.00E+00".to_string()); map.insert(12, "# ?/?".to_string()); map.insert(13, "# ??/??".to_string()); - map.insert(14, "m/d/yyyy".to_string()); // Despite ECMA 'mm-dd-yy"); + map.insert(14, "m/d/yyyy".to_string()); map.insert(15, "d-mmm-yy".to_string()); map.insert(16, "d-mmm".to_string()); map.insert(17, "mmm-yy".to_string()); @@ -201,17 +207,20 @@ lazy_static! { map.insert(19, "h:mm:ss AM/PM".to_string()); map.insert(20, "h:mm".to_string()); map.insert(21, "h:mm:ss".to_string()); - map.insert(22, "m/d/yyyy h:mm".to_string()); // Despite ECMA 'm/d/yy h:mm"); + map.insert(22, "m/d/yyyy h:mm".to_string()); - map.insert(37, "#,##0_);(#,##0)".to_string()); // Despite ECMA '#,##0 ;(#,##0)"); - map.insert(38, "#,##0_);[Red](#,##0)".to_string()); // Despite ECMA '#,##0 ;[Red](#,##0)"); - map.insert(39, "#,##0.00_);(#,##0.00)".to_string()); // Despite ECMA '#,##0.00;(#,##0.00)"); - map.insert(40, "#,##0.00_);[Red](#,##0.00)".to_string()); // Despite ECMA '#,##0.00;[Red](#,##0.00)"); + map.insert(37, "#,##0_);(#,##0)".to_string()); + map.insert(38, "#,##0_);[Red](#,##0)".to_string()); + map.insert(39, "#,##0.00_);(#,##0.00)".to_string()); + map.insert(40, "#,##0.00_);[Red](#,##0.00)".to_string()); - map.insert(44, r#"_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)"#.to_string()); + map.insert( + 44, + r#"_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)"#.to_string(), + ); map.insert(45, "mm:ss".to_string()); map.insert(46, "[h]:mm:ss".to_string()); - map.insert(47, "mm:ss.0".to_string()); // Despite ECMA 'mmss.0"); + map.insert(47, "mm:ss.0".to_string()); map.insert(48, "##0.0E+0".to_string()); map.insert(49, "@".to_string()); @@ -249,7 +258,7 @@ lazy_static! { map.insert(58, r#"[$-411]ggge"å¹´"m"月"d"æ—¥""#.to_string()); map - }; + }) } #[cfg(test)] diff --git a/src/structs/numbering_formats.rs b/src/structs/numbering_formats.rs index 26f9f662..94807171 100644 --- a/src/structs/numbering_formats.rs +++ b/src/structs/numbering_formats.rs @@ -39,7 +39,7 @@ impl NumberingFormats { } pub(crate) fn get_build_in_formats(&mut self) { - for (index, code) in super::numbering_format::FILL_BUILT_IN_FORMAT_CODES.iter() { + for (index, code) in super::numbering_format::get_fill_built_in_format_codes() { let mut obj = NumberingFormat::default(); obj.set_number_format_id_crate(*index) .set_format_code_crate(code.clone()); From 714bf078ad985a82c9063f6ff558ab6d40b5ef1d Mon Sep 17 00:00:00 2001 From: mxsr Date: Sat, 21 Dec 2024 21:34:00 +0100 Subject: [PATCH 008/167] refactor: replace `ThinVec` with rust-lang `Vec` --- Cargo.toml | 1 - src/helper/html.rs | 9 +++-- src/lib.rs | 1 - src/structs/borders_crate.rs | 5 ++- src/structs/cell_formats.rs | 5 ++- src/structs/cell_style_formats.rs | 5 ++- src/structs/cell_styles.rs | 5 ++- src/structs/color_scale.rs | 12 +++---- src/structs/column_breaks.rs | 5 ++- src/structs/column_fields.rs | 5 ++- src/structs/column_items.rs | 5 ++- src/structs/columns.rs | 5 ++- src/structs/conditional_formatting.rs | 7 ++-- src/structs/custom_properties/properties.rs | 9 ++--- src/structs/data_bar.rs | 12 +++---- src/structs/data_fields.rs | 5 ++- src/structs/data_validations.rs | 10 ++---- src/structs/defined_name.rs | 5 ++- src/structs/differential_formats.rs | 5 ++- src/structs/drawing/adjust_value_list.rs | 7 ++-- .../drawing/background_fill_style_list.rs | 13 ++++---- src/structs/drawing/charts/area_3d_chart.rs | 7 ++-- src/structs/drawing/charts/area_chart.rs | 7 ++-- .../drawing/charts/area_chart_series_list.rs | 8 ++--- src/structs/drawing/charts/bar_3d_chart.rs | 7 ++-- src/structs/drawing/charts/bar_chart.rs | 7 ++-- src/structs/drawing/charts/bubble_chart.rs | 7 ++-- src/structs/drawing/charts/line_3d_chart.rs | 7 ++-- src/structs/drawing/charts/line_chart.rs | 7 ++-- src/structs/drawing/charts/plot_area.rs | 19 +++++------ src/structs/drawing/charts/radar_chart.rs | 7 ++-- src/structs/drawing/charts/rich_text.rs | 5 ++- src/structs/drawing/charts/scatter_chart.rs | 7 ++-- src/structs/drawing/charts/string_literal.rs | 5 ++- src/structs/drawing/charts/text_properties.rs | 5 ++- src/structs/drawing/effect_style_list.rs | 10 ++---- src/structs/drawing/fill_style_list.rs | 13 ++++---- src/structs/drawing/font_collection_type.rs | 7 ++-- src/structs/drawing/gradient_stop_list.rs | 7 ++-- src/structs/drawing/line_style_list.rs | 7 ++-- src/structs/drawing/paragraph.rs | 3 +- .../drawing/spreadsheet/group_shape.rs | 9 +++-- src/structs/drawing/spreadsheet/text_body.rs | 5 ++- .../drawing/spreadsheet/worksheet_drawing.rs | 17 +++++----- src/structs/fills.rs | 5 ++- src/structs/fonts.rs | 5 ++- src/structs/gradient_fill.rs | 5 ++- src/structs/icon_set.rs | 9 +++-- src/structs/media_object.rs | 6 ++-- src/structs/merge_cells.rs | 5 ++- src/structs/mru_colors.rs | 5 ++- .../office/excel/reference_sequence.rs | 7 ++-- .../office2010/excel/data_validations.rs | 10 ++---- src/structs/ole_object.rs | 7 ++-- src/structs/ole_objects.rs | 5 ++- src/structs/page_setup.rs | 7 ++-- src/structs/pivot_fields.rs | 5 ++- src/structs/raw/raw_file.rs | 5 ++- src/structs/raw/raw_relationships.rs | 5 ++- src/structs/raw/raw_worksheet.rs | 5 ++- src/structs/rich_text.rs | 7 ++-- src/structs/row_breaks.rs | 5 ++- src/structs/row_items.rs | 5 ++- src/structs/sequence_of_references.rs | 7 ++-- src/structs/shared_string_table.rs | 5 ++- src/structs/sheet_view.rs | 5 ++- src/structs/sheet_views.rs | 5 ++- src/structs/spreadsheet.rs | 21 ++++++------ src/structs/stylesheet.rs | 3 +- src/structs/table.rs | 6 ++-- src/structs/worksheet.rs | 33 +++++++++---------- 71 files changed, 213 insertions(+), 304 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 294ae164..5555a756 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,6 @@ image = { version = "0.25.5", optional = true } md-5 = "0.10.6" regex = "1.11.1" sha2 = "0.10.8" -thin-vec = "0.2.13" thousands = "0.2.0" quick-xml = { version = "0.37.1", features = ["serialize"] } zip = { version = "2.2.1", default-features = false, features = ["deflate"] } diff --git a/src/helper/html.rs b/src/helper/html.rs index 2ad3239a..6d8c5de5 100644 --- a/src/helper/html.rs +++ b/src/helper/html.rs @@ -6,7 +6,6 @@ use crate::structs::UnderlineValues; use crate::structs::VerticalAlignmentRunValues; use html_parser::{Dom, Node}; use std::collections::HashMap; -use thin_vec::ThinVec; /// Generate rich text from html. /// # Arguments @@ -51,8 +50,8 @@ pub fn html_to_richtext_custom( } #[allow(clippy::field_reassign_with_default)] -fn read_node(node_list: &Vec, parent_element: &[HfdElement]) -> ThinVec { - let mut result: ThinVec = ThinVec::new(); +fn read_node(node_list: &Vec, parent_element: &[HfdElement]) -> Vec { + let mut result: Vec = Vec::new(); if node_list.is_empty() { return result; @@ -173,14 +172,14 @@ fn make_rich_text(html_flat_data_list: &[HtmlFlatData], method: &dyn AnalysisMet #[derive(Clone, Default, Debug)] pub struct HtmlFlatData { text: String, - element: ThinVec, + element: Vec, } #[derive(Clone, Default, Debug)] pub struct HfdElement { name: String, attributes: HashMap, - classes: ThinVec, + classes: Vec, } impl HfdElement { #[inline] diff --git a/src/lib.rs b/src/lib.rs index fa3352d2..d2ff4f5f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,7 +122,6 @@ extern crate fancy_regex; extern crate image; extern crate md5; extern crate quick_xml; -extern crate thin_vec; extern crate thousands; extern crate zip; diff --git a/src/structs/borders_crate.rs b/src/structs/borders_crate.rs index ade63bd1..c49871e2 100644 --- a/src/structs/borders_crate.rs +++ b/src/structs/borders_crate.rs @@ -7,11 +7,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct BordersCrate { - borders: ThinVec, + borders: Vec, } impl BordersCrate { @@ -22,7 +21,7 @@ impl BordersCrate { #[inline] #[allow(dead_code)] - pub(crate) fn get_borders_mut(&mut self) -> &mut ThinVec { + pub(crate) fn get_borders_mut(&mut self) -> &mut Vec { &mut self.borders } diff --git a/src/structs/cell_formats.rs b/src/structs/cell_formats.rs index 9bf3213b..6464a2eb 100644 --- a/src/structs/cell_formats.rs +++ b/src/structs/cell_formats.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct CellFormats { - cell_format: ThinVec, + cell_format: Vec, } impl CellFormats { @@ -20,7 +19,7 @@ impl CellFormats { } #[inline] - pub(crate) fn _get_cell_format_mut(&mut self) -> &mut ThinVec { + pub(crate) fn _get_cell_format_mut(&mut self) -> &mut Vec { &mut self.cell_format } diff --git a/src/structs/cell_style_formats.rs b/src/structs/cell_style_formats.rs index 5706cc26..b35d4d8e 100644 --- a/src/structs/cell_style_formats.rs +++ b/src/structs/cell_style_formats.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct CellStyleFormats { - cell_format: ThinVec, + cell_format: Vec, } impl CellStyleFormats { @@ -20,7 +19,7 @@ impl CellStyleFormats { } #[inline] - pub(crate) fn _get_cell_format_mut(&mut self) -> &mut ThinVec { + pub(crate) fn _get_cell_format_mut(&mut self) -> &mut Vec { &mut self.cell_format } diff --git a/src/structs/cell_styles.rs b/src/structs/cell_styles.rs index 997f4c8a..97c65259 100644 --- a/src/structs/cell_styles.rs +++ b/src/structs/cell_styles.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct CellStyles { - cell_style: ThinVec, + cell_style: Vec, } impl CellStyles { @@ -20,7 +19,7 @@ impl CellStyles { } #[inline] - pub fn _get_cell_style_mut(&mut self) -> &mut ThinVec { + pub fn _get_cell_style_mut(&mut self) -> &mut Vec { &mut self.cell_style } diff --git a/src/structs/color_scale.rs b/src/structs/color_scale.rs index 7c7f9056..f718d334 100644 --- a/src/structs/color_scale.rs +++ b/src/structs/color_scale.rs @@ -7,12 +7,11 @@ use quick_xml::events::Event; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct ColorScale { - cfvo_collection: ThinVec, - color_collection: ThinVec, + cfvo_collection: Vec, + color_collection: Vec, } impl ColorScale { @@ -23,10 +22,7 @@ impl ColorScale { } #[inline] - pub fn set_cfvo_collection( - &mut self, - value: ThinVec, - ) -> &mut Self { + pub fn set_cfvo_collection(&mut self, value: Vec) -> &mut Self { self.cfvo_collection = value; self } @@ -44,7 +40,7 @@ impl ColorScale { } #[inline] - pub fn set_color_collection(&mut self, value: impl Into>) -> &mut Self { + pub fn set_color_collection(&mut self, value: impl Into>) -> &mut Self { self.color_collection = value.into(); self } diff --git a/src/structs/column_breaks.rs b/src/structs/column_breaks.rs index 14368311..f9b7c37a 100644 --- a/src/structs/column_breaks.rs +++ b/src/structs/column_breaks.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct ColumnBreaks { - break_list: ThinVec, + break_list: Vec, } impl ColumnBreaks { @@ -21,7 +20,7 @@ impl ColumnBreaks { } #[inline] - pub fn get_break_list_mut(&mut self) -> &mut ThinVec { + pub fn get_break_list_mut(&mut self) -> &mut Vec { &mut self.break_list } diff --git a/src/structs/column_fields.rs b/src/structs/column_fields.rs index 71931653..3a88bd7b 100644 --- a/src/structs/column_fields.rs +++ b/src/structs/column_fields.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct ColumnFields { - list: ThinVec, + list: Vec, } impl ColumnFields { #[inline] @@ -20,7 +19,7 @@ impl ColumnFields { } #[inline] - pub fn get_list_mut(&mut self) -> &mut ThinVec { + pub fn get_list_mut(&mut self) -> &mut Vec { &mut self.list } diff --git a/src/structs/column_items.rs b/src/structs/column_items.rs index 63ced6d4..cb3a42fc 100644 --- a/src/structs/column_items.rs +++ b/src/structs/column_items.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct ColumnItems { - list: ThinVec, + list: Vec, } impl ColumnItems { #[inline] @@ -20,7 +19,7 @@ impl ColumnItems { } #[inline] - pub fn get_list_mut(&mut self) -> &mut ThinVec { + pub fn get_list_mut(&mut self) -> &mut Vec { &mut self.list } diff --git a/src/structs/columns.rs b/src/structs/columns.rs index 7ddf6765..19fb1ad8 100644 --- a/src/structs/columns.rs +++ b/src/structs/columns.rs @@ -10,11 +10,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct Columns { - column: ThinVec, + column: Vec, } impl Columns { @@ -24,7 +23,7 @@ impl Columns { } #[inline] - pub(crate) fn get_column_collection_mut(&mut self) -> &mut ThinVec { + pub(crate) fn get_column_collection_mut(&mut self) -> &mut Vec { &mut self.column } diff --git a/src/structs/conditional_formatting.rs b/src/structs/conditional_formatting.rs index 5b89f108..fd840f7b 100644 --- a/src/structs/conditional_formatting.rs +++ b/src/structs/conditional_formatting.rs @@ -9,12 +9,11 @@ use quick_xml::events::Event; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Default, Debug, Clone)] pub struct ConditionalFormatting { sequence_of_references: SequenceOfReferences, - conditional_collection: ThinVec, + conditional_collection: Vec, } impl ConditionalFormatting { @@ -42,14 +41,14 @@ impl ConditionalFormatting { } #[inline] - pub fn get_conditional_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_conditional_collection_mut(&mut self) -> &mut Vec { &mut self.conditional_collection } #[inline] pub fn set_conditional_collection( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut Self { self.conditional_collection = value.into(); self diff --git a/src/structs/custom_properties/properties.rs b/src/structs/custom_properties/properties.rs index cc9304ab..81d45a45 100644 --- a/src/structs/custom_properties/properties.rs +++ b/src/structs/custom_properties/properties.rs @@ -7,11 +7,10 @@ use quick_xml::events::Event; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Default, Debug, Clone)] pub struct Properties { - custom_document_property_list: ThinVec, + custom_document_property_list: Vec, } impl Properties { @@ -22,16 +21,14 @@ impl Properties { } #[inline] - pub fn get_custom_document_property_list_mut( - &mut self, - ) -> &mut ThinVec { + pub fn get_custom_document_property_list_mut(&mut self) -> &mut Vec { &mut self.custom_document_property_list } #[inline] pub fn set_custom_document_property_list( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut Self { self.custom_document_property_list = value.into(); self diff --git a/src/structs/data_bar.rs b/src/structs/data_bar.rs index c5a89b9f..d4762f47 100644 --- a/src/structs/data_bar.rs +++ b/src/structs/data_bar.rs @@ -7,12 +7,11 @@ use quick_xml::events::Event; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct DataBar { - cfvo_collection: ThinVec, - color_collection: ThinVec, + cfvo_collection: Vec, + color_collection: Vec, } impl DataBar { @@ -23,10 +22,7 @@ impl DataBar { } #[inline] - pub fn set_cfvo_collection( - &mut self, - value: ThinVec, - ) -> &mut Self { + pub fn set_cfvo_collection(&mut self, value: Vec) -> &mut Self { self.cfvo_collection = value; self } @@ -44,7 +40,7 @@ impl DataBar { } #[inline] - pub fn set_color_collection(&mut self, value: impl Into>) -> &mut Self { + pub fn set_color_collection(&mut self, value: impl Into>) -> &mut Self { self.color_collection = value.into(); self } diff --git a/src/structs/data_fields.rs b/src/structs/data_fields.rs index 0d476602..dc4984ec 100644 --- a/src/structs/data_fields.rs +++ b/src/structs/data_fields.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct DataFields { - list: ThinVec, + list: Vec, } impl DataFields { #[inline] @@ -20,7 +19,7 @@ impl DataFields { } #[inline] - pub fn get_list_mut(&mut self) -> &mut ThinVec { + pub fn get_list_mut(&mut self) -> &mut Vec { &mut self.list } diff --git a/src/structs/data_validations.rs b/src/structs/data_validations.rs index 71cdfd60..f0857582 100644 --- a/src/structs/data_validations.rs +++ b/src/structs/data_validations.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Default, Debug, Clone)] pub struct DataValidations { - data_validation_list: ThinVec, + data_validation_list: Vec, } impl DataValidations { @@ -21,15 +20,12 @@ impl DataValidations { } #[inline] - pub fn get_data_validation_list_mut(&mut self) -> &mut ThinVec { + pub fn get_data_validation_list_mut(&mut self) -> &mut Vec { &mut self.data_validation_list } #[inline] - pub fn set_data_validation_list( - &mut self, - value: impl Into>, - ) -> &mut Self { + pub fn set_data_validation_list(&mut self, value: impl Into>) -> &mut Self { self.data_validation_list = value.into(); self } diff --git a/src/structs/defined_name.rs b/src/structs/defined_name.rs index 10502902..fb21d793 100644 --- a/src/structs/defined_name.rs +++ b/src/structs/defined_name.rs @@ -10,12 +10,11 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct DefinedName { name: StringValue, - address: ThinVec
, + address: Vec
, string_value: StringValue, local_sheet_id: UInt32Value, hidden: BooleanValue, @@ -85,7 +84,7 @@ impl DefinedName { #[inline] #[allow(dead_code)] - pub(crate) fn get_address_obj_mut(&mut self) -> &mut ThinVec
{ + pub(crate) fn get_address_obj_mut(&mut self) -> &mut Vec
{ &mut self.address } diff --git a/src/structs/differential_formats.rs b/src/structs/differential_formats.rs index a6e4d0d8..5c38190a 100644 --- a/src/structs/differential_formats.rs +++ b/src/structs/differential_formats.rs @@ -7,11 +7,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct DifferentialFormats { - differential_format: ThinVec, + differential_format: Vec, } impl DifferentialFormats { @@ -21,7 +20,7 @@ impl DifferentialFormats { } #[inline] - pub(crate) fn _get_differential_format_mut(&mut self) -> &mut ThinVec { + pub(crate) fn _get_differential_format_mut(&mut self) -> &mut Vec { &mut self.differential_format } diff --git a/src/structs/drawing/adjust_value_list.rs b/src/structs/drawing/adjust_value_list.rs index aa766779..c94b2561 100644 --- a/src/structs/drawing/adjust_value_list.rs +++ b/src/structs/drawing/adjust_value_list.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct AdjustValueList { - shape_guide_collection: ThinVec, + shape_guide_collection: Vec, } impl AdjustValueList { @@ -21,12 +20,12 @@ impl AdjustValueList { } #[inline] - pub fn get_shape_guide_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_shape_guide_collection_mut(&mut self) -> &mut Vec { &mut self.shape_guide_collection } #[inline] - pub fn set_shape_guide_collection(&mut self, value: impl Into>) { + pub fn set_shape_guide_collection(&mut self, value: impl Into>) { self.shape_guide_collection = value.into(); } diff --git a/src/structs/drawing/background_fill_style_list.rs b/src/structs/drawing/background_fill_style_list.rs index c34fc996..113e7714 100644 --- a/src/structs/drawing/background_fill_style_list.rs +++ b/src/structs/drawing/background_fill_style_list.rs @@ -6,12 +6,11 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct BackgroundFillStyleList { - solid_fill: ThinVec, - gradient_fill_collection: ThinVec, + solid_fill: Vec, + gradient_fill_collection: Vec, } impl BackgroundFillStyleList { @@ -22,12 +21,12 @@ impl BackgroundFillStyleList { } #[inline] - pub fn get_solid_fill_mut(&mut self) -> &mut ThinVec { + pub fn get_solid_fill_mut(&mut self) -> &mut Vec { &mut self.solid_fill } #[inline] - pub fn set_solid_fill(&mut self, value: impl Into>) -> &mut Self { + pub fn set_solid_fill(&mut self, value: impl Into>) -> &mut Self { self.solid_fill = value.into(); self } @@ -45,14 +44,14 @@ impl BackgroundFillStyleList { } #[inline] - pub fn get_gradient_fill_collectionl_mut(&mut self) -> &mut ThinVec { + pub fn get_gradient_fill_collectionl_mut(&mut self) -> &mut Vec { &mut self.gradient_fill_collection } #[inline] pub fn set_gradient_fill_collection( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut Self { self.gradient_fill_collection = value.into(); self diff --git a/src/structs/drawing/charts/area_3d_chart.rs b/src/structs/drawing/charts/area_3d_chart.rs index 0e4400e8..13c7ff19 100644 --- a/src/structs/drawing/charts/area_3d_chart.rs +++ b/src/structs/drawing/charts/area_3d_chart.rs @@ -12,7 +12,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct Area3DChart { @@ -20,7 +19,7 @@ pub struct Area3DChart { vary_colors: VaryColors, area_chart_series_list: AreaChartSeriesList, data_labels: Option>, - axis_id: ThinVec, + axis_id: Vec, } impl Area3DChart { @@ -85,11 +84,11 @@ impl Area3DChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Self { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Self { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/area_chart.rs b/src/structs/drawing/charts/area_chart.rs index a2597b41..efffb81d 100644 --- a/src/structs/drawing/charts/area_chart.rs +++ b/src/structs/drawing/charts/area_chart.rs @@ -12,7 +12,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct AreaChart { @@ -20,7 +19,7 @@ pub struct AreaChart { vary_colors: VaryColors, area_chart_series_list: AreaChartSeriesList, data_labels: DataLabels, - axis_id: ThinVec, + axis_id: Vec, } impl AreaChart { @@ -85,11 +84,11 @@ impl AreaChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut AreaChart { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut AreaChart { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/area_chart_series_list.rs b/src/structs/drawing/charts/area_chart_series_list.rs index 30d5b4b6..e426ce1d 100644 --- a/src/structs/drawing/charts/area_chart_series_list.rs +++ b/src/structs/drawing/charts/area_chart_series_list.rs @@ -1,9 +1,8 @@ use super::AreaChartSeries; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct AreaChartSeriesList { - area_chart_series: ThinVec, + area_chart_series: Vec, } impl AreaChartSeriesList { #[must_use] @@ -15,10 +14,7 @@ impl AreaChartSeriesList { &mut self.area_chart_series } - pub fn set_area_chart_series( - &mut self, - value: impl Into>, - ) -> &mut Self { + pub fn set_area_chart_series(&mut self, value: impl Into>) -> &mut Self { self.area_chart_series = value.into(); self } diff --git a/src/structs/drawing/charts/bar_3d_chart.rs b/src/structs/drawing/charts/bar_3d_chart.rs index 81fcc311..a0b0b823 100644 --- a/src/structs/drawing/charts/bar_3d_chart.rs +++ b/src/structs/drawing/charts/bar_3d_chart.rs @@ -15,7 +15,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct Bar3DChart { @@ -26,7 +25,7 @@ pub struct Bar3DChart { data_labels: DataLabels, gap_width: GapWidth, shape: Shape, - axis_id: ThinVec, + axis_id: Vec, } impl Bar3DChart { @@ -133,11 +132,11 @@ impl Bar3DChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Bar3DChart { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Bar3DChart { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/bar_chart.rs b/src/structs/drawing/charts/bar_chart.rs index 3747cc5b..1475c513 100644 --- a/src/structs/drawing/charts/bar_chart.rs +++ b/src/structs/drawing/charts/bar_chart.rs @@ -15,7 +15,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct BarChart { @@ -26,7 +25,7 @@ pub struct BarChart { data_labels: DataLabels, gap_width: GapWidth, overlap: Overlap, - axis_id: ThinVec, + axis_id: Vec, } impl BarChart { @@ -133,11 +132,11 @@ impl BarChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut BarChart { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut BarChart { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/bubble_chart.rs b/src/structs/drawing/charts/bubble_chart.rs index 46386f33..c779a0b0 100644 --- a/src/structs/drawing/charts/bubble_chart.rs +++ b/src/structs/drawing/charts/bubble_chart.rs @@ -13,7 +13,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct BubbleChart { @@ -22,7 +21,7 @@ pub struct BubbleChart { data_labels: DataLabels, bubble_scale: BubbleScale, show_negative_bubbles: ShowNegativeBubbles, - axis_id: ThinVec, + axis_id: Vec, } impl BubbleChart { @@ -101,11 +100,11 @@ impl BubbleChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut BubbleChart { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut BubbleChart { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/line_3d_chart.rs b/src/structs/drawing/charts/line_3d_chart.rs index bd69e9ed..d8af9cc3 100644 --- a/src/structs/drawing/charts/line_3d_chart.rs +++ b/src/structs/drawing/charts/line_3d_chart.rs @@ -12,7 +12,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct Line3DChart { @@ -20,7 +19,7 @@ pub struct Line3DChart { vary_colors: VaryColors, area_chart_series_list: AreaChartSeriesList, data_labels: DataLabels, - axis_id: ThinVec, + axis_id: Vec, } impl Line3DChart { @@ -85,11 +84,11 @@ impl Line3DChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Line3DChart { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Line3DChart { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/line_chart.rs b/src/structs/drawing/charts/line_chart.rs index 64709541..270e85b6 100644 --- a/src/structs/drawing/charts/line_chart.rs +++ b/src/structs/drawing/charts/line_chart.rs @@ -15,7 +15,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct LineChart { @@ -25,7 +24,7 @@ pub struct LineChart { data_labels: DataLabels, show_marker: ShowMarker, smooth: Smooth, - axis_id: ThinVec, + axis_id: Vec, } impl LineChart { @@ -118,11 +117,11 @@ impl LineChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Self { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut Self { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/plot_area.rs b/src/structs/drawing/charts/plot_area.rs index b507a7b5..26c2e2d5 100644 --- a/src/structs/drawing/charts/plot_area.rs +++ b/src/structs/drawing/charts/plot_area.rs @@ -28,7 +28,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct PlotArea { @@ -46,9 +45,9 @@ pub struct PlotArea { area_chart: Option, area_3d_chart: Option, of_pie_chart: Option, - category_axis: ThinVec, - value_axis: ThinVec, - series_axis: ThinVec, + category_axis: Vec, + value_axis: Vec, + series_axis: Vec, shape_properties: Option, } @@ -254,11 +253,11 @@ impl PlotArea { &self.category_axis } - pub fn get_category_axis_mut(&mut self) -> &mut ThinVec { + pub fn get_category_axis_mut(&mut self) -> &mut Vec { &mut self.category_axis } - pub fn set_category_axis(&mut self, value: impl Into>) -> &mut Self { + pub fn set_category_axis(&mut self, value: impl Into>) -> &mut Self { self.category_axis = value.into(); self } @@ -273,11 +272,11 @@ impl PlotArea { &self.value_axis } - pub fn get_value_axis_mut(&mut self) -> &mut ThinVec { + pub fn get_value_axis_mut(&mut self) -> &mut Vec { &mut self.value_axis } - pub fn set_value_axis(&mut self, value: impl Into>) -> &mut Self { + pub fn set_value_axis(&mut self, value: impl Into>) -> &mut Self { self.value_axis = value.into(); self } @@ -292,11 +291,11 @@ impl PlotArea { &self.series_axis } - pub fn get_series_axis_mut(&mut self) -> &mut ThinVec { + pub fn get_series_axis_mut(&mut self) -> &mut Vec { &mut self.series_axis } - pub fn set_series_axis(&mut self, value: impl Into>) -> &mut Self { + pub fn set_series_axis(&mut self, value: impl Into>) -> &mut Self { self.series_axis = value.into(); self } diff --git a/src/structs/drawing/charts/radar_chart.rs b/src/structs/drawing/charts/radar_chart.rs index 3e753cc9..572c00ac 100644 --- a/src/structs/drawing/charts/radar_chart.rs +++ b/src/structs/drawing/charts/radar_chart.rs @@ -12,7 +12,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct RadarChart { @@ -20,7 +19,7 @@ pub struct RadarChart { vary_colors: VaryColors, area_chart_series_list: AreaChartSeriesList, data_labels: DataLabels, - axis_id: ThinVec, + axis_id: Vec, } impl RadarChart { @@ -85,11 +84,11 @@ impl RadarChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut RadarChart { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut RadarChart { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/rich_text.rs b/src/structs/drawing/charts/rich_text.rs index 90bed6af..f9247d83 100644 --- a/src/structs/drawing/charts/rich_text.rs +++ b/src/structs/drawing/charts/rich_text.rs @@ -8,13 +8,12 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct RichText { body_properties: BodyProperties, list_style: ListStyle, - paragraph: ThinVec, + paragraph: Vec, } impl RichText { @@ -49,7 +48,7 @@ impl RichText { &self.paragraph } - pub fn get_paragraph_mut(&mut self) -> &mut ThinVec { + pub fn get_paragraph_mut(&mut self) -> &mut Vec { &mut self.paragraph } diff --git a/src/structs/drawing/charts/scatter_chart.rs b/src/structs/drawing/charts/scatter_chart.rs index a22216b7..69bd74f1 100644 --- a/src/structs/drawing/charts/scatter_chart.rs +++ b/src/structs/drawing/charts/scatter_chart.rs @@ -12,7 +12,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct ScatterChart { @@ -20,7 +19,7 @@ pub struct ScatterChart { vary_colors: VaryColors, area_chart_series_list: AreaChartSeriesList, data_labels: DataLabels, - axis_id: ThinVec, + axis_id: Vec, } impl ScatterChart { @@ -85,11 +84,11 @@ impl ScatterChart { &self.axis_id } - pub fn get_axis_id_mut(&mut self) -> &mut ThinVec { + pub fn get_axis_id_mut(&mut self) -> &mut Vec { &mut self.axis_id } - pub fn set_axis_id(&mut self, value: impl Into>) -> &mut ScatterChart { + pub fn set_axis_id(&mut self, value: impl Into>) -> &mut ScatterChart { self.axis_id = value.into(); self } diff --git a/src/structs/drawing/charts/string_literal.rs b/src/structs/drawing/charts/string_literal.rs index 4d1eb416..f3c2c041 100644 --- a/src/structs/drawing/charts/string_literal.rs +++ b/src/structs/drawing/charts/string_literal.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct StringLiteral { - string_point_list: ThinVec, + string_point_list: Vec, } impl StringLiteral { @@ -19,7 +18,7 @@ impl StringLiteral { &self.string_point_list } - pub fn get_string_point_list_mut(&mut self) -> &mut ThinVec { + pub fn get_string_point_list_mut(&mut self) -> &mut Vec { &mut self.string_point_list } diff --git a/src/structs/drawing/charts/text_properties.rs b/src/structs/drawing/charts/text_properties.rs index 74ad8fc7..8b46b892 100644 --- a/src/structs/drawing/charts/text_properties.rs +++ b/src/structs/drawing/charts/text_properties.rs @@ -8,13 +8,12 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct TextProperties { body_properties: BodyProperties, list_style: ListStyle, - paragraph: ThinVec, + paragraph: Vec, } impl TextProperties { @@ -51,7 +50,7 @@ impl TextProperties { &self.paragraph } - pub fn get_paragraph_mut(&mut self) -> &mut ThinVec { + pub fn get_paragraph_mut(&mut self) -> &mut Vec { &mut self.paragraph } diff --git a/src/structs/drawing/effect_style_list.rs b/src/structs/drawing/effect_style_list.rs index b8bf6b0c..ff451c7c 100644 --- a/src/structs/drawing/effect_style_list.rs +++ b/src/structs/drawing/effect_style_list.rs @@ -5,11 +5,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct EffectStyleList { - effect_style_collection: ThinVec, + effect_style_collection: Vec, } impl EffectStyleList { @@ -20,15 +19,12 @@ impl EffectStyleList { } #[inline] - pub fn get_effect_style_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_effect_style_collection_mut(&mut self) -> &mut Vec { &mut self.effect_style_collection } #[inline] - pub fn set_effect_style_collection( - &mut self, - value: impl Into>, - ) -> &mut Self { + pub fn set_effect_style_collection(&mut self, value: impl Into>) -> &mut Self { self.effect_style_collection = value.into(); self } diff --git a/src/structs/drawing/fill_style_list.rs b/src/structs/drawing/fill_style_list.rs index f495e3c8..982a5032 100644 --- a/src/structs/drawing/fill_style_list.rs +++ b/src/structs/drawing/fill_style_list.rs @@ -6,12 +6,11 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct FillStyleList { - solid_fill: ThinVec, - gradient_fill_collection: ThinVec, + solid_fill: Vec, + gradient_fill_collection: Vec, } impl FillStyleList { @@ -22,12 +21,12 @@ impl FillStyleList { } #[inline] - pub fn get_solid_fill_mut(&mut self) -> &mut ThinVec { + pub fn get_solid_fill_mut(&mut self) -> &mut Vec { &mut self.solid_fill } #[inline] - pub fn set_solid_fill(&mut self, value: impl Into>) -> &mut Self { + pub fn set_solid_fill(&mut self, value: impl Into>) -> &mut Self { self.solid_fill = value.into(); self } @@ -45,14 +44,14 @@ impl FillStyleList { } #[inline] - pub fn get_gradient_fill_collectionl_mut(&mut self) -> &mut ThinVec { + pub fn get_gradient_fill_collectionl_mut(&mut self) -> &mut Vec { &mut self.gradient_fill_collection } #[inline] pub fn set_gradient_fill_collection( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut Self { self.gradient_fill_collection = value.into(); self diff --git a/src/structs/drawing/font_collection_type.rs b/src/structs/drawing/font_collection_type.rs index 5f777147..41ad942e 100644 --- a/src/structs/drawing/font_collection_type.rs +++ b/src/structs/drawing/font_collection_type.rs @@ -7,14 +7,13 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct FontCollectionType { latin_font: TextFontType, east_asian_font: TextFontType, complex_script_font: TextFontType, - supplemental_font_list: ThinVec, + supplemental_font_list: Vec, } impl FontCollectionType { #[inline] @@ -75,14 +74,14 @@ impl FontCollectionType { } #[inline] - pub fn get_supplemental_font_list_mut(&mut self) -> &mut ThinVec { + pub fn get_supplemental_font_list_mut(&mut self) -> &mut Vec { &mut self.supplemental_font_list } #[inline] pub fn set_supplemental_font_list( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut Self { self.supplemental_font_list = value.into(); self diff --git a/src/structs/drawing/gradient_stop_list.rs b/src/structs/drawing/gradient_stop_list.rs index 0543ea25..728e2bf2 100644 --- a/src/structs/drawing/gradient_stop_list.rs +++ b/src/structs/drawing/gradient_stop_list.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct GradientStopList { - gradient_stop: ThinVec, + gradient_stop: Vec, } impl GradientStopList { @@ -21,14 +20,14 @@ impl GradientStopList { } #[inline] - pub fn get_gradient_stop_mut(&mut self) -> &mut ThinVec { + pub fn get_gradient_stop_mut(&mut self) -> &mut Vec { &mut self.gradient_stop } #[inline] pub fn set_gradient_stop( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut GradientStopList { self.gradient_stop = value.into(); self diff --git a/src/structs/drawing/line_style_list.rs b/src/structs/drawing/line_style_list.rs index 814db86c..736598d0 100644 --- a/src/structs/drawing/line_style_list.rs +++ b/src/structs/drawing/line_style_list.rs @@ -5,11 +5,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct LineStyleList { - outline_collection: ThinVec, + outline_collection: Vec, } impl LineStyleList { @@ -20,12 +19,12 @@ impl LineStyleList { } #[inline] - pub fn get_outline_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_outline_collection_mut(&mut self) -> &mut Vec { &mut self.outline_collection } #[inline] - pub fn set_outline_collection(&mut self, value: impl Into>) -> &mut Self { + pub fn set_outline_collection(&mut self, value: impl Into>) -> &mut Self { self.outline_collection = value.into(); self } diff --git a/src/structs/drawing/paragraph.rs b/src/structs/drawing/paragraph.rs index b93dfb41..44536261 100644 --- a/src/structs/drawing/paragraph.rs +++ b/src/structs/drawing/paragraph.rs @@ -8,12 +8,11 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct Paragraph { paragraph_properties: ParagraphProperties, - run: ThinVec, + run: Vec, end_para_run_properties: Option>, } diff --git a/src/structs/drawing/spreadsheet/group_shape.rs b/src/structs/drawing/spreadsheet/group_shape.rs index f76f2303..8ab26f90 100644 --- a/src/structs/drawing/spreadsheet/group_shape.rs +++ b/src/structs/drawing/spreadsheet/group_shape.rs @@ -10,14 +10,13 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct GroupShape { non_visual_group_shape_properties: NonVisualGroupShapeProperties, group_shape_properties: GroupShapeProperties, - picture_collection: ThinVec, - shape_collection: ThinVec, + picture_collection: Vec, + shape_collection: Vec, } impl GroupShape { @@ -62,7 +61,7 @@ impl GroupShape { } #[inline] - pub fn get_picture_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_picture_collection_mut(&mut self) -> &mut Vec { &mut self.picture_collection } @@ -78,7 +77,7 @@ impl GroupShape { } #[inline] - pub fn get_shape_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_shape_collection_mut(&mut self) -> &mut Vec { &mut self.shape_collection } diff --git a/src/structs/drawing/spreadsheet/text_body.rs b/src/structs/drawing/spreadsheet/text_body.rs index a23a1cdb..6cf8eee6 100644 --- a/src/structs/drawing/spreadsheet/text_body.rs +++ b/src/structs/drawing/spreadsheet/text_body.rs @@ -7,13 +7,12 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct TextBody { body_properties: BodyProperties, list_style: ListStyle, - paragraph: ThinVec, + paragraph: Vec, } impl TextBody { @@ -56,7 +55,7 @@ impl TextBody { } #[inline] - pub fn get_paragraph_mut(&mut self) -> &mut ThinVec { + pub fn get_paragraph_mut(&mut self) -> &mut Vec { &mut self.paragraph } diff --git a/src/structs/drawing/spreadsheet/worksheet_drawing.rs b/src/structs/drawing/spreadsheet/worksheet_drawing.rs index 7d0ef6c3..3656c89e 100644 --- a/src/structs/drawing/spreadsheet/worksheet_drawing.rs +++ b/src/structs/drawing/spreadsheet/worksheet_drawing.rs @@ -18,14 +18,13 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct WorksheetDrawing { - image_collection: ThinVec, - chart_collection: ThinVec, - one_cell_anchor_collection: ThinVec, - two_cell_anchor_collection: ThinVec, + image_collection: Vec, + chart_collection: Vec, + one_cell_anchor_collection: Vec, + two_cell_anchor_collection: Vec, } impl WorksheetDrawing { @@ -36,7 +35,7 @@ impl WorksheetDrawing { } #[inline] - pub fn get_image_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_image_collection_mut(&mut self) -> &mut Vec { &mut self.image_collection } @@ -89,7 +88,7 @@ impl WorksheetDrawing { } #[inline] - pub fn get_chart_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_chart_collection_mut(&mut self) -> &mut Vec { &mut self.chart_collection } @@ -142,7 +141,7 @@ impl WorksheetDrawing { } #[inline] - pub fn get_one_cell_anchor_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_one_cell_anchor_collection_mut(&mut self) -> &mut Vec { &mut self.one_cell_anchor_collection } @@ -159,7 +158,7 @@ impl WorksheetDrawing { } #[inline] - pub fn get_two_cell_anchor_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_two_cell_anchor_collection_mut(&mut self) -> &mut Vec { &mut self.two_cell_anchor_collection } diff --git a/src/structs/fills.rs b/src/structs/fills.rs index 0cc29a0f..e42b4c5c 100644 --- a/src/structs/fills.rs +++ b/src/structs/fills.rs @@ -7,11 +7,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct Fills { - fill: ThinVec, + fill: Vec, } impl Fills { @@ -22,7 +21,7 @@ impl Fills { #[inline] #[allow(dead_code)] - pub(crate) fn get_fill_mut(&mut self) -> &mut ThinVec { + pub(crate) fn get_fill_mut(&mut self) -> &mut Vec { &mut self.fill } diff --git a/src/structs/fonts.rs b/src/structs/fonts.rs index 921462f5..7e494ee3 100644 --- a/src/structs/fonts.rs +++ b/src/structs/fonts.rs @@ -7,11 +7,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct Fonts { - font: ThinVec, + font: Vec, } impl Fonts { @@ -22,7 +21,7 @@ impl Fonts { #[inline] #[allow(dead_code)] - pub(crate) fn get_font_mut(&mut self) -> &mut ThinVec { + pub(crate) fn get_font_mut(&mut self) -> &mut Vec { &mut self.font } diff --git a/src/structs/gradient_fill.rs b/src/structs/gradient_fill.rs index 0beabdf7..5398c640 100644 --- a/src/structs/gradient_fill.rs +++ b/src/structs/gradient_fill.rs @@ -9,12 +9,11 @@ use quick_xml::Reader; use quick_xml::Writer; use std::fmt::Write; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Default, Debug, Clone, PartialEq, PartialOrd)] pub struct GradientFill { degree: DoubleValue, - gradient_stop: ThinVec, + gradient_stop: Vec, } impl GradientFill { @@ -37,7 +36,7 @@ impl GradientFill { } #[inline] - pub fn get_gradient_stop_mut(&mut self) -> &mut ThinVec { + pub fn get_gradient_stop_mut(&mut self) -> &mut Vec { &mut self.gradient_stop } diff --git a/src/structs/icon_set.rs b/src/structs/icon_set.rs index f9325c43..4ce78c29 100644 --- a/src/structs/icon_set.rs +++ b/src/structs/icon_set.rs @@ -7,12 +7,11 @@ use quick_xml::events::Event; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct IconSet { - cfvo_collection: ThinVec, - color_collection: ThinVec, + cfvo_collection: Vec, + color_collection: Vec, } impl IconSet { @@ -25,7 +24,7 @@ impl IconSet { #[inline] pub fn set_cfvo_collection( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut Self { self.cfvo_collection = value.into(); self @@ -44,7 +43,7 @@ impl IconSet { } #[inline] - pub fn set_color_collection(&mut self, value: impl Into>) -> &mut Self { + pub fn set_color_collection(&mut self, value: impl Into>) -> &mut Self { self.color_collection = value.into(); self } diff --git a/src/structs/media_object.rs b/src/structs/media_object.rs index a048dc59..a457acc8 100644 --- a/src/structs/media_object.rs +++ b/src/structs/media_object.rs @@ -1,10 +1,8 @@ -use thin_vec::ThinVec; - #[derive(Clone, Default, Debug)] pub struct MediaObject { image_title: Box, image_name: Box, - image_data: ThinVec, + image_data: Vec, } impl MediaObject { #[inline] @@ -35,7 +33,7 @@ impl MediaObject { } #[inline] - pub fn set_image_data(&mut self, value: impl Into>) -> &mut Self { + pub fn set_image_data(&mut self, value: impl Into>) -> &mut Self { self.image_data = value.into(); self } diff --git a/src/structs/merge_cells.rs b/src/structs/merge_cells.rs index a2821844..a78c133a 100644 --- a/src/structs/merge_cells.rs +++ b/src/structs/merge_cells.rs @@ -7,11 +7,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct MergeCells { - range: ThinVec, + range: Vec, } impl MergeCells { @@ -21,7 +20,7 @@ impl MergeCells { } #[inline] - pub(crate) fn get_range_collection_mut(&mut self) -> &mut ThinVec { + pub(crate) fn get_range_collection_mut(&mut self) -> &mut Vec { &mut self.range } diff --git a/src/structs/mru_colors.rs b/src/structs/mru_colors.rs index a297e7ce..23c91ff6 100644 --- a/src/structs/mru_colors.rs +++ b/src/structs/mru_colors.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct MruColors { - color: ThinVec, + color: Vec, } impl MruColors { @@ -20,7 +19,7 @@ impl MruColors { } #[inline] - pub(crate) fn _get_color_mut(&mut self) -> &mut ThinVec { + pub(crate) fn _get_color_mut(&mut self) -> &mut Vec { &mut self.color } diff --git a/src/structs/office/excel/reference_sequence.rs b/src/structs/office/excel/reference_sequence.rs index 887b9c1c..0d221800 100644 --- a/src/structs/office/excel/reference_sequence.rs +++ b/src/structs/office/excel/reference_sequence.rs @@ -6,11 +6,10 @@ use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; use std::vec; -use thin_vec::ThinVec; #[derive(Default, Debug, Clone)] pub struct ReferenceSequence { - value: ThinVec, + value: Vec, } impl ReferenceSequence { #[inline] @@ -20,12 +19,12 @@ impl ReferenceSequence { } #[inline] - pub fn get_value_mut(&mut self) -> &mut ThinVec { + pub fn get_value_mut(&mut self) -> &mut Vec { &mut self.value } #[inline] - pub fn set_value(&mut self, value: impl Into>) -> &mut Self { + pub fn set_value(&mut self, value: impl Into>) -> &mut Self { self.value = value.into(); self } diff --git a/src/structs/office2010/excel/data_validations.rs b/src/structs/office2010/excel/data_validations.rs index 097c2cb1..769eb206 100644 --- a/src/structs/office2010/excel/data_validations.rs +++ b/src/structs/office2010/excel/data_validations.rs @@ -7,11 +7,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Default, Debug, Clone)] pub struct DataValidations { - data_validation_list: ThinVec, + data_validation_list: Vec, } impl DataValidations { @@ -22,15 +21,12 @@ impl DataValidations { } #[inline] - pub fn get_data_validation_list_mut(&mut self) -> &mut ThinVec { + pub fn get_data_validation_list_mut(&mut self) -> &mut Vec { &mut self.data_validation_list } #[inline] - pub fn set_data_validation_list( - &mut self, - value: impl Into>, - ) -> &mut Self { + pub fn set_data_validation_list(&mut self, value: impl Into>) -> &mut Self { self.data_validation_list = value.into(); self } diff --git a/src/structs/ole_object.rs b/src/structs/ole_object.rs index bd3fe873..9e8a5fe7 100644 --- a/src/structs/ole_object.rs +++ b/src/structs/ole_object.rs @@ -10,14 +10,13 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct OleObject { requires: StringValue, prog_id: StringValue, object_extension: Box, - object_data: Option>, + object_data: Option>, embedded_object_properties: EmbeddedObjectProperties, two_cell_anchor: TwoCellAnchor, shape: Shape, @@ -66,12 +65,12 @@ impl OleObject { } #[inline] - pub fn get_object_data_mut(&mut self) -> Option<&mut ThinVec> { + pub fn get_object_data_mut(&mut self) -> Option<&mut Vec> { self.object_data.as_mut() } #[inline] - pub fn set_object_data(&mut self, value: impl Into>) -> &mut Self { + pub fn set_object_data(&mut self, value: impl Into>) -> &mut Self { self.object_data = Some(value.into()); self } diff --git a/src/structs/ole_objects.rs b/src/structs/ole_objects.rs index 71e0dab6..25e5f685 100644 --- a/src/structs/ole_objects.rs +++ b/src/structs/ole_objects.rs @@ -7,11 +7,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct OleObjects { - ole_object: ThinVec, + ole_object: Vec, } impl OleObjects { @@ -22,7 +21,7 @@ impl OleObjects { } #[inline] - pub fn get_ole_object_mut(&mut self) -> &mut ThinVec { + pub fn get_ole_object_mut(&mut self) -> &mut Vec { &mut self.ole_object } diff --git a/src/structs/page_setup.rs b/src/structs/page_setup.rs index 260458bb..9e2c0145 100644 --- a/src/structs/page_setup.rs +++ b/src/structs/page_setup.rs @@ -8,7 +8,6 @@ use quick_xml::events::BytesStart; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct PageSetup { @@ -19,7 +18,7 @@ pub struct PageSetup { fit_to_width: UInt32Value, horizontal_dpi: UInt32Value, vertical_dpi: UInt32Value, - object_data: Option>, + object_data: Option>, } impl PageSetup { @@ -114,12 +113,12 @@ impl PageSetup { } #[inline] - pub fn get_object_data_mut(&mut self) -> Option<&mut ThinVec> { + pub fn get_object_data_mut(&mut self) -> Option<&mut Vec> { self.object_data.as_mut() } #[inline] - pub fn set_object_data(&mut self, value: impl Into>) -> &mut Self { + pub fn set_object_data(&mut self, value: impl Into>) -> &mut Self { self.object_data = Some(value.into()); self } diff --git a/src/structs/pivot_fields.rs b/src/structs/pivot_fields.rs index 5b60cd03..ceafa830 100644 --- a/src/structs/pivot_fields.rs +++ b/src/structs/pivot_fields.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct PivotFields { - list: ThinVec, + list: Vec, } impl PivotFields { #[inline] @@ -20,7 +19,7 @@ impl PivotFields { } #[inline] - pub fn get_list_mut(&mut self) -> &mut ThinVec { + pub fn get_list_mut(&mut self) -> &mut Vec { &mut self.list } diff --git a/src/structs/raw/raw_file.rs b/src/structs/raw/raw_file.rs index 625f37e9..0f359a9e 100644 --- a/src/structs/raw/raw_file.rs +++ b/src/structs/raw/raw_file.rs @@ -4,12 +4,11 @@ use crate::structs::WriterManager; use crate::XlsxError; use std::io; use std::io::Read; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct RawFile { file_target: StringValue, - file_data: ThinVec, + file_data: Vec, } impl RawFile { #[inline] @@ -56,7 +55,7 @@ impl RawFile { } #[inline] - pub(crate) fn _get_file_data_mut(&mut self) -> &mut ThinVec { + pub(crate) fn _get_file_data_mut(&mut self) -> &mut Vec { &mut self.file_data } diff --git a/src/structs/raw/raw_relationships.rs b/src/structs/raw/raw_relationships.rs index d520eea5..c1f2de2b 100644 --- a/src/structs/raw/raw_relationships.rs +++ b/src/structs/raw/raw_relationships.rs @@ -10,12 +10,11 @@ use quick_xml::Reader; use quick_xml::Writer; use std::io; use std::io::Read; -use thin_vec::ThinVec; #[derive(Clone, Debug, Default)] pub(crate) struct RawRelationships { file_target: StringValue, - relationship_list: ThinVec, + relationship_list: Vec, } impl RawRelationships { @@ -43,7 +42,7 @@ impl RawRelationships { } #[inline] - pub(crate) fn _get_relationship_list_mut(&mut self) -> &mut ThinVec { + pub(crate) fn _get_relationship_list_mut(&mut self) -> &mut Vec { &mut self.relationship_list } diff --git a/src/structs/raw/raw_worksheet.rs b/src/structs/raw/raw_worksheet.rs index 6b2b7b37..b3daf781 100644 --- a/src/structs/raw/raw_worksheet.rs +++ b/src/structs/raw/raw_worksheet.rs @@ -6,12 +6,11 @@ use crate::structs::raw::RawRelationships; use crate::structs::WriterManager; use crate::structs::XlsxError; use std::io; -use thin_vec::ThinVec; #[derive(Clone, Debug, Default)] pub(crate) struct RawWorksheet { worksheet_file: RawFile, - relationships_list: ThinVec, + relationships_list: Vec, } impl RawWorksheet { #[inline] @@ -30,7 +29,7 @@ impl RawWorksheet { } #[inline] - pub(crate) fn _get_relationships_list_mut(&mut self) -> &mut ThinVec { + pub(crate) fn _get_relationships_list_mut(&mut self) -> &mut Vec { &mut self.relationships_list } diff --git a/src/structs/rich_text.rs b/src/structs/rich_text.rs index 3ab92ab1..09d36eea 100644 --- a/src/structs/rich_text.rs +++ b/src/structs/rich_text.rs @@ -8,11 +8,10 @@ use quick_xml::Writer; use std::borrow::Cow; use std::fmt::Write; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug, PartialEq, PartialOrd)] pub struct RichText { - rich_text_elements: ThinVec, + rich_text_elements: Vec, } impl RichText { @@ -42,12 +41,12 @@ impl RichText { } #[inline] - pub fn get_rich_text_elements_mut(&mut self) -> &mut ThinVec { + pub fn get_rich_text_elements_mut(&mut self) -> &mut Vec { &mut self.rich_text_elements } #[inline] - pub fn set_rich_text_elements(&mut self, value: impl Into>) -> &mut Self { + pub fn set_rich_text_elements(&mut self, value: impl Into>) -> &mut Self { self.rich_text_elements = value.into(); self } diff --git a/src/structs/row_breaks.rs b/src/structs/row_breaks.rs index 72b3d131..103ef868 100644 --- a/src/structs/row_breaks.rs +++ b/src/structs/row_breaks.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct RowBreaks { - break_list: ThinVec, + break_list: Vec, } impl RowBreaks { @@ -21,7 +20,7 @@ impl RowBreaks { } #[inline] - pub fn get_break_list_mut(&mut self) -> &mut ThinVec { + pub fn get_break_list_mut(&mut self) -> &mut Vec { &mut self.break_list } diff --git a/src/structs/row_items.rs b/src/structs/row_items.rs index c564853c..5e7738f9 100644 --- a/src/structs/row_items.rs +++ b/src/structs/row_items.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct RowItems { - list: ThinVec, + list: Vec, } impl RowItems { #[inline] @@ -20,7 +19,7 @@ impl RowItems { } #[inline] - pub fn get_list_mut(&mut self) -> &mut ThinVec { + pub fn get_list_mut(&mut self) -> &mut Vec { &mut self.list } diff --git a/src/structs/sequence_of_references.rs b/src/structs/sequence_of_references.rs index 03dd28da..05525b45 100644 --- a/src/structs/sequence_of_references.rs +++ b/src/structs/sequence_of_references.rs @@ -1,10 +1,9 @@ use super::Range; use crate::traits::AdjustmentCoordinate; -use thin_vec::ThinVec; #[derive(Default, Debug, Clone)] pub struct SequenceOfReferences { - range_collection: ThinVec, + range_collection: Vec, } impl SequenceOfReferences { @@ -15,12 +14,12 @@ impl SequenceOfReferences { } #[inline] - pub fn get_range_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_range_collection_mut(&mut self) -> &mut Vec { &mut self.range_collection } #[inline] - pub fn set_range_collection(&mut self, value: impl Into>) -> &mut Self { + pub fn set_range_collection(&mut self, value: impl Into>) -> &mut Self { self.range_collection = value.into(); self } diff --git a/src/structs/shared_string_table.rs b/src/structs/shared_string_table.rs index 9f82c340..a9043137 100644 --- a/src/structs/shared_string_table.rs +++ b/src/structs/shared_string_table.rs @@ -9,11 +9,10 @@ use quick_xml::Reader; use quick_xml::Writer; use std::collections::HashMap; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct SharedStringTable { - shared_string_item: ThinVec, + shared_string_item: Vec, map: HashMap, regist_count: usize, } @@ -26,7 +25,7 @@ impl SharedStringTable { #[inline] #[allow(dead_code)] - pub(crate) fn get_shared_string_item_mut(&mut self) -> &mut ThinVec { + pub(crate) fn get_shared_string_item_mut(&mut self) -> &mut Vec { &mut self.shared_string_item } diff --git a/src/structs/sheet_view.rs b/src/structs/sheet_view.rs index be2de3b4..2716eabf 100644 --- a/src/structs/sheet_view.rs +++ b/src/structs/sheet_view.rs @@ -12,7 +12,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct SheetView { @@ -26,7 +25,7 @@ pub struct SheetView { zoom_scale_page_layout_view: UInt32Value, zoom_scale_sheet_layout_view: UInt32Value, top_left_cell: StringValue, - selection: ThinVec, + selection: Vec, } impl SheetView { @@ -162,7 +161,7 @@ impl SheetView { } #[inline] - pub fn get_selection_mut(&mut self) -> &mut ThinVec { + pub fn get_selection_mut(&mut self) -> &mut Vec { &mut self.selection } diff --git a/src/structs/sheet_views.rs b/src/structs/sheet_views.rs index 0f42db39..716c6601 100644 --- a/src/structs/sheet_views.rs +++ b/src/structs/sheet_views.rs @@ -6,11 +6,10 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub struct SheetViews { - sheet_view_list: ThinVec, + sheet_view_list: Vec, } impl SheetViews { @@ -21,7 +20,7 @@ impl SheetViews { } #[inline] - pub fn get_sheet_view_list_mut(&mut self) -> &mut ThinVec { + pub fn get_sheet_view_list_mut(&mut self) -> &mut Vec { &mut self.sheet_view_list } diff --git a/src/structs/spreadsheet.rs b/src/structs/spreadsheet.rs index d275bfec..04d03342 100644 --- a/src/structs/spreadsheet.rs +++ b/src/structs/spreadsheet.rs @@ -17,25 +17,24 @@ use crate::traits::AdjustmentCoordinateWithSheet; use crate::StringValue; use std::sync::Arc; use std::sync::RwLock; -use thin_vec::ThinVec; /// A Spreadsheet Object. /// The starting point of all struct. #[derive(Clone, Default, Debug)] pub struct Spreadsheet { properties: Properties, - work_sheet_collection: ThinVec, - macros_code: Option>, + work_sheet_collection: Vec, + macros_code: Option>, code_name: StringValue, ribbon_xml_data: StringValue, theme: Theme, stylesheet: Stylesheet, shared_string_table: Arc>, workbook_view: WorkbookView, - backup_context_types: ThinVec<(Box, Box)>, - pivot_caches: ThinVec<(Box, Box, Box)>, + backup_context_types: Vec<(Box, Box)>, + pivot_caches: Vec<(Box, Box, Box)>, workbook_protection: Option>, - defined_names: ThinVec, + defined_names: Vec, } impl Spreadsheet { @@ -235,7 +234,7 @@ impl Spreadsheet { /// # Arguments /// * `value` - Macros Code Raw Data. #[inline] - pub fn set_macros_code(&mut self, value: impl Into>) -> &mut Self { + pub fn set_macros_code(&mut self, value: impl Into>) -> &mut Self { self.macros_code = Some(value.into()); self } @@ -339,7 +338,7 @@ impl Spreadsheet { /// Get Work Sheet List in mutable. #[inline] - pub fn get_sheet_collection_mut(&mut self) -> &mut ThinVec { + pub fn get_sheet_collection_mut(&mut self) -> &mut Vec { self.read_sheet_collection(); &mut self.work_sheet_collection } @@ -643,7 +642,7 @@ impl Spreadsheet { #[inline] pub(crate) fn set_backup_context_types( &mut self, - value: impl Into>, + value: impl Into>, ) -> &mut Self { self.backup_context_types = value .into() @@ -723,7 +722,7 @@ impl Spreadsheet { /// Get Defined Name (Vec) in mutable. #[inline] - pub fn get_defined_names_mut(&mut self) -> &mut ThinVec { + pub fn get_defined_names_mut(&mut self) -> &mut Vec { &mut self.defined_names } @@ -731,7 +730,7 @@ impl Spreadsheet { /// # Arguments /// * `value` - Vec. #[inline] - pub fn set_defined_names(&mut self, value: impl Into>) { + pub fn set_defined_names(&mut self, value: impl Into>) { self.defined_names = value.into(); } diff --git a/src/structs/stylesheet.rs b/src/structs/stylesheet.rs index fc4118ac..ab02621d 100644 --- a/src/structs/stylesheet.rs +++ b/src/structs/stylesheet.rs @@ -17,7 +17,6 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::Reader; use quick_xml::Writer; use std::io::Cursor; -use thin_vec::ThinVec; #[derive(Clone, Default, Debug)] pub(crate) struct Stylesheet { @@ -30,7 +29,7 @@ pub(crate) struct Stylesheet { cell_styles: CellStyles, differential_formats: DifferentialFormats, colors: Colors, - maked_style_list: ThinVec