sc/inc/column.hxx | 7 +++++++ sc/source/core/data/table2.cxx | 17 +++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-)
New commits: commit f3e1ebd309a967d3bb06a7e0fe9b501d1faa124b Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed May 18 18:05:31 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Thu May 19 00:17:52 2022 +0200 ScTable::TestInsertRow() does not need to allocate all columns Change-Id: Ic213997edf6838282a38e444a638713a72397fb4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134545 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 4d6f2c8e01ac..290334f7f3fd 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -169,6 +169,8 @@ public: void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark, SCCOL nCol ); void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark, SCCOL nCol ); + + bool TestInsertRow( SCSIZE nSize ) const; }; // Use protected inheritance to prevent publishing some internal ScColumnData @@ -1034,4 +1036,9 @@ inline void ScColumnData::SetAttrEntries(std::vector<ScAttrEntry> && vNewData) pAttrArray->SetAttrEntries( std::move( vNewData )); } +inline bool ScColumnData::TestInsertRow( SCSIZE nSize ) const +{ + return pAttrArray->TestInsertRow( nSize ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index a290d07f4769..ef49854b5c01 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -134,15 +134,20 @@ void ScTable::SetCalcNotification( bool bSet ) bool ScTable::TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const { - bool bTest = true; - if ( nStartCol==0 && nEndCol==rDocument.MaxCol() && pOutlineTable ) - bTest = pOutlineTable->TestInsertRow(nSize); + if (!pOutlineTable->TestInsertRow(nSize)) + return false; + + SCCOL maxCol = ClampToAllocatedColumns(nEndCol); + for (SCCOL i=nStartCol; i<=maxCol; i++) + if (!aCol[i].TestInsertRow(nStartRow, nSize)) + return false; - for (SCCOL i=nStartCol; (i<=nEndCol) && bTest; i++) - bTest = const_cast<ScTable*>(this)->CreateColumnIfNotExists(i).TestInsertRow(nStartRow, nSize); + if( maxCol != nEndCol ) + if (!aDefaultColData.TestInsertRow(nSize)) + return false; - return bTest; + return true; } void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize )