21#include <document.hxx>
25#include <osl/diagnose.h>
27template<
typename R,
typename S,
typename U >
32 rRef = sal::static_int_cast<R>( rRef + nDelta );
33 else if ( nDelta < 0 && rRef >= nStart + nDelta )
34 rRef = nStart + nDelta;
40 else if ( rRef > nMask )
48template<
typename R,
typename S,
typename U >
53 rRef = sal::static_int_cast<R>( rRef + nDelta );
54 else if ( nDelta < 0 && rRef >= nStart + nDelta )
55 rRef = nStart + nDelta - 1;
69template<
typename R,
typename S,
typename U >
72 if ( rRef >= nStart && rRef <= nEnd )
74 rRef = sal::static_int_cast<R>( rRef + nDelta );
80 if ( rRef >= nStart && rRef <= nEnd + nDelta )
83 rRef = sal::static_int_cast<R>( rRef + nDelta );
85 rRef -= nEnd - nStart + 1;
91 if ( rRef >= nStart + nDelta && rRef <= nEnd )
94 rRef = sal::static_int_cast<R>( rRef + nDelta );
96 rRef += nEnd - nStart + 1;
104template<
typename R,
typename S,
typename U >
108 rRef = sal::static_int_cast<R>( rRef + nDelta );
114 else if ( rRef > nMask )
122template<
typename R,
typename U >
125 rRef = sal::static_int_cast<R>( rRef );
128 else if ( rRef > nMask )
132template<
typename R,
typename S,
typename U >
139 (nStart <=
n1 &&
n1 < nStart + nD)
140 || (
n2 + 1 == nStart)
144template<
typename R,
typename S,
typename U >
148 if (
n2 + 1 == nStart )
150 n2 = sal::static_int_cast<R>(
n2 + nD );
154 n1 = sal::static_int_cast<R>(
n1 - nD );
159 if (
nRef > 0 && nDelta > 0 )
160 return nRef + nDelta <= 0;
161 else if (
nRef < 0 && nDelta < 0 )
162 return nRef + nDelta >= 0;
166static bool lcl_MoveBig( sal_Int64& rRef, sal_Int64 nStart, sal_Int32 nDelta )
169 if ( rRef >= nStart )
197 SCCOL oldCol1 = theCol1;
198 SCROW oldRow1 = theRow1;
199 SCTAB oldTab1 = theTab1;
200 SCCOL oldCol2 = theCol2;
201 SCROW oldRow2 = theRow2;
202 SCTAB oldTab2 = theTab2;
209 if ( nDx && (theRow1 >= nRow1) && (theRow2 <= nRow2) &&
210 (theTab1 >= nTab1) && (theTab2 <= nTab2))
212 bool bExp = (bExpand &&
IsExpand( theCol1, theCol2, nCol1, nDx ));
215 if ( theCol2 < theCol1 )
220 else if (bCut2 && theCol2 == 0)
222 else if ( bCut1 || bCut2 )
226 Expand( theCol1, theCol2, nCol1, nDx );
235 else if (oldCol2 == pDoc->
MaxCol() && oldCol1 < pDoc->MaxCol())
245 if ( nDy && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
246 (theTab1 >= nTab1) && (theTab2 <= nTab2))
248 bool bExp = (bExpand &&
IsExpand( theRow1, theRow2, nRow1, nDy ));
251 if ( theRow2 < theRow1 )
256 else if (bCut2 && theRow2 == 0)
258 else if ( bCut1 || bCut2 )
262 Expand( theRow1, theRow2, nRow1, nDy );
271 else if (oldRow2 == pDoc->
MaxRow() && oldRow1 < pDoc->MaxRow())
281 if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
282 (theRow1 >= nRow1) && (theRow2 <= nRow2) )
285 nMaxTab = sal::static_int_cast<SCTAB>(nMaxTab + nDz);
286 bool bExp = (bExpand &&
IsExpand( theTab1, theTab2, nTab1, nDz ));
288 bCut2 =
lcl_MoveEnd( theTab2, nTab1, nDz, nMaxTab );
289 if ( bCut1 || bCut2 )
293 Expand( theTab1, theTab2, nTab1, nDz );
298 else if (eUpdateRefMode ==
URM_MOVE)
300 if ((theCol1 >= nCol1-nDx) && (theRow1 >= nRow1-nDy) && (theTab1 >= nTab1-nDz) &&
301 (theCol2 <= nCol2-nDx) && (theRow2 <= nRow2-nDy) && (theTab2 <= nTab2-nDz))
307 if ( bCut1 || bCut2 )
320 if ( bCut1 || bCut2 )
334 if ( bCut1 || bCut2 )
342 OSL_ENSURE ( !nDx && !nDy,
"URM_REORDER for x and y not yet implemented" );
344 if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
345 (theRow1 >= nRow1) && (theRow2 <= nRow2) )
349 if ( bCut1 || bCut2 )
356 if (oldCol1 != theCol1
357 || oldRow1 != theRow1
358 || oldTab1 != theTab1
359 || oldCol2 != theCol2
360 || oldRow2 != theRow2
361 || oldTab2 != theTab2
372 const ScBigRange& rWhere, sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz,
378 sal_Int64 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2;
379 sal_Int64 theCol1, theRow1, theTab1, theCol2, theRow2, theTab2;
380 rWhere.
GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
381 rWhat.
GetVars( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 );
387 if ( nDx && (theRow1 >= nRow1) && (theRow2 <= nRow2) &&
388 (theTab1 >= nTab1) && (theTab2 <= nTab2) &&
393 if ( bCut1 || bCut2 )
398 if ( nDy && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
399 (theTab1 >= nTab1) && (theTab2 <= nTab2) &&
404 if ( bCut1 || bCut2 )
409 if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
410 (theRow1 >= nRow1) && (theRow2 <= nRow2) &&
415 if ( bCut1 || bCut2 )
421 else if (eUpdateRefMode ==
URM_MOVE)
429 if ( bCut1 || bCut2 )
438 if ( bCut1 || bCut2 )
447 if ( bCut1 || bCut2 )
455 if ( eRet ==
UR_NOTHING && rWhat != aOldRange )
513 SCTAB nNewTab = rTab+nDz;
515 while (nNewTab<0) nNewTab = sal::static_int_cast<SCTAB>( nNewTab +
nCount );
516 while (nNewTab>=
nCount) nNewTab = sal::static_int_cast<SCTAB>( nNewTab -
nCount );
520 "UpdateTranspose: pos. wrong" );
543 DoTranspose(nCol1, nRow1, nTab1, rDoc, rSource, rDest);
544 DoTranspose(nCol2, nRow2, nTab2, rDoc, rSource, rDest);
563 bool bUpdateX = ( nGrowX &&
567 bool bUpdateY = ( nGrowY &&
void SetCol(sal_Int64 nColP)
void SetTab(sal_Int64 nTabP)
void SetRow(sal_Int64 nRowP)
static constexpr sal_Int64 nRangeMin
static constexpr sal_Int64 nRangeMax
bool Contains(const ScBigAddress &) const
is Address& in range?
void GetVars(sal_Int64 &nCol1, sal_Int64 &nRow1, sal_Int64 &nTab1, sal_Int64 &nCol2, sal_Int64 &nRow2, sal_Int64 &nTab2) const
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
bool IsExpandRefs() const
SC_DLLPUBLIC SCTAB GetTableCount() const
bool Contains(const ScAddress &) const
is Address& fully in Range?
static ScRefUpdateRes UpdateTranspose(const ScDocument &rDoc, const ScRange &rSource, const ScAddress &rDest, ScRange &rRef)
static ScRefUpdateRes Update(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, SCCOL &theCol1, SCROW &theRow1, SCTAB &theTab1, SCCOL &theCol2, SCROW &theRow2, SCTAB &theTab2)
static void DoTranspose(SCCOL &rCol, SCROW &rRow, SCTAB &rTab, const ScDocument &rDoc, const ScRange &rSource, const ScAddress &rDest)
static void MoveRelWrap(const ScDocument &rDoc, const ScAddress &rPos, SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData &rRef)
static ScRefUpdateRes UpdateGrow(const ScRange &rArea, SCCOL nGrowX, SCROW nGrowY, ScRange &rRef)
static bool lcl_MoveStart(R &rRef, U nStart, S nDelta, U nMask)
static bool lcl_MoveReorder(R &rRef, U nStart, U nEnd, S nDelta)
static void lcl_MoveItWrap(R &rRef, U nMask)
static void Expand(R &n1, R &n2, U nStart, S nD)
static bool lcl_MoveBig(sal_Int64 &rRef, sal_Int64 nStart, sal_Int32 nDelta)
static bool IsExpand(R n1, R n2, U nStart, S nD)
static bool lcl_MoveItCut(R &rRef, S nDelta, U nMask)
static bool lcl_MoveItCutBig(sal_Int64 &rRef, sal_Int32 nDelta)
static bool lcl_MoveEnd(R &rRef, U nStart, S nDelta, U nMask)
static bool lcl_IsWrapBig(sal_Int64 nRef, sal_Int32 nDelta)
@ UR_INVALID
Some part of the reference became invalid.
@ UR_STICKY
Not updated because the reference is sticky, but would had been updated if it wasn't.
@ UR_NOTHING
Reference not affected, no change at all.
@ UR_UPDATED
Reference was adjusted/updated.
Complex reference (a range) into the sheet.
SC_DLLPUBLIC ScRange toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
void SetRange(const ScSheetLimits &rLimits, const ScRange &rRange, const ScAddress &rPos)
Set a new range, assuming that the ordering of the range matches the ordering of the reference data f...
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW