summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r--Userland/Applications/Spreadsheet/Cell.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/CellType/Date.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/CellType/Identity.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/CellType/Numeric.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/CellType/String.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/ExportDialog.cpp6
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.cpp36
-rw-r--r--Userland/Applications/Spreadsheet/ImportDialog.cpp6
-rw-r--r--Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp26
-rw-r--r--Userland/Applications/Spreadsheet/Readers/XSV.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp50
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetModel.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetModel.h2
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp38
-rw-r--r--Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/main.cpp4
16 files changed, 97 insertions, 97 deletions
diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp
index ae49b1b1a5..1a0d6cabae 100644
--- a/Userland/Applications/Spreadsheet/Cell.cpp
+++ b/Userland/Applications/Spreadsheet/Cell.cpp
@@ -74,10 +74,10 @@ CellType const& Cell::type() const
if (m_kind == LiteralString) {
if (m_data.to_int().has_value())
- return *CellType::get_by_name("Numeric");
+ return *CellType::get_by_name("Numeric"sv);
}
- return *CellType::get_by_name("Identity");
+ return *CellType::get_by_name("Identity"sv);
}
JS::ThrowCompletionOr<String> Cell::typed_display() const
diff --git a/Userland/Applications/Spreadsheet/CellType/Date.cpp b/Userland/Applications/Spreadsheet/CellType/Date.cpp
index 9810f162d9..f74a5d5a1b 100644
--- a/Userland/Applications/Spreadsheet/CellType/Date.cpp
+++ b/Userland/Applications/Spreadsheet/CellType/Date.cpp
@@ -13,7 +13,7 @@
namespace Spreadsheet {
DateCell::DateCell()
- : CellType("Date")
+ : CellType("Date"sv)
{
}
@@ -21,7 +21,7 @@ JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, CellTypeMetadata con
{
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> {
auto timestamp = TRY(js_value(cell, metadata));
- auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(cell.sheet().global_object()))).to_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S" : metadata.format.characters());
+ auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(cell.sheet().global_object()))).to_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S"sv : metadata.format.view());
if (metadata.length >= 0)
return string.substring(0, metadata.length);
diff --git a/Userland/Applications/Spreadsheet/CellType/Identity.cpp b/Userland/Applications/Spreadsheet/CellType/Identity.cpp
index b44c7c5802..580f7b917a 100644
--- a/Userland/Applications/Spreadsheet/CellType/Identity.cpp
+++ b/Userland/Applications/Spreadsheet/CellType/Identity.cpp
@@ -11,7 +11,7 @@
namespace Spreadsheet {
IdentityCell::IdentityCell()
- : CellType("Identity")
+ : CellType("Identity"sv)
{
}
diff --git a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp
index 483c55d0b4..33bda0507a 100644
--- a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp
+++ b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp
@@ -13,7 +13,7 @@
namespace Spreadsheet {
NumericCell::NumericCell()
- : CellType("Numeric")
+ : CellType("Numeric"sv)
{
}
diff --git a/Userland/Applications/Spreadsheet/CellType/String.cpp b/Userland/Applications/Spreadsheet/CellType/String.cpp
index c0707be469..8a066bbfe5 100644
--- a/Userland/Applications/Spreadsheet/CellType/String.cpp
+++ b/Userland/Applications/Spreadsheet/CellType/String.cpp
@@ -11,7 +11,7 @@
namespace Spreadsheet {
StringCell::StringCell()
- : CellType("String")
+ : CellType("String"sv)
{
}
diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp
index 502e9be0b2..6f5cd8c8f7 100644
--- a/Userland/Applications/Spreadsheet/ExportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp
@@ -26,7 +26,7 @@
#include <unistd.h>
// This is defined in ImportDialog.cpp, we can't include it twice, since the generated symbol is exported.
-extern char const select_format_page_gml[];
+extern StringView select_format_page_gml;
namespace Spreadsheet {
@@ -245,7 +245,7 @@ Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File&
{
auto wizard = GUI::WizardDialog::construct(GUI::Application::the()->active_window());
wizard->set_title("File Export Wizard");
- wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet").bitmap_for_size(16));
+ wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
auto export_xsv = [&]() -> Result<void, String> {
// FIXME: Prompt for the user to select a specific sheet to export
@@ -283,7 +283,7 @@ Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File&
auto const* error = strerror(error_number);
StringBuilder sb;
- sb.append("Unable to save file. Error: ");
+ sb.append("Unable to save file. Error: "sv);
sb.append({ error, strlen(error) });
return sb.to_string();
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp
index 6a9f5eb71e..4ee6d5089c 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.cpp
+++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp
@@ -65,7 +65,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
{
resize(530, 365);
set_title("Spreadsheet Functions Help");
- set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors());
+ set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors());
set_accessory(true);
auto& widget = set_main_widget<GUI::Widget>();
@@ -93,7 +93,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
auto& doc = doc_option.as_object();
const auto& name = url.fragment();
- auto* example_data_ptr = doc.get_ptr("example_data");
+ auto* example_data_ptr = doc.get_ptr("example_data"sv);
if (!example_data_ptr || !example_data_ptr->is_object()) {
GUI::MessageBox::show_error(this, String::formatted("No example data found for '{}'", url.path()));
return;
@@ -143,47 +143,47 @@ String HelpWindow::render(StringView key)
VERIFY(m_docs.has_object(key));
auto& doc = m_docs.get(key).as_object();
- auto name = doc.get("name").to_string();
- auto argc = doc.get("argc").to_u32(0);
- VERIFY(doc.has_array("argnames"));
- auto& argnames = doc.get("argnames").as_array();
+ auto name = doc.get("name"sv).to_string();
+ auto argc = doc.get("argc"sv).to_u32(0);
+ VERIFY(doc.has_array("argnames"sv));
+ auto& argnames = doc.get("argnames"sv).as_array();
- auto docstring = doc.get("doc").to_string();
+ auto docstring = doc.get("doc"sv).to_string();
StringBuilder markdown_builder;
- markdown_builder.append("# NAME\n`");
+ markdown_builder.append("# NAME\n`"sv);
markdown_builder.append(name);
- markdown_builder.append("`\n\n");
+ markdown_builder.append("`\n\n"sv);
- markdown_builder.append("# ARGUMENTS\n");
+ markdown_builder.append("# ARGUMENTS\n"sv);
if (argc > 0)
markdown_builder.appendff("{} required argument(s):\n", argc);
else
- markdown_builder.append("No required arguments.\n");
+ markdown_builder.append("No required arguments.\n"sv);
for (size_t i = 0; i < argc; ++i)
markdown_builder.appendff("- `{}`\n", argnames.at(i).to_string());
if (argc > 0)
- markdown_builder.append("\n");
+ markdown_builder.append("\n"sv);
if ((size_t)argnames.size() > argc) {
auto opt_count = argnames.size() - argc;
markdown_builder.appendff("{} optional argument(s):\n", opt_count);
for (size_t i = argc; i < (size_t)argnames.size(); ++i)
markdown_builder.appendff("- `{}`\n", argnames.at(i).to_string());
- markdown_builder.append("\n");
+ markdown_builder.append("\n"sv);
}
- markdown_builder.append("# DESCRIPTION\n");
+ markdown_builder.append("# DESCRIPTION\n"sv);
markdown_builder.append(docstring);
- markdown_builder.append("\n\n");
+ markdown_builder.append("\n\n"sv);
- if (doc.has("examples")) {
- auto& examples = doc.get("examples");
+ if (doc.has("examples"sv)) {
+ auto& examples = doc.get("examples"sv);
VERIFY(examples.is_object());
- markdown_builder.append("# EXAMPLES\n");
+ markdown_builder.append("# EXAMPLES\n"sv);
examples.as_object().for_each_member([&](auto& text, auto& description_value) {
dbgln("```js\n{}\n```\n\n- {}\n", text, description_value.to_string());
markdown_builder.appendff("```js\n{}\n```\n\n- {}\n", text, description_value.to_string());
diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp
index 3b5c794f65..7382f6f2bd 100644
--- a/Userland/Applications/Spreadsheet/ImportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp
@@ -179,7 +179,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W
{
auto wizard = GUI::WizardDialog::construct(&parent);
wizard->set_title("File Import Wizard");
- wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet").bitmap_for_size(16));
+ wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
auto import_xsv = [&]() -> Result<NonnullRefPtrVector<Sheet>, String> {
auto contents = file.read_all();
@@ -212,7 +212,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W
auto json_value_option = JsonParser(file.read_all()).parse();
if (json_value_option.is_error()) {
StringBuilder sb;
- sb.append("Failed to parse ");
+ sb.append("Failed to parse "sv);
sb.append(file.filename());
return sb.to_string();
@@ -221,7 +221,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W
auto& json_value = json_value_option.value();
if (!json_value.is_array()) {
StringBuilder sb;
- sb.append("Did not find a spreadsheet in ");
+ sb.append("Did not find a spreadsheet in "sv);
sb.append(file.filename());
return sb.to_string();
diff --git a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp
index 0103e4c6c0..82a0df5ab3 100644
--- a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp
+++ b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp
@@ -18,29 +18,29 @@ TEST_CASE(should_parse_valid_data)
auto data = R"~~~(Foo, Bar, Baz
1, 2, 3
4, 5, 6
- """x", y"z, 9)~~~";
+ """x", y"z, 9)~~~"sv;
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(!csv.has_error());
- EXPECT_EQ(csv[0]["Foo"], "1");
- EXPECT_EQ(csv[2]["Foo"], "\"x");
- EXPECT_EQ(csv[2]["Bar"], "y\"z");
+ EXPECT_EQ(csv[0]["Foo"sv], "1"sv);
+ EXPECT_EQ(csv[2]["Foo"sv], "\"x"sv);
+ EXPECT_EQ(csv[2]["Bar"sv], "y\"z"sv);
}
{
auto data = R"~~~(Foo, Bar, Baz
1 , 2, 3
4, "5 " , 6
- """x", y"z, 9 )~~~";
+ """x", y"z, 9 )~~~"sv;
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces | Reader::ParserBehavior::TrimTrailingFieldSpaces };
csv.parse();
EXPECT(!csv.has_error());
- EXPECT_EQ(csv[0]["Foo"], "1");
- EXPECT_EQ(csv[1]["Bar"], "5 ");
- EXPECT_EQ(csv[2]["Foo"], "\"x");
- EXPECT_EQ(csv[2]["Baz"], "9");
+ EXPECT_EQ(csv[0]["Foo"sv], "1"sv);
+ EXPECT_EQ(csv[1]["Bar"sv], "5 "sv);
+ EXPECT_EQ(csv[2]["Foo"sv], "\"x"sv);
+ EXPECT_EQ(csv[2]["Baz"sv], "9"sv);
}
}
@@ -48,7 +48,7 @@ TEST_CASE(should_fail_nicely)
{
{
auto data = R"~~~(Foo, Bar, Baz
- x, y)~~~";
+ x, y)~~~"sv;
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(csv.has_error());
@@ -57,7 +57,7 @@ TEST_CASE(should_fail_nicely)
{
auto data = R"~~~(Foo, Bar, Baz
- x, y, "z)~~~";
+ x, y, "z)~~~"sv;
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(csv.has_error());
@@ -70,7 +70,7 @@ TEST_CASE(should_iterate_rows)
auto data = R"~~~(Foo, Bar, Baz
1, 2, 3
4, 5, 6
- """x", y"z, 9)~~~";
+ """x", y"z, 9)~~~"sv;
auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces };
csv.parse();
EXPECT(!csv.has_error());
@@ -93,7 +93,7 @@ BENCHMARK_CASE(fairly_big_data)
memcpy(buf.offset_pointer(row * line.length()), line.characters_without_null_termination(), line.length());
}
- auto csv = Reader::CSV { (char const*)buf.data(), Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders };
+ auto csv = Reader::CSV { StringView { buf.bytes() }, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders };
csv.parse();
EXPECT(!csv.has_error());
diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.cpp b/Userland/Applications/Spreadsheet/Readers/XSV.cpp
index 4170743195..6a1533aabd 100644
--- a/Userland/Applications/Spreadsheet/Readers/XSV.cpp
+++ b/Userland/Applications/Spreadsheet/Readers/XSV.cpp
@@ -133,7 +133,7 @@ Vector<XSV::Field> XSV::read_row(bool header_row)
XSV::Field XSV::read_one_field()
{
if ((m_behaviors & ParserBehavior::TrimLeadingFieldSpaces) != ParserBehavior::None)
- m_lexer.consume_while(is_any_of(" \t\v"));
+ m_lexer.consume_while(is_any_of(" \t\v"sv));
bool is_quoted = false;
Field field;
@@ -145,7 +145,7 @@ XSV::Field XSV::read_one_field()
}
if ((m_behaviors & ParserBehavior::TrimTrailingFieldSpaces) != ParserBehavior::None) {
- m_lexer.consume_while(is_any_of(" \t\v"));
+ m_lexer.consume_while(is_any_of(" \t\v"sv));
if (!is_quoted) {
// Also have to trim trailing spaces from unquoted fields.
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index 1cebe1a055..18de026374 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -48,7 +48,7 @@ Sheet::Sheet(Workbook& workbook)
global_object().define_direct_property("thisSheet", &global_object(), JS::default_attributes); // Self-reference is unfortunate, but required.
// Sadly, these have to be evaluated once per sheet.
- constexpr StringView runtime_file_path = "/res/js/Spreadsheet/runtime.js";
+ constexpr auto runtime_file_path = "/res/js/Spreadsheet/runtime.js"sv;
auto file_or_error = Core::File::open(runtime_file_path, Core::OpenMode::ReadOnly);
if (!file_or_error.is_error()) {
auto buffer = file_or_error.value()->read_all();
@@ -94,7 +94,7 @@ size_t Sheet::add_row()
static Optional<size_t> convert_from_string(StringView str, unsigned base = 26, StringView map = {})
{
if (map.is_null())
- map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"sv;
VERIFY(base >= 2 && base <= map.length());
@@ -375,10 +375,10 @@ Vector<CellChange> Sheet::copy_cells(Vector<Position> from, Vector<Position> to,
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);
- auto columns = object.get("columns");
- auto name = object.get("name").as_string_or("Sheet");
- if (object.has("cells") && !object.has_object("cells"))
+ auto rows = object.get("rows"sv).to_u32(default_row_count);
+ auto columns = object.get("columns"sv);
+ auto name = object.get("name"sv).as_string_or("Sheet");
+ if (object.has("cells"sv) && !object.has_object("cells"sv))
return {};
sheet->set_name(name);
@@ -403,51 +403,51 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
auto& parse_function = json.as_object().get_without_side_effects("parse").as_function();
auto read_format = [](auto& format, auto const& obj) {
- if (auto value = obj.get("foreground_color"); value.is_string())
+ if (auto value = obj.get("foreground_color"sv); value.is_string())
format.foreground_color = Color::from_string(value.as_string());
- if (auto value = obj.get("background_color"); value.is_string())
+ if (auto value = obj.get("background_color"sv); value.is_string())
format.background_color = Color::from_string(value.as_string());
};
- if (object.has_object("cells")) {
- object.get("cells").as_object().for_each_member([&](auto& name, JsonValue const& value) {
+ if (object.has_object("cells"sv)) {
+ object.get("cells"sv).as_object().for_each_member([&](auto& name, JsonValue const& value) {
auto position_option = sheet->parse_cell_name(name);
if (!position_option.has_value())
return IterationDecision::Continue;
auto position = position_option.value();
auto& obj = value.as_object();
- auto kind = obj.get("kind").as_string_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula;
+ auto kind = obj.get("kind"sv).as_string_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula;
OwnPtr<Cell> cell;
switch (kind) {
case Cell::LiteralString:
- cell = make<Cell>(obj.get("value").to_string(), position, *sheet);
+ cell = make<Cell>(obj.get("value"sv).to_string(), position, *sheet);
break;
case Cell::Formula: {
auto& interpreter = sheet->interpreter();
- auto value_or_error = JS::call(interpreter.global_object(), parse_function, json, JS::js_string(interpreter.heap(), obj.get("value").as_string()));
+ auto value_or_error = JS::call(interpreter.global_object(), parse_function, json, JS::js_string(interpreter.heap(), obj.get("value"sv).as_string()));
if (value_or_error.is_error()) {
warnln("Failed to load previous value for cell {}, leaving as undefined", position.to_cell_identifier(sheet));
value_or_error = JS::js_undefined();
}
- cell = make<Cell>(obj.get("source").to_string(), value_or_error.release_value(), position, *sheet);
+ cell = make<Cell>(obj.get("source"sv).to_string(), value_or_error.release_value(), position, *sheet);
break;
}
}
- auto type_name = obj.has("type") ? obj.get("type").to_string() : "Numeric";
+ auto type_name = obj.has("type"sv) ? obj.get("type"sv).to_string() : "Numeric";
cell->set_type(type_name);
- auto type_meta = obj.get("type_metadata");
+ auto type_meta = obj.get("type_metadata"sv);
if (type_meta.is_object()) {
auto& meta_obj = type_meta.as_object();
auto meta = cell->type_metadata();
- if (auto value = meta_obj.get("length"); value.is_number())
+ if (auto value = meta_obj.get("length"sv); value.is_number())
meta.length = value.to_i32();
- if (auto value = meta_obj.get("format"); value.is_string())
+ if (auto value = meta_obj.get("format"sv); value.is_string())
meta.format = value.as_string();
- if (auto value = meta_obj.get("alignment"); value.is_string()) {
+ if (auto value = meta_obj.get("alignment"sv); value.is_string()) {
auto alignment = Gfx::text_alignment_from_string(value.as_string());
if (alignment.has_value())
meta.alignment = alignment.value();
@@ -457,7 +457,7 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
cell->set_type_metadata(move(meta));
}
- auto conditional_formats = obj.get("conditional_formats");
+ auto conditional_formats = obj.get("conditional_formats"sv);
auto cformats = cell->conditional_formats();
if (conditional_formats.is_array()) {
conditional_formats.as_array().for_each([&](const auto& fmt_val) {
@@ -465,7 +465,7 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
return IterationDecision::Continue;
auto& fmt_obj = fmt_val.as_object();
- auto fmt_cond = fmt_obj.get("condition").to_string();
+ auto fmt_cond = fmt_obj.get("condition"sv).to_string();
if (fmt_cond.is_empty())
return IterationDecision::Continue;
@@ -479,7 +479,7 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
cell->set_conditional_formats(move(cformats));
}
- auto evaluated_format = obj.get("evaluated_formats");
+ auto evaluated_format = obj.get("evaluated_formats"sv);
if (evaluated_format.is_object()) {
auto& evaluated_format_obj = evaluated_format.as_object();
auto& evaluated_fmts = cell->evaluated_formats();
@@ -722,8 +722,8 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu
return String::formatted("{}(...???{})", function, argument_index);
auto& entry_object = entry.as_object();
- size_t argc = entry_object.get("argc").to_int(0);
- auto argnames_value = entry_object.get("argnames");
+ size_t argc = entry_object.get("argc"sv).to_int(0);
+ auto argnames_value = entry_object.get("argnames"sv);
if (!argnames_value.is_array())
return String::formatted("{}(...{}???{})", function, argc, argument_index);
auto& argnames = argnames_value.as_array();
@@ -731,7 +731,7 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu
builder.appendff("{}(", function);
for (size_t i = 0; i < (size_t)argnames.size(); ++i) {
if (i != 0 && i < (size_t)argnames.size())
- builder.append(", ");
+ builder.append(", "sv);
if (i == argument_index)
builder.append('<');
else if (i >= argc)
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp
index 3d496c6ad3..dfa11afd00 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp
@@ -121,12 +121,12 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
StringBuilder builder;
builder.appendff("{}\n", error.get_without_side_effects(object.vm().names.message).to_string_without_side_effects());
for (auto const& frame : trace.in_reverse()) {
- if (frame.source_range.filename.contains("runtime.js")) {
+ if (frame.source_range.filename.contains("runtime.js"sv)) {
if (frame.function_name == "<unknown>")
builder.appendff(" in a builtin function at line {}, column {}\n", frame.source_range.start.line, frame.source_range.start.column);
else
builder.appendff(" while evaluating builtin '{}'\n", frame.function_name);
- } else if (frame.source_range.filename.starts_with("cell ")) {
+ } else if (frame.source_range.filename.starts_with("cell "sv)) {
builder.appendff(" in cell '{}', at line {}, column {}\n", frame.source_range.filename.substring_view(5), frame.source_range.start.line, frame.source_range.start.column);
}
}
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.h b/Userland/Applications/Spreadsheet/SpreadsheetModel.h
index a54b210405..8cdabde030 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetModel.h
+++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.h
@@ -29,7 +29,7 @@ public:
virtual bool is_editable(const GUI::ModelIndex&) const override;
virtual void set_data(const GUI::ModelIndex&, const GUI::Variant&) override;
virtual bool is_column_sortable(int) const override { return false; }
- virtual StringView drag_data_type() const override { return "text/x-spreadsheet-data"; }
+ virtual StringView drag_data_type() const override { return "text/x-spreadsheet-data"sv; }
Sheet& sheet() { return *m_sheet; }
void update();
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index a7fa639f3f..822a4a150e 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -43,12 +43,12 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
current_cell_label.set_fixed_width(50);
auto& help_button = top_bar.add<GUI::Button>("");
- help_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors());
+ help_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors());
help_button.set_tooltip("Functions Help");
help_button.set_fixed_size(20, 20);
help_button.on_click = [&](auto) {
if (!current_view()) {
- GUI::MessageBox::show_error(window(), "Can only show function documentation/help when a worksheet exists and is open");
+ GUI::MessageBox::show_error(window(), "Can only show function documentation/help when a worksheet exists and is open"sv);
} else if (auto* sheet_ptr = current_worksheet_if_available()) {
auto docs = sheet_ptr->gather_documentation();
auto help_window = HelpWindow::the(window());
@@ -88,7 +88,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
m_inline_documentation_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
if (!m_workbook->has_sheets() && should_add_sheet_if_empty)
- m_workbook->add_sheet("Sheet 1");
+ m_workbook->add_sheet("Sheet 1"sv);
m_tab_context_menu = GUI::Menu::construct();
m_rename_action = GUI::CommonActions::make_rename_action([this](auto&) {
@@ -98,16 +98,16 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
VERIFY(sheet_ptr); // How did we get here without a sheet?
auto& sheet = *sheet_ptr;
String new_name;
- if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet") == GUI::Dialog::ExecResult::OK) {
+ if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet"sv) == GUI::Dialog::ExecResult::OK) {
sheet.set_name(new_name);
sheet.update();
m_tab_widget->set_tab_title(static_cast<GUI::Widget&>(*m_tab_context_menu_sheet_view), new_name);
}
});
m_tab_context_menu->add_action(*m_rename_action);
- m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
+ m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
String name;
- if (GUI::InputBox::show(window(), name, "Name for new sheet", "Create sheet") == GUI::Dialog::ExecResult::OK) {
+ if (GUI::InputBox::show(window(), name, "Name for new sheet"sv, "Create sheet"sv) == GUI::Dialog::ExecResult::OK) {
NonnullRefPtrVector<Sheet> new_sheets;
new_sheets.append(m_workbook->add_sheet(name));
setup_tabs(move(new_sheets));
@@ -116,7 +116,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
setup_tabs(m_workbook->sheets());
- m_new_action = GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ m_new_action = GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
add_sheet();
});
@@ -172,7 +172,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
auto* worksheet_ptr = current_worksheet_if_available();
if (!worksheet_ptr) {
- GUI::MessageBox::show_error(window(), "There are no active worksheets");
+ GUI::MessageBox::show_error(window(), "There are no active worksheets"sv);
return;
}
auto& sheet = *worksheet_ptr;
@@ -225,19 +225,19 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
m_redo_action->set_enabled(false);
m_functions_help_action = GUI::Action::create(
- "&Functions Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "&Functions Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
if (auto* worksheet_ptr = current_worksheet_if_available()) {
auto docs = worksheet_ptr->gather_documentation();
auto help_window = Spreadsheet::HelpWindow::the(window());
help_window->set_docs(move(docs));
help_window->show();
} else {
- GUI::MessageBox::show_error(window(), "Cannot prepare documentation/help without an active worksheet");
+ GUI::MessageBox::show_error(window(), "Cannot prepare documentation/help without an active worksheet"sv);
}
},
window());
- m_about_action = GUI::CommonActions::make_about_action("Spreadsheet", GUI::Icon::default_icon("app-spreadsheet"), window());
+ m_about_action = GUI::CommonActions::make_about_action("Spreadsheet", GUI::Icon::default_icon("app-spreadsheet"sv), window());
toolbar.add_action(*m_new_action);
toolbar.add_action(*m_open_action);
@@ -279,7 +279,7 @@ void SpreadsheetWidget::resize_event(GUI::ResizeEvent& event)
void SpreadsheetWidget::clipboard_content_did_change(String const& mime_type)
{
if (auto* sheet = current_worksheet_if_available())
- m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"));
+ m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"sv));
}
void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
@@ -303,7 +303,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
VERIFY(!selection.is_empty());
m_cut_action->set_enabled(true);
m_copy_action->set_enabled(true);
- m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type().starts_with("text/"));
+ m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type().starts_with("text/"sv));
m_current_cell_label->set_enabled(true);
m_cell_value_editor->set_enabled(true);
@@ -338,7 +338,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
auto& first_cell = cells.first();
m_cell_value_editor->on_change = nullptr;
- m_cell_value_editor->set_text("");
+ m_cell_value_editor->set_text(""sv);
m_should_change_selected_cells = false;
m_cell_value_editor->on_focusin = [this] { m_should_change_selected_cells = true; };
m_cell_value_editor->on_focusout = [this] { m_should_change_selected_cells = false; };
@@ -500,7 +500,7 @@ bool SpreadsheetWidget::request_close()
void SpreadsheetWidget::add_sheet()
{
StringBuilder name;
- name.append("Sheet");
+ name.append("Sheet"sv);
name.appendff(" {}", m_workbook->sheets().size() + 1);
NonnullRefPtrVector<Sheet> new_sheets;
@@ -522,10 +522,10 @@ void SpreadsheetWidget::update_window_title()
{
StringBuilder builder;
if (current_filename().is_empty())
- builder.append("Untitled");
+ builder.append("Untitled"sv);
else
builder.append(current_filename());
- builder.append("[*] - Spreadsheet");
+ builder.append("[*] - Spreadsheet"sv);
window()->set_title(builder.to_string());
}
@@ -538,14 +538,14 @@ void SpreadsheetWidget::clipboard_action(bool is_cut)
/// - selected cell+
auto* worksheet_ptr = current_worksheet_if_available();
if (!worksheet_ptr) {
- GUI::MessageBox::show_error(window(), "There are no active worksheets");
+ GUI::MessageBox::show_error(window(), "There are no active worksheets"sv);
return;
}
auto& worksheet = *worksheet_ptr;
auto& cells = worksheet.selected_cells();
VERIFY(!cells.is_empty());
StringBuilder text_builder, url_builder;
- url_builder.append(is_cut ? "cut\n" : "copy\n");
+ url_builder.append(is_cut ? "cut\n"sv : "copy\n"sv);
bool first = true;
auto cursor = current_selection_cursor();
if (cursor) {
diff --git a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp
index fd294d3a0c..0e356a5ba0 100644
--- a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp
+++ b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp
@@ -42,7 +42,7 @@ TEST_CASE(can_write_with_header)
auto buffer = ByteBuffer::create_uninitialized(1024).release_value();
OutputMemoryStream stream { buffer };
- Writer::CSV csv(stream, data, { "A", "B\"", "C" });
+ Writer::CSV csv(stream, data, { "A"sv, "B\""sv, "C"sv });
auto expected_output = R"~(A,"B""",C
1,2,3
@@ -63,7 +63,7 @@ TEST_CASE(can_write_with_different_behaviors)
auto buffer = ByteBuffer::create_uninitialized(1024).release_value();
OutputMemoryStream stream { buffer };
- Writer::CSV csv(stream, data, { "A", "B\"", "C" }, Writer::WriterBehavior::QuoteOnlyInFieldStart | Writer::WriterBehavior::WriteHeaders);
+ Writer::CSV csv(stream, data, { "A"sv, "B\""sv, "C"sv }, Writer::WriterBehavior::QuoteOnlyInFieldStart | Writer::WriterBehavior::WriteHeaders);
auto expected_output = R"~(A,B",C
Well,Hello",Friends
diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp
index 53408b712b..24bf243667 100644
--- a/Userland/Applications/Spreadsheet/main.cpp
+++ b/Userland/Applications/Spreadsheet/main.cpp
@@ -48,11 +48,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// For writing temporary files when exporting.
TRY(Core::System::unveil("/tmp", "crw"));
TRY(Core::System::unveil("/etc", "r"));
- TRY(Core::System::unveil(Core::StandardPaths::home_directory().characters(), "rwc"));
+ TRY(Core::System::unveil(Core::StandardPaths::home_directory(), "rwc"sv));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
- auto app_icon = GUI::Icon::default_icon("app-spreadsheet");
+ auto app_icon = GUI::Icon::default_icon("app-spreadsheet"sv);
auto window = GUI::Window::construct();
window->resize(640, 480);
window->set_icon(app_icon.bitmap_for_size(16));