sc/source/core/data/table2.cxx | 3 +++ 1 file changed, 3 insertions(+)
New commits: commit 141519233b16353c4998bb826fab11d17dbaf6a3 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed May 18 18:45:18 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Thu May 19 00:18:08 2022 +0200 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/+/134546 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index ef49854b5c01..2b6706790bdc 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]); }