UPDATE: Update to Rust 2024 edition
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
name = "ironcalc_base"
|
||||
version = "0.3.0"
|
||||
authors = ["Nicolás Hatcher <nicolas@theuniverse.today>"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
homepage = "https://www.ironcalc.com"
|
||||
repository = "https://github.com/ironcalc/ironcalc/"
|
||||
description = "Open source spreadsheet engine"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ironcalc_base::{types::CellType, Model};
|
||||
use ironcalc_base::{Model, types::CellType};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut model = Model::new_empty("formulas-and-errors", "en", "UTC")?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ironcalc_base::{cell::CellValue, Model};
|
||||
use ironcalc_base::{Model, cell::CellValue};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut model = Model::new_empty("hello-world", "en", "UTC")?;
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::{
|
||||
expressions::{
|
||||
parser::{
|
||||
move_formula::ref_is_in_area,
|
||||
stringify::{to_string, to_string_displaced, DisplaceData},
|
||||
stringify::{DisplaceData, to_string, to_string_displaced},
|
||||
walk::forward_references,
|
||||
},
|
||||
types::{Area, CellReferenceIndex, CellReferenceRC},
|
||||
|
||||
@@ -149,14 +149,16 @@ impl Lexer {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
return Err(self
|
||||
.set_error(&format!("Failed parsing row {}", row_left), position))
|
||||
.set_error(&format!("Failed parsing row {}", row_left), position));
|
||||
}
|
||||
};
|
||||
let row_right = match row_right.parse::<i32>() {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
return Err(self
|
||||
.set_error(&format!("Failed parsing row {}", row_right), position))
|
||||
return Err(self.set_error(
|
||||
&format!("Failed parsing row {}", row_right),
|
||||
position,
|
||||
));
|
||||
}
|
||||
};
|
||||
if row_left > LAST_ROW {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{
|
||||
stringify::{stringify_reference, DisplaceData},
|
||||
Node, Reference,
|
||||
stringify::{DisplaceData, stringify_reference},
|
||||
};
|
||||
use crate::{
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::lexer::LexerMode;
|
||||
use crate::expressions::parser::stringify::{
|
||||
to_rc_format, to_string, to_string_displaced, DisplaceData,
|
||||
DisplaceData, to_rc_format, to_string, to_string_displaced,
|
||||
};
|
||||
use crate::expressions::parser::{Node, Parser};
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::parser::stringify::to_string;
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::stringify::to_string;
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::parser::move_formula::{move_formula, MoveContext};
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::move_formula::{MoveContext, move_formula};
|
||||
use crate::expressions::types::{Area, CellReferenceRC};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::lexer::LexerMode;
|
||||
|
||||
use crate::expressions::parser::stringify::{to_rc_format, to_string};
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::stringify::{to_rc_format, to_string};
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
struct Formula<'a> {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::parser::stringify::to_string;
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::stringify::to_string;
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{move_formula::ref_is_in_area, Node};
|
||||
use super::{Node, move_formula::ref_is_in_area};
|
||||
|
||||
use crate::expressions::types::{Area, CellReferenceIndex};
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ pub fn format_number(value_original: f64, format: &str, locale: &Locale) -> Form
|
||||
text: "#VALUE!".to_owned(),
|
||||
color: None,
|
||||
error: Some(e),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
for token in tokens {
|
||||
@@ -391,11 +391,7 @@ pub fn format_number(value_original: f64, format: &str, locale: &Locale) -> Form
|
||||
if l_exp <= p.exponent_digit_count {
|
||||
if !(number_index < 0 && digit.kind == '#') {
|
||||
let c = if number_index < 0 {
|
||||
if digit.kind == '?' {
|
||||
' '
|
||||
} else {
|
||||
'0'
|
||||
}
|
||||
if digit.kind == '?' { ' ' } else { '0' }
|
||||
} else {
|
||||
exponent_part[number_index as usize]
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::{
|
||||
formatter::format::format_number,
|
||||
locale::{get_locale, Locale},
|
||||
locale::{Locale, get_locale},
|
||||
};
|
||||
|
||||
fn get_default_locale() -> &'static Locale {
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Model {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
let day = date.day() as f64;
|
||||
@@ -54,7 +54,7 @@ impl Model {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
let month = date.month() as f64;
|
||||
@@ -87,7 +87,7 @@ impl Model {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
if serial_number > MAXIMUM_DATE_SERIAL_NUMBER as i64 {
|
||||
@@ -192,7 +192,7 @@ impl Model {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
let year = date.year() as f64;
|
||||
@@ -216,7 +216,7 @@ impl Model {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -266,7 +266,7 @@ impl Model {
|
||||
error: Error::ERROR,
|
||||
origin: cell,
|
||||
message: "Invalid date".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
// 693_594 is computed as:
|
||||
@@ -296,7 +296,7 @@ impl Model {
|
||||
error: Error::ERROR,
|
||||
origin: cell,
|
||||
message: "Invalid date".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
// 693_594 is computed as:
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
use std::f64::consts::FRAC_2_PI;
|
||||
|
||||
use super::bessel_util::{high_word, split_words, FRAC_2_SQRT_PI, HUGE};
|
||||
use super::bessel_util::{FRAC_2_SQRT_PI, HUGE, high_word, split_words};
|
||||
|
||||
// R0/S0 on [0, 2.00]
|
||||
const R02: f64 = 1.562_499_999_999_999_5e-2; // 0x3F8FFFFF, 0xFFFFFFFD
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
use std::f64::consts::FRAC_2_PI;
|
||||
|
||||
use super::bessel_util::{high_word, split_words, FRAC_2_SQRT_PI, HUGE};
|
||||
use super::bessel_util::{FRAC_2_SQRT_PI, HUGE, high_word, split_words};
|
||||
|
||||
// R0/S0 on [0,2]
|
||||
const R00: f64 = -6.25e-2; // 0xBFB00000, 0x00000000
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
use super::{
|
||||
bessel_j0_y0::{j0, y0},
|
||||
bessel_j1_y1::{j1, y1},
|
||||
bessel_util::{split_words, FRAC_2_SQRT_PI},
|
||||
bessel_util::{FRAC_2_SQRT_PI, split_words},
|
||||
};
|
||||
|
||||
// Special cases are:
|
||||
@@ -232,11 +232,7 @@ pub(crate) fn jn(n: i32, x: f64) -> f64 {
|
||||
}
|
||||
}
|
||||
};
|
||||
if sign == 1 {
|
||||
-b
|
||||
} else {
|
||||
b
|
||||
}
|
||||
if sign == 1 { -b } else { b }
|
||||
}
|
||||
|
||||
// Yn returns the order-n Bessel function of the second kind.
|
||||
@@ -321,9 +317,5 @@ pub(crate) fn yn(n: i32, x: f64) -> f64 {
|
||||
}
|
||||
b
|
||||
};
|
||||
if sign > 0 {
|
||||
b
|
||||
} else {
|
||||
-b
|
||||
}
|
||||
if sign > 0 { b } else { -b }
|
||||
}
|
||||
|
||||
@@ -45,9 +45,5 @@ pub(crate) fn erf(x: f64) -> f64 {
|
||||
}
|
||||
|
||||
let res = t * f64::exp(-x_abs * x_abs + 0.5 * (cof[0] + ty * d) - dd);
|
||||
if x < 0.0 {
|
||||
res - 1.0
|
||||
} else {
|
||||
1.0 - res
|
||||
}
|
||||
if x < 0.0 { res - 1.0 } else { 1.0 - res }
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
CalcResult::Number(ipmt)
|
||||
@@ -762,7 +762,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
CalcResult::Number(ppmt)
|
||||
@@ -1075,7 +1075,7 @@ impl Model {
|
||||
error,
|
||||
origin: cell,
|
||||
message,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1096,7 +1096,7 @@ impl Model {
|
||||
error,
|
||||
origin: cell,
|
||||
message,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1634,7 +1634,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1702,7 +1702,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1750,11 +1750,7 @@ impl Model {
|
||||
rate = 1.0
|
||||
};
|
||||
let value = if rate == 1.0 {
|
||||
if period == 1.0 {
|
||||
cost
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
if period == 1.0 { cost } else { 0.0 }
|
||||
} else {
|
||||
cost * (1.0 - rate).powf(period - 1.0)
|
||||
};
|
||||
|
||||
@@ -257,10 +257,10 @@ impl Model {
|
||||
{
|
||||
match defined_name {
|
||||
ParsedDefinedName::CellReference(reference) => {
|
||||
return CalcResult::Number(reference.sheet as f64 + 1.0)
|
||||
return CalcResult::Number(reference.sheet as f64 + 1.0);
|
||||
}
|
||||
ParsedDefinedName::RangeReference(range) => {
|
||||
return CalcResult::Number(range.left.sheet as f64 + 1.0)
|
||||
return CalcResult::Number(range.left.sheet as f64 + 1.0);
|
||||
}
|
||||
ParsedDefinedName::InvalidDefinedNameFormula => {
|
||||
return CalcResult::Error {
|
||||
@@ -296,7 +296,7 @@ impl Model {
|
||||
error: Error::NAME,
|
||||
origin: cell,
|
||||
message: format!("Name not found: {name}"),
|
||||
}
|
||||
};
|
||||
}
|
||||
arg => {
|
||||
// Now it should be the name of a sheet
|
||||
|
||||
@@ -388,7 +388,7 @@ impl Model {
|
||||
Error::ERROR,
|
||||
cell,
|
||||
format!("Invalid worksheet index: '{}'", first_range.left.sheet),
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
let max_row = dimension.max_row;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
calc_result::CalcResult,
|
||||
expressions::{
|
||||
parser::{parse_range, Node},
|
||||
parser::{Node, parse_range},
|
||||
token::Error,
|
||||
types::CellReferenceIndex,
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
text_util::{substitute, text_after, text_before, Case},
|
||||
text_util::{Case, substitute, text_after, text_before},
|
||||
util::from_wildcard_to_regex,
|
||||
};
|
||||
|
||||
@@ -368,7 +368,7 @@ impl Model {
|
||||
error: Error::VALUE,
|
||||
origin: cell,
|
||||
message: "Empty cell".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -629,7 +629,7 @@ impl Model {
|
||||
error: Error::VALUE,
|
||||
origin: cell,
|
||||
message: "Expecting number".to_string(),
|
||||
}
|
||||
};
|
||||
}
|
||||
error @ CalcResult::Error { .. } => return error,
|
||||
CalcResult::Range { .. } => {
|
||||
|
||||
@@ -57,8 +57,8 @@ mod test;
|
||||
#[cfg(test)]
|
||||
pub mod mock_time;
|
||||
|
||||
pub use model::get_milliseconds_since_epoch;
|
||||
pub use model::Model;
|
||||
pub use model::get_milliseconds_since_epoch;
|
||||
pub use user_model::BorderArea;
|
||||
pub use user_model::ClipboardData;
|
||||
pub use user_model::UserModel;
|
||||
|
||||
@@ -10,11 +10,11 @@ use crate::{
|
||||
expressions::{
|
||||
lexer::LexerMode,
|
||||
parser::{
|
||||
move_formula::{move_formula, MoveContext},
|
||||
stringify::{rename_defined_name_in_node, to_rc_format, to_string},
|
||||
Node, Parser,
|
||||
move_formula::{MoveContext, move_formula},
|
||||
stringify::{rename_defined_name_in_node, to_rc_format, to_string},
|
||||
},
|
||||
token::{get_error_by_name, Error, OpCompare, OpProduct, OpSum, OpUnary},
|
||||
token::{Error, OpCompare, OpProduct, OpSum, OpUnary, get_error_by_name},
|
||||
types::*,
|
||||
utils::{self, is_valid_column_number, is_valid_identifier, is_valid_row},
|
||||
},
|
||||
@@ -24,8 +24,8 @@ use crate::{
|
||||
},
|
||||
functions::util::compare_values,
|
||||
implicit_intersection::implicit_intersection,
|
||||
language::{get_language, Language},
|
||||
locale::{get_locale, Currency, Locale},
|
||||
language::{Language, get_language},
|
||||
locale::{Currency, Locale, get_locale},
|
||||
types::*,
|
||||
utils as common,
|
||||
};
|
||||
|
||||
@@ -8,14 +8,14 @@ use crate::{
|
||||
expressions::{
|
||||
lexer::LexerMode,
|
||||
parser::{
|
||||
stringify::{rename_sheet_in_node, to_rc_format},
|
||||
Parser,
|
||||
stringify::{rename_sheet_in_node, to_rc_format},
|
||||
},
|
||||
types::CellReferenceRC,
|
||||
},
|
||||
language::get_language,
|
||||
locale::get_locale,
|
||||
model::{get_milliseconds_since_epoch, Model, ParsedDefinedName},
|
||||
model::{Model, ParsedDefinedName, get_milliseconds_since_epoch},
|
||||
types::{
|
||||
Metadata, SheetState, Workbook, WorkbookSettings, WorkbookView, Worksheet, WorksheetView,
|
||||
},
|
||||
|
||||
@@ -150,7 +150,7 @@ pub fn format_number(value: f64, format_code: &str, locale: &str) -> Formatted {
|
||||
text: "#ERROR!".to_owned(),
|
||||
color: None,
|
||||
error: Some("Invalid locale".to_string()),
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
formatter::format::format_number(value, format_code, locale)
|
||||
|
||||
@@ -206,9 +206,11 @@ fn test_delete_column_width() {
|
||||
let (sheet, column) = (0, 5);
|
||||
let normal_width = model.get_column_width(sheet, column).unwrap();
|
||||
// Set the width of one column to 5 times the normal width
|
||||
assert!(model
|
||||
.set_column_width(sheet, column, normal_width * 5.0)
|
||||
.is_ok());
|
||||
assert!(
|
||||
model
|
||||
.set_column_width(sheet, column, normal_width * 5.0)
|
||||
.is_ok()
|
||||
);
|
||||
|
||||
// delete it
|
||||
assert!(model.delete_columns(sheet, column, 1).is_ok());
|
||||
|
||||
@@ -179,52 +179,60 @@ fn test_move_formula_rectangle() {
|
||||
width: 2,
|
||||
height: 20,
|
||||
};
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 3,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err());
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 2,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok());
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 20,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok());
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 21,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err());
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 3,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 2,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 20,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 21,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{constants::DEFAULT_COLUMN_WIDTH, UserModel};
|
||||
use crate::{UserModel, constants::DEFAULT_COLUMN_WIDTH};
|
||||
|
||||
#[test]
|
||||
fn add_undo_redo() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||
use crate::expressions::types::Area;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||
use crate::expressions::types::Area;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
BorderArea, UserModel,
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
expressions::{types::Area, utils::number_to_column},
|
||||
types::{Border, BorderItem, BorderStyle},
|
||||
BorderArea, UserModel,
|
||||
};
|
||||
|
||||
// checks there are no borders in the sheet
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{expressions::types::Area, UserModel};
|
||||
use crate::{UserModel, expressions::types::Area};
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW};
|
||||
use crate::expressions::types::Area;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn column_width() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW},
|
||||
expressions::types::Area,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -157,7 +157,9 @@ fn new_sheet() {
|
||||
#[test]
|
||||
fn wrong_diffs_handled() {
|
||||
let mut model = UserModel::from_model(new_empty_model());
|
||||
assert!(model
|
||||
.apply_external_diffs("Hello world".as_bytes())
|
||||
.is_err());
|
||||
assert!(
|
||||
model
|
||||
.apply_external_diffs("Hello world".as_bytes())
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::types::CellType;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn set_user_input_errors() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{
|
||||
DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_WINDOW_HEIGHT, DEFAULT_WINDOW_WIDTH,
|
||||
LAST_COLUMN,
|
||||
},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_WINDOW_WIDTH},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_WINDOW_WIDTH, LAST_COLUMN},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::types::Fill;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn simple_pasting() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{expressions::types::Area, UserModel};
|
||||
use crate::{UserModel, expressions::types::Area};
|
||||
|
||||
#[test]
|
||||
fn csv_paste() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
constants::LAST_ROW, expressions::types::Area, test::util::new_empty_model, UserModel,
|
||||
UserModel, constants::LAST_ROW, expressions::types::Area, test::util::new_empty_model,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
|
||||
#[test]
|
||||
fn basic_undo_redo() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
expressions::types::Area,
|
||||
types::{Alignment, HorizontalAlignment, VerticalAlignment},
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{test::util::new_empty_model, UserModel};
|
||||
use crate::{UserModel, test::util::new_empty_model};
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{test::util::new_empty_model, UserModel};
|
||||
use crate::{UserModel, test::util::new_empty_model};
|
||||
|
||||
#[test]
|
||||
fn simple_undo_redo() {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
test::util::new_empty_model,
|
||||
user_model::SelectedView,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_ROW_HEIGHT, DEFAULT_WINDOW_HEIGHT, DEFAULT_WINDOW_WIDTH},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{expressions::types::Area, types::Border, BorderArea, UserModel};
|
||||
use crate::{BorderArea, UserModel, expressions::types::Area, types::Border};
|
||||
|
||||
impl UserModel {
|
||||
pub fn _set_cell_border(&mut self, cell: &str, color: &str) {
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
border_utils::is_max_border, common::BorderType, history::Diff, BorderArea, UserModel,
|
||||
BorderArea, UserModel, border_utils::is_max_border, common::BorderType, history::Diff,
|
||||
};
|
||||
|
||||
impl UserModel {
|
||||
|
||||
@@ -156,7 +156,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::language::get_language;
|
||||
use crate::locale::{get_locale, Locale};
|
||||
use crate::locale::{Locale, get_locale};
|
||||
|
||||
fn get_test_locale() -> &'static Locale {
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
name = "ironcalc_nodejs"
|
||||
version = "0.3.1"
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
tab_spaces = 2
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![deny(clippy::all)]
|
||||
|
||||
use napi::{self, bindgen_prelude::*, JsUnknown, Result};
|
||||
use napi::{self, JsUnknown, Result, bindgen_prelude::*};
|
||||
use serde::Serialize;
|
||||
|
||||
use ironcalc::{
|
||||
base::{
|
||||
types::{CellType, Style},
|
||||
Model as BaseModel,
|
||||
types::{CellType, Style},
|
||||
},
|
||||
error::XlsxError,
|
||||
export::{save_to_icalc, save_to_xlsx},
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use napi::{self, bindgen_prelude::*, JsUnknown, Result};
|
||||
use napi::{self, JsUnknown, Result, bindgen_prelude::*};
|
||||
|
||||
use ironcalc::base::{
|
||||
BorderArea, ClipboardData, UserModel as BaseModel,
|
||||
expressions::types::Area,
|
||||
types::{CellType, Style},
|
||||
BorderArea, ClipboardData, UserModel as BaseModel,
|
||||
};
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "pyroncalc"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
|
||||
[lib]
|
||||
|
||||
@@ -2,8 +2,8 @@ use pyo3::exceptions::PyException;
|
||||
use pyo3::{create_exception, prelude::*, wrap_pyfunction};
|
||||
|
||||
use types::{PySheetProperty, PyStyle};
|
||||
use xlsx::base::types::Style;
|
||||
use xlsx::base::Model;
|
||||
use xlsx::base::types::Style;
|
||||
|
||||
use xlsx::export::{save_to_icalc, save_to_xlsx};
|
||||
use xlsx::import;
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Nicolas Hatcher <nicolas@theuniverse.today>"]
|
||||
description = "IronCalc Web bindings"
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/ironcalc/ironcalc"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use serde::Serialize;
|
||||
use wasm_bindgen::{
|
||||
prelude::{wasm_bindgen, JsError},
|
||||
JsValue,
|
||||
prelude::{JsError, wasm_bindgen},
|
||||
};
|
||||
|
||||
use ironcalc_base::{
|
||||
BorderArea, ClipboardData, UserModel as BaseModel,
|
||||
expressions::{lexer::util::get_tokens as tokenizer, types::Area, utils::number_to_column},
|
||||
types::{CellType, Style},
|
||||
BorderArea, ClipboardData, UserModel as BaseModel,
|
||||
};
|
||||
|
||||
fn to_js_error(error: String) -> JsError {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "generate_locale"
|
||||
version = "0.1.0"
|
||||
authors = ["Nicolás Hatcher <nicolas@theuniverse.today>"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "ironcalc_server"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
rocket = "0.5"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "ironcalc"
|
||||
version = "0.3.0"
|
||||
authors = ["Nicolás Hatcher <nicolas@theuniverse.today>"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
homepage = "https://www.ironcalc.com"
|
||||
repository = "https://github.com/ironcalc/ironcalc/"
|
||||
description = "The democratization of spreadsheets"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use ironcalc::{
|
||||
base::{expressions::utils::number_to_column, Model},
|
||||
base::{Model, expressions::utils::number_to_column},
|
||||
export::save_to_xlsx,
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::path::Path;
|
||||
|
||||
use ironcalc_base::cell::CellValue;
|
||||
use ironcalc_base::types::*;
|
||||
use ironcalc_base::{expressions::utils::number_to_column, Model};
|
||||
use ironcalc_base::{Model, expressions::utils::number_to_column};
|
||||
|
||||
use crate::export::save_to_xlsx;
|
||||
use crate::import::load_from_xlsx;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use chrono::DateTime;
|
||||
use ironcalc_base::{
|
||||
new_empty::{APPLICATION, APP_VERSION, IRONCALC_USER},
|
||||
new_empty::{APP_VERSION, APPLICATION, IRONCALC_USER},
|
||||
types::Workbook,
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ pub(crate) fn get_core_xml(workbook: &Workbook, milliseconds: i64) -> Result<Str
|
||||
return Err(XlsxError::Xml(format!(
|
||||
"Invalid timestamp: {}",
|
||||
milliseconds
|
||||
)))
|
||||
)));
|
||||
}
|
||||
};
|
||||
let last_modified = dt.format("%Y-%m-%dT%H:%M:%SZ").to_string();
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::{
|
||||
|
||||
use ironcalc_base::expressions::utils::number_to_column;
|
||||
use ironcalc_base::types::Workbook;
|
||||
use ironcalc_base::{get_milliseconds_since_epoch, Model};
|
||||
use ironcalc_base::{Model, get_milliseconds_since_epoch};
|
||||
|
||||
use self::xml_constants::XML_DECLARATION;
|
||||
|
||||
|
||||
@@ -9,8 +9,12 @@ pub(crate) fn get_shared_strings_xml(model: &Workbook) -> String {
|
||||
for shared_string in &model.shared_strings {
|
||||
shared_strings.push(format!("<si><t>{}</t></si>", escape_xml(shared_string)));
|
||||
}
|
||||
format!("{}\n\
|
||||
format!(
|
||||
"{}\n\
|
||||
<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"{count}\" uniqueCount=\"{unique_count}\">\
|
||||
{}\
|
||||
</sst>", XML_DECLARATION, shared_strings.join(""))
|
||||
</sst>",
|
||||
XML_DECLARATION,
|
||||
shared_strings.join("")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -158,11 +158,13 @@ fn test_named_styles() {
|
||||
save_to_xlsx(&model, temp_file_name).unwrap();
|
||||
|
||||
let model = load_from_xlsx(temp_file_name, "en", "UTC").unwrap();
|
||||
assert!(model
|
||||
.workbook
|
||||
.styles
|
||||
.get_style_index_by_name("bold & italics")
|
||||
.is_ok());
|
||||
assert!(
|
||||
model
|
||||
.workbook
|
||||
.styles
|
||||
.get_style_index_by_name("bold & italics")
|
||||
.is_ok()
|
||||
);
|
||||
fs::remove_file(temp_file_name).unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use itertools::Itertools;
|
||||
|
||||
use ironcalc_base::{
|
||||
expressions::{
|
||||
parser::{stringify::to_excel_string, Node},
|
||||
parser::{Node, stringify::to_excel_string},
|
||||
types::CellReferenceRC,
|
||||
utils::number_to_column,
|
||||
},
|
||||
|
||||
@@ -16,8 +16,8 @@ use std::{
|
||||
use roxmltree::Node;
|
||||
|
||||
use ironcalc_base::{
|
||||
types::{Metadata, Workbook, WorkbookSettings, WorkbookView},
|
||||
Model,
|
||||
types::{Metadata, Workbook, WorkbookSettings, WorkbookView},
|
||||
};
|
||||
|
||||
use crate::error::XlsxError;
|
||||
@@ -28,7 +28,7 @@ use metadata::load_metadata;
|
||||
use styles::load_styles;
|
||||
use util::get_attribute;
|
||||
use workbook::load_workbook;
|
||||
use worksheets::{load_sheets, Relationship};
|
||||
use worksheets::{Relationship, load_sheets};
|
||||
|
||||
fn load_relationships<R: Read + std::io::Seek>(
|
||||
archive: &mut zip::ZipArchive<R>,
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::{collections::HashMap, io::Read, num::ParseIntError};
|
||||
|
||||
use ironcalc_base::{
|
||||
expressions::{
|
||||
parser::{stringify::to_rc_format, Parser},
|
||||
token::{get_error_by_english_name, Error},
|
||||
parser::{Parser, stringify::to_rc_format},
|
||||
token::{Error, get_error_by_english_name},
|
||||
types::CellReferenceRC,
|
||||
utils::{column_to_number, parse_reference_a1},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user