diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-05-18 18:48:23 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-05-19 00:18:26 +0200 |
commit | 2e86718626a07e1656661df3ad69a64848bf4614 (patch) | |
tree | 23c0a63b1e5f07036d5caabda67374b2caaacd49 /sc | |
parent | 141519233b16353c4998bb826fab11d17dbaf6a3 (diff) |
don't allocate unnecessary columns when inserting a row
Change-Id: I616ef20dc1295ce17c4877ff367815bb6a90b7a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134547
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/column.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 25 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 3 |
4 files changed, 21 insertions, 19 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 290334f7f3fd..e4b7eb148d9a 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -171,6 +171,7 @@ public: void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark, SCCOL nCol ); bool TestInsertRow( SCSIZE nSize ) const; + void InsertRow( SCROW nStartRow, SCSIZE nSize ); }; // Use protected inheritance to prevent publishing some internal ScColumnData @@ -1041,4 +1042,9 @@ inline bool ScColumnData::TestInsertRow( SCSIZE nSize ) const return pAttrArray->TestInsertRow( nSize ); } +inline void ScColumnData::InsertRow( SCROW nStartRow, SCSIZE nSize ) +{ + pAttrArray->InsertRow( nStartRow, nSize ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 2353a476fe8a..57451b19f305 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2391,13 +2391,13 @@ bool ScColumn::UpdateReferenceOnCopy( sc::RefUpdateContext& rCxt, ScDocument* pU bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc ) { - if (rCxt.meMode == URM_COPY) - return UpdateReferenceOnCopy(rCxt, pUndoDoc); - if (IsEmptyData() || GetDoc().IsClipOrUndo()) // Cells in this column are all empty, or clip or undo doc. No update needed. return false; + if (rCxt.meMode == URM_COPY) + return UpdateReferenceOnCopy(rCxt, pUndoDoc); + std::vector<SCROW> aBounds; bool bThisColShifted = (rCxt.maRange.aStart.Tab() <= nTab && nTab <= rCxt.maRange.aEnd.Tab() && diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 619947b15f2a..0b75dcefca2e 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1819,19 +1819,6 @@ void ScTable::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos ) { bool bUpdated = false; - SCCOL i; - SCCOL iMax; - if (rCxt.meMode == URM_COPY ) - { - i = rCxt.maRange.aStart.Col(); - iMax = rCxt.maRange.aEnd.Col(); - } - else - { - i = 0; - iMax = rDocument.MaxCol(); - } - UpdateRefMode eUpdateRefMode = rCxt.meMode; SCCOL nDx = rCxt.mnColDelta; SCROW nDy = rCxt.mnRowDelta; @@ -1844,8 +1831,16 @@ void ScTable::UpdateReference( if (mpRangeName) mpRangeName->UpdateReference(rCxt, nTab); - for ( ; i<=iMax; i++) - bUpdated |= CreateColumnIfNotExists(i).UpdateReference(rCxt, pUndoDoc); + if (rCxt.meMode == URM_COPY ) + { + for( SCCOL col : GetAllocatedColumnsRange( rCxt.maRange.aStart.Col(), rCxt.maRange.aEnd.Col())) + bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc); + } + else + { + for( SCCOL col : GetAllocatedColumnsRange( 0, rDocument.MaxCol())) + bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc); + } if ( bIncludeDraw ) UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos ); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 2b6706790bdc..4e1d1f4da99d 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -186,8 +186,9 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE } } - for (SCCOL j=nStartCol; j<=nEndCol; j++) + for (SCCOL j : GetAllocatedColumnsRange(nStartCol, nEndCol)) aCol[j].InsertRow( nStartRow, nSize ); + aDefaultColData.InsertRow( nStartRow, nSize ); mpCondFormatList->InsertRow(nTab, nStartCol, nEndCol, nStartRow, nSize); |