diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-05-18 18:05:31 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-05-19 00:17:52 +0200 |
commit | f3e1ebd309a967d3bb06a7e0fe9b501d1faa124b (patch) | |
tree | 94d5eb351e55f631d341ade9a72a8819c0e1fb95 | |
parent | c061d3cee60af8aa5e9aa924df0f38248d91b777 (diff) |
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.lunak@collabora.com>
-rw-r--r-- | sc/inc/column.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 17 |
2 files changed, 18 insertions, 6 deletions
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 ) |