summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-07-09 14:48:31 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-07-10 08:58:20 +0100
commit5b2f8231945fedc46425e00f1234dcac90628c1d (patch)
tree7cdee4b82bd29d59292d0a4bd4df4e816317192c /formula
parent315afb12853624bdaac553a8528390c3a61c8351 (diff)
add a SAL_RAND_REPEATABLE for repeatable random nums
merge the formula and comphelper ones together Change-Id: I2e7e2cdb176afc6982e384fa1e007da5b914e6f0
Diffstat (limited to 'formula')
-rw-r--r--formula/Library_for.mk1
-rw-r--r--formula/source/core/api/random.cxx56
2 files changed, 0 insertions, 57 deletions
diff --git a/formula/Library_for.mk b/formula/Library_for.mk
index cbdff466535f..ad7da5af3445 100644
--- a/formula/Library_for.mk
+++ b/formula/Library_for.mk
@@ -42,7 +42,6 @@ $(eval $(call gb_Library_add_exception_objects,for,\
formula/source/core/api/FormulaCompiler \
formula/source/core/api/FormulaOpCodeMapperObj \
formula/source/core/api/grammar \
- formula/source/core/api/random \
formula/source/core/api/services \
formula/source/core/api/token \
formula/source/core/api/vectortoken \
diff --git a/formula/source/core/api/random.cxx b/formula/source/core/api/random.cxx
deleted file mode 100644
index 727262fdffd5..000000000000
--- a/formula/source/core/api/random.cxx
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- 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/.
- */
-
-#include <time.h>
-
-#include <random>
-
-#include <formula/random.hxx>
-#include <rtl/instance.hxx>
-
-namespace {
-
-struct CalcFormulaRandomGenerator
-{
- std::mt19937 aRng;
- CalcFormulaRandomGenerator()
- {
- // initialises the state of this RNG.
- // should only be called once.
- bool bRepeatable = (getenv("SC_RAND_REPEATABLE") != 0);
- aRng.seed(bRepeatable ? 42 : time(NULL));
- }
-};
-
-class theCalcFormulaRandomGenerator : public rtl::Static<CalcFormulaRandomGenerator, theCalcFormulaRandomGenerator> {};
-
-}
-
-namespace formula
-{
-
-namespace rng
-{
-
-double fRandom(double a, double b)
-{
- std::uniform_real_distribution<double> dist(a, b);
- return dist(theCalcFormulaRandomGenerator::get().aRng);
-}
-
-sal_Int32 nRandom(sal_Int32 a, sal_Int32 b)
-{
- std::uniform_int_distribution<sal_Int32> dist(a, b);
- return dist(theCalcFormulaRandomGenerator::get().aRng);
-}
-
-} // rng
-} // formula
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */