diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-13 12:35:24 -0400 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-05-16 08:35:22 +0000 |
commit | 0a47daf3175ec16d48669535a34823be47fbb42a (patch) | |
tree | 1f845770b13d3e341a85e02a7ebeeb513b098aed | |
parent | 8f1f935beee8495168b19f4b5e02bde8a9399154 (diff) |
fdo#78402: Adjust references of validity entries as appropriate.
Change-Id: I7fd62153c7267a3d606b86d74bebecf6b8d75250
(cherry picked from commit a93bb27aa46c84410c8848a6118d5d63d47be92c)
Reviewed-on: https://gerrit.libreoffice.org/9345
Tested-by: David Tardon <dtardon@redhat.com>
Reviewed-by: David Tardon <dtardon@redhat.com>
-rw-r--r-- | sc/source/core/data/conditio.cxx | 29 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 15 |
3 files changed, 47 insertions, 5 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index ae5e098f899d..5e8e5491fb03 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -510,13 +510,38 @@ void ScConditionEntry::UpdateReference( sc::RefUpdateContext& rCxt ) if (pFormula1) { - sc::RefUpdateResult aRes = pFormula1->AdjustReferenceInName(rCxt, aOldSrcPos); + sc::RefUpdateResult aRes; + switch (rCxt.meMode) + { + case URM_INSDEL: + aRes = pFormula1->AdjustReferenceOnShift(rCxt, aOldSrcPos); + break; + case URM_MOVE: + aRes = pFormula1->AdjustReferenceOnMove(rCxt, aOldSrcPos, aSrcPos); + break; + default: + ; + } + if (aRes.mbReferenceModified || bChangedPos) DELETEZ(pFCell1); // is created again in IsValid } + if (pFormula2) { - sc::RefUpdateResult aRes = pFormula2->AdjustReferenceInName(rCxt, aOldSrcPos); + sc::RefUpdateResult aRes; + switch (rCxt.meMode) + { + case URM_INSDEL: + aRes = pFormula2->AdjustReferenceOnShift(rCxt, aOldSrcPos); + break; + case URM_MOVE: + aRes = pFormula2->AdjustReferenceOnMove(rCxt, aOldSrcPos, aSrcPos); + break; + default: + ; + } + if (aRes.mbReferenceModified || bChangedPos) DELETEZ(pFCell2); // is created again in IsValid } diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index c5ebbd3009c2..423900153a1d 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -1843,6 +1843,8 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_ { if (xMat) { + SCSIZE nCols, nRows; + xMat->GetDimensions(nCols, nRows); ScMatrixValue nMatVal = xMat->Get(0, 0); ScMatValType nMatValType = nMatVal.nType; if (ScMatrix::IsNonValueType( nMatValType)) @@ -1850,14 +1852,14 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_ if ( xMat->IsEmptyPath( 0, 0)) { // result of empty FALSE jump path FormulaTokenRef xRes = new FormulaDoubleToken( 0.0); - PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get())); + PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, xMat, xRes.get())); rRetTypeExpr = NUMBERFORMAT_LOGICAL; } else { svl::SharedString aStr( nMatVal.GetString()); FormulaTokenRef xRes = new FormulaStringToken( aStr); - PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get())); + PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, xMat, xRes.get())); rRetTypeExpr = NUMBERFORMAT_TEXT; } } @@ -1869,7 +1871,7 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_ xRes = new FormulaErrorToken( nErr); else xRes = new FormulaDoubleToken( nMatVal.fVal); - PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get())); + PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, xMat, xRes.get())); if ( rRetTypeExpr != NUMBERFORMAT_LOGICAL ) rRetTypeExpr = NUMBERFORMAT_NUMBER; } diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index cb4f25ab9fcb..634e1f6b3430 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -48,6 +48,8 @@ #include "clipparam.hxx" #include "sc.hrc" #include <refhint.hxx> +#include <refupdatecontext.hxx> +#include <validat.hxx> #include <set> @@ -1265,6 +1267,19 @@ void ScUndoDragDrop::Undo() SCTAB nTabDelta = aSrcRange.aStart.Tab() - aDestRange.aStart.Tab(); sc::RefMovedHint aHint(aDestRange, ScAddress(nColDelta, nRowDelta, nTabDelta)); pDoc->BroadcastRefMoved(aHint); + + ScValidationDataList* pValidList = pDoc->GetValidationList(); + if (pValidList) + { + // Update the references of validation entries. + sc::RefUpdateContext aCxt(*pDoc); + aCxt.meMode = URM_MOVE; + aCxt.maRange = aSrcRange; + aCxt.mnColDelta = nColDelta; + aCxt.mnRowDelta = nRowDelta; + aCxt.mnTabDelta = nTabDelta; + pValidList->UpdateReference(aCxt); + } } DoUndo(aDestRange); |