logisheets_controller 1.16.1

Core spreadsheet engine for LogiSheets: formula evaluation, dependency tracking, and undo/redo.
Documentation
use logisheets_base::{
    BlockCellId, CellId, FuncId, Range, RangeId, SheetId, async_func::AsyncFuncCommitTrait,
    block_ref::BlockRefTrait, get_curr_addr::GetCurrAddrTrait, set_curr_cell::SetCurrCellTrait,
};
use logisheets_parser::ast;

use super::calculator::calc_vertex::{CalcValue, CalcVertex};

use crate::errors::Result;

pub trait Connector:
    AsyncFuncCommitTrait + GetCurrAddrTrait + SetCurrCellTrait + BlockRefTrait
{
    fn convert(&mut self, v: &ast::CellReference) -> CalcVertex;
    fn get_calc_value(&mut self, vertex: CalcVertex) -> CalcValue;
    // fn get_text(&self, tid: &TextId) -> Result<String>;
    fn get_func_name(&self, fid: &FuncId) -> Result<String>;
    fn get_cell_idx(&self, sheet_id: SheetId, cell_id: &CellId) -> Result<(usize, usize)>;
    fn get_cell_id(&self, sheet_id: SheetId, row: usize, col: usize) -> Result<CellId>;
    fn get_sheet_id_by_name(&self, name: &str) -> Result<SheetId>;

    /// The unparsed formula text of a cell (without the leading `=`), or `None`
    /// when the cell carries no formula. Backs the `FORMULATEXT` function.
    fn get_formula_string(&self, sheet_id: SheetId, cell_id: &CellId) -> Option<String>;

    /// Whether a cell carries a formula. Backs the `ISFORMULA` function — a
    /// presence check that (unlike `get_formula_string`) never depends on the
    /// formula being serializable.
    fn has_formula(&self, sheet_id: SheetId, cell_id: &CellId) -> bool;
    fn commit_calc_values(&mut self, vertex: (SheetId, CellId), result: CalcValue);
    fn is_async_func(&self, func_name: &str) -> bool;
    fn get_range(&self, sheet_id: &SheetId, range: &RangeId) -> Option<Range>;
    fn get_active_sheet(&self) -> SheetId;

    fn get_block_cell_value(
        &mut self,
        sheet_id: SheetId,
        cell_id: BlockCellId,
    ) -> Option<CalcValue>;

    // This is always used in calculating the functions like RAND and TODAY.
    // These functions should be calculated every time the engine runs.
    // So every time these functions are calculated the current cell should marked as dirty cells in the next process.
    fn set_curr_as_dirty(&mut self) -> Result<()>;
}