summaryrefslogtreecommitdiff
path: root/filter/source/msfilter
diff options
context:
space:
mode:
authorJuan Picca <jumapico@gmail.com>2014-09-19 14:19:30 -0300
committerDavid Tardon <dtardon@redhat.com>2014-10-09 11:33:33 +0000
commit47a2d7642d249d70b5da0c330a73f3a0032e4bba (patch)
tree202b04810382ea87cf8015a7b4de29e931408948 /filter/source/msfilter
parentae77dc81c33ab0817264bcf5fc8bb71a55b78a73 (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 'filter/source/msfilter')
-rw-r--r--filter/source/msfilter/eschesdo.cxx2
-rw-r--r--filter/source/msfilter/msdffimp.cxx44
-rw-r--r--filter/source/msfilter/svdfppt.cxx6
3 files changed, 26 insertions, 26 deletions
diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx
index 2e9227042eb7..0c2b757284a3 100644
--- a/filter/source/msfilter/eschesdo.cxx
+++ b/filter/source/msfilter/eschesdo.cxx
@@ -64,7 +64,7 @@ ImplEESdrWriter::ImplEESdrWriter( EscherEx& rEx )
: mpEscherEx(&rEx)
, maMapModeSrc(MAP_100TH_MM)
// PowerPoint: 576 dpi, WinWord: 1440 dpi, Excel: 1440 dpi
- , maMapModeDest( MAP_INCH, Point(), Fraction( 1, EES_MAP_FRACTION ), Fraction( 1, EES_MAP_FRACTION ) )
+ , maMapModeDest( MAP_INCH, Point(), boost::rational<long>( 1, EES_MAP_FRACTION ), boost::rational<long>( 1, EES_MAP_FRACTION ) )
, mpPicStrm(NULL)
, mpHostAppData(NULL)
, mnPagesWritten(0)
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 1fe026ce0fed..26db18f9b0f1 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -170,9 +170,9 @@ void Impl_OlePres::Write( SvStream & rStm )
{
// Always to 1/100 mm, until Mtf-Solution found
// Assumption (no scaling, no origin translation)
- DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleX() == Fraction( 1, 1 ),
+ DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleX() == boost::rational<long>( 1, 1 ),
"X-Skalierung im Mtf" );
- DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleY() == Fraction( 1, 1 ),
+ DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleY() == boost::rational<long>( 1, 1 ),
"Y-Skalierung im Mtf" );
DBG_ASSERT( pMtf->GetPrefMapMode().GetOrigin() == Point(),
"Origin-Verschiebung im Mtf" );
@@ -183,8 +183,8 @@ void Impl_OlePres::Write( SvStream & rStm )
Size aS( aPrefS );
aS = OutputDevice::LogicToLogic( aS, nMU, MAP_100TH_MM );
- pMtf->Scale( Fraction( aS.Width(), aPrefS.Width() ),
- Fraction( aS.Height(), aPrefS.Height() ) );
+ pMtf->Scale( boost::rational<long>( aS.Width(), aPrefS.Width() ),
+ boost::rational<long>( aS.Height(), aPrefS.Height() ) );
pMtf->SetPrefMapMode( MAP_100TH_MM );
pMtf->SetPrefSize( aS );
}
@@ -3088,11 +3088,11 @@ void SvxMSDffManager::ScaleEmu( sal_Int32& rVal ) const
sal_uInt32 SvxMSDffManager::ScalePt( sal_uInt32 nVal ) const
{
MapUnit eMap = pSdrModel->GetScaleUnit();
- Fraction aFact( GetMapFactor( MAP_POINT, eMap ).X() );
- long aMul = aFact.GetNumerator();
- long aDiv = aFact.GetDenominator() * 65536;
- aFact = Fraction( aMul, aDiv ); // try again to shorten it
- return BigMulDiv( nVal, aFact.GetNumerator(), aFact.GetDenominator() );
+ boost::rational<long> aFact( GetMapFactor( MAP_POINT, eMap ).X() );
+ long aMul = aFact.numerator();
+ long aDiv = aFact.denominator() * 65536;
+ aFact = boost::rational<long>( aMul, aDiv ); // try again to shorten it
+ return BigMulDiv( nVal, aFact.numerator(), aFact.denominator() );
}
sal_Int32 SvxMSDffManager::ScalePoint( sal_Int32 nVal ) const
@@ -3108,31 +3108,31 @@ void SvxMSDffManager::SetModel(SdrModel* pModel, long nApplicationScale)
// PPT works in units of 576DPI
// WW on the other side uses twips, i.e. 1440DPI.
MapUnit eMap = pSdrModel->GetScaleUnit();
- Fraction aFact( GetMapFactor(MAP_INCH, eMap).X() );
- long nMul=aFact.GetNumerator();
- long nDiv=aFact.GetDenominator()*nApplicationScale;
- aFact=Fraction(nMul,nDiv); // try again to shorten it
+ boost::rational<long> aFact = GetMapFactor(MAP_INCH, eMap).X();
+ long nMul=aFact.numerator();
+ long nDiv=aFact.denominator()*nApplicationScale;
+ aFact=boost::rational<long>(nMul,nDiv); // try again to shorten it
// For 100TH_MM -> 2540/576=635/144
// For Twip -> 1440/576=5/2
- nMapMul = aFact.GetNumerator();
- nMapDiv = aFact.GetDenominator();
+ nMapMul = aFact.numerator();
+ nMapDiv = aFact.denominator();
bNeedMap = nMapMul!=nMapDiv;
// MS-DFF-Properties are mostly given in EMU (English Metric Units)
// 1mm=36000emu, 1twip=635emu
aFact=GetMapFactor(MAP_100TH_MM,eMap).X();
- nMul=aFact.GetNumerator();
- nDiv=aFact.GetDenominator()*360;
- aFact=Fraction(nMul,nDiv); // try again to shorten it
+ nMul=aFact.numerator();
+ nDiv=aFact.denominator()*360;
+ aFact=boost::rational<long>(nMul,nDiv); // try again to shorten it
// For 100TH_MM -> 1/360
// For Twip -> 14,40/(25,4*360)=144/91440=1/635
- nEmuMul=aFact.GetNumerator();
- nEmuDiv=aFact.GetDenominator();
+ nEmuMul=aFact.numerator();
+ nEmuDiv=aFact.denominator();
// And something for typographic Points
aFact=GetMapFactor(MAP_POINT,eMap).X();
- nPntMul=aFact.GetNumerator();
- nPntDiv=aFact.GetDenominator();
+ nPntMul=aFact.numerator();
+ nPntDiv=aFact.denominator();
}
else
{
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index e4c54f028c43..b6300bb03d38 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -2470,9 +2470,9 @@ Size SdrPowerPointImport::GetPageSize() const
long nInchMul = 1, nInchDiv = 1;
if ( bInch )
{ // temporarily convert size (for rounding it) from inch to metric units
- Fraction aFact(GetMapFactor(eMap,MAP_100TH_MM).X());
- nInchMul = aFact.GetNumerator();
- nInchDiv = aFact.GetDenominator();
+ boost::rational<long> aFact = GetMapFactor(eMap,MAP_100TH_MM).X();
+ nInchMul = aFact.numerator();
+ nInchDiv = aFact.denominator();
aRet.Width() = BigMulDiv( aRet.Width(), nInchMul, nInchDiv );
aRet.Height() = BigMulDiv( aRet.Height(), nInchMul, nInchDiv );
}