Spreadsheet: do not copy empty cell

Because pasteCells() will clear empty cells in selected range
This commit is contained in:
Zheng, Lei
2022-04-22 22:33:18 +08:00
committed by Chris Hennes
parent 68299281d3
commit 98668ed947

View File

@@ -356,20 +356,21 @@ void PropertySheet::copyCells(Base::Writer& writer, const std::vector<Range>& ra
writer.Stream() << "<Cells count=\"" << ranges.size() << "\">" << std::endl;
writer.incInd();
for (auto range : ranges) {
auto r = range;
int count = 0;
do {
auto cell = getValue(*r);
if(cell && cell->isUsed())
++count;
}while(r.next());
writer.Stream() << writer.ind() << "<Range from=\"" << range.fromCellString()
<< "\" to=\"" << range.toCellString() << "\" count=\"" << range.size() << "\">" << std::endl;
<< "\" to=\"" << range.toCellString() << "\" count=\"" << count << "\">" << std::endl;
writer.incInd();
do {
auto cell = getValue(*range);
if (cell && cell->isUsed()) {
cell->save(writer);
}
else {
// The cell is empty, so when it's pasted it needs to clear the existing contents
writer.Stream() << writer.ind() << "<Cell "
<< "address=\"" << (*range).toString() << "\" "
<< "content = \"\" />";
}
} while (range.next());
writer.decInd();
writer.Stream() << writer.ind() << "</Range>" << std::endl;