diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2017-03-22 21:21:31 -0400 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-04-06 13:52:57 +0000 |
commit | 2d9de590d9ebd8740fc0f6d94f5ee98b22377877 (patch) | |
tree | 128aff09e9a32fcfb942a274d4cd9bd4c5c7e512 | |
parent | d79935cb3154ca86aca01043d7c196cc161db67b (diff) |
tdf#105908: restore previously deleted range references upon undo.
Reviewed-on: https://gerrit.libreoffice.org/35607
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
(cherry picked from commit 749405af4fc38e0c16dc7e860d23a13dfceb4e40)
Conflicts:
sc/source/core/tool/interpr6.cxx
Change-Id: If1932a5eb10da4c50fbcc3329af75f2e7a0a5137
Reviewed-on: https://gerrit.libreoffice.org/35673
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/inc/refdata.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 19 | ||||
-rw-r--r-- | sc/source/core/tool/interpr6.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/refdata.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 19 |
5 files changed, 49 insertions, 2 deletions
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx index 5f3e7626940a..098f24de28fd 100644 --- a/sc/inc/refdata.hxx +++ b/sc/inc/refdata.hxx @@ -190,6 +190,8 @@ struct ScComplexRefData @return TRUE if changed. */ bool IncEndRowSticky( SCROW nDelta, const ScAddress& rPos ); + bool IsDeleted() const; + #if DEBUG_FORMULA_COMPILER void Dump( int nIndent = 0 ) const; #endif diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 24a3d53dc093..fe3469c8f403 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -950,10 +950,17 @@ void ScInterpreter::PopSingleRef( ScAddress& rAdr ) break; case svSingleRef: { + const ScSingleRefData* pRefData = p->GetSingleRef(); + if (pRefData->IsDeleted()) + { + SetError( errNoRef); + break; + } + SCCOL nCol; SCROW nRow; SCTAB nTab; - SingleRefToVars( *p->GetSingleRef(), nCol, nRow, nTab); + SingleRefToVars( *pRefData, nCol, nRow, nTab); rAdr.Set( nCol, nRow, nTab ); if (!pDok->m_TableOpList.empty()) ReplaceCell( rAdr ); @@ -1075,9 +1082,17 @@ void ScInterpreter::PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRe nGlobalError = pToken->GetError(); break; case svDoubleRef: + { --sp; - DoubleRefToRange( *pToken->GetDoubleRef(), rRange); + const ScComplexRefData* pRefData = pToken->GetDoubleRef(); + if (pRefData->IsDeleted()) + { + SetError( errNoRef); + break; + } + DoubleRefToRange( *pRefData, rRange); break; + } case svRefList: { const ScRefList* pList = pToken->GetRefList(); diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 78d6f47c2589..d385e77e1fda 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -613,6 +613,9 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case svSingleRef : { PopSingleRef( aAdr ); + if (nGlobalError == errNoRef) + return 0.0; + if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) { @@ -676,6 +679,9 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case svRefList : { PopDoubleRef( aRange, nParamCount, nRefInList); + if (nGlobalError == errNoRef) + return 0.0; + if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) { diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx index d97289345ae5..5d7d0f320f68 100644 --- a/sc/source/core/tool/refdata.cxx +++ b/sc/source/core/tool/refdata.cxx @@ -553,6 +553,11 @@ bool ScComplexRefData::IncEndRowSticky( SCROW nDelta, const ScAddress& rPos ) return true; } +bool ScComplexRefData::IsDeleted() const +{ + return Ref1.IsDeleted() || Ref2.IsDeleted(); +} + #if DEBUG_FORMULA_COMPILER void ScComplexRefData::Dump( int nIndent ) const { diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 2eb0fa6da110..e7714801dac0 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -2668,6 +2668,12 @@ void setRefDeleted( ScComplexRefData& rRef, const sc::RefUpdateContext& rCxt ) } } +void restoreDeletedRef( ScComplexRefData& rRef, const sc::RefUpdateContext& rCxt ) +{ + restoreDeletedRef(rRef.Ref1, rCxt); + restoreDeletedRef(rRef.Ref2, rCxt); +} + bool shrinkRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, const ScRange& rDeletedRange, const ScComplexRefData& rRef ) { @@ -3043,6 +3049,19 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon } } + if (!rCxt.isDeleted() && rRef.IsDeleted()) + { + // Check if the token has reference to previously deleted region. + ScRange aCheckRange = rRef.toAbs(aNewPos); + if (aSelectedRange.In(aCheckRange)) + { + // This reference was previously in the deleted region. Restore it. + restoreDeletedRef(rRef, rCxt); + aRes.mbValueChanged = true; + break; + } + } + if (rCxt.isInserted()) { if (expandRange(rCxt, aAbs, aSelectedRange, rRef)) |