diff options
author | Juan Picca <jumapico@gmail.com> | 2014-09-19 14:19:30 -0300 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-10-09 11:33:33 +0000 |
commit | 47a2d7642d249d70b5da0c330a73f3a0032e4bba (patch) | |
tree | 202b04810382ea87cf8015a7b4de29e931408948 /sc/source/ui/view/drawutil.cxx | |
parent | fdo#75757: remove inheritance to std::vector (diff) | |
download | core-47a2d7642d249d70b5da0c330a73f3a0032e4bba.tar.gz core-47a2d7642d249d70b5da0c330a73f3a0032e4bba.zip |
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 'sc/source/ui/view/drawutil.cxx')
-rw-r--r-- | sc/source/ui/view/drawutil.cxx | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx index 668337aac0da..21840f50ffaf 100644 --- a/sc/source/ui/view/drawutil.cxx +++ b/sc/source/ui/view/drawutil.cxx @@ -27,9 +27,9 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, OutputDevice* pDev, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, double nPPTX, double nPPTY, - Fraction& rScaleX, Fraction& rScaleY ) + boost::rational<long>& rScaleX, boost::rational<long>& rScaleY ) { long nPixelX = 0; long nTwipsX = 0; @@ -63,27 +63,27 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab, // because ReduceInaccurate is called later anyway. if ( aPixelLog.X() && nTwipsX ) - rScaleX = Fraction( ((double)aPixelLog.X()) * - ((double)rZoomX.GetNumerator()) / + rScaleX = rational_FromDouble( ((double)aPixelLog.X()) * + ((double)rZoomX.numerator()) / ((double)nTwipsX) / ((double)HMM_PER_TWIPS) / - ((double)rZoomX.GetDenominator()) ); + ((double)rZoomX.denominator()) ); else - rScaleX = Fraction( 1, 1 ); + rScaleX = boost::rational<long>( 1, 1 ); if ( aPixelLog.Y() && nTwipsY ) - rScaleY = Fraction( ((double)aPixelLog.Y()) * - ((double)rZoomY.GetNumerator()) / + rScaleY = rational_FromDouble( ((double)aPixelLog.Y()) * + ((double)rZoomY.numerator()) / ((double)nTwipsY) / ((double)HMM_PER_TWIPS) / - ((double)rZoomY.GetDenominator()) ); + ((double)rZoomY.denominator()) ); else - rScaleY = Fraction( 1, 1 ); + rScaleY = boost::rational<long>( 1, 1 ); // 25 bits of accuracy are needed to always hit the right part of // cells in the last rows (was 17 before 1M rows). - rScaleX.ReduceInaccurate( 25 ); - rScaleY.ReduceInaccurate( 25 ); + rational_ReduceInaccurate(rScaleX, 25); + rational_ReduceInaccurate(rScaleY, 25); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |