diff --git a/libxlsxwriter-sys/Cargo.toml b/libxlsxwriter-sys/Cargo.toml index 93a5256..a355e8f 100644 --- a/libxlsxwriter-sys/Cargo.toml +++ b/libxlsxwriter-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libxlsxwriter-sys" -version = "1.1.5" +version = "1.1.7" authors = ["OKAMURA, Yasunobu "] edition = "2018" build = "build.rs" @@ -13,7 +13,11 @@ keywords = ["excel", "xlsx", "ffi"] categories = ["external-ffi-bindings"] license = "MIT" -exclude = ["third_party/libxlsxwriter/docs", "third_party/libxlsxwriter/test", "third_party/zlib/contrib"] +exclude = [ + "third_party/libxlsxwriter/docs", + "third_party/libxlsxwriter/test", + "third_party/zlib/contrib", +] [dependencies] @@ -24,4 +28,4 @@ system-zlib = [] [build-dependencies] cc = "1.0" -bindgen = "0.65" +bindgen = "0.69.4" diff --git a/libxlsxwriter-sys/third_party/libxlsxwriter b/libxlsxwriter-sys/third_party/libxlsxwriter index fc06b59..7548faa 160000 --- a/libxlsxwriter-sys/third_party/libxlsxwriter +++ b/libxlsxwriter-sys/third_party/libxlsxwriter @@ -1 +1 @@ -Subproject commit fc06b59d5bd5ee62afe820083d73b02ee29b2842 +Subproject commit 7548faa95afdf8ac321136d10eda931683fbf7c6 diff --git a/libxlsxwriter-sys/third_party/zlib b/libxlsxwriter-sys/third_party/zlib index 21767c6..51b7f2a 160000 --- a/libxlsxwriter-sys/third_party/zlib +++ b/libxlsxwriter-sys/third_party/zlib @@ -1 +1 @@ -Subproject commit 21767c654d31d2dccdde4330529775c6c5fd5389 +Subproject commit 51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf diff --git a/libxlsxwriter/Cargo.toml b/libxlsxwriter/Cargo.toml index 4b86bb3..9da0fc3 100644 --- a/libxlsxwriter/Cargo.toml +++ b/libxlsxwriter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xlsxwriter" -version = "0.6.0" +version = "0.6.1" authors = ["OKAMURA, Yasunobu "] edition = "2018" readme = "../README.md" @@ -21,8 +21,8 @@ system-zlib = ["libxlsxwriter-sys/system-zlib"] chrono = ["dep:chrono"] [dependencies] -libxlsxwriter-sys = {path = "../libxlsxwriter-sys", version = "1.1.5"} +libxlsxwriter-sys = { path = "../libxlsxwriter-sys", version = "1.1.7" } chrono = { version = "0.4", optional = true } [dev-dependencies] -chrono = { version = "0.4" } \ No newline at end of file +chrono = { version = "0.4" } diff --git a/libxlsxwriter/src/worksheet/conditional_format/mod.rs b/libxlsxwriter/src/worksheet/conditional_format/mod.rs index 5fbc4af..fa1ad2e 100644 --- a/libxlsxwriter/src/worksheet/conditional_format/mod.rs +++ b/libxlsxwriter/src/worksheet/conditional_format/mod.rs @@ -56,13 +56,13 @@ use std::os::raw::c_char; fn set_value_helper( float_value_store: &mut f64, - string_value_store: &mut *mut c_char, + string_value_store: &mut *const c_char, value: &StringOrFloat, c_string_helper: &mut CStringHelper, ) -> Result<(), XlsxError> { match value { StringOrFloat::Float(f) => *float_value_store = *f, - StringOrFloat::String(s) => *string_value_store = c_string_helper.add(s)? as *mut c_char, + StringOrFloat::String(s) => *string_value_store = c_string_helper.add(s)?, } Ok(()) } diff --git a/libxlsxwriter/src/worksheet/filter.rs b/libxlsxwriter/src/worksheet/filter.rs index c42a46e..2583c34 100644 --- a/libxlsxwriter/src/worksheet/filter.rs +++ b/libxlsxwriter/src/worksheet/filter.rs @@ -259,11 +259,8 @@ impl<'a> Worksheet<'a> { list: &[&str], ) -> Result<(), XlsxError> { let mut cstring_helper = crate::CStringHelper::new(); - let mut cstr_list: Vec<_> = try_to_vec( - list.iter() - .map(|x| Ok(cstring_helper.add(x)? as *mut std::os::raw::c_char)), - )?; - cstr_list.push(std::ptr::null_mut()); + let mut cstr_list: Vec<_> = try_to_vec(list.iter().map(|x| Ok(cstring_helper.add(x)?)))?; + cstr_list.push(std::ptr::null()); unsafe { let result = libxlsxwriter_sys::worksheet_filter_list( self.worksheet, diff --git a/libxlsxwriter/src/worksheet/validation.rs b/libxlsxwriter/src/worksheet/validation.rs index 424ed6e..4278929 100644 --- a/libxlsxwriter/src/worksheet/validation.rs +++ b/libxlsxwriter/src/worksheet/validation.rs @@ -9,19 +9,59 @@ use std::os::raw::c_char; #[derive(Debug, Clone, PartialEq, PartialOrd)] pub enum DataValidationType { - Integer{ignore_blank: bool, number_options: DataValidationNumberOptions }, - IntegerFormula{ignore_blank: bool, formula: String }, - Decimal{ignore_blank: bool, number_options: DataValidationNumberOptions }, - DecimalFormula{ignore_blank: bool, formula: String }, - List{ignore_blank: bool, dropdown: bool, values: Vec }, - ListFormula{ignore_blank: bool, formula: String }, - Date{ignore_blank: bool, number_options: DataValidationNumberOptions }, - DateFormula{ignore_blank: bool, formula: String }, - Time{ignore_blank: bool, number_options: DataValidationNumberOptions }, - TimeFormula{ignore_blank: bool, formula: String }, - Length{ignore_blank: bool, number_options: DataValidationNumberOptions }, - LengthFormula{ignore_blank: bool, formula: String }, - CustomFormula{ignore_blank: bool, formula: String }, + Integer { + ignore_blank: bool, + number_options: DataValidationNumberOptions, + }, + IntegerFormula { + ignore_blank: bool, + formula: String, + }, + Decimal { + ignore_blank: bool, + number_options: DataValidationNumberOptions, + }, + DecimalFormula { + ignore_blank: bool, + formula: String, + }, + List { + ignore_blank: bool, + dropdown: bool, + values: Vec, + }, + ListFormula { + ignore_blank: bool, + formula: String, + }, + Date { + ignore_blank: bool, + number_options: DataValidationNumberOptions, + }, + DateFormula { + ignore_blank: bool, + formula: String, + }, + Time { + ignore_blank: bool, + number_options: DataValidationNumberOptions, + }, + TimeFormula { + ignore_blank: bool, + formula: String, + }, + Length { + ignore_blank: bool, + number_options: DataValidationNumberOptions, + }, + LengthFormula { + ignore_blank: bool, + formula: String, + }, + CustomFormula { + ignore_blank: bool, + formula: String, + }, Any, } @@ -173,11 +213,9 @@ impl DataValidation { } _ => None, }; - let mut _value_list_ptr: Option> = match &self.validation_type { + let mut _value_list_ptr: Option> = match &self.validation_type { DataValidationType::List { values, .. } => Some(try_to_vec( - values - .iter() - .map(|y| Ok(c_string_helper.add(y)? as *mut c_char)), + values.iter().map(|y| Ok(c_string_helper.add(y)?)), )) .transpose()?, _ => None, @@ -185,25 +223,40 @@ impl DataValidation { if let Some(l) = _value_list_ptr.as_mut() { l.push(std::ptr::null_mut()); } - let(minimum_number, maximum_number) = match self.validation_type { - DataValidationType::Integer { number_options: - DataValidationNumberOptions::Between(x, y) | - DataValidationNumberOptions::NotBetween(x, y), .. } => (x as f64, y as f64), - DataValidationType::Decimal { number_options: - DataValidationNumberOptions::Between(x, y) | - DataValidationNumberOptions::NotBetween(x, y), .. } => (x, y), - DataValidationType::Length { number_options: - DataValidationNumberOptions::Between(x, y) | - DataValidationNumberOptions::NotBetween(x, y), .. } => (x as f64, y as f64), - _ => (0., 0.) + let (minimum_number, maximum_number) = match self.validation_type { + DataValidationType::Integer { + number_options: + DataValidationNumberOptions::Between(x, y) + | DataValidationNumberOptions::NotBetween(x, y), + .. + } => (x as f64, y as f64), + DataValidationType::Decimal { + number_options: + DataValidationNumberOptions::Between(x, y) + | DataValidationNumberOptions::NotBetween(x, y), + .. + } => (x, y), + DataValidationType::Length { + number_options: + DataValidationNumberOptions::Between(x, y) + | DataValidationNumberOptions::NotBetween(x, y), + .. + } => (x as f64, y as f64), + _ => (0., 0.), }; let (minimum_datetime, maximum_datetime) = match &self.validation_type { - DataValidationType::Date { number_options: - DataValidationNumberOptions::Between(x, y) - | DataValidationNumberOptions::NotBetween(x, y), .. } - | DataValidationType::Time { number_options: - DataValidationNumberOptions::Between(x, y) - | DataValidationNumberOptions::NotBetween(x, y), .. } => (x.into(), y.into()), + DataValidationType::Date { + number_options: + DataValidationNumberOptions::Between(x, y) + | DataValidationNumberOptions::NotBetween(x, y), + .. + } + | DataValidationType::Time { + number_options: + DataValidationNumberOptions::Between(x, y) + | DataValidationNumberOptions::NotBetween(x, y), + .. + } => (x.into(), y.into()), _ => ((&DateTime::default()).into(), (&DateTime::default()).into()), }; Ok(CDataValidation { @@ -340,7 +393,7 @@ impl DataValidation { #[derive(Debug, Clone)] pub(crate) struct CDataValidation { - _value_list_ptr: Option>, + _value_list_ptr: Option>, pub(crate) data_validation: libxlsxwriter_sys::lxw_data_validation, }