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 /basctl | |
parent | ae77dc81c33ab0817264bcf5fc8bb71a55b78a73 (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 'basctl')
-rw-r--r-- | basctl/source/dlged/dlged.cxx | 4 | ||||
-rw-r--r-- | basctl/source/dlged/dlgedobj.cxx | 4 | ||||
-rw-r--r-- | basctl/source/inc/dlgedobj.hxx | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 9800c4c5d2bf..5d8373a0815e 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -234,7 +234,7 @@ DlgEditor::DlgEditor ( pDlgEdView->SetWorkArea( Rectangle( Point( 0, 0 ), pDlgEdPage->GetSize() ) ); pDlgEdView->SetGridCoarse( aGridSize ); - pDlgEdView->SetSnapGridWidth(Fraction(aGridSize.Width(), 1), Fraction(aGridSize.Height(), 1)); + pDlgEdView->SetSnapGridWidth(boost::rational<long>(aGridSize.Width(),1), boost::rational<long>(aGridSize.Height(),1)); pDlgEdView->SetGridSnap( bGridSnap ); pDlgEdView->SetGridVisible( bGridVisible ); pDlgEdView->SetDragStripes(false); @@ -508,7 +508,7 @@ IMPL_LINK_NOARG(DlgEditor, PaintTimeout) Size aSize = rWindow.PixelToLogic( Size( 400, 300 ) ); // align with grid - Size aGridSize_(long(pDlgEdView->GetSnapGridWidthX()), long(pDlgEdView->GetSnapGridWidthY())); + Size aGridSize_(boost::rational_cast<long>(pDlgEdView->GetSnapGridWidthX()), boost::rational_cast<long>(pDlgEdView->GetSnapGridWidthY())); aSize.Width() -= aSize.Width() % aGridSize_.Width(); aSize.Height() -= aSize.Height() % aGridSize_.Height(); diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 4d52b5f1b5ad..89a0207989d8 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -940,7 +940,7 @@ void DlgEdObj::NbcMove( const Size& rSize ) GetDlgEdForm()->GetDlgEditor().SetDialogModelChanged(true); } -void DlgEdObj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract) +void DlgEdObj::NbcResize(const Point& rRef, const boost::rational<long>& xFract, const boost::rational<long>& yFract) { SdrUnoObj::NbcResize( rRef, xFract, yFract ); @@ -1590,7 +1590,7 @@ void DlgEdForm::NbcMove( const Size& rSize ) GetDlgEditor().SetDialogModelChanged(true); } -void DlgEdForm::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract) +void DlgEdForm::NbcResize(const Point& rRef, const boost::rational<long>& xFract, const boost::rational<long>& yFract) { SdrUnoObj::NbcResize( rRef, xFract, yFract ); diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx index 525a5518f271..33e489ff06e1 100644 --- a/basctl/source/inc/dlgedobj.hxx +++ b/basctl/source/inc/dlgedobj.hxx @@ -63,7 +63,7 @@ protected: const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac); virtual void NbcMove( const Size& rSize ) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE; using SfxListener::StartListening; @@ -153,7 +153,7 @@ private: protected: virtual void NbcMove( const Size& rSize ) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE; public: |