mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -47,7 +47,7 @@ void Cell::set_data(JS::Value new_data)
|
|||
m_evaluated_data = move(new_data);
|
||||
}
|
||||
|
||||
void Cell::set_type(const CellType* type)
|
||||
void Cell::set_type(CellType const* type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ void Cell::set_type_metadata(CellTypeMetadata&& metadata)
|
|||
m_type_metadata = move(metadata);
|
||||
}
|
||||
|
||||
const CellType& Cell::type() const
|
||||
CellType const& Cell::type() const
|
||||
{
|
||||
if (m_type)
|
||||
return *m_type;
|
||||
|
@ -171,13 +171,13 @@ void Cell::reference_from(Cell* other)
|
|||
if (!other || other == this)
|
||||
return;
|
||||
|
||||
if (!m_referencing_cells.find_if([other](const auto& ptr) { return ptr.ptr() == other; }).is_end())
|
||||
if (!m_referencing_cells.find_if([other](auto const& ptr) { return ptr.ptr() == other; }).is_end())
|
||||
return;
|
||||
|
||||
m_referencing_cells.append(other->make_weak_ptr());
|
||||
}
|
||||
|
||||
void Cell::copy_from(const Cell& other)
|
||||
void Cell::copy_from(Cell const& other)
|
||||
{
|
||||
m_dirty = true;
|
||||
m_evaluated_externally = other.m_evaluated_externally;
|
||||
|
|
|
@ -58,16 +58,16 @@ struct Cell : public Weakable<Cell> {
|
|||
return m_thrown_value;
|
||||
}
|
||||
|
||||
const String& data() const { return m_data; }
|
||||
String const& data() const { return m_data; }
|
||||
const JS::Value& evaluated_data() const { return m_evaluated_data; }
|
||||
Kind kind() const { return m_kind; }
|
||||
const Vector<WeakPtr<Cell>>& referencing_cells() const { return m_referencing_cells; }
|
||||
Vector<WeakPtr<Cell>> const& referencing_cells() const { return m_referencing_cells; }
|
||||
|
||||
void set_type(StringView name);
|
||||
void set_type(const CellType*);
|
||||
void set_type(CellType const*);
|
||||
void set_type_metadata(CellTypeMetadata&&);
|
||||
|
||||
const Position& position() const { return m_position; }
|
||||
Position const& position() const { return m_position; }
|
||||
void set_position(Position position, Badge<Sheet>)
|
||||
{
|
||||
if (position != m_position) {
|
||||
|
@ -76,9 +76,9 @@ struct Cell : public Weakable<Cell> {
|
|||
}
|
||||
}
|
||||
|
||||
const Format& evaluated_formats() const { return m_evaluated_formats; }
|
||||
Format const& evaluated_formats() const { return m_evaluated_formats; }
|
||||
Format& evaluated_formats() { return m_evaluated_formats; }
|
||||
const Vector<ConditionalFormat>& conditional_formats() const { return m_conditional_formats; }
|
||||
Vector<ConditionalFormat> const& conditional_formats() const { return m_conditional_formats; }
|
||||
void set_conditional_formats(Vector<ConditionalFormat>&& fmts)
|
||||
{
|
||||
m_dirty = true;
|
||||
|
@ -88,8 +88,8 @@ struct Cell : public Weakable<Cell> {
|
|||
JS::ThrowCompletionOr<String> typed_display() const;
|
||||
JS::ThrowCompletionOr<JS::Value> typed_js_data() const;
|
||||
|
||||
const CellType& type() const;
|
||||
const CellTypeMetadata& type_metadata() const { return m_type_metadata; }
|
||||
CellType const& type() const;
|
||||
CellTypeMetadata const& type_metadata() const { return m_type_metadata; }
|
||||
CellTypeMetadata& type_metadata() { return m_type_metadata; }
|
||||
|
||||
String source() const;
|
||||
|
@ -99,10 +99,10 @@ struct Cell : public Weakable<Cell> {
|
|||
void update();
|
||||
void update_data(Badge<Sheet>);
|
||||
|
||||
const Sheet& sheet() const { return *m_sheet; }
|
||||
Sheet const& sheet() const { return *m_sheet; }
|
||||
Sheet& sheet() { return *m_sheet; }
|
||||
|
||||
void copy_from(const Cell&);
|
||||
void copy_from(Cell const&);
|
||||
|
||||
private:
|
||||
bool m_dirty { false };
|
||||
|
@ -113,7 +113,7 @@ private:
|
|||
Kind m_kind { LiteralString };
|
||||
WeakPtr<Sheet> m_sheet;
|
||||
Vector<WeakPtr<Cell>> m_referencing_cells;
|
||||
const CellType* m_type { nullptr };
|
||||
CellType const* m_type { nullptr };
|
||||
CellTypeMetadata m_type_metadata;
|
||||
Position m_position;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
void CellSyntaxHighlighter::rehighlight(const Palette& palette)
|
||||
void CellSyntaxHighlighter::rehighlight(Palette const& palette)
|
||||
{
|
||||
auto text = m_client->get_text();
|
||||
m_client->spans().clear();
|
||||
|
|
|
@ -16,11 +16,11 @@ public:
|
|||
CellSyntaxHighlighter() = default;
|
||||
virtual ~CellSyntaxHighlighter() override = default;
|
||||
|
||||
virtual void rehighlight(const Palette&) override;
|
||||
void set_cell(const Cell* cell) { m_cell = cell; }
|
||||
virtual void rehighlight(Palette const&) override;
|
||||
void set_cell(Cell const* cell) { m_cell = cell; }
|
||||
|
||||
private:
|
||||
const Cell* m_cell { nullptr };
|
||||
Cell const* m_cell { nullptr };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ DateCell::DateCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> {
|
||||
auto timestamp = TRY(js_value(cell, metadata));
|
||||
|
@ -30,7 +30,7 @@ JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, const CellTypeMetada
|
|||
});
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, const CellTypeMetadata&) const
|
||||
JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, CellTypeMetadata const&) const
|
||||
{
|
||||
auto js_data = cell.js_data();
|
||||
auto value = TRY(js_data.to_double(cell.sheet().global_object()));
|
||||
|
|
|
@ -16,8 +16,8 @@ class DateCell : public CellType {
|
|||
public:
|
||||
DateCell();
|
||||
virtual ~DateCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,23 +21,23 @@ struct SingleEntryListNext {
|
|||
|
||||
template<typename PutChFunc, typename ArgumentListRefT, template<typename T, typename U = ArgumentListRefT> typename NextArgument, typename CharType>
|
||||
struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument, CharType> {
|
||||
ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, const int& nwritten)
|
||||
ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, int const& nwritten)
|
||||
: PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument>(putch, bufptr, nwritten)
|
||||
{
|
||||
}
|
||||
|
||||
// Disallow pointer formats.
|
||||
ALWAYS_INLINE int format_n(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const
|
||||
ALWAYS_INLINE int format_n(PrintfImplementation::ModifierState const&, ArgumentListRefT&) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
ALWAYS_INLINE int format_s(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const
|
||||
ALWAYS_INLINE int format_s(PrintfImplementation::ModifierState const&, ArgumentListRefT&) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
String format_double(const char* format, double value)
|
||||
String format_double(char const* format, double value)
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto putch = [&](auto, auto ch) { builder.append(ch); };
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
String format_double(const char* format, double value);
|
||||
String format_double(char const* format, double value);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ IdentityCell::IdentityCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto data = cell.js_data();
|
||||
if (!metadata.format.is_empty())
|
||||
|
@ -24,7 +24,7 @@ JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, const CellTypeMe
|
|||
return data.to_string(cell.sheet().global_object());
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, const CellTypeMetadata&) const
|
||||
JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, CellTypeMetadata const&) const
|
||||
{
|
||||
return cell.js_data();
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ class IdentityCell : public CellType {
|
|||
public:
|
||||
IdentityCell();
|
||||
virtual ~IdentityCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ NumericCell::NumericCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> {
|
||||
auto value = TRY(js_value(cell, metadata));
|
||||
|
@ -34,7 +34,7 @@ JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, const CellTypeMet
|
|||
});
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, const CellTypeMetadata&) const
|
||||
JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, CellTypeMetadata const&) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() {
|
||||
return cell.js_data().to_number(cell.sheet().global_object());
|
||||
|
|
|
@ -26,8 +26,8 @@ class NumericCell : public CellType {
|
|||
public:
|
||||
NumericCell();
|
||||
virtual ~NumericCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ StringCell::StringCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto string = TRY(cell.js_data().to_string(cell.sheet().global_object()));
|
||||
if (metadata.length >= 0)
|
||||
|
@ -24,7 +24,7 @@ JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, const CellTypeMeta
|
|||
return string;
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, const CellTypeMetadata& metadata) const
|
||||
JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto string = TRY(display(cell, metadata));
|
||||
return JS::js_string(cell.sheet().interpreter().heap(), string);
|
||||
|
|
|
@ -15,8 +15,8 @@ class StringCell : public CellType {
|
|||
public:
|
||||
StringCell();
|
||||
virtual ~StringCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ static Spreadsheet::DateCell s_date_cell;
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
const CellType* CellType::get_by_name(StringView name)
|
||||
CellType const* CellType::get_by_name(StringView name)
|
||||
{
|
||||
return s_cell_types.get(name).value_or(nullptr);
|
||||
}
|
||||
|
|
|
@ -32,15 +32,15 @@ enum class MetadataName {
|
|||
|
||||
class CellType {
|
||||
public:
|
||||
static const CellType* get_by_name(StringView);
|
||||
static CellType const* get_by_name(StringView);
|
||||
static Vector<StringView> names();
|
||||
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const = 0;
|
||||
virtual String metadata_hint(MetadataName) const { return {}; }
|
||||
virtual ~CellType() = default;
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
String const& name() const { return m_name; }
|
||||
|
||||
protected:
|
||||
CellType(StringView name);
|
||||
|
|
|
@ -29,7 +29,7 @@ REGISTER_WIDGET(Spreadsheet, ConditionsView);
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet, GUI::Window* parent)
|
||||
CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet, GUI::Window* parent)
|
||||
: GUI::Dialog(parent)
|
||||
{
|
||||
VERIFY(!positions.is_empty());
|
||||
|
@ -62,8 +62,8 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet,
|
|||
ok_button.on_click = [&](auto) { done(ExecOK); };
|
||||
}
|
||||
|
||||
const Vector<String> g_horizontal_alignments { "Left", "Center", "Right" };
|
||||
const Vector<String> g_vertical_alignments { "Top", "Center", "Bottom" };
|
||||
Vector<String> const g_horizontal_alignments { "Left", "Center", "Right" };
|
||||
Vector<String> const g_vertical_alignments { "Top", "Center", "Bottom" };
|
||||
Vector<String> g_types;
|
||||
|
||||
constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx::TextAlignment alignment)
|
||||
|
@ -110,7 +110,7 @@ constexpr static CellTypeDialog::HorizontalAlignment horizontal_alignment_from(G
|
|||
return CellTypeDialog::HorizontalAlignment::Right;
|
||||
}
|
||||
|
||||
void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& positions, Sheet& sheet)
|
||||
void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& positions, Sheet& sheet)
|
||||
{
|
||||
g_types.clear();
|
||||
for (auto& type_name : CellType::names())
|
||||
|
|
|
@ -18,7 +18,7 @@ class CellTypeDialog : public GUI::Dialog {
|
|||
|
||||
public:
|
||||
CellTypeMetadata metadata() const;
|
||||
const CellType* type() const { return m_type; }
|
||||
CellType const* type() const { return m_type; }
|
||||
Vector<ConditionalFormat> conditional_formats() { return m_conditional_formats; }
|
||||
|
||||
enum class HorizontalAlignment : int {
|
||||
|
@ -33,10 +33,10 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
CellTypeDialog(const Vector<Position>&, Sheet&, GUI::Window* parent = nullptr);
|
||||
void setup_tabs(GUI::TabWidget&, const Vector<Position>&, Sheet&);
|
||||
CellTypeDialog(Vector<Position> const&, Sheet&, GUI::Window* parent = nullptr);
|
||||
void setup_tabs(GUI::TabWidget&, Vector<Position> const&, Sheet&);
|
||||
|
||||
const CellType* m_type { nullptr };
|
||||
CellType const* m_type { nullptr };
|
||||
|
||||
int m_length { -1 };
|
||||
String m_format;
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
#include <unistd.h>
|
||||
|
||||
// This is defined in ImportDialog.cpp, we can't include it twice, since the generated symbol is exported.
|
||||
extern const char select_format_page_gml[];
|
||||
extern char const select_format_page_gml[];
|
||||
|
||||
namespace Spreadsheet {
|
||||
|
||||
CSVExportDialogPage::CSVExportDialogPage(const Sheet& sheet)
|
||||
CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
|
||||
: m_data(sheet.to_xsv())
|
||||
{
|
||||
m_headers.extend(m_data.take_first());
|
||||
|
@ -213,7 +213,7 @@ void CSVExportDialogPage::update_preview()
|
|||
m_data_preview_text_editor->update();
|
||||
}
|
||||
|
||||
Result<void, String> CSVExportDialogPage::move_into(const String& target)
|
||||
Result<void, String> CSVExportDialogPage::move_into(String const& target)
|
||||
{
|
||||
auto& source = m_temp_output_file_path;
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@ class Workbook;
|
|||
struct CSVExportDialogPage {
|
||||
using XSV = Writer::XSV<Vector<Vector<String>>, Vector<String>>;
|
||||
|
||||
explicit CSVExportDialogPage(const Sheet&);
|
||||
explicit CSVExportDialogPage(Sheet const&);
|
||||
|
||||
NonnullRefPtr<GUI::WizardPage> page() { return *m_page; }
|
||||
Optional<XSV>& writer() { return m_previously_made_writer; }
|
||||
Result<void, String> move_into(const String& target);
|
||||
Result<void, String> move_into(String const& target);
|
||||
|
||||
protected:
|
||||
void update_preview();
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
String key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; }
|
||||
|
||||
void set_from(const JsonObject& object)
|
||||
void set_from(JsonObject const& object)
|
||||
{
|
||||
m_keys.clear();
|
||||
object.for_each_member([this](auto& name, auto&) {
|
||||
|
|
|
@ -186,7 +186,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents)
|
|||
if (!position.has_value())
|
||||
return vm.throw_completion<JS::TypeError>(global_object, "Invalid cell name");
|
||||
|
||||
const auto* cell = sheet_object->m_sheet.at(position.value());
|
||||
auto const* cell = sheet_object->m_sheet.at(position.value());
|
||||
if (!cell)
|
||||
return JS::js_undefined();
|
||||
|
||||
|
|
|
@ -32,18 +32,18 @@ struct Position {
|
|||
return m_hash;
|
||||
}
|
||||
|
||||
bool operator==(const Position& other) const
|
||||
bool operator==(Position const& other) const
|
||||
{
|
||||
return row == other.row && column == other.column;
|
||||
}
|
||||
|
||||
bool operator!=(const Position& other) const
|
||||
bool operator!=(Position const& other) const
|
||||
{
|
||||
return !(other == *this);
|
||||
}
|
||||
|
||||
String to_cell_identifier(const Sheet& sheet) const;
|
||||
URL to_url(const Sheet& sheet) const;
|
||||
String to_cell_identifier(Sheet const& sheet) const;
|
||||
URL to_url(Sheet const& sheet) const;
|
||||
|
||||
size_t column { 0 };
|
||||
size_t row { 0 };
|
||||
|
|
|
@ -274,7 +274,7 @@ XSV::Field XSV::read_one_unquoted_field()
|
|||
StringView XSV::Row::operator[](StringView name) const
|
||||
{
|
||||
VERIFY(!m_xsv.m_names.is_empty());
|
||||
auto it = m_xsv.m_names.find_if([&](const auto& entry) { return name == entry; });
|
||||
auto it = m_xsv.m_names.find_if([&](auto const& entry) { return name == entry; });
|
||||
VERIFY(!it.is_end());
|
||||
|
||||
return (*this)[it.index()];
|
||||
|
|
|
@ -146,11 +146,11 @@ public:
|
|||
}
|
||||
|
||||
bool is_end() const { return m_index == m_xsv.m_rows.size(); }
|
||||
bool operator==(const RowIterator& other) const
|
||||
bool operator==(RowIterator const& other) const
|
||||
{
|
||||
return m_index == other.m_index && &m_xsv == &other.m_xsv;
|
||||
}
|
||||
bool operator==(const RowIterator<!const_>& other) const
|
||||
bool operator==(RowIterator<!const_> const& other) const
|
||||
{
|
||||
return m_index == other.m_index && &m_xsv == &other.m_xsv;
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ Cell* Sheet::at(StringView name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Cell* Sheet::at(const Position& position)
|
||||
Cell* Sheet::at(Position const& position)
|
||||
{
|
||||
auto it = m_cells.find(position);
|
||||
|
||||
|
@ -271,7 +271,7 @@ Optional<Position> Sheet::position_from_url(const URL& url) const
|
|||
return parse_cell_name(url.fragment());
|
||||
}
|
||||
|
||||
Position Sheet::offset_relative_to(const Position& base, const Position& offset, const Position& offset_base) const
|
||||
Position Sheet::offset_relative_to(Position const& base, Position const& offset, Position const& offset_base) const
|
||||
{
|
||||
if (offset.column >= m_columns.size()) {
|
||||
dbgln("Column '{}' does not exist!", offset.column);
|
||||
|
@ -361,7 +361,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
|
||||
RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
|
||||
{
|
||||
auto sheet = adopt_ref(*new Sheet(workbook));
|
||||
auto rows = object.get("rows").to_u32(default_row_count);
|
||||
|
@ -391,7 +391,7 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
|
|||
auto json = sheet->interpreter().global_object().get_without_side_effects("JSON");
|
||||
auto& parse_function = json.as_object().get_without_side_effects("parse").as_function();
|
||||
|
||||
auto read_format = [](auto& format, const auto& obj) {
|
||||
auto read_format = [](auto& format, auto const& obj) {
|
||||
if (auto value = obj.get("foreground_color"); value.is_string())
|
||||
format.foreground_color = Color::from_string(value.as_string());
|
||||
if (auto value = obj.get("background_color"); value.is_string())
|
||||
|
@ -519,7 +519,7 @@ JsonObject Sheet::to_json() const
|
|||
JsonObject object;
|
||||
object.set("name", m_name);
|
||||
|
||||
auto save_format = [](const auto& format, auto& obj) {
|
||||
auto save_format = [](auto const& format, auto& obj) {
|
||||
if (format.foreground_color.has_value())
|
||||
obj.set("foreground_color", format.foreground_color.value().to_string());
|
||||
if (format.background_color.has_value())
|
||||
|
@ -629,7 +629,7 @@ Vector<Vector<String>> Sheet::to_xsv() const
|
|||
return data;
|
||||
}
|
||||
|
||||
RefPtr<Sheet> Sheet::from_xsv(const Reader::XSV& xsv, Workbook& workbook)
|
||||
RefPtr<Sheet> Sheet::from_xsv(Reader::XSV const& xsv, Workbook& workbook)
|
||||
{
|
||||
auto cols = xsv.headers();
|
||||
auto rows = xsv.size();
|
||||
|
@ -736,12 +736,12 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String Position::to_cell_identifier(const Sheet& sheet) const
|
||||
String Position::to_cell_identifier(Sheet const& sheet) const
|
||||
{
|
||||
return String::formatted("{}{}", sheet.column(column), row);
|
||||
}
|
||||
|
||||
URL Position::to_url(const Sheet& sheet) const
|
||||
URL Position::to_url(Sheet const& sheet) const
|
||||
{
|
||||
URL url;
|
||||
url.set_protocol("spreadsheet");
|
||||
|
|
|
@ -36,37 +36,37 @@ public:
|
|||
Optional<String> column_arithmetic(StringView column_name, int offset);
|
||||
|
||||
Cell* from_url(const URL&);
|
||||
const Cell* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); }
|
||||
Cell const* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); }
|
||||
Optional<Position> position_from_url(const URL& url) const;
|
||||
|
||||
/// Resolve 'offset' to an absolute position assuming 'base' is at 'offset_base'.
|
||||
/// Effectively, "Walk the distance between 'offset' and 'offset_base' away from 'base'".
|
||||
Position offset_relative_to(const Position& base, const Position& offset, const Position& offset_base) const;
|
||||
Position offset_relative_to(Position const& base, Position const& offset, Position const& offset_base) const;
|
||||
|
||||
JsonObject to_json() const;
|
||||
static RefPtr<Sheet> from_json(const JsonObject&, Workbook&);
|
||||
static RefPtr<Sheet> from_json(JsonObject const&, Workbook&);
|
||||
|
||||
Vector<Vector<String>> to_xsv() const;
|
||||
static RefPtr<Sheet> from_xsv(const Reader::XSV&, Workbook&);
|
||||
static RefPtr<Sheet> from_xsv(Reader::XSV const&, Workbook&);
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
String const& name() const { return m_name; }
|
||||
void set_name(StringView name) { m_name = name; }
|
||||
|
||||
JsonObject gather_documentation() const;
|
||||
|
||||
const HashTable<Position>& selected_cells() const { return m_selected_cells; }
|
||||
HashTable<Position> const& selected_cells() const { return m_selected_cells; }
|
||||
HashTable<Position>& selected_cells() { return m_selected_cells; }
|
||||
const HashMap<Position, NonnullOwnPtr<Cell>>& cells() const { return m_cells; }
|
||||
HashMap<Position, NonnullOwnPtr<Cell>> const& cells() const { return m_cells; }
|
||||
HashMap<Position, NonnullOwnPtr<Cell>>& cells() { return m_cells; }
|
||||
|
||||
Cell* at(const Position& position);
|
||||
const Cell* at(const Position& position) const { return const_cast<Sheet*>(this)->at(position); }
|
||||
Cell* at(Position const& position);
|
||||
Cell const* at(Position const& position) const { return const_cast<Sheet*>(this)->at(position); }
|
||||
|
||||
const Cell* at(StringView name) const { return const_cast<Sheet*>(this)->at(name); }
|
||||
Cell const* at(StringView name) const { return const_cast<Sheet*>(this)->at(name); }
|
||||
Cell* at(StringView);
|
||||
|
||||
const Cell& ensure(const Position& position) const { return const_cast<Sheet*>(this)->ensure(position); }
|
||||
Cell& ensure(const Position& position)
|
||||
Cell const& ensure(Position const& position) const { return const_cast<Sheet*>(this)->ensure(position); }
|
||||
Cell& ensure(Position const& position)
|
||||
{
|
||||
if (auto cell = at(position))
|
||||
return *cell;
|
||||
|
@ -80,8 +80,8 @@ public:
|
|||
|
||||
size_t row_count() const { return m_rows; }
|
||||
size_t column_count() const { return m_columns.size(); }
|
||||
const Vector<String>& columns() const { return m_columns; }
|
||||
const String& column(size_t index)
|
||||
Vector<String> const& columns() const { return m_columns; }
|
||||
String const& column(size_t index)
|
||||
{
|
||||
for (size_t i = column_count(); i < index; ++i)
|
||||
add_column();
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
VERIFY(column_count() > index);
|
||||
return m_columns[index];
|
||||
}
|
||||
const String& column(size_t index) const
|
||||
String const& column(size_t index) const
|
||||
{
|
||||
VERIFY(column_count() > index);
|
||||
return m_columns[index];
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
Cell*& current_evaluated_cell() { return m_current_cell_being_evaluated; }
|
||||
bool has_been_visited(Cell* cell) const { return m_visited_cells_in_update.contains(cell); }
|
||||
|
||||
const Workbook& workbook() const { return m_workbook; }
|
||||
Workbook const& workbook() const { return m_workbook; }
|
||||
|
||||
enum class CopyOperation {
|
||||
Copy,
|
||||
|
@ -160,7 +160,7 @@ namespace AK {
|
|||
template<>
|
||||
struct Traits<Spreadsheet::Position> : public GenericTraits<Spreadsheet::Position> {
|
||||
static constexpr bool is_trivial() { return false; }
|
||||
static unsigned hash(const Spreadsheet::Position& p)
|
||||
static unsigned hash(Spreadsheet::Position const& p)
|
||||
{
|
||||
return p.hash();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
return {};
|
||||
|
||||
if (role == GUI::ModelRole::Display) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return String::empty();
|
||||
|
||||
|
@ -63,7 +63,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
return Position { (size_t)index.column(), (size_t)index.row() }.to_url(m_sheet).to_string();
|
||||
|
||||
if (role == GUI::ModelRole::TextAlignment) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return {};
|
||||
|
||||
|
@ -71,7 +71,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
}
|
||||
|
||||
if (role == GUI::ModelRole::ForegroundColor) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return {};
|
||||
|
||||
|
@ -90,7 +90,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
}
|
||||
|
||||
if (role == GUI::ModelRole::BackgroundColor) {
|
||||
const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return {};
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ void SpreadsheetView::EditingDelegate::set_value(GUI::Variant const& value, GUI:
|
|||
return StringModelEditingDelegate::set_value(value, selection_behavior);
|
||||
|
||||
m_has_set_initial_value = true;
|
||||
const auto option = m_sheet.at({ (size_t)index().column(), (size_t)index().row() });
|
||||
auto const option = m_sheet.at({ (size_t)index().column(), (size_t)index().row() });
|
||||
if (option)
|
||||
return StringModelEditingDelegate::set_value(option->source(), selection_behavior);
|
||||
|
||||
|
@ -461,7 +461,7 @@ void SpreadsheetView::move_cursor(GUI::AbstractView::CursorMovement direction)
|
|||
m_table_view->move_cursor(direction, GUI::AbstractView::SelectionUpdate::Set);
|
||||
}
|
||||
|
||||
void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, const Gfx::IntRect& rect, const Gfx::Palette& palette, const GUI::ModelIndex& index)
|
||||
void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, Gfx::IntRect const& rect, Gfx::Palette const& palette, const GUI::ModelIndex& index)
|
||||
{
|
||||
// Draw a border.
|
||||
// Undo the horizontal padding done by the table view...
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
|
||||
class EditingDelegate final : public GUI::StringModelEditingDelegate {
|
||||
public:
|
||||
EditingDelegate(const Sheet& sheet)
|
||||
EditingDelegate(Sheet const& sheet)
|
||||
: m_sheet(sheet)
|
||||
{
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
|
||||
private:
|
||||
bool m_has_set_initial_value { false };
|
||||
const Sheet& m_sheet;
|
||||
Sheet const& m_sheet;
|
||||
};
|
||||
|
||||
class TableCellPainter final : public GUI::TableCellPaintingDelegate {
|
||||
|
@ -157,7 +157,7 @@ private:
|
|||
: m_table_view(view)
|
||||
{
|
||||
}
|
||||
void paint(GUI::Painter&, const Gfx::IntRect&, const Gfx::Palette&, const GUI::ModelIndex&) override;
|
||||
void paint(GUI::Painter&, Gfx::IntRect const&, Gfx::Palette const&, const GUI::ModelIndex&) override;
|
||||
|
||||
private:
|
||||
const GUI::TableView& m_table_view;
|
||||
|
|
|
@ -26,13 +26,13 @@ public:
|
|||
void add_sheet();
|
||||
void add_sheet(NonnullRefPtr<Sheet>&&);
|
||||
|
||||
const String& current_filename() const { return m_workbook->current_filename(); }
|
||||
String const& current_filename() const { return m_workbook->current_filename(); }
|
||||
SpreadsheetView* current_view() { return static_cast<SpreadsheetView*>(m_tab_widget->active_widget()); }
|
||||
Sheet* current_worksheet_if_available() { return current_view() ? current_view()->sheet_if_available() : nullptr; }
|
||||
void update_window_title();
|
||||
|
||||
Workbook& workbook() { return *m_workbook; }
|
||||
const Workbook& workbook() const { return *m_workbook; }
|
||||
Workbook const& workbook() const { return *m_workbook; }
|
||||
|
||||
const GUI::ModelIndex* current_selection_cursor()
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_wind
|
|||
m_vm->enable_default_host_import_module_dynamically_hook();
|
||||
}
|
||||
|
||||
bool Workbook::set_filename(const String& filename)
|
||||
bool Workbook::set_filename(String const& filename)
|
||||
{
|
||||
if (m_current_filename == filename)
|
||||
return false;
|
||||
|
|
|
@ -21,14 +21,14 @@ public:
|
|||
Result<bool, String> load(StringView filename);
|
||||
Result<bool, String> open_file(Core::File&);
|
||||
|
||||
const String& current_filename() const { return m_current_filename; }
|
||||
bool set_filename(const String& filename);
|
||||
String const& current_filename() const { return m_current_filename; }
|
||||
bool set_filename(String const& filename);
|
||||
bool dirty() { return m_dirty; }
|
||||
void set_dirty(bool dirty) { m_dirty = dirty; }
|
||||
|
||||
bool has_sheets() const { return !m_sheets.is_empty(); }
|
||||
|
||||
const NonnullRefPtrVector<Sheet>& sheets() const { return m_sheets; }
|
||||
NonnullRefPtrVector<Sheet> const& sheets() const { return m_sheets; }
|
||||
NonnullRefPtrVector<Sheet> sheets() { return m_sheets; }
|
||||
|
||||
Sheet& add_sheet(StringView name)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Writer {
|
|||
template<typename ContainerType>
|
||||
class CSV : public XSV<ContainerType> {
|
||||
public:
|
||||
CSV(OutputStream& output, const ContainerType& data, const Vector<StringView>& headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
CSV(OutputStream& output, ContainerType const& data, Vector<StringView> const& headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
: XSV<ContainerType>(output, data, { ",", "\"", WriterTraits::Repeat }, headers, behaviors)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ constexpr WriterBehavior default_behaviors()
|
|||
template<typename ContainerType, typename HeaderType = Vector<StringView>>
|
||||
class XSV {
|
||||
public:
|
||||
XSV(OutputStream& output, const ContainerType& data, const WriterTraits& traits, const HeaderType& headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
XSV(OutputStream& output, ContainerType const& data, WriterTraits const& traits, HeaderType const& headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
: m_data(data)
|
||||
, m_traits(traits)
|
||||
, m_behaviors(behaviors)
|
||||
|
@ -188,10 +188,10 @@ private:
|
|||
set_error(WriteError::InternalError);
|
||||
}
|
||||
|
||||
const ContainerType& m_data;
|
||||
const WriterTraits& m_traits;
|
||||
ContainerType const& m_data;
|
||||
WriterTraits const& m_traits;
|
||||
WriterBehavior m_behaviors;
|
||||
const HeaderType& m_names;
|
||||
HeaderType const& m_names;
|
||||
WriteError m_error { WriteError::None };
|
||||
OutputStream& m_output;
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto app = GUI::Application::construct(arguments);
|
||||
|
||||
const char* filename = nullptr;
|
||||
char const* filename = nullptr;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(filename, "File to read from", "file", Core::ArgsParser::Required::No);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue