diff options
author | huttongrabiel <huttonthomas@icloud.com> | 2023-04-02 16:26:54 -0700 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-04-29 12:09:08 +0100 |
commit | 40725c7c8cd4ecebe76aedbc0219479b0e88312b (patch) | |
tree | d70d0c5791dd6e060d60f842d4c600e5c2968ed0 | |
parent | cd33f271b16fda7213a35b3ae1bad04ff270b7eb (diff) | |
download | serenity-40725c7c8cd4ecebe76aedbc0219479b0e88312b.zip |
Spreadsheet: Add CellChange constructor for changes in type metadata
Allows the creation of CellChanges where the change is in the type
metadata instead of in data.
-rw-r--r-- | Userland/Applications/Spreadsheet/Cell.cpp | 5 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/Cell.h | 1 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/Spreadsheet.cpp | 7 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/Spreadsheet.h | 5 |
4 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp index 6cbcfab66c..4b5864a12c 100644 --- a/Userland/Applications/Spreadsheet/Cell.cpp +++ b/Userland/Applications/Spreadsheet/Cell.cpp @@ -62,6 +62,11 @@ void Cell::set_type(StringView name) VERIFY_NOT_REACHED(); } +void Cell::set_type_metadata(CellTypeMetadata const& metadata) +{ + m_type_metadata = metadata; +} + void Cell::set_type_metadata(CellTypeMetadata&& metadata) { m_type_metadata = move(metadata); diff --git a/Userland/Applications/Spreadsheet/Cell.h b/Userland/Applications/Spreadsheet/Cell.h index 0adf45aee7..34456f09a7 100644 --- a/Userland/Applications/Spreadsheet/Cell.h +++ b/Userland/Applications/Spreadsheet/Cell.h @@ -74,6 +74,7 @@ struct Cell : public Weakable<Cell> { void set_type(StringView name); void set_type(CellType const*); + void set_type_metadata(CellTypeMetadata const&); void set_type_metadata(CellTypeMetadata&&); Position const& position() const { return m_position; } diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 3dd6258ca1..f365ce94e9 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -770,4 +770,11 @@ CellChange::CellChange(Cell& cell, DeprecatedString const& previous_data) m_new_data = cell.data(); } +CellChange::CellChange(Cell& cell, CellTypeMetadata const& previous_type_metadata) + : m_cell(cell) + , m_previous_type_metadata(previous_type_metadata) +{ + m_new_type_metadata = cell.type_metadata(); +} + } diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.h b/Userland/Applications/Spreadsheet/Spreadsheet.h index 20f0f36a01..c0ad0beb6a 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.h +++ b/Userland/Applications/Spreadsheet/Spreadsheet.h @@ -25,15 +25,20 @@ namespace Spreadsheet { class CellChange { public: CellChange(Cell&, DeprecatedString const&); + CellChange(Cell&, CellTypeMetadata const&); auto& cell() { return m_cell; } auto& previous_data() { return m_previous_data; } auto& new_data() { return m_new_data; } + auto& previous_type_metadata() { return m_previous_type_metadata; } + auto& new_type_metadata() { return m_new_type_metadata; } private: Cell& m_cell; DeprecatedString m_previous_data; DeprecatedString m_new_data; + CellTypeMetadata m_previous_type_metadata; + CellTypeMetadata m_new_type_metadata; }; class Sheet : public Core::Object { |