mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:18:11 +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
|
@ -25,15 +25,26 @@
|
|||
*/
|
||||
|
||||
#include "Workbook.h"
|
||||
#include "JSIntegration.h"
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonObjectSerializer.h>
|
||||
#include <AK/JsonParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Spreadsheet {
|
||||
|
||||
Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets)
|
||||
: m_sheets(move(sheets))
|
||||
, m_interpreter(JS::Interpreter::create<JS::GlobalObject>())
|
||||
{
|
||||
m_workbook_object = interpreter().heap().allocate<WorkbookObject>(global_object(), *this);
|
||||
global_object().put("workbook", workbook_object());
|
||||
}
|
||||
|
||||
bool Workbook::set_filename(const String& filename)
|
||||
{
|
||||
if (m_current_filename == filename)
|
||||
|
@ -81,7 +92,7 @@ Result<bool, String> Workbook::load(const StringView& filename)
|
|||
if (!sheet_json.is_object())
|
||||
return IterationDecision::Continue;
|
||||
|
||||
auto sheet = Sheet::from_json(sheet_json.as_object());
|
||||
auto sheet = Sheet::from_json(sheet_json.as_object(), *this);
|
||||
if (!sheet)
|
||||
return IterationDecision::Continue;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue