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 /svtools/source | |
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 'svtools/source')
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 6 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox2.cxx | 4 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.cxx | 18 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.hxx | 6 | ||||
-rw-r--r-- | svtools/source/control/ctrltool.cxx | 2 | ||||
-rw-r--r-- | svtools/source/control/ruler.cxx | 6 | ||||
-rw-r--r-- | svtools/source/filter/exportdialog.cxx | 4 | ||||
-rw-r--r-- | svtools/source/graphic/grfmgr.cxx | 2 | ||||
-rw-r--r-- | svtools/source/misc/imap.cxx | 42 |
9 files changed, 51 insertions, 39 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index f7374bf91db1..caf2b417cb8a 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -2423,10 +2423,10 @@ long BrowseBox::CalcReverseZoom(long nVal) { if (IsZoom()) { - const boost::rational<long>& rZoom = GetZoom(); + const Fraction& rZoom = GetZoom(); double n = (double)nVal; - n *= (double)rZoom.denominator(); - n /= (double)rZoom.numerator(); + n *= (double)rZoom.GetDenominator(); + n /= (double)rZoom.GetNumerator(); nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5); } diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 4e9e0c671593..64abdb2072e3 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -549,7 +549,7 @@ void BrowseBox::Resize() // resized - which is done in UpdateScrollbars) sal_uLong nSBSize = GetSettings().GetStyleSettings().GetScrollBarSize(); if (IsZoom()) - nSBSize = (sal_uLong)(nSBSize * boost::rational_cast<double>(GetZoom())); + nSBSize = (sal_uLong)(nSBSize * (double)GetZoom()); DoHideCursor( "Resize" ); sal_uInt16 nOldVisibleRows = 0; @@ -1136,7 +1136,7 @@ void BrowseBox::UpdateScrollbars() // the size of the corner window (and the width of the VSB/height of the HSB) sal_uLong nCornerSize = GetSettings().GetStyleSettings().GetScrollBarSize(); if (IsZoom()) - nCornerSize = (sal_uLong)(nCornerSize * boost::rational_cast<double>(GetZoom())); + nCornerSize = (sal_uLong)(nCornerSize * (double)GetZoom()); bool bNeedsVScroll = false; long nMaxRows = 0; diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx index e8ac1d0e6d3b..91bff8b52be8 100644 --- a/svtools/source/brwbox/datwin.cxx +++ b/svtools/source/brwbox/datwin.cxx @@ -104,7 +104,7 @@ void ButtonFrame::Draw( OutputDevice& rDev ) BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, - const OUString& rTitle, sal_uLong nWidthPixel, const boost::rational<long>& rCurrentZoom ) + const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom ) : _nId( nItemId ), _nWidth( nWidthPixel ), _aImage( rImage ), @@ -112,8 +112,8 @@ BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, _bFrozen( false ) { double n = (double)_nWidth; - n *= (double)rCurrentZoom.denominator(); - n /= (double)rCurrentZoom.numerator(); + n *= (double)rCurrentZoom.GetDenominator(); + n /= (double)rCurrentZoom.GetNumerator(); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); } @@ -123,12 +123,12 @@ BrowserColumn::~BrowserColumn() -void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const boost::rational<long>& rCurrentZoom) +void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom) { _nWidth = nNewWidthPixel; double n = (double)_nWidth; - n *= (double)rCurrentZoom.denominator(); - n /= (double)rCurrentZoom.numerator(); + n *= (double)rCurrentZoom.GetDenominator(); + n /= (double)rCurrentZoom.GetNumerator(); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); } @@ -174,11 +174,11 @@ void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos -void BrowserColumn::ZoomChanged(const boost::rational<long>& rNewZoom) +void BrowserColumn::ZoomChanged(const Fraction& rNewZoom) { double n = (double)_nOriginalWidth; - n *= (double)rNewZoom.numerator(); - n /= (double)rNewZoom.denominator(); + n *= (double)rNewZoom.GetNumerator(); + n /= (double)rNewZoom.GetDenominator(); _nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); } diff --git a/svtools/source/brwbox/datwin.hxx b/svtools/source/brwbox/datwin.hxx index 1bbe57a684d9..bff17665e392 100644 --- a/svtools/source/brwbox/datwin.hxx +++ b/svtools/source/brwbox/datwin.hxx @@ -76,7 +76,7 @@ class BrowserColumn public: BrowserColumn( sal_uInt16 nItemId, const Image &rImage, - const OUString& rTitle, sal_uLong nWidthPixel, const boost::rational<long>& rCurrentZoom ); + const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom ); virtual ~BrowserColumn(); sal_uInt16 GetId() const { return _nId; } @@ -91,8 +91,8 @@ public: virtual void Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, bool bCurs ); - void SetWidth(sal_uLong nNewWidthPixel, const boost::rational<long>& rCurrentZoom); - void ZoomChanged(const boost::rational<long>& rNewZoom); + void SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom); + void ZoomChanged(const Fraction& rNewZoom); }; diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx index 587174e88491..4308379d6012 100644 --- a/svtools/source/control/ctrltool.cxx +++ b/svtools/source/control/ctrltool.cxx @@ -737,7 +737,7 @@ const sal_IntPtr* FontList::GetSizeAry( const vcl::FontInfo& rInfo ) const return aStdSizeAry; MapMode aOldMapMode = pDevice->GetMapMode(); - 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 ) ); pDevice->SetMapMode( aMap ); sal_uInt16 i; diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index a85a474293e2..d65754237248 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -256,7 +256,7 @@ void Ruler::ImplInit( WinBits nWinBits ) // Initialize Units mnUnitIndex = RULER_UNIT_CM; meUnit = FUNIT_CM; - maZoom = boost::rational<long>( 1, 1 ); + maZoom = Fraction( 1, 1 ); meSourceUnit = MAP_100TH_MM; // Recalculate border widths @@ -2478,9 +2478,9 @@ void Ruler::SetUnit( FieldUnit eNewUnit ) } } -void Ruler::SetZoom( const boost::rational<long>& rNewZoom ) +void Ruler::SetZoom( const Fraction& rNewZoom ) { - DBG_ASSERT( rNewZoom.numerator(), "Ruler::SetZoom() with scale 0 is not allowed" ); + DBG_ASSERT( rNewZoom.GetNumerator(), "Ruler::SetZoom() with scale 0 is not allowed" ); if ( maZoom != rNewZoom ) { diff --git a/svtools/source/filter/exportdialog.cxx b/svtools/source/filter/exportdialog.cxx index 808a4205d37f..78ee4385a2e4 100644 --- a/svtools/source/filter/exportdialog.cxx +++ b/svtools/source/filter/exportdialog.cxx @@ -1017,7 +1017,7 @@ IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeX) } else { - boost::rational<long> aFract( 1, 100 ); + Fraction aFract( 1, 100 ); sal_Int32 nWidth = mpMfSizeX->GetValue(); sal_Int32 nHeight= static_cast< sal_Int32 >( nWidth * fRatio ); const Size aSource( static_cast< sal_Int32 >( nWidth ), static_cast< sal_Int32 >( nHeight ) ); @@ -1051,7 +1051,7 @@ IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeY) } else { - boost::rational<long> aFract( 1, 100 ); + Fraction aFract( 1, 100 ); sal_Int32 nHeight= mpMfSizeY->GetValue(); sal_Int32 nWidth = static_cast< sal_Int32 >( nHeight * fRatio ); const Size aSource( static_cast< sal_Int32 >( nWidth ), static_cast< sal_Int32 >( nHeight ) ); diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index 69c710991d5b..b83c74a51496 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -887,7 +887,7 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo } else { - aMtf.Scale( boost::rational<long>( rDestSize.Width(), aSrcSize.Width() ), boost::rational<long>( rDestSize.Height(), aSrcSize.Height() ) ); + aMtf.Scale( Fraction( rDestSize.Width(), aSrcSize.Width() ), Fraction( rDestSize.Height(), aSrcSize.Height() ) ); aMtf.SetPrefMapMode( rDestMap ); } diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx index 967724923ed8..705021afe3fb 100644 --- a/svtools/source/misc/imap.cxx +++ b/svtools/source/misc/imap.cxx @@ -35,8 +35,8 @@ #include <boost/scoped_ptr.hpp> -#define SCALEPOINT(aPT,aFracX,aFracY) (aPT).X()=((aPT).X()*(aFracX).numerator())/(aFracX).denominator(); \ - (aPT).Y()=((aPT).Y()*(aFracY).numerator())/(aFracY).denominator(); +#define SCALEPOINT(aPT,aFracX,aFracY) (aPT).X()=((aPT).X()*(aFracX).GetNumerator())/(aFracX).GetDenominator(); \ + (aPT).Y()=((aPT).Y()*(aFracY).GetNumerator())/(aFracY).GetDenominator(); /******************************************************************************/ @@ -226,13 +226,16 @@ Rectangle IMapRectangleObject::GetRectangle( bool bPixelCoords ) const return aNewRect; } -void IMapRectangleObject::Scale( const boost::rational<long>& rFracX, const boost::rational<long>& rFracY ) +void IMapRectangleObject::Scale( const Fraction& rFracX, const Fraction& rFracY ) { Point aTL( aRect.TopLeft() ); Point aBR( aRect.BottomRight() ); - SCALEPOINT( aTL, rFracX, rFracY ); - SCALEPOINT( aBR, rFracX, rFracY ); + if ( rFracX.GetDenominator() && rFracY.GetDenominator() ) + { + SCALEPOINT( aTL, rFracX, rFracY ); + SCALEPOINT( aBR, rFracX, rFracY ); + } aRect = Rectangle( aTL, aBR ); } @@ -368,16 +371,19 @@ Rectangle IMapCircleObject::GetBoundRect() const Size( nWidth, nWidth ) ); } -void IMapCircleObject::Scale( const boost::rational<long>& rFracX, const boost::rational<long>& rFracY ) +void IMapCircleObject::Scale( const Fraction& rFracX, const Fraction& rFracY ) { - boost::rational<long> aAverage( rFracX ); + Fraction aAverage( rFracX ); aAverage += rFracY; - aAverage *= boost::rational<long>( 1, 2 ); + aAverage *= Fraction( 1, 2 ); - SCALEPOINT( aCenter, rFracX, rFracY ); + if ( rFracX.GetDenominator() && rFracY.GetDenominator() ) + { + SCALEPOINT( aCenter, rFracX, rFracY ); + } - nRadius = ( nRadius * aAverage.numerator() ) / aAverage.denominator(); + nRadius = ( nRadius * aAverage.GetNumerator() ) / aAverage.GetDenominator(); } bool IMapCircleObject::IsEqual( const IMapCircleObject& rEqObj ) @@ -487,7 +493,7 @@ void IMapPolygonObject::SetExtraEllipse( const Rectangle& rEllipse ) } } -void IMapPolygonObject::Scale( const boost::rational<long>& rFracX, const boost::rational<long>& rFracY ) +void IMapPolygonObject::Scale( const Fraction& rFracX, const Fraction& rFracY ) { sal_uInt16 nCount = aPoly.GetSize(); @@ -495,7 +501,10 @@ void IMapPolygonObject::Scale( const boost::rational<long>& rFracX, const boost: { Point aScaledPt( aPoly[ i ] ); - SCALEPOINT( aScaledPt, rFracX, rFracY ); + if ( rFracX.GetDenominator() && rFracY.GetDenominator() ) + { + SCALEPOINT( aScaledPt, rFracX, rFracY ); + } aPoly[ i ] = aScaledPt; } @@ -505,8 +514,11 @@ void IMapPolygonObject::Scale( const boost::rational<long>& rFracX, const boost: Point aTL( aEllipse.TopLeft() ); Point aBR( aEllipse.BottomRight() ); - SCALEPOINT( aTL, rFracX, rFracY ); - SCALEPOINT( aBR, rFracX, rFracY ); + if ( rFracX.GetDenominator() && rFracY.GetDenominator() ) + { + SCALEPOINT( aTL, rFracX, rFracY ); + SCALEPOINT( aBR, rFracX, rFracY ); + } aEllipse = Rectangle( aTL, aBR ); } @@ -812,7 +824,7 @@ IMapObject* ImageMap::GetHitIMapObject( const Size& rTotalSize, return( pObj ? ( pObj->IsActive() ? pObj : NULL ) : NULL ); } -void ImageMap::Scale( const boost::rational<long>& rFracX, const boost::rational<long>& rFracY ) +void ImageMap::Scale( const Fraction& rFracX, const Fraction& rFracY ) { size_t nCount = maList.size(); |