summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/writerhelper.cxx
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 /sw/source/filter/ww8/writerhelper.cxx
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 'sw/source/filter/ww8/writerhelper.cxx')
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx18
1 files changed, 9 insertions, 9 deletions
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 0fc558f546b1..aa0362d2191a 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -666,9 +666,9 @@ namespace sw
{
Polygon aPoly(PolygonFromPolyPolygon(rPolyPoly));
const Size &rOrigSize = pNd->GetGraphic().GetPrefSize();
- Fraction aMapPolyX(ww::nWrap100Percent, rOrigSize.Width());
- Fraction aMapPolyY(ww::nWrap100Percent, rOrigSize.Height());
- aPoly.Scale(aMapPolyX, aMapPolyY);
+ boost::rational<long> aMapPolyX(ww::nWrap100Percent, rOrigSize.Width());
+ boost::rational<long> aMapPolyY(ww::nWrap100Percent, rOrigSize.Height());
+ aPoly.Scale(boost::rational_cast<double>(aMapPolyX), boost::rational_cast<double>(aMapPolyY));
/*
a) stretch right bound by 15twips
@@ -678,15 +678,15 @@ namespace sw
See the import for details
*/
const Size &rSize = pNd->GetTwipSize();
- Fraction aMoveHack(ww::nWrap100Percent, rSize.Width());
- aMoveHack *= Fraction(15, 1);
- long nMove(aMoveHack);
+ boost::rational<long> aMoveHack(ww::nWrap100Percent, rSize.Width());
+ aMoveHack *= boost::rational<long>(15, 1);
+ long nMove(boost::rational_cast<long>(aMoveHack));
- Fraction aHackX(ww::nWrap100Percent + nMove,
+ boost::rational<long> aHackX(ww::nWrap100Percent + nMove,
ww::nWrap100Percent);
- Fraction aHackY(ww::nWrap100Percent - nMove,
+ boost::rational<long> aHackY(ww::nWrap100Percent - nMove,
ww::nWrap100Percent);
- aPoly.Scale(aHackX, aHackY);
+ aPoly.Scale(boost::rational_cast<double>(aHackX), boost::rational_cast<double>(aHackY));
aPoly.Move(-nMove, 0);
return aPoly;