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 --- svx/source/svdraw/svdotxtr.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'svx/source/svdraw/svdotxtr.cxx') diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index e4da47df32eb..b627d591fbed 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -48,7 +48,7 @@ void SdrTextObj::NbcSetSnapRect(const Rectangle& rRect) long nHgt0=aSR0.Bottom()-aSR0.Top(); long nWdt1=rRect.Right()-rRect.Left(); long nHgt1=rRect.Bottom()-rRect.Top(); - SdrTextObj::NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); + SdrTextObj::NbcResize(maSnapRect.TopLeft(),boost::rational(nWdt1,nWdt0),boost::rational(nHgt1,nHgt0)); SdrTextObj::NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top())); } else { long nHDist=GetTextLeftDistance()+GetTextRightDistance(); @@ -118,7 +118,7 @@ void SdrTextObj::NbcMove(const Size& rSiz) SetRectsDirty(true); } -void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrTextObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) { bool bNoShearMerk=aGeo.nShearWink==0; bool bRota90Merk=bNoShearMerk && aGeo.nDrehWink % 9000 ==0; @@ -126,8 +126,8 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0; long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0; - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); + bool bXMirr = xFact.numerator() < 0; + bool bYMirr = yFact.numerator() < 0; if (bXMirr || bYMirr) { Point aRef1(GetSnapRect().Center()); if (bXMirr) { -- cgit