1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:57:44 +00:00

Spreadsheet: struct Cell => class Cell

Hide private members, and make the odd update() -> sheet->update(cell)
-> update(Badge<Sheet>) -> update_data() less odd by removing the
update(Badge<Sheet>) step.
This commit is contained in:
AnotherTest 2020-12-20 12:58:14 +03:30 committed by Andreas Kling
parent 28428beb5c
commit f1f9fd1c60
8 changed files with 110 additions and 93 deletions

View file

@ -43,7 +43,7 @@ DateCell::~DateCell()
String DateCell::display(Cell& cell, const CellTypeMetadata& metadata) const
{
auto timestamp = js_value(cell, metadata);
auto string = Core::DateTime::from_timestamp(timestamp.to_i32(cell.sheet->global_object())).to_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S" : metadata.format.characters());
auto string = Core::DateTime::from_timestamp(timestamp.to_i32(cell.sheet().global_object())).to_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S" : metadata.format.characters());
if (metadata.length >= 0)
return string.substring(0, metadata.length);
@ -53,7 +53,7 @@ String DateCell::display(Cell& cell, const CellTypeMetadata& metadata) const
JS::Value DateCell::js_value(Cell& cell, const CellTypeMetadata&) const
{
auto value = cell.js_data().to_double(cell.sheet->global_object());
auto value = cell.js_data().to_double(cell.sheet().global_object());
return JS::Value(value / 1000); // Turn it to seconds
}

View file

@ -47,7 +47,7 @@ String NumericCell::display(Cell& cell, const CellTypeMetadata& metadata) const
if (metadata.format.is_empty())
string = value.to_string_without_side_effects();
else
string = format_double(metadata.format.characters(), value.to_double(cell.sheet->global_object()));
string = format_double(metadata.format.characters(), value.to_double(cell.sheet().global_object()));
if (metadata.length >= 0)
return string.substring(0, metadata.length);
@ -57,7 +57,7 @@ String NumericCell::display(Cell& cell, const CellTypeMetadata& metadata) const
JS::Value NumericCell::js_value(Cell& cell, const CellTypeMetadata&) const
{
return cell.js_data().to_number(cell.sheet->global_object());
return cell.js_data().to_number(cell.sheet().global_object());
}
}

View file

@ -51,7 +51,7 @@ String StringCell::display(Cell& cell, const CellTypeMetadata& metadata) const
JS::Value StringCell::js_value(Cell& cell, const CellTypeMetadata& metadata) const
{
auto string = display(cell, metadata);
return JS::js_string(cell.sheet->interpreter().heap(), string);
return JS::js_string(cell.sheet().interpreter().heap(), string);
}
}