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/sdr | |
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/sdr')
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx | 10 | ||||
-rw-r--r-- | svx/source/sdr/properties/attributeproperties.cxx | 2 | ||||
-rw-r--r-- | svx/source/sdr/properties/defaultproperties.cxx | 2 | ||||
-rw-r--r-- | svx/source/sdr/properties/itemsettools.cxx | 11 | ||||
-rw-r--r-- | svx/source/sdr/properties/properties.cxx | 2 |
5 files changed, 11 insertions, 16 deletions
diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index 096da89be126..a87b44850ca0 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -279,9 +279,9 @@ namespace sdr { namespace contact { ::basegfx::B2DVector aZoom( 1, 1 ); if ( pWindow ) { - const Fraction& rZoom( pWindow->GetZoom() ); - aZoom.setX( (double)rZoom ); - aZoom.setY( (double)rZoom ); + const boost::rational<long>& rZoom( pWindow->GetZoom() ); + aZoom.setX( boost::rational_cast<double>(rZoom) ); + aZoom.setY( boost::rational_cast<double>(rZoom) ); } return aZoom; } @@ -867,8 +867,8 @@ namespace sdr { namespace contact { ::basegfx::B2DHomMatrix aScaleNormalization; MapMode aCurrentDeviceMapMode( rPageViewDevice.GetMapMode() ); - aScaleNormalization.set( 0, 0, (double)aCurrentDeviceMapMode.GetScaleX() ); - aScaleNormalization.set( 1, 1, (double)aCurrentDeviceMapMode.GetScaleY() ); + aScaleNormalization.set( 0, 0, boost::rational_cast<double>(aCurrentDeviceMapMode.GetScaleX()) ); + aScaleNormalization.set( 1, 1, boost::rational_cast<double>(aCurrentDeviceMapMode.GetScaleY()) ); m_aZoomLevelNormalization *= aScaleNormalization; #if OSL_DEBUG_LEVEL > 1 diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx index 78c6895208f0..21738416f926 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -318,7 +318,7 @@ namespace sdr MapUnit aOldUnit(pOldModel->GetScaleUnit()); MapUnit aNewUnit(pNewModel->GetScaleUnit()); bool bScaleUnitChanged(aNewUnit != aOldUnit); - Fraction aMetricFactor; + boost::rational<long> aMetricFactor; if(bScaleUnitChanged) { diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx index c6f09bd5bb7f..08ff3d349397 100644 --- a/svx/source/sdr/properties/defaultproperties.cxx +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -211,7 +211,7 @@ namespace sdr { } - void DefaultProperties::Scale(const Fraction& rScale) + void DefaultProperties::Scale(const boost::rational<long>& rScale) { if(mpItemSet) { diff --git a/svx/source/sdr/properties/itemsettools.cxx b/svx/source/sdr/properties/itemsettools.cxx index 835f23552c64..e7826272fa2f 100644 --- a/svx/source/sdr/properties/itemsettools.cxx +++ b/svx/source/sdr/properties/itemsettools.cxx @@ -93,15 +93,10 @@ namespace sdr { namespace properties { - void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale) + void ScaleItemSet(SfxItemSet& rSet, const boost::rational<long>& rScale) { - sal_Int32 nMul(rScale.GetNumerator()); - sal_Int32 nDiv(rScale.GetDenominator()); - - if(!rScale.IsValid() || !nDiv) - { - return; - } + sal_Int32 nMul(rScale.numerator()); + sal_Int32 nDiv(rScale.denominator()); SfxWhichIter aIter(rSet); sal_uInt16 nWhich(aIter.FirstWhich()); diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx index 16af145d4946..5865948e405f 100644 --- a/svx/source/sdr/properties/properties.cxx +++ b/svx/source/sdr/properties/properties.cxx @@ -74,7 +74,7 @@ namespace sdr ClearObjectItem(nWhich); } - void BaseProperties::Scale(const Fraction& /*rScale*/) + void BaseProperties::Scale(const boost::rational<long>& /*rScale*/) { // default implementation does nothing; overload where // an ItemSet is implemented. |