2020-08-26 06:02:38 +03:00
|
|
|
/*
|
2022-02-10 22:28:48 +03:00
|
|
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
2020-08-26 06:02:38 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-26 06:02:38 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-08-28 14:50:23 +03:00
|
|
|
#include "Forward.h"
|
2020-08-26 06:02:38 +03:00
|
|
|
#include <LibJS/Forward.h>
|
2021-09-29 20:20:10 +03:00
|
|
|
#include <LibJS/Runtime/Completion.h>
|
2020-08-26 06:02:38 +03:00
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
|
|
|
|
namespace Spreadsheet {
|
|
|
|
|
2020-12-28 23:03:16 +03:00
|
|
|
struct FunctionAndArgumentIndex {
|
2022-12-04 21:02:33 +03:00
|
|
|
DeprecatedString function_name;
|
2020-12-28 23:03:16 +03:00
|
|
|
size_t argument_index { 0 };
|
|
|
|
};
|
|
|
|
Optional<FunctionAndArgumentIndex> get_function_and_argument_index(StringView source);
|
|
|
|
|
2020-09-07 21:51:17 +03:00
|
|
|
class SheetGlobalObject final : public JS::GlobalObject {
|
2020-08-26 06:02:38 +03:00
|
|
|
JS_OBJECT(SheetGlobalObject, JS::GlobalObject);
|
|
|
|
|
|
|
|
public:
|
2022-08-01 21:27:20 +03:00
|
|
|
SheetGlobalObject(JS::Realm&, Sheet&);
|
2023-08-07 09:41:28 +03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-02-10 22:28:48 +03:00
|
|
|
virtual ~SheetGlobalObject() override = default;
|
2020-08-26 06:02:38 +03:00
|
|
|
|
2021-10-24 17:01:24 +03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_has_property(JS::PropertyKey const& name) const override;
|
2023-07-08 18:39:18 +03:00
|
|
|
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*) const override;
|
2023-11-08 22:51:26 +03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*) override;
|
2020-08-26 06:02:38 +03:00
|
|
|
|
2021-10-31 15:20:21 +03:00
|
|
|
JS_DECLARE_NATIVE_FUNCTION(get_real_cell_contents);
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(set_real_cell_contents);
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(parse_cell_name);
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(current_cell_position);
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(column_index);
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(column_arithmetic);
|
2021-11-21 03:08:10 +03:00
|
|
|
JS_DECLARE_NATIVE_FUNCTION(get_column_bound);
|
2022-06-25 18:35:17 +03:00
|
|
|
JS_DECLARE_NATIVE_FUNCTION(get_name);
|
2020-08-26 06:02:38 +03:00
|
|
|
|
|
|
|
private:
|
2020-12-22 13:48:33 +03:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
2020-08-26 06:02:38 +03:00
|
|
|
Sheet& m_sheet;
|
|
|
|
};
|
|
|
|
|
2020-09-07 21:51:17 +03:00
|
|
|
class WorkbookObject final : public JS::Object {
|
2020-08-26 06:02:38 +03:00
|
|
|
JS_OBJECT(WorkbookObject, JS::Object);
|
|
|
|
|
|
|
|
public:
|
2022-08-16 02:20:49 +03:00
|
|
|
WorkbookObject(JS::Realm&, Workbook&);
|
2020-08-26 06:02:38 +03:00
|
|
|
|
2022-02-10 22:28:48 +03:00
|
|
|
virtual ~WorkbookObject() override = default;
|
2020-08-26 06:02:38 +03:00
|
|
|
|
2023-08-07 09:41:28 +03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2020-08-26 06:02:38 +03:00
|
|
|
|
2021-10-31 15:20:21 +03:00
|
|
|
JS_DECLARE_NATIVE_FUNCTION(sheet);
|
2020-08-26 06:02:38 +03:00
|
|
|
|
|
|
|
private:
|
2020-12-22 13:48:33 +03:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
2020-08-26 06:02:38 +03:00
|
|
|
Workbook& m_workbook;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|