mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:57:45 +00:00
Spreadsheet: Add (limited) support for custom cell formatting
This commit is contained in:
parent
e75247a75b
commit
054638c355
10 changed files with 466 additions and 4 deletions
|
@ -43,6 +43,14 @@ const CellType* CellType::get_by_name(const StringView& name)
|
|||
return s_cell_types.get(name).value_or(nullptr);
|
||||
}
|
||||
|
||||
Vector<StringView> CellType::names()
|
||||
{
|
||||
Vector<StringView> names;
|
||||
for (auto& it : s_cell_types)
|
||||
names.append(it.key);
|
||||
return names;
|
||||
}
|
||||
|
||||
CellType::CellType(const StringView& name)
|
||||
{
|
||||
ASSERT(!s_cell_types.contains(name));
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "../Forward.h"
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/TextAlignment.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
namespace Spreadsheet {
|
||||
|
@ -36,11 +37,13 @@ namespace Spreadsheet {
|
|||
struct CellTypeMetadata {
|
||||
int length { -1 };
|
||||
String format;
|
||||
Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterRight };
|
||||
};
|
||||
|
||||
class CellType {
|
||||
public:
|
||||
static const CellType* get_by_name(const StringView&);
|
||||
static Vector<StringView> names();
|
||||
|
||||
virtual String display(Cell&, const CellTypeMetadata&) const = 0;
|
||||
virtual JS::Value js_value(Cell&, const CellTypeMetadata&) const = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue