1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:57:35 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -12,7 +12,7 @@
namespace Spreadsheet {
void Cell::set_data(DeprecatedString new_data)
void Cell::set_data(ByteString new_data)
{
// If we are a formula, we do not save the beginning '=', if the new_data is "" we can simply change our kind
if (m_kind == Formula && m_data.is_empty() && new_data.is_empty()) {
@ -43,7 +43,7 @@ void Cell::set_data(JS::Value new_data)
StringBuilder builder;
builder.append(new_data.to_string_without_side_effects());
m_data = builder.to_deprecated_string();
m_data = builder.to_byte_string();
m_evaluated_data = move(new_data);
}
@ -86,7 +86,7 @@ CellType const& Cell::type() const
return *CellType::get_by_name("Identity"sv);
}
JS::ThrowCompletionOr<DeprecatedString> Cell::typed_display() const
JS::ThrowCompletionOr<ByteString> Cell::typed_display() const
{
return type().display(const_cast<Cell&>(*this), m_type_metadata);
}
@ -163,13 +163,13 @@ JS::Value Cell::js_data()
return JS::PrimitiveString::create(vm, m_data);
}
DeprecatedString Cell::source() const
ByteString Cell::source() const
{
StringBuilder builder;
if (m_kind == Formula)
builder.append('=');
builder.append(m_data);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// FIXME: Find a better way to figure out dependencies

View file

@ -11,7 +11,7 @@
#include "Forward.h"
#include "JSIntegration.h"
#include "Position.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Types.h>
#include <AK/WeakPtr.h>
#include <LibGUI/Command.h>
@ -24,7 +24,7 @@ struct Cell : public Weakable<Cell> {
Formula,
};
Cell(DeprecatedString data, Position position, WeakPtr<Sheet> sheet)
Cell(ByteString data, Position position, WeakPtr<Sheet> sheet)
: m_dirty(false)
, m_data(move(data))
, m_kind(LiteralString)
@ -33,7 +33,7 @@ struct Cell : public Weakable<Cell> {
{
}
Cell(DeprecatedString source, JS::Value&& cell_value, Position position, WeakPtr<Sheet> sheet)
Cell(ByteString source, JS::Value&& cell_value, Position position, WeakPtr<Sheet> sheet)
: m_dirty(false)
, m_data(move(source))
, m_evaluated_data(move(cell_value))
@ -45,7 +45,7 @@ struct Cell : public Weakable<Cell> {
void reference_from(Cell*);
void set_data(DeprecatedString new_data);
void set_data(ByteString new_data);
void set_data(JS::Value new_data);
bool dirty() const { return m_dirty; }
void clear_dirty() { m_dirty = false; }
@ -55,7 +55,7 @@ struct Cell : public Weakable<Cell> {
if (!m_name_for_javascript.is_empty())
return m_name_for_javascript;
m_name_for_javascript = DeprecatedString::formatted("cell {}", m_position.to_cell_identifier(sheet));
m_name_for_javascript = ByteString::formatted("cell {}", m_position.to_cell_identifier(sheet));
return m_name_for_javascript;
}
@ -67,7 +67,7 @@ struct Cell : public Weakable<Cell> {
return m_thrown_value;
}
DeprecatedString const& data() const { return m_data; }
ByteString const& data() const { return m_data; }
const JS::Value& evaluated_data() const { return m_evaluated_data; }
Kind kind() const { return m_kind; }
Vector<WeakPtr<Cell>> const& referencing_cells() const { return m_referencing_cells; }
@ -95,14 +95,14 @@ struct Cell : public Weakable<Cell> {
m_conditional_formats = move(fmts);
}
JS::ThrowCompletionOr<DeprecatedString> typed_display() const;
JS::ThrowCompletionOr<ByteString> typed_display() const;
JS::ThrowCompletionOr<JS::Value> typed_js_data() const;
CellType const& type() const;
CellTypeMetadata const& type_metadata() const { return m_type_metadata; }
CellTypeMetadata& type_metadata() { return m_type_metadata; }
DeprecatedString source() const;
ByteString source() const;
JS::Value js_data();
@ -117,7 +117,7 @@ struct Cell : public Weakable<Cell> {
private:
bool m_dirty { false };
bool m_evaluated_externally { false };
DeprecatedString m_data;
ByteString m_data;
JS::Value m_evaluated_data;
JS::Value m_thrown_value;
Kind m_kind { LiteralString };
@ -126,7 +126,7 @@ private:
CellType const* m_type { nullptr };
CellTypeMetadata m_type_metadata;
Position m_position;
mutable DeprecatedString m_name_for_javascript;
mutable ByteString m_name_for_javascript;
Vector<ConditionalFormat> m_conditional_formats;
Format m_evaluated_formats;

View file

@ -17,12 +17,12 @@ DateCell::DateCell()
{
}
JS::ThrowCompletionOr<DeprecatedString> DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const
JS::ThrowCompletionOr<ByteString> DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const
{
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<DeprecatedString> {
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<ByteString> {
auto& vm = cell.sheet().global_object().vm();
auto timestamp = TRY(js_value(cell, metadata));
auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(vm))).to_deprecated_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S"sv : metadata.format.view());
auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(vm))).to_byte_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);

View file

@ -16,7 +16,7 @@ class DateCell : public CellType {
public:
DateCell();
virtual ~DateCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<ByteString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
virtual String metadata_hint(MetadataName) const override;
};

View file

@ -5,7 +5,7 @@
*/
#include "Format.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/PrintfImplementation.h>
#include <AK/StringBuilder.h>
@ -37,13 +37,13 @@ struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentL
}
};
DeprecatedString format_double(char const* format, double value)
ByteString format_double(char const* format, double value)
{
StringBuilder builder;
auto putch = [&](auto, auto ch) { builder.append(ch); };
printf_internal<decltype(putch), PrintfImpl, double, SingleEntryListNext>(putch, nullptr, format, value);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -10,6 +10,6 @@
namespace Spreadsheet {
DeprecatedString format_double(char const* format, double value);
ByteString format_double(char const* format, double value);
}

View file

@ -15,14 +15,14 @@ IdentityCell::IdentityCell()
{
}
JS::ThrowCompletionOr<DeprecatedString> IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const
JS::ThrowCompletionOr<ByteString> IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const
{
auto& vm = cell.sheet().global_object().vm();
auto data = cell.js_data();
if (!metadata.format.is_empty())
data = TRY(cell.sheet().evaluate(metadata.format, &cell));
return data.to_deprecated_string(vm);
return data.to_byte_string(vm);
}
JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, CellTypeMetadata const&) const

View file

@ -15,7 +15,7 @@ class IdentityCell : public CellType {
public:
IdentityCell();
virtual ~IdentityCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<ByteString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
virtual String metadata_hint(MetadataName) const override;
};

View file

@ -18,14 +18,14 @@ NumericCell::NumericCell()
{
}
JS::ThrowCompletionOr<DeprecatedString> NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const
JS::ThrowCompletionOr<ByteString> NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const
{
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<DeprecatedString> {
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<ByteString> {
auto& vm = cell.sheet().global_object().vm();
auto value = TRY(js_value(cell, metadata));
DeprecatedString string;
ByteString string;
if (metadata.format.is_empty())
string = TRY(value.to_deprecated_string(vm));
string = TRY(value.to_byte_string(vm));
else
string = format_double(metadata.format.characters(), TRY(value.to_double(vm)));

View file

@ -26,7 +26,7 @@ class NumericCell : public CellType {
public:
NumericCell();
virtual ~NumericCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<ByteString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
virtual String metadata_hint(MetadataName) const override;
};

View file

@ -15,10 +15,10 @@ StringCell::StringCell()
{
}
JS::ThrowCompletionOr<DeprecatedString> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const
JS::ThrowCompletionOr<ByteString> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const
{
auto& vm = cell.sheet().global_object().vm();
auto string = TRY(cell.js_data().to_deprecated_string(vm));
auto string = TRY(cell.js_data().to_byte_string(vm));
if (metadata.length >= 0)
return string.substring(0, metadata.length);

View file

@ -15,7 +15,7 @@ class StringCell : public CellType {
public:
StringCell();
virtual ~StringCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<ByteString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
virtual String metadata_hint(MetadataName) const override;
};

View file

@ -12,7 +12,7 @@
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
static HashMap<DeprecatedString, Spreadsheet::CellType*> s_cell_types;
static HashMap<ByteString, Spreadsheet::CellType*> s_cell_types;
static Spreadsheet::StringCell s_string_cell;
static Spreadsheet::NumericCell s_numeric_cell;
static Spreadsheet::IdentityCell s_identity_cell;

View file

@ -8,7 +8,7 @@
#include "../ConditionalFormatting.h"
#include "../Forward.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Forward.h>
#include <LibGfx/Color.h>
#include <LibGfx/TextAlignment.h>
@ -18,7 +18,7 @@ namespace Spreadsheet {
struct CellTypeMetadata {
int length { -1 };
DeprecatedString format;
ByteString format;
Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterRight };
Format static_format;
};
@ -35,18 +35,18 @@ public:
static CellType const* get_by_name(StringView);
static Vector<StringView> names();
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const = 0;
virtual JS::ThrowCompletionOr<ByteString> 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;
DeprecatedString const& name() const { return m_name; }
ByteString const& name() const { return m_name; }
protected:
CellType(StringView name);
private:
DeprecatedString m_name;
ByteString m_name;
};
}

View file

@ -61,9 +61,9 @@ CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet,
ok_button.on_click = [&](auto) { done(ExecResult::OK); };
}
Vector<DeprecatedString> const g_horizontal_alignments { "Left", "Center", "Right" };
Vector<DeprecatedString> const g_vertical_alignments { "Top", "Center", "Bottom" };
Vector<DeprecatedString> g_types;
Vector<ByteString> const g_horizontal_alignments { "Left", "Center", "Right" };
Vector<ByteString> const g_vertical_alignments { "Top", "Center", "Bottom" };
Vector<ByteString> g_types;
constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx::TextAlignment alignment)
{
@ -142,7 +142,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
right_side.set_fixed_width(170);
auto& type_list = left_side.add<GUI::ListView>();
type_list.set_model(*GUI::ItemListModel<DeprecatedString>::create(g_types));
type_list.set_model(*GUI::ItemListModel<ByteString>::create(g_types));
type_list.set_should_hide_unnecessary_scrollbars(true);
type_list.on_selection_change = [&] {
const auto& index = type_list.selection().first();
@ -188,7 +188,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
checkbox.on_checked = [&](auto checked) {
editor.set_enabled(checked);
if (!checked)
m_format = DeprecatedString::empty();
m_format = ByteString::empty();
editor.set_text(m_format);
};
editor.on_change = [&] {
@ -213,7 +213,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
auto& horizontal_combobox = alignment_tab.add<GUI::ComboBox>();
horizontal_combobox.set_only_allow_values_from_model(true);
horizontal_combobox.set_model(*GUI::ItemListModel<DeprecatedString>::create(g_horizontal_alignments));
horizontal_combobox.set_model(*GUI::ItemListModel<ByteString>::create(g_horizontal_alignments));
horizontal_combobox.set_selected_index((int)m_horizontal_alignment);
horizontal_combobox.on_change = [&](auto&, const GUI::ModelIndex& index) {
switch (index.row()) {
@ -244,7 +244,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
auto& vertical_combobox = alignment_tab.add<GUI::ComboBox>();
vertical_combobox.set_only_allow_values_from_model(true);
vertical_combobox.set_model(*GUI::ItemListModel<DeprecatedString>::create(g_vertical_alignments));
vertical_combobox.set_model(*GUI::ItemListModel<ByteString>::create(g_vertical_alignments));
vertical_combobox.set_selected_index((int)m_vertical_alignment);
vertical_combobox.on_change = [&](auto&, const GUI::ModelIndex& index) {
switch (index.row()) {

View file

@ -39,7 +39,7 @@ private:
CellType const* m_type { nullptr };
int m_length { -1 };
DeprecatedString m_format;
ByteString m_format;
HorizontalAlignment m_horizontal_alignment { HorizontalAlignment::Right };
VerticalAlignment m_vertical_alignment { VerticalAlignment::Center };
Format m_static_format;

View file

@ -7,7 +7,7 @@
#pragma once
#include "Forward.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibGUI/AbstractScrollableWidget.h>
#include <LibGfx/Color.h>
@ -19,7 +19,7 @@ struct Format {
};
struct ConditionalFormat : public Format {
DeprecatedString condition;
ByteString condition;
};
enum class FormatType {

View file

@ -7,7 +7,7 @@
#include "ExportDialog.h"
#include "Spreadsheet.h"
#include "Workbook.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/JsonArray.h>
#include <AK/LexicalPath.h>
#include <AK/MemoryStream.h>
@ -59,7 +59,7 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
m_data_preview_text_editor->set_should_hide_unnecessary_scrollbars(true);
m_quote_escape_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(m_quote_escape_items));
m_quote_escape_combo_box->set_model(GUI::ItemListModel<ByteString>::create(m_quote_escape_items));
// By default, use commas, double quotes with repeat, disable headers, and quote only the fields that require quoting.
m_delimiter_comma_radio->set_checked(true);
@ -91,7 +91,7 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> ErrorOr<void>
{
auto delimiter = TRY([this]() -> ErrorOr<DeprecatedString> {
auto delimiter = TRY([this]() -> ErrorOr<ByteString> {
if (m_delimiter_other_radio->is_checked()) {
if (m_delimiter_other_text_box->text().is_empty())
return Error::from_string_literal("Delimiter unset");
@ -108,7 +108,7 @@ auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> Error
return Error::from_string_literal("Delimiter unset");
}());
auto quote = TRY([this]() -> ErrorOr<DeprecatedString> {
auto quote = TRY([this]() -> ErrorOr<ByteString> {
if (m_quote_other_radio->is_checked()) {
if (m_quote_other_text_box->text().is_empty())
return Error::from_string_literal("Quote separator unset");
@ -140,7 +140,7 @@ auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> Error
};
auto behaviors = Writer::default_behaviors();
Vector<DeprecatedString> empty_headers;
Vector<ByteString> empty_headers;
auto* headers = &empty_headers;
if (should_export_headers) {
@ -153,7 +153,7 @@ auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> Error
switch (type) {
case GenerationType::Normal:
TRY((Writer::XSV<decltype(m_data), Vector<DeprecatedString>>::generate(stream, m_data, move(traits), *headers, behaviors)));
TRY((Writer::XSV<decltype(m_data), Vector<ByteString>>::generate(stream, m_data, move(traits), *headers, behaviors)));
break;
case GenerationType::Preview:
TRY((Writer::XSV<decltype(m_data), decltype(*headers)>::generate_preview(stream, m_data, move(traits), *headers, behaviors)));
@ -176,10 +176,10 @@ void CSVExportDialogPage::update_preview()
return {};
}();
if (maybe_error.is_error())
m_data_preview_text_editor->set_text(DeprecatedString::formatted("Cannot update preview: {}", maybe_error.error()));
m_data_preview_text_editor->set_text(ByteString::formatted("Cannot update preview: {}", maybe_error.error()));
}
ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file, DeprecatedString filename, Workbook& workbook)
ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file, ByteString filename, Workbook& workbook)
{
auto wizard = TRY(GUI::WizardDialog::create(GUI::Application::the()->active_window()));
wizard->set_title("File Export Wizard");
@ -205,7 +205,7 @@ ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file,
for (auto& sheet : workbook.sheets())
array.must_append(sheet->to_json());
auto file_content = array.to_deprecated_string();
auto file_content = array.to_byte_string();
return file.write_until_depleted(file_content.bytes());
};
@ -223,11 +223,11 @@ ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file,
TRY(page->body_widget().load_from_gml(select_format_page_gml));
auto format_combo_box = page->body_widget().find_descendant_of_type_named<GUI::ComboBox>("select_format_page_format_combo_box");
Vector<DeprecatedString> supported_formats {
Vector<ByteString> supported_formats {
"CSV (text/csv)",
"Spreadsheet Worksheet",
};
format_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(supported_formats));
format_combo_box->set_model(GUI::ItemListModel<ByteString>::create(supported_formats));
wizard->push_page(page);

View file

@ -33,8 +33,8 @@ protected:
void update_preview();
private:
Vector<Vector<DeprecatedString>> m_data;
Vector<DeprecatedString> m_headers;
Vector<Vector<ByteString>> m_data;
Vector<ByteString> m_headers;
RefPtr<GUI::WizardPage> m_page;
RefPtr<GUI::RadioButton> m_delimiter_comma_radio;
RefPtr<GUI::RadioButton> m_delimiter_semicolon_radio;
@ -50,7 +50,7 @@ private:
RefPtr<GUI::CheckBox> m_export_header_check_box;
RefPtr<GUI::CheckBox> m_quote_all_fields_check_box;
RefPtr<GUI::TextEditor> m_data_preview_text_editor;
Vector<DeprecatedString> m_quote_escape_items {
Vector<ByteString> m_quote_escape_items {
// Note: Keep in sync with Writer::WriterTraits::QuoteEscape.
"Repeat",
"Backslash",
@ -58,7 +58,7 @@ private:
};
struct ExportDialog {
static ErrorOr<void> make_and_run_for(StringView mime, Core::File&, DeprecatedString filename, Workbook&);
static ErrorOr<void> make_and_run_for(StringView mime, Core::File&, ByteString filename, Workbook&);
};
}

View file

@ -38,7 +38,7 @@ public:
return {};
}
DeprecatedString key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; }
ByteString key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; }
void set_from(JsonObject const& object)
{
@ -55,7 +55,7 @@ private:
{
}
Vector<DeprecatedString> m_keys;
Vector<ByteString> m_keys;
};
RefPtr<HelpWindow> HelpWindow::s_the { nullptr };
@ -90,7 +90,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
auto entry = LexicalPath::basename(example_path);
auto doc_option = m_docs.get_object(entry);
if (!doc_option.has_value()) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("No documentation entry found for '{}'", example_path));
GUI::MessageBox::show_error(this, ByteString::formatted("No documentation entry found for '{}'", example_path));
return;
}
auto& doc = doc_option.value();
@ -98,13 +98,13 @@ HelpWindow::HelpWindow(GUI::Window* parent)
auto maybe_example_data = doc.get_object("example_data"sv);
if (!maybe_example_data.has_value()) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("No example data found for '{}'", example_path));
GUI::MessageBox::show_error(this, ByteString::formatted("No example data found for '{}'", example_path));
return;
}
auto& example_data = maybe_example_data.value();
if (!example_data.has_object(name)) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Example '{}' not found for '{}'", name, example_path));
GUI::MessageBox::show_error(this, ByteString::formatted("Example '{}' not found for '{}'", name, example_path));
return;
}
auto& value = example_data.get_object(name).value();
@ -112,13 +112,13 @@ HelpWindow::HelpWindow(GUI::Window* parent)
auto window = GUI::Window::construct(this);
window->resize(size());
window->set_icon(icon());
window->set_title(DeprecatedString::formatted("Spreadsheet Help - Example {} for {}", name, entry));
window->set_title(ByteString::formatted("Spreadsheet Help - Example {} for {}", name, entry));
window->on_close = [window = window.ptr()] { window->remove_from_parent(); };
auto widget = window->set_main_widget<SpreadsheetWidget>(window, Vector<NonnullRefPtr<Sheet>> {}, false);
auto sheet = Sheet::from_json(value, widget->workbook());
if (!sheet) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, example_path));
GUI::MessageBox::show_error(this, ByteString::formatted("Corrupted example '{}' in '{}'", name, example_path));
return;
}
@ -141,17 +141,17 @@ HelpWindow::HelpWindow(GUI::Window* parent)
};
}
DeprecatedString HelpWindow::render(StringView key)
ByteString HelpWindow::render(StringView key)
{
VERIFY(m_docs.has_object(key));
auto& doc = m_docs.get_object(key).value();
auto name = doc.get_deprecated_string("name"sv).value_or({});
auto name = doc.get_byte_string("name"sv).value_or({});
auto argc = doc.get_u32("argc"sv).value_or(0);
VERIFY(doc.has_array("argnames"sv));
auto& argnames = doc.get_array("argnames"sv).value();
auto docstring = doc.get_deprecated_string("doc"sv).value_or({});
auto docstring = doc.get_byte_string("doc"sv).value_or({});
StringBuilder markdown_builder;
@ -166,7 +166,7 @@ DeprecatedString HelpWindow::render(StringView key)
markdown_builder.append("No required arguments.\n"sv);
for (size_t i = 0; i < argc; ++i)
markdown_builder.appendff("- `{}`\n", argnames.at(i).to_deprecated_string());
markdown_builder.appendff("- `{}`\n", argnames.at(i).to_byte_string());
if (argc > 0)
markdown_builder.append("\n"sv);
@ -175,7 +175,7 @@ DeprecatedString HelpWindow::render(StringView key)
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_deprecated_string());
markdown_builder.appendff("- `{}`\n", argnames.at(i).to_byte_string());
markdown_builder.append("\n"sv);
}
@ -188,8 +188,8 @@ DeprecatedString HelpWindow::render(StringView key)
VERIFY(examples.has_value());
markdown_builder.append("# EXAMPLES\n"sv);
examples->for_each_member([&](auto& text, auto& description_value) {
dbgln("```js\n{}\n```\n\n- {}\n", text, description_value.to_deprecated_string());
markdown_builder.appendff("```js\n{}\n```\n\n- {}\n", text, description_value.to_deprecated_string());
dbgln("```js\n{}\n```\n\n- {}\n", text, description_value.to_byte_string());
markdown_builder.appendff("```js\n{}\n```\n\n- {}\n", text, description_value.to_byte_string());
});
}

View file

@ -32,7 +32,7 @@ public:
private:
static RefPtr<HelpWindow> s_the;
DeprecatedString render(StringView key);
ByteString render(StringView key);
HelpWindow(GUI::Window* parent = nullptr);
JsonObject m_docs;

View file

@ -53,7 +53,7 @@ CSVImportDialogPage::CSVImportDialogPage(StringView csv)
m_data_preview_error_label = m_page->body_widget().find_descendant_of_type_named<GUI::Label>("data_preview_error_label");
m_data_preview_widget = m_page->body_widget().find_descendant_of_type_named<GUI::StackWidget>("data_preview_widget");
m_quote_escape_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(m_quote_escape_items));
m_quote_escape_combo_box->set_model(GUI::ItemListModel<ByteString>::create(m_quote_escape_items));
// By default, use commas, double quotes with repeat, and disable headers.
m_delimiter_comma_radio->set_checked(true);
@ -86,8 +86,8 @@ CSVImportDialogPage::CSVImportDialogPage(StringView csv)
auto CSVImportDialogPage::make_reader() -> Optional<Reader::XSV>
{
DeprecatedString delimiter;
DeprecatedString quote;
ByteString delimiter;
ByteString quote;
Reader::ParserTraits::QuoteEscape quote_escape;
// Delimiter
@ -169,7 +169,7 @@ void CSVImportDialogPage::update_preview()
Vector<String> headers;
for (auto const& header : reader.headers())
headers.append(String::from_deprecated_string(header).release_value_but_fixme_should_propagate_errors());
headers.append(String::from_byte_string(header).release_value_but_fixme_should_propagate_errors());
m_data_preview_table_view->set_model(
GUI::ItemListModel<Reader::XSV::Row, Reader::XSV, Vector<String>>::create(reader, headers, min(8ul, reader.size())));
@ -177,16 +177,16 @@ void CSVImportDialogPage::update_preview()
m_data_preview_table_view->update();
}
ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
ErrorOr<Vector<NonnullRefPtr<Sheet>>, ByteString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
{
auto wizard = GUI::WizardDialog::create(&parent).release_value_but_fixme_should_propagate_errors();
wizard->set_title("File Import Wizard");
wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
auto import_xsv = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
auto import_xsv = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, ByteString> {
auto contents_or_error = file.read_until_eof();
if (contents_or_error.is_error())
return DeprecatedString::formatted("{}", contents_or_error.release_error());
return ByteString::formatted("{}", contents_or_error.release_error());
CSVImportDialogPage page { contents_or_error.value() };
wizard->replace_page(page.page());
auto result = wizard->exec();
@ -199,7 +199,7 @@ ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_r
if (reader.has_value()) {
reader->parse();
if (reader.value().has_error())
return DeprecatedString::formatted("CSV Import failed: {}", reader.value().error_string());
return ByteString::formatted("CSV Import failed: {}", reader.value().error_string());
auto sheet = Sheet::from_xsv(reader.value(), workbook);
if (sheet)
@ -209,20 +209,20 @@ ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_r
return sheets;
}
return DeprecatedString { "CSV Import was cancelled" };
return ByteString { "CSV Import was cancelled" };
};
auto import_worksheet = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
auto import_worksheet = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, ByteString> {
auto contents_or_error = file.read_until_eof();
if (contents_or_error.is_error())
return DeprecatedString::formatted("{}", contents_or_error.release_error());
return ByteString::formatted("{}", contents_or_error.release_error());
auto json_value_option = JsonParser(contents_or_error.release_value()).parse();
if (json_value_option.is_error())
return DeprecatedString::formatted("Failed to parse {}", filename);
return ByteString::formatted("Failed to parse {}", filename);
auto& json_value = json_value_option.value();
if (!json_value.is_array())
return DeprecatedString::formatted("Did not find a spreadsheet in {}", filename);
return ByteString::formatted("Did not find a spreadsheet in {}", filename);
Vector<NonnullRefPtr<Sheet>> sheets;
@ -247,7 +247,7 @@ ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_r
} else {
auto page = GUI::WizardPage::create(
"Import File Format"sv,
DeprecatedString::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(filename.to_deprecated_string())))
ByteString::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(filename.to_byte_string())))
.release_value_but_fixme_should_propagate_errors();
page->on_next_page = [] { return nullptr; };
@ -255,16 +255,16 @@ ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_r
page->body_widget().load_from_gml(select_format_page_gml).release_value_but_fixme_should_propagate_errors();
auto format_combo_box = page->body_widget().find_descendant_of_type_named<GUI::ComboBox>("select_format_page_format_combo_box");
Vector<DeprecatedString> supported_formats {
Vector<ByteString> supported_formats {
"CSV (text/csv)",
"Spreadsheet Worksheet",
};
format_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(supported_formats));
format_combo_box->set_model(GUI::ItemListModel<ByteString>::create(supported_formats));
wizard->push_page(page);
if (wizard->exec() != GUI::Dialog::ExecResult::OK)
return DeprecatedString { "Import was cancelled" };
return ByteString { "Import was cancelled" };
if (format_combo_box->selected_index() == 0)
return import_xsv();

View file

@ -47,7 +47,7 @@ private:
RefPtr<GUI::TableView> m_data_preview_table_view;
RefPtr<GUI::Label> m_data_preview_error_label;
RefPtr<GUI::StackWidget> m_data_preview_widget;
Vector<DeprecatedString> m_quote_escape_items {
Vector<ByteString> m_quote_escape_items {
// Note: Keep in sync with Reader::ParserTraits::QuoteEscape.
"Repeat",
"Backslash",
@ -55,7 +55,7 @@ private:
};
struct ImportDialog {
static ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
static ErrorOr<Vector<NonnullRefPtr<Sheet>>, ByteString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
};
}

View file

@ -197,7 +197,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents)
auto name_value = vm.argument(0);
if (!name_value.is_string())
return vm.throw_completion<JS::TypeError>("Expected a String argument to get_real_cell_contents()"sv);
auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().deprecated_string());
auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().byte_string());
if (!position.has_value())
return vm.throw_completion<JS::TypeError>("Invalid cell name"sv);
@ -206,7 +206,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents)
return JS::js_undefined();
if (cell->kind() == Spreadsheet::Cell::Kind::Formula)
return JS::PrimitiveString::create(vm, DeprecatedString::formatted("={}", cell->data()));
return JS::PrimitiveString::create(vm, ByteString::formatted("={}", cell->data()));
return JS::PrimitiveString::create(vm, cell->data());
}
@ -226,7 +226,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents)
auto name_value = vm.argument(0);
if (!name_value.is_string())
return vm.throw_completion<JS::TypeError>("Expected the first argument of set_real_cell_contents() to be a String"sv);
auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().deprecated_string());
auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().byte_string());
if (!position.has_value())
return vm.throw_completion<JS::TypeError>("Invalid cell name"sv);
@ -235,7 +235,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents)
return vm.throw_completion<JS::TypeError>("Expected the second argument of set_real_cell_contents() to be a String"sv);
auto& cell = sheet_object.m_sheet.ensure(position.value());
auto new_contents = new_contents_value.as_string().deprecated_string();
auto new_contents = new_contents_value.as_string().byte_string();
cell.set_data(new_contents);
return JS::js_null();
}
@ -256,7 +256,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name)
auto name_value = vm.argument(0);
if (!name_value.is_string())
return vm.throw_completion<JS::TypeError>("Expected a String argument to parse_cell_name()"sv);
auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().deprecated_string());
auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().byte_string());
if (!position.has_value())
return JS::js_undefined();
@ -302,7 +302,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_index)
if (!column_name.is_string())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "String");
auto column_name_str = column_name.as_string().deprecated_string();
auto column_name_str = column_name.as_string().byte_string();
auto this_object = TRY(vm.this_value().to_object(vm));
@ -327,7 +327,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_arithmetic)
if (!column_name.is_string())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "String");
auto column_name_str = column_name.as_string().deprecated_string();
auto column_name_str = column_name.as_string().byte_string();
auto offset = TRY(vm.argument(1).to_number(vm));
auto offset_number = static_cast<i32>(offset.as_double());
@ -355,7 +355,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound)
if (!column_name.is_string())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "String");
auto column_name_str = column_name.as_string().deprecated_string();
auto column_name_str = column_name.as_string().byte_string();
auto this_object = TRY(vm.this_value().to_object(vm));
if (!is<SheetGlobalObject>(*this_object))
@ -407,7 +407,7 @@ JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
auto& workbook = workbook_object.m_workbook;
if (name_value.is_string()) {
auto name = name_value.as_string().deprecated_string();
auto name = name_value.as_string().byte_string();
for (auto& sheet : workbook.sheets()) {
if (sheet->name() == name)
return JS::Value(&sheet->global_object());

View file

@ -14,7 +14,7 @@
namespace Spreadsheet {
struct FunctionAndArgumentIndex {
DeprecatedString function_name;
ByteString function_name;
size_t argument_index { 0 };
};
Optional<FunctionAndArgumentIndex> get_function_and_argument_index(StringView source);

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Types.h>
#include <AK/URL.h>
@ -37,7 +37,7 @@ struct Position {
return row == other.row && column == other.column;
}
DeprecatedString to_cell_identifier(Sheet const& sheet) const;
ByteString to_cell_identifier(Sheet const& sheet) const;
URL to_url(Sheet const& sheet) const;
size_t column { 0 };

View file

@ -25,9 +25,9 @@ void XSV::set_error(ReadError error)
m_error = error;
}
Vector<DeprecatedString> XSV::headers() const
Vector<ByteString> XSV::headers() const
{
Vector<DeprecatedString> headers;
Vector<ByteString> headers;
if (has_explicit_headers()) {
for (auto& field : m_names)
headers.append(field.is_string_view ? field.as_string_view : field.as_string.view());
@ -37,7 +37,7 @@ Vector<DeprecatedString> XSV::headers() const
return headers;
for ([[maybe_unused]] auto& field : m_rows.first())
headers.append(DeprecatedString::empty());
headers.append(ByteString::empty());
}
return headers;
@ -240,7 +240,7 @@ XSV::Field XSV::read_one_quoted_field()
set_error(ReadError::QuoteFailure);
if (is_copy)
return { {}, builder.to_deprecated_string(), false };
return { {}, builder.to_byte_string(), false };
return { m_source.substring_view(start, end - start), {}, true };
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/GenericLexer.h>
#include <AK/StringView.h>
#include <AK/Types.h>
@ -31,8 +31,8 @@ ParserBehavior operator&(ParserBehavior left, ParserBehavior right);
ParserBehavior operator|(ParserBehavior left, ParserBehavior right);
struct ParserTraits {
DeprecatedString separator;
DeprecatedString quote { "\"" };
ByteString separator;
ByteString quote { "\"" };
enum QuoteEscape {
Repeat,
Backslash,
@ -73,7 +73,7 @@ public:
void parse();
bool has_error() const { return m_error != ReadError::None; }
ReadError error() const { return m_error; }
DeprecatedString error_string() const
ByteString error_string() const
{
switch (m_error) {
#define E(x, y) \
@ -87,7 +87,7 @@ public:
}
size_t size() const { return m_rows.size(); }
Vector<DeprecatedString> headers() const;
Vector<ByteString> headers() const;
[[nodiscard]] bool has_explicit_headers() const { return (static_cast<u32>(m_behaviors) & static_cast<u32>(ParserBehavior::ReadHeaders)) != 0; }
class Row {
@ -185,7 +185,7 @@ public:
private:
struct Field {
StringView as_string_view;
DeprecatedString as_string; // This member only used if the parser couldn't use the original source verbatim.
ByteString as_string; // This member only used if the parser couldn't use the original source verbatim.
bool is_string_view { true };
bool operator==(StringView other) const

View file

@ -61,7 +61,7 @@ Sheet::Sheet(Workbook& workbook)
warnln("Spreadsheet: Failed to parse runtime code");
for (auto& error : script_or_error.error()) {
// FIXME: This doesn't print hints anymore
warnln("SyntaxError: {}", error.to_deprecated_string());
warnln("SyntaxError: {}", error.to_byte_string());
}
} else {
auto result = vm.bytecode_interpreter().run(script_or_error.value());
@ -109,9 +109,9 @@ static Optional<size_t> convert_from_string(StringView str, unsigned base = 26,
return value - 1;
}
DeprecatedString Sheet::add_column()
ByteString Sheet::add_column()
{
auto next_column = DeprecatedString::bijective_base_from(m_columns.size());
auto next_column = ByteString::bijective_base_from(m_columns.size());
m_columns.append(next_column);
return next_column;
}
@ -224,7 +224,7 @@ Optional<size_t> Sheet::column_index(StringView column_name) const
return index;
}
Optional<DeprecatedString> Sheet::column_arithmetic(StringView column_name, int offset)
Optional<ByteString> Sheet::column_arithmetic(StringView column_name, int offset)
{
auto maybe_index = column_index(column_name);
if (!maybe_index.has_value())
@ -255,17 +255,17 @@ Cell* Sheet::from_url(const URL& url)
Optional<Position> Sheet::position_from_url(const URL& url) const
{
if (!url.is_valid()) {
dbgln("Invalid url: {}", url.to_deprecated_string());
dbgln("Invalid url: {}", url.to_byte_string());
return {};
}
if (url.scheme() != "spreadsheet" || url.host() != "cell"_string) {
dbgln("Bad url: {}", url.to_deprecated_string());
dbgln("Bad url: {}", url.to_byte_string());
return {};
}
// FIXME: Figure out a way to do this cross-process.
VERIFY(url.serialize_path() == DeprecatedString::formatted("/{}", getpid()));
VERIFY(url.serialize_path() == ByteString::formatted("/{}", getpid()));
return parse_cell_name(url.fragment().value_or(String {}));
}
@ -372,7 +372,7 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
auto sheet = adopt_ref(*new Sheet(workbook));
auto rows = object.get_u32("rows"sv).value_or(default_row_count);
auto columns = object.get_array("columns"sv);
auto name = object.get_deprecated_string("name"sv).value_or("Sheet");
auto name = object.get_byte_string("name"sv).value_or("Sheet");
if (object.has("cells"sv) && !object.has_object("cells"sv))
return {};
@ -398,9 +398,9 @@ 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_deprecated_string("foreground_color"sv); value.has_value())
if (auto value = obj.get_byte_string("foreground_color"sv); value.has_value())
format.foreground_color = Color::from_string(*value);
if (auto value = obj.get_deprecated_string("background_color"sv); value.has_value())
if (auto value = obj.get_byte_string("background_color"sv); value.has_value())
format.background_color = Color::from_string(*value);
};
@ -412,26 +412,26 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
auto position = position_option.value();
auto& obj = value.as_object();
auto kind = obj.get_deprecated_string("kind"sv).value_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula;
auto kind = obj.get_byte_string("kind"sv).value_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula;
OwnPtr<Cell> cell;
switch (kind) {
case Cell::LiteralString:
cell = make<Cell>(obj.get_deprecated_string("value"sv).value_or({}), position, *sheet);
cell = make<Cell>(obj.get_byte_string("value"sv).value_or({}), position, *sheet);
break;
case Cell::Formula: {
auto& vm = sheet->vm();
auto value_or_error = JS::call(vm, parse_function, json, JS::PrimitiveString::create(vm, obj.get_deprecated_string("value"sv).value_or({})));
auto value_or_error = JS::call(vm, parse_function, json, JS::PrimitiveString::create(vm, obj.get_byte_string("value"sv).value_or({})));
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_deprecated_string("source"sv).value_or({}), value_or_error.release_value(), position, *sheet);
cell = make<Cell>(obj.get_byte_string("source"sv).value_or({}), value_or_error.release_value(), position, *sheet);
break;
}
}
auto type_name = obj.has("type"sv) ? obj.get_deprecated_string("type"sv).value_or({}) : "Numeric";
auto type_name = obj.has("type"sv) ? obj.get_byte_string("type"sv).value_or({}) : "Numeric";
cell->set_type(type_name);
auto type_meta = obj.get_object("type_metadata"sv);
@ -440,9 +440,9 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
auto meta = cell->type_metadata();
if (auto value = meta_obj.get_i32("length"sv); value.has_value())
meta.length = value.value();
if (auto value = meta_obj.get_deprecated_string("format"sv); value.has_value())
if (auto value = meta_obj.get_byte_string("format"sv); value.has_value())
meta.format = value.value();
if (auto value = meta_obj.get_deprecated_string("alignment"sv); value.has_value()) {
if (auto value = meta_obj.get_byte_string("alignment"sv); value.has_value()) {
auto alignment = Gfx::text_alignment_from_string(*value);
if (alignment.has_value())
meta.alignment = alignment.value();
@ -460,7 +460,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_deprecated_string("condition"sv).value_or({});
auto fmt_cond = fmt_obj.get_byte_string("condition"sv).value_or({});
if (fmt_cond.is_empty())
return IterationDecision::Continue;
@ -513,7 +513,7 @@ Position Sheet::written_data_bounds(Optional<size_t> column_index) const
bool Sheet::columns_are_standard() const
{
for (size_t i = 0; i < m_columns.size(); ++i) {
if (m_columns[i] != DeprecatedString::bijective_base_from(i))
if (m_columns[i] != ByteString::bijective_base_from(i))
return false;
}
@ -527,9 +527,9 @@ JsonObject Sheet::to_json() const
auto save_format = [](auto const& format, auto& obj) {
if (format.foreground_color.has_value())
obj.set("foreground_color", format.foreground_color.value().to_deprecated_string());
obj.set("foreground_color", format.foreground_color.value().to_byte_string());
if (format.background_color.has_value())
obj.set("background_color", format.background_color.value().to_deprecated_string());
obj.set("background_color", format.background_color.value().to_byte_string());
};
auto bottom_right = written_data_bounds();
@ -547,7 +547,7 @@ JsonObject Sheet::to_json() const
StringBuilder builder;
builder.append(column(it.key.column));
builder.appendff("{}", it.key.row);
auto key = builder.to_deprecated_string();
auto key = builder.to_byte_string();
JsonObject data;
data.set("kind", it.value->kind() == Cell::Kind::Formula ? "Formula" : "LiteralString");
@ -556,7 +556,7 @@ JsonObject Sheet::to_json() const
auto json = realm().global_object().get_without_side_effects("JSON");
auto stringified_or_error = JS::call(vm(), json.as_object().get_without_side_effects("stringify").as_function(), json, it.value->evaluated_data());
VERIFY(!stringified_or_error.is_error());
data.set("value", stringified_or_error.release_value().to_string_without_side_effects().to_deprecated_string());
data.set("value", stringified_or_error.release_value().to_string_without_side_effects().to_byte_string());
} else {
data.set("value", it.value->data());
}
@ -599,9 +599,9 @@ JsonObject Sheet::to_json() const
return object;
}
Vector<Vector<DeprecatedString>> Sheet::to_xsv() const
Vector<Vector<ByteString>> Sheet::to_xsv() const
{
Vector<Vector<DeprecatedString>> data;
Vector<Vector<ByteString>> data;
auto bottom_right = written_data_bounds();
@ -609,7 +609,7 @@ Vector<Vector<DeprecatedString>> Sheet::to_xsv() const
size_t column_count = m_columns.size();
if (columns_are_standard()) {
column_count = bottom_right.column + 1;
Vector<DeprecatedString> cols;
Vector<ByteString> cols;
for (size_t i = 0; i < column_count; ++i)
cols.append(m_columns[i]);
data.append(move(cols));
@ -618,7 +618,7 @@ Vector<Vector<DeprecatedString>> Sheet::to_xsv() const
}
for (size_t i = 0; i <= bottom_right.row; ++i) {
Vector<DeprecatedString> row;
Vector<ByteString> row;
row.resize(column_count);
for (size_t j = 0; j < column_count; ++j) {
auto cell = at({ j, i });
@ -646,7 +646,7 @@ RefPtr<Sheet> Sheet::from_xsv(Reader::XSV const& xsv, Workbook& workbook)
} else {
sheet->m_columns.ensure_capacity(cols.size());
for (size_t i = 0; i < cols.size(); ++i)
sheet->m_columns.append(DeprecatedString::bijective_base_from(i));
sheet->m_columns.append(ByteString::bijective_base_from(i));
}
for (size_t i = 0; i < max(rows, Sheet::default_row_count); ++i)
sheet->add_row();
@ -706,7 +706,7 @@ JsonObject Sheet::gather_documentation() const
return m_cached_documentation.value();
}
DeprecatedString Sheet::generate_inline_documentation_for(StringView function, size_t argument_index)
ByteString Sheet::generate_inline_documentation_for(StringView function, size_t argument_index)
{
if (!m_cached_documentation.has_value())
gather_documentation();
@ -714,13 +714,13 @@ DeprecatedString Sheet::generate_inline_documentation_for(StringView function, s
auto& docs = m_cached_documentation.value();
auto entry = docs.get_object(function);
if (!entry.has_value())
return DeprecatedString::formatted("{}(...???{})", function, argument_index);
return ByteString::formatted("{}(...???{})", function, argument_index);
auto& entry_object = entry.value();
size_t argc = entry_object.get_integer<int>("argc"sv).value_or(0);
auto argnames_value = entry_object.get_array("argnames"sv);
if (!argnames_value.has_value())
return DeprecatedString::formatted("{}(...{}???{})", function, argc, argument_index);
return ByteString::formatted("{}(...{}???{})", function, argc, argument_index);
auto& argnames = argnames_value.value();
StringBuilder builder;
builder.appendff("{}(", function);
@ -731,7 +731,7 @@ DeprecatedString Sheet::generate_inline_documentation_for(StringView function, s
builder.append('<');
else if (i >= argc)
builder.append('[');
builder.append(argnames[i].to_deprecated_string());
builder.append(argnames[i].to_byte_string());
if (i == argument_index)
builder.append('>');
else if (i >= argc)
@ -739,12 +739,12 @@ DeprecatedString Sheet::generate_inline_documentation_for(StringView function, s
}
builder.append(')');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString Position::to_cell_identifier(Sheet const& sheet) const
ByteString Position::to_cell_identifier(Sheet const& sheet) const
{
return DeprecatedString::formatted("{}{}", sheet.column(column), row);
return ByteString::formatted("{}{}", sheet.column(column), row);
}
URL Position::to_url(Sheet const& sheet) const
@ -752,12 +752,12 @@ URL Position::to_url(Sheet const& sheet) const
URL url;
url.set_scheme("spreadsheet"_string);
url.set_host("cell"_string);
url.set_paths({ DeprecatedString::number(getpid()) });
url.set_fragment(String::from_deprecated_string(to_cell_identifier(sheet)).release_value());
url.set_paths({ ByteString::number(getpid()) });
url.set_fragment(String::from_byte_string(to_cell_identifier(sheet)).release_value());
return url;
}
CellChange::CellChange(Cell& cell, DeprecatedString const& previous_data)
CellChange::CellChange(Cell& cell, ByteString const& previous_data)
: m_cell(cell)
, m_previous_data(previous_data)
{

View file

@ -9,7 +9,7 @@
#include "Cell.h"
#include "Forward.h"
#include "Readers/XSV.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/HashTable.h>
#include <AK/StringBuilder.h>
@ -23,7 +23,7 @@ namespace Spreadsheet {
class CellChange {
public:
CellChange(Cell&, DeprecatedString const&);
CellChange(Cell&, ByteString const&);
CellChange(Cell&, CellTypeMetadata const&);
auto& cell() { return m_cell; }
@ -34,8 +34,8 @@ public:
private:
Cell& m_cell;
DeprecatedString m_previous_data;
DeprecatedString m_new_data;
ByteString m_previous_data;
ByteString m_new_data;
CellTypeMetadata m_previous_type_metadata;
CellTypeMetadata m_new_type_metadata;
};
@ -51,7 +51,7 @@ public:
Optional<Position> parse_cell_name(StringView) const;
Optional<size_t> column_index(StringView column_name) const;
Optional<DeprecatedString> column_arithmetic(StringView column_name, int offset);
Optional<ByteString> column_arithmetic(StringView column_name, int offset);
Cell* from_url(const URL&);
Cell const* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); }
@ -64,10 +64,10 @@ public:
JsonObject to_json() const;
static RefPtr<Sheet> from_json(JsonObject const&, Workbook&);
Vector<Vector<DeprecatedString>> to_xsv() const;
Vector<Vector<ByteString>> to_xsv() const;
static RefPtr<Sheet> from_xsv(Reader::XSV const&, Workbook&);
DeprecatedString const& name() const { return m_name; }
ByteString const& name() const { return m_name; }
void set_name(StringView name) { m_name = name; }
JsonObject gather_documentation() const;
@ -89,17 +89,17 @@ public:
if (auto cell = at(position))
return *cell;
m_cells.set(position, make<Cell>(DeprecatedString::empty(), position, *this));
m_cells.set(position, make<Cell>(ByteString::empty(), position, *this));
return *at(position);
}
size_t add_row();
DeprecatedString add_column();
ByteString add_column();
size_t row_count() const { return m_rows; }
size_t column_count() const { return m_columns.size(); }
Vector<DeprecatedString> const& columns() const { return m_columns; }
DeprecatedString const& column(size_t index)
Vector<ByteString> const& columns() const { return m_columns; }
ByteString const& column(size_t index)
{
for (size_t i = column_count(); i < index; ++i)
add_column();
@ -107,7 +107,7 @@ public:
VERIFY(column_count() > index);
return m_columns[index];
}
DeprecatedString const& column(size_t index) const
ByteString const& column(size_t index) const
{
VERIFY(column_count() > index);
return m_columns[index];
@ -145,7 +145,7 @@ public:
bool columns_are_standard() const;
DeprecatedString generate_inline_documentation_for(StringView function, size_t argument_index);
ByteString generate_inline_documentation_for(StringView function, size_t argument_index);
JS::Realm& realm() const { return *m_root_execution_context->realm; }
JS::VM& vm() const { return realm().vm(); }
@ -154,8 +154,8 @@ private:
explicit Sheet(Workbook&);
explicit Sheet(StringView name, Workbook&);
DeprecatedString m_name;
Vector<DeprecatedString> m_columns;
ByteString m_name;
Vector<ByteString> m_columns;
size_t m_rows { 0 };
HashMap<Position, NonnullOwnPtr<Cell>> m_cells;
HashTable<Position> m_selected_cells;

View file

@ -21,9 +21,9 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
if (role == GUI::ModelRole::Display) {
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
if (!cell)
return DeprecatedString::empty();
return ByteString::empty();
Function<DeprecatedString(JS::Value)> to_deprecated_string_as_exception = [&](JS::Value value) {
Function<ByteString(JS::Value)> to_byte_string_as_exception = [&](JS::Value value) {
auto& vm = cell->sheet().global_object().vm();
StringBuilder builder;
builder.append("Error: "sv);
@ -31,37 +31,37 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
auto& object = value.as_object();
if (is<JS::Error>(object)) {
auto message = object.get_without_side_effects("message");
auto error = message.to_deprecated_string(vm);
auto error = message.to_byte_string(vm);
if (error.is_throw_completion())
builder.append(message.to_string_without_side_effects());
else
builder.append(error.release_value());
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}
auto error_message = value.to_deprecated_string(vm);
auto error_message = value.to_byte_string(vm);
if (error_message.is_throw_completion())
return to_deprecated_string_as_exception(*error_message.release_error().value());
return to_byte_string_as_exception(*error_message.release_error().value());
builder.append(error_message.release_value());
return builder.to_deprecated_string();
return builder.to_byte_string();
};
if (cell->kind() == Spreadsheet::Cell::Formula) {
if (auto opt_throw_value = cell->thrown_value(); opt_throw_value.has_value())
return to_deprecated_string_as_exception(*opt_throw_value);
return to_byte_string_as_exception(*opt_throw_value);
}
auto display = cell->typed_display();
if (display.is_error())
return to_deprecated_string_as_exception(*display.release_error().value());
return to_byte_string_as_exception(*display.release_error().value());
return display.release_value();
}
if (role == GUI::ModelRole::MimeData)
return Position { (size_t)index.column(), (size_t)index.row() }.to_url(m_sheet).to_deprecated_string();
return Position { (size_t)index.column(), (size_t)index.row() }.to_url(m_sheet).to_byte_string();
if (role == GUI::ModelRole::TextAlignment) {
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
@ -131,7 +131,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
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);
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
return {};
@ -154,8 +154,8 @@ RefPtr<Core::MimeData> SheetModel::mime_data(const GUI::ModelSelection& selectio
Position cursor_position { (size_t)cursor->column(), (size_t)cursor->row() };
auto mime_data_buffer = mime_data->data("text/x-spreadsheet-data"sv);
auto new_data = DeprecatedString::formatted("{}\n{}",
cursor_position.to_url(m_sheet).to_deprecated_string(),
auto new_data = ByteString::formatted("{}\n{}",
cursor_position.to_url(m_sheet).to_byte_string(),
StringView(mime_data_buffer));
mime_data->set_data("text/x-spreadsheet-data"_string, new_data.to_byte_buffer());
@ -167,7 +167,7 @@ ErrorOr<String> SheetModel::column_name(int index) const
if (index < 0)
return String {};
return TRY(String::from_deprecated_string(m_sheet->column(index)));
return TRY(String::from_byte_string(m_sheet->column(index)));
}
bool SheetModel::is_editable(const GUI::ModelIndex& index) const
@ -185,7 +185,7 @@ void SheetModel::set_data(const GUI::ModelIndex& index, const GUI::Variant& valu
auto& cell = m_sheet->ensure({ (size_t)index.column(), (size_t)index.row() });
auto previous_data = cell.data();
cell.set_data(value.to_deprecated_string());
cell.set_data(value.to_byte_string());
if (on_cell_data_change)
on_cell_data_change(cell, previous_data);
did_update(UpdateFlag::DontInvalidateIndices);
@ -202,7 +202,7 @@ CellsUndoCommand::CellsUndoCommand(Vector<CellChange> cell_changes)
m_cell_changes = cell_changes;
}
CellsUndoCommand::CellsUndoCommand(Cell& cell, DeprecatedString const& previous_data)
CellsUndoCommand::CellsUndoCommand(Cell& cell, ByteString const& previous_data)
{
m_cell_changes.append(CellChange(cell, previous_data));
}

View file

@ -34,7 +34,7 @@ public:
void update();
Function<void(Cell&, DeprecatedString&)> on_cell_data_change;
Function<void(Cell&, ByteString&)> on_cell_data_change;
Function<void(Vector<CellChange>)> on_cells_data_change;
private:
@ -48,7 +48,7 @@ private:
class CellsUndoCommand : public GUI::Command {
public:
CellsUndoCommand(Cell&, DeprecatedString const&);
CellsUndoCommand(Cell&, ByteString const&);
CellsUndoCommand(Vector<CellChange>);
virtual void undo() override;

View file

@ -80,7 +80,7 @@ void InfinitelyScrollableTableView::mousemove_event(GUI::MouseEvent& event)
if (!is_dragging()) {
auto tooltip = model->data(index, static_cast<GUI::ModelRole>(SheetModel::Role::Tooltip));
if (tooltip.is_string()) {
set_tooltip(MUST(String::from_deprecated_string(tooltip.as_string())));
set_tooltip(MUST(String::from_byte_string(tooltip.as_string())));
show_or_hide_tooltip();
} else {
set_tooltip({});
@ -495,7 +495,7 @@ void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, Gfx::IntRec
auto text_color = index.data(GUI::ModelRole::ForegroundColor).to_color(palette.color(m_table_view.foreground_role()));
auto data = index.data();
auto text_alignment = index.data(GUI::ModelRole::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterRight);
painter.draw_text(rect, data.to_deprecated_string(), m_table_view.font_for_index(index), text_alignment, text_color, Gfx::TextElision::Right);
painter.draw_text(rect, data.to_byte_string(), m_table_view.font_for_index(index), text_alignment, text_color, Gfx::TextElision::Right);
}
}

View file

@ -99,7 +99,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR
auto* sheet_ptr = m_tab_context_menu_sheet_view->sheet_if_available();
VERIFY(sheet_ptr); // How did we get here without a sheet?
auto& sheet = *sheet_ptr;
String new_name = String::from_deprecated_string(sheet.name()).release_value_but_fixme_should_propagate_errors();
String new_name = String::from_byte_string(sheet.name()).release_value_but_fixme_should_propagate_errors();
if (GUI::InputBox::show(window(), new_name, {}, "Rename Sheet"sv, GUI::InputType::NonemptyText, "Name"sv) == GUI::Dialog::ExecResult::OK) {
sheet.set_name(new_name);
sheet.update();
@ -166,7 +166,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR
});
m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
DeprecatedString name = "workbook";
ByteString name = "workbook";
auto response = FileSystemAccessClient::Client::the().save_file(window(), name, "sheets");
if (response.is_error())
return;
@ -336,7 +336,7 @@ void SpreadsheetWidget::resize_event(GUI::ResizeEvent& event)
m_inline_documentation_window->set_rect(m_cell_value_editor->screen_relative_rect().translated(0, m_cell_value_editor->height() + 7).inflated(6, 6));
}
void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mime_type)
void SpreadsheetWidget::clipboard_content_did_change(ByteString 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/"sv));
@ -345,7 +345,7 @@ void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mim
void SpreadsheetWidget::setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets)
{
for (auto& sheet : new_sheets) {
auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(String::from_deprecated_string(sheet->name()).release_value_but_fixme_should_propagate_errors(), sheet);
auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(String::from_byte_string(sheet->name()).release_value_but_fixme_should_propagate_errors(), sheet);
new_view.model()->on_cell_data_change = [&](auto& cell, auto& previous_data) {
undo_stack().push(make<CellsUndoCommand>(cell, previous_data));
window()->set_modified(true);
@ -372,7 +372,7 @@ void SpreadsheetWidget::setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets)
if (selection.size() == 1) {
auto& position = selection.first();
m_current_cell_label->set_text(String::from_deprecated_string(position.to_cell_identifier(sheet)).release_value_but_fixme_should_propagate_errors());
m_current_cell_label->set_text(String::from_byte_string(position.to_cell_identifier(sheet)).release_value_but_fixme_should_propagate_errors());
auto& cell = sheet.ensure(position);
m_cell_value_editor->on_change = nullptr;
@ -467,7 +467,7 @@ void SpreadsheetWidget::try_generate_tip_for_input_expression(StringView source,
if (text.is_empty()) {
m_inline_documentation_window->hide();
} else {
m_inline_documentation_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors());
m_inline_documentation_label->set_text(String::from_byte_string(text).release_value_but_fixme_should_propagate_errors());
m_inline_documentation_window->show();
}
}
@ -564,7 +564,7 @@ void SpreadsheetWidget::save(String const& filename, Core::File& file)
{
auto result = m_workbook->write_to_file(filename, file);
if (result.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Cannot save file: {}", result.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Cannot save file: {}", result.error()));
return;
}
undo_stack().set_current_unmodified();
@ -666,7 +666,7 @@ void SpreadsheetWidget::update_window_title()
builder.append(current_filename());
builder.append("[*] - Spreadsheet"sv);
window()->set_title(builder.to_deprecated_string());
window()->set_title(builder.to_byte_string());
}
void SpreadsheetWidget::clipboard_action(bool is_cut)
@ -689,17 +689,17 @@ void SpreadsheetWidget::clipboard_action(bool is_cut)
auto cursor = current_selection_cursor();
if (cursor) {
Spreadsheet::Position position { (size_t)cursor->column(), (size_t)cursor->row() };
url_builder.append(position.to_url(worksheet).to_deprecated_string());
url_builder.append(position.to_url(worksheet).to_byte_string());
url_builder.append('\n');
}
for (auto& cell : cells) {
if (first && !cursor) {
url_builder.append(cell.to_url(worksheet).to_deprecated_string());
url_builder.append(cell.to_url(worksheet).to_byte_string());
url_builder.append('\n');
}
url_builder.append(cell.to_url(worksheet).to_deprecated_string());
url_builder.append(cell.to_url(worksheet).to_byte_string());
url_builder.append('\n');
auto cell_data = worksheet.at(cell);
@ -709,9 +709,9 @@ void SpreadsheetWidget::clipboard_action(bool is_cut)
text_builder.append(cell_data->data());
first = false;
}
HashMap<DeprecatedString, DeprecatedString> metadata;
metadata.set("text/x-spreadsheet-data", url_builder.to_deprecated_string());
dbgln(url_builder.to_deprecated_string());
HashMap<ByteString, ByteString> metadata;
metadata.set("text/x-spreadsheet-data", url_builder.to_byte_string());
dbgln(url_builder.to_byte_string());
GUI::Clipboard::the().set_data(text_builder.string_view().bytes(), "text/plain", move(metadata));
}

View file

@ -29,7 +29,7 @@ public:
void add_sheet();
void add_sheet(NonnullRefPtr<Sheet>&&);
DeprecatedString const& current_filename() const { return m_workbook->current_filename(); }
ByteString 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();
@ -57,7 +57,7 @@ private:
virtual void resize_event(GUI::ResizeEvent&) override;
// ^GUI::Clipboard::ClipboardClient
virtual void clipboard_content_did_change(DeprecatedString const& mime_type) override;
virtual void clipboard_content_did_change(ByteString const& mime_type) override;
explicit SpreadsheetWidget(GUI::Window& window, Vector<NonnullRefPtr<Sheet>>&& sheets = {}, bool should_add_sheet_if_empty = true);

View file

@ -41,7 +41,7 @@ Workbook::Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_wi
m_vm->set_dynamic_imports_allowed(true);
}
bool Workbook::set_filename(DeprecatedString const& filename)
bool Workbook::set_filename(ByteString const& filename)
{
if (m_current_filename == filename)
return false;
@ -50,14 +50,14 @@ bool Workbook::set_filename(DeprecatedString const& filename)
return true;
}
ErrorOr<void, DeprecatedString> Workbook::open_file(String const& filename, Core::File& file)
ErrorOr<void, ByteString> Workbook::open_file(String const& filename, Core::File& file)
{
auto mime = Core::guess_mime_type_based_on_filename(filename);
// Make an import dialog, we might need to import it.
m_sheets = TRY(ImportDialog::make_and_run_for(m_parent_window, mime, filename, file, *this));
set_filename(filename.to_deprecated_string());
set_filename(filename.to_byte_string());
return {};
}
@ -67,14 +67,14 @@ ErrorOr<void> Workbook::write_to_file(String const& filename, Core::File& stream
auto mime = Core::guess_mime_type_based_on_filename(filename);
// Make an export dialog, we might need to import it.
TRY(ExportDialog::make_and_run_for(mime, stream, filename.to_deprecated_string(), *this));
TRY(ExportDialog::make_and_run_for(mime, stream, filename.to_byte_string(), *this));
set_filename(filename.to_deprecated_string());
set_filename(filename.to_byte_string());
set_dirty(false);
return {};
}
ErrorOr<bool, DeprecatedString> Workbook::import_file(String const& filename, Core::File& file)
ErrorOr<bool, ByteString> Workbook::import_file(String const& filename, Core::File& file)
{
auto mime = Core::guess_mime_type_based_on_filename(filename);

View file

@ -15,13 +15,13 @@ class Workbook {
public:
Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_window);
ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::File&);
ErrorOr<void, ByteString> open_file(String const& filename, Core::File&);
ErrorOr<void> write_to_file(String const& filename, Core::File&);
ErrorOr<bool, DeprecatedString> import_file(String const& filename, Core::File&);
ErrorOr<bool, ByteString> import_file(String const& filename, Core::File&);
DeprecatedString const& current_filename() const { return m_current_filename; }
bool set_filename(DeprecatedString const& filename);
ByteString const& current_filename() const { return m_current_filename; }
bool set_filename(ByteString const& filename);
bool dirty() { return m_dirty; }
void set_dirty(bool dirty) { m_dirty = dirty; }
@ -50,7 +50,7 @@ private:
NonnullOwnPtr<JS::ExecutionContext> m_main_execution_context;
GUI::Window& m_parent_window;
DeprecatedString m_current_filename;
ByteString m_current_filename;
bool m_dirty { false };
};

View file

@ -52,7 +52,7 @@ TEST_CASE(can_write_with_header)
TEST_CASE(can_write_with_different_behaviors)
{
Vector<Vector<DeprecatedString>> data = {
Vector<Vector<ByteString>> data = {
{ "Well", "Hello\"", "Friends" },
{ "We\"ll", "Hello,", " Friends" },
};

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/GenericLexer.h>
#include <AK/OwnPtr.h>
#include <AK/Stream.h>
@ -26,8 +26,8 @@ enum class WriterBehavior : u32 {
AK_ENUM_BITWISE_OPERATORS(WriterBehavior);
struct WriterTraits {
DeprecatedString separator;
DeprecatedString quote { "\"" };
ByteString separator;
ByteString quote { "\"" };
enum QuoteEscape {
Repeat,
Backslash,
@ -121,7 +121,7 @@ private:
template<typename T>
ErrorOr<void> write_entry(T&& entry)
{
auto string = DeprecatedString::formatted("{}", FormatIfSupported(entry));
auto string = ByteString::formatted("{}", FormatIfSupported(entry));
auto safe_to_write_normally = !has_flag(m_behaviors, WriterBehavior::QuoteAll)
&& !string.contains('\n')