1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:27:35 +00:00

Spreadsheet: Setup and prepare for cell types

This commit adds a generic interface for cell types and hooks it up.
There is no way to set these from the UI, and so they're not saved
anywhere yet.
Also implicitly converts numeric values (strictly integers) to numeric
javascript values, as numbery-looking + numbery-looking === string is
not very interesting. :^)
This commit is contained in:
AnotherTest 2020-08-28 17:55:06 +04:30 committed by Andreas Kling
parent 5715ed3dd6
commit 6614ee703b
13 changed files with 468 additions and 11 deletions

View file

@ -26,6 +26,7 @@
#pragma once
#include "CellType/Type.h"
#include "Forward.h"
#include "JSIntegration.h"
#include <AK/String.h>
@ -57,6 +58,16 @@ struct Cell : public Weakable<Cell> {
void set_data(String new_data);
void set_data(JS::Value new_data);
void set_type(const StringView& name);
void set_type_metadata(CellTypeMetadata&&);
String typed_display() const;
JS::Value typed_js_data() const;
const CellType& type() const;
const CellTypeMetadata& type_metadata() const { return m_type_metadata; }
CellTypeMetadata& type_metadata() { return m_type_metadata; }
String source() const;
JS::Value js_data();
@ -76,6 +87,8 @@ struct Cell : public Weakable<Cell> {
Kind kind { LiteralString };
WeakPtr<Sheet> sheet;
Vector<WeakPtr<Cell>> referencing_cells;
const CellType* m_type { nullptr };
CellTypeMetadata m_type_metadata;
private:
void update_data();