summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-18 18:45:18 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-19 06:52:16 +0200
commit0ff5b5f69d9323fadeac31614ea216bb55fae9f5 (patch)
tree6ae73a0d0bef8c349c75379f2a1672f9e19b1ad8 /sc/source
parent8466499595e899ff7db737729bb4ecea17e30a04 (diff)
actually insert the column(s) in ScTable::InsertCol()
This was broken if the all the columns weren't allocated, since at least in the full-column mode it was swapping the last empty columns in the place of the new ones, but without all columns allocated there possibly weren't last empty columns, so it was instead swapping in last data columns. Change-Id: I21552f0eb296b0df5507677510a8b85fccb1ae5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134550 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/table2.cxx3
1 files changed, 3 insertions, 0 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index f42d35f7bb61..230e26166a12 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -308,8 +308,11 @@ void ScTable::InsertCol(
}
}
+ // Make sure there are enough columns at the end.
+ CreateColumnIfNotExists(std::min<SCCOL>(rDocument.MaxCol(), std::max(nStartCol, aCol.size()) + nSize - 1 ));
if ((nStartRow == 0) && (nEndRow == rDocument.MaxRow()))
{
+ // Move existing columns back, this will swap last empty columns in the inserted place.
for (SCCOL nCol = aCol.size() - 1 - nSize; nCol >= nStartCol; --nCol)
aCol[nCol].SwapCol(aCol[nCol+nSize]);
}