summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-01-20 16:24:14 +0200
committerMichael Meeks <michael.meeks@collabora.com>2015-01-21 07:21:19 +0000
commitdad7161cc30b335a108c7850f453877a161969ae (patch)
treeb0b093ffe95b869a94fe3de283e33baff7254c4c /scaddins
parentcd5f69376bf27275d92073943451b8b72a708d04 (diff)
fdo88632: Make the Calc random functions non-random when requested
We don't want such a mode to affect other uses of randomness, though. Thus use a separate random number generator object for these two functions, and use a fixed seed for it if the SC_RAND_REPEATABLE environment variable is set. As RAND() is implemented in sc, and RANDBETWEEN() is implemented in scaddins, it was a bit hard to figure out where to add the new functions needed, without having to over-engineer things with UNO. (This functionality is totally Calc-specific, but neither sc nor scaddins has any public (non-UNO) API.) Caolan suggested the formula module, which seems like a good enough place to me. Change-Id: Ic1c9ca165278d53036598b03b13b4ffbdc98a75e Reviewed-on: https://gerrit.libreoffice.org/14053 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/Library_analysis.mk1
-rw-r--r--scaddins/source/analysis/analysis.cxx4
2 files changed, 3 insertions, 2 deletions
diff --git a/scaddins/Library_analysis.mk b/scaddins/Library_analysis.mk
index cafce60604a7..4946c5f74107 100644
--- a/scaddins/Library_analysis.mk
+++ b/scaddins/Library_analysis.mk
@@ -33,6 +33,7 @@ $(eval $(call gb_Library_use_libraries,analysis,\
comphelper \
cppu \
cppuhelper \
+ for \
sal \
tl \
i18nlangtag \
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx
index c0137f372e7d..ddd5c535b99d 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -22,8 +22,8 @@
#include "bessel.hxx"
#include <cppuhelper/factory.hxx>
#include <comphelper/processfactory.hxx>
-#include <comphelper/random.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <formula/random.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx>
@@ -702,7 +702,7 @@ double SAL_CALL AnalysisAddIn::getRandbetween( double fMin, double fMax ) throw(
if( fMin > fMax )
throw lang::IllegalArgumentException();
- double fRet = floor(comphelper::rng::uniform_real_distribution(fMin, boost::math::nextafter(fMax+1, -DBL_MAX)));
+ double fRet = floor(formula::rng::fRandom(fMin, boost::math::nextafter(fMax+1, -DBL_MAX)));
RETURN_FINITE( fRet );
}