sc/inc/column.hxx | 6 ++++++ sc/source/core/data/table1.cxx | 12 +++++------- sc/source/core/data/table2.cxx | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-)
New commits: commit dd8e061406fac581d399da088c7f0187278035dc Author: Czeber László Ádám <czeber.laszloa...@nisz.hu> AuthorDate: Thu Jun 8 14:55:34 2023 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Jun 9 15:41:38 2023 +0200 tdf#153437 sc: fix broken formatting without performance regression Follow-up to commit 7be7e1ff95af485a9cb00748800d3d084f96387c "tdf#153437 sc: fix broken formatting at Undo of row/column insertion" by replacing that with a better version without performance regression. This keeps the original performance fix of commit 2e86718626a07e1656661df3ad69a64848bf4614 "don't allocate unnecessary columns when inserting a row" related to the support of 16k columns. The previous fix used extra memory to fix the broken formatting of the cells. I have now solved the error in tdf#153437 without taking extra memory. It doesn't change the reserved cells, it just deletes a row from the default attribute of the cells when deleting rows, so they don't slip. When deleting a column, the last column in the still reserved area loses its formatting. I copied the default value back here, as the other columns have this value. Change-Id: I35da1cb79ff4e3493e91d29766cc2b81412080eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152742 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 5c42f02794ab..4b64537e1705 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -172,6 +172,7 @@ public: bool TestInsertRow( SCSIZE nSize ) const; void InsertRow( SCROW nStartRow, SCSIZE nSize ); + void DeleteRow( SCROW nStartRow, SCSIZE nSize ); }; // Use protected inheritance to prevent publishing some internal ScColumnData @@ -1057,4 +1058,9 @@ inline void ScColumnData::InsertRow( SCROW nStartRow, SCSIZE nSize ) pAttrArray->InsertRow( nStartRow, nSize ); } +inline void ScColumnData::DeleteRow(SCROW nStartRow, SCSIZE nSize) +{ + pAttrArray->DeleteRow( nStartRow, nSize ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 99e0c5f39b0d..c5d4de055f8d 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1849,13 +1849,11 @@ void ScTable::UpdateReference( } else { - // When deleting row(s) or column(s), allocate the last column - // before updating the references - if (nDx < 0 || nDy < 0) - CreateColumnIfNotExists(rDocument.MaxCol()); - - for (SCCOL col : GetColumnsRange(0, rDocument.MaxCol())) - bUpdated |= CreateColumnIfNotExists(col).UpdateReference(rCxt, pUndoDoc); + for (SCCOL col : GetAllocatedColumnsRange(0, rDocument.MaxCol())) + bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc); + // When deleting row(s), delete same row from the default attribute + if (nDy < 0) + aDefaultColData.DeleteRow(nRow1+nDy, -nDy); } if ( bIncludeDraw ) diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index b3a5b9aee9b9..b35caa7459bb 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -400,6 +400,9 @@ void ScTable::DeleteCol( { for (SCCOL nCol = nStartCol + nSize; nCol < aCol.size(); ++nCol) aCol[nCol].SwapCol(aCol[nCol - nSize]); + // When delete column(s), inicialize the last columns from the default attributes + for (SCCOL nCol = aCol.size() - nSize; nCol < aCol.size(); ++nCol) + aCol[nCol].Init(nCol, aCol[nCol].GetTab(), rDocument, false); } else {