diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-01-20 16:24:14 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-01-21 07:21:19 +0000 |
commit | dad7161cc30b335a108c7850f453877a161969ae (patch) | |
tree | b0b093ffe95b869a94fe3de283e33baff7254c4c /include | |
parent | cd5f69376bf27275d92073943451b8b72a708d04 (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 'include')
-rw-r--r-- | include/formula/random.hxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/formula/random.hxx b/include/formula/random.hxx new file mode 100644 index 000000000000..d5d14f54ced9 --- /dev/null +++ b/include/formula/random.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_FORMULA_RANDOM_HXX +#define INCLUDED_FORMULA_RANDOM_HXX + +#include <formula/formuladllapi.h> + +namespace formula +{ + +namespace rng +{ + +// These two functions obey the SC_RAND_REPEATABLE environment +// variable: If it is set, use a fixed seed. +double FORMULA_DLLPUBLIC fRandom(double a, double b); +sal_Int32 FORMULA_DLLPUBLIC nRandom(sal_Int32 a, sal_Int32 b); + +} // rng +} // formula + +#endif // INCLUDED_FORMULA_RANDOM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |