diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp index 8f1dcf8cb9..9b71a17016 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp @@ -57,7 +57,7 @@ CellTypeDialog::CellTypeDialog(const Vector& positions, Sheet& sheet, StringBuilder builder; if (positions.size() == 1) - builder.appendff("Format cell {}{}", positions.first().column, positions.first().row); + builder.appendff("Format cell {}", positions.first().to_cell_identifier(sheet)); else builder.appendff("Format {} cells", positions.size()); diff --git a/Userland/Applications/Spreadsheet/Position.h b/Userland/Applications/Spreadsheet/Position.h index 72b1f0a7ff..ea4d33af02 100644 --- a/Userland/Applications/Spreadsheet/Position.h +++ b/Userland/Applications/Spreadsheet/Position.h @@ -62,6 +62,7 @@ struct Position { return !(other == *this); } + String to_cell_identifier(const Sheet& sheet) const; URL to_url(const Sheet& sheet) const; size_t column { 0 }; diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index fdcb7be63d..9fe6240462 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -113,7 +113,7 @@ static String convert_to_string(size_t value, unsigned base = 26, StringView map value /= base; } while (value > 0); - // NOTE: Weird as this may seem, the thing that comes after 'A' is 'AA', which as a number would be '00' + // NOTE: Weird as this may seem, the thing that comes after 'Z' is 'AA', which as a number would be '00' // to make this work, only the most significant digit has to be in a range of (1..25) as opposed to (0..25), // but only if it's not the only digit in the string. if (i > 1) @@ -726,13 +726,18 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu return builder.build(); } +String Position::to_cell_identifier(const Sheet& sheet) const +{ + return String::formatted("{}{}", sheet.column(column), row); +} + URL Position::to_url(const Sheet& sheet) const { URL url; url.set_protocol("spreadsheet"); url.set_host("cell"); url.set_path(String::formatted("/{}", getpid())); - url.set_fragment(String::formatted("{}{}", sheet.column(column), row)); + url.set_fragment(to_cell_identifier(sheet)); return url; } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 036bd5a6c0..10eb88a9e5 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -155,11 +155,8 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) if (selection.size() == 1) { auto& position = selection.first(); - StringBuilder builder; - builder.append(position.column); - builder.appendff("{}", position.row); m_current_cell_label->set_enabled(true); - m_current_cell_label->set_text(builder.string_view()); + m_current_cell_label->set_text(position.to_cell_identifier(m_selected_view->sheet())); auto& cell = m_selected_view->sheet().ensure(position); m_cell_value_editor->on_change = nullptr;