summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-11-11 10:41:10 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-11-11 22:17:55 +0100
commita1cba2d4db9de4883789e9cd7669a051789a48ee (patch)
tree3bd3daa47313e93e7be603799b7c79b9dc7fdb9a
parentd486c3568f7ef545712cd1c9ba97b0296ed48657 (diff)
cid#1455326 MoveSticky always has a non-nullptr pDoc
Change-Id: I84d9a81e9e8a544dbc50b9d6b40a7b9030f2a987 Reviewed-on: https://gerrit.libreoffice.org/82425 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/inc/address.hxx2
-rw-r--r--sc/source/core/tool/address.cxx13
-rw-r--r--sc/source/core/tool/token.cxx2
3 files changed, 9 insertions, 8 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index ec63932c5fc6..9af77284a986 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -625,7 +625,7 @@ public:
ScRange& rErrorRange, const ScDocument* pDocument = nullptr );
/** Same as Move() but with sticky end col/row anchors. */
- [[nodiscard]] SC_DLLPUBLIC bool MoveSticky( const ScDocument* pDoc, SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ,
+ [[nodiscard]] SC_DLLPUBLIC bool MoveSticky( const ScDocument& rDoc, SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ,
ScRange& rErrorRange );
SC_DLLPUBLIC void IncColIfNotLessThan(const ScDocument* pDoc, SCCOL nStartCol, SCCOL nOffset);
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index e38bdc6d68fa..7df7f06866e9 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2376,19 +2376,20 @@ bool ScRange::Move( SCCOL dx, SCROW dy, SCTAB dz, ScRange& rErrorRange, const Sc
return b;
}
-bool ScRange::MoveSticky( const ScDocument* pDoc, SCCOL dx, SCROW dy, SCTAB dz, ScRange& rErrorRange )
+bool ScRange::MoveSticky( const ScDocument& rDoc, SCCOL dx, SCROW dy, SCTAB dz, ScRange& rErrorRange )
{
- const SCCOL nMaxCol = (pDoc ? pDoc->MaxCol() : MAXCOL);
+ const SCCOL nMaxCol = rDoc.MaxCol();
+ const SCROW nMaxRow = rDoc.MaxRow();
bool bColRange = (aStart.Col() < aEnd.Col());
bool bRowRange = (aStart.Row() < aEnd.Row());
- if (dy && aStart.Row() == 0 && aEnd.Row() == pDoc->MaxRow())
+ if (dy && aStart.Row() == 0 && aEnd.Row() == nMaxRow)
dy = 0; // Entire column not to be moved.
if (dx && aStart.Col() == 0 && aEnd.Col() == nMaxCol)
dx = 0; // Entire row not to be moved.
bool b1 = aStart.Move( dx, dy, dz, rErrorRange.aStart );
if (dx && bColRange && aEnd.Col() == nMaxCol)
dx = 0; // End column sticky.
- if (dy && bRowRange && aEnd.Row() == pDoc->MaxRow())
+ if (dy && bRowRange && aEnd.Row() == nMaxRow)
dy = 0; // End row sticky.
SCTAB nOldTab = aEnd.Tab();
bool b2 = aEnd.Move( dx, dy, dz, rErrorRange.aEnd );
@@ -2398,9 +2399,9 @@ bool ScRange::MoveSticky( const ScDocument* pDoc, SCCOL dx, SCROW dy, SCTAB dz,
bColRange = (!dx || (bColRange && aEnd.Col() == nMaxCol));
if (dx && bColRange)
rErrorRange.aEnd.SetCol(nMaxCol);
- bRowRange = (!dy || (bRowRange && aEnd.Row() == pDoc->MaxRow()));
+ bRowRange = (!dy || (bRowRange && aEnd.Row() == nMaxRow));
if (dy && bRowRange)
- rErrorRange.aEnd.SetRow(pDoc->MaxRow());
+ rErrorRange.aEnd.SetRow(nMaxRow);
b2 = bColRange && bRowRange && (aEnd.Tab() - nOldTab == dz);
}
return b1 && b2;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f1ee8ced4bc1..8bed30a6a57f 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3202,7 +3202,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
else
{
ScRange aErrorRange( ScAddress::UNINITIALIZED );
- if (!aAbs.MoveSticky(&rCxt.mrDoc, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, aErrorRange))
+ if (!aAbs.MoveSticky(rCxt.mrDoc, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, aErrorRange))
aAbs = aErrorRange;
aRes.mbReferenceModified = true;
}