mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
Spreadsheet: Add support for multiple sheets
This also refactors the js integration stuff to allow sheets to reference each other safely.
This commit is contained in:
parent
e1f5f709ee
commit
cb7fe4fe7c
11 changed files with 365 additions and 126 deletions
|
@ -32,12 +32,11 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
class WorkbookObject;
|
||||
|
||||
class Workbook {
|
||||
public:
|
||||
Workbook(NonnullRefPtrVector<Sheet>&& sheets)
|
||||
: m_sheets(move(sheets))
|
||||
{
|
||||
}
|
||||
Workbook(NonnullRefPtrVector<Sheet>&& sheets);
|
||||
|
||||
Result<bool, String> save(const StringView& filename);
|
||||
Result<bool, String> load(const StringView& filename);
|
||||
|
@ -52,13 +51,23 @@ public:
|
|||
|
||||
Sheet& add_sheet(const StringView& name)
|
||||
{
|
||||
auto sheet = Sheet::construct(name);
|
||||
auto sheet = Sheet::construct(name, *this);
|
||||
m_sheets.append(sheet);
|
||||
return *sheet;
|
||||
}
|
||||
|
||||
JS::Interpreter& interpreter() { return *m_interpreter; }
|
||||
const JS::Interpreter& interpreter() const { return *m_interpreter; }
|
||||
|
||||
JS::GlobalObject& global_object() { return m_interpreter->global_object(); }
|
||||
const JS::GlobalObject& global_object() const { return m_interpreter->global_object(); }
|
||||
|
||||
WorkbookObject* workbook_object() { return m_workbook_object; }
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<Sheet> m_sheets;
|
||||
NonnullOwnPtr<JS::Interpreter> m_interpreter;
|
||||
WorkbookObject* m_workbook_object { nullptr };
|
||||
|
||||
String m_current_filename;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue