summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-18 18:48:23 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-19 06:52:29 +0200
commit890493c3dc058ddedf9d6629abf178f7898c7342 (patch)
tree606efe5c2c30b63de38bd1a5abda93b0042e462a /sc/source
parent0ff5b5f69d9323fadeac31614ea216bb55fae9f5 (diff)
don't allocate unnecessary columns when inserting a row
Change-Id: I616ef20dc1295ce17c4877ff367815bb6a90b7a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134551 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/column.cxx6
-rw-r--r--sc/source/core/data/table1.cxx25
-rw-r--r--sc/source/core/data/table2.cxx3
3 files changed, 15 insertions, 19 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index a6293094f9a5..51d039fdb5dd 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2390,13 +2390,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 a3003677d431..e65aa194f9f7 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 230e26166a12..5943feb9e5f6 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);