This commit is contained in:
Nicolás Hatcher
2025-04-23 11:43:36 +02:00
parent 6f577575c7
commit 945897a455
5 changed files with 23 additions and 2 deletions

View File

@@ -2102,6 +2102,14 @@ impl Model {
/// Returns a list of all cells
pub fn get_all_cells(&self) -> Vec<CellIndex> {
let mut cells = Vec::new();
for (sheet, row, column) in &self.workbook.calc_chain {
let cell = CellIndex {
row: *row,
column: *column,
index: *sheet,
};
cells.push(cell);
}
for (index, sheet) in self.workbook.worksheets.iter().enumerate() {
let mut sorted_rows: Vec<_> = sheet.sheet_data.keys().collect();
sorted_rows.sort_unstable();
@@ -2128,6 +2136,8 @@ impl Model {
let cells = self.get_all_cells();
// First evaluate all dynamic arrays
for cell in cells {
self.evaluate_cell(CellReferenceIndex {
sheet: cell.index,

View File

@@ -65,7 +65,7 @@ fn basic_undo_redo() {
#[test]
fn mixed_spills() {
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
// D9 => ={1,2,3}
// D9 => ={34,35,3}
model.set_user_input(0, 9, 4, "={34,35,3}").unwrap();
// F6 => ={1;2;3;4}
model.set_user_input(0, 6, 6, "={1;2;3;4}").unwrap();

View File

@@ -51,6 +51,9 @@ pub struct Workbook {
pub metadata: Metadata,
pub tables: HashMap<String, Table>,
pub views: HashMap<u32, WorkbookView>,
/// Calculation chain of the dynamic arrays.
/// List of tuples (sheet_id, row, column)
pub calc_chain: Vec<(u32, i32, i32)>,
}
/// A defined name. The `sheet_id` is the sheet index in case the name is local

View File

@@ -348,7 +348,15 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
return workbookState.getEditingText();
}
const { sheet, row, column } = model.getSelectedView();
return model.getCellContent(sheet, row, column);
const r = model.getCellArrayStructure(sheet, row, column);
if (r === "SingleCell") {
return model.getCellContent(sheet, row, column);
}
if ("DynamicMother" in r) {
return model.getCellContent(sheet, row, column);
}
const [mother_row, mother_column, _] = r.DynamicChild;
return model.getCellContent(sheet, mother_row, mother_column);
};
// returns true if it is either single cell or the root cell of an array

Binary file not shown.