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 /svx/source/form | |
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 'svx/source/form')
-rw-r--r-- | svx/source/form/fmvwimp.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 653feff1774a..212c9de8123d 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -1450,8 +1450,8 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor const sal_uInt16 nObjID = OBJ_FM_BUTTON; ::Size controlSize(4000, 500); FmFormObj *pControl = static_cast<FmFormObj*>(SdrObjFactory::MakeNewObject( FmFormInventor, nObjID, NULL, NULL )); - controlSize.Width() = Fraction(controlSize.Width(), 1) * eTargetMode.GetScaleX(); - controlSize.Height() = Fraction(controlSize.Height(), 1) * eTargetMode.GetScaleY(); + controlSize.Width() = boost::rational_cast<long>(controlSize.Width() * eTargetMode.GetScaleX()); + controlSize.Height() = boost::rational_cast<long>(controlSize.Height() * eTargetMode.GetScaleY()); ::Point controlPos( OutputDevice::LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) ); ::Rectangle controlRect( controlPos, OutputDevice::LogicToLogic( controlSize, eSourceMode, eTargetMode ) ); pControl->SetLogicRect(controlRect); @@ -1541,8 +1541,8 @@ bool FmXFormView::createControlLabelPair( OutputDevice& _rOutDev, sal_Int32 _nXO aRealSize.Height()= aDefSize.Height(); // adjust to scaling of the target device (#53523#) - aRealSize.Width() = long(Fraction(aRealSize.Width(), 1) * eTargetMode.GetScaleX()); - aRealSize.Height() = long(Fraction(aRealSize.Height(), 1) * eTargetMode.GetScaleY()); + aRealSize.Width() = boost::rational_cast<long>(aRealSize.Width() * eTargetMode.GetScaleX()); + aRealSize.Height() = boost::rational_cast<long>(aRealSize.Height() * eTargetMode.GetScaleY()); // for boolean fields, we do not create a label, but just a checkbox bool bNeedLabel = ( _nControlObjectID != OBJ_FM_CHECKBOX ); @@ -1608,8 +1608,8 @@ bool FmXFormView::createControlLabelPair( OutputDevice& _rOutDev, sal_Int32 _nXO if ( OBJ_FM_IMAGECONTROL == _nControlObjectID ) aControlSize = aDefImageSize; - aControlSize.Width() = long(Fraction(aControlSize.Width(), 1) * eTargetMode.GetScaleX()); - aControlSize.Height() = long(Fraction(aControlSize.Height(), 1) * eTargetMode.GetScaleY()); + aControlSize.Width() = boost::rational_cast<long>(aControlSize.Width() * eTargetMode.GetScaleX()); + aControlSize.Height() = boost::rational_cast<long>(aControlSize.Height() * eTargetMode.GetScaleY()); pControl->SetLogicRect( ::Rectangle( OutputDevice::LogicToLogic( ::Point( aRealSize.Width() + _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ), |