From 47a2d7642d249d70b5da0c330a73f3a0032e4bba Mon Sep 17 00:00:00 2001 From: Juan Picca Date: Fri, 19 Sep 2014 14:19:30 -0300 Subject: fdo#81356: convert Fraction to boost::rational - wip * Added rational util functions used by Fraction class not available in the boost::rational class. * Replaced usage of Fraction by boost::rational * Removed code that relies on: 1. fraction.IsValid() -- rational only allow valid values, ie denominator() != 0 2. rational.denominator() == 0 -- always false 3. rational.denominator() < 0 -- always false but implementation detail: http://www.boost.org/doc/libs/release/libs/rational/rational.html#Internal%20representation * Simplified code that relies on: 1. rational.denominator() != 0 -- always true * BUGS EXIST because Fraction allows the creation of invalid values but boost::rational throws the exception boost::bad_rational Change-Id: I84970a4956afb3f91ac0c8f726547466319420f9 Reviewed-on: https://gerrit.libreoffice.org/11551 Reviewed-by: David Tardon Tested-by: David Tardon --- drawinglayer/source/primitive2d/metafileprimitive2d.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drawinglayer') diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index b546ede49a1b..f51099bc4c67 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -573,7 +573,7 @@ namespace basegfx::B2DHomMatrix getTransformFromMapMode(const MapMode& rMapMode) { basegfx::B2DHomMatrix aMapping; - const Fraction aNoScale(1, 1); + const boost::rational aNoScale(1, 1); const Point& rOrigin(rMapMode.GetOrigin()); if(0 != rOrigin.X() || 0 != rOrigin.Y()) @@ -584,8 +584,8 @@ namespace if(rMapMode.GetScaleX() != aNoScale || rMapMode.GetScaleY() != aNoScale) { aMapping.scale( - double(rMapMode.GetScaleX()), - double(rMapMode.GetScaleY())); + boost::rational_cast(rMapMode.GetScaleX()), + boost::rational_cast(rMapMode.GetScaleY())); } return aMapping; -- cgit