diff options
Diffstat (limited to 'svx/source/svdraw')
35 files changed, 240 insertions, 286 deletions
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 1e012d96bac3..216107aa9930 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=Fraction(nMul,nDiv); + nValue=boost::rational<long>(nMul,nDiv); } bool SdrFractionItem::operator==(const SfxPoolItem& rCmp) const @@ -643,19 +643,12 @@ bool SdrFractionItem::GetPresentation( SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresentationMetric*/, OUString &rText, const IntlWrapper *) const { - if(nValue.IsValid()) - { - sal_Int32 nDiv = nValue.GetDenominator(); - rText = OUString::number(nValue.GetNumerator()); + sal_Int32 nDiv = nValue.denominator(); + rText = OUString::number(nValue.numerator()); - if(nDiv != 1) - { - rText = rText + "/" + OUString::number(nDiv); - } - } - else + if(nDiv != 1) { - rText = "?"; + rText = rText + "/" + OUString::number(nDiv); } if(ePresentation == SFX_ITEM_PRESENTATION_COMPLETE) @@ -679,8 +672,8 @@ SfxPoolItem* SdrFractionItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const SvStream& SdrFractionItem::Store(SvStream& rOut, sal_uInt16 /*nItemVers*/) const { - rOut.WriteInt32( nValue.GetNumerator() ); - rOut.WriteInt32( nValue.GetDenominator() ); + rOut.WriteInt32( nValue.numerator() ); + rOut.WriteInt32( nValue.denominator() ); return rOut; } @@ -699,16 +692,9 @@ bool SdrScaleItem::GetPresentation( SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresentationMetric*/, OUString &rText, const IntlWrapper *) const { - if(GetValue().IsValid()) - { - sal_Int32 nDiv = GetValue().GetDenominator(); + sal_Int32 nDiv = GetValue().denominator(); - rText = OUString::number(GetValue().GetNumerator()) + ":" + OUString::number(nDiv); - } - else - { - rText = "?"; - } + rText = OUString::number(GetValue().numerator()) + ":" + OUString::number(nDiv); if(ePresentation == SFX_ITEM_PRESENTATION_COMPLETE) { diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx index 3c0f109954b0..fda560eb2a43 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; } -Fraction SdrDragStat::GetXFact() const +boost::rational<long> 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 Fraction(nMul,nDiv); + return boost::rational<long>(nMul,nDiv); } -Fraction SdrDragStat::GetYFact() const +boost::rational<long> 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 Fraction(nMul,nDiv); + return boost::rational<long>(nMul,nDiv); } void SdrDragStat::TakeCreateRect(Rectangle& rRect) const diff --git a/svx/source/svdraw/svddrgm1.hxx b/svx/source/svdraw/svddrgm1.hxx index 972c17de91ac..7b038800b5e2 100644 --- a/svx/source/svdraw/svddrgm1.hxx +++ b/svx/source/svdraw/svddrgm1.hxx @@ -74,7 +74,7 @@ public: class SdrDragShear : public SdrDragMethod { private: - Fraction aFact; + boost::rational<long> aFact; long nWink0; long nWink; double nTan; @@ -151,7 +151,7 @@ private: Point aMarkCenter; Point aCenter; Point aStart; - Fraction aFact; + boost::rational<long> aFact; Point aRad; bool bContortionAllowed; bool bNoContortionAllowed; diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 9c92001b56af..a5b671cbd38a 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); - Fraction aFact1(1,1); + boost::rational<long> 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(aXFact, aYFact); + aRetval.scale(boost::rational_cast<double>(aXFact), boost::rational_cast<double>(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()); - Fraction aMaxFact(0x7FFFFFFF,1); + boost::rational<long> 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()) { - Fraction aMax(aRef.X()-aLR.Left(),aRef.X()-aSR.Left()); + boost::rational<long> aMax(aRef.X()-aLR.Left(),aRef.X()-aSR.Left()); if (aMax<aMaxFact) aMaxFact=aMax; @@ -1928,7 +1928,7 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) if (aRef.X()<aSR.Right()) { - Fraction aMax(aLR.Right()-aRef.X(),aSR.Right()-aRef.X()); + boost::rational<long> aMax(aLR.Right()-aRef.X(),aSR.Right()-aRef.X()); if (aMax<aMaxFact) aMaxFact=aMax; @@ -1936,7 +1936,7 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) if (aRef.Y()>aSR.Top()) { - Fraction aMax(aRef.Y()-aLR.Top(),aRef.Y()-aSR.Top()); + boost::rational<long> aMax(aRef.Y()-aLR.Top(),aRef.Y()-aSR.Top()); if (aMax<aMaxFact) aMaxFact=aMax; @@ -1944,7 +1944,7 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) if (aRef.Y()<aSR.Bottom()) { - Fraction aMax(aLR.Bottom()-aRef.Y(),aSR.Bottom()-aRef.Y()); + boost::rational<long> aMax(aLR.Bottom()-aRef.Y(),aSR.Bottom()-aRef.Y()); if (aMax<aMaxFact) aMaxFact=aMax; @@ -1979,7 +1979,7 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) if (bOrtho) { - if ((Fraction(nXMul,nXDiv)>Fraction(nYMul,nYDiv)) !=getSdrDragView().IsBigOrtho()) + if ((boost::rational<long>(nXMul,nXDiv)>boost::rational<long>(nYMul,nYDiv)) !=getSdrDragView().IsBigOrtho()) { nXMul=nYMul; nXDiv=nYDiv; @@ -2027,8 +2027,8 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) } } - Fraction aNeuXFact(nXMul,nXDiv); - Fraction aNeuYFact(nYMul,nYDiv); + boost::rational<long> aNeuXFact(nXMul,nXDiv); + boost::rational<long> aNeuYFact(nYMul,nYDiv); if (bOrtho) { @@ -2046,10 +2046,10 @@ void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) } if (bXNeg) - aNeuXFact=Fraction(-aNeuXFact.GetNumerator(),aNeuXFact.GetDenominator()); + aNeuXFact=boost::rational<long>(-aNeuXFact.numerator(),aNeuXFact.denominator()); if (bYNeg) - aNeuYFact=Fraction(-aNeuYFact.GetNumerator(),aNeuYFact.GetDenominator()); + aNeuYFact=boost::rational<long>(-aNeuYFact.numerator(),aNeuYFact.denominator()); if (DragStat().CheckMinMoved(aPnt)) { @@ -2317,12 +2317,12 @@ basegfx::B2DHomMatrix SdrDragShear::getCurrentTransformation() { if (bVertical) { - aRetval.scale(aFact, 1.0); + aRetval.scale(boost::rational_cast<double>(aFact), 1.0); aRetval.shearY(-nTan); } else { - aRetval.scale(1.0, aFact); + aRetval.scale(1.0, boost::rational_cast<double>(aFact)); aRetval.shearX(-nTan); } } @@ -2344,7 +2344,7 @@ void SdrDragShear::MoveSdrDrag(const Point& rPnt) Point aP0(DragStat().GetStart()); Point aPnt(rPnt); - Fraction aNeuFact(1,1); + boost::rational<long> 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=Fraction(aPt2.X()-aRef.X(),aP0.X()-aRef.X()); + aNeuFact=boost::rational<long>(aPt2.X()-aRef.X(),aP0.X()-aRef.X()); } else { - aNeuFact=Fraction(aPt2.Y()-aRef.Y(),aP0.Y()-aRef.Y()); + aNeuFact=boost::rational<long>(aPt2.Y()-aRef.Y(),aP0.Y()-aRef.Y()); } } } @@ -2451,11 +2451,11 @@ void SdrDragShear::applyCurrentTransformationToSdrObject(SdrObject& rTarget) { if (bVertical) { - rTarget.Resize(DragStat().GetRef1(),aFact,Fraction(1,1)); + rTarget.Resize(DragStat().GetRef1(),aFact,boost::rational<long>(1,1)); } else { - rTarget.Resize(DragStat().GetRef1(),Fraction(1,1),aFact); + rTarget.Resize(DragStat().GetRef1(),boost::rational<long>(1,1),aFact); } } @@ -2469,7 +2469,7 @@ bool SdrDragShear::EndSdrDrag(bool bCopy) { Hide(); - if (bResize && aFact==Fraction(1,1)) + if (bResize && aFact==boost::rational<long>(1,1)) bResize=false; if (nWink!=0 || bResize) @@ -2489,11 +2489,11 @@ bool SdrDragShear::EndSdrDrag(bool bCopy) { if (bVertical) { - getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aFact,Fraction(1,1),bCopy); + getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aFact,boost::rational<long>(1,1),bCopy); } else { - getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),Fraction(1,1),aFact,bCopy); + getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),boost::rational<long>(1,1),aFact,bCopy); } bCopy=false; @@ -3016,7 +3016,7 @@ void SdrDragCrook::_MovAllPoints(basegfx::B2DPolyPolygon& rTarget) if (bResize) { - Fraction aFact1(1,1); + boost::rational<long> aFact1(1,1); if (bVertical) { @@ -3108,7 +3108,7 @@ void SdrDragCrook::_MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2) if (bResize) { - Fraction aFact1(1,1); + boost::rational<long> aFact1(1,1); if (bVert) { @@ -3184,7 +3184,7 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) else bAtCenter=true; - Fraction aNeuFact(1,1); + boost::rational<long> 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=Fraction(nMul,nMarkSize); + aNeuFact=boost::rational<long>(nMul,nMarkSize); nWink=nPntWink; } else @@ -3287,7 +3287,7 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) nMul = std::abs(nMul); } - aNeuFact=Fraction(nMul,nDiv); + aNeuFact=boost::rational<long>(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!=Fraction(1,1) && aFact.GetDenominator()!=0 && aFact.IsValid(); + bResize=aFact!=boost::rational<long>(1,1); DragStat().NextMove(aPnt); Show(); } @@ -3310,14 +3310,14 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt) void SdrDragCrook::applyCurrentTransformationToSdrObject(SdrObject& rTarget) { - const bool bDoResize(aFact!=Fraction(1,1)); + const bool bDoResize(aFact!=boost::rational<long>(1,1)); const bool bDoCrook(aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0); if (bDoCrook || bDoResize) { if (bDoResize) { - Fraction aFact1(1,1); + boost::rational<long> aFact1(1,1); if (bContortion) { @@ -3370,7 +3370,7 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) { Hide(); - if (bResize && aFact==Fraction(1,1)) + if (bResize && aFact==boost::rational<long>(1,1)) bResize=false; const bool bUndo = getSdrDragView().IsUndoEnabled(); @@ -3392,7 +3392,7 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) if (bResize) { - Fraction aFact1(1,1); + boost::rational<long> aFact1(1,1); if (bContortion) { diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index 500633aa3ca1..d0a34a13cf08 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 Fraction& xFact, const Fraction& yFact, bool bCopy) +void SdrEditView::ResizeMarkedObj(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bCopy) { const bool bUndo = IsUndoEnabled(); if( bUndo ) @@ -245,8 +245,8 @@ void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, cons EndUndo(); } void SdrEditView::ResizeMultMarkedObj(const Point& rRef, - const Fraction& xFact, - const Fraction& yFact, + const boost::rational<long>& xFact, + const boost::rational<long>& 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)); } - Fraction aFrac(1,1); + boost::rational<long> 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) { - Fraction aXFact=((const SdrResizeXAllItem*)pPoolItem)->GetValue(); - ResizeMarkedObj(aAllSnapRect.TopLeft(),aXFact,Fraction(1,1)); + boost::rational<long> aXFact=((const SdrResizeXAllItem*)pPoolItem)->GetValue(); + ResizeMarkedObj(aAllSnapRect.TopLeft(),aXFact,boost::rational<long>(1,1)); } if (rAttr.GetItemState(SDRATTR_RESIZEYALL,true,&pPoolItem)==SfxItemState::SET) { - Fraction aYFact=((const SdrResizeYAllItem*)pPoolItem)->GetValue(); - ResizeMarkedObj(aAllSnapRect.TopLeft(),Fraction(1,1),aYFact); + boost::rational<long> aYFact=((const SdrResizeYAllItem*)pPoolItem)->GetValue(); + ResizeMarkedObj(aAllSnapRect.TopLeft(),boost::rational<long>(1,1),aYFact); } if (rAttr.GetItemState(SDRATTR_ROTATEALL,true,&pPoolItem)==SfxItemState::SET) { long nAngle=((const SdrRotateAllItem*)pPoolItem)->GetValue(); @@ -1608,8 +1608,8 @@ void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr) // change size and height if (bChgSiz && (bResizeFreeAllowed || bResizePropAllowed)) { - Fraction aWdt(nSizX,aRect.Right()-aRect.Left()); - Fraction aHgt(nSizY,aRect.Bottom()-aRect.Top()); + boost::rational<long> aWdt(nSizX,aRect.Right()-aRect.Left()); + boost::rational<long> 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 c98757922408..5b6a1f4dfcc0 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 = Fraction( 1, 1 ); - maScaleY = Fraction( 1, 1 ); + maScaleX = boost::rational<long>( 1, 1 ); + maScaleY = boost::rational<long>( 1, 1 ); if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1)) { - maScaleX = Fraction(maScaleRect.GetWidth() - 1, aMtfSize.Width()); + maScaleX = boost::rational<long>(maScaleRect.GetWidth() - 1, aMtfSize.Width()); mbSize = true; } if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1)) { - maScaleY = Fraction(maScaleRect.GetHeight() - 1, aMtfSize.Height()); + maScaleY = boost::rational<long>(maScaleRect.GetHeight() - 1, aMtfSize.Height()); mbSize = true; } diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index 16e2dddcc5ce..d394e97463b3 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -63,8 +63,8 @@ protected: Point maOfs; double mfScaleX; double mfScaleY; - Fraction maScaleX; - Fraction maScaleY; + boost::rational<long> maScaleX; + boost::rational<long> maScaleY; bool mbFntDirty; diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx index e6947d92b9f5..279c84631190 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 Fraction*)p2,*(const Fraction*)p3); + ResizePoint(rPt,*(const Point*)p1,*(const boost::rational<long>*)p2,*(const boost::rational<long>*)p3); } -void SdrGlueEditView::ResizeMarkedGluePoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy) +void SdrGlueEditView::ResizeMarkedGluePoints(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bCopy) { ForceUndirtyMrkPnt(); OUString aStr(ImpGetResStr(STR_EditResize)); diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx index e8a03aa36850..be76208d988e 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; - ((SdrFractionItem*)pNewItem)->SetValue(Fraction(nLongX,nLongY)); + ((SdrFractionItem*)pNewItem)->SetValue(boost::rational<long>(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 c197fa7f0dd4..e7171b1c3961 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=Fraction(1,1); + aUIScale=boost::rational<long>(1,1); nUIUnitKomma=0; bUIOnlyKomma=false; pLayerAdmin=NULL; @@ -927,9 +927,9 @@ void SdrModel::SetDefaultTabulator(sal_uInt16 nVal) void SdrModel::ImpSetUIUnit() { - if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator()) + if(0 == aUIScale.numerator()) { - aUIScale = Fraction(1,1); + aUIScale = boost::rational<long>(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 Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv)); - nMul = aTemp.GetNumerator(); - nDiv = aTemp.GetDenominator(); + const boost::rational<long> aTemp(static_cast< long >(nMul), static_cast< long >(nDiv)); + nMul = aTemp.numerator(); + nDiv = aTemp.denominator(); } // #i89872# take Unit of Measurement into account - if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator()) + if(1 != aUIScale.denominator() || 1 != aUIScale.numerator()) { // divide by UIScale - nMul *= aUIScale.GetDenominator(); - nDiv *= aUIScale.GetNumerator(); + nMul *= aUIScale.denominator(); + nDiv *= aUIScale.numerator(); } // shorten trailing zeros for dividend @@ -1043,12 +1043,12 @@ void SdrModel::ImpSetUIUnit() } // end preparations, set member values - aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv)); + aUIUnitFact = boost::rational<long>(sal_Int32(nMul), sal_Int32(nDiv)); bUIOnlyKomma = (nMul == nDiv); TakeUnitStr(eUIUnit, aUIUnitStr); } -void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac) +void SdrModel::SetScaleUnit(MapUnit eMap, const boost::rational<long>& rFrac) { if (eObjUnit!=eMap || aObjUnit!=rFrac) { eObjUnit=eMap; @@ -1073,7 +1073,7 @@ void SdrModel::SetScaleUnit(MapUnit eMap) } } -void SdrModel::SetScaleFraction(const Fraction& rFrac) +void SdrModel::SetScaleFraction(const boost::rational<long>& rFrac) { if (aObjUnit!=rFrac) { aObjUnit=rFrac; @@ -1093,7 +1093,7 @@ void SdrModel::SetUIUnit(FieldUnit eUnit) } } -void SdrModel::SetUIScale(const Fraction& rScale) +void SdrModel::SetUIScale(const boost::rational<long>& rScale) { if (aUIScale!=rScale) { aUIScale=rScale; @@ -1102,7 +1102,7 @@ void SdrModel::SetUIScale(const Fraction& rScale) } } -void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale) +void SdrModel::SetUIUnit(FieldUnit eUnit, const boost::rational<long>& 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) * double(aUIUnitFact)); + double fLocalValue(double(nVal) * boost::rational_cast<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 Fraction& rVal, OUString& rStr, bool bNoPercentChar) const +void SdrModel::TakePercentStr(const boost::rational<long>& rVal, OUString& rStr, bool bNoPercentChar) const { - sal_Int32 nMul(rVal.GetNumerator()); - sal_Int32 nDiv(rVal.GetDenominator()); + sal_Int32 nMul(rVal.numerator()); + sal_Int32 nDiv(rVal.denominator()); bool bNeg(nMul < 0); if(nDiv < 0) diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 687ed35740e4..858772c5ec14 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -1564,15 +1564,15 @@ void SdrObjCustomShape::NbcMove( const Size& rSiz ) mpLastShadowGeometry->NbcMove( rSiz ); } } -void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative ) +void SdrObjCustomShape::Resize( const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bUnsetRelative ) { SdrTextObj::Resize( rRef, xFact, yFact, bUnsetRelative ); } -void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact ) +void SdrObjCustomShape::NbcResize( const Point& rRef, const boost::rational<long>& rxFact, const boost::rational<long>& ryFact ) { - Fraction xFact( rxFact ); - Fraction yFact( ryFact ); + boost::rational<long> xFact( rxFact ); + boost::rational<long> yFact( ryFact ); // taking care of handles that should not been changed Rectangle aOld( aRect ); @@ -1580,16 +1580,16 @@ void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, co SdrTextObj::NbcResize( rRef, xFact, yFact ); - if ( ( xFact.GetNumerator() != xFact.GetDenominator() ) - || ( yFact.GetNumerator()!= yFact.GetDenominator() ) ) + if ( ( xFact.numerator() != xFact.denominator() ) + || ( yFact.numerator()!= yFact.denominator() ) ) { - if ( ( ( xFact.GetNumerator() < 0 ) && ( xFact.GetDenominator() > 0 ) ) || - ( ( xFact.GetNumerator() > 0 ) && ( xFact.GetDenominator() < 0 ) ) ) + if ( ( ( xFact.numerator() < 0 ) && ( xFact.denominator() > 0 ) ) || + ( ( xFact.numerator() > 0 ) && ( xFact.denominator() < 0 ) ) ) { SetMirroredX( IsMirroredX() == false ); } - if ( ( ( yFact.GetNumerator() < 0 ) && ( yFact.GetDenominator() > 0 ) ) || - ( ( yFact.GetNumerator() > 0 ) && ( yFact.GetDenominator() < 0 ) ) ) + if ( ( ( yFact.numerator() < 0 ) && ( yFact.denominator() > 0 ) ) || + ( ( yFact.numerator() > 0 ) && ( yFact.denominator() < 0 ) ) ) { SetMirroredY( IsMirroredY() == false ); } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index a7c12191e318..c98acb0570b6 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); - 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(); + boost::rational<long> aXFact(nXMul,nXDiv); // fractions for canceling + boost::rational<long> aYFact(nYMul,nYDiv); // and for comparing + nXMul=aXFact.numerator(); + nYMul=aYFact.numerator(); + nXDiv=aXFact.denominator(); + nYDiv=aYFact.denominator(); if (bEcke) { // corner point handles bool bUseX=(aXFact<aYFact) != bBigOrtho; if (bUseX) { @@ -1495,10 +1495,10 @@ void SdrObject::NbcMove(const Size& rSiz) SetRectsDirty(); } -void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrObject::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); + bool bXMirr = xFact.numerator() < 0; + bool bYMirr = yFact.numerator() < 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 Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) +void SdrObject::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()) { if (bUnsetRelative) { mnRelativeWidth.reset( ); @@ -2262,15 +2262,15 @@ void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr) if (aNewLogic!=rLogic) { NbcSetLogicRect(aNewLogic); } - Fraction aResizeX(1,1); - Fraction aResizeY(1,1); + boost::rational<long> aResizeX(1,1); + boost::rational<long> aResizeY(1,1); if (rAttr.GetItemState(SDRATTR_RESIZEXONE,true,&pPoolItem)==SfxItemState::SET) { aResizeX*=((const SdrResizeXOneItem*)pPoolItem)->GetValue(); } if (rAttr.GetItemState(SDRATTR_RESIZEYONE,true,&pPoolItem)==SfxItemState::SET) { aResizeY*=((const SdrResizeYOneItem*)pPoolItem)->GetValue(); } - if (aResizeX!=Fraction(1,1) || aResizeY!=Fraction(1,1)) { + if (aResizeX!=boost::rational<long>(1,1) || aResizeY!=boost::rational<long>(1,1)) { NbcResize(aRef1,aResizeX,aResizeY); } } diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index 583222a1cab2..85f7502f9d33 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 Fraction& xFact, const Fraction& yFact) +void SdrCaptionObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& 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 db836dd721e0..81a9c413a95b 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 Fraction& xFact, const Fraction& yFact) +void SdrCircObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { long nWink0=aGeo.nDrehWink; bool bNoShearRota=(aGeo.nDrehWink==0 && aGeo.nShearWink==0); SdrTextObj::NbcResize(rRef,xFact,yFact); bNoShearRota|=(aGeo.nDrehWink==0 && aGeo.nShearWink==0); if (meCircleKind!=OBJ_CIRC) { - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); + bool bXMirr = xFact.numerator() < 0; + bool bYMirr = yFact.numerator() < 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(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); + NbcResize(maSnapRect.TopLeft(),boost::rational<long>(nWdt1,nWdt0),boost::rational<long>(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 a743cc3ce901..c73a6d167f73 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; } - Fraction aX(nMulX, nDivX); - Fraction aY(nMulY, nDivY); + boost::rational<long> aX(nMulX, nDivX); + boost::rational<long> 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 Fraction& aXFact, const Fraction& aYFact) +void SdrEdgeObj::NbcResize(const Point& rRefPnt, const boost::rational<long>& aXFact, const boost::rational<long>& 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 8c6a4892435b..b101d0311bff 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 Fraction& xFact, const Fraction& yFact) +void SdrGrafObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { SdrRectObj::NbcResize( rRef, xFact, yFact ); - bool bMirrX = xFact.GetNumerator() < 0; - bool bMirrY = yFact.GetNumerator() < 0; + bool bMirrX = xFact.numerator() < 0; + bool bMirrY = yFact.numerator() < 0; if( bMirrX != bMirrY ) bMirrored = !bMirrored; diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index 87634138df20..dd79cc445854 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) { - Fraction aX(nMulX,nDivX); - Fraction aY(nMulY,nDivY); + boost::rational<long> aX(nMulX,nDivX); + boost::rational<long> 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 Fraction& xFact, const Fraction& yFact) +void SdrObjGroup::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); + bool bXMirr = xFact.numerator() < 0; + bool bYMirr = yFact.numerator() < 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) { - Fraction aX(nMulX,nDivX); - Fraction aY(nMulY,nDivY); + boost::rational<long> aX(nMulX,nDivX); + boost::rational<long> 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 Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) +void SdrObjGroup::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()) { - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); + if (xFact.numerator()!=xFact.denominator() || yFact.numerator()!=yFact.denominator()) { + bool bXMirr = xFact.numerator() < 0; + bool bYMirr = yFact.numerator() < 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 007c97350afa..dd3998b21d72 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; - Fraction aMeasureScale(1, 1); + boost::rational<long> 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)); - Fraction aFact(1,1); + boost::rational<long> aFact(1,1); if(eMeasureUnit != eModUIUnit) { @@ -113,27 +113,21 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X(); } - if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator()) + if(aMeasureScale.numerator() != aMeasureScale.denominator()) { aFact *= aMeasureScale; } - if(aFact.GetNumerator() != aFact.GetDenominator()) + if(aFact.numerator() != aFact.denominator()) { // scale via BigInt, to avoid overruns - nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator()); + nLen = BigMulDiv(nLen, aFact.numerator(), aFact.denominator()); } 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) @@ -281,7 +275,7 @@ struct ImpMeasureRec : public SdrDragStatUserData bool bTextUpsideDown; long nMeasureOverhang; FieldUnit eMeasureUnit; - Fraction aMeasureScale; + boost::rational<long> aMeasureScale; bool bShowUnit; OUString aFormatString; bool bTextAutoAngle; @@ -1035,7 +1029,7 @@ void SdrMeasureObj::NbcMove(const Size& rSiz) MovePoint(aPt2,rSiz); } -void SdrMeasureObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrMeasureObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& 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 df431560a8d2..cb9dd89ffc04 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; - Fraction m_aScaleWidth; - Fraction m_aScaleHeight; + boost::rational<long> m_aScaleWidth; + boost::rational<long> m_aScaleHeight; public: SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj ); void Release(); - void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight ) + void SetSizeScale( const boost::rational<long>& aScaleWidth, const boost::rational<long>& aScaleHeight ) { m_aScaleWidth = aScaleWidth; m_aScaleHeight = aScaleHeight; } - Fraction GetScaleWidth() const { return m_aScaleWidth; } - Fraction GetScaleHeight() const { return m_aScaleHeight; } + boost::rational<long> GetScaleWidth() const { return m_aScaleWidth; } + boost::rational<long> 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( Fraction( aLogicRect.GetWidth() ) * m_aScaleWidth, - Fraction( aLogicRect.GetHeight() ) * m_aScaleHeight ) ); + aLogicRect.SetSize( Size( boost::rational_cast<long>(aLogicRect.GetWidth() * m_aScaleWidth), + boost::rational_cast<long>(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( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ), - static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) ); + Size aScaledSize( boost::rational_cast<long>( m_aScaleWidth * aVisArea.GetWidth() ), + boost::rational_cast<long>( m_aScaleHeight * 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( Fraction( aNewLogicRect.GetWidth() ) / m_aScaleWidth, - Fraction( aNewLogicRect.GetHeight() ) / m_aScaleHeight ); + Size aNewObjSize( boost::rational_cast<long>(aNewLogicRect.GetWidth() / m_aScaleWidth), + boost::rational_cast<long>(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 ) { - Fraction aScaleWidth; - Fraction aScaleHeight; + boost::rational<long> aScaleWidth; + boost::rational<long> 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( (long)( Fraction( aRect.GetWidth() ) / aScaleWidth ), - (long)( Fraction( aRect.GetHeight() ) / aScaleHeight ) ); + Size aVisSize( boost::rational_cast<long>(aRect.GetWidth() / aScaleWidth), + boost::rational_cast<long>(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( (long)( Fraction( long( aSz.Width ) ) * aScaleWidth ), - (long)( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) ); + aAcceptedVisArea.SetSize( Size( boost::rational_cast<long>(long(aSz.Width) * aScaleWidth), + boost::rational_cast<long>(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 - Fraction aScaleWidth; - Fraction aScaleHeight; + boost::rational<long> aScaleWidth; + boost::rational<long> aScaleHeight; Size aObjAreaSize; if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) { @@ -1865,7 +1865,7 @@ void SdrOle2Obj::ImpSetVisAreaSize() -void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrOle2Obj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { if( pModel && !pModel->isLocked() ) { @@ -2211,7 +2211,7 @@ uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const } -bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize ) +bool SdrOle2Obj::CalculateNewScaling( boost::rational<long>& aScaleWidth, boost::rational<long>& 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( Fraction& aScaleWidth, Fraction& aScaleHei aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode ); Size aSize = aRect.GetSize(); - aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() ); - aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() ); + aScaleWidth = boost::rational<long>(aSize.Width(), aObjAreaSize.Width() ); + aScaleHeight = boost::rational<long>(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 ) { - Fraction aScaleWidth; - Fraction aScaleHeight; + boost::rational<long> aScaleWidth; + boost::rational<long> aScaleHeight; Size aObjAreaSize; if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) { diff --git a/svx/source/svdraw/svdoopengl.cxx b/svx/source/svdraw/svdoopengl.cxx index 1b3398359c83..b1e8e8f0e945 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 Fraction& xFact, const Fraction& yFact) +void SdrOpenGLObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { SdrObject::NbcResize(rRef, xFact, yFact); diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 702493ea69c9..7a20ab068ce2 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 Fraction& xFact, const Fraction& yFact) +void SdrPathObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRef.X(), -rRef.Y())); aTrans = basegfx::tools::createScaleTranslateB2DHomMatrix( - double(xFact), double(yFact), rRef.X(), rRef.Y()) * aTrans; + boost::rational_cast<double>(xFact), boost::rational_cast<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; } - Fraction aX(nMulX,nDivX); - Fraction aY(nMulY,nDivY); + boost::rational<long> aX(nMulX,nDivX); + boost::rational<long> 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 387f57910cde..75385b40e995 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 Fraction& xFact, const Fraction& yFact) +void SdrRectObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { SdrTextObj::NbcResize(rRef,xFact,yFact); SetXPolyDirty(); diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 011418d57844..bdf85d0e5c69 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -871,7 +871,7 @@ OutlinerParaObject* SdrTextObj::GetEditOutlinerParaObject() const return pPara; } -void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, Fraction& rFitXKorreg) const +void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, boost::rational<long>& rFitXKorreg) const { OutputDevice* pOut = rOutliner.GetRefDevice(); bool bNoStretching(false); @@ -963,7 +963,7 @@ void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextS nLoopCount++; Size aSiz(rOutliner.CalcTextSize()); long nXDiff=aSiz.Width()-nWantWdt; - rFitXKorreg=Fraction(nWantWdt,aSiz.Width()); + rFitXKorreg=boost::rational<long>(nWantWdt,aSiz.Width()); if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || nXDiff==nXDiff0) { bNoMoreLoop = true; } else { @@ -1245,7 +1245,7 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame, Rectangle& rTextRect, Rectangle& rAnchorRect, Rectangle& rPaintRect, - Fraction& rFitXKorreg ) const + boost::rational<long>& rFitXKorreg ) const { if (!bContourFrame) { @@ -1349,7 +1349,7 @@ void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaint { Rectangle aTextRect; Rectangle aAnchorRect; - Fraction aFitXKorreg(1,1); + boost::rational<long> aFitXKorreg(1,1); bool bContourFrame=IsContourTextFrame(); @@ -1837,7 +1837,7 @@ GDIMetaFile* SdrTextObj::GetTextScrollMetaFileAndRectangle( Rectangle aTextRect; Rectangle aAnchorRect; Rectangle aPaintRect; - Fraction aFitXKorreg(1,1); + boost::rational<long> 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 dd00cee48de7..d7d563157c8d 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); - 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(); + boost::rational<long> aXFact(nXMul,nXDiv); // fractions for canceling + boost::rational<long> aYFact(nYMul,nYDiv); // and for comparing + nXMul=aXFact.numerator(); + nYMul=aYFact.numerator(); + nXDiv=aXFact.denominator(); + nYDiv=aYFact.denominator(); if (bEcke) { // corner point handles bool bUseX=(aXFact<aYFact) != bBigOrtho; if (bUseX) { diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx index 4c7754ed074d..1f5693854f57 100644 --- a/svx/source/svdraw/svdotxed.cxx +++ b/svx/source/svdraw/svdotxed.cxx @@ -95,7 +95,7 @@ bool SdrTextObj::BegTextEdit(SdrOutliner& rOutl) Rectangle aTextRect; TakeTextRect(rOutl, aTextRect, false, &aAnchorRect); - Fraction aFitXKorreg(1,1); + boost::rational<long> 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 e4da47df32eb..b627d591fbed 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -48,7 +48,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(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); + SdrTextObj::NbcResize(maSnapRect.TopLeft(),boost::rational<long>(nWdt1,nWdt0),boost::rational<long>(nHgt1,nHgt0)); SdrTextObj::NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top())); } else { long nHDist=GetTextLeftDistance()+GetTextRightDistance(); @@ -118,7 +118,7 @@ void SdrTextObj::NbcMove(const Size& rSiz) SetRectsDirty(true); } -void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrTextObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { bool bNoShearMerk=aGeo.nShearWink==0; bool bRota90Merk=bNoShearMerk && aGeo.nDrehWink % 9000 ==0; @@ -126,8 +126,8 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract 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.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); + bool bXMirr = xFact.numerator() < 0; + bool bYMirr = yFact.numerator() < 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 3c5f21ede3c0..eceb1f3f9844 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 Fraction& xFact, const Fraction& yFact) +void SdrUnoObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { SdrRectObj::NbcResize(rRef,xFact,yFact); diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index 122e8a59477c..ae99c80b2e5c 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 Fraction& xFact, const Fraction& yFact) +void SdrVirtObj::NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& 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 Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) +void SdrVirtObj::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!=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 4eb1b6d1981c..e7a713ec74f5 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 - Fraction aXFact(aNewSize.Width(),aActualSize.Width()); - Fraction aYFact(aNewSize.Height(),aActualSize.Height()); + boost::rational<long> aXFact(aNewSize.Width(),aActualSize.Width()); + boost::rational<long> aYFact(aNewSize.Height(),aActualSize.Height()); if (aYFact>aXFact) aXFact=aYFact; aXFact*=aMap.GetScaleX(); - aXFact.ReduceInaccurate(10); // to avoid runovers and BigInt mapping + rational_ReduceInaccurate(aXFact, 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 2d9394db6b2c..8ee050116a7c 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 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); + ResizePoint(rPt,*(const Point*)p1,*(const boost::rational<long>*)p2,*(const boost::rational<long>*)p3); + if (pC1!=NULL) ResizePoint(*pC1,*(const Point*)p1,*(const boost::rational<long>*)p2,*(const boost::rational<long>*)p3); + if (pC2!=NULL) ResizePoint(*pC2,*(const Point*)p1,*(const boost::rational<long>*)p2,*(const boost::rational<long>*)p3); } -void SdrPolyEditView::ResizeMarkedPoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrPolyEditView::ResizeMarkedPoints(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { ForceUndirtyMrkPnt(); OUString aStr(ImpGetResStr(STR_EditResize)); diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx index 00a61b109137..c80176c79725 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 = aSnapWdtX; + double fSnapWidth = boost::rational_cast<double>(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 = aSnapWdtY; + fSnapWidth = boost::rational_cast<double>(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 ed99ae31008f..acd1546b1cad 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) { - Fraction aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X(); + boost::rational<long> aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X(); if (bSetHgtItem) { // Now correct the frame attribute - nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.GetNumerator(),aMetricFactor.GetDenominator()); + nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.numerator(),aMetricFactor.denominator()); SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT)); } } diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx index 10ea4007a055..442f3e71d532 100644 --- a/svx/source/svdraw/svdtrans.cxx +++ b/svx/source/svdraw/svdtrans.cxx @@ -32,46 +32,20 @@ void MoveXPoly(XPolygon& rPoly, const Size& S) rPoly.Move(S.Width(),S.Height()); } -void ResizeRect(Rectangle& rRect, const Point& rRef, const Fraction& rxFact, const Fraction& ryFact, bool bNoJustify) +void ResizeRect(Rectangle& rRect, const Point& rRef, const boost::rational<long>& rxFact, const boost::rational<long>& ryFact, bool bNoJustify) { - Fraction xFact(rxFact); - Fraction yFact(ryFact); + boost::rational<long> xFact(rxFact); + boost::rational<long> yFact(ryFact); - { - 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()); - } + 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 (!bNoJustify) rRect.Justify(); } -void ResizePoly(Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void ResizePoly(Polygon& rPoly, const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { sal_uInt16 nAnz=rPoly.GetSize(); for (sal_uInt16 i=0; i<nAnz; i++) { @@ -79,7 +53,7 @@ void ResizePoly(Polygon& rPoly, const Point& rRef, const Fraction& xFact, const } } -void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) { sal_uInt16 nAnz=rPoly.GetPointCount(); for (sal_uInt16 i=0; i<nAnz; i++) { @@ -596,10 +570,10 @@ long BigMulDiv(long nVal, long nMul, long nDiv) return 0x7fffffff; } -void Kuerzen(Fraction& rF, unsigned nDigits) +void Kuerzen(boost::rational<long>& rF, unsigned nDigits) { - sal_Int32 nMul=rF.GetNumerator(); - sal_Int32 nDiv=rF.GetDenominator(); + sal_Int32 nMul=rF.numerator(); + sal_Int32 nDiv=rF.denominator(); bool bNeg = false; if (nMul<0) { nMul=-nMul; bNeg=!bNeg; } if (nDiv<0) { nDiv=-nDiv; bNeg=!bNeg; } @@ -625,7 +599,7 @@ void Kuerzen(Fraction& rF, unsigned nDigits) return; } if (bNeg) nMul=-nMul; - rF=Fraction(nMul,nDiv); + rF=boost::rational<long>(nMul,nDiv); } @@ -661,7 +635,7 @@ FrPair GetInchOrMM(MapUnit eU) } default: break; } - return Fraction(1,1); + return boost::rational<long>(1,1); } FrPair GetInchOrMM(FieldUnit eU) @@ -680,7 +654,7 @@ FrPair GetInchOrMM(FieldUnit eU) case FUNIT_MILE : return FrPair( 1,63360); default: break; } - return Fraction(1,1); + return boost::rational<long>(1,1); } // Calculate the factor that we need to convert units from eS to eD. @@ -694,8 +668,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()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); } - if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); } + if (bSInch && !bDInch) { aRet.X()*=boost::rational<long>(127,5); aRet.Y()*=boost::rational<long>(127,5); } + if (!bSInch && bDInch) { aRet.X()*=boost::rational<long>(5,127); aRet.Y()*=boost::rational<long>(5,127); } return aRet; }; @@ -707,8 +681,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()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); } - if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); } + if (bSInch && !bDInch) { aRet.X()*=boost::rational<long>(127,5); aRet.Y()*=boost::rational<long>(127,5); } + if (!bSInch && bDInch) { aRet.X()*=boost::rational<long>(5,127); aRet.Y()*=boost::rational<long>(5,127); } return aRet; }; @@ -789,7 +763,7 @@ void GetMeterOrInch(FieldUnit eFU, short& rnKomma, long& rnMul, long& rnDiv, boo void SdrFormatter::Undirty() { - if (aScale.GetNumerator()==0 || aScale.GetDenominator()==0) aScale=Fraction(1,1); + if (aScale.numerator()==0) aScale=boost::rational<long>(1,1); bool bSrcMetr,bSrcInch,bDstMetr,bDstInch; long nMul1,nDiv1,nMul2,nDiv2; short nKomma1,nKomma2; @@ -818,9 +792,9 @@ void SdrFormatter::Undirty() } // temporary fraction for canceling - Fraction aTempFract(nMul1,nDiv1); - nMul1=aTempFract.GetNumerator(); - nDiv1=aTempFract.GetDenominator(); + boost::rational<long> aTempFract(nMul1,nDiv1); + nMul1=aTempFract.numerator(); + nDiv1=aTempFract.denominator(); nMul_=nMul1; nDiv_=nDiv1; diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx index 981659fb2bc4..e3a50cd0135e 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) { - Fraction aX(aTextRect.GetWidth()-1,aAnchor.GetWidth()-1); - Fraction aY(aTextRect.GetHeight()-1,aAnchor.GetHeight()-1); + boost::rational<long> aX(aTextRect.GetWidth()-1,aAnchor.GetWidth()-1); + boost::rational<long> 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 fc4e732e4851..1b070a17f1f2 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(); - Fraction aMap=pMod->GetScaleFraction(); + boost::rational<long> 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(); - Fraction aMap=pMod->GetScaleFraction(); + boost::rational<long> 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; - Fraction xResize,yResize; + boost::rational<long> 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)); - 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(); + boost::rational<long> 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(); long xs=nSizX; long ys=nSizY; Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2); |