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 /sw | |
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 'sw')
46 files changed, 181 insertions, 187 deletions
diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx index 29dab399a691..e1a216d7ae3f 100644 --- a/sw/inc/accmap.hxx +++ b/sw/inc/accmap.hxx @@ -25,7 +25,7 @@ #include <osl/mutex.hxx> #include <svx/IAccessibleViewForwarder.hxx> #include <svx/IAccessibleParent.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <svx/AccessibleControlShape.hxx> #include <svx/AccessibleShape.hxx> @@ -140,7 +140,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> GetDocumentPreview( const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ); @@ -249,7 +249,7 @@ public: // update preview data (and fire events if necessary) void UpdatePreview( const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ); diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index 9f5ef1fc3c01..270f95ab18c2 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -279,12 +279,12 @@ class SwDrawVirtObj : public SdrVirtObj virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const SAL_OVERRIDE; virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt16 nPlNum) const; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; virtual void Move(const Size& rSiz) SAL_OVERRIDE; - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; + virtual void Resize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; virtual void Rotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void Mirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 58ab7a802f64..a9a4fc79c6f3 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SW_INC_PAGEDESC_HXX #define INCLUDED_SW_INC_PAGEDESC_HXX -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <tools/color.hxx> #include "swdllapi.h" #include <swtypes.hxx> @@ -46,7 +46,7 @@ class SW_DLLPUBLIC SwPageFtnInfo sal_uLong nLineWidth; ///< width of separator line editeng::SvxBorderStyle eLineStyle; ///< Style of the separator line Color aLineColor; ///< color of the separator line - Fraction aWidth; ///< percentage width of the separator line. + boost::rational<long> aWidth; ///< percentage width of the separator line. SwFtnAdj eAdj; ///< line adjustment. SwTwips nTopDist; ///< distance between body and separator. SwTwips nBottomDist; ///< distance between separator and first footnote @@ -56,7 +56,7 @@ public: sal_uLong GetLineWidth() const { return nLineWidth; } const Color& GetLineColor() const { return aLineColor;} editeng::SvxBorderStyle GetLineStyle() const { return eLineStyle; } - const Fraction& GetWidth() const { return aWidth; } + const boost::rational<long>& GetWidth() const { return aWidth; } SwFtnAdj GetAdj() const { return eAdj; } SwTwips GetTopDist()const { return nTopDist; } SwTwips GetBottomDist() const { return nBottomDist; } @@ -65,7 +65,7 @@ public: void SetLineWidth(sal_uLong nSet ) { nLineWidth = nSet; } void SetLineStyle( editeng::SvxBorderStyle eSet ) { eLineStyle = eSet; } void SetLineColor(const Color& rCol ) { aLineColor = rCol;} - void SetWidth( const Fraction &rNew){ aWidth = rNew; } + void SetWidth( const boost::rational<long> &rNew){ aWidth = rNew; } void SetAdj ( SwFtnAdj eNew ) { eAdj = eNew; } void SetTopDist ( SwTwips nNew ) { nTopDist = nNew; } void SetBottomDist( SwTwips nNew ) { nBottomDist = nNew; } diff --git a/sw/inc/pagepreviewlayout.hxx b/sw/inc/pagepreviewlayout.hxx index 8c01106fd179..90488a1354f7 100644 --- a/sw/inc/pagepreviewlayout.hxx +++ b/sw/inc/pagepreviewlayout.hxx @@ -32,7 +32,7 @@ class SwViewShell; class SwRootFrm; class SwPageFrm; -class Fraction; +namespace boost { template<typename T> class rational; } struct PreviewPage; /** page preview functionality in the writer @@ -396,8 +396,8 @@ public: @return Point, start position for new scale */ - Point GetPreviewStartPosForNewScale( const Fraction& _aNewScale, - const Fraction& _aOldScale, + Point GetPreviewStartPosForNewScale( const boost::rational<long>& _aNewScale, + const boost::rational<long>& _aOldScale, const Size& _aNewWinSize ) const; /** determines, if page with given page number is visible in preview diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index f6c74f92bf27..2516af70c6b2 100644 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -1024,7 +1024,7 @@ #include <tools/diagnose_ex.h> #include <tools/errinf.hxx> #include <tools/fldunit.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <tools/gen.hxx> #include <tools/globname.hxx> #include <tools/helpers.hxx> diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index 64a70c94a67e..63661e303225 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -602,7 +602,7 @@ class SwAccPreviewData Rectangles maLogicRects; SwRect maVisArea; - Fraction maScale; + boost::rational<long> maScale; const SwPageFrm *mpSelPage; @@ -630,7 +630,7 @@ public: void Update( const SwAccessibleMap& rAccMap, const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ); @@ -661,7 +661,7 @@ SwAccPreviewData::~SwAccPreviewData() void SwAccPreviewData::Update( const SwAccessibleMap& rAccMap, const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ) { @@ -1801,7 +1801,7 @@ uno::Reference< XAccessible > SwAccessibleMap::GetDocumentView( ) uno::Reference<XAccessible> SwAccessibleMap::GetDocumentPreview( const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ) { @@ -2964,7 +2964,7 @@ sal_Int32 SwAccessibleMap::GetChildIndex( const SwFrm& rParentFrm, } void SwAccessibleMap::UpdatePreview( const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ) { diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 1ce8a372c978..f7987da558e6 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -25,7 +25,7 @@ #include <editeng/lrspitem.hxx> #include <editeng/protitem.hxx> #include <editeng/boxitem.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <fmtfsize.hxx> #include <fmtornt.hxx> #include <doc.hxx> @@ -3986,10 +3986,10 @@ void SetLineHeight( SwTableLine& rLine, SwTwips nOldHeight, SwTwips nNewHeight, else { // Calculate as exactly as possible - Fraction aTmp( nMyOldH ); - aTmp *= Fraction( nNewHeight, nOldHeight ); - aTmp += Fraction( 1, 2 ); // round up if needed - nMyNewH = aTmp; + boost::rational<long> aTmp( nMyOldH ); + aTmp *= boost::rational<long>( nNewHeight, nOldHeight ); + aTmp += boost::rational<long>( 1, 2 ); // round up if needed + nMyNewH = boost::rational_cast<long>(aTmp); } SwFrmSize eSize = ATT_MIN_SIZE; diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx index 7a325c93cc94..6360b359e319 100644 --- a/sw/source/core/docnode/ndnotxt.cxx +++ b/sw/source/core/docnode/ndnotxt.cxx @@ -125,8 +125,8 @@ const tools::PolyPolygon *SwNoTxtNode::HasContour() const const Size aGrfPrefMapModeSize( GetGraphic().GetPrefSize() ); if ( aGrfMap.GetMapUnit() == MAP_INCH ) { - nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() ); - nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() ); + nGrfDPIx = aGrfPixelSize.Width() / ( boost::rational_cast<double>(aGrfMap.GetScaleX()) * aGrfPrefMapModeSize.Width() ); + nGrfDPIy = aGrfPixelSize.Height() / ( boost::rational_cast<double>(aGrfMap.GetScaleY()) * aGrfPrefMapModeSize.Height() ); } else { diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index d9c9af706e65..b9f1318f648e 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -2372,7 +2372,7 @@ void SwDrawVirtObj::NbcMove(const Size& rSiz) SdrObject::NbcMove( rSiz ); } -void SwDrawVirtObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SwDrawVirtObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { rRefObj.NbcResize(rRef - GetOffset(), xFact, yFact); SetRectsDirty(); @@ -2401,9 +2401,9 @@ void SwDrawVirtObj::Move(const Size& rSiz) SdrObject::Move( rSiz ); } -void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) +void SwDrawVirtObj::Resize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bUnsetRelative) { - if(xFact.GetNumerator() != xFact.GetDenominator() || yFact.GetNumerator() != yFact.GetDenominator()) + if(xFact.numerator() != xFact.denominator() || yFact.numerator() != yFact.denominator()) { Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect(); rRefObj.Resize(rRef - GetOffset(), xFact, yFact, bUnsetRelative); diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index caad92de8c9d..834bc65fc6e3 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -731,7 +731,7 @@ void SwVirtFlyDrawObj::NbcMove(const Size& rSiz) } void SwVirtFlyDrawObj::NbcResize(const Point& rRef, - const Fraction& xFact, const Fraction& yFact) + const boost::rational<long>& xFact, const boost::rational<long>& yFact) { ResizeRect( aOutRect, rRef, xFact, yFact ); @@ -843,7 +843,7 @@ void SwVirtFlyDrawObj::Move(const Size& rSiz) } void SwVirtFlyDrawObj::Resize(const Point& rRef, - const Fraction& xFact, const Fraction& yFact, bool /*bUnsetRelative*/) + const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool /*bUnsetRelative*/) { NbcResize( rRef, xFact, yFact ); SetChanged(); diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 3669a5902734..0cbcb5e97636 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -1389,8 +1389,8 @@ void SwFEShell::Paste( SvStream& rStrm, sal_uInt16 nAction, const Point* pPt ) Rectangle aNewRect( pNewObj->GetCurrentBoundRect() ); Size aNewSize( aNewRect.GetSize() ); - Fraction aScaleWidth( aOldObjSize.Width(), aNewSize.Width() ); - Fraction aScaleHeight( aOldObjSize.Height(), aNewSize.Height()); + boost::rational<long> aScaleWidth( aOldObjSize.Width(), aNewSize.Width() ); + boost::rational<long> aScaleHeight( aOldObjSize.Height(), aNewSize.Height()); pNewObj->NbcResize( aNewRect.TopLeft(), aScaleWidth, aScaleHeight); Point aVec = aOldObjRect.TopLeft() - aNewRect.TopLeft(); diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 280c6d45b7e1..d4cc181943f6 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -812,8 +812,8 @@ void SwGrfNode::ScaleImageMap() return; bool bScale = false; - Fraction aScaleX( 1, 1 ); - Fraction aScaleY( 1, 1 ); + boost::rational<long> aScaleX( 1, 1 ); + boost::rational<long> aScaleY( 1, 1 ); const SwFmtFrmSize& rFrmSize = pFmt->GetFrmSize(); const SvxBoxItem& rBox = pFmt->GetBox(); @@ -829,7 +829,7 @@ void SwGrfNode::ScaleImageMap() if( nGrfSize.Width() != nWidth ) { - aScaleX = Fraction( nGrfSize.Width(), nWidth ); + aScaleX = boost::rational<long>( nGrfSize.Width(), nWidth ); bScale = true; } } @@ -844,7 +844,7 @@ void SwGrfNode::ScaleImageMap() if( nGrfSize.Height() != nHeight ) { - aScaleY = Fraction( nGrfSize.Height(), nHeight ); + aScaleY = boost::rational<long>( nGrfSize.Height(), nHeight ); bScale = true; } } diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index 058e64c13d8e..79e9f37471d7 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -99,11 +99,11 @@ public: virtual void NbcSetLogicRect(const Rectangle& rRect) SAL_OVERRIDE; virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const SAL_OVERRIDE; virtual void NbcMove (const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, - const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, + const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void Move (const Size& rSiz) SAL_OVERRIDE; - virtual void Resize(const Point& rRef, const Fraction& xFact, - const Fraction& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; + virtual void Resize(const Point& rRef, const boost::rational<long>& xFact, + const boost::rational<long>& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; const SwFrmFmt *GetFmt() const; SwFrmFmt *GetFmt(); diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx index 66a652510944..ae86642f8d73 100644 --- a/sw/source/core/inc/viewimp.hxx +++ b/sw/source/core/inc/viewimp.hxx @@ -40,7 +40,7 @@ class SwPageFrm; class SwRegionRects; class SwAccessibleMap; class SdrObject; -class Fraction; +namespace boost { template<typename T> class rational; } class SwPrintData; class SwPagePreviewLayout; struct PreviewPage; @@ -262,7 +262,7 @@ public: /// update data for accessible preview /// change method signature due to new page preview functionality void UpdateAccessiblePreview( const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ); diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 628ed1356d5b..58fa20cac362 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -655,13 +655,14 @@ const SwRect SwAnchoredDrawObject::GetObjBoundRect() const nTargetHeight = aPageRect.GetHeight( ) * GetDrawObj( )->GetRelativeHeight( ).get( ); } - if ( nTargetWidth != aCurrObjRect.GetWidth( ) || nTargetHeight != aCurrObjRect.GetHeight( ) ) + if ( (nTargetWidth != aCurrObjRect.GetWidth( ) || nTargetHeight != aCurrObjRect.GetHeight( )) + && aCurrObjRect.GetWidth() != 0 && aCurrObjRect.GetHeight() != 0 ) { SwDoc* pDoc = const_cast<SwDoc*>(GetPageFrm()->GetFmt()->GetDoc()); bool bModified = pDoc->getIDocumentState().IsModified(); const_cast< SdrObject* >( GetDrawObj() )->Resize( aCurrObjRect.TopLeft(), - Fraction( nTargetWidth, aCurrObjRect.GetWidth() ), - Fraction( nTargetHeight, aCurrObjRect.GetHeight() ), false ); + boost::rational<long>( nTargetWidth, aCurrObjRect.GetWidth() ), + boost::rational<long>( nTargetHeight, aCurrObjRect.GetHeight() ), false ); if (!bModified) pDoc->getIDocumentState().ResetModified(); } diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 40131ecd2fe7..9299a2120abd 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -867,8 +867,8 @@ void SwFlyFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew, if ( rOld.GetWidth() && rOld.GetHeight() ) { - Fraction aScaleX( rOld.GetWidth(), rNew.GetWidth() ); - Fraction aScaleY( rOld.GetHeight(), rOld.GetHeight() ); + boost::rational<long> aScaleX( rOld.GetWidth(), rNew.GetWidth() ); + boost::rational<long> aScaleY( rOld.GetHeight(), rOld.GetHeight() ); aURL.GetMap()->Scale( aScaleX, aScaleY ); SwFrmFmt *pFmt = GetFmt(); pFmt->LockModify(); @@ -994,8 +994,8 @@ void SwFlyFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew, rSz.GetWidth() != Frm().Width() ) { SwFmtURL aURL( GetFmt()->GetURL() ); - Fraction aScaleX( Frm().Width(), rSz.GetWidth() ); - Fraction aScaleY( Frm().Height(), rSz.GetHeight() ); + boost::rational<long> aScaleX( Frm().Width(), rSz.GetWidth() ); + boost::rational<long> aScaleY( Frm().Height(), rSz.GetHeight() ); aURL.GetMap()->Scale( aScaleX, aScaleY ); SwFrmFmt *pFmt = GetFmt(); pFmt->LockModify(); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index be4fc5f80fd3..b2c9f8d0ebea 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -355,8 +355,8 @@ void SwCalcPixStatics( OutputDevice *pOut ) nMinDistPixelH = nPixelSzH * 2 + 1; const MapMode &rMap = pOut->GetMapMode(); - aScaleX = rMap.GetScaleX(); - aScaleY = rMap.GetScaleY(); + aScaleX = boost::rational_cast<double>(rMap.GetScaleX()); + aScaleY = boost::rational_cast<double>(rMap.GetScaleY()); } /** @@ -2960,17 +2960,17 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem ) SwViewShell* pViewShell = mrTabFrm.getRootFrm()->GetCurrShell(); OutputDevice* pOutDev = pViewShell->GetOut(); const MapMode& rMapMode = pOutDev->GetMapMode(); - const Fraction& rFracX = rMapMode.GetScaleX(); - const Fraction& rFracY = rMapMode.GetScaleY(); + const boost::rational<long>& rFracX = rMapMode.GetScaleX(); + const boost::rational<long>& rFracY = rMapMode.GetScaleY(); svx::frame::Style aL(rBoxItem.GetLeft()); - aL.SetPatternScale(rFracY); + aL.SetPatternScale(boost::rational_cast<double>(rFracY)); svx::frame::Style aR(rBoxItem.GetRight()); - aR.SetPatternScale(rFracY); + aR.SetPatternScale(boost::rational_cast<double>(rFracY)); svx::frame::Style aT(rBoxItem.GetTop()); - aT.SetPatternScale(rFracX); + aT.SetPatternScale(boost::rational_cast<double>(rFracX)); svx::frame::Style aB(rBoxItem.GetBottom()); - aB.SetPatternScale(rFracX); + aB.SetPatternScale(boost::rational_cast<double>(rFracX)); aR.MirrorSelf(); aB.MirrorSelf(); @@ -5576,8 +5576,7 @@ void SwFtnContFrm::PaintLine( const SwRect& rRect, SWRECTFN( this ) SwTwips nPrtWidth = (Prt().*fnRect->fnGetWidth)(); - Fraction aFract( nPrtWidth, 1 ); - const SwTwips nWidth = (long)(aFract *= rInf.GetWidth()); + const SwTwips nWidth = boost::rational_cast<long>(long(nPrtWidth) * rInf.GetWidth()); SwTwips nX = (this->*fnRect->fnGetPrtLeft)(); switch ( rInf.GetAdj() ) diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx index 3784cdaad445..1213a06b0f23 100644 --- a/sw/source/core/text/porlay.hxx +++ b/sw/source/core/text/porlay.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_SW_SOURCE_CORE_TEXT_PORLAY_HXX #define INCLUDED_SW_SOURCE_CORE_TEXT_PORLAY_HXX -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <scriptinfo.hxx> #include "swrect.hxx" diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 0e88feb0f1ce..f3b648bc2af0 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -467,12 +467,10 @@ void SwFntObj::CreateScrFont( const SwViewShell& rSh, const OutputDevice& rOut ) // one in the ViewOptions, this Font must not be cached, // hence set zoom factor to an invalid value long nTmp; - if( pOut->GetMapMode().GetScaleX().IsValid() && - pOut->GetMapMode().GetScaleY().IsValid() && - pOut->GetMapMode().GetScaleX() == pOut->GetMapMode().GetScaleY() ) + if( pOut->GetMapMode().GetScaleX() == pOut->GetMapMode().GetScaleY() ) { - nTmp = ( 100 * pOut->GetMapMode().GetScaleX().GetNumerator() ) / - pOut->GetMapMode().GetScaleX().GetDenominator(); + nTmp = ( 100 * pOut->GetMapMode().GetScaleX().numerator() ) / + pOut->GetMapMode().GetScaleX().denominator(); } else nTmp = 0; @@ -1133,7 +1131,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) if ( bDirectPrint ) { - const Fraction aTmp( 1, 1 ); + const boost::rational<long> aTmp( 1, 1 ); bool bStretch = rInf.GetWidth() && ( rInf.GetLen() > 1 ) && bPrt && ( aTmp != rInf.GetOut().GetMapMode().GetScaleX() ); diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx index 3e8004ab1776..4f2307c6e4c7 100644 --- a/sw/source/core/view/pagepreviewlayout.cxx +++ b/sw/source/core/view/pagepreviewlayout.cxx @@ -215,17 +215,17 @@ bool SwPagePreviewLayout::Init( const sal_uInt16 _nCols, // calculate scaling MapMode aMapMode( MAP_TWIP ); Size aWinSize = mrParentViewShell.GetOut()->PixelToLogic( _rPxWinSize, aMapMode ); - Fraction aXScale( aWinSize.Width(), mnPreviewLayoutWidth ); - Fraction aYScale( aWinSize.Height(), mnPreviewLayoutHeight ); + boost::rational<long> aXScale( aWinSize.Width(), mnPreviewLayoutWidth ); + boost::rational<long> aYScale( aWinSize.Height(), mnPreviewLayoutHeight ); if( aXScale < aYScale ) aYScale = aXScale; { // adjust scaling for Drawing layer. - aYScale *= Fraction( 1000, 1 ); - long nNewNuminator = aYScale.operator long(); + aYScale *= boost::rational<long>( 1000, 1 ); + long nNewNuminator = boost::rational_cast<long>(aYScale); if( nNewNuminator < 1 ) nNewNuminator = 1; - aYScale = Fraction( nNewNuminator, 1000 ); + aYScale = boost::rational<long>( nNewNuminator, 1000 ); // propagate scaling as zoom percentage to view options for font cache _ApplyNewZoomAtViewShell( static_cast<sal_uInt8>(nNewNuminator/10) ); } @@ -740,8 +740,8 @@ bool SwPagePreviewLayout::SetBookPreviewMode( const bool _bEnableBookPreview, OD 12.12.2002 #103492# */ Point SwPagePreviewLayout::GetPreviewStartPosForNewScale( - const Fraction& _aNewScale, - const Fraction& _aOldScale, + const boost::rational<long>& _aNewScale, + const boost::rational<long>& _aOldScale, const Size& _aNewWinSize ) const { Point aNewPaintStartPos = maPaintedPreviewDocRect.TopLeft(); diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index ed381b74d6a9..68725dbbda18 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -70,8 +70,8 @@ void SwViewImp::Init( const SwViewOption *pNewOpt ) ( rSz.Width() ? rSz.Width() /std::max(short(1),pNewOpt->GetDivisionX()):0, rSz.Height()? rSz.Height()/std::max(short(1),pNewOpt->GetDivisionY()):0); pDrawView->SetGridFine( aFSize ); - Fraction aSnGrWdtX(rSz.Width(), pNewOpt->GetDivisionX() + 1); - Fraction aSnGrWdtY(rSz.Height(), pNewOpt->GetDivisionY() + 1); + boost::rational<long> aSnGrWdtX(rSz.Width(), pNewOpt->GetDivisionX() + 1); + boost::rational<long> aSnGrWdtY(rSz.Height(), pNewOpt->GetDivisionY() + 1); pDrawView->SetSnapGridWidth( aSnGrWdtX, aSnGrWdtY ); if ( pRoot->Frm().HasArea() ) @@ -432,7 +432,7 @@ void SwViewImp::_InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm ) // OD 15.01.2003 #103492# - method signature change due to new page preview functionality void SwViewImp::UpdateAccessiblePreview( const std::vector<PreviewPage*>& _rPreviewPages, - const Fraction& _rScale, + const boost::rational<long>& _rScale, const SwPageFrm* _pSelectedPageFrm, const Size& _rPreviewWinSize ) { diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 601c710b54c1..2e086c4ede71 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -175,20 +175,20 @@ void SwViewShell::PrintProspect( // set the MapMode aMapMode.SetOrigin( Point() ); { - Fraction aScX( aPrtSize.Width(), nMaxColSz ); - Fraction aScY( aPrtSize.Height(), nMaxRowSz ); + boost::rational<long> aScX( aPrtSize.Width(), nMaxColSz ); + boost::rational<long> aScY( aPrtSize.Height(), nMaxRowSz ); if( aScX < aScY ) aScY = aScX; { // Round percentages for Drawings so that these can paint their objects properly - aScY *= Fraction( 1000, 1 ); - long nTmp = (long)aScY; + aScY *= boost::rational<long>( 1000, 1 ); + long nTmp = boost::rational_cast<long>(aScY); if( 1 < nTmp ) --nTmp; else nTmp = 1; - aScY = Fraction( nTmp, 1000 ); + aScY = boost::rational<long>( nTmp, 1000 ); } aMapMode.SetScaleY( aScY ); diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 0731c2b07298..d861c8d51cc8 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1775,8 +1775,8 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex // Scaling. Must convert from pixels to twips. We know // that VirtualDevises use a DPI of 96. - Fraction scaleX = Fraction(contextWidth, 96) * Fraction(1440L) / Fraction(tileWidth); - Fraction scaleY = Fraction(contextHeight, 96) * Fraction(1440L) / Fraction(tileHeight); + boost::rational<long> scaleX = boost::rational<long>(contextWidth, 96) * boost::rational<long>(1440L) / boost::rational<long>(tileWidth); + boost::rational<long> scaleY = boost::rational<long>(contextHeight, 96) * boost::rational<long>(1440L) / boost::rational<long>(tileHeight); aMapMode.SetScaleX(scaleX); aMapMode.SetScaleY(scaleY); rDevice.SetMapMode(aMapMode); @@ -2131,7 +2131,7 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt ) if( mpOpt->GetZoom() != rOpt.GetZoom() && !IsPreview() ) { MapMode aMode( pMyWin->GetMapMode() ); - Fraction aNewFactor( rOpt.GetZoom(), 100 ); + boost::rational<long> aNewFactor( rOpt.GetZoom(), 100 ); aMode.SetScaleX( aNewFactor ); aMode.SetScaleY( aNewFactor ); pMyWin->SetMapMode( aMode ); @@ -2172,8 +2172,8 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt ) ( rSz.Width() ? rSz.Width() / (rOpt.GetDivisionX()+1) : 0, rSz.Height()? rSz.Height()/ (rOpt.GetDivisionY()+1) : 0); pDView->SetGridFine( aFSize ); - Fraction aSnGrWdtX(rSz.Width(), rOpt.GetDivisionX() + 1); - Fraction aSnGrWdtY(rSz.Height(), rOpt.GetDivisionY() + 1); + boost::rational<long> aSnGrWdtX(rSz.Width(), rOpt.GetDivisionX() + 1); + boost::rational<long> aSnGrWdtY(rSz.Height(), rOpt.GetDivisionY() + 1); pDView->SetSnapGridWidth( aSnGrWdtX, aSnGrWdtY ); // set handle size to 9 pixels, always diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index 231abcdcb7ec..4b38f181d0b8 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -65,7 +65,7 @@ void SwViewShell::Init( const SwViewOption *pNewOpt ) if( GetWin() && 100 != mpOpt->GetZoom() ) { MapMode aMode( mpWin->GetMapMode() ); - const Fraction aNewFactor( mpOpt->GetZoom(), 100 ); + const boost::rational<long> aNewFactor( mpOpt->GetZoom(), 100 ); aMode.SetScaleX( aNewFactor ); aMode.SetScaleY( aNewFactor ); mpWin->SetMapMode( aMode ); diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 6a0d313b6316..17e207eed8b5 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1120,8 +1120,8 @@ OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, con } while (bFound); bool bScale = false; - Fraction aScaleX(1, 1); - Fraction aScaleY(1, 1); + boost::rational<long> aScaleX(1, 1); + boost::rational<long> aScaleY(1, 1); const SwFmtFrmSize& rFrmSize = rFrmFmt.GetFrmSize(); const SvxBoxItem& rBox = rFrmFmt.GetBox(); @@ -1137,7 +1137,7 @@ OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, con if (rRealSize.Width() != nWidth) { - aScaleX = Fraction(nWidth, rRealSize.Width()); + aScaleX = boost::rational<long>(nWidth, rRealSize.Width()); bScale = true; } } @@ -1154,7 +1154,7 @@ OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, con if (rRealSize.Height() != nHeight) { - aScaleY = Fraction(nHeight, rRealSize.Height()); + aScaleY = boost::rational<long>(nHeight, rRealSize.Height()); bScale = true; } } diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx index cfa1781afff8..3285e1379636 100644 --- a/sw/source/filter/writer/wrtswtbl.cxx +++ b/sw/source/filter/writer/wrtswtbl.cxx @@ -20,7 +20,7 @@ #include <hintids.hxx> #include <editeng/boxitem.hxx> #include <editeng/brushitem.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <wrtswtbl.hxx> #include <swtable.hxx> #include <frmfmt.hxx> @@ -344,8 +344,7 @@ sal_uInt16 SwWriteTable::GetRelWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) con { long nWidth = GetRawWidth( nCol, nColSpan ); - return (sal_uInt16)(long)Fraction( nWidth*256 + GetBaseWidth()/2, - GetBaseWidth() ); + return (sal_uInt16) boost::rational_cast<long>(boost::rational<long>(nWidth * 256 + GetBaseWidth() / 2, GetBaseWidth())); } sal_uInt16 SwWriteTable::GetPrcWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const @@ -354,8 +353,7 @@ sal_uInt16 SwWriteTable::GetPrcWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) con // Looks funny, but is nothing more than // [(100 * nWidth) + .5] without rounding errors - return (sal_uInt16)(long)Fraction( nWidth*100 + GetBaseWidth()/2, - GetBaseWidth() ); + return (sal_uInt16) boost::rational_cast<long>(boost::rational<long>(nWidth * 100 + GetBaseWidth() / 2, GetBaseWidth())); } long SwWriteTable::GetAbsHeight(long nRawHeight, size_t const nRow, diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx index 1ee058754799..937b4b260bc6 100644 --- a/sw/source/filter/ww1/w1filter.cxx +++ b/sw/source/filter/ww1/w1filter.cxx @@ -1878,8 +1878,8 @@ void Ww1Picture::Out(Ww1Shell& rOut, Ww1Manager& /*rMan*/) aWMF.SetPrefMapMode(MapMode(MAP_100TH_MM)); Size aOldSiz(aWMF.GetPrefSize()); Size aNewSiz(pPic->mfp.xExtGet(), pPic->mfp.yExtGet()); - Fraction aFracX(aNewSiz.Width(), aOldSiz.Width()); - Fraction aFracY(aNewSiz.Height(), aOldSiz.Height()); + boost::rational<long> aFracX(aNewSiz.Width(), aOldSiz.Width()); + boost::rational<long> aFracY(aNewSiz.Height(), aOldSiz.Height()); aWMF.Scale(aFracX, aFracY); aWMF.SetPrefSize(aNewSiz); pGraphic = new Graphic(aWMF); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 2529b1a496fc..3b144fdab5b8 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6709,7 +6709,7 @@ void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes ) { const SwPageFtnInfo& rFtnInfo = m_rExport.pDoc->GetPageDesc(0).GetFtnInfo(); // Request a separator only in case the width is larger than zero. - bSeparator = double(rFtnInfo.GetWidth()) > 0; + bSeparator = boost::rational_cast<double>(rFtnInfo.GetWidth()) > 0; } if (bSeparator) diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index ba6aae0547b1..0d8e1d2c97cb 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -396,7 +396,7 @@ void RtfExport::WriteFootnoteSettings() { const SwPageFtnInfo& rFtnInfo = pDoc->GetPageDesc(0).GetFtnInfo(); // Request a separator only in case the width is larger than zero. - bool bSeparator = double(rFtnInfo.GetWidth()) > 0; + bool bSeparator = boost::rational_cast<double>(rFtnInfo.GetWidth()) > 0; Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_FTNSEP); if (bSeparator) diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 0fc558f546b1..aa0362d2191a 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -666,9 +666,9 @@ namespace sw { Polygon aPoly(PolygonFromPolyPolygon(rPolyPoly)); const Size &rOrigSize = pNd->GetGraphic().GetPrefSize(); - Fraction aMapPolyX(ww::nWrap100Percent, rOrigSize.Width()); - Fraction aMapPolyY(ww::nWrap100Percent, rOrigSize.Height()); - aPoly.Scale(aMapPolyX, aMapPolyY); + boost::rational<long> aMapPolyX(ww::nWrap100Percent, rOrigSize.Width()); + boost::rational<long> aMapPolyY(ww::nWrap100Percent, rOrigSize.Height()); + aPoly.Scale(boost::rational_cast<double>(aMapPolyX), boost::rational_cast<double>(aMapPolyY)); /* a) stretch right bound by 15twips @@ -678,15 +678,15 @@ namespace sw See the import for details */ const Size &rSize = pNd->GetTwipSize(); - Fraction aMoveHack(ww::nWrap100Percent, rSize.Width()); - aMoveHack *= Fraction(15, 1); - long nMove(aMoveHack); + boost::rational<long> aMoveHack(ww::nWrap100Percent, rSize.Width()); + aMoveHack *= boost::rational<long>(15, 1); + long nMove(boost::rational_cast<long>(aMoveHack)); - Fraction aHackX(ww::nWrap100Percent + nMove, + boost::rational<long> aHackX(ww::nWrap100Percent + nMove, ww::nWrap100Percent); - Fraction aHackY(ww::nWrap100Percent - nMove, + boost::rational<long> aHackY(ww::nWrap100Percent - nMove, ww::nWrap100Percent); - aPoly.Scale(aHackX, aHackY); + aPoly.Scale(boost::rational_cast<double>(aHackX), boost::rational_cast<double>(aHackY)); aPoly.Move(-nMove, 0); return aPoly; diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 1c2f3ff8bf32..1c5e838b1d19 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2155,12 +2155,12 @@ void SwBasicEscherEx::Init() // MS-DFF-Properties sind grossteils in EMU (English Metric Units) angegeben // 1mm=36000emu, 1twip=635emu - Fraction aFact(360, 1); + boost::rational<long> aFact(360, 1); aFact /= GetMapFactor(MAP_100TH_MM, eMap).X(); // create little values - aFact = Fraction(aFact.GetNumerator(), aFact.GetDenominator()); - mnEmuMul = aFact.GetNumerator(); - mnEmuDiv = aFact.GetDenominator(); + aFact = boost::rational<long>(aFact.numerator(), aFact.denominator()); + mnEmuMul = aFact.numerator(); + mnEmuDiv = aFact.denominator(); SetHellLayerId(rWrt.pDoc->getIDocumentDrawModelAccess().GetHellId()); } diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 56324f571182..02abc6c6f2d1 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1951,20 +1951,20 @@ void SwWW8ImplReader::MapWrapIntoFlyFmt(SvxMSDffImportRec* pRecord, b) stretch bottom bound to where I think it should have been in the first place */ - Fraction aMoveHack(ww::nWrap100Percent, rSize.Width()); - aMoveHack *= Fraction(15, 1); - long nMove(aMoveHack); + boost::rational<long> aMoveHack(ww::nWrap100Percent, rSize.Width()); + aMoveHack *= boost::rational<long>(15, 1); + long nMove(boost::rational_cast<long>(aMoveHack)); aPoly.Move(nMove, 0); - Fraction aHackX(ww::nWrap100Percent, ww::nWrap100Percent + nMove); - Fraction aHackY(ww::nWrap100Percent, ww::nWrap100Percent - nMove); - aPoly.Scale(aHackX, aHackY); + boost::rational<long> aHackX(ww::nWrap100Percent, ww::nWrap100Percent + nMove); + boost::rational<long> aHackY(ww::nWrap100Percent, ww::nWrap100Percent - nMove); + aPoly.Scale(boost::rational_cast<double>(aHackX), boost::rational_cast<double>(aHackY)); // Turn polygon back into units that match the graphic's const Size &rOrigSize = pNd->GetGraphic().GetPrefSize(); - Fraction aMapPolyX(rOrigSize.Width(), ww::nWrap100Percent); - Fraction aMapPolyY(rOrigSize.Height(), ww::nWrap100Percent); - aPoly.Scale(aMapPolyX, aMapPolyY); + boost::rational<long> aMapPolyX(rOrigSize.Width(), ww::nWrap100Percent); + boost::rational<long> aMapPolyY(rOrigSize.Height(), ww::nWrap100Percent); + aPoly.Scale(boost::rational_cast<double>(aMapPolyX), boost::rational_cast<double>(aMapPolyY)); // #i47277# - contour is already in unit of the // graphic preferred unit. Thus, call method <SetContour(..)> diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index b09fec67d5bf..b7dcac3b7831 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -170,8 +170,8 @@ static bool SwWw6ReadMetaStream(GDIMetaFile& rWMF, OLE_MFP* pMfp, // neue Groesse am MetaFile setzen Size aOldSiz( rWMF.GetPrefSize() ); Size aNewSiz( pMfp->xExt, pMfp->yExt ); - Fraction aFracX( aNewSiz.Width(), aOldSiz.Width() ); - Fraction aFracY( aNewSiz.Height(), aOldSiz.Height() ); + boost::rational<long> aFracX( aNewSiz.Width(), aOldSiz.Width() ); + boost::rational<long> aFracY( aNewSiz.Height(), aOldSiz.Height() ); rWMF.Scale( aFracX, aFracY ); rWMF.SetPrefSize( aNewSiz ); @@ -326,8 +326,8 @@ bool SwWW8ImplReader::ImportOleWMF(SvStorageRef xSrc1,GDIMetaFile &rWMF, aFinalSize = OutputDevice::LogicToLogic( aFinalSize, MAP_TWIP, rWMF.GetPrefMapMode() ); aOrigSize = rWMF.GetPrefSize(); - Fraction aScaleX(aFinalSize.Width(),aOrigSize.Width()); - Fraction aScaleY(aFinalSize.Height(),aOrigSize.Height()); + boost::rational<long> aScaleX(aFinalSize.Width(),aOrigSize.Width()); + boost::rational<long> aScaleY(aFinalSize.Height(),aOrigSize.Height()); rWMF.Scale( aScaleX, aScaleY ); bOk = true; } diff --git a/sw/source/ui/misc/pgfnote.cxx b/sw/source/ui/misc/pgfnote.cxx index e81e2c34d6f4..0c5d52970705 100644 --- a/sw/source/ui/misc/pgfnote.cxx +++ b/sw/source/ui/misc/pgfnote.cxx @@ -243,9 +243,9 @@ void SwFootNotePage::Reset(const SfxItemSet *rSet) m_pLinePosBox->SelectEntryPos( static_cast< sal_Int32 >(pFtnInfo->GetAdj()) ); // width - Fraction aTmp( 100, 1 ); + boost::rational<long> aTmp( 100, 1 ); aTmp *= pFtnInfo->GetWidth(); - m_pLineLengthEdit->SetValue( static_cast<long>(aTmp) ); + m_pLineLengthEdit->SetValue( boost::rational_cast<long>(aTmp) ); // gap footnote area m_pDistEdit->SetValue(m_pDistEdit->Normalize(pFtnInfo->GetTopDist()),FUNIT_TWIP); @@ -292,7 +292,7 @@ bool SwFootNotePage::FillItemSet(SfxItemSet *rSet) rFtnInfo.SetAdj((SwFtnAdj)m_pLinePosBox->GetSelectEntryPos()); // Breite - rFtnInfo.SetWidth(Fraction( static_cast< long >(m_pLineLengthEdit->GetValue()), 100)); + rFtnInfo.SetWidth(boost::rational<long>( static_cast< long >(m_pLineLengthEdit->GetValue()), 100)); const SfxPoolItem* pOldItem; if(0 == (pOldItem = GetOldItem( *rSet, FN_PARAM_FTN_INFO )) || diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 5daecba4624c..54366223c8d3 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -1909,32 +1909,32 @@ void SwPostItMgr::Rescale() sal_Int32 SwPostItMgr::GetInitialAnchorDistance() const { - const Fraction& f( mpEditWin->GetMapMode().GetScaleY() ); - return POSTIT_INITIAL_ANCHOR_DISTANCE * f.GetNumerator() / f.GetDenominator(); + const boost::rational<long>& f( mpEditWin->GetMapMode().GetScaleY() ); + return POSTIT_INITIAL_ANCHOR_DISTANCE * f.numerator() / f.denominator(); } sal_Int32 SwPostItMgr::GetSpaceBetween() const { - const Fraction& f( mpEditWin->GetMapMode().GetScaleY() ); - return ( POSTIT_SPACE_BETWEEN ) * f.GetNumerator() / f.GetDenominator(); + const boost::rational<long>& f( mpEditWin->GetMapMode().GetScaleY() ); + return ( POSTIT_SPACE_BETWEEN ) * f.numerator() / f.denominator(); } sal_Int32 SwPostItMgr::GetScrollSize() const { - const Fraction& f( mpEditWin->GetMapMode().GetScaleY() ); - return ( POSTIT_SPACE_BETWEEN + POSTIT_MINIMUMSIZE_WITH_META ) * f.GetNumerator() / f.GetDenominator(); + const boost::rational<long>& f( mpEditWin->GetMapMode().GetScaleY() ); + return ( POSTIT_SPACE_BETWEEN + POSTIT_MINIMUMSIZE_WITH_META ) * f.numerator() / f.denominator(); } sal_Int32 SwPostItMgr::GetMinimumSizeWithMeta() const { - const Fraction& f( mpEditWin->GetMapMode().GetScaleY() ); - return POSTIT_MINIMUMSIZE_WITH_META * f.GetNumerator() / f.GetDenominator(); + const boost::rational<long>& f( mpEditWin->GetMapMode().GetScaleY() ); + return POSTIT_MINIMUMSIZE_WITH_META * f.numerator() / f.denominator(); } sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const { - const Fraction& f( mpEditWin->GetMapMode().GetScaleY() ); - return POSTIT_SCROLL_SIDEBAR_HEIGHT * f.GetNumerator() / f.GetDenominator(); + const boost::rational<long>& f( mpEditWin->GetMapMode().GetScaleY() ); + return POSTIT_SCROLL_SIDEBAR_HEIGHT * f.numerator() / f.denominator(); } void SwPostItMgr::SetSpellChecking() diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index d3c1b0be7936..ba4c47437f42 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -508,7 +508,7 @@ void SwSidebarWin::Rescale() { vcl::Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() ); sal_Int32 nHeight = aFont.GetHeight(); - nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator(); + nHeight = nHeight * aMode.GetScaleY().numerator() / aMode.GetScaleY().denominator(); aFont.SetHeight( nHeight ); mpMetadataAuthor->SetControlFont( aFont ); } @@ -516,7 +516,7 @@ void SwSidebarWin::Rescale() { vcl::Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); sal_Int32 nHeight = aFont.GetHeight(); - nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator(); + nHeight = nHeight * aMode.GetScaleY().numerator() / aMode.GetScaleY().denominator(); aFont.SetHeight( nHeight ); mpMetadataDate->SetControlFont( aFont ); } @@ -780,26 +780,26 @@ void SwSidebarWin::DoResize() mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight())); //calculate rects for meta- button - const Fraction& fx( GetMapMode().GetScaleX() ); - const Fraction& fy( GetMapMode().GetScaleY() ); + const boost::rational<long>& fx( GetMapMode().GetScaleX() ); + const boost::rational<long>& fy( GetMapMode().GetScaleY() ); const Point aPos( mpMetadataAuthor->GetPosPixel()); Rectangle aRectMetaButton; if (IsPreview()) { aRectMetaButton = PixelToLogic( - Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.GetNumerator()/fx.GetDenominator(), - aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ), - Size( METABUTTON_WIDTH*4*fx.GetNumerator()/fx.GetDenominator(), - METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) ); + Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.numerator()/fx.denominator(), + aPos.Y()+5*fy.numerator()/fy.denominator() ), + Size( METABUTTON_WIDTH*4*fx.numerator()/fx.denominator(), + METABUTTON_HEIGHT*fy.numerator()/fy.denominator() ) ) ); } else { aRectMetaButton = PixelToLogic( - Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(), - aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ), - Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), - METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) ); + Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.numerator()/fx.denominator(), + aPos.Y()+5*fy.numerator()/fy.denominator() ), + Size( METABUTTON_WIDTH*fx.numerator()/fx.denominator(), + METABUTTON_HEIGHT*fy.numerator()/fy.denominator() ) ) ); } { @@ -1208,17 +1208,17 @@ sal_Int32 SwSidebarWin::GetScrollbarWidth() sal_Int32 SwSidebarWin::GetMetaButtonAreaWidth() { - const Fraction& f( GetMapMode().GetScaleX() ); + const boost::rational<long>& f( GetMapMode().GetScaleX() ); if (IsPreview()) - return 3 * METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator(); + return 3 * METABUTTON_AREA_WIDTH * f.numerator() / f.denominator(); else - return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator(); + return METABUTTON_AREA_WIDTH * f.numerator() / f.denominator(); } sal_Int32 SwSidebarWin::GetMetaHeight() { - const Fraction& f( GetMapMode().GetScaleY() ); - return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator(); + const boost::rational<long>& f( GetMapMode().GetScaleY() ); + return POSTIT_META_HEIGHT * f.numerator() / f.denominator(); } sal_Int32 SwSidebarWin::GetMinimumSizeWithMeta() @@ -1228,8 +1228,8 @@ sal_Int32 SwSidebarWin::GetMinimumSizeWithMeta() sal_Int32 SwSidebarWin::GetMinimumSizeWithoutMeta() { - const Fraction& f( GetMapMode().GetScaleY() ); - return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator(); + const boost::rational<long>& f( GetMapMode().GetScaleY() ); + return POSTIT_MINIMUMSIZE_WITHOUT_META * f.numerator() / f.denominator(); } void SwSidebarWin::SetSpellChecking() diff --git a/sw/source/uibase/frmdlg/colex.cxx b/sw/source/uibase/frmdlg/colex.cxx index d11992e6ff82..2bdec9a95915 100644 --- a/sw/source/uibase/frmdlg/colex.cxx +++ b/sw/source/uibase/frmdlg/colex.cxx @@ -336,7 +336,7 @@ SwColumnOnlyExample::SwColumnOnlyExample(vcl::Window* pParent) ::FitToActualSize(m_aCols, (sal_uInt16)m_aFrmSize.Width()); long nHeight = m_aFrmSize.Height(); - Fraction aScale( m_aWinSize.Height(), nHeight ); + boost::rational<long> aScale( m_aWinSize.Height(), nHeight ); MapMode aMapMode( GetMapMode() ); aMapMode.SetScaleX( aScale ); aMapMode.SetScaleY( aScale ); diff --git a/sw/source/uibase/inc/pview.hxx b/sw/source/uibase/inc/pview.hxx index 162ef375eb3a..96eb7760ef9d 100644 --- a/sw/source/uibase/inc/pview.hxx +++ b/sw/source/uibase/inc/pview.hxx @@ -48,7 +48,7 @@ class SwPagePreviewWin : public vcl::Window sal_uInt16 mnSttPage; sal_uInt8 mnRow, mnCol; Size maPxWinSize; - Fraction maScale; + boost::rational<long> maScale; SwPagePreview& mrView; bool mbCalcScaleForPreviewLayout; Rectangle maPaintedPreviewDocRect; diff --git a/sw/source/uibase/inc/view.hxx b/sw/source/uibase/inc/view.hxx index e624560e071f..64040606ccf7 100644 --- a/sw/source/uibase/inc/view.hxx +++ b/sw/source/uibase/inc/view.hxx @@ -492,7 +492,7 @@ public: void InsFrmMode(sal_uInt16 nCols); void SetZoom( SvxZoomType eZoomType, short nFactor = 100, bool bViewOnly = false); - virtual void SetZoomFactor( const Fraction &rX, const Fraction & ) SAL_OVERRIDE; + virtual void SetZoomFactor( const boost::rational<long> &rX, const boost::rational<long> & ) SAL_OVERRIDE; void SetViewLayout( sal_uInt16 nColumns, bool bBookMode, bool bViewOnly = false ); diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index a3980162cfbb..1f7c255acb94 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -1741,7 +1741,7 @@ void SwPagePreviewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor, else if ( _nZoomFactor != 0 ) { // calculate new scaling and set mapping mode appropriately. - Fraction aNewScale( _nZoomFactor, 100 ); + boost::rational<long> aNewScale( _nZoomFactor, 100 ); MapMode aNewMapMode = GetMapMode(); aNewMapMode.SetScaleX( aNewScale ); aNewMapMode.SetScaleY( aNewScale ); diff --git a/sw/source/uibase/uiview/swcli.cxx b/sw/source/uibase/uiview/swcli.cxx index 71b57499ddb2..900bab9db0e7 100644 --- a/sw/source/uibase/uiview/swcli.cxx +++ b/sw/source/uibase/uiview/swcli.cxx @@ -67,8 +67,8 @@ void SwOleClient::RequestNewObjectArea( Rectangle& aLogRect ) MapMode aObjectMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) ); MapMode aClientMap( GetEditWin()->GetMapMode().GetMapUnit() ); - Size aNewObjSize( Fraction( aLogRect.GetWidth() ) / GetScaleWidth(), - Fraction( aLogRect.GetHeight() ) / GetScaleHeight() ); + Size aNewObjSize( boost::rational_cast<long>(aLogRect.GetWidth() / GetScaleWidth()), + boost::rational_cast<long>(aLogRect.GetHeight() / GetScaleHeight()) ); // convert to logical coordinates of the embedded object Size aNewSize = GetEditWin()->LogicToLogic( aNewObjSize, &aClientMap, &aObjectMap ); @@ -141,8 +141,8 @@ void SwOleClient::ViewChanged() const MapMode aObjMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) ); aVisSize = OutputDevice::LogicToLogic( aVisSize, aObjMap, aMyMap ); - aVisSize.Width() = Fraction( aVisSize.Width() ) * GetScaleWidth(); - aVisSize.Height()= Fraction( aVisSize.Height() ) * GetScaleHeight(); + aVisSize.Width() = boost::rational_cast<long>(aVisSize.Width() * GetScaleWidth()); + aVisSize.Height()= boost::rational_cast<long>(aVisSize.Height() * GetScaleHeight()); SwRect aRect( Point( LONG_MIN, LONG_MIN ), aVisSize ); rSh.LockView( true ); // Prevent scrolling in the EndAction diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 993b26bed8d7..1b93bc50cae4 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -892,7 +892,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) StartListening( *pDocSh, true ); // Set Zoom-factor from HRuler - Fraction aZoomFract( aUsrPref.GetZoom(), 100 ); + boost::rational<long> aZoomFract( aUsrPref.GetZoom(), 100 ); m_pHRuler->SetZoom( aZoomFract ); m_pVRuler->SetZoom( aZoomFract ); m_pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick )); diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx index bd16c2680e54..2082a43a5b41 100644 --- a/sw/source/uibase/uiview/viewmdi.cxx +++ b/sw/source/uibase/uiview/viewmdi.cxx @@ -192,7 +192,7 @@ void SwView::_SetZoom( const Size &rEditSize, SvxZoomType eZoomType, m_pWrtShell->ApplyViewOptions( aOpt ); } - const Fraction aFrac( nFac, 100 ); + const boost::rational<long> aFrac( nFac, 100 ); m_pVRuler->SetZoom( aFrac ); m_pVRuler->ForceUpdate(); m_pHRuler->SetZoom( aFrac ); diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx index 742afb0b1172..90903289afb5 100644 --- a/sw/source/uibase/uiview/viewport.cxx +++ b/sw/source/uibase/uiview/viewport.cxx @@ -947,8 +947,8 @@ void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize ) aSize.Width() -= (aBorder.Left() + aBorder.Right()); aSize.Height() -= (aBorder.Top() + aBorder.Bottom()); Size aObjSizePixel = GetWindow()->LogicToPixel( aObjSize, MAP_TWIP ); - SfxViewShell::SetZoomFactor( Fraction( aSize.Width(), aObjSizePixel.Width() ), - Fraction( aSize.Height(), aObjSizePixel.Height() ) ); + SfxViewShell::SetZoomFactor( boost::rational<long>( aSize.Width(), aObjSizePixel.Width() ), + boost::rational<long>( aSize.Height(), aObjSizePixel.Height() ) ); } m_bInInnerResizePixel = true; @@ -985,12 +985,10 @@ void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize ) if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() ) { - const Fraction& rFrac = GetEditWin().GetMapMode().GetScaleX(); - long nZoom = 100; - if (rFrac.IsValid()) - nZoom = rFrac.GetNumerator() * 100L / rFrac.GetDenominator(); + const boost::rational<long>& rFrac = GetEditWin().GetMapMode().GetScaleX(); + long nZoom = rFrac.numerator() * 100L / rFrac.denominator(); - const Fraction aFrac( nZoom, 100 ); + const boost::rational<long> aFrac( nZoom, 100 ); m_pVRuler->SetZoom( aFrac ); m_pHRuler->SetZoom( aFrac ); InvalidateRulerPos(); // Invalidate content. @@ -1136,10 +1134,10 @@ void SwView::OuterResizePixel( const Point &rOfst, const Size &rSize ) } } -void SwView::SetZoomFactor( const Fraction &rX, const Fraction &rY ) +void SwView::SetZoomFactor( const boost::rational<long>& rX, const boost::rational<long>& rY ) { - const Fraction &rFrac = rX < rY ? rX : rY; - SetZoom( SVX_ZOOM_PERCENT, (short) long(rFrac * Fraction( 100, 1 )) ); + const boost::rational<long>&rFrac = rX < rY ? rX : rY; + SetZoom( SVX_ZOOM_PERCENT, (short) boost::rational_cast<long>(rFrac * 100) ); // To minimize rounding errors we also adjust the odd values // of the base class if necessary. diff --git a/sw/source/uibase/utlui/uiitems.cxx b/sw/source/uibase/utlui/uiitems.cxx index 2bd0c8b911b6..a15c23091ceb 100644 --- a/sw/source/uibase/utlui/uiitems.cxx +++ b/sw/source/uibase/utlui/uiitems.cxx @@ -88,9 +88,9 @@ bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const case MID_LINE_COLOR : rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break; case MID_LINE_RELWIDTH : { - Fraction aTmp( 100, 1 ); + boost::rational<long> aTmp( 100, 1 ); aTmp *= aFtnInfo.GetWidth(); - rVal <<= (sal_Int8)(long)aTmp; + rVal <<= (sal_Int8)boost::rational_cast<long>(aTmp); } break; case MID_LINE_ADJUST : rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust @@ -158,7 +158,7 @@ bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId) if(nSet < 0) bRet = false; else - aFtnInfo.SetWidth(Fraction(nSet, 100)); + aFtnInfo.SetWidth(boost::rational<long>(nSet, 100)); } break; case MID_LINE_ADJUST : diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index e7f78d121334..3a7ddf2860cf 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -743,8 +743,8 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj, Size _aVisArea( aSize.Width, aSize.Height ); - Fraction aScaleWidth( 1, 1 ); - Fraction aScaleHeight( 1, 1 ); + boost::rational<long> aScaleWidth( 1, 1 ); + boost::rational<long> aScaleHeight( 1, 1 ); bool bUseObjectSize = false; @@ -777,8 +777,8 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj, } else { - aScaleWidth = Fraction( aObjArea.Width(), _aVisArea.Width() ); - aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height()); + aScaleWidth = boost::rational<long>( aObjArea.Width(), _aVisArea.Width() ); + aScaleHeight = boost::rational<long>( aObjArea.Height(), _aVisArea.Height()); } } } @@ -815,8 +815,8 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj, } else { - aArea.Width ( Fraction( aArea.Width() ) / pCli->GetScaleWidth() ); - aArea.Height( Fraction( aArea.Height() ) / pCli->GetScaleHeight()); + aArea.Width ( boost::rational_cast<long>(aArea.Width() / pCli->GetScaleWidth()) ); + aArea.Height( boost::rational_cast<long>(aArea.Height() / pCli->GetScaleHeight()) ); } pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight ); |