summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-11-23 16:21:41 +0330
committerAndreas Kling <kling@serenityos.org>2020-11-24 21:38:13 +0100
commit3bafef0b159e2acfe3e62da1b5a30f63041d1fdc (patch)
tree9110413553fb80c525182acd13b9f28bc8770e9d
parent48d85349674764afef9aa8592b0cdd548160ffdd (diff)
downloadserenity-3bafef0b159e2acfe3e62da1b5a30f63041d1fdc.zip
Spreadsheet: Allow copying from one cell to many
This simply fils the target selection with the source cell. Fixes #4010.
-rw-r--r--Applications/Spreadsheet/Spreadsheet.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Applications/Spreadsheet/Spreadsheet.cpp b/Applications/Spreadsheet/Spreadsheet.cpp
index 5a7504bc5c..6f419bcf16 100644
--- a/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Applications/Spreadsheet/Spreadsheet.cpp
@@ -299,6 +299,18 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
return;
}
+ if (from.size() == 1) {
+ // Fill the target selection with the single cell.
+ auto& source = from.first();
+ for (auto& position : to) {
+#ifdef COPY_DEBUG
+ dbg() << "Paste from '" << source.to_url() << "' to '" << position.to_url() << "'";
+#endif
+ copy_to(source, resolve_relative_to.has_value() ? offset_relative_to(position, source, resolve_relative_to.value()) : position);
+ }
+ return;
+ }
+
// Just disallow misaligned copies.
dbg() << "Cannot copy " << from.size() << " cells to " << to.size() << " cells";
}