UPDATE: Adds bindings to update timezone and locale
UPDATE: Update "generate locale" utility FIX: Minor fixes to UI and proper support for locales/timezones UPDATE: Adds "display language" setting to core
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
use ironcalc_base::{types::CellType, Model};
|
use ironcalc_base::{types::CellType, Model};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut model = Model::new_empty("formulas-and-errors", "en", "UTC")?;
|
let mut model = Model::new_empty("formulas-and-errors", "en", "UTC", "en")?;
|
||||||
// A1
|
// A1
|
||||||
model.set_user_input(0, 1, 1, "1".to_string())?;
|
model.set_user_input(0, 1, 1, "1".to_string())?;
|
||||||
// A2
|
// A2
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use ironcalc_base::{cell::CellValue, Model};
|
use ironcalc_base::{cell::CellValue, Model};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut model = Model::new_empty("hello-world", "en", "UTC")?;
|
let mut model = Model::new_empty("hello-world", "en", "UTC", "en")?;
|
||||||
// A1
|
// A1
|
||||||
model.set_user_input(0, 1, 1, "Hello".to_string())?;
|
model.set_user_input(0, 1, 1, "Hello".to_string())?;
|
||||||
// B1
|
// B1
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||||
use crate::expressions::parser::stringify::{to_string, to_string_displaced, DisplaceData};
|
use crate::expressions::parser::stringify::{
|
||||||
|
to_localized_string, to_string_displaced, DisplaceData,
|
||||||
|
};
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
use crate::model::Model;
|
use crate::model::Model;
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ impl Model {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
// FIXME: This is not a very performant way if the formula has changed :S.
|
// FIXME: This is not a very performant way if the formula has changed :S.
|
||||||
let formula = to_string(node, &cell_reference);
|
let formula = to_localized_string(node, &cell_reference, &self.locale, &self.language);
|
||||||
let formula_displaced = to_string_displaced(node, &cell_reference, displace_data);
|
let formula_displaced = to_string_displaced(node, &cell_reference, displace_data);
|
||||||
if formula != formula_displaced {
|
if formula != formula_displaced {
|
||||||
self.update_cell_with_formula(sheet, row, column, format!("={formula_displaced}"))?;
|
self.update_cell_with_formula(sheet, row, column, format!("={formula_displaced}"))?;
|
||||||
@@ -108,7 +110,9 @@ impl Model {
|
|||||||
// FIXME: we need some user_input getter instead of get_text
|
// FIXME: we need some user_input getter instead of get_text
|
||||||
let formula_or_value = self
|
let formula_or_value = self
|
||||||
.get_cell_formula(sheet, source_row, source_column)?
|
.get_cell_formula(sheet, source_row, source_column)?
|
||||||
.unwrap_or_else(|| source_cell.get_text(&self.workbook.shared_strings, &self.language));
|
.unwrap_or_else(|| {
|
||||||
|
source_cell.get_localized_text(&self.workbook.shared_strings, &self.language)
|
||||||
|
});
|
||||||
self.set_user_input(sheet, target_row, target_column, formula_or_value)?;
|
self.set_user_input(sheet, target_row, target_column, formula_or_value)?;
|
||||||
self.workbook
|
self.workbook
|
||||||
.worksheet_mut(sheet)?
|
.worksheet_mut(sheet)?
|
||||||
@@ -490,9 +494,11 @@ impl Model {
|
|||||||
.cell(r.row, column)
|
.cell(r.row, column)
|
||||||
.ok_or("Expected Cell to exist")?;
|
.ok_or("Expected Cell to exist")?;
|
||||||
let style_idx = cell.get_style();
|
let style_idx = cell.get_style();
|
||||||
let formula_or_value = self
|
let formula_or_value =
|
||||||
.get_cell_formula(sheet, r.row, column)?
|
self.get_cell_formula(sheet, r.row, column)?
|
||||||
.unwrap_or_else(|| cell.get_text(&self.workbook.shared_strings, &self.language));
|
.unwrap_or_else(|| {
|
||||||
|
cell.get_localized_text(&self.workbook.shared_strings, &self.language)
|
||||||
|
});
|
||||||
original_cells.push((r.row, formula_or_value, style_idx));
|
original_cells.push((r.row, formula_or_value, style_idx));
|
||||||
self.cell_clear_all(sheet, r.row, column)?;
|
self.cell_clear_all(sheet, r.row, column)?;
|
||||||
}
|
}
|
||||||
@@ -577,9 +583,9 @@ impl Model {
|
|||||||
.cell(row, *c)
|
.cell(row, *c)
|
||||||
.ok_or("Expected Cell to exist")?;
|
.ok_or("Expected Cell to exist")?;
|
||||||
let style_idx = cell.get_style();
|
let style_idx = cell.get_style();
|
||||||
let formula_or_value = self
|
let formula_or_value = self.get_cell_formula(sheet, row, *c)?.unwrap_or_else(|| {
|
||||||
.get_cell_formula(sheet, row, *c)?
|
cell.get_localized_text(&self.workbook.shared_strings, &self.language)
|
||||||
.unwrap_or_else(|| cell.get_text(&self.workbook.shared_strings, &self.language));
|
});
|
||||||
original_cells.push((*c, formula_or_value, style_idx));
|
original_cells.push((*c, formula_or_value, style_idx));
|
||||||
self.cell_clear_all(sheet, row, *c)?;
|
self.cell_clear_all(sheet, row, *c)?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,16 @@ impl Model {
|
|||||||
if !currencies.iter().any(|e| *e == currency) {
|
if !currencies.iter().any(|e| *e == currency) {
|
||||||
currencies.push(currency);
|
currencies.push(currency);
|
||||||
}
|
}
|
||||||
|
let (decimal_separator, group_separator) =
|
||||||
|
if self.locale.numbers.symbols.decimal == "," {
|
||||||
|
(b',', b'.')
|
||||||
|
} else {
|
||||||
|
(b'.', b',')
|
||||||
|
};
|
||||||
// Try to parse as a formatted number (e.g., dates, currencies, percentages)
|
// Try to parse as a formatted number (e.g., dates, currencies, percentages)
|
||||||
if let Ok((v, _number_format)) = parse_formatted_number(s, ¤cies) {
|
if let Ok((v, _number_format)) =
|
||||||
|
parse_formatted_number(s, ¤cies, decimal_separator, group_separator)
|
||||||
|
{
|
||||||
return Some(v);
|
return Some(v);
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -122,11 +122,17 @@ impl Cell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_text(&self, shared_strings: &[String], language: &Language) -> String {
|
pub fn get_localized_text(&self, shared_strings: &[String], language: &Language) -> String {
|
||||||
match self.value(shared_strings, language) {
|
match self.value(shared_strings, language) {
|
||||||
CellValue::None => "".to_string(),
|
CellValue::None => "".to_string(),
|
||||||
CellValue::String(v) => v,
|
CellValue::String(v) => v,
|
||||||
CellValue::Boolean(v) => v.to_string().to_uppercase(),
|
CellValue::Boolean(v) => {
|
||||||
|
if v {
|
||||||
|
language.booleans.r#true.to_string()
|
||||||
|
} else {
|
||||||
|
language.booleans.r#false.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
CellValue::Number(v) => to_excel_precision_str(v),
|
CellValue::Number(v) => to_excel_precision_str(v),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +177,13 @@ impl Cell {
|
|||||||
match self.value(shared_strings, language) {
|
match self.value(shared_strings, language) {
|
||||||
CellValue::None => "".to_string(),
|
CellValue::None => "".to_string(),
|
||||||
CellValue::String(value) => value,
|
CellValue::String(value) => value,
|
||||||
CellValue::Boolean(value) => value.to_string().to_uppercase(),
|
CellValue::Boolean(value) => {
|
||||||
|
if value {
|
||||||
|
language.booleans.r#true.to_string()
|
||||||
|
} else {
|
||||||
|
language.booleans.r#false.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
CellValue::Number(value) => format_number(value),
|
CellValue::Number(value) => format_number(value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,16 @@ impl Lexer {
|
|||||||
self.mode = mode;
|
self.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the locale
|
||||||
|
pub fn set_locale(&mut self, locale: &Locale) {
|
||||||
|
self.locale = locale.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the language
|
||||||
|
pub fn set_language(&mut self, language: &Language) {
|
||||||
|
self.language = language.clone();
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: I don't think we should have `is_a1_mode` and `get_formula`.
|
// FIXME: I don't think we should have `is_a1_mode` and `get_formula`.
|
||||||
// The caller already knows those two
|
// The caller already knows those two
|
||||||
|
|
||||||
@@ -188,6 +198,7 @@ impl Lexer {
|
|||||||
':' => TokenType::Colon,
|
':' => TokenType::Colon,
|
||||||
';' => TokenType::Semicolon,
|
';' => TokenType::Semicolon,
|
||||||
'@' => TokenType::At,
|
'@' => TokenType::At,
|
||||||
|
'\\' => TokenType::Backslash,
|
||||||
',' => {
|
',' => {
|
||||||
if self.locale.numbers.symbols.decimal == "," {
|
if self.locale.numbers.symbols.decimal == "," {
|
||||||
match self.consume_number(',') {
|
match self.consume_number(',') {
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::functions::Function;
|
use crate::functions::Function;
|
||||||
use crate::language::get_language;
|
use crate::language::get_language;
|
||||||
|
use crate::language::Language;
|
||||||
use crate::locale::get_locale;
|
use crate::locale::get_locale;
|
||||||
|
use crate::locale::Locale;
|
||||||
use crate::types::Table;
|
use crate::types::Table;
|
||||||
|
|
||||||
use super::lexer;
|
use super::lexer;
|
||||||
@@ -208,6 +210,18 @@ pub struct Parser {
|
|||||||
defined_names: Vec<DefinedNameS>,
|
defined_names: Vec<DefinedNameS>,
|
||||||
context: CellReferenceRC,
|
context: CellReferenceRC,
|
||||||
tables: HashMap<String, Table>,
|
tables: HashMap<String, Table>,
|
||||||
|
locale: Locale,
|
||||||
|
language: Language,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_parser_english(
|
||||||
|
worksheets: Vec<String>,
|
||||||
|
defined_names: Vec<DefinedNameS>,
|
||||||
|
tables: HashMap<String, Table>,
|
||||||
|
) -> Parser {
|
||||||
|
let locale = Locale::default();
|
||||||
|
let language = Language::default();
|
||||||
|
Parser::new(worksheets, defined_names, tables, &locale, &language)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parser {
|
impl Parser {
|
||||||
@@ -215,15 +229,10 @@ impl Parser {
|
|||||||
worksheets: Vec<String>,
|
worksheets: Vec<String>,
|
||||||
defined_names: Vec<DefinedNameS>,
|
defined_names: Vec<DefinedNameS>,
|
||||||
tables: HashMap<String, Table>,
|
tables: HashMap<String, Table>,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
) -> Parser {
|
) -> Parser {
|
||||||
let lexer = lexer::Lexer::new(
|
let lexer = lexer::Lexer::new("", lexer::LexerMode::A1, locale, language);
|
||||||
"",
|
|
||||||
lexer::LexerMode::A1,
|
|
||||||
#[allow(clippy::expect_used)]
|
|
||||||
get_locale("en").expect(""),
|
|
||||||
#[allow(clippy::expect_used)]
|
|
||||||
get_language("en").expect(""),
|
|
||||||
);
|
|
||||||
let context = CellReferenceRC {
|
let context = CellReferenceRC {
|
||||||
sheet: worksheets.first().map_or("", |v| v).to_string(),
|
sheet: worksheets.first().map_or("", |v| v).to_string(),
|
||||||
column: 1,
|
column: 1,
|
||||||
@@ -235,12 +244,24 @@ impl Parser {
|
|||||||
defined_names,
|
defined_names,
|
||||||
context,
|
context,
|
||||||
tables,
|
tables,
|
||||||
|
locale: locale.clone(),
|
||||||
|
language: language.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set_lexer_mode(&mut self, mode: lexer::LexerMode) {
|
pub fn set_lexer_mode(&mut self, mode: lexer::LexerMode) {
|
||||||
self.lexer.set_lexer_mode(mode)
|
self.lexer.set_lexer_mode(mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_locale(&mut self, locale: &Locale) {
|
||||||
|
self.locale = locale.clone();
|
||||||
|
self.lexer.set_locale(locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_language(&mut self, language: &Language) {
|
||||||
|
self.language = language.clone();
|
||||||
|
self.lexer.set_language(language);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_worksheets_and_names(
|
pub fn set_worksheets_and_names(
|
||||||
&mut self,
|
&mut self,
|
||||||
worksheets: Vec<String>,
|
worksheets: Vec<String>,
|
||||||
@@ -256,6 +277,27 @@ impl Parser {
|
|||||||
self.parse_expr()
|
self.parse_expr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the token used to separate arguments in functions and arrays
|
||||||
|
// If the locale decimal separator is '.', then it is a comma ','
|
||||||
|
// Otherwise, it is a semicolon ';'
|
||||||
|
fn get_argument_separator_token(&self) -> TokenType {
|
||||||
|
if self.locale.numbers.symbols.decimal == "." {
|
||||||
|
TokenType::Comma
|
||||||
|
} else {
|
||||||
|
TokenType::Semicolon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the token used to separate columns in arrays
|
||||||
|
// If the locale decimal separator is '.', then it is a semicolon ';'
|
||||||
|
fn get_column_separator_token(&self) -> TokenType {
|
||||||
|
if self.locale.numbers.symbols.decimal == "." {
|
||||||
|
TokenType::Semicolon
|
||||||
|
} else {
|
||||||
|
TokenType::Backslash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_sheet_index_by_name(&self, name: &str) -> Option<u32> {
|
fn get_sheet_index_by_name(&self, name: &str) -> Option<u32> {
|
||||||
let worksheets = &self.worksheets;
|
let worksheets = &self.worksheets;
|
||||||
for (i, sheet) in worksheets.iter().enumerate() {
|
for (i, sheet) in worksheets.iter().enumerate() {
|
||||||
@@ -464,6 +506,7 @@ impl Parser {
|
|||||||
|
|
||||||
fn parse_array_row(&mut self) -> Result<Vec<ArrayNode>, Node> {
|
fn parse_array_row(&mut self) -> Result<Vec<ArrayNode>, Node> {
|
||||||
let mut row = Vec::new();
|
let mut row = Vec::new();
|
||||||
|
let column_separator_token = self.get_argument_separator_token();
|
||||||
// and array can only have numbers, string or booleans
|
// and array can only have numbers, string or booleans
|
||||||
// otherwise it is a syntax error
|
// otherwise it is a syntax error
|
||||||
let first_element = match self.parse_expr() {
|
let first_element = match self.parse_expr() {
|
||||||
@@ -496,8 +539,7 @@ impl Parser {
|
|||||||
};
|
};
|
||||||
row.push(first_element);
|
row.push(first_element);
|
||||||
let mut next_token = self.lexer.peek_token();
|
let mut next_token = self.lexer.peek_token();
|
||||||
// FIXME: this is not respecting the locale
|
while next_token == column_separator_token {
|
||||||
while next_token == TokenType::Comma {
|
|
||||||
self.lexer.advance_token();
|
self.lexer.advance_token();
|
||||||
let value = match self.parse_expr() {
|
let value = match self.parse_expr() {
|
||||||
Node::BooleanKind(s) => ArrayNode::Boolean(s),
|
Node::BooleanKind(s) => ArrayNode::Boolean(s),
|
||||||
@@ -555,6 +597,7 @@ impl Parser {
|
|||||||
TokenType::String(s) => Node::StringKind(s),
|
TokenType::String(s) => Node::StringKind(s),
|
||||||
TokenType::LeftBrace => {
|
TokenType::LeftBrace => {
|
||||||
// It's an array. It's a collection of rows all of the same dimension
|
// It's an array. It's a collection of rows all of the same dimension
|
||||||
|
let column_separator_token = self.get_column_separator_token();
|
||||||
|
|
||||||
let first_row = match self.parse_array_row() {
|
let first_row = match self.parse_array_row() {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
@@ -564,9 +607,8 @@ impl Parser {
|
|||||||
|
|
||||||
let mut matrix = Vec::new();
|
let mut matrix = Vec::new();
|
||||||
matrix.push(first_row);
|
matrix.push(first_row);
|
||||||
// FIXME: this is not respecting the locale
|
|
||||||
let mut next_token = self.lexer.peek_token();
|
let mut next_token = self.lexer.peek_token();
|
||||||
while next_token == TokenType::Semicolon {
|
while next_token == column_separator_token {
|
||||||
self.lexer.advance_token();
|
self.lexer.advance_token();
|
||||||
let row = match self.parse_array_row() {
|
let row = match self.parse_array_row() {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
@@ -715,12 +757,7 @@ impl Parser {
|
|||||||
message: err.message,
|
message: err.message,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if let Some(function_kind) = Function::get_function(&name) {
|
// We should do this *only* importing functions from xlsx
|
||||||
return Node::FunctionKind {
|
|
||||||
kind: function_kind,
|
|
||||||
args,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if &name == "_xlfn.SINGLE" {
|
if &name == "_xlfn.SINGLE" {
|
||||||
if args.len() != 1 {
|
if args.len() != 1 {
|
||||||
return Node::ParseErrorKind {
|
return Node::ParseErrorKind {
|
||||||
@@ -735,6 +772,17 @@ impl Parser {
|
|||||||
child: Box::new(args[0].clone()),
|
child: Box::new(args[0].clone()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// We should do this *only* importing functions from xlsx
|
||||||
|
if let Some(function_kind) = self
|
||||||
|
.language
|
||||||
|
.functions
|
||||||
|
.lookup(name.trim_start_matches("_xlfn."))
|
||||||
|
{
|
||||||
|
return Node::FunctionKind {
|
||||||
|
kind: function_kind,
|
||||||
|
args,
|
||||||
|
};
|
||||||
|
}
|
||||||
return Node::InvalidFunctionKind { name, args };
|
return Node::InvalidFunctionKind { name, args };
|
||||||
}
|
}
|
||||||
let context = &self.context;
|
let context = &self.context;
|
||||||
@@ -849,6 +897,7 @@ impl Parser {
|
|||||||
| TokenType::RightBracket
|
| TokenType::RightBracket
|
||||||
| TokenType::Colon
|
| TokenType::Colon
|
||||||
| TokenType::Semicolon
|
| TokenType::Semicolon
|
||||||
|
| TokenType::Backslash
|
||||||
| TokenType::RightBrace
|
| TokenType::RightBrace
|
||||||
| TokenType::Comma
|
| TokenType::Comma
|
||||||
| TokenType::Bang
|
| TokenType::Bang
|
||||||
@@ -1048,12 +1097,13 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_function_args(&mut self) -> Result<Vec<Node>, Node> {
|
fn parse_function_args(&mut self) -> Result<Vec<Node>, Node> {
|
||||||
|
let arg_separator_token = &self.get_argument_separator_token();
|
||||||
let mut args: Vec<Node> = Vec::new();
|
let mut args: Vec<Node> = Vec::new();
|
||||||
let mut next_token = self.lexer.peek_token();
|
let mut next_token = self.lexer.peek_token();
|
||||||
if next_token == TokenType::RightParenthesis {
|
if next_token == TokenType::RightParenthesis {
|
||||||
return Ok(args);
|
return Ok(args);
|
||||||
}
|
}
|
||||||
if self.lexer.peek_token() == TokenType::Comma {
|
if &self.lexer.peek_token() == arg_separator_token {
|
||||||
args.push(Node::EmptyArgKind);
|
args.push(Node::EmptyArgKind);
|
||||||
} else {
|
} else {
|
||||||
let t = self.parse_expr();
|
let t = self.parse_expr();
|
||||||
@@ -1063,11 +1113,11 @@ impl Parser {
|
|||||||
args.push(t);
|
args.push(t);
|
||||||
}
|
}
|
||||||
next_token = self.lexer.peek_token();
|
next_token = self.lexer.peek_token();
|
||||||
while next_token == TokenType::Comma {
|
while &next_token == arg_separator_token {
|
||||||
self.lexer.advance_token();
|
self.lexer.advance_token();
|
||||||
if self.lexer.peek_token() == TokenType::Comma {
|
if &self.lexer.peek_token() == arg_separator_token {
|
||||||
args.push(Node::EmptyArgKind);
|
args.push(Node::EmptyArgKind);
|
||||||
next_token = TokenType::Comma;
|
next_token = arg_separator_token.clone();
|
||||||
} else if self.lexer.peek_token() == TokenType::RightParenthesis {
|
} else if self.lexer.peek_token() == TokenType::RightParenthesis {
|
||||||
args.push(Node::EmptyArgKind);
|
args.push(Node::EmptyArgKind);
|
||||||
return Ok(args);
|
return Ok(args);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ use super::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
constants::{LAST_COLUMN, LAST_ROW},
|
constants::{LAST_COLUMN, LAST_ROW},
|
||||||
expressions::token::OpUnary,
|
expressions::token::OpUnary,
|
||||||
|
language::Language,
|
||||||
|
locale::Locale,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
expressions::types::{Area, CellReferenceRC},
|
expressions::types::{Area, CellReferenceRC},
|
||||||
@@ -38,38 +40,78 @@ pub(crate) struct MoveContext<'a> {
|
|||||||
/// We are moving a formula in (row, column) to (row+row_delta, column + column_delta).
|
/// We are moving a formula in (row, column) to (row+row_delta, column + column_delta).
|
||||||
/// All references that do not point to a cell in area will be left untouched.
|
/// All references that do not point to a cell in area will be left untouched.
|
||||||
/// All references that point to a cell in area will be displaced
|
/// All references that point to a cell in area will be displaced
|
||||||
pub(crate) fn move_formula(node: &Node, move_context: &MoveContext) -> String {
|
pub(crate) fn move_formula(
|
||||||
to_string_moved(node, move_context)
|
node: &Node,
|
||||||
|
move_context: &MoveContext,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
|
) -> String {
|
||||||
|
to_string_moved(node, move_context, locale, language)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_function(name: &str, args: &Vec<Node>, move_context: &MoveContext) -> String {
|
fn move_function(
|
||||||
|
name: &str,
|
||||||
|
args: &Vec<Node>,
|
||||||
|
move_context: &MoveContext,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
|
) -> String {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
let mut arguments = "".to_string();
|
let mut arguments = "".to_string();
|
||||||
for el in args {
|
for el in args {
|
||||||
if !first {
|
if !first {
|
||||||
arguments = format!("{},{}", arguments, to_string_moved(el, move_context));
|
arguments = format!(
|
||||||
|
"{},{}",
|
||||||
|
arguments,
|
||||||
|
to_string_moved(el, move_context, locale, language)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
arguments = to_string_moved(el, move_context);
|
arguments = to_string_moved(el, move_context, locale, language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
format!("{name}({arguments})")
|
format!("{name}({arguments})")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn to_string_array_node(node: &ArrayNode) -> String {
|
fn format_number_locale(number: f64, locale: &Locale) -> String {
|
||||||
|
let s = to_excel_precision_str(number);
|
||||||
|
let decimal = &locale.numbers.symbols.decimal;
|
||||||
|
if decimal == "." {
|
||||||
|
s
|
||||||
|
} else {
|
||||||
|
s.replace('.', decimal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn to_string_array_node(
|
||||||
|
node: &ArrayNode,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
|
) -> String {
|
||||||
match node {
|
match node {
|
||||||
ArrayNode::Boolean(value) => format!("{value}").to_ascii_uppercase(),
|
ArrayNode::Boolean(value) => {
|
||||||
ArrayNode::Number(number) => to_excel_precision_str(*number),
|
if *value {
|
||||||
|
language.booleans.r#true.to_ascii_uppercase()
|
||||||
|
} else {
|
||||||
|
language.booleans.r#false.to_ascii_uppercase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrayNode::Number(number) => format_number_locale(*number, locale),
|
||||||
ArrayNode::String(value) => format!("\"{value}\""),
|
ArrayNode::String(value) => format!("\"{value}\""),
|
||||||
ArrayNode::Error(kind) => format!("{kind}"),
|
ArrayNode::Error(kind) => format!("{kind}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
fn to_string_moved(
|
||||||
|
node: &Node,
|
||||||
|
move_context: &MoveContext,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
|
) -> String {
|
||||||
use self::Node::*;
|
use self::Node::*;
|
||||||
match node {
|
match node {
|
||||||
BooleanKind(value) => format!("{value}").to_ascii_uppercase(),
|
BooleanKind(value) => format!("{value}").to_ascii_uppercase(),
|
||||||
NumberKind(number) => to_excel_precision_str(*number),
|
NumberKind(number) => format_number_locale(*number, locale),
|
||||||
StringKind(value) => format!("\"{value}\""),
|
StringKind(value) => format!("\"{value}\""),
|
||||||
ReferenceKind {
|
ReferenceKind {
|
||||||
sheet_name,
|
sheet_name,
|
||||||
@@ -329,55 +371,81 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
|||||||
}
|
}
|
||||||
OpRangeKind { left, right } => format!(
|
OpRangeKind { left, right } => format!(
|
||||||
"{}:{}",
|
"{}:{}",
|
||||||
to_string_moved(left, move_context),
|
to_string_moved(left, move_context, locale, language),
|
||||||
to_string_moved(right, move_context),
|
to_string_moved(right, move_context, locale, language),
|
||||||
),
|
),
|
||||||
OpConcatenateKind { left, right } => format!(
|
OpConcatenateKind { left, right } => format!(
|
||||||
"{}&{}",
|
"{}&{}",
|
||||||
to_string_moved(left, move_context),
|
to_string_moved(left, move_context, locale, language),
|
||||||
to_string_moved(right, move_context),
|
to_string_moved(right, move_context, locale, language),
|
||||||
),
|
),
|
||||||
OpSumKind { kind, left, right } => format!(
|
OpSumKind { kind, left, right } => format!(
|
||||||
"{}{}{}",
|
"{}{}{}",
|
||||||
to_string_moved(left, move_context),
|
to_string_moved(left, move_context, locale, language),
|
||||||
kind,
|
kind,
|
||||||
to_string_moved(right, move_context),
|
to_string_moved(right, move_context, locale, language),
|
||||||
),
|
),
|
||||||
OpProductKind { kind, left, right } => {
|
OpProductKind { kind, left, right } => {
|
||||||
let x = match **left {
|
let x = match **left {
|
||||||
OpSumKind { .. } => format!("({})", to_string_moved(left, move_context)),
|
OpSumKind { .. } => format!(
|
||||||
CompareKind { .. } => format!("({})", to_string_moved(left, move_context)),
|
"({})",
|
||||||
_ => to_string_moved(left, move_context),
|
to_string_moved(left, move_context, locale, language)
|
||||||
|
),
|
||||||
|
CompareKind { .. } => format!(
|
||||||
|
"({})",
|
||||||
|
to_string_moved(left, move_context, locale, language)
|
||||||
|
),
|
||||||
|
_ => to_string_moved(left, move_context, locale, language),
|
||||||
};
|
};
|
||||||
let y = match **right {
|
let y = match **right {
|
||||||
OpSumKind { .. } => format!("({})", to_string_moved(right, move_context)),
|
OpSumKind { .. } => format!(
|
||||||
CompareKind { .. } => format!("({})", to_string_moved(right, move_context)),
|
"({})",
|
||||||
OpProductKind { .. } => format!("({})", to_string_moved(right, move_context)),
|
to_string_moved(right, move_context, locale, language)
|
||||||
|
),
|
||||||
|
CompareKind { .. } => format!(
|
||||||
|
"({})",
|
||||||
|
to_string_moved(right, move_context, locale, language)
|
||||||
|
),
|
||||||
|
OpProductKind { .. } => format!(
|
||||||
|
"({})",
|
||||||
|
to_string_moved(right, move_context, locale, language)
|
||||||
|
),
|
||||||
UnaryKind { .. } => {
|
UnaryKind { .. } => {
|
||||||
format!("({})", to_string_moved(right, move_context))
|
format!(
|
||||||
|
"({})",
|
||||||
|
to_string_moved(right, move_context, locale, language)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
_ => to_string_moved(right, move_context),
|
_ => to_string_moved(right, move_context, locale, language),
|
||||||
};
|
};
|
||||||
format!("{x}{kind}{y}")
|
format!("{x}{kind}{y}")
|
||||||
}
|
}
|
||||||
OpPowerKind { left, right } => format!(
|
OpPowerKind { left, right } => format!(
|
||||||
"{}^{}",
|
"{}^{}",
|
||||||
to_string_moved(left, move_context),
|
to_string_moved(left, move_context, locale, language),
|
||||||
to_string_moved(right, move_context),
|
to_string_moved(right, move_context, locale, language),
|
||||||
),
|
),
|
||||||
InvalidFunctionKind { name, args } => move_function(name, args, move_context),
|
InvalidFunctionKind { name, args } => {
|
||||||
|
move_function(name, args, move_context, locale, language)
|
||||||
|
}
|
||||||
FunctionKind { kind, args } => {
|
FunctionKind { kind, args } => {
|
||||||
let name = &kind.to_string();
|
let name = &kind.to_localized_name(language);
|
||||||
move_function(name, args, move_context)
|
move_function(name, args, move_context, locale, language)
|
||||||
}
|
}
|
||||||
ArrayKind(args) => {
|
ArrayKind(args) => {
|
||||||
let mut first_row = true;
|
let mut first_row = true;
|
||||||
let mut matrix_string = String::new();
|
let mut matrix_string = String::new();
|
||||||
|
|
||||||
// Each element in `args` is assumed to be one "row" (itself a `Vec<T>`).
|
// Each element in `args` is assumed to be one "row" (itself a `Vec<T>`).
|
||||||
|
let row_separator = if locale.numbers.symbols.decimal == "." {
|
||||||
|
';'
|
||||||
|
} else {
|
||||||
|
'/'
|
||||||
|
};
|
||||||
|
let col_separator = if row_separator == ';' { ',' } else { ';' };
|
||||||
for row in args {
|
for row in args {
|
||||||
if !first_row {
|
if !first_row {
|
||||||
matrix_string.push(',');
|
matrix_string.push(col_separator);
|
||||||
} else {
|
} else {
|
||||||
first_row = false;
|
first_row = false;
|
||||||
}
|
}
|
||||||
@@ -387,13 +455,13 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
|||||||
let mut row_string = String::new();
|
let mut row_string = String::new();
|
||||||
for el in row {
|
for el in row {
|
||||||
if !first_col {
|
if !first_col {
|
||||||
row_string.push(',');
|
row_string.push(row_separator);
|
||||||
} else {
|
} else {
|
||||||
first_col = false;
|
first_col = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reuse your existing element-stringification function
|
// Reuse your existing element-stringification function
|
||||||
row_string.push_str(&to_string_array_node(el));
|
row_string.push_str(&to_string_array_node(el, locale, language));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enclose the row in braces
|
// Enclose the row in braces
|
||||||
@@ -410,13 +478,19 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
|||||||
WrongVariableKind(name) => name.to_string(),
|
WrongVariableKind(name) => name.to_string(),
|
||||||
CompareKind { kind, left, right } => format!(
|
CompareKind { kind, left, right } => format!(
|
||||||
"{}{}{}",
|
"{}{}{}",
|
||||||
to_string_moved(left, move_context),
|
to_string_moved(left, move_context, locale, language),
|
||||||
kind,
|
kind,
|
||||||
to_string_moved(right, move_context),
|
to_string_moved(right, move_context, locale, language),
|
||||||
),
|
),
|
||||||
UnaryKind { kind, right } => match kind {
|
UnaryKind { kind, right } => match kind {
|
||||||
OpUnary::Minus => format!("-{}", to_string_moved(right, move_context)),
|
OpUnary::Minus => format!(
|
||||||
OpUnary::Percentage => format!("{}%", to_string_moved(right, move_context)),
|
"-{}",
|
||||||
|
to_string_moved(right, move_context, locale, language)
|
||||||
|
),
|
||||||
|
OpUnary::Percentage => format!(
|
||||||
|
"{}%",
|
||||||
|
to_string_moved(right, move_context, locale, language)
|
||||||
|
),
|
||||||
},
|
},
|
||||||
ErrorKind(kind) => format!("{kind}"),
|
ErrorKind(kind) => format!("{kind}"),
|
||||||
ParseErrorKind {
|
ParseErrorKind {
|
||||||
@@ -429,7 +503,10 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
|||||||
automatic: _,
|
automatic: _,
|
||||||
child,
|
child,
|
||||||
} => {
|
} => {
|
||||||
format!("@{}", to_string_moved(child, move_context))
|
format!(
|
||||||
|
"@{}",
|
||||||
|
to_string_moved(child, move_context, locale, language)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ use crate::constants::{LAST_COLUMN, LAST_ROW};
|
|||||||
use crate::expressions::parser::move_formula::to_string_array_node;
|
use crate::expressions::parser::move_formula::to_string_array_node;
|
||||||
use crate::expressions::parser::static_analysis::add_implicit_intersection;
|
use crate::expressions::parser::static_analysis::add_implicit_intersection;
|
||||||
use crate::expressions::token::{OpSum, OpUnary};
|
use crate::expressions::token::{OpSum, OpUnary};
|
||||||
|
use crate::language::{get_language, Language};
|
||||||
|
use crate::locale::{get_locale, Locale};
|
||||||
use crate::{expressions::types::CellReferenceRC, number_format::to_excel_precision_str};
|
use crate::{expressions::types::CellReferenceRC, number_format::to_excel_precision_str};
|
||||||
|
|
||||||
pub enum DisplaceData {
|
pub enum DisplaceData {
|
||||||
@@ -43,17 +45,44 @@ pub enum DisplaceData {
|
|||||||
|
|
||||||
/// This is the internal mode in IronCalc
|
/// This is the internal mode in IronCalc
|
||||||
pub fn to_rc_format(node: &Node) -> String {
|
pub fn to_rc_format(node: &Node) -> String {
|
||||||
stringify(node, None, &DisplaceData::None, false)
|
#[allow(clippy::expect_used)]
|
||||||
|
let locale = get_locale("en").expect("");
|
||||||
|
#[allow(clippy::expect_used)]
|
||||||
|
let language = get_language("en").expect("");
|
||||||
|
stringify(node, None, &DisplaceData::None, false, locale, language)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the mode used to display the formula in the UI
|
/// This is the mode used to display the formula in the UI
|
||||||
pub fn to_string(node: &Node, context: &CellReferenceRC) -> String {
|
pub fn to_localized_string(
|
||||||
stringify(node, Some(context), &DisplaceData::None, false)
|
node: &Node,
|
||||||
|
context: &CellReferenceRC,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
|
) -> String {
|
||||||
|
stringify(
|
||||||
|
node,
|
||||||
|
Some(context),
|
||||||
|
&DisplaceData::None,
|
||||||
|
false,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the mode used to export the formula to Excel
|
/// This is the mode used to export the formula to Excel
|
||||||
pub fn to_excel_string(node: &Node, context: &CellReferenceRC) -> String {
|
pub fn to_excel_string(node: &Node, context: &CellReferenceRC) -> String {
|
||||||
stringify(node, Some(context), &DisplaceData::None, true)
|
#[allow(clippy::expect_used)]
|
||||||
|
let locale = get_locale("en").expect("");
|
||||||
|
#[allow(clippy::expect_used)]
|
||||||
|
let language = get_language("en").expect("");
|
||||||
|
stringify(
|
||||||
|
node,
|
||||||
|
Some(context),
|
||||||
|
&DisplaceData::None,
|
||||||
|
true,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_string_displaced(
|
pub fn to_string_displaced(
|
||||||
@@ -61,7 +90,11 @@ pub fn to_string_displaced(
|
|||||||
context: &CellReferenceRC,
|
context: &CellReferenceRC,
|
||||||
displace_data: &DisplaceData,
|
displace_data: &DisplaceData,
|
||||||
) -> String {
|
) -> String {
|
||||||
stringify(node, Some(context), displace_data, false)
|
#[allow(clippy::expect_used)]
|
||||||
|
let locale = get_locale("en").expect("");
|
||||||
|
#[allow(clippy::expect_used)]
|
||||||
|
let language = get_language("en").expect("");
|
||||||
|
stringify(node, Some(context), displace_data, false, locale, language)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a local reference to a string applying some displacement if needed.
|
/// Converts a local reference to a string applying some displacement if needed.
|
||||||
@@ -273,19 +306,41 @@ fn format_function(
|
|||||||
context: Option<&CellReferenceRC>,
|
context: Option<&CellReferenceRC>,
|
||||||
displace_data: &DisplaceData,
|
displace_data: &DisplaceData,
|
||||||
export_to_excel: bool,
|
export_to_excel: bool,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
) -> String {
|
) -> String {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
let mut arguments = "".to_string();
|
let mut arguments = "".to_string();
|
||||||
|
let arg_separator = if locale.numbers.symbols.decimal == "." {
|
||||||
|
','
|
||||||
|
} else {
|
||||||
|
';'
|
||||||
|
};
|
||||||
for el in args {
|
for el in args {
|
||||||
if !first {
|
if !first {
|
||||||
arguments = format!(
|
arguments = format!(
|
||||||
"{},{}",
|
"{}{}{}",
|
||||||
arguments,
|
arguments,
|
||||||
stringify(el, context, displace_data, export_to_excel)
|
arg_separator,
|
||||||
|
stringify(
|
||||||
|
el,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
arguments = stringify(el, context, displace_data, export_to_excel);
|
arguments = stringify(
|
||||||
|
el,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
format!("{name}({arguments})")
|
format!("{name}({arguments})")
|
||||||
@@ -321,11 +376,26 @@ fn stringify(
|
|||||||
context: Option<&CellReferenceRC>,
|
context: Option<&CellReferenceRC>,
|
||||||
displace_data: &DisplaceData,
|
displace_data: &DisplaceData,
|
||||||
export_to_excel: bool,
|
export_to_excel: bool,
|
||||||
|
locale: &Locale,
|
||||||
|
language: &Language,
|
||||||
) -> String {
|
) -> String {
|
||||||
use self::Node::*;
|
use self::Node::*;
|
||||||
match node {
|
match node {
|
||||||
BooleanKind(value) => format!("{value}").to_ascii_uppercase(),
|
BooleanKind(value) => {
|
||||||
NumberKind(number) => to_excel_precision_str(*number),
|
if *value {
|
||||||
|
language.booleans.r#true.to_string()
|
||||||
|
} else {
|
||||||
|
language.booleans.r#false.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NumberKind(number) => {
|
||||||
|
let s = to_excel_precision_str(*number);
|
||||||
|
if locale.numbers.symbols.decimal == "." {
|
||||||
|
s
|
||||||
|
} else {
|
||||||
|
s.replace(".", &locale.numbers.symbols.decimal)
|
||||||
|
}
|
||||||
|
}
|
||||||
StringKind(value) => format!("\"{value}\""),
|
StringKind(value) => format!("\"{value}\""),
|
||||||
WrongReferenceKind {
|
WrongReferenceKind {
|
||||||
sheet_name,
|
sheet_name,
|
||||||
@@ -469,32 +539,95 @@ fn stringify(
|
|||||||
}
|
}
|
||||||
OpRangeKind { left, right } => format!(
|
OpRangeKind { left, right } => format!(
|
||||||
"{}:{}",
|
"{}:{}",
|
||||||
stringify(left, context, displace_data, export_to_excel),
|
stringify(
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
),
|
||||||
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
),
|
),
|
||||||
OpConcatenateKind { left, right } => format!(
|
OpConcatenateKind { left, right } => format!(
|
||||||
"{}&{}",
|
"{}&{}",
|
||||||
stringify(left, context, displace_data, export_to_excel),
|
stringify(
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
),
|
||||||
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
),
|
),
|
||||||
CompareKind { kind, left, right } => format!(
|
CompareKind { kind, left, right } => format!(
|
||||||
"{}{}{}",
|
"{}{}{}",
|
||||||
stringify(left, context, displace_data, export_to_excel),
|
stringify(
|
||||||
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
),
|
||||||
kind,
|
kind,
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
),
|
),
|
||||||
OpSumKind { kind, left, right } => {
|
OpSumKind { kind, left, right } => {
|
||||||
let left_str = stringify(left, context, displace_data, export_to_excel);
|
let left_str = stringify(
|
||||||
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
);
|
||||||
// if kind is minus then we need parentheses in the right side if they are OpSumKind or CompareKind
|
// if kind is minus then we need parentheses in the right side if they are OpSumKind or CompareKind
|
||||||
let right_str = if (matches!(kind, OpSum::Minus) && matches!(**right, OpSumKind { .. }))
|
let right_str = if (matches!(kind, OpSum::Minus) && matches!(**right, OpSumKind { .. }))
|
||||||
| matches!(**right, CompareKind { .. })
|
| matches!(**right, CompareKind { .. })
|
||||||
{
|
{
|
||||||
format!(
|
format!(
|
||||||
"({})",
|
"({})",
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
format!("{left_str}{kind}{right_str}")
|
format!("{left_str}{kind}{right_str}")
|
||||||
@@ -503,16 +636,44 @@ fn stringify(
|
|||||||
let x = match **left {
|
let x = match **left {
|
||||||
OpSumKind { .. } | CompareKind { .. } => format!(
|
OpSumKind { .. } | CompareKind { .. } => format!(
|
||||||
"({})",
|
"({})",
|
||||||
stringify(left, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
|
),
|
||||||
|
_ => stringify(
|
||||||
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
),
|
),
|
||||||
_ => stringify(left, context, displace_data, export_to_excel),
|
|
||||||
};
|
};
|
||||||
let y = match **right {
|
let y = match **right {
|
||||||
OpSumKind { .. } | CompareKind { .. } | OpProductKind { .. } => format!(
|
OpSumKind { .. } | CompareKind { .. } | OpProductKind { .. } => format!(
|
||||||
"({})",
|
"({})",
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
|
),
|
||||||
|
_ => stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
),
|
),
|
||||||
_ => stringify(right, context, displace_data, export_to_excel),
|
|
||||||
};
|
};
|
||||||
format!("{x}{kind}{y}")
|
format!("{x}{kind}{y}")
|
||||||
}
|
}
|
||||||
@@ -528,7 +689,14 @@ fn stringify(
|
|||||||
| DefinedNameKind(_)
|
| DefinedNameKind(_)
|
||||||
| TableNameKind(_)
|
| TableNameKind(_)
|
||||||
| WrongVariableKind(_)
|
| WrongVariableKind(_)
|
||||||
| WrongRangeKind { .. } => stringify(left, context, displace_data, export_to_excel),
|
| WrongRangeKind { .. } => stringify(
|
||||||
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
),
|
||||||
OpRangeKind { .. }
|
OpRangeKind { .. }
|
||||||
| OpConcatenateKind { .. }
|
| OpConcatenateKind { .. }
|
||||||
| OpProductKind { .. }
|
| OpProductKind { .. }
|
||||||
@@ -543,7 +711,14 @@ fn stringify(
|
|||||||
| ImplicitIntersection { .. }
|
| ImplicitIntersection { .. }
|
||||||
| EmptyArgKind => format!(
|
| EmptyArgKind => format!(
|
||||||
"({})",
|
"({})",
|
||||||
stringify(left, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
left,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
let y = match **right {
|
let y = match **right {
|
||||||
@@ -556,9 +731,14 @@ fn stringify(
|
|||||||
| DefinedNameKind(_)
|
| DefinedNameKind(_)
|
||||||
| TableNameKind(_)
|
| TableNameKind(_)
|
||||||
| WrongVariableKind(_)
|
| WrongVariableKind(_)
|
||||||
| WrongRangeKind { .. } => {
|
| WrongRangeKind { .. } => stringify(
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
right,
|
||||||
}
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
),
|
||||||
OpRangeKind { .. }
|
OpRangeKind { .. }
|
||||||
| OpConcatenateKind { .. }
|
| OpConcatenateKind { .. }
|
||||||
| OpProductKind { .. }
|
| OpProductKind { .. }
|
||||||
@@ -574,29 +754,56 @@ fn stringify(
|
|||||||
| ImplicitIntersection { .. }
|
| ImplicitIntersection { .. }
|
||||||
| EmptyArgKind => format!(
|
| EmptyArgKind => format!(
|
||||||
"({})",
|
"({})",
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
format!("{x}^{y}")
|
format!("{x}^{y}")
|
||||||
}
|
}
|
||||||
InvalidFunctionKind { name, args } => {
|
InvalidFunctionKind { name, args } => format_function(
|
||||||
format_function(name, args, context, displace_data, export_to_excel)
|
&name.to_ascii_lowercase(),
|
||||||
}
|
args,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
),
|
||||||
FunctionKind { kind, args } => {
|
FunctionKind { kind, args } => {
|
||||||
let name = if export_to_excel {
|
let name = if export_to_excel {
|
||||||
kind.to_xlsx_string()
|
kind.to_xlsx_string()
|
||||||
} else {
|
} else {
|
||||||
kind.to_string()
|
kind.to_localized_name(language)
|
||||||
};
|
};
|
||||||
format_function(&name, args, context, displace_data, export_to_excel)
|
format_function(
|
||||||
|
&name,
|
||||||
|
args,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ArrayKind(args) => {
|
ArrayKind(args) => {
|
||||||
let mut first_row = true;
|
let mut first_row = true;
|
||||||
let mut matrix_string = String::new();
|
let mut matrix_string = String::new();
|
||||||
|
let row_separator = if locale.numbers.symbols.decimal == "." {
|
||||||
|
';'
|
||||||
|
} else {
|
||||||
|
'/'
|
||||||
|
};
|
||||||
|
let col_separator = if row_separator == ';' { ',' } else { ';' };
|
||||||
|
|
||||||
for row in args {
|
for row in args {
|
||||||
if !first_row {
|
if !first_row {
|
||||||
matrix_string.push(';');
|
matrix_string.push(row_separator);
|
||||||
} else {
|
} else {
|
||||||
first_row = false;
|
first_row = false;
|
||||||
}
|
}
|
||||||
@@ -604,11 +811,11 @@ fn stringify(
|
|||||||
let mut row_string = String::new();
|
let mut row_string = String::new();
|
||||||
for el in row {
|
for el in row {
|
||||||
if !first_column {
|
if !first_column {
|
||||||
row_string.push(',');
|
row_string.push(col_separator);
|
||||||
} else {
|
} else {
|
||||||
first_column = false;
|
first_column = false;
|
||||||
}
|
}
|
||||||
row_string.push_str(&to_string_array_node(el));
|
row_string.push_str(&to_string_array_node(el, locale, language));
|
||||||
}
|
}
|
||||||
matrix_string.push_str(&row_string);
|
matrix_string.push_str(&row_string);
|
||||||
}
|
}
|
||||||
@@ -647,19 +854,40 @@ fn stringify(
|
|||||||
if needs_parentheses {
|
if needs_parentheses {
|
||||||
format!(
|
format!(
|
||||||
"-({})",
|
"-({})",
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
"-{}",
|
"-{}",
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OpUnary::Percentage => {
|
OpUnary::Percentage => {
|
||||||
format!(
|
format!(
|
||||||
"{}%",
|
"{}%",
|
||||||
stringify(right, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
right,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -680,17 +908,38 @@ fn stringify(
|
|||||||
|
|
||||||
add_implicit_intersection(&mut new_node, true);
|
add_implicit_intersection(&mut new_node, true);
|
||||||
if matches!(&new_node, Node::ImplicitIntersection { .. }) {
|
if matches!(&new_node, Node::ImplicitIntersection { .. }) {
|
||||||
return stringify(child, context, displace_data, export_to_excel);
|
return stringify(
|
||||||
|
child,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return format!(
|
return format!(
|
||||||
"_xlfn.SINGLE({})",
|
"_xlfn.SINGLE({})",
|
||||||
stringify(child, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
child,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
format!(
|
format!(
|
||||||
"@{}",
|
"@{}",
|
||||||
stringify(child, context, displace_data, export_to_excel)
|
stringify(
|
||||||
|
child,
|
||||||
|
context,
|
||||||
|
displace_data,
|
||||||
|
export_to_excel,
|
||||||
|
locale,
|
||||||
|
language
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ mod test_general;
|
|||||||
mod test_implicit_intersection;
|
mod test_implicit_intersection;
|
||||||
mod test_issue_155;
|
mod test_issue_155;
|
||||||
mod test_issue_483;
|
mod test_issue_483;
|
||||||
|
mod test_languages;
|
||||||
|
mod test_locales;
|
||||||
mod test_move_formula;
|
mod test_move_formula;
|
||||||
mod test_ranges;
|
mod test_ranges;
|
||||||
mod test_stringify;
|
mod test_stringify;
|
||||||
mod test_tables;
|
mod test_tables;
|
||||||
|
mod utils;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::expressions::{
|
use crate::expressions::{
|
||||||
parser::{
|
parser::{
|
||||||
stringify::{to_excel_string, to_string},
|
stringify::to_excel_string,
|
||||||
Parser,
|
tests::utils::{new_parser, to_english_localized_string},
|
||||||
},
|
},
|
||||||
types::CellReferenceRC,
|
types::CellReferenceRC,
|
||||||
};
|
};
|
||||||
@@ -13,7 +13,7 @@ use crate::expressions::parser::static_analysis::add_implicit_intersection;
|
|||||||
#[test]
|
#[test]
|
||||||
fn simple_test() {
|
fn simple_test() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -72,7 +72,7 @@ fn simple_test() {
|
|||||||
for (formula, expected) in cases {
|
for (formula, expected) in cases {
|
||||||
let mut t = parser.parse(formula, &cell_reference);
|
let mut t = parser.parse(formula, &cell_reference);
|
||||||
add_implicit_intersection(&mut t, true);
|
add_implicit_intersection(&mut t, true);
|
||||||
let r = to_string(&t, &cell_reference);
|
let r = to_english_localized_string(&t, &cell_reference);
|
||||||
assert_eq!(r, expected);
|
assert_eq!(r, expected);
|
||||||
let excel_formula = to_excel_string(&t, &cell_reference);
|
let excel_formula = to_excel_string(&t, &cell_reference);
|
||||||
assert_eq!(excel_formula, formula);
|
assert_eq!(excel_formula, formula);
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::expressions::parser::stringify::{to_rc_format, to_string};
|
use crate::expressions::parser::stringify::to_rc_format;
|
||||||
use crate::expressions::parser::{ArrayNode, Node, Parser};
|
use crate::expressions::parser::tests::utils::{new_parser, to_english_localized_string};
|
||||||
|
use crate::expressions::parser::{ArrayNode, Node};
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_horizontal() {
|
fn simple_horizontal() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -28,13 +29,16 @@ fn simple_horizontal() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(to_rc_format(&horizontal), "{1,2,3}");
|
assert_eq!(to_rc_format(&horizontal), "{1,2,3}");
|
||||||
assert_eq!(to_string(&horizontal, &cell_reference), "{1,2,3}");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&horizontal, &cell_reference),
|
||||||
|
"{1,2,3}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_vertical() {
|
fn simple_vertical() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -52,13 +56,16 @@ fn simple_vertical() {
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
assert_eq!(to_rc_format(&vertical), "{1;2;3}");
|
assert_eq!(to_rc_format(&vertical), "{1;2;3}");
|
||||||
assert_eq!(to_string(&vertical, &cell_reference), "{1;2;3}");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&vertical, &cell_reference),
|
||||||
|
"{1;2;3}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_matrix() {
|
fn simple_matrix() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -88,5 +95,8 @@ fn simple_matrix() {
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
assert_eq!(to_rc_format(&matrix), "{1,2,3;4,5,6;7,8,9}");
|
assert_eq!(to_rc_format(&matrix), "{1,2,3;4,5,6;7,8,9}");
|
||||||
assert_eq!(to_string(&matrix, &cell_reference), "{1,2,3;4,5,6;7,8,9}");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&matrix, &cell_reference),
|
||||||
|
"{1,2,3;4,5,6;7,8,9}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::expressions::lexer::LexerMode;
|
use crate::expressions::lexer::LexerMode;
|
||||||
use crate::expressions::parser::stringify::{
|
use crate::expressions::parser::stringify::{to_rc_format, to_string_displaced, DisplaceData};
|
||||||
to_rc_format, to_string, to_string_displaced, DisplaceData,
|
use crate::expressions::parser::Node;
|
||||||
};
|
|
||||||
use crate::expressions::parser::{Node, Parser};
|
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
|
|
||||||
|
use crate::expressions::parser::tests::utils::{new_parser, to_english_localized_string};
|
||||||
|
|
||||||
struct Formula<'a> {
|
struct Formula<'a> {
|
||||||
initial: &'a str,
|
initial: &'a str,
|
||||||
expected: &'a str,
|
expected: &'a str,
|
||||||
@@ -17,7 +17,7 @@ struct Formula<'a> {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_reference() {
|
fn test_parser_reference() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -32,7 +32,7 @@ fn test_parser_reference() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_absolute_column() {
|
fn test_parser_absolute_column() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -47,7 +47,7 @@ fn test_parser_absolute_column() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_absolute_row_col() {
|
fn test_parser_absolute_row_col() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -62,7 +62,7 @@ fn test_parser_absolute_row_col() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_absolute_row_col_1() {
|
fn test_parser_absolute_row_col_1() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -77,7 +77,7 @@ fn test_parser_absolute_row_col_1() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_simple_formula() {
|
fn test_parser_simple_formula() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -93,7 +93,7 @@ fn test_parser_simple_formula() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_boolean() {
|
fn test_parser_boolean() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -109,7 +109,7 @@ fn test_parser_boolean() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_bad_formula() {
|
fn test_parser_bad_formula() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -138,7 +138,7 @@ fn test_parser_bad_formula() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_bad_formula_1() {
|
fn test_parser_bad_formula_1() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -167,7 +167,7 @@ fn test_parser_bad_formula_1() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_bad_formula_2() {
|
fn test_parser_bad_formula_2() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -196,7 +196,7 @@ fn test_parser_bad_formula_2() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_bad_formula_3() {
|
fn test_parser_bad_formula_3() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -225,7 +225,7 @@ fn test_parser_bad_formula_3() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_formulas() {
|
fn test_parser_formulas() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let formulas = vec![
|
let formulas = vec![
|
||||||
Formula {
|
Formula {
|
||||||
@@ -266,14 +266,17 @@ fn test_parser_formulas() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(to_rc_format(&t), formula.expected);
|
assert_eq!(to_rc_format(&t), formula.expected);
|
||||||
assert_eq!(to_string(&t, &cell_reference), formula.initial);
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
formula.initial
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parser_r1c1_formulas() {
|
fn test_parser_r1c1_formulas() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
parser.set_lexer_mode(LexerMode::R1C1);
|
parser.set_lexer_mode(LexerMode::R1C1);
|
||||||
|
|
||||||
let formulas = vec![
|
let formulas = vec![
|
||||||
@@ -330,7 +333,10 @@ fn test_parser_r1c1_formulas() {
|
|||||||
column: 1,
|
column: 1,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(to_string(&t, &cell_reference), formula.expected);
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
formula.expected
|
||||||
|
);
|
||||||
assert_eq!(to_rc_format(&t), formula.initial);
|
assert_eq!(to_rc_format(&t), formula.initial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +344,7 @@ fn test_parser_r1c1_formulas() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_quotes() {
|
fn test_parser_quotes() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Second Sheet".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Second Sheet".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -354,7 +360,7 @@ fn test_parser_quotes() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_escape_quotes() {
|
fn test_parser_escape_quotes() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Second '2' Sheet".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Second '2' Sheet".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -370,7 +376,7 @@ fn test_parser_escape_quotes() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_parenthesis() {
|
fn test_parser_parenthesis() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Second2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Second2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -386,7 +392,7 @@ fn test_parser_parenthesis() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_excel_xlfn() {
|
fn test_parser_excel_xlfn() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Second2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Second2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -407,7 +413,7 @@ fn test_to_string_displaced() {
|
|||||||
column: 1,
|
column: 1,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let node = parser.parse("C3", context);
|
let node = parser.parse("C3", context);
|
||||||
let displace_data = DisplaceData::Column {
|
let displace_data = DisplaceData::Column {
|
||||||
@@ -427,7 +433,7 @@ fn test_to_string_displaced_full_ranges() {
|
|||||||
column: 1,
|
column: 1,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let node = parser.parse("SUM(3:3)", context);
|
let node = parser.parse("SUM(3:3)", context);
|
||||||
let displace_data = DisplaceData::Column {
|
let displace_data = DisplaceData::Column {
|
||||||
@@ -460,7 +466,7 @@ fn test_to_string_displaced_too_low() {
|
|||||||
column: 1,
|
column: 1,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let node = parser.parse("C3", context);
|
let node = parser.parse("C3", context);
|
||||||
let displace_data = DisplaceData::Column {
|
let displace_data = DisplaceData::Column {
|
||||||
@@ -480,7 +486,7 @@ fn test_to_string_displaced_too_high() {
|
|||||||
column: 1,
|
column: 1,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let node = parser.parse("C3", context);
|
let node = parser.parse("C3", context);
|
||||||
let displace_data = DisplaceData::Column {
|
let displace_data = DisplaceData::Column {
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
#![allow(clippy::panic)]
|
#![allow(clippy::panic)]
|
||||||
|
|
||||||
use crate::expressions::parser::{Node, Parser};
|
use crate::expressions::parser::Node;
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use crate::expressions::parser::tests::utils::new_parser;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple() {
|
fn simple() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!B3
|
// Reference cell is Sheet1!B3
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -40,7 +42,7 @@ fn simple() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn simple_add() {
|
fn simple_add() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!B3
|
// Reference cell is Sheet1!B3
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::expressions::parser::stringify::to_string;
|
use crate::expressions::parser::tests::utils::{new_parser, to_english_localized_string};
|
||||||
use crate::expressions::parser::Parser;
|
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_155_parser() {
|
fn issue_155_parser() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -18,13 +17,13 @@ fn issue_155_parser() {
|
|||||||
column: 2,
|
column: 2,
|
||||||
};
|
};
|
||||||
let t = parser.parse("A$1:A2", &cell_reference);
|
let t = parser.parse("A$1:A2", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "A$1:A2");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "A$1:A2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_155_parser_case_2() {
|
fn issue_155_parser_case_2() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -33,13 +32,13 @@ fn issue_155_parser_case_2() {
|
|||||||
column: 20,
|
column: 20,
|
||||||
};
|
};
|
||||||
let t = parser.parse("C$1:D2", &cell_reference);
|
let t = parser.parse("C$1:D2", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "C$1:D2");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "C$1:D2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_155_parser_only_row() {
|
fn issue_155_parser_only_row() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -49,13 +48,13 @@ fn issue_155_parser_only_row() {
|
|||||||
};
|
};
|
||||||
// This is tricky, I am not sure what to do in these cases
|
// This is tricky, I am not sure what to do in these cases
|
||||||
let t = parser.parse("A$2:B1", &cell_reference);
|
let t = parser.parse("A$2:B1", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "A1:B$2");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "A1:B$2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_155_parser_only_column() {
|
fn issue_155_parser_only_column() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -65,5 +64,5 @@ fn issue_155_parser_only_column() {
|
|||||||
};
|
};
|
||||||
// This is tricky, I am not sure what to do in these cases
|
// This is tricky, I am not sure what to do in these cases
|
||||||
let t = parser.parse("D1:$A3", &cell_reference);
|
let t = parser.parse("D1:$A3", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "$A1:D3");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "$A1:D3");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::expressions::parser::stringify::to_string;
|
use crate::expressions::parser::tests::utils::{new_parser, to_english_localized_string};
|
||||||
use crate::expressions::parser::{Node, Parser};
|
use crate::expressions::parser::Node;
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_483_parser() {
|
fn issue_483_parser() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -19,9 +19,12 @@ fn issue_483_parser() {
|
|||||||
};
|
};
|
||||||
let t = parser.parse("-(A1^1.22)", &cell_reference);
|
let t = parser.parse("-(A1^1.22)", &cell_reference);
|
||||||
assert!(matches!(t, Node::UnaryKind { .. }));
|
assert!(matches!(t, Node::UnaryKind { .. }));
|
||||||
assert_eq!(to_string(&t, &cell_reference), "-(A1^1.22)");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
"-(A1^1.22)"
|
||||||
|
);
|
||||||
|
|
||||||
let t = parser.parse("-A1^1.22", &cell_reference);
|
let t = parser.parse("-A1^1.22", &cell_reference);
|
||||||
assert!(matches!(t, Node::OpPowerKind { .. }));
|
assert!(matches!(t, Node::OpPowerKind { .. }));
|
||||||
assert_eq!(to_string(&t, &cell_reference), "-A1^1.22");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "-A1^1.22");
|
||||||
}
|
}
|
||||||
|
|||||||
56
base/src/expressions/parser/tests/test_languages.rs
Normal file
56
base/src/expressions/parser/tests/test_languages.rs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use crate::expressions::parser::{DefinedNameS, Node, Parser};
|
||||||
|
use crate::expressions::types::CellReferenceRC;
|
||||||
|
|
||||||
|
use crate::expressions::parser::stringify::to_localized_string;
|
||||||
|
use crate::functions::Function;
|
||||||
|
use crate::language::get_language;
|
||||||
|
use crate::locale::get_locale;
|
||||||
|
use crate::types::Table;
|
||||||
|
|
||||||
|
pub fn to_string(t: &Node, cell_reference: &CellReferenceRC) -> String {
|
||||||
|
let locale = get_locale("en").unwrap();
|
||||||
|
let language = get_language("es").unwrap();
|
||||||
|
to_localized_string(t, cell_reference, locale, language)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_parser(
|
||||||
|
worksheets: Vec<String>,
|
||||||
|
defined_names: Vec<DefinedNameS>,
|
||||||
|
tables: HashMap<String, Table>,
|
||||||
|
) -> Parser {
|
||||||
|
let locale = get_locale("en").unwrap();
|
||||||
|
let language = get_language("es").unwrap();
|
||||||
|
Parser::new(worksheets, defined_names, tables, locale, language)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn simple_language() {
|
||||||
|
let worksheets = vec!["Sheet1".to_string(), "Second Sheet".to_string()];
|
||||||
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
// Reference cell is Sheet1!A1
|
||||||
|
let cell_reference = CellReferenceRC {
|
||||||
|
sheet: "Sheet1".to_string(),
|
||||||
|
row: 1,
|
||||||
|
column: 1,
|
||||||
|
};
|
||||||
|
let t = parser.parse("FALSO", &cell_reference);
|
||||||
|
assert!(matches!(t, Node::BooleanKind(false)));
|
||||||
|
|
||||||
|
let t = parser.parse("VERDADERO", &cell_reference);
|
||||||
|
assert!(matches!(t, Node::BooleanKind(true)));
|
||||||
|
|
||||||
|
let t = parser.parse("TRUE()", &cell_reference);
|
||||||
|
assert!(matches!(t, Node::InvalidFunctionKind { ref name, args: _} if name == "TRUE"));
|
||||||
|
|
||||||
|
let t = parser.parse("VERDADERO()", &cell_reference);
|
||||||
|
assert!(matches!(
|
||||||
|
t,
|
||||||
|
Node::FunctionKind {
|
||||||
|
kind: Function::True,
|
||||||
|
args: _
|
||||||
|
}
|
||||||
|
));
|
||||||
|
assert_eq!(to_string(&t, &cell_reference), "VERDADERO()".to_string());
|
||||||
|
}
|
||||||
1
base/src/expressions/parser/tests/test_locales.rs
Normal file
1
base/src/expressions/parser/tests/test_locales.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -1,8 +1,17 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::expressions::parser::move_formula::{move_formula, MoveContext};
|
use crate::expressions::parser::move_formula::{move_formula as mf, MoveContext};
|
||||||
use crate::expressions::parser::Parser;
|
use crate::expressions::parser::tests::utils::new_parser;
|
||||||
|
use crate::expressions::parser::Node;
|
||||||
use crate::expressions::types::{Area, CellReferenceRC};
|
use crate::expressions::types::{Area, CellReferenceRC};
|
||||||
|
use crate::language::Language;
|
||||||
|
use crate::locale::Locale;
|
||||||
|
|
||||||
|
fn move_formula(node: &Node, context: &MoveContext) -> String {
|
||||||
|
let locale = Locale::default();
|
||||||
|
let language = Language::default();
|
||||||
|
mf(node, context, &locale, &language)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_move_formula() {
|
fn test_move_formula() {
|
||||||
@@ -15,7 +24,7 @@ fn test_move_formula() {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Area is C2:F6
|
// Area is C2:F6
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
@@ -102,7 +111,7 @@ fn test_move_formula_context_offset() {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Area is C2:F6
|
// Area is C2:F6
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
@@ -140,7 +149,7 @@ fn test_move_formula_area_limits() {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Area is C2:F6
|
// Area is C2:F6
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
@@ -195,7 +204,7 @@ fn test_move_formula_ranges() {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -318,7 +327,7 @@ fn test_move_formula_wrong_reference() {
|
|||||||
height: 5,
|
height: 5,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Wrong formulas will NOT be displaced
|
// Wrong formulas will NOT be displaced
|
||||||
let node = parser.parse("Sheet3!AB31", context);
|
let node = parser.parse("Sheet3!AB31", context);
|
||||||
@@ -377,7 +386,7 @@ fn test_move_formula_misc() {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Area is C2:F6
|
// Area is C2:F6
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
@@ -445,7 +454,7 @@ fn test_move_formula_another_sheet() {
|
|||||||
};
|
};
|
||||||
// we add two sheets and we cut/paste from Sheet1 to Sheet2
|
// we add two sheets and we cut/paste from Sheet1 to Sheet2
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Area is C2:F6
|
// Area is C2:F6
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
@@ -487,7 +496,7 @@ fn move_formula_implicit_intersetion() {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Area is C2:F6
|
// Area is C2:F6
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
@@ -524,7 +533,7 @@ fn move_formula_implicit_intersetion_with_ranges() {
|
|||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Area is C2:F6
|
// Area is C2:F6
|
||||||
let area = &Area {
|
let area = &Area {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::expressions::lexer::LexerMode;
|
use crate::expressions::lexer::LexerMode;
|
||||||
|
|
||||||
use crate::expressions::parser::stringify::{to_rc_format, to_string};
|
use crate::expressions::parser::stringify::to_rc_format;
|
||||||
use crate::expressions::parser::Parser;
|
use crate::expressions::parser::tests::utils::{new_parser, to_english_localized_string};
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
|
|
||||||
struct Formula<'a> {
|
struct Formula<'a> {
|
||||||
@@ -14,7 +14,7 @@ struct Formula<'a> {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parser_formulas_with_full_ranges() {
|
fn test_parser_formulas_with_full_ranges() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Second Sheet".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Second Sheet".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let formulas = vec![
|
let formulas = vec![
|
||||||
Formula {
|
Formula {
|
||||||
@@ -59,7 +59,10 @@ fn test_parser_formulas_with_full_ranges() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(to_rc_format(&t), formula.formula_r1c1);
|
assert_eq!(to_rc_format(&t), formula.formula_r1c1);
|
||||||
assert_eq!(to_string(&t, &cell_reference), formula.formula_a1);
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
formula.formula_a1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now the inverse
|
// Now the inverse
|
||||||
@@ -74,14 +77,17 @@ fn test_parser_formulas_with_full_ranges() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(to_rc_format(&t), formula.formula_r1c1);
|
assert_eq!(to_rc_format(&t), formula.formula_r1c1);
|
||||||
assert_eq!(to_string(&t, &cell_reference), formula.formula_a1);
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
formula.formula_a1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_range_inverse_order() {
|
fn test_range_inverse_order() {
|
||||||
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
let worksheets = vec!["Sheet1".to_string(), "Sheet2".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -96,7 +102,7 @@ fn test_range_inverse_order() {
|
|||||||
&cell_reference,
|
&cell_reference,
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_string(&t, &cell_reference),
|
to_english_localized_string(&t, &cell_reference),
|
||||||
"SUM(C2:D4)*SUM(Sheet2!C4:D20)*SUM($C4:D$20)".to_string()
|
"SUM(C2:D4)*SUM(Sheet2!C4:D20)*SUM($C4:D$20)".to_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::expressions::parser::stringify::to_string;
|
use crate::expressions::parser::tests::utils::{new_parser, to_english_localized_string};
|
||||||
use crate::expressions::parser::Parser;
|
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn exp_order() {
|
fn exp_order() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
// Reference cell is Sheet1!A1
|
// Reference cell is Sheet1!A1
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -18,25 +17,34 @@ fn exp_order() {
|
|||||||
column: 1,
|
column: 1,
|
||||||
};
|
};
|
||||||
let t = parser.parse("(1 + 2)^3 + 4", &cell_reference);
|
let t = parser.parse("(1 + 2)^3 + 4", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "(1+2)^3+4");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
"(1+2)^3+4"
|
||||||
|
);
|
||||||
|
|
||||||
let t = parser.parse("(C5 + 3)^R4", &cell_reference);
|
let t = parser.parse("(C5 + 3)^R4", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "(C5+3)^R4");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
"(C5+3)^R4"
|
||||||
|
);
|
||||||
|
|
||||||
let t = parser.parse("(C5 + 3)^(R4*6)", &cell_reference);
|
let t = parser.parse("(C5 + 3)^(R4*6)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "(C5+3)^(R4*6)");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
"(C5+3)^(R4*6)"
|
||||||
|
);
|
||||||
|
|
||||||
let t = parser.parse("(C5)^(R4)", &cell_reference);
|
let t = parser.parse("(C5)^(R4)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "C5^R4");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "C5^R4");
|
||||||
|
|
||||||
let t = parser.parse("(5)^(4)", &cell_reference);
|
let t = parser.parse("(5)^(4)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "5^4");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "5^4");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn correct_parenthesis() {
|
fn correct_parenthesis() {
|
||||||
let worksheets = vec!["Sheet1".to_string()];
|
let worksheets = vec!["Sheet1".to_string()];
|
||||||
let mut parser = Parser::new(worksheets, vec![], HashMap::new());
|
let mut parser = new_parser(worksheets, vec![], HashMap::new());
|
||||||
|
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
sheet: "Sheet1".to_string(),
|
sheet: "Sheet1".to_string(),
|
||||||
@@ -45,26 +53,29 @@ fn correct_parenthesis() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let t = parser.parse("-(1 + 1)", &cell_reference);
|
let t = parser.parse("-(1 + 1)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "-(1+1)");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "-(1+1)");
|
||||||
|
|
||||||
let t = parser.parse("1 - (3 + 4)", &cell_reference);
|
let t = parser.parse("1 - (3 + 4)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "1-(3+4)");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "1-(3+4)");
|
||||||
|
|
||||||
let t = parser.parse("-(1.05*(0.0284 + 0.0046) - 0.0284)", &cell_reference);
|
let t = parser.parse("-(1.05*(0.0284 + 0.0046) - 0.0284)", &cell_reference);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_string(&t, &cell_reference),
|
to_english_localized_string(&t, &cell_reference),
|
||||||
"-(1.05*(0.0284+0.0046)-0.0284)"
|
"-(1.05*(0.0284+0.0046)-0.0284)"
|
||||||
);
|
);
|
||||||
|
|
||||||
let t = parser.parse("1 + (3+5)", &cell_reference);
|
let t = parser.parse("1 + (3+5)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "1+3+5");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "1+3+5");
|
||||||
|
|
||||||
let t = parser.parse("1 - (3+5)", &cell_reference);
|
let t = parser.parse("1 - (3+5)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "1-(3+5)");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "1-(3+5)");
|
||||||
|
|
||||||
let t = parser.parse("(1 - 3) - (3+5)", &cell_reference);
|
let t = parser.parse("(1 - 3) - (3+5)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "1-3-(3+5)");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
"1-3-(3+5)"
|
||||||
|
);
|
||||||
|
|
||||||
let t = parser.parse("1 + (3<5)", &cell_reference);
|
let t = parser.parse("1 + (3<5)", &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "1+(3<5)");
|
assert_eq!(to_english_localized_string(&t, &cell_reference), "1+(3<5)");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::expressions::parser::stringify::to_string;
|
use crate::expressions::parser::tests::utils::{new_parser, to_english_localized_string};
|
||||||
use crate::expressions::parser::Parser;
|
|
||||||
use crate::expressions::types::CellReferenceRC;
|
use crate::expressions::types::CellReferenceRC;
|
||||||
use crate::expressions::utils::{number_to_column, parse_reference_a1};
|
use crate::expressions::utils::{number_to_column, parse_reference_a1};
|
||||||
use crate::types::{Table, TableColumn, TableStyleInfo};
|
use crate::types::{Table, TableColumn, TableStyleInfo};
|
||||||
@@ -62,7 +61,7 @@ fn simple_table() {
|
|||||||
let row_count = 3;
|
let row_count = 3;
|
||||||
let tables = create_test_table("tblIncome", &column_names, "A1", row_count);
|
let tables = create_test_table("tblIncome", &column_names, "A1", row_count);
|
||||||
|
|
||||||
let mut parser = Parser::new(worksheets, vec![], tables);
|
let mut parser = new_parser(worksheets, vec![], tables);
|
||||||
// Reference cell is 'Sheet One'!F2
|
// Reference cell is 'Sheet One'!F2
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
sheet: "Sheet One".to_string(),
|
sheet: "Sheet One".to_string(),
|
||||||
@@ -72,7 +71,10 @@ fn simple_table() {
|
|||||||
|
|
||||||
let formula = "SUM(tblIncome[[#This Row],[Jan]:[Dec]])";
|
let formula = "SUM(tblIncome[[#This Row],[Jan]:[Dec]])";
|
||||||
let t = parser.parse(formula, &cell_reference);
|
let t = parser.parse(formula, &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "SUM($A$2:$E$2)");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
"SUM($A$2:$E$2)"
|
||||||
|
);
|
||||||
|
|
||||||
// Cell A3
|
// Cell A3
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -82,7 +84,10 @@ fn simple_table() {
|
|||||||
};
|
};
|
||||||
let formula = "SUBTOTAL(109, tblIncome[Jan])";
|
let formula = "SUBTOTAL(109, tblIncome[Jan])";
|
||||||
let t = parser.parse(formula, &cell_reference);
|
let t = parser.parse(formula, &cell_reference);
|
||||||
assert_eq!(to_string(&t, &cell_reference), "SUBTOTAL(109,$A$2:$A$3)");
|
assert_eq!(
|
||||||
|
to_english_localized_string(&t, &cell_reference),
|
||||||
|
"SUBTOTAL(109,$A$2:$A$3)"
|
||||||
|
);
|
||||||
|
|
||||||
// Cell A3 in 'Second Sheet'
|
// Cell A3 in 'Second Sheet'
|
||||||
let cell_reference = CellReferenceRC {
|
let cell_reference = CellReferenceRC {
|
||||||
@@ -93,7 +98,7 @@ fn simple_table() {
|
|||||||
let formula = "SUBTOTAL(109, tblIncome[Jan])";
|
let formula = "SUBTOTAL(109, tblIncome[Jan])";
|
||||||
let t = parser.parse(formula, &cell_reference);
|
let t = parser.parse(formula, &cell_reference);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_string(&t, &cell_reference),
|
to_english_localized_string(&t, &cell_reference),
|
||||||
"SUBTOTAL(109,'Sheet One'!$A$2:$A$3)"
|
"SUBTOTAL(109,'Sheet One'!$A$2:$A$3)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
29
base/src/expressions/parser/tests/utils.rs
Normal file
29
base/src/expressions/parser/tests/utils.rs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
expressions::{
|
||||||
|
parser::{DefinedNameS, Node, Parser},
|
||||||
|
types::CellReferenceRC,
|
||||||
|
},
|
||||||
|
language::Language,
|
||||||
|
locale::Locale,
|
||||||
|
types::Table,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::expressions::parser::stringify::to_localized_string;
|
||||||
|
|
||||||
|
pub fn to_english_localized_string(t: &Node, cell_reference: &CellReferenceRC) -> String {
|
||||||
|
let locale = Locale::default();
|
||||||
|
let language = Language::default();
|
||||||
|
to_localized_string(t, cell_reference, &locale, &language)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_parser(
|
||||||
|
worksheets: Vec<String>,
|
||||||
|
defined_names: Vec<DefinedNameS>,
|
||||||
|
tables: HashMap<String, Table>,
|
||||||
|
) -> Parser {
|
||||||
|
let locale = Locale::default();
|
||||||
|
let language = Language::default();
|
||||||
|
Parser::new(worksheets, defined_names, tables, &locale, &language)
|
||||||
|
}
|
||||||
@@ -241,6 +241,7 @@ pub enum TokenType {
|
|||||||
Percent, // %
|
Percent, // %
|
||||||
And, // &
|
And, // &
|
||||||
At, // @
|
At, // @
|
||||||
|
Backslash, // \
|
||||||
Reference {
|
Reference {
|
||||||
sheet: Option<String>,
|
sheet: Option<String>,
|
||||||
row: i32,
|
row: i32,
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ pub fn format_number(value_original: f64, format: &str, locale: &Locale) -> Form
|
|||||||
if (1.0e-8..1.0e+11).contains(&value_abs) {
|
if (1.0e-8..1.0e+11).contains(&value_abs) {
|
||||||
let mut text = format!("{value:.9}");
|
let mut text = format!("{value:.9}");
|
||||||
text = text.trim_end_matches('0').trim_end_matches('.').to_string();
|
text = text.trim_end_matches('0').trim_end_matches('.').to_string();
|
||||||
|
if locale.numbers.symbols.decimal != "." {
|
||||||
|
text = text.replace('.', &locale.numbers.symbols.decimal.to_string());
|
||||||
|
}
|
||||||
Formatted {
|
Formatted {
|
||||||
text,
|
text,
|
||||||
color: None,
|
color: None,
|
||||||
@@ -145,13 +148,17 @@ pub fn format_number(value_original: f64, format: &str, locale: &Locale) -> Form
|
|||||||
value /= 10.0_f64.powf(exponent);
|
value /= 10.0_f64.powf(exponent);
|
||||||
let sign = if exponent < 0.0 { '-' } else { '+' };
|
let sign = if exponent < 0.0 { '-' } else { '+' };
|
||||||
let s = format!("{value:.5}");
|
let s = format!("{value:.5}");
|
||||||
|
let mut text = format!(
|
||||||
|
"{}E{}{:02}",
|
||||||
|
s.trim_end_matches('0').trim_end_matches('.'),
|
||||||
|
sign,
|
||||||
|
exponent.abs()
|
||||||
|
);
|
||||||
|
if locale.numbers.symbols.decimal != "." {
|
||||||
|
text = text.replace('.', &locale.numbers.symbols.decimal.to_string());
|
||||||
|
}
|
||||||
Formatted {
|
Formatted {
|
||||||
text: format!(
|
text,
|
||||||
"{}E{}{:02}",
|
|
||||||
s.trim_end_matches('0').trim_end_matches('.'),
|
|
||||||
sign,
|
|
||||||
exponent.abs()
|
|
||||||
),
|
|
||||||
color: None,
|
color: None,
|
||||||
error: None,
|
error: None,
|
||||||
}
|
}
|
||||||
@@ -752,13 +759,15 @@ fn parse_date(value: &str) -> Result<(i32, String), String> {
|
|||||||
pub(crate) fn parse_formatted_number(
|
pub(crate) fn parse_formatted_number(
|
||||||
original: &str,
|
original: &str,
|
||||||
currencies: &[&str],
|
currencies: &[&str],
|
||||||
|
decimal_separator: u8,
|
||||||
|
group_separator: u8,
|
||||||
) -> Result<(f64, Option<String>), String> {
|
) -> Result<(f64, Option<String>), String> {
|
||||||
let value = original.trim();
|
let value = original.trim();
|
||||||
let scientific_format = "0.00E+00";
|
let scientific_format = "0.00E+00";
|
||||||
|
|
||||||
// Check if it is a percentage
|
// Check if it is a percentage
|
||||||
if let Some(p) = value.strip_suffix('%') {
|
if let Some(p) = value.strip_suffix('%') {
|
||||||
let (f, options) = parse_number(p.trim())?;
|
let (f, options) = parse_number(p.trim(), decimal_separator, group_separator)?;
|
||||||
if options.is_scientific {
|
if options.is_scientific {
|
||||||
return Ok((f / 100.0, Some(scientific_format.to_string())));
|
return Ok((f / 100.0, Some(scientific_format.to_string())));
|
||||||
}
|
}
|
||||||
@@ -774,7 +783,7 @@ pub(crate) fn parse_formatted_number(
|
|||||||
// check if it is a currency in currencies
|
// check if it is a currency in currencies
|
||||||
for currency in currencies {
|
for currency in currencies {
|
||||||
if let Some(p) = value.strip_prefix(&format!("-{currency}")) {
|
if let Some(p) = value.strip_prefix(&format!("-{currency}")) {
|
||||||
let (f, options) = parse_number(p.trim())?;
|
let (f, options) = parse_number(p.trim(), decimal_separator, group_separator)?;
|
||||||
if options.is_scientific {
|
if options.is_scientific {
|
||||||
return Ok((f, Some(scientific_format.to_string())));
|
return Ok((f, Some(scientific_format.to_string())));
|
||||||
}
|
}
|
||||||
@@ -783,7 +792,7 @@ pub(crate) fn parse_formatted_number(
|
|||||||
}
|
}
|
||||||
return Ok((-f, Some(format!("{currency}#,##0"))));
|
return Ok((-f, Some(format!("{currency}#,##0"))));
|
||||||
} else if let Some(p) = value.strip_prefix(currency) {
|
} else if let Some(p) = value.strip_prefix(currency) {
|
||||||
let (f, options) = parse_number(p.trim())?;
|
let (f, options) = parse_number(p.trim(), decimal_separator, group_separator)?;
|
||||||
if options.is_scientific {
|
if options.is_scientific {
|
||||||
return Ok((f, Some(scientific_format.to_string())));
|
return Ok((f, Some(scientific_format.to_string())));
|
||||||
}
|
}
|
||||||
@@ -792,7 +801,7 @@ pub(crate) fn parse_formatted_number(
|
|||||||
}
|
}
|
||||||
return Ok((f, Some(format!("{currency}#,##0"))));
|
return Ok((f, Some(format!("{currency}#,##0"))));
|
||||||
} else if let Some(p) = value.strip_suffix(currency) {
|
} else if let Some(p) = value.strip_suffix(currency) {
|
||||||
let (f, options) = parse_number(p.trim())?;
|
let (f, options) = parse_number(p.trim(), decimal_separator, group_separator)?;
|
||||||
if options.is_scientific {
|
if options.is_scientific {
|
||||||
return Ok((f, Some(scientific_format.to_string())));
|
return Ok((f, Some(scientific_format.to_string())));
|
||||||
}
|
}
|
||||||
@@ -811,7 +820,7 @@ pub(crate) fn parse_formatted_number(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lastly we check if it is a number
|
// Lastly we check if it is a number
|
||||||
let (f, options) = parse_number(value)?;
|
let (f, options) = parse_number(value, decimal_separator, group_separator)?;
|
||||||
if options.is_scientific {
|
if options.is_scientific {
|
||||||
return Ok((f, Some(scientific_format.to_string())));
|
return Ok((f, Some(scientific_format.to_string())));
|
||||||
}
|
}
|
||||||
@@ -834,7 +843,11 @@ struct NumberOptions {
|
|||||||
|
|
||||||
// tries to parse 'value' as a number.
|
// tries to parse 'value' as a number.
|
||||||
// If it is a number it either uses commas as thousands separator or it does not
|
// If it is a number it either uses commas as thousands separator or it does not
|
||||||
fn parse_number(value: &str) -> Result<(f64, NumberOptions), String> {
|
fn parse_number(
|
||||||
|
value: &str,
|
||||||
|
decimal_separator: u8,
|
||||||
|
group_separator: u8,
|
||||||
|
) -> Result<(f64, NumberOptions), String> {
|
||||||
let mut position = 0;
|
let mut position = 0;
|
||||||
let bytes = value.as_bytes();
|
let bytes = value.as_bytes();
|
||||||
let len = bytes.len();
|
let len = bytes.len();
|
||||||
@@ -842,8 +855,6 @@ fn parse_number(value: &str) -> Result<(f64, NumberOptions), String> {
|
|||||||
return Err("Cannot parse number".to_string());
|
return Err("Cannot parse number".to_string());
|
||||||
}
|
}
|
||||||
let mut chars = String::from("");
|
let mut chars = String::from("");
|
||||||
let decimal_separator = b'.';
|
|
||||||
let group_separator = b',';
|
|
||||||
let mut group_separator_index = Vec::new();
|
let mut group_separator_index = Vec::new();
|
||||||
// get the sign
|
// get the sign
|
||||||
let sign = if bytes[0] == b'-' {
|
let sign = if bytes[0] == b'-' {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
#![allow(clippy::expect_used)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
formatter::format::format_number,
|
formatter::format::format_number,
|
||||||
@@ -202,3 +203,9 @@ fn test_date() {
|
|||||||
"Sat-September-12"
|
"Sat-September-12"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_german_locale() {
|
||||||
|
let locale = get_locale("de").expect("");
|
||||||
|
assert_eq!(format_number(1234.56, "General", locale).text, "1234,56");
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::formatter::format::parse_formatted_number as parse;
|
use crate::formatter::format::parse_formatted_number;
|
||||||
|
|
||||||
const PARSE_ERROR_MSG: &str = "Could not parse number";
|
const PARSE_ERROR_MSG: &str = "Could not parse number";
|
||||||
|
|
||||||
|
fn parse(input: &str, currencies: &[&str]) -> Result<(f64, Option<String>), String> {
|
||||||
|
parse_formatted_number(input, currencies, b'.', b',')
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn numbers() {
|
fn numbers() {
|
||||||
// whole numbers
|
// whole numbers
|
||||||
|
|||||||
@@ -373,6 +373,8 @@ impl Model {
|
|||||||
CalcResult::Number(sheet_count)
|
CalcResult::Number(sheet_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// INFO(info_type, [reference])
|
||||||
|
/// NB: In Excel "info_type" is localized. Here it is always in English.
|
||||||
pub(crate) fn fn_cell(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
pub(crate) fn fn_cell(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||||
let arg_count = args.len();
|
let arg_count = args.len();
|
||||||
if arg_count == 0 || arg_count > 2 {
|
if arg_count == 0 || arg_count > 2 {
|
||||||
|
|||||||
@@ -839,6 +839,10 @@ impl Model {
|
|||||||
CalcResult::Range { left, right }
|
CalcResult::Range { left, right }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FORMULATEXT(reference)
|
||||||
|
// Returns a formula as a string. Two differences with Excel:
|
||||||
|
// - It returns the formula in English
|
||||||
|
// - It formats the formula without spaces between elements
|
||||||
pub(crate) fn fn_formulatext(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
pub(crate) fn fn_formulatext(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||||
if args.len() != 1 {
|
if args.len() != 1 {
|
||||||
return CalcResult::new_args_number_error(cell);
|
return CalcResult::new_args_number_error(cell);
|
||||||
@@ -860,7 +864,7 @@ impl Model {
|
|||||||
message: "argument must be a reference to a single cell".to_string(),
|
message: "argument must be a reference to a single cell".to_string(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if let Ok(Some(f)) = self.get_cell_formula(left.sheet, left.row, left.column) {
|
if let Ok(Some(f)) = self.get_english_cell_formula(left.sheet, left.row, left.column) {
|
||||||
CalcResult::String(f)
|
CalcResult::String(f)
|
||||||
} else {
|
} else {
|
||||||
CalcResult::Error {
|
CalcResult::Error {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1210,7 +1210,15 @@ impl Model {
|
|||||||
match self.evaluate_node_in_context(&args[0], cell) {
|
match self.evaluate_node_in_context(&args[0], cell) {
|
||||||
CalcResult::String(text) => {
|
CalcResult::String(text) => {
|
||||||
let currencies = vec!["$", "€"];
|
let currencies = vec!["$", "€"];
|
||||||
if let Ok((value, _)) = parse_formatted_number(&text, ¤cies) {
|
let (decimal_separator, group_separator) =
|
||||||
|
if self.locale.numbers.symbols.decimal == "," {
|
||||||
|
(b',', b'.')
|
||||||
|
} else {
|
||||||
|
(b'.', b',')
|
||||||
|
};
|
||||||
|
if let Ok((value, _)) =
|
||||||
|
parse_formatted_number(&text, ¤cies, decimal_separator, group_separator)
|
||||||
|
{
|
||||||
return CalcResult::Number(value);
|
return CalcResult::Number(value);
|
||||||
};
|
};
|
||||||
CalcResult::Error {
|
CalcResult::Error {
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -24,10 +24,369 @@ pub struct Errors {
|
|||||||
pub null: String,
|
pub null: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Encode, Decode, Clone)]
|
||||||
|
pub struct Functions {
|
||||||
|
pub and: String,
|
||||||
|
pub r#false: String,
|
||||||
|
pub r#if: String,
|
||||||
|
pub iferror: String,
|
||||||
|
pub ifna: String,
|
||||||
|
pub ifs: String,
|
||||||
|
pub not: String,
|
||||||
|
pub or: String,
|
||||||
|
pub switch: String,
|
||||||
|
pub r#true: String,
|
||||||
|
pub xor: String,
|
||||||
|
pub log: String,
|
||||||
|
pub log10: String,
|
||||||
|
pub ln: String,
|
||||||
|
pub sin: String,
|
||||||
|
pub cos: String,
|
||||||
|
pub tan: String,
|
||||||
|
pub asin: String,
|
||||||
|
pub acos: String,
|
||||||
|
pub atan: String,
|
||||||
|
pub sinh: String,
|
||||||
|
pub cosh: String,
|
||||||
|
pub tanh: String,
|
||||||
|
pub asinh: String,
|
||||||
|
pub acosh: String,
|
||||||
|
pub atanh: String,
|
||||||
|
pub acot: String,
|
||||||
|
pub acoth: String,
|
||||||
|
pub cot: String,
|
||||||
|
pub coth: String,
|
||||||
|
pub csc: String,
|
||||||
|
pub csch: String,
|
||||||
|
pub sec: String,
|
||||||
|
pub sech: String,
|
||||||
|
pub abs: String,
|
||||||
|
pub pi: String,
|
||||||
|
pub sqrt: String,
|
||||||
|
pub sqrtpi: String,
|
||||||
|
pub atan2: String,
|
||||||
|
pub power: String,
|
||||||
|
pub max: String,
|
||||||
|
pub min: String,
|
||||||
|
pub product: String,
|
||||||
|
pub rand: String,
|
||||||
|
pub randbetween: String,
|
||||||
|
pub round: String,
|
||||||
|
pub rounddown: String,
|
||||||
|
pub roundup: String,
|
||||||
|
pub sum: String,
|
||||||
|
pub sumif: String,
|
||||||
|
pub sumifs: String,
|
||||||
|
pub choose: String,
|
||||||
|
pub column: String,
|
||||||
|
pub columns: String,
|
||||||
|
pub index: String,
|
||||||
|
pub indirect: String,
|
||||||
|
pub hlookup: String,
|
||||||
|
pub lookup: String,
|
||||||
|
pub r#match: String,
|
||||||
|
pub offset: String,
|
||||||
|
pub row: String,
|
||||||
|
pub rows: String,
|
||||||
|
pub vlookup: String,
|
||||||
|
pub xlookup: String,
|
||||||
|
pub concatenate: String,
|
||||||
|
pub exact: String,
|
||||||
|
pub value: String,
|
||||||
|
pub t: String,
|
||||||
|
pub valuetotext: String,
|
||||||
|
pub concat: String,
|
||||||
|
pub find: String,
|
||||||
|
pub left: String,
|
||||||
|
pub len: String,
|
||||||
|
pub lower: String,
|
||||||
|
pub mid: String,
|
||||||
|
pub right: String,
|
||||||
|
pub search: String,
|
||||||
|
pub text: String,
|
||||||
|
pub trim: String,
|
||||||
|
pub unicode: String,
|
||||||
|
pub upper: String,
|
||||||
|
pub isnumber: String,
|
||||||
|
pub isnontext: String,
|
||||||
|
pub istext: String,
|
||||||
|
pub islogical: String,
|
||||||
|
pub isblank: String,
|
||||||
|
pub iserr: String,
|
||||||
|
pub iserror: String,
|
||||||
|
pub isna: String,
|
||||||
|
pub na: String,
|
||||||
|
pub isref: String,
|
||||||
|
pub isodd: String,
|
||||||
|
pub iseven: String,
|
||||||
|
pub errortype: String,
|
||||||
|
pub formulatext: String,
|
||||||
|
pub isformula: String,
|
||||||
|
pub r#type: String,
|
||||||
|
pub sheet: String,
|
||||||
|
pub average: String,
|
||||||
|
pub averagea: String,
|
||||||
|
pub avedev: String,
|
||||||
|
pub averageif: String,
|
||||||
|
pub averageifs: String,
|
||||||
|
pub count: String,
|
||||||
|
pub counta: String,
|
||||||
|
pub countblank: String,
|
||||||
|
pub countif: String,
|
||||||
|
pub countifs: String,
|
||||||
|
pub maxifs: String,
|
||||||
|
pub minifs: String,
|
||||||
|
pub geomean: String,
|
||||||
|
pub year: String,
|
||||||
|
pub day: String,
|
||||||
|
pub month: String,
|
||||||
|
pub eomonth: String,
|
||||||
|
pub date: String,
|
||||||
|
pub datedif: String,
|
||||||
|
pub datevalue: String,
|
||||||
|
pub edate: String,
|
||||||
|
pub networkdays: String,
|
||||||
|
pub networkdaysintl: String,
|
||||||
|
pub time: String,
|
||||||
|
pub timevalue: String,
|
||||||
|
pub hour: String,
|
||||||
|
pub minute: String,
|
||||||
|
pub second: String,
|
||||||
|
pub today: String,
|
||||||
|
pub now: String,
|
||||||
|
pub days: String,
|
||||||
|
pub days360: String,
|
||||||
|
pub weekday: String,
|
||||||
|
pub weeknum: String,
|
||||||
|
pub workday: String,
|
||||||
|
pub workdayintl: String,
|
||||||
|
pub yearfrac: String,
|
||||||
|
pub isoweeknum: String,
|
||||||
|
pub pmt: String,
|
||||||
|
pub pv: String,
|
||||||
|
pub rate: String,
|
||||||
|
pub nper: String,
|
||||||
|
pub fv: String,
|
||||||
|
pub ppmt: String,
|
||||||
|
pub ipmt: String,
|
||||||
|
pub npv: String,
|
||||||
|
pub mirr: String,
|
||||||
|
pub irr: String,
|
||||||
|
pub xirr: String,
|
||||||
|
pub xnpv: String,
|
||||||
|
pub rept: String,
|
||||||
|
pub textafter: String,
|
||||||
|
pub textbefore: String,
|
||||||
|
pub textjoin: String,
|
||||||
|
pub substitute: String,
|
||||||
|
pub ispmt: String,
|
||||||
|
pub rri: String,
|
||||||
|
pub sln: String,
|
||||||
|
pub syd: String,
|
||||||
|
pub nominal: String,
|
||||||
|
pub effect: String,
|
||||||
|
pub pduration: String,
|
||||||
|
pub tbillyield: String,
|
||||||
|
pub tbillprice: String,
|
||||||
|
pub tbilleq: String,
|
||||||
|
pub dollarde: String,
|
||||||
|
pub dollarfr: String,
|
||||||
|
pub ddb: String,
|
||||||
|
pub db: String,
|
||||||
|
pub cumprinc: String,
|
||||||
|
pub cumipmt: String,
|
||||||
|
pub besseli: String,
|
||||||
|
pub besselj: String,
|
||||||
|
pub besselk: String,
|
||||||
|
pub bessely: String,
|
||||||
|
pub erf: String,
|
||||||
|
pub erfprecise: String,
|
||||||
|
pub erfc: String,
|
||||||
|
pub erfcprecise: String,
|
||||||
|
pub bin2dec: String,
|
||||||
|
pub bin2hex: String,
|
||||||
|
pub bin2oct: String,
|
||||||
|
pub dec2bin: String,
|
||||||
|
pub dec2hex: String,
|
||||||
|
pub dec2oct: String,
|
||||||
|
pub hex2bin: String,
|
||||||
|
pub hex2dec: String,
|
||||||
|
pub hex2oct: String,
|
||||||
|
pub oct2bin: String,
|
||||||
|
pub oct2dec: String,
|
||||||
|
pub oct2hex: String,
|
||||||
|
pub bitand: String,
|
||||||
|
pub bitlshift: String,
|
||||||
|
pub bitor: String,
|
||||||
|
pub bitrshift: String,
|
||||||
|
pub bitxor: String,
|
||||||
|
pub complex: String,
|
||||||
|
pub imabs: String,
|
||||||
|
pub imaginary: String,
|
||||||
|
pub imargument: String,
|
||||||
|
pub imconjugate: String,
|
||||||
|
pub imcos: String,
|
||||||
|
pub imcosh: String,
|
||||||
|
pub imcot: String,
|
||||||
|
pub imcsc: String,
|
||||||
|
pub imcsch: String,
|
||||||
|
pub imdiv: String,
|
||||||
|
pub imexp: String,
|
||||||
|
pub imln: String,
|
||||||
|
pub imlog10: String,
|
||||||
|
pub imlog2: String,
|
||||||
|
pub impower: String,
|
||||||
|
pub improduct: String,
|
||||||
|
pub imreal: String,
|
||||||
|
pub imsec: String,
|
||||||
|
pub imsech: String,
|
||||||
|
pub imsin: String,
|
||||||
|
pub imsinh: String,
|
||||||
|
pub imsqrt: String,
|
||||||
|
pub imsub: String,
|
||||||
|
pub imsum: String,
|
||||||
|
pub imtan: String,
|
||||||
|
pub convert: String,
|
||||||
|
pub delta: String,
|
||||||
|
pub gestep: String,
|
||||||
|
pub subtotal: String,
|
||||||
|
pub exp: String,
|
||||||
|
pub fact: String,
|
||||||
|
pub factdouble: String,
|
||||||
|
pub sign: String,
|
||||||
|
pub radians: String,
|
||||||
|
pub degrees: String,
|
||||||
|
pub int: String,
|
||||||
|
pub even: String,
|
||||||
|
pub odd: String,
|
||||||
|
pub ceiling: String,
|
||||||
|
pub ceilingmath: String,
|
||||||
|
pub ceilingprecise: String,
|
||||||
|
pub floor: String,
|
||||||
|
pub floormath: String,
|
||||||
|
pub floorprecise: String,
|
||||||
|
pub isoceiling: String,
|
||||||
|
pub r#mod: String,
|
||||||
|
pub quotient: String,
|
||||||
|
pub mround: String,
|
||||||
|
pub trunc: String,
|
||||||
|
pub gcd: String,
|
||||||
|
pub lcm: String,
|
||||||
|
pub base: String,
|
||||||
|
pub decimal: String,
|
||||||
|
pub roman: String,
|
||||||
|
pub arabic: String,
|
||||||
|
pub combin: String,
|
||||||
|
pub combina: String,
|
||||||
|
pub sumsq: String,
|
||||||
|
pub n: String,
|
||||||
|
pub cell: String,
|
||||||
|
pub info: String,
|
||||||
|
pub sheets: String,
|
||||||
|
pub daverage: String,
|
||||||
|
pub dcount: String,
|
||||||
|
pub dget: String,
|
||||||
|
pub dmax: String,
|
||||||
|
pub dmin: String,
|
||||||
|
pub dsum: String,
|
||||||
|
pub dcounta: String,
|
||||||
|
pub dproduct: String,
|
||||||
|
pub dstdev: String,
|
||||||
|
pub dvar: String,
|
||||||
|
pub dvarp: String,
|
||||||
|
pub dstdevp: String,
|
||||||
|
pub betadist: String,
|
||||||
|
pub betainv: String,
|
||||||
|
pub binomdist: String,
|
||||||
|
pub binomdistrange: String,
|
||||||
|
pub binominv: String,
|
||||||
|
pub chisqdist: String,
|
||||||
|
pub chisqdistrt: String,
|
||||||
|
pub chisqinv: String,
|
||||||
|
pub chisqinvrt: String,
|
||||||
|
pub chisqtest: String,
|
||||||
|
pub confidencenorm: String,
|
||||||
|
pub confidencet: String,
|
||||||
|
pub covariancep: String,
|
||||||
|
pub covariances: String,
|
||||||
|
pub devsq: String,
|
||||||
|
pub expondist: String,
|
||||||
|
pub fdist: String,
|
||||||
|
pub fdistrt: String,
|
||||||
|
pub finv: String,
|
||||||
|
pub finvrt: String,
|
||||||
|
pub fisher: String,
|
||||||
|
pub fisherinv: String,
|
||||||
|
pub ftest: String,
|
||||||
|
pub gamma: String,
|
||||||
|
pub gammadist: String,
|
||||||
|
pub gammainv: String,
|
||||||
|
pub gammaln: String,
|
||||||
|
pub gammalnprecise: String,
|
||||||
|
pub hypgeomdist: String,
|
||||||
|
pub lognormdist: String,
|
||||||
|
pub lognorminv: String,
|
||||||
|
pub negbinomdist: String,
|
||||||
|
pub normdist: String,
|
||||||
|
pub norminv: String,
|
||||||
|
pub normsdist: String,
|
||||||
|
pub normsinv: String,
|
||||||
|
pub pearson: String,
|
||||||
|
pub phi: String,
|
||||||
|
pub poissondist: String,
|
||||||
|
pub standardize: String,
|
||||||
|
pub stdevp: String,
|
||||||
|
pub stdevs: String,
|
||||||
|
pub stdeva: String,
|
||||||
|
pub stdevpa: String,
|
||||||
|
pub tdist: String,
|
||||||
|
pub tdist2t: String,
|
||||||
|
pub tdistrt: String,
|
||||||
|
pub tinv: String,
|
||||||
|
pub tinv2t: String,
|
||||||
|
pub ttest: String,
|
||||||
|
pub varp: String,
|
||||||
|
pub vars: String,
|
||||||
|
pub varpa: String,
|
||||||
|
pub vara: String,
|
||||||
|
pub weibulldist: String,
|
||||||
|
pub ztest: String,
|
||||||
|
pub sumx2my2: String,
|
||||||
|
pub sumx2py2: String,
|
||||||
|
pub sumxmy2: String,
|
||||||
|
pub correl: String,
|
||||||
|
pub rsq: String,
|
||||||
|
pub intercept: String,
|
||||||
|
pub slope: String,
|
||||||
|
pub steyx: String,
|
||||||
|
pub gauss: String,
|
||||||
|
pub harmean: String,
|
||||||
|
pub kurt: String,
|
||||||
|
pub large: String,
|
||||||
|
pub maxa: String,
|
||||||
|
pub median: String,
|
||||||
|
pub mina: String,
|
||||||
|
pub rankavg: String,
|
||||||
|
pub rankeq: String,
|
||||||
|
pub skew: String,
|
||||||
|
pub skewp: String,
|
||||||
|
pub small: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Encode, Decode, Clone)]
|
#[derive(Encode, Decode, Clone)]
|
||||||
pub struct Language {
|
pub struct Language {
|
||||||
|
pub name: String,
|
||||||
|
pub code: String,
|
||||||
pub booleans: Booleans,
|
pub booleans: Booleans,
|
||||||
pub errors: Errors,
|
pub errors: Errors,
|
||||||
|
pub functions: Functions,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Language {
|
||||||
|
fn default() -> Self {
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
get_language("en").unwrap().clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static LANGUAGES: OnceLock<HashMap<String, Language>> = OnceLock::new();
|
static LANGUAGES: OnceLock<HashMap<String, Language>> = OnceLock::new();
|
||||||
|
|||||||
@@ -57,8 +57,10 @@ mod test;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod mock_time;
|
pub mod mock_time;
|
||||||
|
|
||||||
|
pub use locale::get_supported_locales;
|
||||||
pub use model::get_milliseconds_since_epoch;
|
pub use model::get_milliseconds_since_epoch;
|
||||||
pub use model::Model;
|
pub use model::Model;
|
||||||
pub use user_model::BorderArea;
|
pub use user_model::BorderArea;
|
||||||
pub use user_model::ClipboardData;
|
pub use user_model::ClipboardData;
|
||||||
pub use user_model::UserModel;
|
pub use user_model::UserModel;
|
||||||
|
pub use utils::get_all_timezones;
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -29,6 +29,9 @@ pub struct Dates {
|
|||||||
pub months: Vec<String>,
|
pub months: Vec<String>,
|
||||||
pub months_short: Vec<String>,
|
pub months_short: Vec<String>,
|
||||||
pub months_letter: Vec<String>,
|
pub months_letter: Vec<String>,
|
||||||
|
pub date_formats: DateFormats,
|
||||||
|
pub time_formats: DateFormats,
|
||||||
|
pub date_time_formats: DateFormats,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Encode, Decode, Clone)]
|
#[derive(Encode, Decode, Clone)]
|
||||||
@@ -64,6 +67,29 @@ pub struct DecimalFormats {
|
|||||||
pub standard: String,
|
pub standard: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Encode, Decode, Clone)]
|
||||||
|
pub struct DateFormats {
|
||||||
|
pub full: String,
|
||||||
|
pub long: String,
|
||||||
|
pub medium: String,
|
||||||
|
pub short: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encode, Decode, Clone)]
|
||||||
|
pub struct TimeFormats {
|
||||||
|
pub full: String,
|
||||||
|
pub long: String,
|
||||||
|
pub medium: String,
|
||||||
|
pub short: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Locale {
|
||||||
|
fn default() -> Self {
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
get_locale("en").unwrap().clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static LOCALES: OnceLock<HashMap<String, Locale>> = OnceLock::new();
|
static LOCALES: OnceLock<HashMap<String, Locale>> = OnceLock::new();
|
||||||
|
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
@@ -73,6 +99,11 @@ fn get_locales() -> &'static HashMap<String, Locale> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get all available locale IDs.
|
||||||
|
pub fn get_supported_locales() -> Vec<String> {
|
||||||
|
get_locales().keys().cloned().collect()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_locale(id: &str) -> Result<&Locale, String> {
|
pub fn get_locale(id: &str) -> Result<&Locale, String> {
|
||||||
get_locales()
|
get_locales()
|
||||||
.get(id)
|
.get(id)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
lexer::LexerMode,
|
lexer::LexerMode,
|
||||||
parser::{
|
parser::{
|
||||||
move_formula::{move_formula, MoveContext},
|
move_formula::{move_formula, MoveContext},
|
||||||
stringify::{rename_defined_name_in_node, to_rc_format, to_string},
|
stringify::{rename_defined_name_in_node, to_localized_string, to_rc_format},
|
||||||
Node, Parser,
|
Node, Parser,
|
||||||
},
|
},
|
||||||
token::{get_error_by_name, Error, OpCompare, OpProduct, OpSum, OpUnary},
|
token::{get_error_by_name, Error, OpCompare, OpProduct, OpSum, OpUnary},
|
||||||
@@ -25,7 +25,7 @@ use crate::{
|
|||||||
functions::util::compare_values,
|
functions::util::compare_values,
|
||||||
implicit_intersection::implicit_intersection,
|
implicit_intersection::implicit_intersection,
|
||||||
language::{get_language, Language},
|
language::{get_language, Language},
|
||||||
locale::{get_locale, Currency, Locale},
|
locale::{get_locale, Locale},
|
||||||
types::*,
|
types::*,
|
||||||
utils as common,
|
utils as common,
|
||||||
};
|
};
|
||||||
@@ -375,7 +375,7 @@ impl Model {
|
|||||||
}
|
}
|
||||||
FunctionKind { kind, args } => self.evaluate_function(kind, args, cell),
|
FunctionKind { kind, args } => self.evaluate_function(kind, args, cell),
|
||||||
InvalidFunctionKind { name, args: _ } => {
|
InvalidFunctionKind { name, args: _ } => {
|
||||||
CalcResult::new_error(Error::ERROR, cell, format!("Invalid function: {name}"))
|
CalcResult::new_error(Error::NAME, cell, format!("Invalid function: {name}"))
|
||||||
}
|
}
|
||||||
ArrayKind(s) => CalcResult::Array(s.to_owned()),
|
ArrayKind(s) => CalcResult::Array(s.to_owned()),
|
||||||
DefinedNameKind((name, scope, _)) => {
|
DefinedNameKind((name, scope, _)) => {
|
||||||
@@ -680,7 +680,7 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// assert_eq!(model.workbook.worksheet(0)?.color, None);
|
/// assert_eq!(model.workbook.worksheet(0)?.color, None);
|
||||||
/// model.set_sheet_color(0, "#DBBE29")?;
|
/// model.set_sheet_color(0, "#DBBE29")?;
|
||||||
/// assert_eq!(model.workbook.worksheet(0)?.color, Some("#DBBE29".to_string()));
|
/// assert_eq!(model.workbook.worksheet(0)?.color, Some("#DBBE29".to_string()));
|
||||||
@@ -761,7 +761,7 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// assert_eq!(model.is_empty_cell(0, 1, 1)?, true);
|
/// assert_eq!(model.is_empty_cell(0, 1, 1)?, true);
|
||||||
/// model.set_user_input(0, 1, 1, "Attention is all you need".to_string());
|
/// model.set_user_input(0, 1, 1, "Attention is all you need".to_string());
|
||||||
/// assert_eq!(model.is_empty_cell(0, 1, 1)?, false);
|
/// assert_eq!(model.is_empty_cell(0, 1, 1)?, false);
|
||||||
@@ -839,9 +839,9 @@ impl Model {
|
|||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # use ironcalc_base::cell::CellValue;
|
/// # use ironcalc_base::cell::CellValue;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// model.set_user_input(0, 1, 1, "Stella!".to_string());
|
/// model.set_user_input(0, 1, 1, "Stella!".to_string());
|
||||||
/// let model2 = Model::from_bytes(&model.to_bytes())?;
|
/// let model2 = Model::from_bytes(&model.to_bytes(), "en")?;
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// model2.get_cell_value_by_index(0, 1, 1),
|
/// model2.get_cell_value_by_index(0, 1, 1),
|
||||||
/// Ok(CellValue::String("Stella!".to_string()))
|
/// Ok(CellValue::String("Stella!".to_string()))
|
||||||
@@ -852,10 +852,10 @@ impl Model {
|
|||||||
///
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
/// * [Model::to_bytes]
|
/// * [Model::to_bytes]
|
||||||
pub fn from_bytes(s: &[u8]) -> Result<Model, String> {
|
pub fn from_bytes(s: &[u8], language_id: &str) -> Result<Model, String> {
|
||||||
let workbook: Workbook =
|
let workbook: Workbook =
|
||||||
bitcode::decode(s).map_err(|e| format!("Error parsing workbook: {e}"))?;
|
bitcode::decode(s).map_err(|e| format!("Error parsing workbook: {e}"))?;
|
||||||
Model::from_workbook(workbook)
|
Model::from_workbook(workbook, language_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a model from a Workbook object
|
/// Returns a model from a Workbook object
|
||||||
@@ -866,9 +866,9 @@ impl Model {
|
|||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # use ironcalc_base::cell::CellValue;
|
/// # use ironcalc_base::cell::CellValue;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// model.set_user_input(0, 1, 1, "Stella!".to_string());
|
/// model.set_user_input(0, 1, 1, "Stella!".to_string());
|
||||||
/// let model2 = Model::from_workbook(model.workbook)?;
|
/// let model2 = Model::from_workbook(model.workbook, "en")?;
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// model2.get_cell_value_by_index(0, 1, 1),
|
/// model2.get_cell_value_by_index(0, 1, 1),
|
||||||
/// Ok(CellValue::String("Stella!".to_string()))
|
/// Ok(CellValue::String("Stella!".to_string()))
|
||||||
@@ -876,7 +876,7 @@ impl Model {
|
|||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn from_workbook(workbook: Workbook) -> Result<Model, String> {
|
pub fn from_workbook(workbook: Workbook, language_id: &str) -> Result<Model, String> {
|
||||||
let parsed_formulas = Vec::new();
|
let parsed_formulas = Vec::new();
|
||||||
let worksheets = &workbook.worksheets;
|
let worksheets = &workbook.worksheets;
|
||||||
|
|
||||||
@@ -892,7 +892,7 @@ impl Model {
|
|||||||
// }
|
// }
|
||||||
// tables.push(tables_in_sheet);
|
// tables.push(tables_in_sheet);
|
||||||
// }
|
// }
|
||||||
let parser = Parser::new(worksheet_names, defined_names, workbook.tables.clone());
|
|
||||||
let cells = HashMap::new();
|
let cells = HashMap::new();
|
||||||
let locale = get_locale(&workbook.settings.locale)
|
let locale = get_locale(&workbook.settings.locale)
|
||||||
.map_err(|_| "Invalid locale".to_string())?
|
.map_err(|_| "Invalid locale".to_string())?
|
||||||
@@ -903,9 +903,17 @@ impl Model {
|
|||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| format!("Invalid timezone: {}", workbook.settings.tz))?;
|
.map_err(|_| format!("Invalid timezone: {}", workbook.settings.tz))?;
|
||||||
|
|
||||||
// FIXME: Add support for display languages
|
let language = match get_language(language_id) {
|
||||||
#[allow(clippy::expect_used)]
|
Ok(lang) => lang.clone(),
|
||||||
let language = get_language("en").expect("").clone();
|
Err(_) => return Err("Invalid language".to_string()),
|
||||||
|
};
|
||||||
|
let parser = Parser::new(
|
||||||
|
worksheet_names,
|
||||||
|
defined_names,
|
||||||
|
workbook.tables.clone(),
|
||||||
|
&locale,
|
||||||
|
&language,
|
||||||
|
);
|
||||||
let mut shared_strings = HashMap::new();
|
let mut shared_strings = HashMap::new();
|
||||||
for (index, s) in workbook.shared_strings.iter().enumerate() {
|
for (index, s) in workbook.shared_strings.iter().enumerate() {
|
||||||
shared_strings.insert(s.to_string(), index);
|
shared_strings.insert(s.to_string(), index);
|
||||||
@@ -938,7 +946,7 @@ impl Model {
|
|||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # use ironcalc_base::expressions::types::CellReferenceIndex;
|
/// # use ironcalc_base::expressions::types::CellReferenceIndex;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// model.set_user_input(0, 1, 1, "Stella!".to_string());
|
/// model.set_user_input(0, 1, 1, "Stella!".to_string());
|
||||||
/// let reference = model.parse_reference("Sheet1!D40");
|
/// let reference = model.parse_reference("Sheet1!D40");
|
||||||
/// assert_eq!(reference, Some(CellReferenceIndex {sheet: 0, row: 40, column: 4}));
|
/// assert_eq!(reference, Some(CellReferenceIndex {sheet: 0, row: 40, column: 4}));
|
||||||
@@ -1004,7 +1012,7 @@ impl Model {
|
|||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # use ironcalc_base::expressions::types::{Area, CellReferenceIndex};
|
/// # use ironcalc_base::expressions::types::{Area, CellReferenceIndex};
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let source = CellReferenceIndex { sheet: 0, row: 3, column: 1};
|
/// let source = CellReferenceIndex { sheet: 0, row: 3, column: 1};
|
||||||
/// let target = CellReferenceIndex { sheet: 0, row: 50, column: 1};
|
/// let target = CellReferenceIndex { sheet: 0, row: 50, column: 1};
|
||||||
/// let area = Area { sheet: 0, row: 1, column: 1, width: 5, height: 4};
|
/// let area = Area { sheet: 0, row: 1, column: 1, width: 5, height: 4};
|
||||||
@@ -1060,6 +1068,8 @@ impl Model {
|
|||||||
row_delta: target.row - source.row,
|
row_delta: target.row - source.row,
|
||||||
column_delta: target.column - source.column,
|
column_delta: target.column - source.column,
|
||||||
},
|
},
|
||||||
|
&self.locale,
|
||||||
|
&self.language,
|
||||||
);
|
);
|
||||||
Ok(format!("={formula_str}"))
|
Ok(format!("={formula_str}"))
|
||||||
} else {
|
} else {
|
||||||
@@ -1074,7 +1084,7 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "=B1*D4".to_string());
|
/// model.set_user_input(sheet, row, column, "=B1*D4".to_string());
|
||||||
/// let (target_row, target_column) = (30, 1);
|
/// let (target_row, target_column) = (30, 1);
|
||||||
@@ -1098,7 +1108,7 @@ impl Model {
|
|||||||
let cell = self.workbook.worksheet(sheet)?.cell(row, column);
|
let cell = self.workbook.worksheet(sheet)?.cell(row, column);
|
||||||
let result = match cell {
|
let result = match cell {
|
||||||
Some(cell) => match cell.get_formula() {
|
Some(cell) => match cell.get_formula() {
|
||||||
None => cell.get_text(&self.workbook.shared_strings, &self.language),
|
None => cell.get_localized_text(&self.workbook.shared_strings, &self.language),
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
let formula = &self.parsed_formulas[sheet as usize][i as usize];
|
let formula = &self.parsed_formulas[sheet as usize][i as usize];
|
||||||
let cell_ref = CellReferenceRC {
|
let cell_ref = CellReferenceRC {
|
||||||
@@ -1106,7 +1116,10 @@ impl Model {
|
|||||||
row: target_row,
|
row: target_row,
|
||||||
column: target_column,
|
column: target_column,
|
||||||
};
|
};
|
||||||
format!("={}", to_string(formula, &cell_ref))
|
format!(
|
||||||
|
"={}",
|
||||||
|
to_localized_string(formula, &cell_ref, &self.locale, &self.language)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
@@ -1122,7 +1135,7 @@ impl Model {
|
|||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # use ironcalc_base::expressions::types::CellReferenceIndex;
|
/// # use ironcalc_base::expressions::types::CellReferenceIndex;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let source = CellReferenceIndex {sheet: 0, row: 1, column: 1};
|
/// let source = CellReferenceIndex {sheet: 0, row: 1, column: 1};
|
||||||
/// let target = CellReferenceIndex {sheet: 0, row: 30, column: 1};
|
/// let target = CellReferenceIndex {sheet: 0, row: 30, column: 1};
|
||||||
/// let result = model.extend_copied_value("=B1*D4", &source, &target)?;
|
/// let result = model.extend_copied_value("=B1*D4", &source, &target)?;
|
||||||
@@ -1164,7 +1177,10 @@ impl Model {
|
|||||||
row: target.row,
|
row: target.row,
|
||||||
column: target.column,
|
column: target.column,
|
||||||
};
|
};
|
||||||
return Ok(format!("={}", to_string(formula, &cell_reference)));
|
return Ok(format!(
|
||||||
|
"={}",
|
||||||
|
to_localized_string(formula, &cell_reference, &self.locale, &self.language)
|
||||||
|
));
|
||||||
};
|
};
|
||||||
Ok(value.to_string())
|
Ok(value.to_string())
|
||||||
}
|
}
|
||||||
@@ -1176,7 +1192,7 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "=SIN(B1*C3)+1".to_string());
|
/// model.set_user_input(sheet, row, column, "=SIN(B1*C3)+1".to_string());
|
||||||
/// model.evaluate();
|
/// model.evaluate();
|
||||||
@@ -1187,7 +1203,7 @@ impl Model {
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
/// * [Model::get_cell_content()]
|
/// * [Model::get_localized_cell_content()]
|
||||||
pub fn get_cell_formula(
|
pub fn get_cell_formula(
|
||||||
&self,
|
&self,
|
||||||
sheet: u32,
|
sheet: u32,
|
||||||
@@ -1209,7 +1225,47 @@ impl Model {
|
|||||||
row,
|
row,
|
||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
Ok(Some(format!("={}", to_string(formula, &cell_ref))))
|
Ok(Some(format!(
|
||||||
|
"={}",
|
||||||
|
to_localized_string(formula, &cell_ref, &self.locale, &self.language)
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
None => Ok(None),
|
||||||
|
},
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the text for the formula in (`sheet`, `row`, `column`) in English if any
|
||||||
|
///
|
||||||
|
/// See also:
|
||||||
|
/// * [Model::get_localized_cell_content()]
|
||||||
|
pub(crate) fn get_english_cell_formula(
|
||||||
|
&self,
|
||||||
|
sheet: u32,
|
||||||
|
row: i32,
|
||||||
|
column: i32,
|
||||||
|
) -> Result<Option<String>, String> {
|
||||||
|
let worksheet = self.workbook.worksheet(sheet)?;
|
||||||
|
match worksheet.cell(row, column) {
|
||||||
|
Some(cell) => match cell.get_formula() {
|
||||||
|
Some(formula_index) => {
|
||||||
|
let formula = &self
|
||||||
|
.parsed_formulas
|
||||||
|
.get(sheet as usize)
|
||||||
|
.ok_or("missing sheet")?
|
||||||
|
.get(formula_index as usize)
|
||||||
|
.ok_or("missing formula")?;
|
||||||
|
let cell_ref = CellReferenceRC {
|
||||||
|
sheet: worksheet.get_name(),
|
||||||
|
row,
|
||||||
|
column,
|
||||||
|
};
|
||||||
|
let language_en = Language::default();
|
||||||
|
Ok(Some(format!(
|
||||||
|
"={}",
|
||||||
|
to_localized_string(formula, &cell_ref, &self.locale, &language_en)
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
},
|
},
|
||||||
@@ -1225,13 +1281,13 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "Hello!".to_string())?;
|
/// model.set_user_input(sheet, row, column, "Hello!".to_string())?;
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "Hello!".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "Hello!".to_string());
|
||||||
///
|
///
|
||||||
/// model.update_cell_with_text(sheet, row, column, "Goodbye!")?;
|
/// model.update_cell_with_text(sheet, row, column, "Goodbye!")?;
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "Goodbye!".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "Goodbye!".to_string());
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
@@ -1275,13 +1331,13 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "TRUE".to_string())?;
|
/// model.set_user_input(sheet, row, column, "TRUE".to_string())?;
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "TRUE".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "TRUE".to_string());
|
||||||
///
|
///
|
||||||
/// model.update_cell_with_bool(sheet, row, column, false)?;
|
/// model.update_cell_with_bool(sheet, row, column, false)?;
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "FALSE".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "FALSE".to_string());
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
@@ -1317,13 +1373,13 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "42".to_string())?;
|
/// model.set_user_input(sheet, row, column, "42".to_string())?;
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "42".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "42".to_string());
|
||||||
///
|
///
|
||||||
/// model.update_cell_with_number(sheet, row, column, 23.0)?;
|
/// model.update_cell_with_number(sheet, row, column, 23.0)?;
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "23".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "23".to_string());
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
@@ -1360,15 +1416,15 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "=A2*2".to_string())?;
|
/// model.set_user_input(sheet, row, column, "=A2*2".to_string())?;
|
||||||
/// model.evaluate();
|
/// model.evaluate();
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "=A2*2".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "=A2*2".to_string());
|
||||||
///
|
///
|
||||||
/// model.update_cell_with_formula(sheet, row, column, "=A3*2".to_string())?;
|
/// model.update_cell_with_formula(sheet, row, column, "=A3*2".to_string())?;
|
||||||
/// model.evaluate();
|
/// model.evaluate();
|
||||||
/// assert_eq!(model.get_cell_content(sheet, row, column)?, "=A3*2".to_string());
|
/// assert_eq!(model.get_localized_cell_content(sheet, row, column)?, "=A3*2".to_string());
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
@@ -1413,7 +1469,7 @@ impl Model {
|
|||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # use ironcalc_base::cell::CellValue;
|
/// # use ironcalc_base::cell::CellValue;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// model.set_user_input(0, 1, 1, "100$".to_string());
|
/// model.set_user_input(0, 1, 1, "100$".to_string());
|
||||||
/// model.set_user_input(0, 2, 1, "125$".to_string());
|
/// model.set_user_input(0, 2, 1, "125$".to_string());
|
||||||
/// model.set_user_input(0, 3, 1, "-10$".to_string());
|
/// model.set_user_input(0, 3, 1, "-10$".to_string());
|
||||||
@@ -1478,8 +1534,16 @@ impl Model {
|
|||||||
if !currencies.iter().any(|e| e == currency) {
|
if !currencies.iter().any(|e| e == currency) {
|
||||||
currencies.push(currency);
|
currencies.push(currency);
|
||||||
}
|
}
|
||||||
|
let (decimal_separator, group_separator) =
|
||||||
|
if self.locale.numbers.symbols.decimal == "," {
|
||||||
|
(b',', b'.')
|
||||||
|
} else {
|
||||||
|
(b'.', b',')
|
||||||
|
};
|
||||||
// We try to parse as number
|
// We try to parse as number
|
||||||
if let Ok((v, number_format)) = parse_formatted_number(&value, ¤cies) {
|
if let Ok((v, number_format)) =
|
||||||
|
parse_formatted_number(&value, ¤cies, decimal_separator, group_separator)
|
||||||
|
{
|
||||||
if let Some(num_fmt) = number_format {
|
if let Some(num_fmt) = number_format {
|
||||||
// Should not apply the format in the following cases:
|
// Should not apply the format in the following cases:
|
||||||
// - we assign a date to already date-formatted cell
|
// - we assign a date to already date-formatted cell
|
||||||
@@ -1700,7 +1764,7 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "=1/3".to_string());
|
/// model.set_user_input(sheet, row, column, "=1/3".to_string());
|
||||||
/// model.evaluate();
|
/// model.evaluate();
|
||||||
@@ -1736,10 +1800,16 @@ impl Model {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a string with the cell content. If there is a formula returns the formula
|
/// Returns a string with the cell content in the given language and locale.
|
||||||
|
/// If there is a formula returns the formula
|
||||||
/// If the cell is empty returns the empty string
|
/// If the cell is empty returns the empty string
|
||||||
/// Raises an error if there is no worksheet
|
/// Returns an error if there is no worksheet
|
||||||
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> Result<String, String> {
|
pub fn get_localized_cell_content(
|
||||||
|
&self,
|
||||||
|
sheet: u32,
|
||||||
|
row: i32,
|
||||||
|
column: i32,
|
||||||
|
) -> Result<String, String> {
|
||||||
let worksheet = self.workbook.worksheet(sheet)?;
|
let worksheet = self.workbook.worksheet(sheet)?;
|
||||||
let cell = match worksheet.cell(row, column) {
|
let cell = match worksheet.cell(row, column) {
|
||||||
Some(c) => c,
|
Some(c) => c,
|
||||||
@@ -1753,9 +1823,12 @@ impl Model {
|
|||||||
row,
|
row,
|
||||||
column,
|
column,
|
||||||
};
|
};
|
||||||
Ok(format!("={}", to_string(formula, &cell_ref)))
|
Ok(format!(
|
||||||
|
"={}",
|
||||||
|
to_localized_string(formula, &cell_ref, &self.locale, &self.language)
|
||||||
|
))
|
||||||
}
|
}
|
||||||
None => Ok(cell.get_text(&self.workbook.shared_strings, &self.language)),
|
None => Ok(cell.get_localized_text(&self.workbook.shared_strings, &self.language)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1807,7 +1880,7 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "100$".to_string());
|
/// model.set_user_input(sheet, row, column, "100$".to_string());
|
||||||
/// model.cell_clear_contents(sheet, row, column);
|
/// model.cell_clear_contents(sheet, row, column);
|
||||||
@@ -1834,7 +1907,7 @@ impl Model {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::Model;
|
/// # use ironcalc_base::Model;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = Model::new_empty("model", "en", "UTC")?;
|
/// let mut model = Model::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// let (sheet, row, column) = (0, 1, 1);
|
/// let (sheet, row, column) = (0, 1, 1);
|
||||||
/// model.set_user_input(sheet, row, column, "100$".to_string());
|
/// model.set_user_input(sheet, row, column, "100$".to_string());
|
||||||
/// model.cell_clear_all(sheet, row, column);
|
/// model.cell_clear_all(sheet, row, column);
|
||||||
@@ -1958,29 +2031,6 @@ impl Model {
|
|||||||
Ok(rows.join("\n"))
|
Ok(rows.join("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the currency of the model.
|
|
||||||
/// Currently we only support `USD`, `EUR`, `GBP` and `JPY`
|
|
||||||
/// NB: This is not preserved in the JSON.
|
|
||||||
pub fn set_currency(&mut self, iso: &str) -> Result<(), &str> {
|
|
||||||
// TODO: Add a full list
|
|
||||||
let symbol = if iso == "USD" {
|
|
||||||
"$"
|
|
||||||
} else if iso == "EUR" {
|
|
||||||
"€"
|
|
||||||
} else if iso == "GBP" {
|
|
||||||
"£"
|
|
||||||
} else if iso == "JPY" {
|
|
||||||
"¥"
|
|
||||||
} else {
|
|
||||||
return Err("Unsupported currency");
|
|
||||||
};
|
|
||||||
self.locale.currency = Currency {
|
|
||||||
symbol: symbol.to_string(),
|
|
||||||
iso: iso.to_string(),
|
|
||||||
};
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the number of frozen rows in `sheet`
|
/// Returns the number of frozen rows in `sheet`
|
||||||
pub fn get_frozen_rows_count(&self, sheet: u32) -> Result<i32, String> {
|
pub fn get_frozen_rows_count(&self, sheet: u32) -> Result<i32, String> {
|
||||||
if let Some(worksheet) = self.workbook.worksheets.get(sheet as usize) {
|
if let Some(worksheet) = self.workbook.worksheets.get(sheet as usize) {
|
||||||
@@ -2296,6 +2346,57 @@ impl Model {
|
|||||||
pub fn delete_row_style(&mut self, sheet: u32, row: i32) -> Result<(), String> {
|
pub fn delete_row_style(&mut self, sheet: u32, row: i32) -> Result<(), String> {
|
||||||
self.workbook.worksheet_mut(sheet)?.delete_row_style(row)
|
self.workbook.worksheet_mut(sheet)?.delete_row_style(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the locale of the model
|
||||||
|
pub fn set_locale(&mut self, locale_id: &str) -> Result<(), String> {
|
||||||
|
let locale = match get_locale(locale_id) {
|
||||||
|
Ok(l) => l.clone(),
|
||||||
|
Err(_) => return Err(format!("Invalid locale: {locale_id}")),
|
||||||
|
};
|
||||||
|
self.parser.set_locale(&locale);
|
||||||
|
self.locale = locale;
|
||||||
|
self.workbook.settings.locale = locale_id.to_string();
|
||||||
|
self.evaluate();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the timezone of the model
|
||||||
|
pub fn set_timezone(&mut self, timezone: &str) -> Result<(), String> {
|
||||||
|
let tz: Tz = match &timezone.parse() {
|
||||||
|
Ok(tz) => *tz,
|
||||||
|
Err(_) => return Err(format!("Invalid timezone: {}", &timezone)),
|
||||||
|
};
|
||||||
|
self.tz = tz;
|
||||||
|
self.workbook.settings.tz = timezone.to_string();
|
||||||
|
self.evaluate();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the language
|
||||||
|
pub fn set_language(&mut self, language_id: &str) -> Result<(), String> {
|
||||||
|
let language = match get_language(language_id) {
|
||||||
|
Ok(l) => l.clone(),
|
||||||
|
Err(_) => return Err(format!("Invalid language: {language_id}")),
|
||||||
|
};
|
||||||
|
self.parser.set_language(&language);
|
||||||
|
self.language = language;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the current language
|
||||||
|
pub fn get_language(&self) -> String {
|
||||||
|
self.language.name.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the timezone of the model
|
||||||
|
pub fn get_timezone(&self) -> String {
|
||||||
|
self.workbook.settings.tz.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the locale of the model
|
||||||
|
pub fn get_locale(&self) -> String {
|
||||||
|
self.workbook.settings.locale.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -8,14 +8,13 @@ use crate::{
|
|||||||
expressions::{
|
expressions::{
|
||||||
lexer::LexerMode,
|
lexer::LexerMode,
|
||||||
parser::{
|
parser::{
|
||||||
stringify::{rename_sheet_in_node, to_rc_format, to_string},
|
Parser, stringify::{rename_sheet_in_node, to_localized_string, to_rc_format}
|
||||||
Parser,
|
|
||||||
},
|
},
|
||||||
types::CellReferenceRC,
|
types::CellReferenceRC,
|
||||||
},
|
},
|
||||||
language::get_language,
|
language::{Language, get_language},
|
||||||
locale::get_locale,
|
locale::{Locale, get_locale},
|
||||||
model::{get_milliseconds_since_epoch, Model, ParsedDefinedName},
|
model::{Model, ParsedDefinedName, get_milliseconds_since_epoch},
|
||||||
types::{
|
types::{
|
||||||
DefinedName, Metadata, SheetState, Workbook, WorkbookSettings, WorkbookView, Worksheet,
|
DefinedName, Metadata, SheetState, Workbook, WorkbookSettings, WorkbookView, Worksheet,
|
||||||
WorksheetView,
|
WorksheetView,
|
||||||
@@ -81,7 +80,14 @@ impl Model {
|
|||||||
index + 1
|
index + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function parses all the internal formulas in all the worksheets
|
||||||
|
// (in the default language ("en") and locale ("en") and the RC format)
|
||||||
pub(crate) fn parse_formulas(&mut self) {
|
pub(crate) fn parse_formulas(&mut self) {
|
||||||
|
let locale = self.locale.clone();
|
||||||
|
let language = self.language.clone();
|
||||||
|
|
||||||
|
self.parser.set_locale(&Locale::default());
|
||||||
|
self.parser.set_language(&Language::default());
|
||||||
self.parser.set_lexer_mode(LexerMode::R1C1);
|
self.parser.set_lexer_mode(LexerMode::R1C1);
|
||||||
let worksheets = &self.workbook.worksheets;
|
let worksheets = &self.workbook.worksheets;
|
||||||
for worksheet in worksheets {
|
for worksheet in worksheets {
|
||||||
@@ -99,6 +105,8 @@ impl Model {
|
|||||||
self.parsed_formulas.push(parse_formula);
|
self.parsed_formulas.push(parse_formula);
|
||||||
}
|
}
|
||||||
self.parser.set_lexer_mode(LexerMode::A1);
|
self.parser.set_lexer_mode(LexerMode::A1);
|
||||||
|
self.parser.set_locale(&locale);
|
||||||
|
self.parser.set_language(&language);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_defined_names(&mut self) {
|
pub(crate) fn parse_defined_names(&mut self) {
|
||||||
@@ -290,7 +298,7 @@ impl Model {
|
|||||||
for defined_name in &mut self.workbook.defined_names {
|
for defined_name in &mut self.workbook.defined_names {
|
||||||
let mut t = self.parser.parse(&defined_name.formula, cell_reference);
|
let mut t = self.parser.parse(&defined_name.formula, cell_reference);
|
||||||
rename_sheet_in_node(&mut t, sheet_index, new_name);
|
rename_sheet_in_node(&mut t, sheet_index, new_name);
|
||||||
let formula = to_string(&t, cell_reference);
|
let formula = to_localized_string(&t, cell_reference, &self.locale, &self.language);
|
||||||
defined_names.push(DefinedName {
|
defined_names.push(DefinedName {
|
||||||
name: defined_name.name.clone(),
|
name: defined_name.name.clone(),
|
||||||
formula,
|
formula,
|
||||||
@@ -355,7 +363,12 @@ impl Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new workbook with one empty sheet
|
/// Creates a new workbook with one empty sheet
|
||||||
pub fn new_empty(name: &str, locale_id: &str, timezone: &str) -> Result<Model, String> {
|
pub fn new_empty(
|
||||||
|
name: &str,
|
||||||
|
locale_id: &str,
|
||||||
|
timezone: &str,
|
||||||
|
language_id: &str,
|
||||||
|
) -> Result<Model, String> {
|
||||||
let tz: Tz = match &timezone.parse() {
|
let tz: Tz = match &timezone.parse() {
|
||||||
Ok(tz) => *tz,
|
Ok(tz) => *tz,
|
||||||
Err(_) => return Err(format!("Invalid timezone: {}", &timezone)),
|
Err(_) => return Err(format!("Invalid timezone: {}", &timezone)),
|
||||||
@@ -364,6 +377,10 @@ impl Model {
|
|||||||
Ok(l) => l.clone(),
|
Ok(l) => l.clone(),
|
||||||
Err(_) => return Err(format!("Invalid locale: {locale_id}")),
|
Err(_) => return Err(format!("Invalid locale: {locale_id}")),
|
||||||
};
|
};
|
||||||
|
let language = match get_language(language_id) {
|
||||||
|
Ok(l) => l.clone(),
|
||||||
|
Err(_) => return Err(format!("Invalid language: {language_id}")),
|
||||||
|
};
|
||||||
|
|
||||||
let milliseconds = get_milliseconds_since_epoch();
|
let milliseconds = get_milliseconds_since_epoch();
|
||||||
let seconds = milliseconds / 1000;
|
let seconds = milliseconds / 1000;
|
||||||
@@ -409,13 +426,9 @@ impl Model {
|
|||||||
let parsed_formulas = Vec::new();
|
let parsed_formulas = Vec::new();
|
||||||
let worksheets = &workbook.worksheets;
|
let worksheets = &workbook.worksheets;
|
||||||
let worksheet_names = worksheets.iter().map(|s| s.get_name()).collect();
|
let worksheet_names = worksheets.iter().map(|s| s.get_name()).collect();
|
||||||
let parser = Parser::new(worksheet_names, vec![], HashMap::new());
|
let parser = Parser::new(worksheet_names, vec![], HashMap::new(), &locale, &language);
|
||||||
let cells = HashMap::new();
|
let cells = HashMap::new();
|
||||||
|
|
||||||
// FIXME: Add support for display languages
|
|
||||||
#[allow(clippy::expect_used)]
|
|
||||||
let language = get_language("en").expect("").clone();
|
|
||||||
|
|
||||||
let mut model = Model {
|
let mut model = Model {
|
||||||
workbook,
|
workbook,
|
||||||
shared_strings: HashMap::new(),
|
shared_strings: HashMap::new(),
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ fn fn_hex2dec() {
|
|||||||
model._set("A4", r#"=HEX2DEC("FE")"#);
|
model._set("A4", r#"=HEX2DEC("FE")"#);
|
||||||
|
|
||||||
model._set("B1", "=HEX2DEC()");
|
model._set("B1", "=HEX2DEC()");
|
||||||
model._set("B2", "=HHEX2DEC(1,2,3)");
|
model._set("B2", "=HEX2DEC(1,2,3)");
|
||||||
|
|
||||||
model.evaluate();
|
model.evaluate();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ mod test_cell_clear_contents;
|
|||||||
mod test_circular_references;
|
mod test_circular_references;
|
||||||
mod test_column_width;
|
mod test_column_width;
|
||||||
mod test_criteria;
|
mod test_criteria;
|
||||||
mod test_currency;
|
|
||||||
mod test_date_and_time;
|
mod test_date_and_time;
|
||||||
mod test_datedif_leap_month_end;
|
mod test_datedif_leap_month_end;
|
||||||
mod test_days360_month_end;
|
mod test_days360_month_end;
|
||||||
@@ -63,6 +62,7 @@ mod test_fn_offset;
|
|||||||
mod test_number_format;
|
mod test_number_format;
|
||||||
|
|
||||||
mod test_arrays;
|
mod test_arrays;
|
||||||
|
mod test_cell_info_n_sheets;
|
||||||
mod test_combin_combina;
|
mod test_combin_combina;
|
||||||
mod test_escape_quotes;
|
mod test_escape_quotes;
|
||||||
mod test_even_odd;
|
mod test_even_odd;
|
||||||
@@ -79,7 +79,9 @@ mod test_get_cell_content;
|
|||||||
mod test_implicit_intersection;
|
mod test_implicit_intersection;
|
||||||
mod test_issue_155;
|
mod test_issue_155;
|
||||||
mod test_issue_483;
|
mod test_issue_483;
|
||||||
|
mod test_language;
|
||||||
mod test_ln;
|
mod test_ln;
|
||||||
|
mod test_locale;
|
||||||
mod test_log;
|
mod test_log;
|
||||||
mod test_log10;
|
mod test_log10;
|
||||||
mod test_mod_quotient;
|
mod test_mod_quotient;
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ use crate::test::util::new_empty_model;
|
|||||||
#[test]
|
#[test]
|
||||||
fn arguments() {
|
fn arguments() {
|
||||||
let mut model = new_empty_model();
|
let mut model = new_empty_model();
|
||||||
model._set("A1", "=CELL("address",A1)");
|
model._set("A1", "=CELL(\"address\",A1)");
|
||||||
model._set("A2", "=CELL()");
|
model._set("A2", "=CELL()");
|
||||||
|
|
||||||
model._set("A3", "=INFO("system")");
|
model._set("A3", "=INFO(\"system\")");
|
||||||
model._set("A4", "=INFO()");
|
model._set("A4", "=INFO()");
|
||||||
|
|
||||||
model._set("A5", "=N(TRUE)");
|
model._set("A5", "=N(TRUE)");
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
|
||||||
|
|
||||||
use crate::test::util::new_empty_model;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_cell_currency_dollar() {
|
|
||||||
let mut model = new_empty_model();
|
|
||||||
model._set("A1", "=PMT(8/1200,10,10000)");
|
|
||||||
model.evaluate();
|
|
||||||
|
|
||||||
assert_eq!(model._get_text("A1"), "-$1,037.03");
|
|
||||||
|
|
||||||
assert!(model.set_currency("EUR").is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_cell_currency_euro() {
|
|
||||||
let mut model = new_empty_model();
|
|
||||||
assert!(model.set_currency("EUR").is_ok());
|
|
||||||
model._set("A1", "=PMT(8/1200,10,10000)");
|
|
||||||
model.evaluate();
|
|
||||||
|
|
||||||
assert_eq!(model._get_text("A1"), "-€1,037.03");
|
|
||||||
}
|
|
||||||
@@ -52,3 +52,32 @@ fn non_reference() {
|
|||||||
|
|
||||||
assert_eq!(model._get_text("A1"), *"#ERROR!");
|
assert_eq!(model._get_text("A1"), *"#ERROR!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_language_independence() {
|
||||||
|
let mut model = new_empty_model();
|
||||||
|
model._set("A1", "=SUM(1, 2)");
|
||||||
|
model._set("B1", "=FORMULATEXT(A1)");
|
||||||
|
|
||||||
|
model.evaluate();
|
||||||
|
model.set_language("fr").unwrap();
|
||||||
|
model.evaluate();
|
||||||
|
|
||||||
|
assert_eq!(model._get_formula("A1"), *"=SOMME(1,2)");
|
||||||
|
assert_eq!(model._get_text("B1"), *"=SUM(1,2)");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_locale() {
|
||||||
|
let mut model = new_empty_model();
|
||||||
|
|
||||||
|
model._set("A1", "=SUM(1.123, 2)");
|
||||||
|
model._set("B1", "=FORMULATEXT(A1)");
|
||||||
|
model.evaluate();
|
||||||
|
model.set_language("fr").unwrap();
|
||||||
|
model.set_locale("fr").unwrap();
|
||||||
|
model.evaluate();
|
||||||
|
|
||||||
|
assert_eq!(model._get_formula("A1"), *"=SOMME(1,123;2)");
|
||||||
|
assert_eq!(model._get_text("B1"), *"=SUM(1,123;2)");
|
||||||
|
}
|
||||||
|
|||||||
@@ -481,7 +481,9 @@ fn test_cell_formula() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip xlfn tests for now
|
||||||
#[test]
|
#[test]
|
||||||
|
#[ignore]
|
||||||
fn test_xlfn() {
|
fn test_xlfn() {
|
||||||
let mut model = new_empty_model();
|
let mut model = new_empty_model();
|
||||||
model._set("A1", "=_xlfn.SIN(1)");
|
model._set("A1", "=_xlfn.SIN(1)");
|
||||||
|
|||||||
@@ -14,9 +14,15 @@ fn test_formulas() {
|
|||||||
|
|
||||||
model.evaluate();
|
model.evaluate();
|
||||||
|
|
||||||
assert_eq!(model.get_cell_content(0, 1, 1).unwrap(), "100.348");
|
assert_eq!(
|
||||||
assert_eq!(model.get_cell_content(0, 1, 2).unwrap(), "=ISNUMBER(A1)");
|
model.get_localized_cell_content(0, 1, 1).unwrap(),
|
||||||
assert_eq!(model.get_cell_content(0, 5, 5).unwrap(), "");
|
"100.348"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
model.get_localized_cell_content(0, 1, 2).unwrap(),
|
||||||
|
"=ISNUMBER(A1)"
|
||||||
|
);
|
||||||
|
assert_eq!(model.get_localized_cell_content(0, 5, 5).unwrap(), "");
|
||||||
|
|
||||||
assert!(model.get_cell_content(1, 1, 2).is_err());
|
assert!(model.get_localized_cell_content(1, 1, 2).is_err());
|
||||||
}
|
}
|
||||||
|
|||||||
52
base/src/test/test_language.rs
Normal file
52
base/src/test/test_language.rs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
|
use crate::{test::util::new_empty_model, Model};
|
||||||
|
|
||||||
|
pub fn new_german_empty_model() -> Model {
|
||||||
|
Model::new_empty("model", "en", "UTC", "de").unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn german() {
|
||||||
|
let mut model = new_german_empty_model();
|
||||||
|
model._set("A1", "=WENN(1>2, 3, 4)");
|
||||||
|
|
||||||
|
model.evaluate();
|
||||||
|
|
||||||
|
assert_eq!(model._get_text("A1"), *"4");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn french() {
|
||||||
|
let mut model = new_empty_model();
|
||||||
|
model._set("A1", "=IF(1>2, 3, 4)");
|
||||||
|
model._set("B1", "=TRUE");
|
||||||
|
model._set("C1", "=FALSE()");
|
||||||
|
model._set("D1", "=FALSE");
|
||||||
|
model.evaluate();
|
||||||
|
model.set_language("fr").unwrap();
|
||||||
|
model.evaluate();
|
||||||
|
|
||||||
|
assert_eq!(model._get_text("A1"), *"4");
|
||||||
|
assert_eq!(model._get_formula("A1"), *"=SI(1>2,3,4)");
|
||||||
|
assert_eq!(model._get_formula("B1"), *"=VRAI");
|
||||||
|
assert_eq!(model._get_formula("C1"), *"=FAUX()");
|
||||||
|
assert_eq!(model._get_formula("D1"), *"=FAUX");
|
||||||
|
assert_eq!(model._get_text("B1"), *"VRAI");
|
||||||
|
assert_eq!(model._get_text("C1"), *"FAUX");
|
||||||
|
assert_eq!(model._get_text("D1"), *"FAUX");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn spanish() {
|
||||||
|
let mut model = new_empty_model();
|
||||||
|
model._set("A1", "=TRUE()");
|
||||||
|
model.evaluate();
|
||||||
|
model.set_language("es").unwrap();
|
||||||
|
model._set("B1", "=TRUE()");
|
||||||
|
model.evaluate();
|
||||||
|
|
||||||
|
assert_eq!(model._get_formula("A1"), *"=VERDADERO()");
|
||||||
|
assert_eq!(model._get_text("A1"), *"VERDADERO");
|
||||||
|
assert_eq!(model._get_text("B1"), *"#¿NOMBRE?");
|
||||||
|
}
|
||||||
29
base/src/test/test_locale.rs
Normal file
29
base/src/test/test_locale.rs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
|
use crate::Model;
|
||||||
|
|
||||||
|
pub fn new_empty_model() -> Model {
|
||||||
|
Model::new_empty("model", "de", "UTC", "de").unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn german_functions() {
|
||||||
|
let mut model = new_empty_model();
|
||||||
|
model._set("A1", "=WENN(1>2; 3; 4)");
|
||||||
|
model._set("A2", "=SUMME({1;2;3\\4;5;6})");
|
||||||
|
|
||||||
|
model.evaluate();
|
||||||
|
|
||||||
|
assert_eq!(model._get_text("A1"), *"4");
|
||||||
|
assert_eq!(model._get_text("A2"), *"21");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn german_numbers() {
|
||||||
|
let mut model = new_empty_model();
|
||||||
|
model._set("A1", "=SUMME(1,23; 3,45; 4,56)");
|
||||||
|
|
||||||
|
model.evaluate();
|
||||||
|
|
||||||
|
assert_eq!(model._get_text("A1"), *"9,24");
|
||||||
|
}
|
||||||
@@ -20,14 +20,14 @@ fn today_basic() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn today_with_wrong_tz() {
|
fn today_with_wrong_tz() {
|
||||||
let model = Model::new_empty("model", "en", "Wrong Timezone");
|
let model = Model::new_empty("model", "en", "Wrong Timezone", "en");
|
||||||
assert!(model.is_err());
|
assert!(model.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn now_basic_utc() {
|
fn now_basic_utc() {
|
||||||
mock_time::set_mock_time(TIMESTAMP_2023);
|
mock_time::set_mock_time(TIMESTAMP_2023);
|
||||||
let mut model = Model::new_empty("model", "en", "UTC").unwrap();
|
let mut model = Model::new_empty("model", "en", "UTC", "en").unwrap();
|
||||||
model._set("A1", "=TODAY()");
|
model._set("A1", "=TODAY()");
|
||||||
model._set("A2", "=NOW()");
|
model._set("A2", "=NOW()");
|
||||||
model.evaluate();
|
model.evaluate();
|
||||||
@@ -40,7 +40,7 @@ fn now_basic_utc() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn now_basic_europe_berlin() {
|
fn now_basic_europe_berlin() {
|
||||||
mock_time::set_mock_time(TIMESTAMP_2023);
|
mock_time::set_mock_time(TIMESTAMP_2023);
|
||||||
let mut model = Model::new_empty("model", "en", "Europe/Berlin").unwrap();
|
let mut model = Model::new_empty("model", "en", "Europe/Berlin", "en").unwrap();
|
||||||
model._set("A1", "=TODAY()");
|
model._set("A1", "=TODAY()");
|
||||||
model._set("A2", "=NOW()");
|
model._set("A2", "=NOW()");
|
||||||
model.evaluate();
|
model.evaluate();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::{constants::DEFAULT_COLUMN_WIDTH, UserModel};
|
use crate::{constants::DEFAULT_COLUMN_WIDTH, test::user_model::util::new_empty_user_model};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add_undo_redo() {
|
fn add_undo_redo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
model.set_user_input(1, 1, 1, "=1 + 1").unwrap();
|
model.set_user_input(1, 1, 1, "=1 + 1").unwrap();
|
||||||
model.set_user_input(1, 1, 2, "=A1*3").unwrap();
|
model.set_user_input(1, 1, 2, "=A1*3").unwrap();
|
||||||
@@ -29,7 +29,7 @@ fn add_undo_redo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_sheet_color() {
|
fn set_sheet_color() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_sheet_color(0, "#343434").unwrap();
|
model.set_sheet_color(0, "#343434").unwrap();
|
||||||
let worksheets_properties = model.get_worksheets_properties();
|
let worksheets_properties = model.get_worksheets_properties();
|
||||||
assert_eq!(worksheets_properties.len(), 1);
|
assert_eq!(worksheets_properties.len(), 1);
|
||||||
@@ -55,12 +55,12 @@ fn set_sheet_color() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new_sheet_propagates() {
|
fn new_sheet_propagates() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
let worksheets_properties = model2.get_worksheets_properties();
|
let worksheets_properties = model2.get_worksheets_properties();
|
||||||
assert_eq!(worksheets_properties.len(), 2);
|
assert_eq!(worksheets_properties.len(), 2);
|
||||||
@@ -68,13 +68,13 @@ fn new_sheet_propagates() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn delete_sheet_propagates() {
|
fn delete_sheet_propagates() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
model.delete_sheet(0).unwrap();
|
model.delete_sheet(0).unwrap();
|
||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
let sheets_info = model2.get_worksheets_properties();
|
let sheets_info = model2.get_worksheets_properties();
|
||||||
assert_eq!(sheets_info.len(), 1);
|
assert_eq!(sheets_info.len(), 1);
|
||||||
@@ -83,7 +83,7 @@ fn delete_sheet_propagates() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn delete_last_sheet() {
|
fn delete_last_sheet() {
|
||||||
// Deleting the last sheet, selects the previous
|
// Deleting the last sheet, selects the previous
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
model.set_selected_sheet(2).unwrap();
|
model.set_selected_sheet(2).unwrap();
|
||||||
@@ -94,7 +94,7 @@ fn delete_last_sheet() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new_sheet_selects_it() {
|
fn new_sheet_selects_it() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
assert_eq!(model.get_selected_sheet(), 0);
|
assert_eq!(model.get_selected_sheet(), 0);
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
assert_eq!(model.get_selected_sheet(), 1);
|
assert_eq!(model.get_selected_sheet(), 1);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
|
use crate::test::user_model::util::new_empty_user_model;
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::{LAST_COLUMN, LAST_ROW},
|
constants::{LAST_COLUMN, LAST_ROW},
|
||||||
expressions::{types::Area, utils::number_to_column},
|
expressions::{types::Area, utils::number_to_column},
|
||||||
@@ -96,7 +97,7 @@ fn check_borders(model: &UserModel) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn borders_all() {
|
fn borders_all() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
// We set an outer border in cells F5:H9
|
// We set an outer border in cells F5:H9
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -252,7 +253,7 @@ fn borders_all() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn borders_inner() {
|
fn borders_inner() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
check_borders(&model);
|
check_borders(&model);
|
||||||
// We set an outer border in cells F5:H9
|
// We set an outer border in cells F5:H9
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
@@ -340,7 +341,7 @@ fn borders_inner() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn borders_outer() {
|
fn borders_outer() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
// We set an outer border in cells F5:H9
|
// We set an outer border in cells F5:H9
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -484,7 +485,7 @@ fn borders_outer() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn borders_top() {
|
fn borders_top() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
// We set an outer border in cells F5:H9
|
// We set an outer border in cells F5:H9
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -609,7 +610,7 @@ fn borders_top() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn borders_right() {
|
fn borders_right() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
// We set an outer border in cells F5:H9
|
// We set an outer border in cells F5:H9
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -666,7 +667,7 @@ fn borders_right() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn borders_bottom() {
|
fn borders_bottom() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
// We set an outer border in cells F5:H9
|
// We set an outer border in cells F5:H9
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -719,7 +720,7 @@ fn borders_bottom() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn borders_left() {
|
fn borders_left() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
// We set an outer border in cells F5:H9
|
// We set an outer border in cells F5:H9
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -787,7 +788,7 @@ fn borders_left() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn none_borders_get_neighbour() {
|
fn none_borders_get_neighbour() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
// We set an outer border in cells F5:
|
// We set an outer border in cells F5:
|
||||||
let range = &Area {
|
let range = &Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -889,7 +890,7 @@ fn none_borders_get_neighbour() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn heavier_borders() {
|
fn heavier_borders() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
model._set_cell_border("F5", "#F2F2F2");
|
model._set_cell_border("F5", "#F2F2F2");
|
||||||
|
|
||||||
@@ -915,7 +916,7 @@ fn heavier_borders() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lighter_borders() {
|
fn lighter_borders() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
model._set_cell_border("F5", "#000000");
|
model._set_cell_border("F5", "#000000");
|
||||||
|
|
||||||
@@ -962,7 +963,7 @@ fn lighter_borders() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn autofill() {
|
fn autofill() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
model._set_area_border("C4:F6", "#F4F4F4", "All");
|
model._set_area_border("C4:F6", "#F4F4F4", "All");
|
||||||
|
|
||||||
@@ -1007,7 +1008,7 @@ fn autofill() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn border_top() {
|
fn border_top() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
model._set_area_border("C4:F6", "#000000", "All");
|
model._set_area_border("C4:F6", "#000000", "All");
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::{expressions::types::Area, UserModel};
|
use crate::{expressions::types::Area, test::user_model::util::new_empty_user_model};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic() {
|
fn basic() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "100$").unwrap();
|
model.set_user_input(0, 1, 1, "100$").unwrap();
|
||||||
model
|
model
|
||||||
.range_clear_contents(&Area {
|
.range_clear_contents(&Area {
|
||||||
@@ -58,7 +58,7 @@ fn basic() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn clear_empty_cell() {
|
fn clear_empty_cell() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model
|
model
|
||||||
.range_clear_contents(&Area {
|
.range_clear_contents(&Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -75,7 +75,7 @@ fn clear_empty_cell() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn clear_all_empty_cell() {
|
fn clear_all_empty_cell() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model
|
model
|
||||||
.range_clear_all(&Area {
|
.range_clear_all(&Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -92,7 +92,7 @@ fn clear_all_empty_cell() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_454() {
|
fn issue_454() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model
|
model
|
||||||
.set_user_input(
|
.set_user_input(
|
||||||
0,
|
0,
|
||||||
@@ -124,7 +124,7 @@ fn issue_454() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_454b() {
|
fn issue_454b() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model
|
model
|
||||||
.set_user_input(
|
.set_user_input(
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
use crate::constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW};
|
use crate::constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW};
|
||||||
use crate::expressions::types::Area;
|
use crate::expressions::types::Area;
|
||||||
use crate::UserModel;
|
use crate::test::user_model::util::new_empty_user_model;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn column_width() {
|
fn column_width() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -47,7 +47,7 @@ fn column_width() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn existing_style() {
|
fn existing_style() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
let cell_g123 = Area {
|
let cell_g123 = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -95,7 +95,7 @@ fn existing_style() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn row_column() {
|
fn row_column() {
|
||||||
// We set the row style, then a column style
|
// We set the row style, then a column style
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
let column_g_range = Area {
|
let column_g_range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -138,7 +138,7 @@ fn row_column() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn column_row() {
|
fn column_row() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
let default_style = model.get_cell_style(0, 3, 7).unwrap();
|
let default_style = model.get_cell_style(0, 3, 7).unwrap();
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ fn column_row() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn row_column_column() {
|
fn row_column_column() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
let column_c_range = Area {
|
let column_c_range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
@@ -238,7 +238,7 @@ fn row_column_column() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn width_column_undo() {
|
fn width_column_undo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
model
|
model
|
||||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||||
@@ -265,7 +265,7 @@ fn width_column_undo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn height_row_undo() {
|
fn height_row_undo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model
|
model
|
||||||
.set_rows_height(0, 10, 10, DEFAULT_ROW_HEIGHT * 2.0)
|
.set_rows_height(0, 10, 10, DEFAULT_ROW_HEIGHT * 2.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -297,7 +297,7 @@ fn height_row_undo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cell_row_undo() {
|
fn cell_row_undo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let cell_g12 = Area {
|
let cell_g12 = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 12,
|
row: 12,
|
||||||
@@ -335,7 +335,7 @@ fn cell_row_undo() {
|
|||||||
fn set_column_style_then_cell() {
|
fn set_column_style_then_cell() {
|
||||||
// We check that if we set a cell style in a column that already has a style
|
// We check that if we set a cell style in a column that already has a style
|
||||||
// the styles compound
|
// the styles compound
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let cell_g12 = Area {
|
let cell_g12 = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 12,
|
row: 12,
|
||||||
@@ -374,7 +374,7 @@ fn set_column_style_then_cell() {
|
|||||||
fn set_row_style_then_cell() {
|
fn set_row_style_then_cell() {
|
||||||
// We check that if we set a cell style in a column that already has a style
|
// We check that if we set a cell style in a column that already has a style
|
||||||
// the styles compound
|
// the styles compound
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let cell_g12 = Area {
|
let cell_g12 = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 12,
|
row: 12,
|
||||||
@@ -406,7 +406,7 @@ fn set_row_style_then_cell() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn column_style_then_row_alignment() {
|
fn column_style_then_row_alignment() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let column_g_range = Area {
|
let column_g_range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -434,7 +434,7 @@ fn column_style_then_row_alignment() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn column_style_then_width() {
|
fn column_style_then_width() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let column_g_range = Area {
|
let column_g_range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -458,7 +458,7 @@ fn column_style_then_width() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_row_column_column() {
|
fn test_row_column_column() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
let column_c_range = Area {
|
let column_c_range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::UserModel;
|
use crate::test::user_model::util::new_empty_user_model;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create_defined_name() {
|
fn create_defined_name() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||||
model
|
model
|
||||||
.new_defined_name("myName", None, "Sheet1!$A$1")
|
.new_defined_name("myName", None, "Sheet1!$A$1")
|
||||||
@@ -38,7 +38,7 @@ fn create_defined_name() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn scopes() {
|
fn scopes() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
@@ -78,7 +78,7 @@ fn scopes() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn delete_sheet() {
|
fn delete_sheet() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model
|
model
|
||||||
.set_user_input(0, 2, 1, r#"=CONCATENATE(MyName, " world!")"#)
|
.set_user_input(0, 2, 1, r#"=CONCATENATE(MyName, " world!")"#)
|
||||||
@@ -116,7 +116,7 @@ fn delete_sheet() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn change_scope() {
|
fn change_scope() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model
|
model
|
||||||
.set_user_input(0, 2, 1, r#"=CONCATENATE(MyName, " world!")"#)
|
.set_user_input(0, 2, 1, r#"=CONCATENATE(MyName, " world!")"#)
|
||||||
@@ -143,7 +143,7 @@ fn change_scope() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rename_defined_name() {
|
fn rename_defined_name() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model
|
model
|
||||||
.set_user_input(0, 2, 1, r#"=CONCATENATE(MyName, " world!")"#)
|
.set_user_input(0, 2, 1, r#"=CONCATENATE(MyName, " world!")"#)
|
||||||
@@ -175,7 +175,7 @@ fn rename_defined_name() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rename_defined_name_operations() {
|
fn rename_defined_name_operations() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||||
model.set_user_input(0, 1, 2, "123").unwrap();
|
model.set_user_input(0, 1, 2, "123").unwrap();
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ fn rename_defined_name_operations() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
model.get_cell_content(0, 3, 1),
|
model.get_cell_content(0, 3, 1),
|
||||||
Ok("=badDunction(-respuesta)".to_string())
|
Ok("=baddunction(-respuesta)".to_string())
|
||||||
);
|
);
|
||||||
|
|
||||||
// A defined name with the same name but different scope
|
// A defined name with the same name but different scope
|
||||||
@@ -219,7 +219,7 @@ fn rename_defined_name_operations() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rename_defined_name_string_operations() {
|
fn rename_defined_name_string_operations() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model.set_user_input(0, 1, 2, "World").unwrap();
|
model.set_user_input(0, 1, 2, "World").unwrap();
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ fn rename_defined_name_string_operations() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_names() {
|
fn invalid_names() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model
|
model
|
||||||
.new_defined_name("MyName", None, "Sheet1!$A$1")
|
.new_defined_name("MyName", None, "Sheet1!$A$1")
|
||||||
@@ -272,7 +272,7 @@ fn invalid_names() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn already_existing() {
|
fn already_existing() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
model
|
model
|
||||||
.new_defined_name("MyName", None, "Sheet1!$A$1")
|
.new_defined_name("MyName", None, "Sheet1!$A$1")
|
||||||
@@ -296,7 +296,7 @@ fn already_existing() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_sheet() {
|
fn invalid_sheet() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model
|
model
|
||||||
.new_defined_name("MyName", None, "Sheet1!$A$1")
|
.new_defined_name("MyName", None, "Sheet1!$A$1")
|
||||||
@@ -320,7 +320,7 @@ fn invalid_sheet() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_formula() {
|
fn invalid_formula() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
assert!(model.new_defined_name("MyName", None, "A1").is_err());
|
assert!(model.new_defined_name("MyName", None, "A1").is_err());
|
||||||
|
|
||||||
@@ -334,7 +334,7 @@ fn invalid_formula() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn undo_redo() {
|
fn undo_redo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model.set_user_input(0, 2, 1, "Hola").unwrap();
|
model.set_user_input(0, 2, 1, "Hola").unwrap();
|
||||||
model.set_user_input(0, 1, 2, r#"=MyName&"!""#).unwrap();
|
model.set_user_input(0, 1, 2, r#"=MyName&"!""#).unwrap();
|
||||||
@@ -387,7 +387,7 @@ fn undo_redo() {
|
|||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
|
|
||||||
assert_eq!(model2.get_defined_name_list().len(), 1);
|
assert_eq!(model2.get_defined_name_list().len(), 1);
|
||||||
@@ -399,7 +399,7 @@ fn undo_redo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn change_scope_to_first_sheet() {
|
fn change_scope_to_first_sheet() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
model
|
model
|
||||||
@@ -426,7 +426,7 @@ fn change_scope_to_first_sheet() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rename_sheet() {
|
fn rename_sheet() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.new_sheet().unwrap();
|
model.new_sheet().unwrap();
|
||||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW},
|
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW},
|
||||||
expressions::types::Area,
|
expressions::types::Area,
|
||||||
UserModel,
|
test::user_model::util::new_empty_user_model,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -11,7 +11,7 @@ fn delete_column_formatting() {
|
|||||||
// We are going to delete formatting in column G (7)
|
// We are going to delete formatting in column G (7)
|
||||||
// There are cells with their own styles
|
// There are cells with their own styles
|
||||||
// There are rows with their own styles
|
// There are rows with their own styles
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let cell_g123 = Area {
|
let cell_g123 = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 123,
|
row: 123,
|
||||||
@@ -103,7 +103,7 @@ fn delete_column_formatting() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn column_width() {
|
fn column_width() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model
|
model
|
||||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -143,7 +143,7 @@ fn column_width() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn column_row_style_undo() {
|
fn column_row_style_undo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model
|
model
|
||||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -205,7 +205,7 @@ fn column_row_style_undo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn column_row_row_height_undo() {
|
fn column_row_row_height_undo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
let column_g_range = Area {
|
let column_g_range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::UserModel;
|
use crate::test::user_model::util::new_empty_user_model;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn model_evaluates_automatically() {
|
fn model_evaluates_automatically() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "=1 + 1").unwrap();
|
model.set_user_input(0, 1, 1, "=1 + 1").unwrap();
|
||||||
|
|
||||||
assert_eq!(model.get_formatted_cell_value(0, 1, 1), Ok("2".to_string()));
|
assert_eq!(model.get_formatted_cell_value(0, 1, 1), Ok("2".to_string()));
|
||||||
@@ -13,7 +13,7 @@ fn model_evaluates_automatically() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pause_resume_evaluation() {
|
fn pause_resume_evaluation() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.pause_evaluation();
|
model.pause_evaluation();
|
||||||
model.set_user_input(0, 1, 1, "=1+1").unwrap();
|
model.set_user_input(0, 1, 1, "=1+1").unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
10
base/src/test/user_model/test_fn_formulatext.rs
Normal file
10
base/src/test/user_model/test_fn_formulatext.rs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#[test]
|
||||||
|
fn formulatext_english() {
|
||||||
|
let mut model = UserModel::from_model(new_empty_model());
|
||||||
|
model.set_user_input(0, 1, 1, "=SUM(1, 2, 3)").unwrap();
|
||||||
|
model.set_user_input(0, 1, 2, "=FORMULATEXT(A1)").unwrap();
|
||||||
|
|
||||||
|
model.set_language("de").unwrap();
|
||||||
|
|
||||||
|
assert_eq!(model.get_formatted_cell_value(0, 1, 2), Ok("=SUM(1,2,3)".to_string()));
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||||
|
use crate::test::user_model::util::new_empty_user_model;
|
||||||
use crate::test::util::new_empty_model;
|
use crate::test::util::new_empty_model;
|
||||||
use crate::types::CellType;
|
use crate::types::CellType;
|
||||||
use crate::UserModel;
|
use crate::UserModel;
|
||||||
@@ -25,14 +26,14 @@ fn set_user_input_errors() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn user_model_debug_message() {
|
fn user_model_debug_message() {
|
||||||
let model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let model = new_empty_user_model();
|
||||||
let s = &format!("{model:?}");
|
let s = &format!("{model:?}");
|
||||||
assert_eq!(s, "UserModel");
|
assert_eq!(s, "UserModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cell_type() {
|
fn cell_type() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "1").unwrap();
|
model.set_user_input(0, 1, 1, "1").unwrap();
|
||||||
model.set_user_input(0, 1, 2, "Wish you were here").unwrap();
|
model.set_user_input(0, 1, 2, "Wish you were here").unwrap();
|
||||||
model.set_user_input(0, 1, 3, "true").unwrap();
|
model.set_user_input(0, 1, 3, "true").unwrap();
|
||||||
@@ -124,14 +125,14 @@ fn insert_remove_columns() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn delete_remove_cell() {
|
fn delete_remove_cell() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let (sheet, row, column) = (0, 1, 1);
|
let (sheet, row, column) = (0, 1, 1);
|
||||||
model.set_user_input(sheet, row, column, "100$").unwrap();
|
model.set_user_input(sheet, row, column, "100$").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_and_set_name() {
|
fn get_and_set_name() {
|
||||||
let mut model = UserModel::new_empty("MyWorkbook123", "en", "UTC").unwrap();
|
let mut model = UserModel::new_empty("MyWorkbook123", "en", "UTC", "en").unwrap();
|
||||||
assert_eq!(model.get_name(), "MyWorkbook123");
|
assert_eq!(model.get_name(), "MyWorkbook123");
|
||||||
|
|
||||||
model.set_name("Another name");
|
model.set_name("Another name");
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::{expressions::types::Area, UserModel};
|
use crate::expressions::types::Area;
|
||||||
|
use crate::test::user_model::util::new_empty_user_model;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn csv_paste() {
|
fn csv_paste() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 7, 7, "=SUM(B4:D7)").unwrap();
|
model.set_user_input(0, 7, 7, "=SUM(B4:D7)").unwrap();
|
||||||
assert_eq!(model.get_formatted_cell_value(0, 7, 7), Ok("0".to_string()));
|
assert_eq!(model.get_formatted_cell_value(0, 7, 7), Ok("0".to_string()));
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ fn csv_paste() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn csv_paste_formula() {
|
fn csv_paste_formula() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
|
|
||||||
let csv = "=YEAR(TODAY())";
|
let csv = "=YEAR(TODAY())";
|
||||||
let area = Area {
|
let area = Area {
|
||||||
@@ -51,7 +52,7 @@ fn csv_paste_formula() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tsv_crlf_paste() {
|
fn tsv_crlf_paste() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 7, 7, "=SUM(B4:D7)").unwrap();
|
model.set_user_input(0, 7, 7, "=SUM(B4:D7)").unwrap();
|
||||||
assert_eq!(model.get_formatted_cell_value(0, 7, 7), Ok("0".to_string()));
|
assert_eq!(model.get_formatted_cell_value(0, 7, 7), Ok("0".to_string()));
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ fn tsv_crlf_paste() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cut_paste() {
|
fn cut_paste() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||||
model.set_user_input(0, 1, 2, "=A1*3+1").unwrap();
|
model.set_user_input(0, 1, 2, "=A1*3+1").unwrap();
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ fn cut_paste() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cut_paste_different_sheet() {
|
fn cut_paste_different_sheet() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||||
|
|
||||||
model.set_selected_range(1, 1, 1, 1).unwrap();
|
model.set_selected_range(1, 1, 1, 1).unwrap();
|
||||||
@@ -144,7 +145,7 @@ fn cut_paste_different_sheet() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn copy_paste_internal() {
|
fn copy_paste_internal() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||||
model.set_user_input(0, 1, 2, "=A1*3+1").unwrap();
|
model.set_user_input(0, 1, 2, "=A1*3+1").unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
use crate::UserModel;
|
use crate::test::user_model::util::new_empty_user_model;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_rename() {
|
fn basic_rename() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.rename_sheet(0, "NewSheet").unwrap();
|
model.rename_sheet(0, "NewSheet").unwrap();
|
||||||
assert_eq!(model.get_worksheets_properties()[0].name, "NewSheet");
|
assert_eq!(model.get_worksheets_properties()[0].name, "NewSheet");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rename_with_same_name() {
|
fn rename_with_same_name() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.rename_sheet(0, "Sheet1").unwrap();
|
model.rename_sheet(0, "Sheet1").unwrap();
|
||||||
assert_eq!(model.get_worksheets_properties()[0].name, "Sheet1");
|
assert_eq!(model.get_worksheets_properties()[0].name, "Sheet1");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn undo_redo() {
|
fn undo_redo() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
model.rename_sheet(0, "NewSheet").unwrap();
|
model.rename_sheet(0, "NewSheet").unwrap();
|
||||||
model.undo().unwrap();
|
model.undo().unwrap();
|
||||||
assert_eq!(model.get_worksheets_properties()[0].name, "Sheet1");
|
assert_eq!(model.get_worksheets_properties()[0].name, "Sheet1");
|
||||||
@@ -27,14 +27,14 @@ fn undo_redo() {
|
|||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
assert_eq!(model.get_worksheets_properties()[0].name, "NewSheet");
|
assert_eq!(model.get_worksheets_properties()[0].name, "NewSheet");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn errors() {
|
fn errors() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
model.rename_sheet(0, ""),
|
model.rename_sheet(0, ""),
|
||||||
Err("Invalid name for a sheet: ''.".to_string())
|
Err("Invalid name for a sheet: ''.".to_string())
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN},
|
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN},
|
||||||
test::util::new_empty_model,
|
test::{user_model::util::new_empty_user_model, util::new_empty_model},
|
||||||
UserModel,
|
UserModel,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ fn simple_delete_column() {
|
|||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -134,7 +134,7 @@ fn simple_delete_row() {
|
|||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -157,7 +157,7 @@ fn simple_delete_row_no_style() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn row_heigh_increases_automatically() {
|
fn row_heigh_increases_automatically() {
|
||||||
let mut model = UserModel::new_empty("Workbook1", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
assert_eq!(model.get_row_height(0, 1), Ok(DEFAULT_ROW_HEIGHT));
|
assert_eq!(model.get_row_height(0, 1), Ok(DEFAULT_ROW_HEIGHT));
|
||||||
|
|
||||||
// Entering a single line does not change the height
|
// Entering a single line does not change the height
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
expressions::types::Area,
|
expressions::types::Area,
|
||||||
|
test::user_model::util::new_empty_user_model,
|
||||||
types::{Alignment, HorizontalAlignment, VerticalAlignment},
|
types::{Alignment, HorizontalAlignment, VerticalAlignment},
|
||||||
UserModel,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_fonts() {
|
fn basic_fonts() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -77,7 +77,7 @@ fn basic_fonts() {
|
|||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
|
|
||||||
let style = model2.get_cell_style(0, 1, 1).unwrap();
|
let style = model2.get_cell_style(0, 1, 1).unwrap();
|
||||||
@@ -90,7 +90,7 @@ fn basic_fonts() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn font_errors() {
|
fn font_errors() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -133,7 +133,7 @@ fn font_errors() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_fill() {
|
fn basic_fill() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -161,7 +161,7 @@ fn basic_fill() {
|
|||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
|
|
||||||
let style = model2.get_cell_style(0, 1, 1).unwrap();
|
let style = model2.get_cell_style(0, 1, 1).unwrap();
|
||||||
@@ -171,7 +171,7 @@ fn basic_fill() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fill_errors() {
|
fn fill_errors() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -192,7 +192,7 @@ fn fill_errors() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_format() {
|
fn basic_format() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -222,7 +222,7 @@ fn basic_format() {
|
|||||||
|
|
||||||
let send_queue = model.flush_send_queue();
|
let send_queue = model.flush_send_queue();
|
||||||
|
|
||||||
let mut model2 = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model2 = new_empty_user_model();
|
||||||
model2.apply_external_diffs(&send_queue).unwrap();
|
model2.apply_external_diffs(&send_queue).unwrap();
|
||||||
|
|
||||||
let style = model2.get_cell_style(0, 1, 1).unwrap();
|
let style = model2.get_cell_style(0, 1, 1).unwrap();
|
||||||
@@ -231,7 +231,7 @@ fn basic_format() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_alignment() {
|
fn basic_alignment() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -322,7 +322,7 @@ fn basic_alignment() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn alignment_errors() {
|
fn alignment_errors() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -370,7 +370,7 @@ fn alignment_errors() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_wrap_text() {
|
fn basic_wrap_text() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -418,7 +418,7 @@ fn basic_wrap_text() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn false_removes_value() {
|
fn false_removes_value() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
@@ -439,7 +439,7 @@ fn false_removes_value() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cell_clear_formatting() {
|
fn cell_clear_formatting() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = new_empty_user_model();
|
||||||
let range = Area {
|
let range = Area {
|
||||||
sheet: 0,
|
sheet: 0,
|
||||||
row: 1,
|
row: 1,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ fn basic() {
|
|||||||
|
|
||||||
let model_bytes = model1.to_bytes();
|
let model_bytes = model1.to_bytes();
|
||||||
|
|
||||||
let model2 = UserModel::from_bytes(&model_bytes).unwrap();
|
let model2 = UserModel::from_bytes(&model_bytes, "en").unwrap();
|
||||||
|
|
||||||
assert_eq!(model2.get_column_width(0, 3), Ok(width));
|
assert_eq!(model2.get_column_width(0, 3), Ok(width));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -24,7 +24,33 @@ fn basic() {
|
|||||||
fn errors() {
|
fn errors() {
|
||||||
let model_bytes = "Early in the morning, late in the century, Cricklewood Broadway.".as_bytes();
|
let model_bytes = "Early in the morning, late in the century, Cricklewood Broadway.".as_bytes();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&UserModel::from_bytes(model_bytes).unwrap_err(),
|
&UserModel::from_bytes(model_bytes, "en").unwrap_err(),
|
||||||
"Error parsing workbook: invalid packing"
|
"Error parsing workbook: invalid packing"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn language() {
|
||||||
|
let mut model = UserModel::from_model(new_empty_model());
|
||||||
|
model.set_user_input(0, 1, 1, "=NOW()").unwrap();
|
||||||
|
model.set_user_input(0, 1, 2, "=SUM(1.234, 3.4, T1:T3, {1,2.4,3})").unwrap();
|
||||||
|
model.set_language("fr").unwrap();
|
||||||
|
model.set_locale("fr").unwrap();
|
||||||
|
let model_bytes = model.to_bytes();
|
||||||
|
|
||||||
|
let model2 = UserModel::from_bytes(&model_bytes, "es").unwrap();
|
||||||
|
// Check that the formula has been localized to Spanish
|
||||||
|
assert_eq!(model2.get_cell_content(0, 1, 1), Ok("=AHORA()".to_string()));
|
||||||
|
assert_eq!(model2.get_cell_content(0, 1, 2), Ok("=SUMA(1,234;3,4;T1:T3;{1;2,4;3})".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn formulatext_english() {
|
||||||
|
let mut model = UserModel::from_model(new_empty_model());
|
||||||
|
model.set_user_input(0, 1, 1, "=SUM(1, 2, 3)").unwrap();
|
||||||
|
model.set_user_input(0, 1, 2, "=FORMULATEXT(A1)").unwrap();
|
||||||
|
|
||||||
|
model.set_language("de").unwrap();
|
||||||
|
|
||||||
|
assert_eq!(model.get_formatted_cell_value(0, 1, 2), Ok("=SUM(1,2,3)".to_string()));
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
use crate::{expressions::types::Area, types::Border, BorderArea, UserModel};
|
use crate::{expressions::types::Area, types::Border, BorderArea, UserModel};
|
||||||
|
|
||||||
|
pub fn new_empty_user_model() -> UserModel {
|
||||||
|
UserModel::new_empty("model", "en", "UTC", "en").unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
impl UserModel {
|
impl UserModel {
|
||||||
pub fn _set_cell_border(&mut self, cell: &str, color: &str) {
|
pub fn _set_cell_border(&mut self, cell: &str, color: &str) {
|
||||||
let cell_reference = self.model._parse_reference(cell);
|
let cell_reference = self.model._parse_reference(cell);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::model::Model;
|
|||||||
use crate::types::Cell;
|
use crate::types::Cell;
|
||||||
|
|
||||||
pub fn new_empty_model() -> Model {
|
pub fn new_empty_model() -> Model {
|
||||||
Model::new_empty("model", "en", "UTC").unwrap()
|
Model::new_empty("model", "en", "UTC", "en").unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Model {
|
impl Model {
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ fn update_style(old_value: &Style, style_path: &str, value: &str) -> Result<Styl
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use ironcalc_base::UserModel;
|
/// # use ironcalc_base::UserModel;
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut model = UserModel::new_empty("model", "en", "UTC")?;
|
/// let mut model = UserModel::new_empty("model", "en", "UTC", "en")?;
|
||||||
/// model.set_user_input(0, 1, 1, "=1+1")?;
|
/// model.set_user_input(0, 1, 1, "=1+1")?;
|
||||||
/// assert_eq!(model.get_formatted_cell_value(0, 1, 1)?, "2");
|
/// assert_eq!(model.get_formatted_cell_value(0, 1, 1)?, "2");
|
||||||
/// model.undo()?;
|
/// model.undo()?;
|
||||||
@@ -246,8 +246,13 @@ impl UserModel {
|
|||||||
///
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
/// * [Model::new_empty]
|
/// * [Model::new_empty]
|
||||||
pub fn new_empty(name: &str, locale_id: &str, timezone: &str) -> Result<UserModel, String> {
|
pub fn new_empty(
|
||||||
let model = Model::new_empty(name, locale_id, timezone)?;
|
name: &str,
|
||||||
|
locale_id: &str,
|
||||||
|
timezone: &str,
|
||||||
|
language_id: &str,
|
||||||
|
) -> Result<UserModel, String> {
|
||||||
|
let model = Model::new_empty(name, locale_id, timezone, language_id)?;
|
||||||
Ok(UserModel {
|
Ok(UserModel {
|
||||||
model,
|
model,
|
||||||
history: History::default(),
|
history: History::default(),
|
||||||
@@ -260,8 +265,8 @@ impl UserModel {
|
|||||||
///
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
/// * [Model::from_bytes]
|
/// * [Model::from_bytes]
|
||||||
pub fn from_bytes(s: &[u8]) -> Result<UserModel, String> {
|
pub fn from_bytes(s: &[u8], language_id: &str) -> Result<UserModel, String> {
|
||||||
let model = Model::from_bytes(s)?;
|
let model = Model::from_bytes(s, language_id)?;
|
||||||
Ok(UserModel {
|
Ok(UserModel {
|
||||||
model,
|
model,
|
||||||
history: History::default(),
|
history: History::default(),
|
||||||
@@ -458,7 +463,7 @@ impl UserModel {
|
|||||||
/// * [Model::get_cell_content]
|
/// * [Model::get_cell_content]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> Result<String, String> {
|
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> Result<String, String> {
|
||||||
self.model.get_cell_content(sheet, row, column)
|
self.model.get_localized_cell_content(sheet, row, column)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the formatted value of a cell
|
/// Returns the formatted value of a cell
|
||||||
@@ -2030,6 +2035,35 @@ impl UserModel {
|
|||||||
self.model.is_valid_defined_name(name, scope, formula)
|
self.model.is_valid_defined_name(name, scope, formula)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the timezone for the model
|
||||||
|
pub fn set_timezone(&mut self, timezone: &str) -> Result<(), String> {
|
||||||
|
self.model.set_timezone(timezone)
|
||||||
|
}
|
||||||
|
/// Sets the locale for the model
|
||||||
|
pub fn set_locale(&mut self, locale: &str) -> Result<(), String> {
|
||||||
|
self.model.set_locale(locale)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the timezone of the model
|
||||||
|
pub fn get_timezone(&self) -> String {
|
||||||
|
self.model.get_timezone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the locale of the model
|
||||||
|
pub fn get_locale(&self) -> String {
|
||||||
|
self.model.get_locale()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the language for the model
|
||||||
|
pub fn get_language(&self) -> String {
|
||||||
|
self.model.get_language()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the language for the model
|
||||||
|
pub fn set_language(&mut self, language: &str) -> Result<(), String> {
|
||||||
|
self.model.set_language(language)
|
||||||
|
}
|
||||||
|
|
||||||
// **** Private methods ****** //
|
// **** Private methods ****** //
|
||||||
|
|
||||||
pub(crate) fn push_diff_list(&mut self, diff_list: DiffList) {
|
pub(crate) fn push_diff_list(&mut self, diff_list: DiffList) {
|
||||||
|
|||||||
@@ -133,6 +133,14 @@ pub(crate) fn value_needs_quoting(value: &str, language: &Language) -> bool {
|
|||||||
|| get_error_by_name(&value.to_uppercase(), language).is_some()
|
|| get_error_by_name(&value.to_uppercase(), language).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets all timezones
|
||||||
|
pub fn get_all_timezones() -> Vec<String> {
|
||||||
|
chrono_tz::TZ_VARIANTS
|
||||||
|
.iter()
|
||||||
|
.map(|tz| tz.name().to_string())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Valid hex colors are #FFAABB
|
/// Valid hex colors are #FFAABB
|
||||||
/// #fff is not valid
|
/// #fff is not valid
|
||||||
pub(crate) fn is_valid_hex_color(color: &str) -> bool {
|
pub(crate) fn is_valid_hex_color(color: &str) -> bool {
|
||||||
|
|||||||
@@ -36,21 +36,27 @@ pub struct Model {
|
|||||||
#[napi]
|
#[napi]
|
||||||
impl Model {
|
impl Model {
|
||||||
#[napi(constructor)]
|
#[napi(constructor)]
|
||||||
pub fn new(name: String, locale: String, timezone: String) -> Result<Self> {
|
pub fn new(name: String, locale: String, timezone: String, language_id: String) -> Result<Self> {
|
||||||
let model = BaseModel::new_empty(&name, &locale, &timezone).map_err(to_js_error)?;
|
let model =
|
||||||
|
BaseModel::new_empty(&name, &locale, &timezone, &language_id).map_err(to_js_error)?;
|
||||||
Ok(Self { model })
|
Ok(Self { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi(factory)]
|
#[napi(factory)]
|
||||||
pub fn from_xlsx(file_path: String, locale: String, tz: String) -> Result<Model> {
|
pub fn from_xlsx(
|
||||||
let model = load_from_xlsx(&file_path, &locale, &tz)
|
file_path: String,
|
||||||
|
locale: String,
|
||||||
|
tz: String,
|
||||||
|
language_id: String,
|
||||||
|
) -> Result<Model> {
|
||||||
|
let model = load_from_xlsx(&file_path, &locale, &tz, &language_id)
|
||||||
.map_err(|error| Error::new(Status::Unknown, error.to_string()))?;
|
.map_err(|error| Error::new(Status::Unknown, error.to_string()))?;
|
||||||
Ok(Self { model })
|
Ok(Self { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi(factory)]
|
#[napi(factory)]
|
||||||
pub fn from_icalc(file_name: String) -> Result<Model> {
|
pub fn from_icalc(file_name: String, language_id: String) -> Result<Model> {
|
||||||
let model = load_from_icalc(&file_name)
|
let model = load_from_icalc(&file_name, &language_id)
|
||||||
.map_err(|error| Error::new(Status::Unknown, error.to_string()))?;
|
.map_err(|error| Error::new(Status::Unknown, error.to_string()))?;
|
||||||
Ok(Self { model })
|
Ok(Self { model })
|
||||||
}
|
}
|
||||||
@@ -90,7 +96,7 @@ impl Model {
|
|||||||
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> Result<String> {
|
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> Result<String> {
|
||||||
self
|
self
|
||||||
.model
|
.model
|
||||||
.get_cell_content(sheet, row, column)
|
.get_localized_cell_content(sheet, row, column)
|
||||||
.map_err(to_js_error)
|
.map_err(to_js_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,14 +29,15 @@ pub struct UserModel {
|
|||||||
#[napi]
|
#[napi]
|
||||||
impl UserModel {
|
impl UserModel {
|
||||||
#[napi(constructor)]
|
#[napi(constructor)]
|
||||||
pub fn new(name: String, locale: String, timezone: String) -> Result<Self> {
|
pub fn new(name: String, locale: String, timezone: String, language_id: String) -> Result<Self> {
|
||||||
let model = BaseModel::new_empty(&name, &locale, &timezone).map_err(to_js_error)?;
|
let model =
|
||||||
|
BaseModel::new_empty(&name, &locale, &timezone, &language_id).map_err(to_js_error)?;
|
||||||
Ok(Self { model })
|
Ok(Self { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi(factory)]
|
#[napi(factory)]
|
||||||
pub fn from_bytes(bytes: &[u8]) -> Result<UserModel> {
|
pub fn from_bytes(bytes: &[u8], language_id: String) -> Result<UserModel> {
|
||||||
let model = BaseModel::from_bytes(bytes).map_err(to_js_error)?;
|
let model = BaseModel::from_bytes(bytes, &language_id).map_err(to_js_error)?;
|
||||||
Ok(UserModel { model })
|
Ok(UserModel { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import ironcalc as ic
|
import ironcalc as ic
|
||||||
|
|
||||||
model = ic.create("model", "en", "UTC")
|
model = ic.create("model", "en", "UTC", "en")
|
||||||
|
|
||||||
model.set_user_input(0, 1, 1, "=21*2")
|
model.set_user_input(0, 1, 1, "=21*2")
|
||||||
model.evaluate()
|
model.evaluate()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Creating an Empty Model
|
|||||||
|
|
||||||
import ironcalc as ic
|
import ironcalc as ic
|
||||||
|
|
||||||
model = ic.create("My Workbook", "en", "UTC")
|
model = ic.create("My Workbook", "en", "UTC", "en")
|
||||||
|
|
||||||
Loading from XLSX
|
Loading from XLSX
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
@@ -18,14 +18,14 @@ Loading from XLSX
|
|||||||
|
|
||||||
import ironcalc as ic
|
import ironcalc as ic
|
||||||
|
|
||||||
model = ic.load_from_xlsx("example.xlsx", "en", "UTC")
|
model = ic.load_from_xlsx("example.xlsx", "en", "UTC", "en")
|
||||||
|
|
||||||
Modifying and Saving
|
Modifying and Saving
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
model = ic.create("model", "en", "UTC")
|
model = ic.create("model", "en", "UTC", "en")
|
||||||
model.set_user_input(0, 1, 1, "123")
|
model.set_user_input(0, 1, 1, "123")
|
||||||
model.set_user_input(0, 1, 2, "=A1*2")
|
model.set_user_input(0, 1, 2, "=A1*2")
|
||||||
model.evaluate()
|
model.evaluate()
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ impl PyModel {
|
|||||||
/// Get raw value
|
/// Get raw value
|
||||||
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> PyResult<String> {
|
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> PyResult<String> {
|
||||||
self.model
|
self.model
|
||||||
.get_cell_content(sheet, row, column)
|
.get_localized_cell_content(sheet, row, column)
|
||||||
.map_err(|e| WorkbookError::new_err(e.to_string()))
|
.map_err(|e| WorkbookError::new_err(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,17 +329,22 @@ impl PyModel {
|
|||||||
|
|
||||||
/// Loads a function from an xlsx file
|
/// Loads a function from an xlsx file
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
pub fn load_from_xlsx(file_path: &str, locale: &str, tz: &str) -> PyResult<PyModel> {
|
pub fn load_from_xlsx(
|
||||||
let model = import::load_from_xlsx(file_path, locale, tz)
|
file_path: &str,
|
||||||
|
locale: &str,
|
||||||
|
tz: &str,
|
||||||
|
language_id: &str,
|
||||||
|
) -> PyResult<PyModel> {
|
||||||
|
let model = import::load_from_xlsx(file_path, locale, tz, language_id)
|
||||||
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
Ok(PyModel { model })
|
Ok(PyModel { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads a function from icalc binary representation
|
/// Loads a function from icalc binary representation
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
pub fn load_from_icalc(file_name: &str) -> PyResult<PyModel> {
|
pub fn load_from_icalc(file_name: &str, language_id: &str) -> PyResult<PyModel> {
|
||||||
let model =
|
let model = import::load_from_icalc(file_name, language_id)
|
||||||
import::load_from_icalc(file_name).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
Ok(PyModel { model })
|
Ok(PyModel { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,26 +352,31 @@ pub fn load_from_icalc(file_name: &str) -> PyResult<PyModel> {
|
|||||||
/// This function expects the bytes to be in the internal binary ic format
|
/// This function expects the bytes to be in the internal binary ic format
|
||||||
/// which is the same format used by the `save_to_icalc` function.
|
/// which is the same format used by the `save_to_icalc` function.
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
pub fn load_from_bytes(bytes: &[u8]) -> PyResult<PyModel> {
|
pub fn load_from_bytes(bytes: &[u8], language_id: &str) -> PyResult<PyModel> {
|
||||||
let workbook: Workbook =
|
let workbook: Workbook =
|
||||||
bitcode::decode(bytes).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
bitcode::decode(bytes).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
let model =
|
let model = Model::from_workbook(workbook, language_id)
|
||||||
Model::from_workbook(workbook).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
Ok(PyModel { model })
|
Ok(PyModel { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an empty model in the raw API
|
/// Creates an empty model in the raw API
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
pub fn create(name: &str, locale: &str, tz: &str) -> PyResult<PyModel> {
|
pub fn create(name: &str, locale: &str, tz: &str, language_id: &str) -> PyResult<PyModel> {
|
||||||
let model =
|
let model = Model::new_empty(name, locale, tz, language_id)
|
||||||
Model::new_empty(name, locale, tz).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
Ok(PyModel { model })
|
Ok(PyModel { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a model with the user model API
|
/// Creates a model with the user model API
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
pub fn create_user_model(name: &str, locale: &str, tz: &str) -> PyResult<PyUserModel> {
|
pub fn create_user_model(
|
||||||
let model = UserModel::new_empty(name, locale, tz)
|
name: &str,
|
||||||
|
locale: &str,
|
||||||
|
tz: &str,
|
||||||
|
language_id: &str,
|
||||||
|
) -> PyResult<PyUserModel> {
|
||||||
|
let model = UserModel::new_empty(name, locale, tz, language_id)
|
||||||
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
Ok(PyUserModel { model })
|
Ok(PyUserModel { model })
|
||||||
}
|
}
|
||||||
@@ -377,8 +387,9 @@ pub fn create_user_model_from_xlsx(
|
|||||||
file_path: &str,
|
file_path: &str,
|
||||||
locale: &str,
|
locale: &str,
|
||||||
tz: &str,
|
tz: &str,
|
||||||
|
language_id: &str,
|
||||||
) -> PyResult<PyUserModel> {
|
) -> PyResult<PyUserModel> {
|
||||||
let model = import::load_from_xlsx(file_path, locale, tz)
|
let model = import::load_from_xlsx(file_path, locale, tz, language_id)
|
||||||
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
let model = UserModel::from_model(model);
|
let model = UserModel::from_model(model);
|
||||||
Ok(PyUserModel { model })
|
Ok(PyUserModel { model })
|
||||||
@@ -386,9 +397,9 @@ pub fn create_user_model_from_xlsx(
|
|||||||
|
|
||||||
/// Creates a user model from an icalc file
|
/// Creates a user model from an icalc file
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
pub fn create_user_model_from_icalc(file_name: &str) -> PyResult<PyUserModel> {
|
pub fn create_user_model_from_icalc(file_name: &str, language_id: &str) -> PyResult<PyUserModel> {
|
||||||
let model =
|
let model = import::load_from_icalc(file_name, language_id)
|
||||||
import::load_from_icalc(file_name).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
let model = UserModel::from_model(model);
|
let model = UserModel::from_model(model);
|
||||||
Ok(PyUserModel { model })
|
Ok(PyUserModel { model })
|
||||||
}
|
}
|
||||||
@@ -397,11 +408,11 @@ pub fn create_user_model_from_icalc(file_name: &str) -> PyResult<PyUserModel> {
|
|||||||
/// This function expects the bytes to be in the internal binary ic format
|
/// This function expects the bytes to be in the internal binary ic format
|
||||||
/// which is the same format used by the `save_to_icalc` function.
|
/// which is the same format used by the `save_to_icalc` function.
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
pub fn create_user_model_from_bytes(bytes: &[u8]) -> PyResult<PyUserModel> {
|
pub fn create_user_model_from_bytes(bytes: &[u8], language_id: &str) -> PyResult<PyUserModel> {
|
||||||
let workbook: Workbook =
|
let workbook: Workbook =
|
||||||
bitcode::decode(bytes).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
bitcode::decode(bytes).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
let model =
|
let model = Model::from_workbook(workbook, language_id)
|
||||||
Model::from_workbook(workbook).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
let user_model = UserModel::from_model(model);
|
let user_model = UserModel::from_model(model);
|
||||||
Ok(PyUserModel { model: user_model })
|
Ok(PyUserModel { model: user_model })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import ironcalc as ic
|
import ironcalc as ic
|
||||||
|
|
||||||
def test_simple():
|
def test_simple():
|
||||||
model = ic.create("model", "en", "UTC")
|
model = ic.create("model", "en", "UTC", "en")
|
||||||
model.set_user_input(0, 1, 1, "=1+2")
|
model.set_user_input(0, 1, 1, "=1+2")
|
||||||
model.evaluate()
|
model.evaluate()
|
||||||
|
|
||||||
@@ -9,12 +9,12 @@ def test_simple():
|
|||||||
|
|
||||||
bytes = model.to_bytes()
|
bytes = model.to_bytes()
|
||||||
|
|
||||||
model2 = ic.load_from_bytes(bytes)
|
model2 = ic.load_from_bytes(bytes, "en")
|
||||||
assert model2.get_formatted_cell_value(0, 1, 1) == "3"
|
assert model2.get_formatted_cell_value(0, 1, 1) == "3"
|
||||||
|
|
||||||
|
|
||||||
def test_simple_user():
|
def test_simple_user():
|
||||||
model = ic.create_user_model("model", "en", "UTC")
|
model = ic.create_user_model("model", "en", "UTC", "en")
|
||||||
model.set_user_input(0, 1, 1, "=1+2")
|
model.set_user_input(0, 1, 1, "=1+2")
|
||||||
model.set_user_input(0, 1, 2, "=A1+3")
|
model.set_user_input(0, 1, 2, "=A1+3")
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ def test_simple_user():
|
|||||||
|
|
||||||
diffs = model.flush_send_queue()
|
diffs = model.flush_send_queue()
|
||||||
|
|
||||||
model2 = ic.create_user_model("model", "en", "UTC")
|
model2 = ic.create_user_model("model", "en", "UTC", "en")
|
||||||
model2.apply_external_diffs(diffs)
|
model2.apply_external_diffs(diffs)
|
||||||
assert model2.get_formatted_cell_value(0, 1, 1) == "3"
|
assert model2.get_formatted_cell_value(0, 1, 1) == "3"
|
||||||
assert model2.get_formatted_cell_value(0, 1, 2) == "6"
|
assert model2.get_formatted_cell_value(0, 1, 2) == "6"
|
||||||
@@ -31,7 +31,7 @@ def test_simple_user():
|
|||||||
|
|
||||||
def test_sheet_dimensions():
|
def test_sheet_dimensions():
|
||||||
# Test with empty sheet
|
# Test with empty sheet
|
||||||
model = ic.create("model", "en", "UTC")
|
model = ic.create("model", "en", "UTC", "en")
|
||||||
min_row, max_row, min_col, max_col = model.get_sheet_dimensions(0)
|
min_row, max_row, min_col, max_col = model.get_sheet_dimensions(0)
|
||||||
assert (min_row, max_row, min_col, max_col) == (1, 1, 1, 1)
|
assert (min_row, max_row, min_col, max_col) == (1, 1, 1, 1)
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ def test_sheet_dimensions():
|
|||||||
|
|
||||||
def test_sheet_dimensions_user_model():
|
def test_sheet_dimensions_user_model():
|
||||||
# Test with user model API as well
|
# Test with user model API as well
|
||||||
model = ic.create_user_model("model", "en", "UTC")
|
model = ic.create_user_model("model", "en", "UTC", "en")
|
||||||
|
|
||||||
# Add a single cell
|
# Add a single cell
|
||||||
model.set_user_input(0, 2, 3, "Test")
|
model.set_user_input(0, 2, 3, "Test")
|
||||||
|
|||||||
@@ -40,6 +40,18 @@ pub fn quote_name(name: &str) -> String {
|
|||||||
quote_name_ic(name)
|
quote_name_ic(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets all timezones
|
||||||
|
#[wasm_bindgen(js_name = "getAllTimezones")]
|
||||||
|
pub fn get_all_timezones() -> Vec<String> {
|
||||||
|
ironcalc_base::get_all_timezones()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets all supported locales
|
||||||
|
#[wasm_bindgen(js_name = "getSupportedLocales")]
|
||||||
|
pub fn get_supported_locales() -> Vec<String> {
|
||||||
|
ironcalc_base::get_supported_locales()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct DefinedName {
|
struct DefinedName {
|
||||||
name: String,
|
name: String,
|
||||||
@@ -55,13 +67,19 @@ pub struct Model {
|
|||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl Model {
|
impl Model {
|
||||||
#[wasm_bindgen(constructor)]
|
#[wasm_bindgen(constructor)]
|
||||||
pub fn new(name: &str, locale: &str, timezone: &str) -> Result<Model, JsError> {
|
pub fn new(
|
||||||
let model = BaseModel::new_empty(name, locale, timezone).map_err(to_js_error)?;
|
name: &str,
|
||||||
|
locale: &str,
|
||||||
|
timezone: &str,
|
||||||
|
language_id: &str,
|
||||||
|
) -> Result<Model, JsError> {
|
||||||
|
let model =
|
||||||
|
BaseModel::new_empty(name, locale, timezone, language_id).map_err(to_js_error)?;
|
||||||
Ok(Model { model })
|
Ok(Model { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_bytes(bytes: &[u8]) -> Result<Model, JsError> {
|
pub fn from_bytes(bytes: &[u8], language_id: &str) -> Result<Model, JsError> {
|
||||||
let model = BaseModel::from_bytes(bytes).map_err(to_js_error)?;
|
let model = BaseModel::from_bytes(bytes, language_id).map_err(to_js_error)?;
|
||||||
Ok(Model { model })
|
Ok(Model { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,4 +806,44 @@ impl Model {
|
|||||||
Err(e) => Err(to_js_error(e.to_string())),
|
Err(e) => Err(to_js_error(e.to_string())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen(js_name = "setTimezone")]
|
||||||
|
pub fn set_timezone(&mut self, timezone: &str) -> Result<(), JsError> {
|
||||||
|
self.model
|
||||||
|
.set_timezone(timezone)
|
||||||
|
.map_err(|e| to_js_error(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen(js_name = "setLocale")]
|
||||||
|
pub fn set_locale(&mut self, locale: &str) -> Result<(), JsError> {
|
||||||
|
self.model
|
||||||
|
.set_locale(locale)
|
||||||
|
.map_err(|e| to_js_error(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the timezone of the model
|
||||||
|
#[wasm_bindgen(js_name = "getTimezone")]
|
||||||
|
pub fn get_timezone(&self) -> String {
|
||||||
|
self.model.get_timezone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the locale of the model
|
||||||
|
#[wasm_bindgen(js_name = "getLocale")]
|
||||||
|
pub fn get_locale(&self) -> String {
|
||||||
|
self.model.get_locale()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the language of the model
|
||||||
|
#[wasm_bindgen(js_name = "getLanguage")]
|
||||||
|
pub fn get_language(&self) -> String {
|
||||||
|
self.model.get_language()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the language of the model
|
||||||
|
#[wasm_bindgen(js_name = "setLanguage")]
|
||||||
|
pub fn set_language(&mut self, language: &str) -> Result<(), JsError> {
|
||||||
|
self.model
|
||||||
|
.set_language(language)
|
||||||
|
.map_err(|e| to_js_error(e.to_string()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Model } from "../pkg/wasm.js";
|
|||||||
const DEFAULT_ROW_HEIGHT = 28;
|
const DEFAULT_ROW_HEIGHT = 28;
|
||||||
|
|
||||||
test('Frozen rows and columns', () => {
|
test('Frozen rows and columns', () => {
|
||||||
let model = new Model('Workbook1', 'en', 'UTC');
|
let model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
assert.strictEqual(model.getFrozenRowsCount(0), 0);
|
assert.strictEqual(model.getFrozenRowsCount(0), 0);
|
||||||
assert.strictEqual(model.getFrozenColumnsCount(0), 0);
|
assert.strictEqual(model.getFrozenColumnsCount(0), 0);
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ test('Frozen rows and columns', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Row height', () => {
|
test('Row height', () => {
|
||||||
let model = new Model('Workbook1', 'en', 'UTC');
|
let model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
assert.strictEqual(model.getRowHeight(0, 3), DEFAULT_ROW_HEIGHT);
|
assert.strictEqual(model.getRowHeight(0, 3), DEFAULT_ROW_HEIGHT);
|
||||||
|
|
||||||
model.setRowsHeight(0, 3, 3, 32);
|
model.setRowsHeight(0, 3, 3, 32);
|
||||||
@@ -34,7 +34,7 @@ test('Row height', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Evaluates correctly', (t) => {
|
test('Evaluates correctly', (t) => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 1, 1, "23");
|
model.setUserInput(0, 1, 1, "23");
|
||||||
model.setUserInput(0, 1, 2, "=A1*3+1");
|
model.setUserInput(0, 1, 2, "=A1*3+1");
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ test('Evaluates correctly', (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Styles work', () => {
|
test('Styles work', () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
let style = model.getCellStyle(0, 1, 1);
|
let style = model.getCellStyle(0, 1, 1);
|
||||||
assert.deepEqual(style, {
|
assert.deepEqual(style, {
|
||||||
num_fmt: 'general',
|
num_fmt: 'general',
|
||||||
@@ -76,7 +76,7 @@ test('Styles work', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Add sheets", (t) => {
|
test("Add sheets", (t) => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.newSheet();
|
model.newSheet();
|
||||||
model.renameSheet(1, "NewName");
|
model.renameSheet(1, "NewName");
|
||||||
let props = model.getWorksheetsProperties();
|
let props = model.getWorksheetsProperties();
|
||||||
@@ -94,7 +94,7 @@ test("Add sheets", (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("invalid sheet index throws an exception", () => {
|
test("invalid sheet index throws an exception", () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
model.setRowsHeight(1, 1, 1, 100);
|
model.setRowsHeight(1, 1, 1, 100);
|
||||||
}, {
|
}, {
|
||||||
@@ -104,7 +104,7 @@ test("invalid sheet index throws an exception", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("invalid column throws an exception", () => {
|
test("invalid column throws an exception", () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
model.setRowsHeight(0, -1, 0, 100);
|
model.setRowsHeight(0, -1, 0, 100);
|
||||||
}, {
|
}, {
|
||||||
@@ -114,7 +114,7 @@ test("invalid column throws an exception", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("floating column numbers get truncated", () => {
|
test("floating column numbers get truncated", () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setRowsHeight(0.8, 5.2, 5.5, 100.5);
|
model.setRowsHeight(0.8, 5.2, 5.5, 100.5);
|
||||||
|
|
||||||
assert.strictEqual(model.getRowHeight(0.11, 5.99), 100.5);
|
assert.strictEqual(model.getRowHeight(0.11, 5.99), 100.5);
|
||||||
@@ -122,7 +122,7 @@ test("floating column numbers get truncated", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("autofill", () => {
|
test("autofill", () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 1, 1, "23");
|
model.setUserInput(0, 1, 1, "23");
|
||||||
model.autoFillRows({sheet: 0, row: 1, column: 1, width: 1, height: 1}, 2);
|
model.autoFillRows({sheet: 0, row: 1, column: 1, width: 1, height: 1}, 2);
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ test("autofill", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('insertRows shifts cells', () => {
|
test('insertRows shifts cells', () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 1, 1, '42');
|
model.setUserInput(0, 1, 1, '42');
|
||||||
model.insertRows(0, 1, 1);
|
model.insertRows(0, 1, 1);
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ test('insertRows shifts cells', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('insertColumns shifts cells', () => {
|
test('insertColumns shifts cells', () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 1, 1, 'A');
|
model.setUserInput(0, 1, 1, 'A');
|
||||||
model.setUserInput(0, 1, 2, 'B');
|
model.setUserInput(0, 1, 2, 'B');
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ test('insertColumns shifts cells', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('deleteRows removes cells', () => {
|
test('deleteRows removes cells', () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 1, 1, '1');
|
model.setUserInput(0, 1, 1, '1');
|
||||||
model.setUserInput(0, 2, 1, '2');
|
model.setUserInput(0, 2, 1, '2');
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ test('deleteRows removes cells', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('deleteColumns removes cells', () => {
|
test('deleteColumns removes cells', () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 1, 1, 'A');
|
model.setUserInput(0, 1, 1, 'A');
|
||||||
model.setUserInput(0, 1, 2, 'B');
|
model.setUserInput(0, 1, 2, 'B');
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ test('deleteColumns removes cells', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("move row", () => {
|
test("move row", () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 3, 5, "=G3");
|
model.setUserInput(0, 3, 5, "=G3");
|
||||||
model.setUserInput(0, 4, 5, "=G4");
|
model.setUserInput(0, 4, 5, "=G4");
|
||||||
model.setUserInput(0, 5, 5, "=SUM(G3:J3)");
|
model.setUserInput(0, 5, 5, "=SUM(G3:J3)");
|
||||||
@@ -192,7 +192,7 @@ test("move row", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("move column", () => {
|
test("move column", () => {
|
||||||
const model = new Model('Workbook1', 'en', 'UTC');
|
const model = new Model('Workbook1', 'en', 'UTC', 'en');
|
||||||
model.setUserInput(0, 3, 5, "=G3");
|
model.setUserInput(0, 3, 5, "=G3");
|
||||||
model.setUserInput(0, 4, 5, "=H3");
|
model.setUserInput(0, 4, 5, "=H3");
|
||||||
model.setUserInput(0, 5, 5, "=SUM(G3:J7)");
|
model.setUserInput(0, 5, 5, "=SUM(G3:J7)");
|
||||||
|
|||||||
183
generate_locale/Cargo.lock
generated
183
generate_locale/Cargo.lock
generated
@@ -1,6 +1,12 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arrayvec"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
@@ -15,9 +21,33 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitcode"
|
||||||
|
version = "0.6.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "648bd963d2e5d465377acecfb4b827f9f553b6bc97a8f61715779e9ed9e52b74"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
|
"bitcode_derive",
|
||||||
|
"bytemuck",
|
||||||
|
"glam",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitcode_derive"
|
||||||
|
version = "0.6.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ffebfc2d28a12b262c303cb3860ee77b91bd83b1f20f0bd2a9693008e2f55a9e"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.111",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
@@ -26,10 +56,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "bytemuck"
|
||||||
version = "3.2.22"
|
version = "1.24.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
|
checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "3.2.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
@@ -44,15 +80,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "3.2.18"
|
version = "3.2.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -68,11 +104,18 @@ dependencies = [
|
|||||||
name = "generate_locale"
|
name = "generate_locale"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bitcode",
|
||||||
"clap",
|
"clap",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glam"
|
||||||
|
version = "0.30.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd47b05dddf0005d850e5644cae7f2b14ac3df487979dbfff3b56f20b1a6ae46"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
@@ -81,9 +124,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
@@ -96,9 +139,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.9.1"
|
version = "1.9.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@@ -106,27 +149,33 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.3"
|
version = "1.0.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.132"
|
version = "0.2.177"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
|
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.14.0"
|
version = "1.21.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_str_bytes"
|
name = "os_str_bytes"
|
||||||
version = "6.3.0"
|
version = "6.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
|
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-error"
|
name = "proc-macro-error"
|
||||||
@@ -137,7 +186,7 @@ dependencies = [
|
|||||||
"proc-macro-error-attr",
|
"proc-macro-error-attr",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -154,57 +203,69 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.43"
|
version = "1.0.103"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
|
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.21"
|
version = "1.0.42"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
|
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.11"
|
version = "1.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.144"
|
version = "1.0.228"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
|
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||||
|
dependencies = [
|
||||||
|
"serde_core",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_core"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.144"
|
version = "1.0.228"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
|
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.111",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.85"
|
version = "1.0.145"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
|
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
|
"memchr",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -215,9 +276,20 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.100"
|
version = "1.0.109"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e"
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.111"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -226,30 +298,30 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termcolor"
|
name = "termcolor"
|
||||||
version = "1.1.3"
|
version = "1.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textwrap"
|
name = "textwrap"
|
||||||
version = "0.15.1"
|
version = "0.16.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
|
checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.4"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
|
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
@@ -269,11 +341,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-util"
|
name = "winapi-util"
|
||||||
version = "0.1.5"
|
version = "0.1.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -281,3 +353,18 @@ name = "winapi-x86_64-pc-windows-gnu"
|
|||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.61.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|||||||
@@ -10,3 +10,5 @@ edition = "2021"
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
clap = { version = "3.2.22", features = ["derive"] }
|
clap = { version = "3.2.22", features = ["derive"] }
|
||||||
|
bitcode = "0.6.3"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
[
|
[
|
||||||
"en", "en-GB", "de", "es"
|
"en", "en-GB", "de", "es", "fr"
|
||||||
]
|
]
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
|
use bitcode::Encode;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub const LOCAL_TYPE: &str = "modern"; // or "full"
|
pub const LOCAL_TYPE: &str = "full"; // or "modern"
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
pub struct Locale {
|
pub struct Locale {
|
||||||
pub dates: Dates,
|
pub dates: Dates,
|
||||||
pub numbers: NumbersProperties,
|
pub numbers: NumbersProperties,
|
||||||
pub currency: Currency
|
pub currency: Currency,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
pub struct Currency {
|
pub struct Currency {
|
||||||
pub iso: String,
|
pub iso: String,
|
||||||
pub symbol: String,
|
pub symbol: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Encode, Clone)]
|
||||||
pub struct NumbersProperties {
|
pub struct NumbersProperties {
|
||||||
#[serde(rename = "symbols-numberSystem-latn")]
|
#[serde(rename = "symbols-numberSystem-latn")]
|
||||||
pub symbols: NumbersSymbols,
|
pub symbols: NumbersSymbols,
|
||||||
@@ -25,16 +26,19 @@ pub struct NumbersProperties {
|
|||||||
pub currency_formats: CurrencyFormats,
|
pub currency_formats: CurrencyFormats,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
pub struct Dates {
|
pub struct Dates {
|
||||||
pub day_names: Vec<String>,
|
pub day_names: Vec<String>,
|
||||||
pub day_names_short: Vec<String>,
|
pub day_names_short: Vec<String>,
|
||||||
pub months: Vec<String>,
|
pub months: Vec<String>,
|
||||||
pub months_short: Vec<String>,
|
pub months_short: Vec<String>,
|
||||||
pub months_letter: Vec<String>,
|
pub months_letter: Vec<String>,
|
||||||
|
pub date_formats: DateFormats,
|
||||||
|
pub time_formats: DateFormats,
|
||||||
|
pub date_time_formats: DateFormats,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Encode, Clone)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct NumbersSymbols {
|
pub struct NumbersSymbols {
|
||||||
pub decimal: String,
|
pub decimal: String,
|
||||||
@@ -52,10 +56,8 @@ pub struct NumbersSymbols {
|
|||||||
pub time_separator: String,
|
pub time_separator: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// See: https://cldr.unicode.org/translation/number-currency-formats/number-and-currency-patterns
|
// See: https://cldr.unicode.org/translation/number-currency-formats/number-and-currency-patterns
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Encode, Clone)]
|
||||||
pub struct CurrencyFormats {
|
pub struct CurrencyFormats {
|
||||||
pub standard: String,
|
pub standard: String,
|
||||||
#[serde(rename = "standard-alphaNextToNumber")]
|
#[serde(rename = "standard-alphaNextToNumber")]
|
||||||
@@ -71,8 +73,16 @@ pub struct CurrencyFormats {
|
|||||||
pub accounting_no_currency: String,
|
pub accounting_no_currency: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Encode, Clone)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct DecimalFormats {
|
pub struct DecimalFormats {
|
||||||
pub standard: String,
|
pub standard: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Encode, Clone)]
|
||||||
|
pub struct DateFormats {
|
||||||
|
full: String,
|
||||||
|
long: String,
|
||||||
|
medium: String,
|
||||||
|
short: String,
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,37 +1,43 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use bitcode::Encode;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
|
||||||
|
|
||||||
use crate::constants::{Dates, LOCAL_TYPE};
|
use crate::constants::{DateFormats, Dates, LOCAL_TYPE};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGCalendarsFormat {
|
struct CaGCalendarsFormat {
|
||||||
format: HashMap<String, HashMap<String, String>>,
|
format: HashMap<String, HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGCalendarsII {
|
struct CaGCalendarsII {
|
||||||
months: CaGCalendarsFormat,
|
months: CaGCalendarsFormat,
|
||||||
days: CaGCalendarsFormat,
|
days: CaGCalendarsFormat,
|
||||||
|
#[serde(rename = "dateFormats")]
|
||||||
|
date_formats: DateFormats,
|
||||||
|
#[serde(rename = "timeFormats")]
|
||||||
|
time_formats: DateFormats,
|
||||||
|
#[serde(rename = "dateTimeFormats")]
|
||||||
|
date_time_formats: DateFormats,
|
||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGCalendarsI {
|
struct CaGCalendarsI {
|
||||||
gregorian: CaGCalendarsII,
|
gregorian: CaGCalendarsII,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGCalendars {
|
struct CaGCalendars {
|
||||||
calendars: CaGCalendarsI,
|
calendars: CaGCalendarsI,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGId {
|
struct CaGId {
|
||||||
identity: Value,
|
// identity: Value,
|
||||||
dates: CaGCalendars,
|
dates: CaGCalendars,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGregorian {
|
struct CaGregorian {
|
||||||
main: HashMap<String, CaGId>,
|
main: HashMap<String, CaGId>,
|
||||||
}
|
}
|
||||||
@@ -42,6 +48,7 @@ pub fn get_dates_formatting(cldr_dir: &str, locale_id: &str) -> Result<Dates, &'
|
|||||||
cldr_dir, LOCAL_TYPE, locale_id
|
cldr_dir, LOCAL_TYPE, locale_id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
println!("Reading dates from file: {}", calendar_file);
|
||||||
let contents =
|
let contents =
|
||||||
fs::read_to_string(calendar_file).or(Err("Failed reading 'ca-gregorian' file"))?;
|
fs::read_to_string(calendar_file).or(Err("Failed reading 'ca-gregorian' file"))?;
|
||||||
let ca_gregorian: CaGregorian =
|
let ca_gregorian: CaGregorian =
|
||||||
@@ -51,6 +58,7 @@ pub fn get_dates_formatting(cldr_dir: &str, locale_id: &str) -> Result<Dates, &'
|
|||||||
// for the difference between stand-alone and format. We will use only the format mode
|
// for the difference between stand-alone and format. We will use only the format mode
|
||||||
let months_format = &gregorian.months.format;
|
let months_format = &gregorian.months.format;
|
||||||
let days_format = &gregorian.days.format;
|
let days_format = &gregorian.days.format;
|
||||||
|
|
||||||
let mut day_names = vec![];
|
let mut day_names = vec![];
|
||||||
let mut day_names_short = vec![];
|
let mut day_names_short = vec![];
|
||||||
|
|
||||||
@@ -79,5 +87,8 @@ pub fn get_dates_formatting(cldr_dir: &str, locale_id: &str) -> Result<Dates, &'
|
|||||||
months,
|
months,
|
||||||
months_short,
|
months_short,
|
||||||
months_letter,
|
months_letter,
|
||||||
|
date_formats: gregorian.date_formats.clone(),
|
||||||
|
time_formats: gregorian.time_formats.clone(),
|
||||||
|
date_time_formats: gregorian.date_time_formats.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::{collections::HashMap, io::Write, path::PathBuf};
|
use std::{collections::HashMap, io::Write, path::PathBuf};
|
||||||
|
|
||||||
use constants::{Locale, Currency};
|
use constants::{Currency, Locale};
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use numbers::get_numbers_formatting;
|
use numbers::get_numbers_formatting;
|
||||||
@@ -34,8 +34,13 @@ fn main() -> Result<(), String> {
|
|||||||
let opt = Opt::from_args();
|
let opt = Opt::from_args();
|
||||||
let cldr_dir = opt.cldr_dir;
|
let cldr_dir = opt.cldr_dir;
|
||||||
let locales_list: Vec<String> = if let Some(locales_path) = opt.locales {
|
let locales_list: Vec<String> = if let Some(locales_path) = opt.locales {
|
||||||
let contents = fs::read_to_string(locales_path).or(Err("Failed reading file"))?;
|
let locales_path_str = locales_path.display().to_string();
|
||||||
serde_json::from_str(&contents).or(Err("Failed parsing file"))?
|
let contents = fs::read_to_string(locales_path)
|
||||||
|
.or(Err(format!("Failed reading file: {}", locales_path_str)))?;
|
||||||
|
serde_json::from_str(&contents).or(Err(format!(
|
||||||
|
"Failed parsing locales file: {}",
|
||||||
|
locales_path_str
|
||||||
|
)))?
|
||||||
} else {
|
} else {
|
||||||
get_all_locales_id(&cldr_dir)
|
get_all_locales_id(&cldr_dir)
|
||||||
};
|
};
|
||||||
@@ -49,13 +54,27 @@ fn main() -> Result<(), String> {
|
|||||||
// We just stick here one and make this adaptable in the calc module for now
|
// We just stick here one and make this adaptable in the calc module for now
|
||||||
let currency = Currency {
|
let currency = Currency {
|
||||||
iso: "USD".to_string(),
|
iso: "USD".to_string(),
|
||||||
symbol: "$".to_string()
|
symbol: "$".to_string(),
|
||||||
};
|
};
|
||||||
locales.insert(locale_id, Locale { dates, numbers, currency });
|
locales.insert(
|
||||||
|
locale_id,
|
||||||
|
Locale {
|
||||||
|
dates,
|
||||||
|
numbers,
|
||||||
|
currency,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let s = serde_json::to_string(&locales).or(Err("Failed to stringify data"))?;
|
let s = serde_json::to_string(&locales).or(Err("Failed to stringify data"))?;
|
||||||
let mut f = fs::File::create(opt.output).or(Err("Failed to create file"))?;
|
let mut f = fs::File::create(opt.output).or(Err("Failed to create file"))?;
|
||||||
f.write_all(s.as_bytes()).or(Err("Failed writing"))?;
|
f.write_all(s.as_bytes()).or(Err("Failed writing"))?;
|
||||||
|
|
||||||
|
// save to locales.bin using bitcode
|
||||||
|
let bytes = bitcode::encode(&locales);
|
||||||
|
let mut f_bin = fs::File::create("locales.bin").or(Err("Failed to create locales.bin"))?;
|
||||||
|
f_bin
|
||||||
|
.write_all(&bytes)
|
||||||
|
.or(Err("Failed writing locales.bin"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,29 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use bitcode::Encode;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::constants::{NumbersProperties, LOCAL_TYPE};
|
use crate::constants::{NumbersProperties, LOCAL_TYPE};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGCalendarsFormat {
|
struct CaGCalendarsFormat {
|
||||||
format: HashMap<String, HashMap<String, String>>,
|
format: HashMap<String, HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct CaGCalendarsII {
|
struct CaGCalendarsII {
|
||||||
months: CaGCalendarsFormat,
|
months: CaGCalendarsFormat,
|
||||||
days: CaGCalendarsFormat,
|
days: CaGCalendarsFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct NumbersJSONId {
|
struct NumbersJSONId {
|
||||||
identity: Value,
|
// identity: Value,
|
||||||
numbers: NumbersProperties,
|
numbers: NumbersProperties,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Encode)]
|
||||||
struct NumbersJSON {
|
struct NumbersJSON {
|
||||||
main: HashMap<String, NumbersJSONId>,
|
main: HashMap<String, NumbersJSONId>,
|
||||||
}
|
}
|
||||||
|
|||||||
1446
webapp/IronCalc/package-lock.json
generated
1446
webapp/IronCalc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -204,7 +204,9 @@ const MenuDivider = styled("div")`
|
|||||||
border-top: 1px solid #eeeeee;
|
border-top: 1px solid #eeeeee;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const CheckIcon = styled(Check)<{ $active: boolean }>`
|
const CheckIcon = styled(Check, {
|
||||||
|
shouldForwardProp: (prop) => prop !== "$active",
|
||||||
|
})<{ $active: boolean }>`
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
color: ${(props) => (props.$active ? "currentColor" : "transparent")};
|
color: ${(props) => (props.$active ? "currentColor" : "transparent")};
|
||||||
|
|||||||
@@ -301,7 +301,9 @@ const TabWrapper = styled("div")<{ $color: string; $selected: boolean }>`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledButton = styled(Button)<{ $active: boolean }>`
|
const StyledButton = styled(Button, {
|
||||||
|
shouldForwardProp: (prop) => prop !== "$active",
|
||||||
|
})<{ $active: boolean }>`
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
min-width: 0px;
|
min-width: 0px;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import type { WorkbookState } from "../workbookState";
|
|||||||
import SheetListMenu from "./SheetListMenu";
|
import SheetListMenu from "./SheetListMenu";
|
||||||
import SheetTab from "./SheetTab";
|
import SheetTab from "./SheetTab";
|
||||||
import type { SheetOptions } from "./types";
|
import type { SheetOptions } from "./types";
|
||||||
|
import { Model } from "@ironcalc/wasm";
|
||||||
|
|
||||||
export interface SheetTabBarProps {
|
export interface SheetTabBarProps {
|
||||||
sheets: SheetOptions[];
|
sheets: SheetOptions[];
|
||||||
@@ -22,9 +23,12 @@ export interface SheetTabBarProps {
|
|||||||
onSheetRenamed: (name: string) => void;
|
onSheetRenamed: (name: string) => void;
|
||||||
onSheetDeleted: () => void;
|
onSheetDeleted: () => void;
|
||||||
onHideSheet: () => void;
|
onHideSheet: () => void;
|
||||||
onOpenWorkbookSettings: () => void;
|
model: Model;
|
||||||
initialLocale: string;
|
onSettingsChange: (
|
||||||
initialTimezone: string;
|
locale: string,
|
||||||
|
timezone: string,
|
||||||
|
language: string,
|
||||||
|
) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SheetTabBar(props: SheetTabBarProps) {
|
function SheetTabBar(props: SheetTabBarProps) {
|
||||||
@@ -105,7 +109,7 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
$pressed={false}
|
$pressed={false}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setWorkbookSettingsOpen(true);
|
setWorkbookSettingsOpen(true);
|
||||||
props.onOpenWorkbookSettings();
|
// props.onOpenWorkbookSettings();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<EllipsisVertical />
|
<EllipsisVertical />
|
||||||
@@ -126,8 +130,12 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
<WorkbookSettingsDialog
|
<WorkbookSettingsDialog
|
||||||
open={workbookSettingsOpen}
|
open={workbookSettingsOpen}
|
||||||
onClose={() => setWorkbookSettingsOpen(false)}
|
onClose={() => setWorkbookSettingsOpen(false)}
|
||||||
initialLocale={props.initialLocale}
|
initialLocale={props.model.getLocale()}
|
||||||
initialTimezone={props.initialTimezone}
|
initialTimezone={ props.model.getTimezone()}
|
||||||
|
initialLanguage={props.model.getLanguage()}
|
||||||
|
onSave={(locale: string, timezone: string, language: string) => {
|
||||||
|
props.onSettingsChange(locale, timezone, language);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -736,6 +736,17 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
|
|||||||
model.hideSheet(selectedSheet);
|
model.hideSheet(selectedSheet);
|
||||||
setRedrawId((value) => value + 1);
|
setRedrawId((value) => value + 1);
|
||||||
}}
|
}}
|
||||||
|
onSettingsChange={(
|
||||||
|
locale: string,
|
||||||
|
timezone: string,
|
||||||
|
language: string,
|
||||||
|
) => {
|
||||||
|
model.setLocale(locale);
|
||||||
|
model.setTimezone(timezone);
|
||||||
|
model.setLanguage(language);
|
||||||
|
setRedrawId((id) => id + 1);
|
||||||
|
}}
|
||||||
|
model={model}
|
||||||
/>
|
/>
|
||||||
</WorksheetAreaLeft>
|
</WorksheetAreaLeft>
|
||||||
<RightDrawer
|
<RightDrawer
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import styled from "@emotion/styled";
|
import styled from "@emotion/styled";
|
||||||
|
import { getAllTimezones, getSupportedLocales } from "@ironcalc/wasm";
|
||||||
import {
|
import {
|
||||||
Autocomplete,
|
Autocomplete,
|
||||||
|
type AutocompleteProps,
|
||||||
Box,
|
Box,
|
||||||
Dialog,
|
Dialog,
|
||||||
FormControl,
|
FormControl,
|
||||||
@@ -9,7 +11,7 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { Check, X } from "lucide-react";
|
import { Check, X } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { theme } from "../../theme";
|
import { theme } from "../../theme";
|
||||||
|
|
||||||
@@ -18,49 +20,44 @@ type WorkbookSettingsDialogProps = {
|
|||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
initialLocale: string;
|
initialLocale: string;
|
||||||
initialTimezone: string;
|
initialTimezone: string;
|
||||||
onSave?: (locale: string, timezone: string) => void;
|
initialLanguage: string;
|
||||||
|
onSave: (locale: string, timezone: string, language: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
|
const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const locales = ["en-US", "en-GB", "de-DE", "fr-FR", "es-ES"];
|
const locales = getSupportedLocales();
|
||||||
const timezones = [
|
|
||||||
"Berlin, Germany (GMT+1)",
|
const timezones = getAllTimezones();
|
||||||
"New York, USA (GMT-5)",
|
|
||||||
"Tokyo, Japan (GMT+9)",
|
const [selectedLocale, setSelectedLocale] = useState(
|
||||||
"London, UK (GMT+0)",
|
properties.initialLocale,
|
||||||
"Sydney, Australia (GMT+10)",
|
|
||||||
];
|
|
||||||
const [selectedLocale, setSelectedLocale] = useState<string>(
|
|
||||||
properties.initialLocale && locales.includes(properties.initialLocale)
|
|
||||||
? properties.initialLocale
|
|
||||||
: locales[0],
|
|
||||||
);
|
);
|
||||||
const [selectedTimezone, setSelectedTimezone] = useState<string>(
|
const [selectedTimezone, setSelectedTimezone] = useState(
|
||||||
properties.initialTimezone && timezones.includes(properties.initialTimezone)
|
properties.initialTimezone,
|
||||||
? properties.initialTimezone
|
|
||||||
: timezones[0],
|
|
||||||
);
|
);
|
||||||
|
const [selectedLanguage, setSelectedLanguage] = useState(
|
||||||
|
properties.initialLanguage,
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (properties.open) {
|
||||||
|
setSelectedLocale(properties.initialLocale);
|
||||||
|
setSelectedTimezone(properties.initialTimezone);
|
||||||
|
setSelectedLanguage(properties.initialLanguage);
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
properties.open,
|
||||||
|
properties.initialLocale,
|
||||||
|
properties.initialTimezone,
|
||||||
|
properties.initialLanguage,
|
||||||
|
]);
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
if (properties.onSave && selectedLocale && selectedTimezone) {
|
properties.onSave(selectedLocale, selectedTimezone, selectedLanguage);
|
||||||
properties.onSave(selectedLocale, selectedTimezone);
|
|
||||||
}
|
|
||||||
properties.onClose();
|
properties.onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ensure selectedLocale is always a valid locale
|
|
||||||
const validSelectedLocale =
|
|
||||||
selectedLocale && locales.includes(selectedLocale)
|
|
||||||
? selectedLocale
|
|
||||||
: locales[0];
|
|
||||||
|
|
||||||
// Ensure selectedTimezone is always a valid timezone
|
|
||||||
const validSelectedTimezone =
|
|
||||||
selectedTimezone && timezones.includes(selectedTimezone)
|
|
||||||
? selectedTimezone
|
|
||||||
: timezones[0];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDialog
|
<StyledDialog
|
||||||
open={properties.open}
|
open={properties.open}
|
||||||
@@ -85,10 +82,7 @@ const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
|
|||||||
</Cross>
|
</Cross>
|
||||||
</StyledDialogTitle>
|
</StyledDialogTitle>
|
||||||
|
|
||||||
<StyledDialogContent
|
<StyledDialogContent>
|
||||||
onClick={(event) => event.stopPropagation()}
|
|
||||||
onMouseDown={(event) => event.stopPropagation()}
|
|
||||||
>
|
|
||||||
<StyledSectionTitle>
|
<StyledSectionTitle>
|
||||||
{t("workbook_settings.locale_and_timezone.title")}
|
{t("workbook_settings.locale_and_timezone.title")}
|
||||||
</StyledSectionTitle>
|
</StyledSectionTitle>
|
||||||
@@ -99,7 +93,7 @@ const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
|
|||||||
<FormControl fullWidth>
|
<FormControl fullWidth>
|
||||||
<StyledSelect
|
<StyledSelect
|
||||||
id="locale"
|
id="locale"
|
||||||
value={validSelectedLocale}
|
value={selectedLocale}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
setSelectedLocale(event.target.value as string);
|
setSelectedLocale(event.target.value as string);
|
||||||
}}
|
}}
|
||||||
@@ -113,11 +107,7 @@ const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{locales.map((locale) => (
|
{locales.map((locale) => (
|
||||||
<StyledMenuItem
|
<StyledMenuItem key={locale} value={locale}>
|
||||||
key={locale}
|
|
||||||
value={locale}
|
|
||||||
$isSelected={locale === selectedLocale}
|
|
||||||
>
|
|
||||||
{locale}
|
{locale}
|
||||||
</StyledMenuItem>
|
</StyledMenuItem>
|
||||||
))}
|
))}
|
||||||
@@ -149,18 +139,14 @@ const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
|
|||||||
<FormControl fullWidth>
|
<FormControl fullWidth>
|
||||||
<StyledAutocomplete
|
<StyledAutocomplete
|
||||||
id="timezone"
|
id="timezone"
|
||||||
value={validSelectedTimezone}
|
value={selectedTimezone}
|
||||||
onChange={(_event, newValue) => {
|
onChange={(_event, newValue) => {
|
||||||
setSelectedTimezone((newValue as string) || "");
|
setSelectedTimezone(newValue);
|
||||||
}}
|
}}
|
||||||
options={timezones}
|
options={timezones}
|
||||||
renderInput={(params) => <TextField {...params} />}
|
renderInput={(params) => <TextField {...params} />}
|
||||||
renderOption={(props, option) => (
|
renderOption={(props, option) => (
|
||||||
<StyledMenuItem
|
<StyledMenuItem {...props} key={option as string}>
|
||||||
{...props}
|
|
||||||
key={option as string}
|
|
||||||
$isSelected={option === validSelectedTimezone}
|
|
||||||
>
|
|
||||||
{option as string}
|
{option as string}
|
||||||
</StyledMenuItem>
|
</StyledMenuItem>
|
||||||
)}
|
)}
|
||||||
@@ -193,6 +179,49 @@ const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
|
|||||||
</HelperBox>
|
</HelperBox>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FieldWrapper>
|
</FieldWrapper>
|
||||||
|
<FieldWrapper>
|
||||||
|
<StyledLabel htmlFor="display_language">
|
||||||
|
{t("workbook_settings.locale_and_timezone.display_language_label")}
|
||||||
|
</StyledLabel>
|
||||||
|
<FormControl fullWidth>
|
||||||
|
<StyledSelect
|
||||||
|
id="display_language"
|
||||||
|
value={selectedLanguage}
|
||||||
|
onChange={(event) => {
|
||||||
|
setSelectedLanguage(event.target.value as string);
|
||||||
|
}}
|
||||||
|
MenuProps={{
|
||||||
|
PaperProps: {
|
||||||
|
sx: menuPaperStyles,
|
||||||
|
},
|
||||||
|
TransitionProps: {
|
||||||
|
timeout: 0,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<StyledMenuItem key="en" value="en">
|
||||||
|
{t(
|
||||||
|
"workbook_settings.locale_and_timezone.display_language.english",
|
||||||
|
)}
|
||||||
|
</StyledMenuItem>
|
||||||
|
<StyledMenuItem key="es" value="es">
|
||||||
|
{t(
|
||||||
|
"workbook_settings.locale_and_timezone.display_language.spanish",
|
||||||
|
)}
|
||||||
|
</StyledMenuItem>
|
||||||
|
<StyledMenuItem key="fr" value="fr">
|
||||||
|
{t(
|
||||||
|
"workbook_settings.locale_and_timezone.display_language.french",
|
||||||
|
)}
|
||||||
|
</StyledMenuItem>
|
||||||
|
<StyledMenuItem key="de" value="de">
|
||||||
|
{t(
|
||||||
|
"workbook_settings.locale_and_timezone.display_language.german",
|
||||||
|
)}
|
||||||
|
</StyledMenuItem>
|
||||||
|
</StyledSelect>
|
||||||
|
</FormControl>
|
||||||
|
</FieldWrapper>
|
||||||
</StyledDialogContent>
|
</StyledDialogContent>
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
@@ -317,7 +346,15 @@ const RowValue = styled("span")`
|
|||||||
color: ${theme.palette.grey[500]};
|
color: ${theme.palette.grey[500]};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledAutocomplete = styled(Autocomplete)`
|
// Autocomplete with customized styles
|
||||||
|
// Value => string,
|
||||||
|
// multiple => false, (we cannot select multiple timezones)
|
||||||
|
// disableClearable => true, (the timezone must always have a value)
|
||||||
|
// freeSolo => false (the timezone must be from the list)
|
||||||
|
type TimezoneAutocompleteProps = AutocompleteProps<string, false, true, false>;
|
||||||
|
const StyledAutocomplete = styled((props: TimezoneAutocompleteProps) => (
|
||||||
|
<Autocomplete<string, false, true, false> {...props} />
|
||||||
|
))`
|
||||||
& .MuiInputBase-root {
|
& .MuiInputBase-root {
|
||||||
padding: 0px !important;
|
padding: 0px !important;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
@@ -369,7 +406,7 @@ const menuPaperStyles = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledMenuItem = styled(MenuItem)<{ $isSelected?: boolean }>`
|
const StyledMenuItem = styled(MenuItem)`
|
||||||
padding: 8px !important;
|
padding: 8px !important;
|
||||||
height: 32px !important;
|
height: 32px !important;
|
||||||
min-height: 32px !important;
|
min-height: 32px !important;
|
||||||
@@ -377,8 +414,15 @@ const StyledMenuItem = styled(MenuItem)<{ $isSelected?: boolean }>`
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
background-color: ${({ $isSelected }) =>
|
|
||||||
$isSelected ? theme.palette.grey[50] : "transparent"} !important;
|
&.Mui-selected {
|
||||||
|
background-color: ${theme.palette.grey[50]} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.Mui-selected:hover {
|
||||||
|
background-color: ${theme.palette.grey[50]} !important;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: ${theme.palette.grey[50]} !important;
|
background-color: ${theme.palette.grey[50]} !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { expect, test } from "vitest";
|
|||||||
test("simple calculation", async () => {
|
test("simple calculation", async () => {
|
||||||
const buffer = await readFile("node_modules/@ironcalc/wasm/wasm_bg.wasm");
|
const buffer = await readFile("node_modules/@ironcalc/wasm/wasm_bg.wasm");
|
||||||
initSync(buffer);
|
initSync(buffer);
|
||||||
const model = new Model("workbook", "en", "UTC");
|
const model = new Model("workbook", "en", "UTC", "en");
|
||||||
model.setUserInput(0, 1, 1, "=21*2");
|
model.setUserInput(0, 1, 1, "=21*2");
|
||||||
expect(model.getFormattedCellValue(0, 1, 1)).toBe("42");
|
expect(model.getFormattedCellValue(0, 1, 1)).toBe("42");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -181,7 +181,14 @@
|
|||||||
"locale_example4": "First day of the week",
|
"locale_example4": "First day of the week",
|
||||||
"timezone_label": "Timezone",
|
"timezone_label": "Timezone",
|
||||||
"timezone_example1": "TODAY()",
|
"timezone_example1": "TODAY()",
|
||||||
"timezone_example2": "NOW()"
|
"timezone_example2": "NOW()",
|
||||||
|
"display_language_label": "Display language",
|
||||||
|
"display_language": {
|
||||||
|
"english": "English",
|
||||||
|
"spanish": "Spanish",
|
||||||
|
"french": "French",
|
||||||
|
"german": "German"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const Workbook = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function start() {
|
async function start() {
|
||||||
await init();
|
await init();
|
||||||
setModel(new Model("Workbook1", "en", "UTC"));
|
setModel(new Model("Workbook1", "en", "UTC", "en"));
|
||||||
}
|
}
|
||||||
start();
|
start();
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
6
webapp/app.ironcalc.com/frontend/deploy_testing.sh
Executable file
6
webapp/app.ironcalc.com/frontend/deploy_testing.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
set -e
|
||||||
|
rm -rf dist/*
|
||||||
|
npm run build
|
||||||
|
cd dist/assets && brotli wasm* && brotli index-*
|
||||||
|
cd ..
|
||||||
|
scp -r * app.ironcalc.com:~/testing/
|
||||||
352
webapp/app.ironcalc.com/frontend/package-lock.json
generated
352
webapp/app.ironcalc.com/frontend/package-lock.json
generated
@@ -91,7 +91,6 @@
|
|||||||
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
|
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.27.1",
|
"@babel/code-frame": "^7.27.1",
|
||||||
"@babel/generator": "^7.28.5",
|
"@babel/generator": "^7.28.5",
|
||||||
@@ -571,7 +570,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.14.0.tgz",
|
"resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.14.0.tgz",
|
||||||
"integrity": "sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==",
|
"integrity": "sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.3",
|
"@babel/runtime": "^7.18.3",
|
||||||
"@emotion/babel-plugin": "^11.13.5",
|
"@emotion/babel-plugin": "^11.13.5",
|
||||||
@@ -615,7 +613,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.14.1.tgz",
|
"resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.14.1.tgz",
|
||||||
"integrity": "sha512-qEEJt42DuToa3gurlH4Qqc1kVpNq8wO8cJtDzU46TjlzWjDlsVyevtYCRijVq3SrHsROS+gVQ8Fnea108GnKzw==",
|
"integrity": "sha512-qEEJt42DuToa3gurlH4Qqc1kVpNq8wO8cJtDzU46TjlzWjDlsVyevtYCRijVq3SrHsROS+gVQ8Fnea108GnKzw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.3",
|
"@babel/runtime": "^7.18.3",
|
||||||
"@emotion/babel-plugin": "^11.13.5",
|
"@emotion/babel-plugin": "^11.13.5",
|
||||||
@@ -1154,9 +1151,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/core-downloads-tracker": {
|
"node_modules/@mui/core-downloads-tracker": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-7.3.6.tgz",
|
||||||
"integrity": "sha512-kOLwlcDPnVz2QMhiBv0OQ8le8hTCqKM9cRXlfVPL91l3RGeOsxrIhNRsUt3Xb8wb+pTVUolW+JXKym93vRKxCw==",
|
"integrity": "sha512-QaYtTHlr8kDFN5mE1wbvVARRKH7Fdw1ZuOjBJcFdVpfNfRYKF3QLT4rt+WaB6CKJvpqxRsmEo0kpYinhH5GeHg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@@ -1164,16 +1161,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/material": {
|
"node_modules/@mui/material": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/material/-/material-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/material/-/material-7.3.6.tgz",
|
||||||
"integrity": "sha512-8VVxFmp1GIm9PpmnQoCoYo0UWHoOrdA57tDL62vkpzEgvb/d71Wsbv4FRg7r1Gyx7PuSo0tflH34cdl/NvfHNQ==",
|
"integrity": "sha512-R4DaYF3dgCQCUAkr4wW1w26GHXcf5rCmBRHVBuuvJvaGLmZdD8EjatP80Nz5JCw0KxORAzwftnHzXVnjR8HnFw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.28.4",
|
"@babel/runtime": "^7.28.4",
|
||||||
"@mui/core-downloads-tracker": "^7.3.5",
|
"@mui/core-downloads-tracker": "^7.3.6",
|
||||||
"@mui/system": "^7.3.5",
|
"@mui/system": "^7.3.6",
|
||||||
"@mui/types": "^7.4.8",
|
"@mui/types": "^7.4.9",
|
||||||
"@mui/utils": "^7.3.5",
|
"@mui/utils": "^7.3.6",
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@types/react-transition-group": "^4.4.12",
|
"@types/react-transition-group": "^4.4.12",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
@@ -1192,7 +1189,7 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@emotion/react": "^11.5.0",
|
"@emotion/react": "^11.5.0",
|
||||||
"@emotion/styled": "^11.3.0",
|
"@emotion/styled": "^11.3.0",
|
||||||
"@mui/material-pigment-css": "^7.3.5",
|
"@mui/material-pigment-css": "^7.3.6",
|
||||||
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||||
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||||
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||||
@@ -1213,13 +1210,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/private-theming": {
|
"node_modules/@mui/private-theming": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-7.3.6.tgz",
|
||||||
"integrity": "sha512-cTx584W2qrLonwhZLbEN7P5pAUu0nZblg8cLBlTrZQ4sIiw8Fbvg7GvuphQaSHxPxrCpa7FDwJKtXdbl2TSmrA==",
|
"integrity": "sha512-Ws9wZpqM+FlnbZXaY/7yvyvWQo1+02Tbx50mVdNmzWEi51C51y56KAbaDCYyulOOBL6BJxuaqG8rNNuj7ivVyw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.28.4",
|
"@babel/runtime": "^7.28.4",
|
||||||
"@mui/utils": "^7.3.5",
|
"@mui/utils": "^7.3.6",
|
||||||
"prop-types": "^15.8.1"
|
"prop-types": "^15.8.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -1240,9 +1237,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/styled-engine": {
|
"node_modules/@mui/styled-engine": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-7.3.6.tgz",
|
||||||
"integrity": "sha512-zbsZ0uYYPndFCCPp2+V3RLcAN6+fv4C8pdwRx6OS3BwDkRCN8WBehqks7hWyF3vj1kdQLIWrpdv/5Y0jHRxYXQ==",
|
"integrity": "sha512-+wiYbtvj+zyUkmDB+ysH6zRjuQIJ+CM56w0fEXV+VDNdvOuSywG+/8kpjddvvlfMLsaWdQe5oTuYGBcodmqGzQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.28.4",
|
"@babel/runtime": "^7.28.4",
|
||||||
@@ -1274,16 +1271,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/system": {
|
"node_modules/@mui/system": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/system/-/system-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/system/-/system-7.3.6.tgz",
|
||||||
"integrity": "sha512-yPaf5+gY3v80HNkJcPi6WT+r9ebeM4eJzrREXPxMt7pNTV/1eahyODO4fbH3Qvd8irNxDFYn5RQ3idHW55rA6g==",
|
"integrity": "sha512-8fehAazkHNP1imMrdD2m2hbA9sl7Ur6jfuNweh5o4l9YPty4iaZzRXqYvBCWQNwFaSHmMEj2KPbyXGp7Bt73Rg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.28.4",
|
"@babel/runtime": "^7.28.4",
|
||||||
"@mui/private-theming": "^7.3.5",
|
"@mui/private-theming": "^7.3.6",
|
||||||
"@mui/styled-engine": "^7.3.5",
|
"@mui/styled-engine": "^7.3.6",
|
||||||
"@mui/types": "^7.4.8",
|
"@mui/types": "^7.4.9",
|
||||||
"@mui/utils": "^7.3.5",
|
"@mui/utils": "^7.3.6",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"csstype": "^3.1.3",
|
"csstype": "^3.1.3",
|
||||||
"prop-types": "^15.8.1"
|
"prop-types": "^15.8.1"
|
||||||
@@ -1314,9 +1311,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/types": {
|
"node_modules/@mui/types": {
|
||||||
"version": "7.4.8",
|
"version": "7.4.9",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/types/-/types-7.4.8.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/types/-/types-7.4.9.tgz",
|
||||||
"integrity": "sha512-ZNXLBjkPV6ftLCmmRCafak3XmSn8YV0tKE/ZOhzKys7TZXUiE0mZxlH8zKDo6j6TTUaDnuij68gIG+0Ucm7Xhw==",
|
"integrity": "sha512-dNO8Z9T2cujkSIaCnWwprfeKmTWh97cnjkgmpFJ2sbfXLx8SMZijCYHOtP/y5nnUb/Rm2omxbDMmtUoSaUtKaw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.28.4"
|
"@babel/runtime": "^7.28.4"
|
||||||
@@ -1331,13 +1328,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/utils": {
|
"node_modules/@mui/utils": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/utils/-/utils-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/utils/-/utils-7.3.6.tgz",
|
||||||
"integrity": "sha512-jisvFsEC3sgjUjcPnR4mYfhzjCDIudttSGSbe1o/IXFNu0kZuR+7vqQI0jg8qtcVZBHWrwTfvAZj9MNMumcq1g==",
|
"integrity": "sha512-jn+Ba02O6PiFs7nKva8R2aJJ9kJC+3kQ2R0BbKNY3KQQ36Qng98GnPRFTlbwYTdMD6hLEBKaMLUktyg/rTfd2w==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.28.4",
|
"@babel/runtime": "^7.28.4",
|
||||||
"@mui/types": "^7.4.8",
|
"@mui/types": "^7.4.9",
|
||||||
"@types/prop-types": "^15.7.15",
|
"@types/prop-types": "^15.7.15",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
@@ -1401,9 +1398,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.3.tgz",
|
||||||
"integrity": "sha512-yDPzwsgiFO26RJA4nZo8I+xqzh7sJTZIWQOxn+/XOdPE31lAvLIYCKqjV+lNH/vxE2L2iH3plKxDCRK6i+CwhA==",
|
"integrity": "sha512-mRSi+4cBjrRLoaal2PnqH82Wqyb+d3HsPUN/W+WslCXsZsyHa9ZeQQX/pQsZaVIWDkPcpV6jJ+3KLbTbgnwv8w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@@ -1415,9 +1412,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-android-arm64": {
|
"node_modules/@rollup/rollup-android-arm64": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.3.tgz",
|
||||||
"integrity": "sha512-k8FontTxIE7b0/OGKeSN5B6j25EuppBcWM33Z19JoVT7UTXFSo3D9CdU39wGTeb29NO3XxpMNauh09B+Ibw+9g==",
|
"integrity": "sha512-CbDGaMpdE9sh7sCmTrTUyllhrg65t6SwhjlMJsLr+J8YjFuPmCEjbBSx4Z/e4SmDyH3aB5hGaJUP2ltV/vcs4w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1429,9 +1426,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-darwin-arm64": {
|
"node_modules/@rollup/rollup-darwin-arm64": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.3.tgz",
|
||||||
"integrity": "sha512-A6s4gJpomNBtJ2yioj8bflM2oogDwzUiMl2yNJ2v9E7++sHrSrsQ29fOfn5DM/iCzpWcebNYEdXpaK4tr2RhfQ==",
|
"integrity": "sha512-Nr7SlQeqIBpOV6BHHGZgYBuSdanCXuw09hon14MGOLGmXAFYjx1wNvquVPmpZnl0tLjg25dEdr4IQ6GgyToCUA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1443,9 +1440,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-darwin-x64": {
|
"node_modules/@rollup/rollup-darwin-x64": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.3.tgz",
|
||||||
"integrity": "sha512-e6XqVmXlHrBlG56obu9gDRPW3O3hLxpwHpLsBJvuI8qqnsrtSZ9ERoWUXtPOkY8c78WghyPHZdmPhHLWNdAGEw==",
|
"integrity": "sha512-DZ8N4CSNfl965CmPktJ8oBnfYr3F8dTTNBQkRlffnUarJ2ohudQD17sZBa097J8xhQ26AwhHJ5mvUyQW8ddTsQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -1457,9 +1454,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-freebsd-arm64": {
|
"node_modules/@rollup/rollup-freebsd-arm64": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.3.tgz",
|
||||||
"integrity": "sha512-v0E9lJW8VsrwPux5Qe5CwmH/CF/2mQs6xU1MF3nmUxmZUCHazCjLgYvToOk+YuuUqLQBio1qkkREhxhc656ViA==",
|
"integrity": "sha512-yMTrCrK92aGyi7GuDNtGn2sNW+Gdb4vErx4t3Gv/Tr+1zRb8ax4z8GWVRfr3Jw8zJWvpGHNpss3vVlbF58DZ4w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1471,9 +1468,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-freebsd-x64": {
|
"node_modules/@rollup/rollup-freebsd-x64": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.3.tgz",
|
||||||
"integrity": "sha512-ClAmAPx3ZCHtp6ysl4XEhWU69GUB1D+s7G9YjHGhIGCSrsg00nEGRRZHmINYxkdoJehde8VIsDC5t9C0gb6yqA==",
|
"integrity": "sha512-lMfF8X7QhdQzseM6XaX0vbno2m3hlyZFhwcndRMw8fbAGUGL3WFMBdK0hbUBIUYcEcMhVLr1SIamDeuLBnXS+Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -1485,9 +1482,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.3.tgz",
|
||||||
"integrity": "sha512-EPlb95nUsz6Dd9Qy13fI5kUPXNSljaG9FiJ4YUGU1O/Q77i5DYFW5KR8g1OzTcdZUqQQ1KdDqsTohdFVwCwjqg==",
|
"integrity": "sha512-k9oD15soC/Ln6d2Wv/JOFPzZXIAIFLp6B+i14KhxAfnq76ajt0EhYc5YPeX6W1xJkAdItcVT+JhKl1QZh44/qw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@@ -1499,9 +1496,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
|
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.3.tgz",
|
||||||
"integrity": "sha512-BOmnVW+khAUX+YZvNfa0tGTEMVVEerOxN0pDk2E6N6DsEIa2Ctj48FOMfNDdrwinocKaC7YXUZ1pHlKpnkja/Q==",
|
"integrity": "sha512-vTNlKq+N6CK/8UktsrFuc+/7NlEYVxgaEgRXVUVK258Z5ymho29skzW1sutgYjqNnquGwVUObAaxae8rZ6YMhg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@@ -1513,9 +1510,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.3.tgz",
|
||||||
"integrity": "sha512-Xt2byDZ+6OVNuREgBXr4+CZDJtrVso5woFtpKdGPhpTPHcNG7D8YXeQzpNbFRxzTVqJf7kvPMCub/pcGUWgBjA==",
|
"integrity": "sha512-RGrFLWgMhSxRs/EWJMIFM1O5Mzuz3Xy3/mnxJp/5cVhZ2XoCAxJnmNsEyeMJtpK+wu0FJFWz+QF4mjCA7AUQ3w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1527,9 +1524,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.3.tgz",
|
||||||
"integrity": "sha512-+LdZSldy/I9N8+klim/Y1HsKbJ3BbInHav5qE9Iy77dtHC/pibw1SR/fXlWyAk0ThnpRKoODwnAuSjqxFRDHUQ==",
|
"integrity": "sha512-kASyvfBEWYPEwe0Qv4nfu6pNkITLTb32p4yTgzFCocHnJLAHs+9LjUu9ONIhvfT/5lv4YS5muBHyuV84epBo/A==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1541,9 +1538,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-loong64-gnu": {
|
"node_modules/@rollup/rollup-linux-loong64-gnu": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.3.tgz",
|
||||||
"integrity": "sha512-8ms8sjmyc1jWJS6WdNSA23rEfdjWB30LH8Wqj0Cqvv7qSHnvw6kgMMXRdop6hkmGPlyYBdRPkjJnj3KCUHV/uQ==",
|
"integrity": "sha512-JiuKcp2teLJwQ7vkJ95EwESWkNRFJD7TQgYmCnrPtlu50b4XvT5MOmurWNrCj3IFdyjBQ5p9vnrX4JM6I8OE7g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"loong64"
|
"loong64"
|
||||||
],
|
],
|
||||||
@@ -1555,9 +1552,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-ppc64-gnu": {
|
"node_modules/@rollup/rollup-linux-ppc64-gnu": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.3.tgz",
|
||||||
"integrity": "sha512-3HRQLUQbpBDMmzoxPJYd3W6vrVHOo2cVW8RUo87Xz0JPJcBLBr5kZ1pGcQAhdZgX9VV7NbGNipah1omKKe23/g==",
|
"integrity": "sha512-EoGSa8nd6d3T7zLuqdojxC20oBfNT8nexBbB/rkxgKj5T5vhpAQKKnD+h3UkoMuTyXkP5jTjK/ccNRmQrPNDuw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@@ -1569,9 +1566,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.3.tgz",
|
||||||
"integrity": "sha512-fMjKi+ojnmIvhk34gZP94vjogXNNUKMEYs+EDaB/5TG/wUkoeua7p7VCHnE6T2Tx+iaghAqQX8teQzcvrYpaQA==",
|
"integrity": "sha512-4s+Wped2IHXHPnAEbIB0YWBv7SDohqxobiiPA1FIWZpX+w9o2i4LezzH/NkFUl8LRci/8udci6cLq+jJQlh+0g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@@ -1583,9 +1580,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-riscv64-musl": {
|
"node_modules/@rollup/rollup-linux-riscv64-musl": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.3.tgz",
|
||||||
"integrity": "sha512-XuGFGU+VwUUV5kLvoAdi0Wz5Xbh2SrjIxCtZj6Wq8MDp4bflb/+ThZsVxokM7n0pcbkEr2h5/pzqzDYI7cCgLQ==",
|
"integrity": "sha512-68k2g7+0vs2u9CxDt5ktXTngsxOQkSEV/xBbwlqYcUrAVh6P9EgMZvFsnHy4SEiUl46Xf0IObWVbMvPrr2gw8A==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@@ -1597,9 +1594,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.3.tgz",
|
||||||
"integrity": "sha512-w6yjZF0P+NGzWR3AXWX9zc0DNEGdtvykB03uhonSHMRa+oWA6novflo2WaJr6JZakG2ucsyb+rvhrKac6NIy+w==",
|
"integrity": "sha512-VYsFMpULAz87ZW6BVYw3I6sWesGpsP9OPcyKe8ofdg9LHxSbRMd7zrVrr5xi/3kMZtpWL/wC+UIJWJYVX5uTKg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
@@ -1611,9 +1608,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.3.tgz",
|
||||||
"integrity": "sha512-yo8d6tdfdeBArzC7T/PnHd7OypfI9cbuZzPnzLJIyKYFhAQ8SvlkKtKBMbXDxe1h03Rcr7u++nFS7tqXz87Gtw==",
|
"integrity": "sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -1625,9 +1622,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-x64-musl": {
|
"node_modules/@rollup/rollup-linux-x64-musl": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.3.tgz",
|
||||||
"integrity": "sha512-ah59c1YkCxKExPP8O9PwOvs+XRLKwh/mV+3YdKqQ5AMQ0r4M4ZDuOrpWkUaqO7fzAHdINzV9tEVu8vNw48z0lA==",
|
"integrity": "sha512-eoROhjcc6HbZCJr+tvVT8X4fW3/5g/WkGvvmwz/88sDtSJzO7r/blvoBDgISDiCjDRZmHpwud7h+6Q9JxFwq1Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -1639,9 +1636,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-openharmony-arm64": {
|
"node_modules/@rollup/rollup-openharmony-arm64": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.3.tgz",
|
||||||
"integrity": "sha512-4VEd19Wmhr+Zy7hbUsFZ6YXEiP48hE//KPLCSVNY5RMGX2/7HZ+QkN55a3atM1C/BZCGIgqN+xrVgtdak2S9+A==",
|
"integrity": "sha512-OueLAWgrNSPGAdUdIjSWXw+u/02BRTcnfw9PN41D2vq/JSEPnJnVuBgw18VkN8wcd4fjUs+jFHVM4t9+kBSNLw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1653,9 +1650,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.3.tgz",
|
||||||
"integrity": "sha512-IlbHFYc/pQCgew/d5fslcy1KEaYVCJ44G8pajugd8VoOEI8ODhtb/j8XMhLpwHCMB3yk2J07ctup10gpw2nyMA==",
|
"integrity": "sha512-GOFuKpsxR/whszbF/bzydebLiXIHSgsEUp6M0JI8dWvi+fFa1TD6YQa4aSZHtpmh2/uAlj/Dy+nmby3TJ3pkTw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1667,9 +1664,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.3.tgz",
|
||||||
"integrity": "sha512-lNlPEGgdUfSzdCWU176ku/dQRnA7W+Gp8d+cWv73jYrb8uT7HTVVxq62DUYxjbaByuf1Yk0RIIAbDzp+CnOTFg==",
|
"integrity": "sha512-iah+THLcBJdpfZ1TstDFbKNznlzoxa8fmnFYK4V67HvmuNYkVdAywJSoteUszvBQ9/HqN2+9AZghbajMsFT+oA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -1681,9 +1678,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-win32-x64-gnu": {
|
"node_modules/@rollup/rollup-win32-x64-gnu": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.3.tgz",
|
||||||
"integrity": "sha512-S6YojNVrHybQis2lYov1sd+uj7K0Q05NxHcGktuMMdIQ2VixGwAfbJ23NnlvvVV1bdpR2m5MsNBViHJKcA4ADw==",
|
"integrity": "sha512-J9QDiOIZlZLdcot5NXEepDkstocktoVjkaKUtqzgzpt2yWjGlbYiKyp05rWwk4nypbYUNoFAztEgixoLaSETkg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -1695,9 +1692,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.3.tgz",
|
||||||
"integrity": "sha512-k+/Rkcyx//P6fetPoLMb8pBeqJBNGx81uuf7iljX9++yNBVRDQgD04L+SVXmXmh5ZP4/WOp4mWF0kmi06PW2tA==",
|
"integrity": "sha512-UhTd8u31dXadv0MopwGgNOBpUVROFKWVQgAg5N1ESyCz8AuBcMqm4AuTjrwgQKGDfoFuz02EuMRHQIw/frmYKQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -2025,13 +2022,12 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
"version": "19.2.4",
|
"version": "19.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.7.tgz",
|
||||||
"integrity": "sha512-tBFxBp9Nfyy5rsmefN+WXc1JeW/j2BpBHFdLZbEVfs9wn3E3NRFxwV0pJg8M1qQAexFpvz73hJXFofV0ZAu92A==",
|
"integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.0.2"
|
"csstype": "^3.2.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/react-dom": {
|
"node_modules/@types/react-dom": {
|
||||||
@@ -2097,9 +2093,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/baseline-browser-mapping": {
|
"node_modules/baseline-browser-mapping": {
|
||||||
"version": "2.8.28",
|
"version": "2.9.4",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.28.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.4.tgz",
|
||||||
"integrity": "sha512-gYjt7OIqdM0PcttNYP2aVrr2G0bMALkBaoehD4BuRGjAOtipg0b6wHg1yNL+s5zSnLZZrGHOw4IrND8CD+3oIQ==",
|
"integrity": "sha512-ZCQ9GEWl73BVm8bu5Fts8nt7MHdbt5vY9bP6WGnUh+r3l8M7CgfyTlwsgCbMC66BNxPr6Xoce3j66Ms5YUQTNA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -2107,9 +2103,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/browserslist": {
|
"node_modules/browserslist": {
|
||||||
"version": "4.28.0",
|
"version": "4.28.1",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.0.tgz",
|
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz",
|
||||||
"integrity": "sha512-tbydkR/CxfMwelN0vwdP/pLkDwyAASZ+VfWm4EOwlB6SWhx1sYnWLqo8N5j0rAzPfzfRaxt0mM/4wPU/Su84RQ==",
|
"integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -2126,13 +2122,12 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"baseline-browser-mapping": "^2.8.25",
|
"baseline-browser-mapping": "^2.9.0",
|
||||||
"caniuse-lite": "^1.0.30001754",
|
"caniuse-lite": "^1.0.30001759",
|
||||||
"electron-to-chromium": "^1.5.249",
|
"electron-to-chromium": "^1.5.263",
|
||||||
"node-releases": "^2.0.27",
|
"node-releases": "^2.0.27",
|
||||||
"update-browserslist-db": "^1.1.4"
|
"update-browserslist-db": "^1.2.0"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"browserslist": "cli.js"
|
"browserslist": "cli.js"
|
||||||
@@ -2164,9 +2159,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001754",
|
"version": "1.0.30001759",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001754.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001759.tgz",
|
||||||
"integrity": "sha512-x6OeBXueoAceOmotzx3PO4Zpt4rzpeIFsSr6AAePTZxSkXiYDUmpypEl7e2+8NCd9bD7bXjqyef8CJYPC1jfxg==",
|
"integrity": "sha512-Pzfx9fOKoKvevQf8oCXoyNRQ5QyxJj+3O0Rqx2V5oxT61KGx8+n6hV/IUyJeifUci2clnmmKVpvtiqRzgiWjSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -2225,9 +2220,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/csstype": {
|
"node_modules/csstype": {
|
||||||
"version": "3.1.3",
|
"version": "3.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
@@ -2269,9 +2264,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/electron-to-chromium": {
|
"node_modules/electron-to-chromium": {
|
||||||
"version": "1.5.250",
|
"version": "1.5.266",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.250.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.266.tgz",
|
||||||
"integrity": "sha512-/5UMj9IiGDMOFBnN4i7/Ry5onJrAGSbOGo3s9FEKmwobGq6xw832ccET0CE3CkkMBZ8GJSlUIesZofpyurqDXw==",
|
"integrity": "sha512-kgWEglXvkEfMH7rxP5OSZZwnaDWT7J9EoZCujhnpLbfi0bbNtRkgdX2E3gt0Uer11c61qCYktB3hwkAS325sJg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
@@ -2696,7 +2691,6 @@
|
|||||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
@@ -2760,32 +2754,30 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react": {
|
"node_modules/react": {
|
||||||
"version": "19.2.0",
|
"version": "19.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.2.1.tgz",
|
||||||
"integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==",
|
"integrity": "sha512-DGrYcCWK7tvYMnWh79yrPHt+vdx9tY+1gPZa7nJQtO/p8bLTDaHp4dzwEhQB7pZ4Xe3ok4XKuEPrVuc+wlpkmw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-dom": {
|
"node_modules/react-dom": {
|
||||||
"version": "19.2.0",
|
"version": "19.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.1.tgz",
|
||||||
"integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==",
|
"integrity": "sha512-ibrK8llX2a4eOskq1mXKu/TGZj9qzomO+sNfO98M6d9zIPOEhlBkMkBUBLd1vgS0gQsLDBzA+8jJBVXDnfHmJg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"scheduler": "^0.27.0"
|
"scheduler": "^0.27.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^19.2.0"
|
"react": "^19.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-is": {
|
"node_modules/react-is": {
|
||||||
"version": "19.2.0",
|
"version": "19.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.1.tgz",
|
||||||
"integrity": "sha512-x3Ax3kNSMIIkyVYhWPyO09bu0uttcAIoecO/um/rKGQ4EltYWVYtyiGkS/3xMynrbVQdS69Jhlv8FXUEZehlzA==",
|
"integrity": "sha512-L7BnWgRbMwzMAubQcS7sXdPdNLmKlucPlopgAzx7FtYbksWZgEWiuYM5x9T6UqS2Ne0rsgQTq5kY2SGqpzUkYA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/react-refresh": {
|
"node_modules/react-refresh": {
|
||||||
@@ -2844,9 +2836,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rollup": {
|
"node_modules/rollup": {
|
||||||
"version": "4.53.2",
|
"version": "4.53.3",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.2.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.3.tgz",
|
||||||
"integrity": "sha512-MHngMYwGJVi6Fmnk6ISmnk7JAHRNF0UkuucA0CUW3N3a4KnONPEZz+vUanQP/ZC/iY1Qkf3bwPWzyY84wEks1g==",
|
"integrity": "sha512-w8GmOxZfBmKknvdXU1sdM9NHcoQejwF/4mNgj2JuEEdRaHwwF12K7e9eXn1nLZ07ad+du76mkVsyeb2rKGllsA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2860,28 +2852,28 @@
|
|||||||
"npm": ">=8.0.0"
|
"npm": ">=8.0.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@rollup/rollup-android-arm-eabi": "4.53.2",
|
"@rollup/rollup-android-arm-eabi": "4.53.3",
|
||||||
"@rollup/rollup-android-arm64": "4.53.2",
|
"@rollup/rollup-android-arm64": "4.53.3",
|
||||||
"@rollup/rollup-darwin-arm64": "4.53.2",
|
"@rollup/rollup-darwin-arm64": "4.53.3",
|
||||||
"@rollup/rollup-darwin-x64": "4.53.2",
|
"@rollup/rollup-darwin-x64": "4.53.3",
|
||||||
"@rollup/rollup-freebsd-arm64": "4.53.2",
|
"@rollup/rollup-freebsd-arm64": "4.53.3",
|
||||||
"@rollup/rollup-freebsd-x64": "4.53.2",
|
"@rollup/rollup-freebsd-x64": "4.53.3",
|
||||||
"@rollup/rollup-linux-arm-gnueabihf": "4.53.2",
|
"@rollup/rollup-linux-arm-gnueabihf": "4.53.3",
|
||||||
"@rollup/rollup-linux-arm-musleabihf": "4.53.2",
|
"@rollup/rollup-linux-arm-musleabihf": "4.53.3",
|
||||||
"@rollup/rollup-linux-arm64-gnu": "4.53.2",
|
"@rollup/rollup-linux-arm64-gnu": "4.53.3",
|
||||||
"@rollup/rollup-linux-arm64-musl": "4.53.2",
|
"@rollup/rollup-linux-arm64-musl": "4.53.3",
|
||||||
"@rollup/rollup-linux-loong64-gnu": "4.53.2",
|
"@rollup/rollup-linux-loong64-gnu": "4.53.3",
|
||||||
"@rollup/rollup-linux-ppc64-gnu": "4.53.2",
|
"@rollup/rollup-linux-ppc64-gnu": "4.53.3",
|
||||||
"@rollup/rollup-linux-riscv64-gnu": "4.53.2",
|
"@rollup/rollup-linux-riscv64-gnu": "4.53.3",
|
||||||
"@rollup/rollup-linux-riscv64-musl": "4.53.2",
|
"@rollup/rollup-linux-riscv64-musl": "4.53.3",
|
||||||
"@rollup/rollup-linux-s390x-gnu": "4.53.2",
|
"@rollup/rollup-linux-s390x-gnu": "4.53.3",
|
||||||
"@rollup/rollup-linux-x64-gnu": "4.53.2",
|
"@rollup/rollup-linux-x64-gnu": "4.53.3",
|
||||||
"@rollup/rollup-linux-x64-musl": "4.53.2",
|
"@rollup/rollup-linux-x64-musl": "4.53.3",
|
||||||
"@rollup/rollup-openharmony-arm64": "4.53.2",
|
"@rollup/rollup-openharmony-arm64": "4.53.3",
|
||||||
"@rollup/rollup-win32-arm64-msvc": "4.53.2",
|
"@rollup/rollup-win32-arm64-msvc": "4.53.3",
|
||||||
"@rollup/rollup-win32-ia32-msvc": "4.53.2",
|
"@rollup/rollup-win32-ia32-msvc": "4.53.3",
|
||||||
"@rollup/rollup-win32-x64-gnu": "4.53.2",
|
"@rollup/rollup-win32-x64-gnu": "4.53.3",
|
||||||
"@rollup/rollup-win32-x64-msvc": "4.53.2",
|
"@rollup/rollup-win32-x64-msvc": "4.53.3",
|
||||||
"fsevents": "~2.3.2"
|
"fsevents": "~2.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2986,7 +2978,6 @@
|
|||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
@@ -2996,9 +2987,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/update-browserslist-db": {
|
"node_modules/update-browserslist-db": {
|
||||||
"version": "1.1.4",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.2.tgz",
|
||||||
"integrity": "sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A==",
|
"integrity": "sha512-E85pfNzMQ9jpKkA7+TJAi4TJN+tBCuWh5rUcS/sv6cFi+1q9LYDwDI5dpUL0u/73EElyQ8d3TEaeW4sPedBqYA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -3027,12 +3018,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "7.2.2",
|
"version": "7.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-7.2.6.tgz",
|
||||||
"integrity": "sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==",
|
"integrity": "sha512-tI2l/nFHC5rLh7+5+o7QjKjSR04ivXDF4jcgV0f/bTQ+OJiITy5S6gaynVsEM+7RqzufMnVbIon6Sr5x1SDYaQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.25.0",
|
"esbuild": "^0.25.0",
|
||||||
"fdir": "^6.5.0",
|
"fdir": "^6.5.0",
|
||||||
@@ -3123,6 +3113,24 @@
|
|||||||
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
|
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/yaml": {
|
||||||
|
"version": "2.8.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz",
|
||||||
|
"integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
|
"bin": {
|
||||||
|
"yaml": "bin.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 14.6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/eemeli"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ function App() {
|
|||||||
// Get a remote model
|
// Get a remote model
|
||||||
try {
|
try {
|
||||||
const model_bytes = await get_model(modelHash);
|
const model_bytes = await get_model(modelHash);
|
||||||
const importedModel = Model.from_bytes(model_bytes);
|
const importedModel = Model.from_bytes(model_bytes, "en");
|
||||||
localStorage.removeItem("selected");
|
localStorage.removeItem("selected");
|
||||||
setModel(importedModel);
|
setModel(importedModel);
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
@@ -54,7 +54,7 @@ function App() {
|
|||||||
} else if (exampleFilename) {
|
} else if (exampleFilename) {
|
||||||
try {
|
try {
|
||||||
const model_bytes = await get_documentation_model(exampleFilename);
|
const model_bytes = await get_documentation_model(exampleFilename);
|
||||||
const importedModel = Model.from_bytes(model_bytes);
|
const importedModel = Model.from_bytes(model_bytes, "en");
|
||||||
localStorage.removeItem("selected");
|
localStorage.removeItem("selected");
|
||||||
setModel(importedModel);
|
setModel(importedModel);
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
@@ -152,7 +152,7 @@ function App() {
|
|||||||
const blob = await uploadFile(arrayBuffer, fileName);
|
const blob = await uploadFile(arrayBuffer, fileName);
|
||||||
|
|
||||||
const bytes = new Uint8Array(await blob.arrayBuffer());
|
const bytes = new Uint8Array(await blob.arrayBuffer());
|
||||||
const newModel = Model.from_bytes(bytes);
|
const newModel = Model.from_bytes(bytes, "en");
|
||||||
saveModelToStorage(newModel);
|
saveModelToStorage(newModel);
|
||||||
|
|
||||||
setModel(newModel);
|
setModel(newModel);
|
||||||
@@ -187,7 +187,7 @@ function App() {
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
const model_bytes = await get_documentation_model(templateId);
|
const model_bytes = await get_documentation_model(templateId);
|
||||||
const importedModel = Model.from_bytes(model_bytes);
|
const importedModel = Model.from_bytes(model_bytes, "en");
|
||||||
saveModelToStorage(importedModel);
|
saveModelToStorage(importedModel);
|
||||||
setModel(importedModel);
|
setModel(importedModel);
|
||||||
break;
|
break;
|
||||||
@@ -207,7 +207,7 @@ function App() {
|
|||||||
onClose={() => setTemplatesDialogOpen(false)}
|
onClose={() => setTemplatesDialogOpen(false)}
|
||||||
onSelectTemplate={async (fileName) => {
|
onSelectTemplate={async (fileName) => {
|
||||||
const model_bytes = await get_documentation_model(fileName);
|
const model_bytes = await get_documentation_model(fileName);
|
||||||
const importedModel = Model.from_bytes(model_bytes);
|
const importedModel = Model.from_bytes(model_bytes, "en");
|
||||||
saveModelToStorage(importedModel);
|
saveModelToStorage(importedModel);
|
||||||
setModel(importedModel);
|
setModel(importedModel);
|
||||||
setTemplatesDialogOpen(false);
|
setTemplatesDialogOpen(false);
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ import { Model } from "@ironcalc/workbook";
|
|||||||
import { base64ToBytes, bytesToBase64 } from "./util";
|
import { base64ToBytes, bytesToBase64 } from "./util";
|
||||||
|
|
||||||
const MAX_WORKBOOKS = 50;
|
const MAX_WORKBOOKS = 50;
|
||||||
|
const DEFAULT_LANGUAGE = "en";
|
||||||
|
|
||||||
type ModelsMetadata = Record<
|
type ModelsMetadata = Record<
|
||||||
string,
|
string,
|
||||||
{ name: string; createdAt: number; pinned?: boolean }
|
{ name: string; createdAt: number; pinned: boolean; language: string }
|
||||||
>;
|
>;
|
||||||
|
|
||||||
function randomUUID(): string {
|
function randomUUID(): string {
|
||||||
@@ -27,11 +28,17 @@ export function updateNameSelectedWorkbook(model: Model, newName: string) {
|
|||||||
const modelsJson = localStorage.getItem("models");
|
const modelsJson = localStorage.getItem("models");
|
||||||
if (modelsJson) {
|
if (modelsJson) {
|
||||||
try {
|
try {
|
||||||
const models = JSON.parse(modelsJson);
|
const models: ModelsMetadata = JSON.parse(modelsJson);
|
||||||
if (models[uuid]) {
|
if (models[uuid]) {
|
||||||
models[uuid].name = newName;
|
models[uuid].name = newName;
|
||||||
|
models[uuid].language = model.getLanguage();
|
||||||
} else {
|
} else {
|
||||||
models[uuid] = { name: newName, createdAt: Date.now() };
|
models[uuid] = {
|
||||||
|
name: newName,
|
||||||
|
createdAt: Date.now(),
|
||||||
|
language: model.getLanguage(),
|
||||||
|
pinned: false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
localStorage.setItem("models", JSON.stringify(models));
|
localStorage.setItem("models", JSON.stringify(models));
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
@@ -48,26 +55,7 @@ export function getModelsMetadata(): ModelsMetadata {
|
|||||||
if (!modelsJson) {
|
if (!modelsJson) {
|
||||||
modelsJson = "{}";
|
modelsJson = "{}";
|
||||||
}
|
}
|
||||||
const models = JSON.parse(modelsJson);
|
return JSON.parse(modelsJson);
|
||||||
|
|
||||||
// Migrate old format to new format
|
|
||||||
const migratedModels: ModelsMetadata = {};
|
|
||||||
for (const [uuid, value] of Object.entries(models)) {
|
|
||||||
if (typeof value === "string") {
|
|
||||||
// Old format: just the name string
|
|
||||||
migratedModels[uuid] = { name: value, createdAt: Date.now() };
|
|
||||||
} else if (typeof value === "object" && value !== null && "name" in value) {
|
|
||||||
// New format: object with name and createdAt
|
|
||||||
migratedModels[uuid] = value as { name: string; createdAt: number };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save migrated data back to localStorage
|
|
||||||
if (JSON.stringify(models) !== JSON.stringify(migratedModels)) {
|
|
||||||
localStorage.setItem("models", JSON.stringify(migratedModels));
|
|
||||||
}
|
|
||||||
|
|
||||||
return migratedModels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick a different name Workbook{N} where N = 1, 2, 3
|
// Pick a different name Workbook{N} where N = 1, 2, 3
|
||||||
@@ -88,10 +76,10 @@ function getNewName(existingNames: string[]): string {
|
|||||||
export function createModelWithSafeTimezone(name: string): Model {
|
export function createModelWithSafeTimezone(name: string): Model {
|
||||||
try {
|
try {
|
||||||
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
return new Model(name, "en", tz);
|
return new Model(name, "en", tz, DEFAULT_LANGUAGE);
|
||||||
} catch {
|
} catch (e) {
|
||||||
console.warn("Failed to get timezone, defaulting to UTC");
|
console.warn("Failed to get timezone, defaulting to UTC", e);
|
||||||
return new Model(name, "en", "UTC");
|
return new Model(name, "en", "UTC", DEFAULT_LANGUAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +92,12 @@ export function createNewModel(): Model {
|
|||||||
localStorage.setItem("selected", uuid);
|
localStorage.setItem("selected", uuid);
|
||||||
localStorage.setItem(uuid, bytesToBase64(model.toBytes()));
|
localStorage.setItem(uuid, bytesToBase64(model.toBytes()));
|
||||||
|
|
||||||
models[uuid] = { name, createdAt: Date.now() };
|
models[uuid] = {
|
||||||
|
name,
|
||||||
|
createdAt: Date.now(),
|
||||||
|
language: model.getLanguage(),
|
||||||
|
pinned: false,
|
||||||
|
};
|
||||||
localStorage.setItem("models", JSON.stringify(models));
|
localStorage.setItem("models", JSON.stringify(models));
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
@@ -114,8 +107,9 @@ export function loadSelectedModelFromStorage(): Model | null {
|
|||||||
if (uuid) {
|
if (uuid) {
|
||||||
// We try to load the selected model
|
// We try to load the selected model
|
||||||
const modelBytesString = localStorage.getItem(uuid);
|
const modelBytesString = localStorage.getItem(uuid);
|
||||||
|
const language = getModelsMetadata()[uuid]?.language || DEFAULT_LANGUAGE;
|
||||||
if (modelBytesString) {
|
if (modelBytesString) {
|
||||||
return Model.from_bytes(base64ToBytes(modelBytesString));
|
return Model.from_bytes(base64ToBytes(modelBytesString), language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -140,6 +134,14 @@ export function saveSelectedModelInStorage(model: Model) {
|
|||||||
if (uuid) {
|
if (uuid) {
|
||||||
const modeBytes = model.toBytes();
|
const modeBytes = model.toBytes();
|
||||||
localStorage.setItem(uuid, bytesToBase64(modeBytes));
|
localStorage.setItem(uuid, bytesToBase64(modeBytes));
|
||||||
|
let modelsJson = localStorage.getItem("models");
|
||||||
|
if (!modelsJson) {
|
||||||
|
modelsJson = "{}";
|
||||||
|
}
|
||||||
|
const models: ModelsMetadata = JSON.parse(modelsJson);
|
||||||
|
models[uuid].language = model.getLanguage(),
|
||||||
|
|
||||||
|
localStorage.setItem("models", JSON.stringify(models));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,16 +153,22 @@ export function saveModelToStorage(model: Model) {
|
|||||||
if (!modelsJson) {
|
if (!modelsJson) {
|
||||||
modelsJson = "{}";
|
modelsJson = "{}";
|
||||||
}
|
}
|
||||||
const models = JSON.parse(modelsJson);
|
const models: ModelsMetadata = JSON.parse(modelsJson);
|
||||||
models[uuid] = { name: model.getName(), createdAt: Date.now() };
|
models[uuid] = {
|
||||||
|
name: model.getName(),
|
||||||
|
createdAt: Date.now(),
|
||||||
|
language: model.getLanguage(),
|
||||||
|
pinned: false,
|
||||||
|
};
|
||||||
localStorage.setItem("models", JSON.stringify(models));
|
localStorage.setItem("models", JSON.stringify(models));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectModelFromStorage(uuid: string): Model | null {
|
export function selectModelFromStorage(uuid: string): Model | null {
|
||||||
localStorage.setItem("selected", uuid);
|
localStorage.setItem("selected", uuid);
|
||||||
const modelBytesString = localStorage.getItem(uuid);
|
const modelBytesString = localStorage.getItem(uuid);
|
||||||
|
const language = getModelsMetadata()[uuid]?.language || DEFAULT_LANGUAGE;
|
||||||
if (modelBytesString) {
|
if (modelBytesString) {
|
||||||
return Model.from_bytes(base64ToBytes(modelBytesString));
|
return Model.from_bytes(base64ToBytes(modelBytesString), language);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -210,8 +218,10 @@ export function deleteModelByUuid(uuid: string): Model | null {
|
|||||||
// If it wasn't the selected model, return the currently selected model
|
// If it wasn't the selected model, return the currently selected model
|
||||||
if (selectedUuid) {
|
if (selectedUuid) {
|
||||||
const modelBytesString = localStorage.getItem(selectedUuid);
|
const modelBytesString = localStorage.getItem(selectedUuid);
|
||||||
|
const language =
|
||||||
|
getModelsMetadata()[selectedUuid]?.language || DEFAULT_LANGUAGE;
|
||||||
if (modelBytesString) {
|
if (modelBytesString) {
|
||||||
return Model.from_bytes(base64ToBytes(modelBytesString));
|
return Model.from_bytes(base64ToBytes(modelBytesString), language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,11 +244,14 @@ export function isWorkbookPinned(uuid: string): boolean {
|
|||||||
|
|
||||||
export function duplicateModel(uuid: string): Model | null {
|
export function duplicateModel(uuid: string): Model | null {
|
||||||
const originalModel = selectModelFromStorage(uuid);
|
const originalModel = selectModelFromStorage(uuid);
|
||||||
if (!originalModel) return null;
|
if (!originalModel) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const duplicatedModel = Model.from_bytes(originalModel.toBytes());
|
const language = originalModel.getLanguage();
|
||||||
|
const duplicatedModel = Model.from_bytes(originalModel.toBytes(), language);
|
||||||
const models = getModelsMetadata();
|
const models = getModelsMetadata();
|
||||||
const originalName = models[uuid]?.name || "Workbook";
|
const originalName = models[uuid].name;
|
||||||
const existingNames = Object.values(models).map((m) => m.name);
|
const existingNames = Object.values(models).map((m) => m.name);
|
||||||
|
|
||||||
// Find next available number
|
// Find next available number
|
||||||
@@ -255,7 +268,12 @@ export function duplicateModel(uuid: string): Model | null {
|
|||||||
localStorage.setItem("selected", newUuid);
|
localStorage.setItem("selected", newUuid);
|
||||||
localStorage.setItem(newUuid, bytesToBase64(duplicatedModel.toBytes()));
|
localStorage.setItem(newUuid, bytesToBase64(duplicatedModel.toBytes()));
|
||||||
|
|
||||||
models[newUuid] = { name: newName, createdAt: Date.now() };
|
models[newUuid] = {
|
||||||
|
name: newName,
|
||||||
|
createdAt: Date.now(),
|
||||||
|
language,
|
||||||
|
pinned: false,
|
||||||
|
};
|
||||||
localStorage.setItem("models", JSON.stringify(models));
|
localStorage.setItem("models", JSON.stringify(models));
|
||||||
|
|
||||||
return duplicatedModel;
|
return duplicatedModel;
|
||||||
|
|||||||
24
webapp/app.ironcalc.com/server/Cargo.lock
generated
24
webapp/app.ironcalc.com/server/Cargo.lock
generated
@@ -77,6 +77,15 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "approx"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
version = "0.7.6"
|
version = "0.7.6"
|
||||||
@@ -925,7 +934,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ironcalc"
|
name = "ironcalc"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitcode",
|
"bitcode",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -940,7 +949,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ironcalc_base"
|
name = "ironcalc_base"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitcode",
|
"bitcode",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -951,6 +960,7 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
|
"statrs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1978,6 +1988,16 @@ dependencies = [
|
|||||||
"loom",
|
"loom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "statrs"
|
||||||
|
version = "0.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2a3fe7c28c6512e766b0874335db33c94ad7b8f9054228ae1c2abd47ce7d335e"
|
||||||
|
dependencies = [
|
||||||
|
"approx",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.6.1"
|
version = "2.6.1"
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ pub async fn add_model(
|
|||||||
.execute(&mut **db)
|
.execute(&mut **db)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
io::Error::new(
|
io::Error::other(
|
||||||
io::ErrorKind::Other,
|
|
||||||
format!("Failed to save to the database: {}", e),
|
format!("Failed to save to the database: {}", e),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -36,14 +36,13 @@ async fn download(data: Data<'_>) -> io::Result<FileResponder> {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if !bytes.is_complete() {
|
if !bytes.is_complete() {
|
||||||
return Err(io::Error::new(
|
return Err(io::Error::other(
|
||||||
io::ErrorKind::Other,
|
|
||||||
"The file was not fully uploaded",
|
"The file was not fully uploaded",
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let model = IModel::from_bytes(&bytes).map_err(|e| {
|
let model = IModel::from_bytes(&bytes, "en").map_err(|e| {
|
||||||
io::Error::new(io::ErrorKind::Other, format!("Error creating model, '{e}'"))
|
io::Error::other(format!("Error creating model, '{e}'"))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let mut buffer: Vec<u8> = Vec::new();
|
let mut buffer: Vec<u8> = Vec::new();
|
||||||
@@ -51,7 +50,7 @@ async fn download(data: Data<'_>) -> io::Result<FileResponder> {
|
|||||||
let cursor = Cursor::new(&mut buffer);
|
let cursor = Cursor::new(&mut buffer);
|
||||||
let mut writer = BufWriter::new(cursor);
|
let mut writer = BufWriter::new(cursor);
|
||||||
save_xlsx_to_writer(&model, &mut writer).map_err(|e| {
|
save_xlsx_to_writer(&model, &mut writer).map_err(|e| {
|
||||||
io::Error::new(io::ErrorKind::Other, format!("Error saving model: '{e}'"))
|
io::Error::other(format!("Error saving model: '{e}'"))
|
||||||
})?;
|
})?;
|
||||||
writer.flush().unwrap();
|
writer.flush().unwrap();
|
||||||
}
|
}
|
||||||
@@ -82,8 +81,7 @@ async fn share(db: Connection<IronCalcDB>, data: Data<'_>) -> io::Result<String>
|
|||||||
let hash = id::new_id();
|
let hash = id::new_id();
|
||||||
let bytes = data.open(MAX_SIZE_MB.megabytes()).into_bytes().await?;
|
let bytes = data.open(MAX_SIZE_MB.megabytes()).into_bytes().await?;
|
||||||
if !bytes.is_complete() {
|
if !bytes.is_complete() {
|
||||||
return Err(io::Error::new(
|
return Err(io::Error::other(
|
||||||
io::ErrorKind::Other,
|
|
||||||
"file was not fully uploaded",
|
"file was not fully uploaded",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -111,15 +109,14 @@ async fn upload(data: Data<'_>, name: &str) -> io::Result<Vec<u8>> {
|
|||||||
println!("start upload");
|
println!("start upload");
|
||||||
let bytes = data.open(MAX_SIZE_MB.megabytes()).into_bytes().await?;
|
let bytes = data.open(MAX_SIZE_MB.megabytes()).into_bytes().await?;
|
||||||
if !bytes.is_complete() {
|
if !bytes.is_complete() {
|
||||||
return Err(io::Error::new(
|
return Err(io::Error::other(
|
||||||
io::ErrorKind::Other,
|
|
||||||
"file was not fully uploaded",
|
"file was not fully uploaded",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let workbook = load_from_xlsx_bytes(&bytes, name.trim_end_matches(".xlsx"), "en", "UTC")
|
let workbook = load_from_xlsx_bytes(&bytes, name.trim_end_matches(".xlsx"), "en", "UTC")
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("Error loading model: '{e}'")))?;
|
.map_err(|e| io::Error::other(format!("Error loading model: '{e}'")))?;
|
||||||
let model = IModel::from_workbook(workbook).map_err(|e| {
|
let model = IModel::from_workbook(workbook, "en").map_err(|e| {
|
||||||
io::Error::new(io::ErrorKind::Other, format!("Error creating model: '{e}'"))
|
io::Error::other(format!("Error creating model: '{e}'"))
|
||||||
})?;
|
})?;
|
||||||
println!("end upload");
|
println!("end upload");
|
||||||
Ok(model.to_bytes())
|
Ok(model.to_bytes())
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use ironcalc::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut model = Model::new_empty("hello-calc.xlsx", "en", "UTC")?;
|
let mut model = Model::new_empty("hello-calc.xlsx", "en", "UTC", "en")?;
|
||||||
// Adds a square of numbers in the first sheet
|
// Adds a square of numbers in the first sheet
|
||||||
for row in 1..100 {
|
for row in 1..100 {
|
||||||
for column in 1..100 {
|
for column in 1..100 {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user