summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2016-07-08 09:46:10 +0200
committerEike Rathke <erack@redhat.com>2016-07-12 12:38:07 +0000
commite4b3772ef966fb3db8dfaa55dfc5f5582d61761d (patch)
tree929b4720cbf36bfbcb62a4e96a27aae941c0bcbc /sc
parent0759f31172253d6c5be3b938446ff1b8313adebd (diff)
tdf#100762 Add support for array arguments to NPV.
Change-Id: I8935ed85df456bd5f86adf0392a19eb0b6a2f656 Reviewed-on: https://gerrit.libreoffice.org/27034 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/interpr2.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 8418062b8606..458236ebca7e 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1316,6 +1316,41 @@ void ScInterpreter::ScNPV()
SetError(nErr);
}
break;
+ case svMatrix :
+ case svExternalSingleRef:
+ case svExternalDoubleRef:
+ {
+ ScMatrixRef pMat = GetMatrix();
+ if (pMat)
+ {
+ SCSIZE nC, nR;
+ pMat->GetDimensions(nC, nR);
+ if (nC == 0 || nR == 0)
+ {
+ PushIllegalArgument();
+ return;
+ }
+ else
+ {
+ double fx;
+ for ( SCSIZE j = 0; j < nC; j++ )
+ {
+ for (SCSIZE k = 0; k < nR; ++k)
+ {
+ if (!pMat->IsValue(j,k))
+ {
+ PushIllegalArgument();
+ return;
+ }
+ fx = pMat->GetDouble(j,k);
+ nVal += (fx / pow(1.0 + nInterest, nCount));
+ nCount++;
+ }
+ }
+ }
+ }
+ }
+ break;
default : SetError(errIllegalParameter); break;
}
}