diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-03 17:12:23 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-06 14:13:27 +0100 |
commit | 8f436d3de7e99268a8862664d2cb2574231c3b18 (patch) | |
tree | 0a07dd3cecbd7bc5b0293006bb8691e33c5cca75 /drawinglayer | |
parent | e5ab3685550cf35c3eb9cb47530044f2d86433d5 (diff) |
use comphelper::rng::uniform_*_distribution everywhere
and automatically seed from time on first use
coverity#1242393 Don't call rand
coverity#1242404 Don't call rand
coverity#1242410 Don't call rand and additionally allow 0xFF as a value
coverity#1242409 Don't call rand
coverity#1242399 Don't call rand
coverity#1242372 Don't call rand
coverity#1242377 Don't call rand
coverity#1242378 Don't call rand
coverity#1242379 Don't call rand
coverity#1242382 Don't call rand
coverity#1242383 Don't call rand
coverity#1242402 Don't call rand
coverity#1242397 Don't call rand
coverity#1242390 Don't call rand
coverity#1242389 Don't call rand
coverity#1242388 Don't call rand
coverity#1242386 Don't call rand
coverity#1242384 Don't call rand
coverity#1242394 Don't call rand
Change-Id: I241feab9cb370e091fd6ccaba2af941eb95bc7cf
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/polygonprimitive2d.cxx | 16 | ||||
-rw-r--r-- | drawinglayer/source/texture/texture.cxx | 9 |
2 files changed, 15 insertions, 10 deletions
diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index 79a5e9e10c54..4a2944be5bb0 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -25,9 +25,9 @@ #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <basegfx/polygon/b2dlinegeometry.hxx> +#include <boost/math/special_functions/next.hpp> #include <com/sun/star/drawing/LineCap.hpp> - - +#include <comphelper/random.hxx> using namespace com::sun::star; @@ -212,10 +212,16 @@ namespace drawinglayer } // end of namespace primitive2d } // end of namespace drawinglayer - - namespace drawinglayer { + namespace tools + { + double getRandomColorRange() + { + return comphelper::rng::uniform_real_distribution(0.0, boost::math::nextafter(1.0, DBL_MAX)); + } + } + namespace primitive2d { Primitive2DSequence PolygonStrokePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const @@ -271,7 +277,7 @@ namespace drawinglayer const basegfx::B2DPolyPolygon aNewPolyPolygon(aAreaPolyPolygon.getB2DPolygon(b)); static bool bTestByUsingRandomColor(false); const basegfx::BColor aColor(bTestByUsingRandomColor - ? basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0) + ? basegfx::BColor(tools::getRandomColorRange(), tools::getRandomColorRange(), tools::getRandomColorRange()) : getLineAttribute().getColor()); const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(aNewPolyPolygon, aColor)); aRetval[b] = xRef; diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index e1f8f92a3a5a..89953e624395 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -18,12 +18,11 @@ */ #include <drawinglayer/texture/texture.hxx> +#include <drawinglayer/tools/converters.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/tools/gradienttools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> - - namespace drawinglayer { namespace texture @@ -45,9 +44,9 @@ namespace drawinglayer void GeoTexSvx::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { // base implementation creates random color (for testing only, may also be pure virtual) - rBColor.setRed((rand() & 0x7fff) / 32767.0); - rBColor.setGreen((rand() & 0x7fff) / 32767.0); - rBColor.setBlue((rand() & 0x7fff) / 32767.0); + rBColor.setRed(tools::getRandomColorRange()); + rBColor.setGreen(tools::getRandomColorRange()); + rBColor.setBlue(tools::getRandomColorRange()); } void GeoTexSvx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const |