diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-10-23 17:41:47 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-10-23 18:34:39 +0200 |
commit | 31af61ea091cc895b893c849f2130aa35792b7db (patch) | |
tree | 6c7b63c5b538034bd5d356c5a8667b7e95d59b9c /vcl | |
parent | e92c0d6f9b7a6251e00dc55219a203a7e53c96e2 (diff) |
Fraction: Revert "fdo#81356: convert Fraction to boost::rational<long> - wip"
This reverts commit 47a2d7642d249d70b5da0c330a73f3a0032e4bba.
Conflicts:
cui/source/tabpages/transfrm.cxx
svx/source/svdraw/svdedtv1.cxx
svx/source/svdraw/svdibrow.cxx
sw/source/filter/ww1/w1filter.cxx
tools/source/generic/rational.cxx
Change-Id: I4849916f5f277a4afef0e279b0135c76b36b9d15
Diffstat (limited to 'vcl')
25 files changed, 175 insertions, 148 deletions
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index d34c5d1a9d27..c4eea0fe3c37 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -22,7 +22,7 @@ #include <prex.h> #include <postx.h> -#include <tools/rational.hxx> +#include <tools/fract.hxx> #include <vcl/salgtype.hxx> #include <vcl/vclenum.hxx> diff --git a/vcl/inc/window.h b/vcl/inc/window.h index b6ffa3d41640..53d077f200e8 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -231,7 +231,7 @@ public: void* mpUserData; vcl::Cursor* mpCursor; Pointer maPointer; - boost::rational<long> maZoom; + Fraction maZoom; OUString maText; vcl::Font* mpControlFont; Color maControlForeground; diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 1bad8034d929..79be1aadf326 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -860,7 +860,7 @@ static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& r MapMode aMap( MAP_100TH_INCH ); sal_Int32 nDPI = rConfigItem.ReadInt32( "Resolution", 75 ); - boost::rational<long> aFrac( 1, std::min( std::max( nDPI, sal_Int32( 75 ) ), sal_Int32( 600 ) ) ); + Fraction aFrac( 1, std::min( std::max( nDPI, sal_Int32( 75 ) ), sal_Int32( 600 ) ) ); aMap.SetScaleX( aFrac ); aMap.SetScaleY( aFrac ); @@ -900,8 +900,8 @@ static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& r if( aNewSize.Width() && aNewSize.Height() ) { const Size aPreferredSize( aMtf.GetPrefSize() ); - aMtf.Scale( boost::rational<long>( aNewSize.Width(), aPreferredSize.Width() ), - boost::rational<long>( aNewSize.Height(), aPreferredSize.Height() ) ); + aMtf.Scale( Fraction( aNewSize.Width(), aPreferredSize.Width() ), + Fraction( aNewSize.Height(), aPreferredSize.Height() ) ); } aGraphic = Graphic( aMtf ); } diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 9f552e96a953..a2bf39b7a58a 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -336,8 +336,8 @@ bool GraphicDescriptor::ImpDetectJPG( SvStream& rStm, bool bExtendedInfo ) { MapMode aMap; aMap.SetMapUnit( nUnits == 1 ? MAP_INCH : MAP_CM ); - aMap.SetScaleX( boost::rational<long>( 1, nHorizontalResolution ) ); - aMap.SetScaleY( boost::rational<long>( 1, nVerticalResolution ) ); + aMap.SetScaleX( Fraction( 1, nHorizontalResolution ) ); + aMap.SetScaleY( Fraction( 1, nVerticalResolution ) ); aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, MapMode( MAP_100TH_MM ) ); } } @@ -489,7 +489,7 @@ bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm, bool bExtendedInfo ) // set logical size MapMode aMap( MAP_INCH, Point(), - boost::rational<long>( 1, nDPIx ), boost::rational<long>( 1, nDPIy ) ); + Fraction( 1, nDPIx ), Fraction( 1, nDPIy ) ); aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, MapMode( MAP_100TH_MM ) ); diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index 5d4c0479e1cf..08fdf1dfd328 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -258,8 +258,8 @@ unsigned char * JPEGReader::CreateBitmap( JPEGCreateBitmapParam * pParam ) if( ( ( 1 == nUnit ) || ( 2 == nUnit ) ) && pParam->X_density && pParam->Y_density ) { Point aEmptyPoint; - boost::rational<long> aFractX( 1, pParam->X_density ); - boost::rational<long> aFractY( 1, pParam->Y_density ); + Fraction aFractX( 1, pParam->X_density ); + Fraction aFractY( 1, pParam->Y_density ); MapMode aMapMode( nUnit == 1 ? MAP_INCH : MAP_CM, aEmptyPoint, aFractX, aFractY ); Size aPrefSize = OutputDevice::LogicToLogic( aSize, aMapMode, MAP_100TH_MM ); diff --git a/vcl/source/filter/sgfbram.cxx b/vcl/source/filter/sgfbram.cxx index ac119cae625b..733b9c01b47a 100644 --- a/vcl/source/filter/sgfbram.cxx +++ b/vcl/source/filter/sgfbram.cxx @@ -447,7 +447,7 @@ bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMt rMtf.Stop(); rMtf.WindStart(); MapMode aMap( MAP_10TH_MM, Point(), - boost::rational<long>( 1, 4 ), boost::rational<long>( 1, 4 ) ); + Fraction( 1, 4 ), Fraction( 1, 4 ) ); rMtf.SetPrefMapMode( aMap ); rMtf.SetPrefSize( Size( (short)rHead.Xsize, (short)rHead.Ysize ) ); return true; diff --git a/vcl/source/filter/sgvmain.cxx b/vcl/source/filter/sgvmain.cxx index 089573a36e17..33219b626f99 100644 --- a/vcl/source/filter/sgvmain.cxx +++ b/vcl/source/filter/sgvmain.cxx @@ -830,7 +830,7 @@ bool SgfFilterSDrw( SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf ) rMtf.Stop(); rMtf.WindStart(); - MapMode aMap(MAP_10TH_MM,Point(),boost::rational<long>(1,4),boost::rational<long>(1,4)); + MapMode aMap(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4)); rMtf.SetPrefMapMode(aMap); rMtf.SetPrefSize(Size((sal_Int16)aPage.Paper.Size.x,(sal_Int16)aPage.Paper.Size.y)); bRet=true; diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx index 7cbf6bf9732f..e8c31aaae39c 100644 --- a/vcl/source/filter/sgvtext.cxx +++ b/vcl/source/filter/sgvtext.cxx @@ -688,7 +688,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType& sal_uInt16 i,j,k,h; sal_uInt16 re,li; - vOut.SetMapMode(MapMode(MAP_10TH_MM,Point(),boost::rational<long>(1,4),boost::rational<long>(1,4))); + vOut.SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4))); nChars=0; SetTextContext(vOut,AktAtr,false,0,1,1,1,1); diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 579ca89f20ee..b9c34fca7ff1 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -1252,8 +1252,8 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) MapMode aMapMode( aSubstitute.GetPrefMapMode() ); Size aOutSize( OutputDevice::LogicToLogic( pA->GetSize(), maVDev.GetMapMode(), aMapMode ) ); - aMapMode.SetScaleX( boost::rational<long>( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) ); - aMapMode.SetScaleY( boost::rational<long>( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) ); + aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) ); + aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) ); aMapMode.SetOrigin( OutputDevice::LogicToLogic( pA->GetPoint(), maVDev.GetMapMode(), aMapMode ) ); maVDev.SetMapMode( aMapMode ); ImplWrite( aSubstitute ); diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx index 1aa01fef966b..03596c477f75 100644 --- a/vcl/source/filter/wmf/winmtf.cxx +++ b/vcl/source/filter/wmf/winmtf.cxx @@ -1510,8 +1510,8 @@ void WinMtfOutput::ImplDrawBitmap( const Point& rPos, const Size& rSize, const B const Size aSizePixel( rBitmap.GetSizePixel() ); if ( aOutputSizePixel.Width() && aOutputSizePixel.Height() ) { - aMapMode.SetScaleX( boost::rational<long>( aSizePixel.Width(), aOutputSizePixel.Width() ) ); - aMapMode.SetScaleY( boost::rational<long>( aSizePixel.Height(), aOutputSizePixel.Height() ) ); + aMapMode.SetScaleX( Fraction( aSizePixel.Width(), aOutputSizePixel.Width() ) ); + aMapMode.SetScaleY( Fraction( aSizePixel.Height(), aOutputSizePixel.Height() ) ); } aVDev.SetMapMode( aMapMode ); aVDev.SetOutputSizePixel( aSizePixel ); diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx index eac50c044ba2..819d9c203ac3 100644 --- a/vcl/source/filter/wmf/winwmf.cxx +++ b/vcl/source/filter/wmf/winwmf.cxx @@ -1236,7 +1236,7 @@ bool WMFReader::ReadHeader() Size aDevExt( 10000, 10000 ); if( ( labs( aWMFSize.Width() ) > 1 ) && ( labs( aWMFSize.Height() ) > 1 ) ) { - const boost::rational<long> aFrac( 1, nUnitsPerInch ); + const Fraction aFrac( 1, nUnitsPerInch ); MapMode aWMFMap( MAP_INCH, Point(), aFrac, aFrac ); Size aSize100( OutputDevice::LogicToLogic( aWMFSize, aWMFMap, MAP_100TH_MM ) ); aDevExt = Size( labs( aSize100.Width() ), labs( aSize100.Height() ) ); diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 95473f08f08c..fbfb5caf5d2d 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -1401,37 +1401,37 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) if( pA->GetMapMode().GetMapUnit() == MAP_RELATIVE ) { MapMode aMM = pA->GetMapMode(); - boost::rational<long> aScaleX = aMM.GetScaleX(); - boost::rational<long> aScaleY = aMM.GetScaleY(); + Fraction aScaleX = aMM.GetScaleX(); + Fraction aScaleY = aMM.GetScaleY(); Point aOrigin = aSrcMapMode.GetOrigin(); BigInt aX( aOrigin.X() ); - aX *= BigInt( aScaleX.denominator() ); + aX *= BigInt( aScaleX.GetDenominator() ); if( aOrigin.X() >= 0 ) - if( aScaleX.numerator() >= 0 ) - aX += BigInt( aScaleX.numerator()/2 ); + if( aScaleX.GetNumerator() >= 0 ) + aX += BigInt( aScaleX.GetNumerator()/2 ); else - aX -= BigInt( (aScaleX.numerator()+1)/2 ); + aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); else - if( aScaleX.numerator() >= 0 ) - aX -= BigInt( (aScaleX.numerator()-1)/2 ); + if( aScaleX.GetNumerator() >= 0 ) + aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); else - aX += BigInt( aScaleX.numerator()/2 ); - aX /= BigInt( aScaleX.numerator() ); + aX += BigInt( aScaleX.GetNumerator()/2 ); + aX /= BigInt( aScaleX.GetNumerator() ); aOrigin.X() = (long)aX + aMM.GetOrigin().X(); BigInt aY( aOrigin.Y() ); - aY *= BigInt( aScaleY.denominator() ); + aY *= BigInt( aScaleY.GetDenominator() ); if( aOrigin.Y() >= 0 ) - if( aScaleY.numerator() >= 0 ) - aY += BigInt( aScaleY.numerator()/2 ); + if( aScaleY.GetNumerator() >= 0 ) + aY += BigInt( aScaleY.GetNumerator()/2 ); else - aY -= BigInt( (aScaleY.numerator()+1)/2 ); + aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); else - if( aScaleY.numerator() >= 0 ) - aY -= BigInt( (aScaleY.numerator()-1)/2 ); + if( aScaleY.GetNumerator() >= 0 ) + aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); else - aY += BigInt( aScaleY.numerator()/2 ); - aY /= BigInt( aScaleY.numerator() ); + aY += BigInt( aScaleY.GetNumerator()/2 ); + aY /= BigInt( aScaleY.GetNumerator() ); aOrigin.Y() = (long)aY + aMM.GetOrigin().Y(); aSrcMapMode.SetOrigin( aOrigin ); @@ -1740,7 +1740,7 @@ bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream, aTargetMapMode = MapMode( MAP_INCH ); const long nUnit = pVirDev->LogicToPixel( Size( 1, 1 ), aTargetMapMode ).Width(); - const boost::rational<long> aFrac( 1, nUnit ); + const Fraction aFrac( 1, nUnit ); aTargetMapMode.SetScaleX( aFrac ); aTargetMapMode.SetScaleY( aFrac ); @@ -1824,14 +1824,14 @@ bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream, sal_uInt16 WMFWriter::CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize) { - boost::rational<long> aDivFrac(2, 1); + Fraction aDivFrac(2, 1); sal_uInt16 nDivisor = 1; Size aSize = OutputDevice::LogicToLogic( rPrefSize, aSrcMapMode, rMapMode ); while( nDivisor <= 64 && (aSize.Width() > 32767 || aSize.Height() > 32767) ) { - boost::rational<long> aFrac = rMapMode.GetScaleX(); + Fraction aFrac = rMapMode.GetScaleX(); aFrac *= aDivFrac; rMapMode.SetScaleX(aFrac); diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 3d95cc97d59d..9e560776da1c 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -139,17 +139,17 @@ void ImplReadMapMode( SvStream& rIStm, MapMode& rMapMode ) rIStm.ReadInt16( nUnit ); ReadPair( rIStm, aOrg ); rIStm.ReadInt32( nXNum ).ReadInt32( nXDenom ).ReadInt32( nYNum ).ReadInt32( nYDenom ); - rMapMode = MapMode( (MapUnit) nUnit, aOrg, boost::rational<long>( nXNum, nXDenom ), boost::rational<long>( nYNum, nYDenom ) ); + rMapMode = MapMode( (MapUnit) nUnit, aOrg, Fraction( nXNum, nXDenom ), Fraction( nYNum, nYDenom ) ); } void ImplWriteMapMode( SvStream& rOStm, const MapMode& rMapMode ) { rOStm.WriteInt16( rMapMode.GetMapUnit() ); WritePair( rOStm, rMapMode.GetOrigin() ); - rOStm.WriteInt32( rMapMode.GetScaleX().numerator() ); - rOStm.WriteInt32( rMapMode.GetScaleX().denominator() ); - rOStm.WriteInt32( rMapMode.GetScaleY().numerator() ); - rOStm.WriteInt32( rMapMode.GetScaleY().denominator() ); + rOStm.WriteInt32( rMapMode.GetScaleX().GetNumerator() ); + rOStm.WriteInt32( rMapMode.GetScaleX().GetDenominator() ); + rOStm.WriteInt32( rMapMode.GetScaleY().GetNumerator() ); + rOStm.WriteInt32( rMapMode.GetScaleY().GetDenominator() ); } void ImplWritePushAction( SvStream& rOStm ) diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index 2e503ed7dc6b..a37d5c21e3a0 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -766,8 +766,8 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, Bitmap* pBmpAlpha, sal_uLon MapMode aMapMode( MAP_MM, Point(), - boost::rational<long>(1000, aHeader.nXPelsPerMeter), - boost::rational<long>(1000, aHeader.nYPelsPerMeter)); + Fraction(1000, aHeader.nXPelsPerMeter), + Fraction(1000, aHeader.nYPelsPerMeter)); aNewBmp.SetPrefMapMode(aMapMode); aNewBmp.SetPrefSize(Size(aHeader.nWidth, aHeader.nHeight)); diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 9144800e627c..a767f8553e71 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -550,8 +550,8 @@ void GDIMetaFile::Play( OutputDevice* pOut, const Point& rPos, if( !aTmpPrefSize.Height() ) aTmpPrefSize.Height() = aDestSize.Height(); - boost::rational<long> aScaleX( aDestSize.Width(), aTmpPrefSize.Width() ); - boost::rational<long> aScaleY( aDestSize.Height(), aTmpPrefSize.Height() ); + Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() ); + Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() ); aScaleX *= aDrawMap.GetScaleX(); aDrawMap.SetScaleX( aScaleX ); aScaleY *= aDrawMap.GetScaleY(); aDrawMap.SetScaleY( aScaleY ); @@ -784,8 +784,8 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) { aOffset = aMapVDev.LogicToPixel( aBaseOffset, GetPrefMapMode() ); MapMode aMap( aMapVDev.GetMapMode() ); - aOffset.Width() = static_cast<long>(aOffset.Width() * boost::rational_cast<double>(aMap.GetScaleX())); - aOffset.Height() = static_cast<long>(aOffset.Height() * boost::rational_cast<double>(aMap.GetScaleY())); + aOffset.Width() = static_cast<long>(aOffset.Width() * (double)aMap.GetScaleX()); + aOffset.Height() = static_cast<long>(aOffset.Height() * (double)aMap.GetScaleY()); } else aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev.GetMapMode() ); @@ -816,9 +816,9 @@ void GDIMetaFile::Scale( double fScaleX, double fScaleY ) aPrefSize.Height() = FRound( aPrefSize.Height() * fScaleY ); } -void GDIMetaFile::Scale( const boost::rational<long>& rScaleX, const boost::rational<long>& rScaleY ) +void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY ) { - Scale( boost::rational_cast<double>(rScaleX), boost::rational_cast<double>(rScaleY) ); + Scale( (double) rScaleX, (double) rScaleY ); } void GDIMetaFile::Clip( const Rectangle& i_rClipRect ) diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 9ec9a2887728..d48432941f0c 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1039,8 +1039,8 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm, bool bSwap ) aSize = Size( nWidth, nHeight ); aMapMode = MapMode( (MapUnit) nMapMode, Point( nOffsX, nOffsY ), - boost::rational<long>( nScaleNumX, nScaleDenomX ), - boost::rational<long>( nScaleNumY, nScaleDenomY ) ); + Fraction( nScaleNumX, nScaleDenomX ), + Fraction( nScaleNumY, nScaleDenomY ) ); } nHeaderLen = rIStm.Tell() - nStartPos; @@ -1246,10 +1246,10 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm ) rOStm.WriteInt32( aSize.Width() ); rOStm.WriteInt32( aSize.Height() ); rOStm.WriteInt32( aMapMode.GetMapUnit() ); - rOStm.WriteInt32( aMapMode.GetScaleX().numerator() ); - rOStm.WriteInt32( aMapMode.GetScaleX().denominator() ); - rOStm.WriteInt32( aMapMode.GetScaleY().numerator() ); - rOStm.WriteInt32( aMapMode.GetScaleY().denominator() ); + rOStm.WriteInt32( aMapMode.GetScaleX().GetNumerator() ); + rOStm.WriteInt32( aMapMode.GetScaleX().GetDenominator() ); + rOStm.WriteInt32( aMapMode.GetScaleY().GetNumerator() ); + rOStm.WriteInt32( aMapMode.GetScaleY().GetDenominator() ); rOStm.WriteInt32( aMapMode.GetOrigin().X() ); rOStm.WriteInt32( aMapMode.GetOrigin().Y() ); } diff --git a/vcl/source/gdi/mapmod.cxx b/vcl/source/gdi/mapmod.cxx index 2ac95ed54b11..992898e0164e 100644 --- a/vcl/source/gdi/mapmod.cxx +++ b/vcl/source/gdi/mapmod.cxx @@ -80,7 +80,7 @@ ImplMapMode* ImplMapMode::ImplGetStaticMapMode( MapUnit eUnit ) ImplMapMode* pImplMapMode = ((ImplMapMode*)aStaticImplMapModeAry)+eUnit; if ( !pImplMapMode->mbSimple ) { - boost::rational<long> aDefFraction( 1, 1 ); + Fraction aDefFraction( 1, 1 ); pImplMapMode->maScaleX = aDefFraction; pImplMapMode->maScaleY = aDefFraction; pImplMapMode->meUnit = eUnit; @@ -125,7 +125,7 @@ MapMode::MapMode( MapUnit eUnit ) } MapMode::MapMode( MapUnit eUnit, const Point& rLogicOrg, - const boost::rational<long>& rScaleX, const boost::rational<long>& rScaleY ) + const Fraction& rScaleX, const Fraction& rScaleY ) { mpImplMapMode = new ImplMapMode; @@ -163,14 +163,14 @@ void MapMode::SetOrigin( const Point& rLogicOrg ) mpImplMapMode->maOrigin = rLogicOrg; } -void MapMode::SetScaleX( const boost::rational<long>& rScaleX ) +void MapMode::SetScaleX( const Fraction& rScaleX ) { ImplMakeUnique(); mpImplMapMode->maScaleX = rScaleX; } -void MapMode::SetScaleY( const boost::rational<long>& rScaleY ) +void MapMode::SetScaleY( const Fraction& rScaleY ) { ImplMakeUnique(); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 450177671fc5..172eac9f97b3 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1705,7 +1705,7 @@ void PDFWriterImpl::PDFPage::appendWaveLine( sal_Int32 nWidth, sal_Int32 nY, sal PDFWriter& i_rOuterFace) : m_pReferenceDevice( NULL ), - m_aMapMode( MAP_POINT, Point(), boost::rational<long>( 1L, pointToPixel(1) ), boost::rational<long>( 1L, pointToPixel(1) ) ), + m_aMapMode( MAP_POINT, Point(), Fraction( 1L, pointToPixel(1) ), Fraction( 1L, pointToPixel(1) ) ), m_nCurrentStructElement( 0 ), m_bEmitStructure( true ), m_bNewMCID( false ), @@ -7465,7 +7465,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool // if the mapmode is distorted we need to adjust for that also if( m_aCurrentPDFState.m_aMapMode.GetScaleX() != m_aCurrentPDFState.m_aMapMode.GetScaleY() ) { - fXScale *= boost::rational_cast<double>(m_aCurrentPDFState.m_aMapMode.GetScaleX()) / boost::rational_cast<double>(m_aCurrentPDFState.m_aMapMode.GetScaleY()); + fXScale *= double(m_aCurrentPDFState.m_aMapMode.GetScaleX()) / double(m_aCurrentPDFState.m_aMapMode.GetScaleY()); } int nAngle = m_aCurrentPDFState.m_aFont.GetOrientation(); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index a43e61245e52..3c0aaf7f76b5 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -497,8 +497,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa MapMode aMapMode( aSubstitute.GetPrefMapMode() ); Size aOutSize( OutputDevice::LogicToLogic( pA->GetSize(), pDummyVDev->GetMapMode(), aMapMode ) ); - aMapMode.SetScaleX( boost::rational<long>( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) ); - aMapMode.SetScaleY( boost::rational<long>( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) ); + aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) ); + aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) ); aMapMode.SetOrigin( OutputDevice::LogicToLogic( pA->GetPoint(), pDummyVDev->GetMapMode(), aMapMode ) ); m_rOuterFace.SetMapMode( aMapMode ); diff --git a/vcl/source/gdi/textlayout.cxx b/vcl/source/gdi/textlayout.cxx index 0d584eb1a8b3..59e36687f046 100644 --- a/vcl/source/gdi/textlayout.cxx +++ b/vcl/source/gdi/textlayout.cxx @@ -103,7 +103,7 @@ namespace vcl OutputDevice& m_rTargetDevice; OutputDevice& m_rReferenceDevice; Font m_aUnzoomedPointFont; - const boost::rational<long> m_aZoom; + const Fraction m_aZoom; const bool m_bRTLEnabled; Rectangle m_aCompleteTextRect; diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index a8ef0925bab1..b9a8b2bdb20f 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -451,7 +451,7 @@ bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase ) } bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( - const Size& rNewSize, const boost::rational<long>& rScale, const Point& rNewOffset, + const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer, const bool bTopDown ) { if (pBuffer) { diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index f6af60cc6476..b5cbb0e09f0a 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -122,7 +122,7 @@ Size OutputDevice::GetDevFontSize( const vcl::Font& rFont, int nSizeIndex ) cons if ( mbMap ) { aSize.Height() *= 10; - MapMode aMap( MAP_10TH_INCH, Point(), boost::rational<long>( 1, 72 ), boost::rational<long>( 1, 72 ) ); + MapMode aMap( MAP_10TH_INCH, Point(), Fraction( 1, 72 ), Fraction( 1, 72 ) ); aSize = PixelToLogic( aSize, aMap ); aSize.Height() += 5; aSize.Height() /= 10; diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 9de77a74bb23..125b8e33345b 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -43,14 +43,41 @@ Reduces accuracy until it is a fraction (should become ctor fraction once); we could also do this with BigInts */ -static boost::rational<long> ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 ) +static Fraction ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 ) { - if( nD1 == 0 || nD2 == 0 ) + long i = 1; + + if ( nN1 < 0 ) { i = -i; nN1 = -nN1; } + if ( nN2 < 0 ) { i = -i; nN2 = -nN2; } + if ( nD1 < 0 ) { i = -i; nD1 = -nD1; } + if ( nD2 < 0 ) { i = -i; nD2 = -nD2; } + // all positive; i sign + + Fraction aF( i*nN1, nD1 ); + aF *= Fraction( nN2, nD2 ); + + if( nD1 == 0 || nD2 == 0 ) //under these bad circumstances the following while loop will be endless { DBG_ASSERT(false,"Invalid parameter for ImplMakeFraction"); - return boost::rational<long>( 1, 1 ); + return Fraction( 1, 1 ); + } + + while ( aF.GetDenominator() == -1 ) + { + if ( nN1 > nN2 ) + nN1 = (nN1 + 1) / 2; + else + nN2 = (nN2 + 1) / 2; + if ( nD1 > nD2 ) + nD1 = (nD1 + 1) / 2; + else + nD2 = (nD2 + 1) / 2; + + aF = Fraction( i*nN1, nD1 ); + aF *= Fraction( nN2, nD2 ); } - return boost::rational<long>( nN1, nD1 ) * boost::rational<long>( nN2, nD2 ); + + return aF; } // Fraction.GetNumerator() @@ -220,8 +247,8 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, break; } - boost::rational<long> aScaleX = rMapMode.GetScaleX(); - boost::rational<long> aScaleY = rMapMode.GetScaleY(); + Fraction aScaleX = rMapMode.GetScaleX(); + Fraction aScaleY = rMapMode.GetScaleY(); // set offset according to MapMode Point aOrigin = rMapMode.GetOrigin(); @@ -234,70 +261,70 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, } else { - rMapRes.mfOffsetX *= aScaleX.denominator(); - rMapRes.mfOffsetX /= aScaleX.numerator(); + rMapRes.mfOffsetX *= aScaleX.GetDenominator(); + rMapRes.mfOffsetX /= aScaleX.GetNumerator(); rMapRes.mfOffsetX += aOrigin.X(); - rMapRes.mfOffsetY *= aScaleY.denominator(); - rMapRes.mfOffsetY /= aScaleY.numerator(); + rMapRes.mfOffsetY *= aScaleY.GetDenominator(); + rMapRes.mfOffsetY /= aScaleY.GetNumerator(); rMapRes.mfOffsetY += aOrigin.Y(); BigInt aX( rMapRes.mnMapOfsX ); - aX *= BigInt( aScaleX.denominator() ); + aX *= BigInt( aScaleX.GetDenominator() ); if ( rMapRes.mnMapOfsX >= 0 ) { - if ( aScaleX.numerator() >= 0 ) - aX += BigInt( aScaleX.numerator()/2 ); + if ( aScaleX.GetNumerator() >= 0 ) + aX += BigInt( aScaleX.GetNumerator()/2 ); else - aX -= BigInt( (aScaleX.numerator()+1)/2 ); + aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); } else { - if ( aScaleX.numerator() >= 0 ) - aX -= BigInt( (aScaleX.numerator()-1)/2 ); + if ( aScaleX.GetNumerator() >= 0 ) + aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); else - aX += BigInt( aScaleX.numerator()/2 ); + aX += BigInt( aScaleX.GetNumerator()/2 ); } - aX /= BigInt( aScaleX.numerator() ); + aX /= BigInt( aScaleX.GetNumerator() ); rMapRes.mnMapOfsX = (long)aX + aOrigin.X(); BigInt aY( rMapRes.mnMapOfsY ); - aY *= BigInt( aScaleY.denominator() ); + aY *= BigInt( aScaleY.GetDenominator() ); if( rMapRes.mnMapOfsY >= 0 ) { - if ( aScaleY.numerator() >= 0 ) - aY += BigInt( aScaleY.numerator()/2 ); + if ( aScaleY.GetNumerator() >= 0 ) + aY += BigInt( aScaleY.GetNumerator()/2 ); else - aY -= BigInt( (aScaleY.numerator()+1)/2 ); + aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); } else { - if ( aScaleY.numerator() >= 0 ) - aY -= BigInt( (aScaleY.numerator()-1)/2 ); + if ( aScaleY.GetNumerator() >= 0 ) + aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); else - aY += BigInt( aScaleY.numerator()/2 ); + aY += BigInt( aScaleY.GetNumerator()/2 ); } - aY /= BigInt( aScaleY.numerator() ); + aY /= BigInt( aScaleY.GetNumerator() ); rMapRes.mnMapOfsY = (long)aY + aOrigin.Y(); } - rMapRes.mfScaleX *= (double)rMapRes.mnMapScNumX * (double)aScaleX.numerator() / - ((double)rMapRes.mnMapScDenomX * (double)aScaleX.denominator()); - rMapRes.mfScaleY *= (double)rMapRes.mnMapScNumY * (double)aScaleY.numerator() / - ((double)rMapRes.mnMapScDenomY * (double)aScaleY.denominator()); + rMapRes.mfScaleX *= (double)rMapRes.mnMapScNumX * (double)aScaleX.GetNumerator() / + ((double)rMapRes.mnMapScDenomX * (double)aScaleX.GetDenominator()); + rMapRes.mfScaleY *= (double)rMapRes.mnMapScNumY * (double)aScaleY.GetNumerator() / + ((double)rMapRes.mnMapScDenomY * (double)aScaleY.GetDenominator()); // calculate scaling factor according to MapMode // aTemp? = rMapRes.mnMapSc? * aScale? - boost::rational<long> aTempX = ImplMakeFraction( rMapRes.mnMapScNumX, - aScaleX.numerator(), + Fraction aTempX = ImplMakeFraction( rMapRes.mnMapScNumX, + aScaleX.GetNumerator(), rMapRes.mnMapScDenomX, - aScaleX.denominator() ); - boost::rational<long> aTempY = ImplMakeFraction( rMapRes.mnMapScNumY, - aScaleY.numerator(), + aScaleX.GetDenominator() ); + Fraction aTempY = ImplMakeFraction( rMapRes.mnMapScNumY, + aScaleY.GetNumerator(), rMapRes.mnMapScDenomY, - aScaleY.denominator() ); - rMapRes.mnMapScNumX = aTempX.numerator(); - rMapRes.mnMapScDenomX = aTempX.denominator(); - rMapRes.mnMapScNumY = aTempY.numerator(); - rMapRes.mnMapScDenomY = aTempY.denominator(); + aScaleY.GetDenominator() ); + rMapRes.mnMapScNumX = aTempX.GetNumerator(); + rMapRes.mnMapScDenomX = aTempX.GetDenominator(); + rMapRes.mnMapScNumY = aTempY.GetNumerator(); + rMapRes.mnMapScDenomY = aTempY.GetDenominator(); // hack: 0/n approximately 1/max if ( !rMapRes.mnMapScNumX ) @@ -739,14 +766,14 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) { Point aOrigin( maMapRes.mnMapOfsX, maMapRes.mnMapOfsY ); // aScale? = maMapMode.GetScale?() * rNewMapMode.GetScale?() - boost::rational<long> aScaleX = ImplMakeFraction( maMapMode.GetScaleX().numerator(), - rNewMapMode.GetScaleX().numerator(), - maMapMode.GetScaleX().denominator(), - rNewMapMode.GetScaleX().denominator() ); - boost::rational<long> aScaleY = ImplMakeFraction( maMapMode.GetScaleY().numerator(), - rNewMapMode.GetScaleY().numerator(), - maMapMode.GetScaleY().denominator(), - rNewMapMode.GetScaleY().denominator() ); + Fraction aScaleX = ImplMakeFraction( maMapMode.GetScaleX().GetNumerator(), + rNewMapMode.GetScaleX().GetNumerator(), + maMapMode.GetScaleX().GetDenominator(), + rNewMapMode.GetScaleX().GetDenominator() ); + Fraction aScaleY = ImplMakeFraction( maMapMode.GetScaleY().GetNumerator(), + rNewMapMode.GetScaleY().GetNumerator(), + maMapMode.GetScaleY().GetDenominator(), + rNewMapMode.GetScaleY().GetDenominator() ); maMapMode.SetOrigin( aOrigin ); maMapMode.SetScaleX( aScaleX ); maMapMode.SetScaleY( aScaleY ); @@ -785,14 +812,14 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode ) MapUnit eNew = rNewMapMode.GetMapUnit(); // a?F = rNewMapMode.GetScale?() / maMapMode.GetScale?() - boost::rational<long> aXF = ImplMakeFraction( rNewMapMode.GetScaleX().numerator(), - maMapMode.GetScaleX().denominator(), - rNewMapMode.GetScaleX().denominator(), - maMapMode.GetScaleX().numerator() ); - boost::rational<long> aYF = ImplMakeFraction( rNewMapMode.GetScaleY().numerator(), - maMapMode.GetScaleY().denominator(), - rNewMapMode.GetScaleY().denominator(), - maMapMode.GetScaleY().numerator() ); + Fraction aXF = ImplMakeFraction( rNewMapMode.GetScaleX().GetNumerator(), + maMapMode.GetScaleX().GetDenominator(), + rNewMapMode.GetScaleX().GetDenominator(), + maMapMode.GetScaleX().GetNumerator() ); + Fraction aYF = ImplMakeFraction( rNewMapMode.GetScaleY().GetNumerator(), + maMapMode.GetScaleY().GetDenominator(), + rNewMapMode.GetScaleY().GetDenominator(), + maMapMode.GetScaleY().GetNumerator() ); Point aPt( LogicToLogic( Point(), NULL, &rNewMapMode ) ); if ( eNew != eOld ) @@ -807,23 +834,23 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode ) } else { - boost::rational<long> aF( aImplNumeratorAry[eNew] * aImplDenominatorAry[eOld], + Fraction aF( aImplNumeratorAry[eNew] * aImplDenominatorAry[eOld], aImplNumeratorAry[eOld] * aImplDenominatorAry[eNew] ); // a?F = a?F * aF - aXF = ImplMakeFraction( aXF.numerator(), aF.numerator(), - aXF.denominator(), aF.denominator() ); - aYF = ImplMakeFraction( aYF.numerator(), aF.numerator(), - aYF.denominator(), aF.denominator() ); + aXF = ImplMakeFraction( aXF.GetNumerator(), aF.GetNumerator(), + aXF.GetDenominator(), aF.GetDenominator() ); + aYF = ImplMakeFraction( aYF.GetNumerator(), aF.GetNumerator(), + aYF.GetDenominator(), aF.GetDenominator() ); if ( eOld == MAP_PIXEL ) { - aXF *= boost::rational<long>( mnDPIX, 1 ); - aYF *= boost::rational<long>( mnDPIY, 1 ); + aXF *= Fraction( mnDPIX, 1 ); + aYF *= Fraction( mnDPIY, 1 ); } else if ( eNew == MAP_PIXEL ) { - aXF *= boost::rational<long>( 1, mnDPIX ); - aYF *= boost::rational<long>( 1, mnDPIY ); + aXF *= Fraction( 1, mnDPIX ); + aYF *= Fraction( 1, mnDPIY ); } } } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 9577581af9fc..e03f98937ffc 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -572,7 +572,7 @@ Window::~Window() WindowImpl::WindowImpl( WindowType nType ) { - maZoom = boost::rational<long>( 1, 1 ); + maZoom = Fraction( 1, 1 ); maWinRegion = vcl::Region(true); maWinClipRegion = vcl::Region(true); mpWinData = NULL; // Extra Window Data, that we dont need for all windows diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index bf09d53b4e94..fec025132a36 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -507,7 +507,7 @@ bool Window::EndSaveFocus( sal_uIntPtr nSaveId, bool bRestore ) } } -void Window::SetZoom( const boost::rational<long>& rZoom ) +void Window::SetZoom( const Fraction& rZoom ) { if ( mpWindowImpl->maZoom != rZoom ) { @@ -523,18 +523,18 @@ inline long WinFloatRound( double fVal ) void Window::SetZoomedPointFont( const vcl::Font& rFont ) { - const boost::rational<long>& rZoom = GetZoom(); - if ( rZoom.numerator() != rZoom.denominator() ) + const Fraction& rZoom = GetZoom(); + if ( rZoom.GetNumerator() != rZoom.GetDenominator() ) { vcl::Font aFont( rFont ); Size aSize = aFont.GetSize(); double n = (double)aSize.Width(); - n *= (double)rZoom.numerator(); - n /= (double)rZoom.denominator(); + n *= (double)rZoom.GetNumerator(); + n /= (double)rZoom.GetDenominator(); aSize.Width() = WinFloatRound( n ); n = (double)aSize.Height(); - n *= (double)rZoom.numerator(); - n /= (double)rZoom.denominator(); + n *= (double)rZoom.GetNumerator(); + n /= (double)rZoom.GetDenominator(); aSize.Height() = WinFloatRound( n ); aFont.SetSize( aSize ); SetPointFont( aFont ); @@ -562,12 +562,12 @@ void Window::SetZoomedPointFont( const vcl::Font& rFont ) long Window::CalcZoom( long nCalc ) const { - const boost::rational<long>& rZoom = GetZoom(); - if ( rZoom.numerator() != rZoom.denominator() ) + const Fraction& rZoom = GetZoom(); + if ( rZoom.GetNumerator() != rZoom.GetDenominator() ) { double n = (double)nCalc; - n *= (double)rZoom.numerator(); - n /= (double)rZoom.denominator(); + n *= (double)rZoom.GetNumerator(); + n /= (double)rZoom.GetDenominator(); nCalc = WinFloatRound( n ); } return nCalc; @@ -1318,14 +1318,14 @@ vcl::Cursor* Window::GetCursor() const return mpWindowImpl->mpCursor; } -const boost::rational<long>& Window::GetZoom() const +const Fraction& Window::GetZoom() const { return mpWindowImpl->maZoom; } bool Window::IsZoom() const { - return mpWindowImpl->maZoom.numerator() != mpWindowImpl->maZoom.denominator(); + return mpWindowImpl->maZoom.GetNumerator() != mpWindowImpl->maZoom.GetDenominator(); } void Window::SetHelpText( const OUString& rHelpText ) |