summaryrefslogtreecommitdiff
path: root/svx/source/customshapes
diff options
context:
space:
mode:
authorJuan Picca <jumapico@gmail.com>2014-09-19 14:19:30 -0300
committerDavid Tardon <dtardon@redhat.com>2014-10-09 11:33:33 +0000
commit47a2d7642d249d70b5da0c330a73f3a0032e4bba (patch)
tree202b04810382ea87cf8015a7b4de29e931408948 /svx/source/customshapes
parentae77dc81c33ab0817264bcf5fc8bb71a55b78a73 (diff)
fdo#81356: convert Fraction to boost::rational<long> - wip
* Added rational util functions used by Fraction class not available in the boost::rational class. * Replaced usage of Fraction by boost::rational<long> * 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 <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'svx/source/customshapes')
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.cxx8
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx12
2 files changed, 10 insertions, 10 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index 92967399c1da..0a810de128d1 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -262,11 +262,11 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
if ( pModel )
{
fMap = 1.0;
- Fraction aFraction( pModel->GetScaleFraction() );
- if ( ( aFraction.GetNumerator() ) != 1 || ( aFraction.GetDenominator() != 1 ) )
+ boost::rational<long> aFraction( pModel->GetScaleFraction() );
+ if ( ( aFraction.numerator() ) != 1 || ( aFraction.denominator() != 1 ) )
{
- fMap *= aFraction.GetNumerator();
- fMap /= aFraction.GetDenominator();
+ fMap *= aFraction.numerator();
+ fMap /= aFraction.denominator();
pMap = &fMap;
}
if ( pModel->GetScaleUnit() != MAP_100TH_MM )
diff --git a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx
index 4f546e1b1c0c..661af54f66e8 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx
@@ -19,7 +19,7 @@
#include "svx/EnhancedCustomShape2d.hxx"
#include <rtl/ustring.hxx>
-#include <tools/fract.hxx>
+#include <tools/rational.hxx>
// Makes parser a static resource,
// we're synchronized externally.
@@ -116,19 +116,19 @@ public:
virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /* pOptionalArg */, sal_uInt32 /* nFlags */ ) SAL_OVERRIDE
{
EnhancedCustomShapeParameter aRet;
- Fraction aFract( maValue );
- if ( aFract.GetDenominator() == 1 )
+ boost::rational<long> aFract( maValue );
+ if ( aFract.denominator() == 1 )
{
aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
- aRet.Value <<= (sal_Int32)aFract.GetNumerator();
+ aRet.Value <<= (sal_Int32)aFract.numerator();
}
else
{
EnhancedCustomShapeEquation aEquation;
aEquation.nOperation = 1;
aEquation.nPara[ 0 ] = 1;
- aEquation.nPara[ 1 ] = (sal_Int16)aFract.GetNumerator();
- aEquation.nPara[ 2 ] = (sal_Int16)aFract.GetDenominator();
+ aEquation.nPara[ 1 ] = (sal_Int16)aFract.numerator();
+ aEquation.nPara[ 2 ] = (sal_Int16)aFract.denominator();
aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
aRet.Value <<= (sal_Int32)rEquations.size();
rEquations.push_back( aEquation );