mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 15:07:45 +00:00
Spreadsheet: Let the cells know their own position in the sheet
This commit is contained in:
parent
13ce24de13
commit
f159d161fa
7 changed files with 227 additions and 22 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "ConditionalFormatting.h"
|
||||
#include "Forward.h"
|
||||
#include "JSIntegration.h"
|
||||
#include "Position.h"
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
|
@ -37,20 +38,22 @@
|
|||
namespace Spreadsheet {
|
||||
|
||||
struct Cell : public Weakable<Cell> {
|
||||
Cell(String data, WeakPtr<Sheet> sheet)
|
||||
Cell(String data, Position position, WeakPtr<Sheet> sheet)
|
||||
: dirty(false)
|
||||
, data(move(data))
|
||||
, kind(LiteralString)
|
||||
, sheet(sheet)
|
||||
, m_position(move(position))
|
||||
{
|
||||
}
|
||||
|
||||
Cell(String source, JS::Value&& cell_value, WeakPtr<Sheet> sheet)
|
||||
Cell(String source, JS::Value&& cell_value, Position position, WeakPtr<Sheet> sheet)
|
||||
: dirty(false)
|
||||
, data(move(source))
|
||||
, evaluated_data(move(cell_value))
|
||||
, kind(Formula)
|
||||
, sheet(sheet)
|
||||
, m_position(move(position))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -63,6 +66,13 @@ struct Cell : public Weakable<Cell> {
|
|||
void set_type(const CellType*);
|
||||
void set_type_metadata(CellTypeMetadata&&);
|
||||
|
||||
const Position& position() const { return m_position; }
|
||||
void set_position(Position position, Badge<Sheet>)
|
||||
{
|
||||
dirty = true;
|
||||
m_position = move(position);
|
||||
}
|
||||
|
||||
const Format& evaluated_formats() const { return m_evaluated_formats; }
|
||||
const Vector<ConditionalFormat>& conditional_formats() const { return m_conditional_formats; }
|
||||
void set_conditional_formats(Vector<ConditionalFormat>&& fmts)
|
||||
|
@ -99,6 +109,7 @@ struct Cell : public Weakable<Cell> {
|
|||
Vector<WeakPtr<Cell>> referencing_cells;
|
||||
const CellType* m_type { nullptr };
|
||||
CellTypeMetadata m_type_metadata;
|
||||
Position m_position;
|
||||
|
||||
Vector<ConditionalFormat> m_conditional_formats;
|
||||
Format m_evaluated_formats;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue