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 --- include/vcl/gdimtf.hxx | 2 +- include/vcl/mapmod.hxx | 16 ++++++++-------- include/vcl/virdev.hxx | 2 +- include/vcl/window.hxx | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'include/vcl') diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx index 5a80213a7550..128895fc0675 100644 --- a/include/vcl/gdimtf.hxx +++ b/include/vcl/gdimtf.hxx @@ -136,7 +136,7 @@ public: // additional Move method getting specifics how to handle MapMode( MAP_PIXEL ) void Move( long nX, long nY, long nDPIX, long nDPIY ); void Scale( double fScaleX, double fScaleY ); - void Scale( const Fraction& rScaleX, const Fraction& rScaleY ); + void Scale( const boost::rational& rScaleX, const boost::rational& rScaleY ); void Rotate( long nAngle10 ); void Clip( const Rectangle& ); /* get the bound rect of the contained actions diff --git a/include/vcl/mapmod.hxx b/include/vcl/mapmod.hxx index 10e06d2e9ca3..211727f39660 100644 --- a/include/vcl/mapmod.hxx +++ b/include/vcl/mapmod.hxx @@ -21,7 +21,7 @@ #define INCLUDED_VCL_MAPMOD_HXX #include -#include +#include #include #include #include @@ -44,8 +44,8 @@ private: sal_uLong mnRefCount; MapUnit meUnit; Point maOrigin; - Fraction maScaleX; - Fraction maScaleY; + boost::rational maScaleX; + boost::rational maScaleY; bool mbSimple; friend SvStream& ReadImplMapMode( SvStream& rIStm, ImplMapMode& rMapMode ); @@ -75,7 +75,7 @@ public: MapMode( const MapMode& rMapMode ); MapMode( MapUnit eUnit ); MapMode( MapUnit eUnit, const Point& rLogicOrg, - const Fraction& rScaleX, const Fraction& rScaleY ); + const boost::rational& rScaleX, const boost::rational& rScaleY ); ~MapMode(); void SetMapUnit( MapUnit eUnit ); @@ -86,11 +86,11 @@ public: const Point& GetOrigin() const { return mpImplMapMode->maOrigin; } - void SetScaleX( const Fraction& rScaleX ); - const Fraction& GetScaleX() const + void SetScaleX( const boost::rational& rScaleX ); + const boost::rational& GetScaleX() const { return mpImplMapMode->maScaleX; } - void SetScaleY( const Fraction& rScaleY ); - const Fraction& GetScaleY() const + void SetScaleY( const boost::rational& rScaleY ); + const boost::rational& GetScaleY() const { return mpImplMapMode->maScaleY; } MapMode& operator=( const MapMode& rMapMode ); diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index 624cb2f0f31a..4886410bd2aa 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -124,7 +124,7 @@ public: bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true ); bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, - const Fraction& rScale, + const boost::rational& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer, const bool bTopDown = false ); diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index decc15c1c88e..14c23bdfbcff 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1009,8 +1009,8 @@ public: void SetCursor( vcl::Cursor* pCursor ); vcl::Cursor* GetCursor() const; - void SetZoom( const Fraction& rZoom ); - const Fraction& GetZoom() const; + void SetZoom( const boost::rational& rZoom ); + const boost::rational& GetZoom() const; bool IsZoom() const; long CalcZoom( long n ) const; -- cgit