[Libreoffice-commits] core.git: sc/source
Winfried Donkers
winfrieddonkers at libreoffice.org
Tue Jul 12 12:38:29 UTC 2016
sc/source/core/tool/interpr2.cxx | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
New commits:
commit e4b3772ef966fb3db8dfaa55dfc5f5582d61761d
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date: Fri Jul 8 09:46:10 2016 +0200
tdf#100762 Add support for array arguments to NPV.
Change-Id: I8935ed85df456bd5f86adf0392a19eb0b6a2f656
Reviewed-on: https://gerrit.libreoffice.org/27034
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 8418062..458236e 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;
}
}
More information about the Libreoffice-commits
mailing list