Spreadsheet: Implement the cut operation for cells

This is done by adding another field to our custom
text/x-spreadsheet-data mime-type that specifies the
action (just copy/cut for now)
This commit is contained in:
Idan Horowitz 2021-02-28 16:54:53 +02:00 committed by Andreas Kling
commit 147d30ae4f
Notes: sideshowbarker 2024-07-18 21:49:08 +09:00
3 changed files with 25 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2020-2021, the SerenityOS developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -325,7 +325,7 @@ Position Sheet::offset_relative_to(const Position& base, const Position& offset,
return { new_column, new_row };
}
void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Position> resolve_relative_to)
void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Position> resolve_relative_to, CopyOperation copy_operation)
{
auto copy_to = [&](auto& source_position, Position target_position) {
auto& target_cell = ensure(target_position);
@ -337,6 +337,8 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
}
target_cell.copy_from(*source_cell);
if (copy_operation == CopyOperation::Cut)
source_cell->set_data("");
};
if (from.size() == to.size()) {