From 31af61ea091cc895b893c849f2130aa35792b7db Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Thu, 23 Oct 2014 17:41:47 +0200 Subject: Fraction: Revert "fdo#81356: convert Fraction to boost::rational - 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 --- svx/source/customshapes/EnhancedCustomShape3d.cxx | 8 +-- .../EnhancedCustomShapeFunctionParser.cxx | 12 ++-- svx/source/dialog/connctrl.cxx | 28 ++++----- svx/source/dialog/graphctl.cxx | 6 +- svx/source/dialog/measctrl.cxx | 26 ++++---- svx/source/dialog/pagectrl.cxx | 10 +-- svx/source/engine3d/obj3d.cxx | 6 +- svx/source/engine3d/scene3d.cxx | 4 +- svx/source/fmcomp/gridctrl.cxx | 2 +- svx/source/form/fmvwimp.cxx | 12 ++-- .../sdr/contact/viewobjectcontactofunocontrol.cxx | 10 +-- svx/source/sdr/properties/attributeproperties.cxx | 2 +- svx/source/sdr/properties/defaultproperties.cxx | 2 +- svx/source/sdr/properties/itemsettools.cxx | 11 +++- svx/source/sdr/properties/properties.cxx | 2 +- .../sidebar/possize/PosSizePropertyPanel.cxx | 36 +++++------ .../sidebar/possize/PosSizePropertyPanel.hxx | 2 +- svx/source/svdraw/svdattr.cxx | 32 +++++++--- svx/source/svdraw/svddrag.cxx | 8 +-- svx/source/svdraw/svddrgm1.hxx | 4 +- svx/source/svdraw/svddrgmt.cxx | 64 +++++++++---------- svx/source/svdraw/svdedtv1.cxx | 20 +++--- svx/source/svdraw/svdfmtf.cxx | 8 +-- svx/source/svdraw/svdfmtf.hxx | 4 +- svx/source/svdraw/svdglev.cxx | 4 +- svx/source/svdraw/svdibrow.cxx | 2 +- svx/source/svdraw/svdmodel.cxx | 36 +++++------ svx/source/svdraw/svdoashp.cxx | 20 +++--- svx/source/svdraw/svdobj.cxx | 28 ++++----- svx/source/svdraw/svdocapt.cxx | 2 +- svx/source/svdraw/svdocirc.cxx | 8 +-- svx/source/svdraw/svdoedge.cxx | 6 +- svx/source/svdraw/svdograf.cxx | 6 +- svx/source/svdraw/svdogrp.cxx | 22 +++---- svx/source/svdraw/svdomeas.cxx | 20 +++--- svx/source/svdraw/svdoole2.cxx | 50 +++++++-------- svx/source/svdraw/svdoopengl.cxx | 2 +- svx/source/svdraw/svdopath.cxx | 8 +-- svx/source/svdraw/svdorect.cxx | 2 +- svx/source/svdraw/svdotext.cxx | 10 +-- svx/source/svdraw/svdotxdr.cxx | 12 ++-- svx/source/svdraw/svdotxed.cxx | 2 +- svx/source/svdraw/svdotxtr.cxx | 8 +-- svx/source/svdraw/svdouno.cxx | 2 +- svx/source/svdraw/svdovirt.cxx | 6 +- svx/source/svdraw/svdpntv.cxx | 6 +- svx/source/svdraw/svdpoev.cxx | 8 +-- svx/source/svdraw/svdsnpv.cxx | 4 +- svx/source/svdraw/svdtext.cxx | 4 +- svx/source/svdraw/svdtrans.cxx | 72 +++++++++++++++------- svx/source/svdraw/svdview.cxx | 4 +- svx/source/svdraw/svdxcgv.cxx | 32 +++++----- svx/source/table/svdotable.cxx | 2 +- svx/source/unodraw/UnoGraphicExporter.cxx | 16 ++--- svx/source/unodraw/unoshape.cxx | 4 +- 55 files changed, 389 insertions(+), 338 deletions(-) (limited to 'svx/source') diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx index 5dfae47826eb..60dcb86146a5 100644 --- a/svx/source/customshapes/EnhancedCustomShape3d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx @@ -262,11 +262,11 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con if ( pModel ) { fMap = 1.0; - boost::rational aFraction( pModel->GetScaleFraction() ); - if ( ( aFraction.numerator() ) != 1 || ( aFraction.denominator() != 1 ) ) + Fraction aFraction( pModel->GetScaleFraction() ); + if ( ( aFraction.GetNumerator() ) != 1 || ( aFraction.GetDenominator() != 1 ) ) { - fMap *= aFraction.numerator(); - fMap /= aFraction.denominator(); + fMap *= aFraction.GetNumerator(); + fMap /= aFraction.GetDenominator(); pMap = &fMap; } if ( pModel->GetScaleUnit() != MAP_100TH_MM ) diff --git a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx index 661af54f66e8..4f546e1b1c0c 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx @@ -19,7 +19,7 @@ #include "svx/EnhancedCustomShape2d.hxx" #include -#include +#include // Makes parser a static resource, // we're synchronized externally. @@ -116,19 +116,19 @@ public: virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /* pOptionalArg */, sal_uInt32 /* nFlags */ ) SAL_OVERRIDE { EnhancedCustomShapeParameter aRet; - boost::rational aFract( maValue ); - if ( aFract.denominator() == 1 ) + Fraction aFract( maValue ); + if ( aFract.GetDenominator() == 1 ) { aRet.Type = EnhancedCustomShapeParameterType::NORMAL; - aRet.Value <<= (sal_Int32)aFract.numerator(); + aRet.Value <<= (sal_Int32)aFract.GetNumerator(); } else { EnhancedCustomShapeEquation aEquation; aEquation.nOperation = 1; aEquation.nPara[ 0 ] = 1; - aEquation.nPara[ 1 ] = (sal_Int16)aFract.numerator(); - aEquation.nPara[ 2 ] = (sal_Int16)aFract.denominator(); + aEquation.nPara[ 1 ] = (sal_Int16)aFract.GetNumerator(); + aEquation.nPara[ 2 ] = (sal_Int16)aFract.GetDenominator(); aRet.Type = EnhancedCustomShapeParameterType::EQUATION; aRet.Value <<= (sal_Int32)rEquations.size(); rEquations.push_back( aEquation ); diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx index 7075c0249cec..f87d310a37e1 100644 --- a/svx/source/dialog/connctrl.cxx +++ b/svx/source/dialog/connctrl.cxx @@ -113,9 +113,9 @@ void SvxXConnectionPreview::AdaptSize() aNewSize.Height()= (long) ( (double) nWidth / fRectWH ); } - boost::rational aFrac1( aWinSize.Width(), aRect.GetWidth() ); - boost::rational aFrac2( aWinSize.Height(), aRect.GetHeight() ); - boost::rational aMinFrac( aFrac1 <= aFrac2 ? aFrac1 : aFrac2 ); + Fraction aFrac1( aWinSize.Width(), aRect.GetWidth() ); + Fraction aFrac2( aWinSize.Height(), aRect.GetHeight() ); + Fraction aMinFrac( aFrac1 <= aFrac2 ? aFrac1 : aFrac2 ); // Implement MapMode aDisplayMap.SetScaleX( aMinFrac ); @@ -261,29 +261,29 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt ) if( bZoomIn || bZoomOut ) { MapMode aMapMode = GetMapMode(); - boost::rational aXFrac = aMapMode.GetScaleX(); - boost::rational aYFrac = aMapMode.GetScaleY(); - boost::scoped_ptr> pMultFrac; + Fraction aXFrac = aMapMode.GetScaleX(); + Fraction aYFrac = aMapMode.GetScaleY(); + boost::scoped_ptr pMultFrac; if( bZoomIn ) { if( bCtrl ) - pMultFrac.reset(new boost::rational( 3, 2 )); + pMultFrac.reset(new Fraction( 3, 2 )); else - pMultFrac.reset(new boost::rational( 11, 10 )); + pMultFrac.reset(new Fraction( 11, 10 )); } else { if( bCtrl ) - pMultFrac.reset(new boost::rational( 2, 3 )); + pMultFrac.reset(new Fraction( 2, 3 )); else - pMultFrac.reset(new boost::rational( 10, 11 )); + pMultFrac.reset(new Fraction( 10, 11 )); } aXFrac *= *pMultFrac; aYFrac *= *pMultFrac; - if( boost::rational_cast(aXFrac) > 0.001 && boost::rational_cast(aXFrac) < 1000.0 && - boost::rational_cast(aYFrac) > 0.001 && boost::rational_cast(aYFrac) < 1000.0 ) + if( (double)aXFrac > 0.001 && (double)aXFrac < 1000.0 && + (double)aYFrac > 0.001 && (double)aYFrac < 1000.0 ) { aMapMode.SetScaleX( aXFrac ); aMapMode.SetScaleY( aYFrac ); @@ -292,8 +292,8 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt ) Size aOutSize( GetOutputSize() ); Point aPt( aMapMode.GetOrigin() ); - long nX = (long)( ( (double)aOutSize.Width() - ( (double)aOutSize.Width() * boost::rational_cast(* pMultFrac) ) ) / 2.0 + 0.5 ); - long nY = (long)( ( (double)aOutSize.Height() - ( (double)aOutSize.Height() * boost::rational_cast(* pMultFrac) ) ) / 2.0 + 0.5 ); + long nX = (long)( ( (double)aOutSize.Width() - ( (double)aOutSize.Width() * (double)*pMultFrac ) ) / 2.0 + 0.5 ); + long nY = (long)( ( (double)aOutSize.Height() - ( (double)aOutSize.Height() * (double)*pMultFrac ) ) / 2.0 + 0.5 ); aPt.X() += nX; aPt.Y() += nY; diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx index 59f402538299..0c590d3becce 100644 --- a/svx/source/dialog/graphctl.cxx +++ b/svx/source/dialog/graphctl.cxx @@ -128,7 +128,7 @@ void GraphCtrl::InitSdrModel() pModel = new SdrModel; pModel->GetItemPool().FreezeIdRanges(); pModel->SetScaleUnit( aMap100.GetMapUnit() ); - pModel->SetScaleFraction( boost::rational( 1, 1 ) ); + pModel->SetScaleFraction( Fraction( 1, 1 ) ); pModel->SetDefaultFontHeight( 500 ); pPage = new SdrPage( *pModel ); @@ -225,8 +225,8 @@ void GraphCtrl::Resize() aNewPos.Y() = ( nHeight - aNewSize.Height() ) >> 1; // Implementing MapMode for Engine - aDisplayMap.SetScaleX( boost::rational( aNewSize.Width(), aGraphSize.Width() ) ); - aDisplayMap.SetScaleY( boost::rational( aNewSize.Height(), aGraphSize.Height() ) ); + aDisplayMap.SetScaleX( Fraction( aNewSize.Width(), aGraphSize.Width() ) ); + aDisplayMap.SetScaleY( Fraction( aNewSize.Height(), aGraphSize.Height() ) ); aDisplayMap.SetOrigin( LogicToLogic( aNewPos, aMap100, aDisplayMap ) ); SetMapMode( aDisplayMap ); diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx index 8206ea373637..8810a874ba91 100644 --- a/svx/source/dialog/measctrl.cxx +++ b/svx/source/dialog/measctrl.cxx @@ -34,8 +34,8 @@ SvxXMeasurePreview::SvxXMeasurePreview( vcl::Window* pParent, WinBits nStyle) // Scale: 1:2 MapMode aMapMode = GetMapMode(); - aMapMode.SetScaleX( boost::rational( 1, 2 ) ); - aMapMode.SetScaleY( boost::rational( 1, 2 ) ); + aMapMode.SetScaleX( Fraction( 1, 2 ) ); + aMapMode.SetScaleY( Fraction( 1, 2 ) ); SetMapMode( aMapMode ); Size aSize = GetOutputSize(); @@ -109,29 +109,29 @@ void SvxXMeasurePreview::MouseButtonDown( const MouseEvent& rMEvt ) if( bZoomIn || bZoomOut ) { MapMode aMapMode = GetMapMode(); - boost::rational aXFrac = aMapMode.GetScaleX(); - boost::rational aYFrac = aMapMode.GetScaleY(); - boost::scoped_ptr> pMultFrac; + Fraction aXFrac = aMapMode.GetScaleX(); + Fraction aYFrac = aMapMode.GetScaleY(); + boost::scoped_ptr pMultFrac; if( bZoomIn ) { if( bCtrl ) - pMultFrac.reset(new boost::rational( 3, 2 )); + pMultFrac.reset(new Fraction( 3, 2 )); else - pMultFrac.reset(new boost::rational( 11, 10 )); + pMultFrac.reset(new Fraction( 11, 10 )); } else { if( bCtrl ) - pMultFrac.reset(new boost::rational( 2, 3 )); + pMultFrac.reset(new Fraction( 2, 3 )); else - pMultFrac.reset(new boost::rational( 10, 11 )); + pMultFrac.reset(new Fraction( 10, 11 )); } aXFrac *= *pMultFrac; aYFrac *= *pMultFrac; - if( boost::rational_cast(aXFrac) > 0.001 && boost::rational_cast(aXFrac) < 1000.0 && - boost::rational_cast(aYFrac) > 0.001 && boost::rational_cast(aYFrac) < 1000.0 ) + if( (double)aXFrac > 0.001 && (double)aXFrac < 1000.0 && + (double)aYFrac > 0.001 && (double)aYFrac < 1000.0 ) { aMapMode.SetScaleX( aXFrac ); aMapMode.SetScaleY( aYFrac ); @@ -140,8 +140,8 @@ void SvxXMeasurePreview::MouseButtonDown( const MouseEvent& rMEvt ) Size aOutSize( GetOutputSize() ); Point aPt( aMapMode.GetOrigin() ); - long nX = (long)( ( (double)aOutSize.Width() - ( (double)aOutSize.Width() * boost::rational_cast(* pMultFrac) ) ) / 2.0 + 0.5 ); - long nY = (long)( ( (double)aOutSize.Height() - ( (double)aOutSize.Height() * boost::rational_cast(* pMultFrac) ) ) / 2.0 + 0.5 ); + long nX = (long)( ( (double)aOutSize.Width() - ( (double)aOutSize.Width() * (double)*pMultFrac ) ) / 2.0 + 0.5 ); + long nY = (long)( ( (double)aOutSize.Height() - ( (double)aOutSize.Height() * (double)*pMultFrac ) ) / 2.0 + 0.5 ); aPt.X() += nX; aPt.Y() += nY; diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx index 7aa7e8b167ed..fa7b9befa814 100644 --- a/svx/source/dialog/pagectrl.cxx +++ b/svx/source/dialog/pagectrl.cxx @@ -102,8 +102,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSvxPageWindow(vcl::Win void SvxPageWindow::Paint(const Rectangle&) { - boost::rational aXScale(aWinSize.Width(),std::max((long)(aSize.Width() * 2 + aSize.Width() / 8),1L)); - boost::rational aYScale(aWinSize.Height(),std::max(aSize.Height(),1L)); + Fraction aXScale(aWinSize.Width(),std::max((long)(aSize.Width() * 2 + aSize.Width() / 8),1L)); + Fraction aYScale(aWinSize.Height(),std::max(aSize.Height(),1L)); MapMode aMapMode(GetMapMode()); if(aYScale < aXScale) @@ -126,9 +126,9 @@ void SvxPageWindow::Paint(const Rectangle&) if (aSize.Width() > aSize.Height()) { // Draw Landscape page of the same size - boost::rational aX = aMapMode.GetScaleX(); - boost::rational aY = aMapMode.GetScaleY(); - boost::rational a2(1.5); + Fraction aX = aMapMode.GetScaleX(); + Fraction aY = aMapMode.GetScaleY(); + Fraction a2(1.5); aX *= a2; aY *= a2; aMapMode.SetScaleX(aX); diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index 998d9d80dbbc..06eac9c647d7 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -322,7 +322,7 @@ void E3dObject::SetModel(SdrModel* pNewModel) // resize object, used from old 2d interfaces, e.g. in Move/Scale dialog (F4) -void E3dObject::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void E3dObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { // Movement in X, Y in the eye coordinate system E3dScene* pScene = GetScene(); @@ -345,8 +345,8 @@ void E3dObject::NbcResize(const Point& rRef, const boost::rational& xFact, aScaleCenter3D = aInverseViewToEye * aScaleCenter3D; // Get scale factors - double fScaleX(boost::rational_cast(xFact)); - double fScaleY(boost::rational_cast(yFact)); + double fScaleX(xFact); + double fScaleY(yFact); // build transform basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx index 54c582bd2392..9d5336f02c8c 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -323,8 +323,8 @@ void E3dScene::NbcMove(const Size& rSize) NbcSetSnapRect(aNewSnapRect); } -void E3dScene::NbcResize(const Point& rRef, const boost::rational& rXFact, - const boost::rational& rYFact) +void E3dScene::NbcResize(const Point& rRef, const Fraction& rXFact, + const Fraction& rYFact) { Rectangle aNewSnapRect = GetSnapRect(); ResizeRect(aNewSnapRect, rRef, rXFact, rYFact); diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 3657c0735ab7..3c1a9e3bad41 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -736,7 +736,7 @@ void DbGridControl::NavigationBar::StateChanged( StateChangedType nType ) case StateChangedType::ZOOM: { - boost::rational aZoom = GetZoom(); + Fraction aZoom = GetZoom(); // not all of these controls need to know the new zoom, but to be sure ... vcl::Font aFont( GetSettings().GetStyleSettings().GetFieldFont() ); diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index e0b06c2e8412..5e5ea8cba42c 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -1459,8 +1459,8 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor const sal_uInt16 nObjID = OBJ_FM_BUTTON; ::Size controlSize(4000, 500); FmFormObj *pControl = static_cast(SdrObjFactory::MakeNewObject( FmFormInventor, nObjID, NULL, NULL )); - controlSize.Width() = boost::rational_cast(controlSize.Width() * eTargetMode.GetScaleX()); - controlSize.Height() = boost::rational_cast(controlSize.Height() * eTargetMode.GetScaleY()); + controlSize.Width() = Fraction(controlSize.Width(), 1) * eTargetMode.GetScaleX(); + controlSize.Height() = Fraction(controlSize.Height(), 1) * eTargetMode.GetScaleY(); ::Point controlPos( OutputDevice::LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) ); ::Rectangle controlRect( controlPos, OutputDevice::LogicToLogic( controlSize, eSourceMode, eTargetMode ) ); pControl->SetLogicRect(controlRect); @@ -1550,8 +1550,8 @@ bool FmXFormView::createControlLabelPair( OutputDevice& _rOutDev, sal_Int32 _nXO aRealSize.Height()= aDefSize.Height(); // adjust to scaling of the target device (#53523#) - aRealSize.Width() = boost::rational_cast(aRealSize.Width() * eTargetMode.GetScaleX()); - aRealSize.Height() = boost::rational_cast(aRealSize.Height() * eTargetMode.GetScaleY()); + aRealSize.Width() = long(Fraction(aRealSize.Width(), 1) * eTargetMode.GetScaleX()); + aRealSize.Height() = long(Fraction(aRealSize.Height(), 1) * eTargetMode.GetScaleY()); // for boolean fields, we do not create a label, but just a checkbox bool bNeedLabel = ( _nControlObjectID != OBJ_FM_CHECKBOX ); @@ -1617,8 +1617,8 @@ bool FmXFormView::createControlLabelPair( OutputDevice& _rOutDev, sal_Int32 _nXO if ( OBJ_FM_IMAGECONTROL == _nControlObjectID ) aControlSize = aDefImageSize; - aControlSize.Width() = boost::rational_cast(aControlSize.Width() * eTargetMode.GetScaleX()); - aControlSize.Height() = boost::rational_cast(aControlSize.Height() * eTargetMode.GetScaleY()); + aControlSize.Width() = long(Fraction(aControlSize.Width(), 1) * eTargetMode.GetScaleX()); + aControlSize.Height() = long(Fraction(aControlSize.Height(), 1) * eTargetMode.GetScaleY()); pControl->SetLogicRect( ::Rectangle( OutputDevice::LogicToLogic( ::Point( aRealSize.Width() + _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ), diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index a87b44850ca0..096da89be126 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -279,9 +279,9 @@ namespace sdr { namespace contact { ::basegfx::B2DVector aZoom( 1, 1 ); if ( pWindow ) { - const boost::rational& rZoom( pWindow->GetZoom() ); - aZoom.setX( boost::rational_cast(rZoom) ); - aZoom.setY( boost::rational_cast(rZoom) ); + const Fraction& rZoom( pWindow->GetZoom() ); + aZoom.setX( (double)rZoom ); + aZoom.setY( (double)rZoom ); } return aZoom; } @@ -867,8 +867,8 @@ namespace sdr { namespace contact { ::basegfx::B2DHomMatrix aScaleNormalization; MapMode aCurrentDeviceMapMode( rPageViewDevice.GetMapMode() ); - aScaleNormalization.set( 0, 0, boost::rational_cast(aCurrentDeviceMapMode.GetScaleX()) ); - aScaleNormalization.set( 1, 1, boost::rational_cast(aCurrentDeviceMapMode.GetScaleY()) ); + aScaleNormalization.set( 0, 0, (double)aCurrentDeviceMapMode.GetScaleX() ); + aScaleNormalization.set( 1, 1, (double)aCurrentDeviceMapMode.GetScaleY() ); m_aZoomLevelNormalization *= aScaleNormalization; #if OSL_DEBUG_LEVEL > 1 diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx index 0c61dc1b5814..31e0711bbd2c 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -318,7 +318,7 @@ namespace sdr MapUnit aOldUnit(pOldModel->GetScaleUnit()); MapUnit aNewUnit(pNewModel->GetScaleUnit()); bool bScaleUnitChanged(aNewUnit != aOldUnit); - boost::rational aMetricFactor; + Fraction aMetricFactor; if(bScaleUnitChanged) { diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx index 08ff3d349397..c6f09bd5bb7f 100644 --- a/svx/source/sdr/properties/defaultproperties.cxx +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -211,7 +211,7 @@ namespace sdr { } - void DefaultProperties::Scale(const boost::rational& rScale) + void DefaultProperties::Scale(const Fraction& rScale) { if(mpItemSet) { diff --git a/svx/source/sdr/properties/itemsettools.cxx b/svx/source/sdr/properties/itemsettools.cxx index a15f9f8a4d68..191d3e7d3b83 100644 --- a/svx/source/sdr/properties/itemsettools.cxx +++ b/svx/source/sdr/properties/itemsettools.cxx @@ -93,10 +93,15 @@ namespace sdr { namespace properties { - void ScaleItemSet(SfxItemSet& rSet, const boost::rational& rScale) + void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale) { - sal_Int32 nMul(rScale.numerator()); - sal_Int32 nDiv(rScale.denominator()); + sal_Int32 nMul(rScale.GetNumerator()); + sal_Int32 nDiv(rScale.GetDenominator()); + + if(!rScale.IsValid() || !nDiv) + { + return; + } SfxWhichIter aIter(rSet); sal_uInt16 nWhich(aIter.FirstWhich()); diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx index 01490d03051b..9b8670f7030d 100644 --- a/svx/source/sdr/properties/properties.cxx +++ b/svx/source/sdr/properties/properties.cxx @@ -74,7 +74,7 @@ namespace sdr ClearObjectItem(nWhich); } - void BaseProperties::Scale(const boost::rational& /*rScale*/) + void BaseProperties::Scale(const Fraction& /*rScale*/) { // default implementation does nothing; overload where // an ItemSet is implemented. diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx index 2d0910f6d693..1c714e81acb4 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx @@ -508,7 +508,7 @@ IMPL_LINK( PosSizePropertyPanel, AngleModifiedHdl, void *, EMPTYARG ) sal_Int64 nTmp = dTmp*100; // #i123993# Need to take UIScale into account when executing rotations - const double fUIScale(mpView && mpView->GetModel() ? boost::rational_cast(mpView->GetModel()->GetUIScale()) : 1.0); + const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0); SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp); SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * fUIScale)); SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * fUIScale)); @@ -526,7 +526,7 @@ IMPL_LINK( PosSizePropertyPanel, RotationHdl, void *, EMPTYARG ) sal_Int32 nTmp = mpDial->GetRotation(); // #i123993# Need to take UIScale into account when executing rotations - const double fUIScale(mpView && mpView->GetModel() ? boost::rational_cast(mpView->GetModel()->GetUIScale()) : 1.0); + const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0); SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp); SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * fUIScale)); SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * fUIScale)); @@ -604,7 +604,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( { long mlOldWidth1 = pWidthItem->GetValue(); - mlOldWidth1 = boost::rational_cast(mlOldWidth1 / maUIScale); + mlOldWidth1 = Fraction( mlOldWidth1 ) / maUIScale; SetFieldUnit( *mpMtrWidth, meDlgUnit, true ); SetMetricValue( *mpMtrWidth, mlOldWidth1, mePoolUnit ); mlOldWidth = mlOldWidth1; @@ -624,7 +624,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( { long mlOldHeight1 = pHeightItem->GetValue(); - mlOldHeight1 = boost::rational_cast(mlOldHeight1 / maUIScale); + mlOldHeight1 = Fraction( mlOldHeight1 ) / maUIScale; SetFieldUnit( *mpMtrHeight, meDlgUnit, true ); SetMetricValue( *mpMtrHeight, mlOldHeight1, mePoolUnit ); mlOldHeight = mlOldHeight1; @@ -643,7 +643,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { long nTmp = pItem->GetValue(); - nTmp = boost::rational_cast(nTmp / maUIScale); + nTmp = Fraction( nTmp ) / maUIScale; SetFieldUnit( *mpMtrPosX, meDlgUnit, true ); SetMetricValue( *mpMtrPosX, nTmp, mePoolUnit ); break; @@ -661,7 +661,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { long nTmp = pItem->GetValue(); - nTmp = boost::rational_cast(nTmp / maUIScale); + nTmp = Fraction( nTmp ) / maUIScale; SetFieldUnit( *mpMtrPosY, meDlgUnit, true ); SetMetricValue( *mpMtrPosY, nTmp, mePoolUnit ); break; @@ -679,7 +679,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { mlRotX = pItem->GetValue(); - mlRotX = boost::rational_cast(mlRotX / maUIScale); + mlRotX = Fraction( mlRotX ) / maUIScale; } } break; @@ -692,7 +692,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { mlRotY = pItem->GetValue(); - mlRotY = boost::rational_cast(mlRotY / maUIScale); + mlRotY = Fraction( mlRotY ) / maUIScale; } } break; @@ -898,19 +898,19 @@ void PosSizePropertyPanel::executeSize() { if ( mpMtrWidth->IsValueModified() || mpMtrHeight->IsValueModified()) { - boost::rational aUIScale = mpView->GetModel()->GetUIScale(); + Fraction aUIScale = mpView->GetModel()->GetUIScale(); // get Width double nWidth = (double)mpMtrWidth->GetValue( meDlgUnit ); nWidth = MetricField::ConvertDoubleValue( nWidth, mpMtrWidth->GetBaseValue(), mpMtrWidth->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM ); - long lWidth = (long)(nWidth * boost::rational_cast(aUIScale)); + long lWidth = (long)(nWidth * (double)aUIScale); lWidth = OutputDevice::LogicToLogic( lWidth, MAP_100TH_MM, (MapUnit)mePoolUnit ); lWidth = (long)mpMtrWidth->Denormalize( lWidth ); // get Height double nHeight = (double)mpMtrHeight->GetValue( meDlgUnit ); nHeight = MetricField::ConvertDoubleValue( nHeight, mpMtrHeight->GetBaseValue(), mpMtrHeight->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM ); - long lHeight = (long)(nHeight * boost::rational_cast(aUIScale)); + long lHeight = (long)(nHeight * (double)aUIScale); lHeight = OutputDevice::LogicToLogic( lHeight, MAP_100TH_MM, (MapUnit)mePoolUnit ); lHeight = (long)mpMtrWidth->Denormalize( lHeight ); @@ -953,11 +953,11 @@ void PosSizePropertyPanel::executePosX() maRect = mpView->GetAllMarkedRect(); aRect = mpView->GetAllMarkedRect(); - boost::rational aUIScale = mpView->GetModel()->GetUIScale(); + Fraction aUIScale = mpView->GetModel()->GetUIScale(); lX += maAnchorPos.X(); - lX = boost::rational_cast(lX * aUIScale); + lX = Fraction( lX ) * aUIScale; lY += maAnchorPos.Y(); - lY = boost::rational_cast(lY * aUIScale); + lY = Fraction( lY ) * aUIScale; SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX); SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY); @@ -980,11 +980,11 @@ void PosSizePropertyPanel::executePosY() maRect = mpView->GetAllMarkedRect(); aRect = mpView->GetAllMarkedRect(); - boost::rational aUIScale = mpView->GetModel()->GetUIScale(); + Fraction aUIScale = mpView->GetModel()->GetUIScale(); lX += maAnchorPos.X(); - lX = boost::rational_cast(lX * aUIScale); + lX = Fraction( lX ) * aUIScale; lY += maAnchorPos.Y(); - lY = boost::rational_cast(lY * aUIScale); + lY = Fraction( lY ) * aUIScale; SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX); SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY); @@ -1158,7 +1158,7 @@ void PosSizePropertyPanel::DisableControls() void PosSizePropertyPanel::UpdateUIScale() { - const boost::rational aUIScale (mpView->GetModel()->GetUIScale()); + const Fraction aUIScale (mpView->GetModel()->GetUIScale()); if (maUIScale != aUIScale) { // UI scale has changed. diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx index 97fa3e27708d..9a3685cd4134 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx @@ -102,7 +102,7 @@ private: Point maAnchorPos; //anchor position long mlRotX; long mlRotY; - boost::rational maUIScale; + Fraction maUIScale; SfxMapUnit mePoolUnit; FieldUnit meDlgUnit; diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 0b124173d25e..d183230d0db3 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -630,7 +630,7 @@ SdrFractionItem::SdrFractionItem(sal_uInt16 nId, SvStream& rIn): sal_Int32 nMul,nDiv; rIn.ReadInt32( nMul ); rIn.ReadInt32( nDiv ); - nValue=boost::rational(nMul,nDiv); + nValue=Fraction(nMul,nDiv); } bool SdrFractionItem::operator==(const SfxPoolItem& rCmp) const @@ -643,12 +643,19 @@ bool SdrFractionItem::GetPresentation( SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresentationMetric*/, OUString &rText, const IntlWrapper *) const { - sal_Int32 nDiv = nValue.denominator(); - rText = OUString::number(nValue.numerator()); + if(nValue.IsValid()) + { + sal_Int32 nDiv = nValue.GetDenominator(); + rText = OUString::number(nValue.GetNumerator()); - if(nDiv != 1) + if(nDiv != 1) + { + rText = rText + "/" + OUString::number(nDiv); + } + } + else { - rText = rText + "/" + OUString::number(nDiv); + rText = "?"; } if(ePresentation == SFX_ITEM_PRESENTATION_COMPLETE) @@ -672,8 +679,8 @@ SfxPoolItem* SdrFractionItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const SvStream& SdrFractionItem::Store(SvStream& rOut, sal_uInt16 /*nItemVers*/) const { - rOut.WriteInt32( nValue.numerator() ); - rOut.WriteInt32( nValue.denominator() ); + rOut.WriteInt32( nValue.GetNumerator() ); + rOut.WriteInt32( nValue.GetDenominator() ); return rOut; } @@ -692,9 +699,16 @@ bool SdrScaleItem::GetPresentation( SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresentationMetric*/, OUString &rText, const IntlWrapper *) const { - sal_Int32 nDiv = GetValue().denominator(); + if(GetValue().IsValid()) + { + sal_Int32 nDiv = GetValue().GetDenominator(); - rText = OUString::number(GetValue().numerator()) + ":" + OUString::number(nDiv); + rText = OUString::number(GetValue().GetNumerator()) + ":" + OUString::number(nDiv); + } + else + { + rText = "?"; + } if(ePresentation == SFX_ITEM_PRESENTATION_COMPLETE) { diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx index fda560eb2a43..3c0f109954b0 100644 --- a/svx/source/svdraw/svddrag.cxx +++ b/svx/source/svdraw/svddrag.cxx @@ -106,22 +106,22 @@ bool SdrDragStat::CheckMinMoved(const Point& rPnt) return bMinMoved; } -boost::rational SdrDragStat::GetXFact() const +Fraction SdrDragStat::GetXFact() const { long nMul=GetNow().X()-aRef1.X(); long nDiv=GetPrev().X()-aRef1.X(); if (nDiv==0) nDiv=1; if (bHorFixed) { nMul=1; nDiv=1; } - return boost::rational(nMul,nDiv); + return Fraction(nMul,nDiv); } -boost::rational SdrDragStat::GetYFact() const +Fraction SdrDragStat::GetYFact() const { long nMul=GetNow().Y()-aRef1.Y(); long nDiv=GetPrev().Y()-aRef1.Y(); if (nDiv==0) nDiv=1; if (bVerFixed) { nMul=1; nDiv=1; } - return boost::rational(nMul,nDiv); + return Fraction(nMul,nDiv); } void SdrDragStat::TakeCreateRect(Rectangle& rRect) const diff --git a/svx/source/svdraw/svddrgm1.hxx b/svx/source/svdraw/svddrgm1.hxx index 7b038800b5e2..972c17de91ac 100644 --- a/svx/source/svdraw/svddrgm1.hxx +++ b/svx/source/svdraw/svddrgm1.hxx @@ -74,7 +74,7 @@ public: class SdrDragShear : public SdrDragMethod { private: - boost::rational aFact; + Fraction aFact; long nWink0; long nWink; double nTan; @@ -151,7 +151,7 @@ private: Point aMarkCenter; Point aCenter; Point aStart; - boost::rational aFact; + Fraction aFact; Point aRad; bool bContortionAllowed; bool bNoContortionAllowed; diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index f0d0205eee8c..15ebe12facf9 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1779,7 +1779,7 @@ SdrDragResize::SdrDragResize(SdrDragView& rNewView) void SdrDragResize::TakeSdrDragComment(OUString& rStr) const { ImpTakeDescriptionStr(STR_DragMethResize, rStr); - boost::rational aFact1(1,1); + Fraction aFact1(1,1); Point aStart(DragStat().GetStart()); Point aRef(DragStat().GetRef1()); sal_Int32 nXDiv(aStart.X() - aRef.X()); @@ -1878,7 +1878,7 @@ basegfx::B2DHomMatrix SdrDragResize::getCurrentTransformation() { basegfx::B2DHomMatrix aRetval(basegfx::tools::createTranslateB2DHomMatrix( -DragStat().Ref1().X(), -DragStat().Ref1().Y())); - aRetval.scale(boost::rational_cast(aXFact), boost::rational_cast(aYFact)); + aRetval.scale(aXFact, aYFact); aRetval.translate(DragStat().Ref1().X(), DragStat().Ref1().Y()); return aRetval; @@ -1889,7 +1889,7 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) Point aPnt(GetSnapPos(rNoSnapPnt)); Point aStart(DragStat().GetStart()); Point aRef(DragStat().GetRef1()); - boost::rational aMaxFact(0x7FFFFFFF,1); + Fraction aMaxFact(0x7FFFFFFF,1); Rectangle aLR(getSdrDragView().GetWorkArea()); bool bWorkArea=!aLR.IsEmpty(); bool bDragLimit=IsDragLimit(); @@ -1920,7 +1920,7 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) if (aRef.X()>aSR.Left()) { - boost::rational aMax(aRef.X()-aLR.Left(),aRef.X()-aSR.Left()); + Fraction aMax(aRef.X()-aLR.Left(),aRef.X()-aSR.Left()); if (aMax aMax(aLR.Right()-aRef.X(),aSR.Right()-aRef.X()); + Fraction aMax(aLR.Right()-aRef.X(),aSR.Right()-aRef.X()); if (aMaxaSR.Top()) { - boost::rational aMax(aRef.Y()-aLR.Top(),aRef.Y()-aSR.Top()); + Fraction aMax(aRef.Y()-aLR.Top(),aRef.Y()-aSR.Top()); if (aMax aMax(aLR.Bottom()-aRef.Y(),aSR.Bottom()-aRef.Y()); + Fraction aMax(aLR.Bottom()-aRef.Y(),aSR.Bottom()-aRef.Y()); if (aMax(nXMul,nXDiv)>boost::rational(nYMul,nYDiv)) !=getSdrDragView().IsBigOrtho()) + if ((Fraction(nXMul,nXDiv)>Fraction(nYMul,nYDiv)) !=getSdrDragView().IsBigOrtho()) { nXMul=nYMul; nXDiv=nYDiv; @@ -2027,8 +2027,8 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) } } - boost::rational aNeuXFact(nXMul,nXDiv); - boost::rational aNeuYFact(nYMul,nYDiv); + Fraction aNeuXFact(nXMul,nXDiv); + Fraction aNeuYFact(nYMul,nYDiv); if (bOrtho) { @@ -2046,10 +2046,10 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) } if (bXNeg) - aNeuXFact=boost::rational(-aNeuXFact.numerator(),aNeuXFact.denominator()); + aNeuXFact=Fraction(-aNeuXFact.GetNumerator(),aNeuXFact.GetDenominator()); if (bYNeg) - aNeuYFact=boost::rational(-aNeuYFact.numerator(),aNeuYFact.denominator()); + aNeuYFact=Fraction(-aNeuYFact.GetNumerator(),aNeuYFact.GetDenominator()); if (DragStat().CheckMinMoved(aPnt)) { @@ -2317,12 +2317,12 @@ basegfx::B2DHomMatrix SdrDragShear::getCurrentTransformation() { if (bVertical) { - aRetval.scale(boost::rational_cast(aFact), 1.0); + aRetval.scale(aFact, 1.0); aRetval.shearY(-nTan); } else { - aRetval.scale(1.0, boost::rational_cast(aFact)); + aRetval.scale(1.0, aFact); aRetval.shearX(-nTan); } } @@ -2344,7 +2344,7 @@ void SdrDragShear::MoveSdrDrag(const Point& rPnt) Point aP0(DragStat().GetStart()); Point aPnt(rPnt); - boost::rational aNeuFact(1,1); + Fraction aNeuFact(1,1); // if angle snapping not activated, snap to raster (except when using slant) if (nSA==0 && !bSlant) @@ -2389,11 +2389,11 @@ void SdrDragShear::MoveSdrDrag(const Point& rPnt) if (bVertical) { - aNeuFact=boost::rational(aPt2.X()-aRef.X(),aP0.X()-aRef.X()); + aNeuFact=Fraction(aPt2.X()-aRef.X(),aP0.X()-aRef.X()); } else { - aNeuFact=boost::rational(aPt2.Y()-aRef.Y(),aP0.Y()-aRef.Y()); + aNeuFact=Fraction(aPt2.Y()-aRef.Y(),aP0.Y()-aRef.Y()); } } } @@ -2451,11 +2451,11 @@ void SdrDragShear::applyCurrentTransformationToSdrObject(SdrObject& rTarget) { if (bVertical) { - rTarget.Resize(DragStat().GetRef1(),aFact,boost::rational(1,1)); + rTarget.Resize(DragStat().GetRef1(),aFact,Fraction(1,1)); } else { - rTarget.Resize(DragStat().GetRef1(),boost::rational(1,1),aFact); + rTarget.Resize(DragStat().GetRef1(),Fraction(1,1),aFact); } } @@ -2469,7 +2469,7 @@ bool SdrDragShear::EndSdrDrag(bool bCopy) { Hide(); - if (bResize && aFact==boost::rational(1,1)) + if (bResize && aFact==Fraction(1,1)) bResize=false; if (nWink!=0 || bResize) @@ -2489,11 +2489,11 @@ bool SdrDragShear::EndSdrDrag(bool bCopy) { if (bVertical) { - getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aFact,boost::rational(1,1),bCopy); + getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aFact,Fraction(1,1),bCopy); } else { - getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),boost::rational(1,1),aFact,bCopy); + getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),Fraction(1,1),aFact,bCopy); } bCopy=false; @@ -3016,7 +3016,7 @@ void SdrDragCrook::_MovAllPoints(basegfx::B2DPolyPolygon& rTarget) if (bResize) { - boost::rational aFact1(1,1); + Fraction aFact1(1,1); if (bVertical) { @@ -3108,7 +3108,7 @@ void SdrDragCrook::_MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2) if (bResize) { - boost::rational aFact1(1,1); + Fraction aFact1(1,1); if (bVert) { @@ -3184,7 +3184,7 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) else bAtCenter=true; - boost::rational aNeuFact(1,1); + Fraction aNeuFact(1,1); long dx1=aPnt.X()-aNeuCenter.X(); long dy1=aPnt.Y()-aNeuCenter.Y(); bValid=bVertical ? dx1!=0 : dy1!=0; @@ -3254,7 +3254,7 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) if (bAtCenter) nMul*=2; - aNeuFact=boost::rational(nMul,nMarkSize); + aNeuFact=Fraction(nMul,nMarkSize); nWink=nPntWink; } else @@ -3287,7 +3287,7 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) nMul = std::abs(nMul); } - aNeuFact=boost::rational(nMul,nDiv); + aNeuFact=Fraction(nMul,nDiv); } if (aNeuCenter!=aCenter || bNeuContortion!=bContortion || aNeuFact!=aFact || @@ -3301,7 +3301,7 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) aCenter=aNeuCenter; aFact=aNeuFact; aRad=Point(nNeuRad,nNeuRad); - bResize=aFact!=boost::rational(1,1); + bResize=aFact!=Fraction(1,1) && aFact.GetDenominator()!=0 && aFact.IsValid(); DragStat().NextMove(aPnt); Show(); } @@ -3310,14 +3310,14 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) void SdrDragCrook::applyCurrentTransformationToSdrObject(SdrObject& rTarget) { - const bool bDoResize(aFact!=boost::rational(1,1)); + const bool bDoResize(aFact!=Fraction(1,1)); const bool bDoCrook(aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0); if (bDoCrook || bDoResize) { if (bDoResize) { - boost::rational aFact1(1,1); + Fraction aFact1(1,1); if (bContortion) { @@ -3370,7 +3370,7 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) { Hide(); - if (bResize && aFact==boost::rational(1,1)) + if (bResize && aFact==Fraction(1,1)) bResize=false; const bool bUndo = getSdrDragView().IsUndoEnabled(); @@ -3392,7 +3392,7 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) if (bResize) { - boost::rational aFact1(1,1); + Fraction aFact1(1,1); if (bContortion) { diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index 8ccd32b8f25c..cd8fc5e28946 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -212,7 +212,7 @@ void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy) EndUndo(); } -void SdrEditView::ResizeMarkedObj(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact, bool bCopy) +void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy) { const bool bUndo = IsUndoEnabled(); if( bUndo ) @@ -245,8 +245,8 @@ void SdrEditView::ResizeMarkedObj(const Point& rRef, const boost::rational EndUndo(); } void SdrEditView::ResizeMultMarkedObj(const Point& rRef, - const boost::rational& xFact, - const boost::rational& yFact, + const Fraction& xFact, + const Fraction& yFact, const bool bCopy, const bool bWdh, const bool bHgt) @@ -276,7 +276,7 @@ void SdrEditView::ResizeMultMarkedObj(const Point& rRef, AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); } - boost::rational aFrac(1,1); + Fraction aFrac(1,1); if (bWdh && bHgt) pO->Resize(rRef, xFact, yFact); else if (bWdh) @@ -755,12 +755,12 @@ void SdrEditView::SetNotPersistAttrToMarked(const SfxItemSet& rAttr, bool /*bRep SetMarkedObjRect(aRect); } if (rAttr.GetItemState(SDRATTR_RESIZEXALL,true,&pPoolItem)==SfxItemState::SET) { - boost::rational aXFact=static_cast(pPoolItem)->GetValue(); - ResizeMarkedObj(aAllSnapRect.TopLeft(),aXFact,boost::rational(1,1)); + Fraction aXFact=static_cast(pPoolItem)->GetValue(); + ResizeMarkedObj(aAllSnapRect.TopLeft(),aXFact,Fraction(1,1)); } if (rAttr.GetItemState(SDRATTR_RESIZEYALL,true,&pPoolItem)==SfxItemState::SET) { - boost::rational aYFact=static_cast(pPoolItem)->GetValue(); - ResizeMarkedObj(aAllSnapRect.TopLeft(),boost::rational(1,1),aYFact); + Fraction aYFact=static_cast(pPoolItem)->GetValue(); + ResizeMarkedObj(aAllSnapRect.TopLeft(),Fraction(1,1),aYFact); } if (rAttr.GetItemState(SDRATTR_ROTATEALL,true,&pPoolItem)==SfxItemState::SET) { long nAngle=static_cast(pPoolItem)->GetValue(); @@ -1608,8 +1608,8 @@ void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr) // change size and height if (bChgSiz && (bResizeFreeAllowed || bResizePropAllowed)) { - boost::rational aWdt(nSizX,aRect.Right()-aRect.Left()); - boost::rational aHgt(nSizY,aRect.Bottom()-aRect.Top()); + Fraction aWdt(nSizX,aRect.Right()-aRect.Left()); + Fraction aHgt(nSizY,aRect.Bottom()-aRect.Top()); Point aRef(ImpGetPoint(aRect,eSizePoint)); if(GetSdrPageView()) diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 1385a48cc6bb..4d4292367cb0 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -241,18 +241,18 @@ size_t ImpSdrGDIMetaFileImport::DoImport( mbMov = maOfs.X()!=0 || maOfs.Y()!=0; mbSize = false; - maScaleX = boost::rational( 1, 1 ); - maScaleY = boost::rational( 1, 1 ); + maScaleX = Fraction( 1, 1 ); + maScaleY = Fraction( 1, 1 ); if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1)) { - maScaleX = boost::rational(maScaleRect.GetWidth() - 1, aMtfSize.Width()); + maScaleX = Fraction(maScaleRect.GetWidth() - 1, aMtfSize.Width()); mbSize = true; } if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1)) { - maScaleY = boost::rational(maScaleRect.GetHeight() - 1, aMtfSize.Height()); + maScaleY = Fraction(maScaleRect.GetHeight() - 1, aMtfSize.Height()); mbSize = true; } diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index d394e97463b3..16e2dddcc5ce 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -63,8 +63,8 @@ protected: Point maOfs; double mfScaleX; double mfScaleY; - boost::rational maScaleX; - boost::rational maScaleY; + Fraction maScaleX; + Fraction maScaleY; bool mbFntDirty; diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx index 36e84601099c..107f5c6b20e0 100644 --- a/svx/source/svdraw/svdglev.cxx +++ b/svx/source/svdraw/svdglev.cxx @@ -378,10 +378,10 @@ void SdrGlueEditView::MoveMarkedGluePoints(const Size& rSiz, bool bCopy) static void ImpResize(Point& rPt, const void* p1, const void* p2, const void* p3, const void* /*p4*/, const void* /*p5*/) { - ResizePoint(rPt,*(const Point*)p1,*(const boost::rational*)p2,*(const boost::rational*)p3); + ResizePoint(rPt,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3); } -void SdrGlueEditView::ResizeMarkedGluePoints(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact, bool bCopy) +void SdrGlueEditView::ResizeMarkedGluePoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy) { ForceUndirtyMrkPnt(); OUString aStr(ImpGetResStr(STR_EditResize)); diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx index fc36eb0ccb13..2123500e09c3 100644 --- a/svx/source/svdraw/svdibrow.cxx +++ b/svx/source/svdraw/svdibrow.cxx @@ -1217,7 +1217,7 @@ IMPL_LINK(SdrItemBrowser,ChangedHdl,_SdrItemBrowserControl*,pBrowse) case ITEM_FRACTION: { if (!bPairX) nLongX=1; if (!bPairY) nLongY=1; - static_cast(pNewItem)->SetValue(boost::rational(nLongX,nLongY)); + static_cast(pNewItem)->SetValue(Fraction(nLongX,nLongY)); } break; case ITEM_XCOLOR: break; case ITEM_COLOR: break; diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index d57d0ab324bf..f06d66700b63 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -113,7 +113,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe aObjUnit=SdrEngineDefaults::GetMapFraction(); eObjUnit=SdrEngineDefaults::GetMapUnit(); eUIUnit=FUNIT_MM; - aUIScale=boost::rational(1,1); + aUIScale=Fraction(1,1); nUIUnitKomma=0; bUIOnlyKomma=false; pLayerAdmin=NULL; @@ -927,9 +927,9 @@ void SdrModel::SetDefaultTabulator(sal_uInt16 nVal) void SdrModel::ImpSetUIUnit() { - if(0 == aUIScale.numerator()) + if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator()) { - aUIScale = boost::rational(1,1); + aUIScale = Fraction(1,1); } // set start values @@ -1015,17 +1015,17 @@ void SdrModel::ImpSetUIUnit() // may need to be changed in the future, too if(1 != nMul || 1 != nDiv) { - const boost::rational aTemp(static_cast< long >(nMul), static_cast< long >(nDiv)); - nMul = aTemp.numerator(); - nDiv = aTemp.denominator(); + const Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv)); + nMul = aTemp.GetNumerator(); + nDiv = aTemp.GetDenominator(); } // #i89872# take Unit of Measurement into account - if(1 != aUIScale.denominator() || 1 != aUIScale.numerator()) + if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator()) { // divide by UIScale - nMul *= aUIScale.denominator(); - nDiv *= aUIScale.numerator(); + nMul *= aUIScale.GetDenominator(); + nDiv *= aUIScale.GetNumerator(); } // shorten trailing zeros for dividend @@ -1043,12 +1043,12 @@ void SdrModel::ImpSetUIUnit() } // end preparations, set member values - aUIUnitFact = boost::rational(sal_Int32(nMul), sal_Int32(nDiv)); + aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv)); bUIOnlyKomma = (nMul == nDiv); TakeUnitStr(eUIUnit, aUIUnitStr); } -void SdrModel::SetScaleUnit(MapUnit eMap, const boost::rational& rFrac) +void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac) { if (eObjUnit!=eMap || aObjUnit!=rFrac) { eObjUnit=eMap; @@ -1073,7 +1073,7 @@ void SdrModel::SetScaleUnit(MapUnit eMap) } } -void SdrModel::SetScaleFraction(const boost::rational& rFrac) +void SdrModel::SetScaleFraction(const Fraction& rFrac) { if (aObjUnit!=rFrac) { aObjUnit=rFrac; @@ -1093,7 +1093,7 @@ void SdrModel::SetUIUnit(FieldUnit eUnit) } } -void SdrModel::SetUIScale(const boost::rational& rScale) +void SdrModel::SetUIScale(const Fraction& rScale) { if (aUIScale!=rScale) { aUIScale=rScale; @@ -1102,7 +1102,7 @@ void SdrModel::SetUIScale(const boost::rational& rScale) } } -void SdrModel::SetUIUnit(FieldUnit eUnit, const boost::rational& rScale) +void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale) { if (eUIUnit!=eUnit || aUIScale!=rScale) { eUIUnit=eUnit; @@ -1193,7 +1193,7 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I const bool bNegative(nVal < 0L); SvtSysLocale aSysLoc; const LocaleDataWrapper& rLoc(aSysLoc.GetLocaleData()); - double fLocalValue(double(nVal) * boost::rational_cast(aUIUnitFact)); + double fLocalValue(double(nVal) * double(aUIUnitFact)); if(bNegative) { @@ -1333,10 +1333,10 @@ void SdrModel::TakeWinkStr(long nWink, OUString& rStr, bool bNoDegChar) const rStr = aBuf.makeStringAndClear(); } -void SdrModel::TakePercentStr(const boost::rational& rVal, OUString& rStr, bool bNoPercentChar) const +void SdrModel::TakePercentStr(const Fraction& rVal, OUString& rStr, bool bNoPercentChar) const { - sal_Int32 nMul(rVal.numerator()); - sal_Int32 nDiv(rVal.denominator()); + sal_Int32 nMul(rVal.GetNumerator()); + sal_Int32 nDiv(rVal.GetDenominator()); bool bNeg(nMul < 0); if(nDiv < 0) diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index b54e272c79d6..9108eaeb9349 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -1561,15 +1561,15 @@ void SdrObjCustomShape::NbcMove( const Size& rSiz ) mpLastShadowGeometry->NbcMove( rSiz ); } } -void SdrObjCustomShape::Resize( const Point& rRef, const boost::rational& xFact, const boost::rational& yFact, bool bUnsetRelative ) +void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative ) { SdrTextObj::Resize( rRef, xFact, yFact, bUnsetRelative ); } -void SdrObjCustomShape::NbcResize( const Point& rRef, const boost::rational& rxFact, const boost::rational& ryFact ) +void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact ) { - boost::rational xFact( rxFact ); - boost::rational yFact( ryFact ); + Fraction xFact( rxFact ); + Fraction yFact( ryFact ); // taking care of handles that should not been changed Rectangle aOld( aRect ); @@ -1577,16 +1577,16 @@ void SdrObjCustomShape::NbcResize( const Point& rRef, const boost::rational 0 ) ) || - ( ( xFact.numerator() > 0 ) && ( xFact.denominator() < 0 ) ) ) + if ( ( ( xFact.GetNumerator() < 0 ) && ( xFact.GetDenominator() > 0 ) ) || + ( ( xFact.GetNumerator() > 0 ) && ( xFact.GetDenominator() < 0 ) ) ) { SetMirroredX( IsMirroredX() == false ); } - if ( ( ( yFact.numerator() < 0 ) && ( yFact.denominator() > 0 ) ) || - ( ( yFact.numerator() > 0 ) && ( yFact.denominator() < 0 ) ) ) + if ( ( ( yFact.GetNumerator() < 0 ) && ( yFact.GetDenominator() > 0 ) ) || + ( ( yFact.GetNumerator() > 0 ) && ( yFact.GetDenominator() < 0 ) ) ) { SetMirroredY( IsMirroredY() == false ); } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 0bf13893da80..4a3792df95eb 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1338,12 +1338,12 @@ Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const nYMul=std::abs(nYMul); nXDiv=std::abs(nXDiv); nYDiv=std::abs(nYDiv); - boost::rational aXFact(nXMul,nXDiv); // fractions for canceling - boost::rational aYFact(nYMul,nYDiv); // and for comparing - nXMul=aXFact.numerator(); - nYMul=aYFact.numerator(); - nXDiv=aXFact.denominator(); - nYDiv=aYFact.denominator(); + Fraction aXFact(nXMul,nXDiv); // fractions for canceling + Fraction aYFact(nYMul,nYDiv); // and for comparing + nXMul=aXFact.GetNumerator(); + nYMul=aYFact.GetNumerator(); + nXDiv=aXFact.GetDenominator(); + nYDiv=aYFact.GetDenominator(); if (bEcke) { // corner point handles bool bUseX=(aXFact& xFact, const boost::rational& yFact) +void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { - bool bXMirr = xFact.numerator() < 0; - bool bYMirr = yFact.numerator() < 0; + bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); + bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); if (bXMirr || bYMirr) { Point aRef1(GetSnapRect().Center()); if (bXMirr) { @@ -1593,9 +1593,9 @@ void SdrObject::Move(const Size& rSiz) } } -void SdrObject::Resize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact, bool bUnsetRelative) +void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { - if (xFact.numerator()!=xFact.denominator() || yFact.numerator()!=yFact.denominator()) { + if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { if (bUnsetRelative) { mnRelativeWidth.reset( ); @@ -2262,15 +2262,15 @@ void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr) if (aNewLogic!=rLogic) { NbcSetLogicRect(aNewLogic); } - boost::rational aResizeX(1,1); - boost::rational aResizeY(1,1); + Fraction aResizeX(1,1); + Fraction aResizeY(1,1); if (rAttr.GetItemState(SDRATTR_RESIZEXONE,true,&pPoolItem)==SfxItemState::SET) { aResizeX*=static_cast(pPoolItem)->GetValue(); } if (rAttr.GetItemState(SDRATTR_RESIZEYONE,true,&pPoolItem)==SfxItemState::SET) { aResizeY*=static_cast(pPoolItem)->GetValue(); } - if (aResizeX!=boost::rational(1,1) || aResizeY!=boost::rational(1,1)) { + if (aResizeX!=Fraction(1,1) || aResizeY!=Fraction(1,1)) { NbcResize(aRef1,aResizeX,aResizeY); } } diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index 436bea742bcf..1390794f6cf6 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -608,7 +608,7 @@ void SdrCaptionObj::NbcMove(const Size& rSiz) SetTailPos(GetFixedTailPos()); } -void SdrCaptionObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrCaptionObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { SdrRectObj::NbcResize(rRef,xFact,yFact); ResizePoly(aTailPoly,rRef,xFact,yFact); diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 1027112e114c..d420c00bfe6b 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -811,15 +811,15 @@ void SdrCircObj::NbcMove(const Size& aSiz) SetRectsDirty(true); } -void SdrCircObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrCircObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { long nWink0=aGeo.nRotationAngle; bool bNoShearRota=(aGeo.nRotationAngle==0 && aGeo.nShearAngle==0); SdrTextObj::NbcResize(rRef,xFact,yFact); bNoShearRota|=(aGeo.nRotationAngle==0 && aGeo.nShearAngle==0); if (meCircleKind!=OBJ_CIRC) { - bool bXMirr = xFact.numerator() < 0; - bool bYMirr = yFact.numerator() < 0; + bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); + bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); if (bXMirr || bYMirr) { // At bXMirr!=bYMirr we should actually swap both line ends. // That, however, is pretty bad (because of forced "hard" formatting). @@ -1031,7 +1031,7 @@ void SdrCircObj::NbcSetSnapRect(const Rectangle& rRect) long nHgt0=aSR0.Bottom()-aSR0.Top(); long nWdt1=rRect.Right()-rRect.Left(); long nHgt1=rRect.Bottom()-rRect.Top(); - NbcResize(maSnapRect.TopLeft(),boost::rational(nWdt1,nWdt0),boost::rational(nHgt1,nHgt0)); + NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top())); } else { aRect=rRect; diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index a0620387fb7d..aa88b86a1265 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -2244,8 +2244,8 @@ void SdrEdgeObj::NbcSetSnapRect(const Rectangle& rRect) long nDivY = aOld.Bottom() - aOld.Top(); if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; } if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; } - boost::rational aX(nMulX, nDivX); - boost::rational aY(nMulY, nDivY); + Fraction aX(nMulX, nDivX); + Fraction aY(nMulY, nDivY); NbcResize(aOld.TopLeft(), aX, aY); NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top())); } @@ -2258,7 +2258,7 @@ void SdrEdgeObj::NbcMove(const Size& rSiz) MoveXPoly(*pEdgeTrack,rSiz); } -void SdrEdgeObj::NbcResize(const Point& rRefPnt, const boost::rational& aXFact, const boost::rational& aYFact) +void SdrEdgeObj::NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact) { SdrTextObj::NbcResize(rRefPnt,aXFact,aXFact); ResizeXPoly(*pEdgeTrack,rRefPnt,aXFact,aYFact); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 4a56e52910f5..bb2d6b985ca0 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -897,12 +897,12 @@ SdrHdl* SdrGrafObj::GetHdl(sal_uInt32 nHdlNum) const return SdrRectObj::GetHdl( nHdlNum + 1L ); } -void SdrGrafObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrGrafObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { SdrRectObj::NbcResize( rRef, xFact, yFact ); - bool bMirrX = xFact.numerator() < 0; - bool bMirrY = yFact.numerator() < 0; + bool bMirrX = xFact.GetNumerator() < 0; + bool bMirrY = yFact.GetNumerator() < 0; if( bMirrX != bMirrY ) bMirrored = !bMirrored; diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index dd79cc445854..87634138df20 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -403,8 +403,8 @@ void SdrObjGroup::NbcSetSnapRect(const Rectangle& rRect) if (nDivX==0) { nMulX=1; nDivX=1; } if (nDivY==0) { nMulY=1; nDivY=1; } if (nMulX!=nDivX || nMulY!=nDivY) { - boost::rational aX(nMulX,nDivX); - boost::rational aY(nMulY,nDivY); + Fraction aX(nMulX,nDivX); + Fraction aY(nMulY,nDivY); NbcResize(aOld.TopLeft(),aX,aY); } if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) { @@ -436,10 +436,10 @@ void SdrObjGroup::NbcMove(const Size& rSiz) } -void SdrObjGroup::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { - bool bXMirr = xFact.numerator() < 0; - bool bYMirr = yFact.numerator() < 0; + bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); + bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); if (bXMirr || bYMirr) { Point aRef1(GetSnapRect().Center()); if (bXMirr) { @@ -538,8 +538,8 @@ void SdrObjGroup::SetSnapRect(const Rectangle& rRect) if (nDivX==0) { nMulX=1; nDivX=1; } if (nDivY==0) { nMulY=1; nDivY=1; } if (nMulX!=nDivX || nMulY!=nDivY) { - boost::rational aX(nMulX,nDivX); - boost::rational aY(nMulY,nDivY); + Fraction aX(nMulX,nDivX); + Fraction aY(nMulY,nDivY); Resize(aOld.TopLeft(),aX,aY); } if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) { @@ -587,11 +587,11 @@ void SdrObjGroup::Move(const Size& rSiz) } -void SdrObjGroup::Resize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact, bool bUnsetRelative) +void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { - if (xFact.numerator()!=xFact.denominator() || yFact.numerator()!=yFact.denominator()) { - bool bXMirr = xFact.numerator() < 0; - bool bYMirr = yFact.numerator() < 0; + if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { + bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); + bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); if (bXMirr || bYMirr) { Point aRef1(GetSnapRect().Center()); if (bXMirr) { diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index f879b82e812a..908b59540db6 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -80,7 +80,7 @@ SdrMeasureObjGeoData::~SdrMeasureObjGeoData() {} OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind) const { OUString aStr; - boost::rational aMeasureScale(1, 1); + Fraction aMeasureScale(1, 1); bool bTextRota90(false); bool bShowUnit(false); FieldUnit eMeasureUnit(FUNIT_NONE); @@ -105,7 +105,7 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind eMeasureUnit = eModUIUnit; sal_Int32 nLen(GetLen(aPt2 - aPt1)); - boost::rational aFact(1,1); + Fraction aFact(1,1); if(eMeasureUnit != eModUIUnit) { @@ -113,21 +113,27 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X(); } - if(aMeasureScale.numerator() != aMeasureScale.denominator()) + if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator()) { aFact *= aMeasureScale; } - if(aFact.numerator() != aFact.denominator()) + if(aFact.GetNumerator() != aFact.GetDenominator()) { // scale via BigInt, to avoid overruns - nLen = BigMulDiv(nLen, aFact.numerator(), aFact.denominator()); + nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator()); } OUString aTmp; pModel->TakeMetricStr(nLen, aTmp, true, nNumDigits); aStr = aTmp; + if(!aFact.IsValid()) + { + aStr = ""; + aStr += "?"; + } + sal_Unicode cDec(SvtSysLocale().GetLocaleData().getNumDecimalSep()[0]); if(aStr.indexOf(cDec) != -1) @@ -275,7 +281,7 @@ struct ImpMeasureRec : public SdrDragStatUserData bool bTextUpsideDown; long nMeasureOverhang; FieldUnit eMeasureUnit; - boost::rational aMeasureScale; + Fraction aMeasureScale; bool bShowUnit; OUString aFormatString; bool bTextAutoAngle; @@ -1029,7 +1035,7 @@ void SdrMeasureObj::NbcMove(const Size& rSiz) MovePoint(aPt2,rSiz); } -void SdrMeasureObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrMeasureObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { SdrTextObj::NbcResize(rRef,xFact,yFact); ResizePoint(aPt1,rRef,xFact,yFact); diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index cb9dd89ffc04..df431560a8d2 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -114,22 +114,22 @@ class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper5 uno::Reference< awt::XWindow > m_xWindow; SdrOle2Obj* mpObj; - boost::rational m_aScaleWidth; - boost::rational m_aScaleHeight; + Fraction m_aScaleWidth; + Fraction m_aScaleHeight; public: SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj ); void Release(); - void SetSizeScale( const boost::rational& aScaleWidth, const boost::rational& aScaleHeight ) + void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight ) { m_aScaleWidth = aScaleWidth; m_aScaleHeight = aScaleHeight; } - boost::rational GetScaleWidth() const { return m_aScaleWidth; } - boost::rational GetScaleHeight() const { return m_aScaleHeight; } + Fraction GetScaleWidth() const { return m_aScaleWidth; } + Fraction GetScaleHeight() const { return m_aScaleHeight; } void setWindow(const uno::Reference< awt::XWindow >& _xWindow); @@ -177,8 +177,8 @@ Rectangle SdrLightEmbeddedClient_Impl::impl_getScaledRect_nothrow() const { Rectangle aLogicRect( mpObj->GetLogicRect() ); // apply scaling to object area and convert to pixels - aLogicRect.SetSize( Size( boost::rational_cast(aLogicRect.GetWidth() * m_aScaleWidth), - boost::rational_cast(aLogicRect.GetHeight() * m_aScaleHeight) ) ); + aLogicRect.SetSize( Size( Fraction( aLogicRect.GetWidth() ) * m_aScaleWidth, + Fraction( aLogicRect.GetHeight() ) * m_aScaleHeight ) ); return aLogicRect; } @@ -262,8 +262,8 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObj aVisArea.SetSize( Size( aSz.Width, aSz.Height ) ); aVisArea = OutputDevice::LogicToLogic( aVisArea, aObjMapUnit, aContainerMapUnit ); - Size aScaledSize( boost::rational_cast( m_aScaleWidth * aVisArea.GetWidth() ), - boost::rational_cast( m_aScaleHeight * aVisArea.GetHeight() ) ); + Size aScaledSize( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ), + static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) ); Rectangle aLogicRect( mpObj->GetLogicRect() ); // react to the change if the difference is bigger than one pixel @@ -548,8 +548,8 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangl //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, true ); // new size of the object area without scaling - Size aNewObjSize( boost::rational_cast(aNewLogicRect.GetWidth() / m_aScaleWidth), - boost::rational_cast(aNewLogicRect.GetHeight() / m_aScaleHeight) ); + Size aNewObjSize( Fraction( aNewLogicRect.GetWidth() ) / m_aScaleWidth, + Fraction( aNewLogicRect.GetHeight() ) / m_aScaleHeight ); // now remove scaling from new placement and keep this a the new object area aNewLogicRect.SetSize( aNewObjSize ); @@ -1762,8 +1762,8 @@ void SdrOle2Obj::ImpSetVisAreaSize() || mpImpl->mxObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE ) { - boost::rational aScaleWidth; - boost::rational aScaleHeight; + Fraction aScaleWidth; + Fraction aScaleHeight; if ( pClient ) { aScaleWidth = pClient->GetScaleWidth(); @@ -1781,8 +1781,8 @@ void SdrOle2Obj::ImpSetVisAreaSize() // objects' visual area. The scaling will not change, but it might exist already and must // be used in calculations MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) ); - Size aVisSize( boost::rational_cast(aRect.GetWidth() / aScaleWidth), - boost::rational_cast(aRect.GetHeight() / aScaleHeight) ); + Size aVisSize( (long)( Fraction( aRect.GetWidth() ) / aScaleWidth ), + (long)( Fraction( aRect.GetHeight() ) / aScaleHeight ) ); aVisSize = OutputDevice::LogicToLogic( aVisSize, pModel->GetScaleUnit(), aMapUnit); awt::Size aSz; @@ -1798,8 +1798,8 @@ void SdrOle2Obj::ImpSetVisAreaSize() {} Rectangle aAcceptedVisArea; - aAcceptedVisArea.SetSize( Size( boost::rational_cast(long(aSz.Width) * aScaleWidth), - boost::rational_cast(long(aSz.Height) * aScaleHeight) ) ); + aAcceptedVisArea.SetSize( Size( (long)( Fraction( long( aSz.Width ) ) * aScaleWidth ), + (long)( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) ); if (aVisSize != aAcceptedVisArea.GetSize()) { // server changed VisArea to its liking and the VisArea is different than the suggested one @@ -1826,8 +1826,8 @@ void SdrOle2Obj::ImpSetVisAreaSize() { // The object isn't active and does not want to resize itself so the changed object area size // will be reflected in a changed object scaling - boost::rational aScaleWidth; - boost::rational aScaleHeight; + Fraction aScaleWidth; + Fraction aScaleHeight; Size aObjAreaSize; if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) { @@ -1865,7 +1865,7 @@ void SdrOle2Obj::ImpSetVisAreaSize() -void SdrOle2Obj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { if( pModel && !pModel->isLocked() ) { @@ -2211,7 +2211,7 @@ uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const } -bool SdrOle2Obj::CalculateNewScaling( boost::rational& aScaleWidth, boost::rational& aScaleHeight, Size& aObjAreaSize ) +bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize ) { // TODO/LEAN: to avoid rounding errors scaling always uses the VisArea. // If we don't cache it for own objects also we must load the object here @@ -2222,8 +2222,8 @@ bool SdrOle2Obj::CalculateNewScaling( boost::rational& aScaleWidth, boost: aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode ); Size aSize = aRect.GetSize(); - aScaleWidth = boost::rational(aSize.Width(), aObjAreaSize.Width() ); - aScaleHeight = boost::rational(aSize.Height(), aObjAreaSize.Height() ); + aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() ); + aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() ); // reduce to 10 binary digits Kuerzen(aScaleHeight, 10); @@ -2243,8 +2243,8 @@ bool SdrOle2Obj::AddOwnLightClient() if ( mpImpl->mxObjRef.is() && mpImpl->pLightClient ) { - boost::rational aScaleWidth; - boost::rational aScaleHeight; + Fraction aScaleWidth; + Fraction aScaleHeight; Size aObjAreaSize; if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) { diff --git a/svx/source/svdraw/svdoopengl.cxx b/svx/source/svdraw/svdoopengl.cxx index b1e8e8f0e945..1b3398359c83 100644 --- a/svx/source/svdraw/svdoopengl.cxx +++ b/svx/source/svdraw/svdoopengl.cxx @@ -35,7 +35,7 @@ sdr::contact::ViewContact* SdrOpenGLObj::CreateObjectSpecificViewContact() } -void SdrOpenGLObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrOpenGLObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { SdrObject::NbcResize(rRef, xFact, yFact); diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 2bc99cebee1f..ad93ed9915ff 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2352,11 +2352,11 @@ void SdrPathObj::NbcMove(const Size& rSiz) SdrTextObj::NbcMove(rSiz); } -void SdrPathObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrPathObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRef.X(), -rRef.Y())); aTrans = basegfx::tools::createScaleTranslateB2DHomMatrix( - boost::rational_cast(xFact), boost::rational_cast(yFact), rRef.X(), rRef.Y()) * aTrans; + double(xFact), double(yFact), rRef.X(), rRef.Y()) * aTrans; maPathPolygon.transform(aTrans); // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints) @@ -2454,8 +2454,8 @@ void SdrPathObj::NbcSetSnapRect(const Rectangle& rRect) long nDivY = aOld.Bottom() - aOld.Top(); if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; } if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; } - boost::rational aX(nMulX,nDivX); - boost::rational aY(nMulY,nDivY); + Fraction aX(nMulX,nDivX); + Fraction aY(nMulY,nDivY); NbcResize(aOld.TopLeft(), aX, aY); NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top())); } diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 141a71c9e603..473e38c196cb 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -494,7 +494,7 @@ void SdrRectObj::NbcMove(const Size& rSiz) SetXPolyDirty(); } -void SdrRectObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrRectObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { SdrTextObj::NbcResize(rRef,xFact,yFact); SetXPolyDirty(); diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index fc50d519b3a7..cd75e66f6c02 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -878,7 +878,7 @@ OutlinerParaObject* SdrTextObj::GetEditOutlinerParaObject() const return pPara; } -void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, boost::rational& rFitXKorreg) const +void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, Fraction& rFitXKorreg) const { OutputDevice* pOut = rOutliner.GetRefDevice(); bool bNoStretching(false); @@ -970,7 +970,7 @@ void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextS nLoopCount++; Size aSiz(rOutliner.CalcTextSize()); long nXDiff=aSiz.Width()-nWantWdt; - rFitXKorreg=boost::rational(nWantWdt,aSiz.Width()); + rFitXKorreg=Fraction(nWantWdt,aSiz.Width()); if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || nXDiff==nXDiff0) { bNoMoreLoop = true; } else { @@ -1252,7 +1252,7 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame, Rectangle& rTextRect, Rectangle& rAnchorRect, Rectangle& rPaintRect, - boost::rational& rFitXKorreg ) const + Fraction& rFitXKorreg ) const { if (!bContourFrame) { @@ -1356,7 +1356,7 @@ void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaint { Rectangle aTextRect; Rectangle aAnchorRect; - boost::rational aFitXKorreg(1,1); + Fraction aFitXKorreg(1,1); bool bContourFrame=IsContourTextFrame(); @@ -1844,7 +1844,7 @@ GDIMetaFile* SdrTextObj::GetTextScrollMetaFileAndRectangle( Rectangle aTextRect; Rectangle aAnchorRect; Rectangle aPaintRect; - boost::rational aFitXKorreg(1,1); + Fraction aFitXKorreg(1,1); bool bContourFrame(IsContourTextFrame()); // get outliner set up. To avoid getting a somehow rotated MetaFile, diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx index f65049e4df2b..1ed67ac0373c 100644 --- a/svx/source/svdraw/svdotxdr.cxx +++ b/svx/source/svdraw/svdotxdr.cxx @@ -104,12 +104,12 @@ Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const nYMul=std::abs(nYMul); nXDiv=std::abs(nXDiv); nYDiv=std::abs(nYDiv); - boost::rational aXFact(nXMul,nXDiv); // fractions for canceling - boost::rational aYFact(nYMul,nYDiv); // and for comparing - nXMul=aXFact.numerator(); - nYMul=aYFact.numerator(); - nXDiv=aXFact.denominator(); - nYDiv=aYFact.denominator(); + Fraction aXFact(nXMul,nXDiv); // fractions for canceling + Fraction aYFact(nYMul,nYDiv); // and for comparing + nXMul=aXFact.GetNumerator(); + nYMul=aYFact.GetNumerator(); + nXDiv=aXFact.GetDenominator(); + nYDiv=aYFact.GetDenominator(); if (bEcke) { // corner point handles bool bUseX=(aXFact aFitXKorreg(1,1); + Fraction aFitXKorreg(1,1); ImpSetCharStretching(rOutl,aTextRect.GetSize(),aAnchorRect.GetSize(),aFitXKorreg); } else if (IsAutoFit()) diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index b793121e846e..262012b6f758 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -50,7 +50,7 @@ void SdrTextObj::NbcSetSnapRect(const Rectangle& rRect) long nHgt0=aSR0.Bottom()-aSR0.Top(); long nWdt1=rRect.Right()-rRect.Left(); long nHgt1=rRect.Bottom()-rRect.Top(); - SdrTextObj::NbcResize(maSnapRect.TopLeft(),boost::rational(nWdt1,nWdt0),boost::rational(nHgt1,nHgt0)); + SdrTextObj::NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); SdrTextObj::NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top())); } else @@ -108,7 +108,7 @@ void SdrTextObj::NbcMove(const Size& rSiz) SetRectsDirty(true); } -void SdrTextObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { bool bNoShearMerk=aGeo.nShearAngle==0; bool bRota90Merk=bNoShearMerk && aGeo.nRotationAngle % 9000 ==0; @@ -116,8 +116,8 @@ void SdrTextObj::NbcResize(const Point& rRef, const boost::rational& xFact long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0; long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0; - bool bXMirr = xFact.numerator() < 0; - bool bYMirr = yFact.numerator() < 0; + bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); + bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); if (bXMirr || bYMirr) { Point aRef1(GetSnapRect().Center()); if (bXMirr) { diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index 02d65530c67b..166123d51d79 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -320,7 +320,7 @@ SdrUnoObj& SdrUnoObj::operator= (const SdrUnoObj& rObj) return *this; } -void SdrUnoObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrUnoObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { SdrRectObj::NbcResize(rRef,xFact,yFact); diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index ae99c80b2e5c..122e8a59477c 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -355,7 +355,7 @@ void SdrVirtObj::NbcMove(const Size& rSiz) SetRectsDirty(); } -void SdrVirtObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrVirtObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { rRefObj.NbcResize(rRef-aAnchor,xFact,yFact); SetRectsDirty(); @@ -392,9 +392,9 @@ void SdrVirtObj::Move(const Size& rSiz) } } -void SdrVirtObj::Resize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact, bool bUnsetRelative) +void SdrVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { - if (xFact.numerator()!=xFact.denominator() || yFact.numerator()!=yFact.denominator()) { + if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); rRefObj.Resize(rRef-aAnchor,xFact,yFact, bUnsetRelative); SetRectsDirty(); diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index df507c2e1a98..9d829797abe9 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -1149,11 +1149,11 @@ void SdrPaintView::MakeVisible(const Rectangle& rRect, vcl::Window& rWin) { bNewScale=true; // set new MapMode (Size+Org) and invalidate everything - boost::rational aXFact(aNewSize.Width(),aActualSize.Width()); - boost::rational aYFact(aNewSize.Height(),aActualSize.Height()); + Fraction aXFact(aNewSize.Width(),aActualSize.Width()); + Fraction aYFact(aNewSize.Height(),aActualSize.Height()); if (aYFact>aXFact) aXFact=aYFact; aXFact*=aMap.GetScaleX(); - rational_ReduceInaccurate(aXFact, 10); // to avoid runovers and BigInt mapping + aXFact.ReduceInaccurate(10); // to avoid runovers and BigInt mapping aMap.SetScaleX(aXFact); aMap.SetScaleY(aYFact); rWin.SetMapMode(aMap); diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx index 8ee050116a7c..2d9394db6b2c 100644 --- a/svx/source/svdraw/svdpoev.cxx +++ b/svx/source/svdraw/svdpoev.cxx @@ -672,12 +672,12 @@ void SdrPolyEditView::MoveMarkedPoints(const Size& rSiz) static void ImpResize(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* p2, const void* p3, const void* /*p4*/, const void* /*p5*/) { - ResizePoint(rPt,*(const Point*)p1,*(const boost::rational*)p2,*(const boost::rational*)p3); - if (pC1!=NULL) ResizePoint(*pC1,*(const Point*)p1,*(const boost::rational*)p2,*(const boost::rational*)p3); - if (pC2!=NULL) ResizePoint(*pC2,*(const Point*)p1,*(const boost::rational*)p2,*(const boost::rational*)p3); + ResizePoint(rPt,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3); + if (pC1!=NULL) ResizePoint(*pC1,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3); + if (pC2!=NULL) ResizePoint(*pC2,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3); } -void SdrPolyEditView::ResizeMarkedPoints(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrPolyEditView::ResizeMarkedPoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { ForceUndirtyMrkPnt(); OUString aStr(ImpGetResStr(STR_EditResize)); diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx index c80176c79725..00a61b109137 100644 --- a/svx/source/svdraw/svdsnpv.cxx +++ b/svx/source/svdraw/svdsnpv.cxx @@ -393,7 +393,7 @@ sal_uInt16 SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const } if(bGridSnap) { - double fSnapWidth = boost::rational_cast(aSnapWdtX); + double fSnapWidth = aSnapWdtX; if(dx == NOT_SNAPPED && fSnapWidth != 0.0) { double fx = (double)x; @@ -408,7 +408,7 @@ sal_uInt16 SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const x = (long)((double)x * fSnapWidth + (double)pPV->GetPageOrigin().X()); dx = 0; } - fSnapWidth = boost::rational_cast(aSnapWdtY); + fSnapWidth = aSnapWdtY; if(dy == NOT_SNAPPED && fSnapWidth) { double fy = (double)y; diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx index acd1546b1cad..ed99ae31008f 100644 --- a/svx/source/svdraw/svdtext.cxx +++ b/svx/source/svdraw/svdtext.cxx @@ -153,12 +153,12 @@ void SdrText::SetModel( SdrModel* pNewModel ) mpOutlinerParaObject=0; if (bScaleUnitChanged) { - boost::rational aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X(); + Fraction aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X(); if (bSetHgtItem) { // Now correct the frame attribute - nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.numerator(),aMetricFactor.denominator()); + nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.GetNumerator(),aMetricFactor.GetDenominator()); SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT)); } } diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx index e1d7104656da..f3cccd0db8e0 100644 --- a/svx/source/svdraw/svdtrans.cxx +++ b/svx/source/svdraw/svdtrans.cxx @@ -32,20 +32,46 @@ void MoveXPoly(XPolygon& rPoly, const Size& S) rPoly.Move(S.Width(),S.Height()); } -void ResizeRect(Rectangle& rRect, const Point& rRef, const boost::rational& rxFact, const boost::rational& ryFact, bool bNoJustify) +void ResizeRect(Rectangle& rRect, const Point& rRef, const Fraction& rxFact, const Fraction& ryFact, bool bNoJustify) { - boost::rational xFact(rxFact); - boost::rational yFact(ryFact); + Fraction xFact(rxFact); + Fraction yFact(ryFact); - rRect.Left() =rRef.X()+Round(((double)(rRect.Left() -rRef.X())*xFact.numerator())/xFact.denominator()); - rRect.Right() =rRef.X()+Round(((double)(rRect.Right() -rRef.X())*xFact.numerator())/xFact.denominator()); - rRect.Top() =rRef.Y()+Round(((double)(rRect.Top() -rRef.Y())*yFact.numerator())/yFact.denominator()); - rRect.Bottom()=rRef.Y()+Round(((double)(rRect.Bottom()-rRef.Y())*yFact.numerator())/yFact.denominator()); + { + if (xFact.GetDenominator()==0) { + long nWdt=rRect.Right()-rRect.Left(); + if (xFact.GetNumerator()>=0) { // catch divisions by zero + xFact=Fraction(xFact.GetNumerator(),1); + if (nWdt==0) rRect.Right()++; + } else { + xFact=Fraction(xFact.GetNumerator(),-1); + if (nWdt==0) rRect.Left()--; + } + } + rRect.Left() =rRef.X()+Round(((double)(rRect.Left() -rRef.X())*xFact.GetNumerator())/xFact.GetDenominator()); + rRect.Right() =rRef.X()+Round(((double)(rRect.Right() -rRef.X())*xFact.GetNumerator())/xFact.GetDenominator()); + } + { + if (yFact.GetDenominator()==0) { + long nHgt=rRect.Bottom()-rRect.Top(); + if (yFact.GetNumerator()>=0) { // catch divisions by zero + yFact=Fraction(yFact.GetNumerator(),1); + if (nHgt==0) rRect.Bottom()++; + } else { + yFact=Fraction(yFact.GetNumerator(),-1); + if (nHgt==0) rRect.Top()--; + } + + yFact=Fraction(yFact.GetNumerator(),1); // catch divisions by zero + } + rRect.Top() =rRef.Y()+Round(((double)(rRect.Top() -rRef.Y())*yFact.GetNumerator())/yFact.GetDenominator()); + rRect.Bottom()=rRef.Y()+Round(((double)(rRect.Bottom()-rRef.Y())*yFact.GetNumerator())/yFact.GetDenominator()); + } if (!bNoJustify) rRect.Justify(); } -void ResizePoly(Polygon& rPoly, const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void ResizePoly(Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact) { sal_uInt16 nAnz=rPoly.GetSize(); for (sal_uInt16 i=0; i& } } -void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact) { sal_uInt16 nAnz=rPoly.GetPointCount(); for (sal_uInt16 i=0; i& rF, unsigned nDigits) +void Kuerzen(Fraction& rF, unsigned nDigits) { - sal_Int32 nMul=rF.numerator(); - sal_Int32 nDiv=rF.denominator(); + sal_Int32 nMul=rF.GetNumerator(); + sal_Int32 nDiv=rF.GetDenominator(); bool bNeg = false; if (nMul<0) { nMul=-nMul; bNeg=!bNeg; } if (nDiv<0) { nDiv=-nDiv; bNeg=!bNeg; } @@ -599,7 +625,7 @@ void Kuerzen(boost::rational& rF, unsigned nDigits) return; } if (bNeg) nMul=-nMul; - rF=boost::rational(nMul,nDiv); + rF=Fraction(nMul,nDiv); } @@ -635,7 +661,7 @@ FrPair GetInchOrMM(MapUnit eU) } default: break; } - return boost::rational(1,1); + return Fraction(1,1); } FrPair GetInchOrMM(FieldUnit eU) @@ -654,7 +680,7 @@ FrPair GetInchOrMM(FieldUnit eU) case FUNIT_MILE : return FrPair( 1,63360); default: break; } - return boost::rational(1,1); + return Fraction(1,1); } // Calculate the factor that we need to convert units from eS to eD. @@ -668,8 +694,8 @@ FrPair GetMapFactor(MapUnit eS, MapUnit eD) bool bSInch=IsInch(eS); bool bDInch=IsInch(eD); FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y()); - if (bSInch && !bDInch) { aRet.X()*=boost::rational(127,5); aRet.Y()*=boost::rational(127,5); } - if (!bSInch && bDInch) { aRet.X()*=boost::rational(5,127); aRet.Y()*=boost::rational(5,127); } + if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); } + if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); } return aRet; }; @@ -681,8 +707,8 @@ FrPair GetMapFactor(FieldUnit eS, FieldUnit eD) bool bSInch=IsInch(eS); bool bDInch=IsInch(eD); FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y()); - if (bSInch && !bDInch) { aRet.X()*=boost::rational(127,5); aRet.Y()*=boost::rational(127,5); } - if (!bSInch && bDInch) { aRet.X()*=boost::rational(5,127); aRet.Y()*=boost::rational(5,127); } + if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); } + if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); } return aRet; }; @@ -763,7 +789,7 @@ void GetMeterOrInch(FieldUnit eFU, short& rnKomma, long& rnMul, long& rnDiv, boo void SdrFormatter::Undirty() { - if (aScale.numerator()==0) aScale=boost::rational(1,1); + if (aScale.GetNumerator()==0 || aScale.GetDenominator()==0) aScale=Fraction(1,1); bool bSrcMetr,bSrcInch,bDstMetr,bDstInch; long nMul1,nDiv1,nMul2,nDiv2; short nKomma1,nKomma2; @@ -792,9 +818,9 @@ void SdrFormatter::Undirty() } // temporary fraction for canceling - boost::rational aTempFract(nMul1,nDiv1); - nMul1=aTempFract.numerator(); - nDiv1=aTempFract.denominator(); + Fraction aTempFract(nMul1,nDiv1); + nMul1=aTempFract.GetNumerator(); + nDiv1=aTempFract.GetDenominator(); nMul_=nMul1; nDiv_=nDiv1; diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx index a5f2acd3ea7f..b36b5e725719 100644 --- a/svx/source/svdraw/svdview.cxx +++ b/svx/source/svdraw/svdview.cxx @@ -478,8 +478,8 @@ SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) co // account for FitToSize bool bFitToSize(pTextObj->IsFitToSize()); if (bFitToSize) { - boost::rational aX(aTextRect.GetWidth()-1,aAnchor.GetWidth()-1); - boost::rational aY(aTextRect.GetHeight()-1,aAnchor.GetHeight()-1); + Fraction aX(aTextRect.GetWidth()-1,aAnchor.GetWidth()-1); + Fraction aY(aTextRect.GetHeight()-1,aAnchor.GetHeight()-1); ResizePoint(aTemporaryTextRelativePosition,Point(),aX,aY); } // account for rotation diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 1b070a17f1f2..fc4e732e4851 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -160,7 +160,7 @@ bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList* pObj->FitFrameToTextSize(); Size aSiz(pObj->GetLogicRect().GetSize()); MapUnit eMap=pMod->GetScaleUnit(); - boost::rational aMap=pMod->GetScaleFraction(); + Fraction aMap=pMod->GetScaleFraction(); ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions); return true; } @@ -197,7 +197,7 @@ bool SdrExchangeView::Paste(SvStream& rInput, const OUString& rBaseURL, sal_uInt pObj->FitFrameToTextSize(); Size aSiz(pObj->GetLogicRect().GetSize()); MapUnit eMap=pMod->GetScaleUnit(); - boost::rational aMap=pMod->GetScaleFraction(); + Fraction aMap=pMod->GetScaleFraction(); ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions); // b4967543 @@ -267,7 +267,7 @@ bool SdrExchangeView::Paste( MapUnit eSrcUnit=pSrcMod->GetScaleUnit(); MapUnit eDstUnit=pMod->GetScaleUnit(); bool bResize=eSrcUnit!=eDstUnit; - boost::rational xResize,yResize; + Fraction xResize,yResize; Point aPt0; if (bResize) { @@ -403,19 +403,19 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po MapUnit eSrcMU=rMap.GetMapUnit(); MapUnit eDstMU=pMod->GetScaleUnit(); FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU)); - boost::rational aDstFr(pMod->GetScaleFraction()); - nSizX*=aMapFact.X().numerator(); - nSizX*=rMap.GetScaleX().numerator(); - nSizX*=aDstFr.denominator(); - nSizX/=aMapFact.X().denominator(); - nSizX/=rMap.GetScaleX().denominator(); - nSizX/=aDstFr.numerator(); - nSizY*=aMapFact.Y().numerator(); - nSizY*=rMap.GetScaleY().numerator(); - nSizX*=aDstFr.denominator(); - nSizY/=aMapFact.Y().denominator(); - nSizY/=rMap.GetScaleY().denominator(); - nSizY/=aDstFr.numerator(); + Fraction aDstFr(pMod->GetScaleFraction()); + nSizX*=aMapFact.X().GetNumerator(); + nSizX*=rMap.GetScaleX().GetNumerator(); + nSizX*=aDstFr.GetDenominator(); + nSizX/=aMapFact.X().GetDenominator(); + nSizX/=rMap.GetScaleX().GetDenominator(); + nSizX/=aDstFr.GetNumerator(); + nSizY*=aMapFact.Y().GetNumerator(); + nSizY*=rMap.GetScaleY().GetNumerator(); + nSizX*=aDstFr.GetDenominator(); + nSizY/=aMapFact.Y().GetDenominator(); + nSizY/=rMap.GetScaleY().GetDenominator(); + nSizY/=aDstFr.GetNumerator(); long xs=nSizX; long ys=nSizY; Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 67d1d9c9a80f..e41c2cb6fccc 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -1965,7 +1965,7 @@ void SdrTableObj::NbcMove(const Size& rSiz) -void SdrTableObj::NbcResize(const Point& rRef, const boost::rational& xFact, const boost::rational& yFact) +void SdrTableObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { Rectangle aOldRect( maLogicRect ); ResizeRect(maLogicRect,rRef,xFact,yFact); diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 0d15e88fb61b..ad1be5447ef8 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -111,8 +111,8 @@ namespace { Sequence< PropertyValue > maFilterData; - boost::rational maScaleX; - boost::rational maScaleY; + Fraction maScaleX; + Fraction maScaleY; ExportSettings( SdrModel* pDoc ); }; @@ -407,7 +407,7 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid // use scaling? if( nWidthPixel ) { - const boost::rational aFrac( (long) nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() ); + const Fraction aFrac( (long) nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() ); aMM.SetScaleX( aFrac ); @@ -417,7 +417,7 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid if( nHeightPixel ) { - const boost::rational aFrac( (long) nHeightPixel, pVDev->LogicToPixel( aPageSize, aMM ).Height() ); + const Fraction aFrac( (long) nHeightPixel, pVDev->LogicToPixel( aPageSize, aMM ).Height() ); if( nWidthPixel == 0 ) aMM.SetScaleX( aFrac ); @@ -577,25 +577,25 @@ void GraphicExporter::ParseSettings( const Sequence< PropertyValue >& aDescripto { sal_Int32 nVal = 1; if( pDataValues->Value >>= nVal ) - rSettings.maScaleX = boost::rational( nVal, rSettings.maScaleX.denominator() ); + rSettings.maScaleX = Fraction( nVal, rSettings.maScaleX.GetDenominator() ); } else if ( pDataValues->Name == "ScaleXDenominator" ) { sal_Int32 nVal = 1; if( pDataValues->Value >>= nVal ) - rSettings.maScaleX = boost::rational( rSettings.maScaleX.numerator(), nVal ); + rSettings.maScaleX = Fraction( rSettings.maScaleX.GetNumerator(), nVal ); } else if ( pDataValues->Name == "ScaleYNumerator" ) { sal_Int32 nVal = 1; if( pDataValues->Value >>= nVal ) - rSettings.maScaleY = boost::rational( nVal, rSettings.maScaleY.denominator() ); + rSettings.maScaleY = Fraction( nVal, rSettings.maScaleY.GetDenominator() ); } else if ( pDataValues->Name == "ScaleYDenominator" ) { sal_Int32 nVal = 1; if( pDataValues->Value >>= nVal ) - rSettings.maScaleY = boost::rational( rSettings.maScaleY.numerator(), nVal ); + rSettings.maScaleY = Fraction( rSettings.maScaleY.GetNumerator(), nVal ); } pDataValues++; diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index a1b6a7b3e07e..9e45f285492d 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -1219,8 +1219,8 @@ void SAL_CALL SvxShape::setSize( const awt::Size& rSize ) if(mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_MEASURE ) { - boost::rational aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left()); - boost::rational aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top()); + Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left()); + Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top()); Point aPt = mpObj->GetSnapRect().TopLeft(); mpObj->Resize(aPt,aWdt,aHgt); } -- cgit