diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-12 09:31:42 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-13 13:38:26 +0100 |
commit | d55e0fbde49ad3b1e678419588dd58df6d9e06c4 (patch) | |
tree | 4c448d5a759829f4e7b6e5e594db83dd3a926009 | |
parent | 811b77e0f63b91eeb05311c724e3e209bff30f68 (diff) |
Revert "remove BigInt::operator tools::Long()"
This reverts commit 1397a1c8e4995b0dd336478e564880fe8ad91d1d.
Reason for revert: Some discussion required
Change-Id: Id39ee8260790e0722c5bf8338b0b76ca34da83d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105539
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/editeng/itemtype.hxx | 2 | ||||
-rw-r--r-- | include/tools/bigint.hxx | 14 | ||||
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv1.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdotxdr.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdtrans.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdxcgv.cxx | 4 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh1.cxx | 4 | ||||
-rw-r--r-- | tools/source/generic/poly.cxx | 4 | ||||
-rw-r--r-- | vcl/source/control/longcurr.cxx | 8 | ||||
-rw-r--r-- | vcl/source/filter/wmf/wmfwr.cxx | 4 | ||||
-rw-r--r-- | vcl/source/outdev/map.cxx | 12 |
14 files changed, 48 insertions, 34 deletions
diff --git a/include/editeng/itemtype.hxx b/include/editeng/itemtype.hxx index 9adcb98cb370..19d2a19b4ee3 100644 --- a/include/editeng/itemtype.hxx +++ b/include/editeng/itemtype.hxx @@ -42,7 +42,7 @@ inline tools::Long Scale( tools::Long nVal, tools::Long nMult, tools::Long nDiv aVal *= nMult; aVal += nDiv/2; aVal /= nDiv; - return static_cast<sal_Int32>(aVal); + return aVal; } #endif diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx index 6683f07e3121..db8c3bcd1b1c 100644 --- a/include/tools/bigint.hxx +++ b/include/tools/bigint.hxx @@ -88,6 +88,9 @@ public: operator sal_Int32() const; operator sal_uInt32() const; operator double() const; +#if SAL_TYPES_SIZEOFPOINTER == 8 + operator tools::Long() const; +#endif bool IsSet() const { return bIsSet; } bool IsNeg() const; @@ -153,6 +156,17 @@ inline BigInt::operator sal_uInt32() const return 0; } +#if SAL_TYPES_SIZEOFPOINTER == 8 +inline BigInt::operator tools::Long() const +{ + // Clamp to int32 since long is int32 on Windows. + if (!bIsBig) + return nVal; + assert(false && "out of range"); + return 0; +} +#endif + inline BigInt& BigInt::operator =( sal_Int32 nValue ) { bIsSet = true; diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 58aa365e02ae..2e007ea7d513 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -855,7 +855,7 @@ void SdrMetricItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv) aVal*=nMul; aVal+=nDiv/2; // to round accurately aVal/=nDiv; - SetValue(sal_Int32(aVal)); + SetValue(tools::Long(aVal)); } } diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index 5f98c816c65f..0beba3a215aa 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -131,10 +131,10 @@ void SdrEditView::SetMarkedObjRect(const tools::Rectangle& rRect) } else { t=0; b=h1; } - aR1.SetLeft(sal_Int32(l) ); - aR1.SetRight(sal_Int32(r) ); - aR1.SetTop(sal_Int32(t) ); - aR1.SetBottom(sal_Int32(b) ); + aR1.SetLeft(tools::Long(l) ); + aR1.SetRight(tools::Long(r) ); + aR1.SetTop(tools::Long(t) ); + aR1.SetBottom(tools::Long(b) ); aR1.Move(x1,y1); } pO->SetSnapRect(aR1); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 6b2db29caf7d..638c590a52cd 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1236,12 +1236,12 @@ tools::Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const if (bEcke) { // corner point handles bool bUseX=(aXFact<aYFact) != bBigOrtho; if (bUseX) { - tools::Long nNeed=sal_Int32(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv)); + tools::Long nNeed=tools::Long(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv)); if (bYNeg) nNeed=-nNeed; if (bTop) aTmpRect.SetTop(aTmpRect.Bottom()-nNeed ); if (bBtm) aTmpRect.SetBottom(aTmpRect.Top()+nNeed ); } else { - tools::Long nNeed=sal_Int32(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv)); + tools::Long nNeed=tools::Long(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv)); if (bXNeg) nNeed=-nNeed; if (bLft) aTmpRect.SetLeft(aTmpRect.Right()-nNeed ); if (bRgt) aTmpRect.SetRight(aTmpRect.Left()+nNeed ); @@ -1249,13 +1249,13 @@ tools::Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const } else { // apex handles if ((bLft || bRgt) && nXDiv!=0) { tools::Long nHgt0b=aRect.Bottom()-aRect.Top(); - tools::Long nNeed=sal_Int32(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv)); + tools::Long nNeed=tools::Long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv)); aTmpRect.AdjustTop( -((nNeed-nHgt0b)/2) ); aTmpRect.SetBottom(aTmpRect.Top()+nNeed ); } if ((bTop || bBtm) && nYDiv!=0) { tools::Long nWdt0b=aRect.Right()-aRect.Left(); - tools::Long nNeed=sal_Int32(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv)); + tools::Long nNeed=tools::Long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv)); aTmpRect.AdjustLeft( -((nNeed-nWdt0b)/2) ); aTmpRect.SetRight(aTmpRect.Left()+nNeed ); } diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx index 429f30df1106..86adbdac2daa 100644 --- a/svx/source/svdraw/svdotxdr.cxx +++ b/svx/source/svdraw/svdotxdr.cxx @@ -113,12 +113,12 @@ tools::Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const if (bEcke) { // corner point handles bool bUseX=(aXFact<aYFact) != bBigOrtho; if (bUseX) { - tools::Long nNeed=sal_Int32(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv)); + tools::Long nNeed=tools::Long(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv)); if (bYNeg) nNeed=-nNeed; if (bTop) aTmpRect.SetTop(aTmpRect.Bottom()-nNeed ); if (bBtm) aTmpRect.SetBottom(aTmpRect.Top()+nNeed ); } else { - tools::Long nNeed=sal_Int32(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv)); + tools::Long nNeed=tools::Long(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv)); if (bXNeg) nNeed=-nNeed; if (bLft) aTmpRect.SetLeft(aTmpRect.Right()-nNeed ); if (bRgt) aTmpRect.SetRight(aTmpRect.Left()+nNeed ); @@ -126,13 +126,13 @@ tools::Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const } else { // apex handles if ((bLft || bRgt) && nXDiv!=0) { tools::Long nHgt0b=maRect.Bottom()-maRect.Top(); - tools::Long nNeed=sal_Int32(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv)); + tools::Long nNeed=tools::Long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv)); aTmpRect.AdjustTop( -((nNeed-nHgt0b)/2) ); aTmpRect.SetBottom(aTmpRect.Top()+nNeed ); } if ((bTop || bBtm) && nYDiv!=0) { tools::Long nWdt0b=maRect.Right()-maRect.Left(); - tools::Long nNeed=sal_Int32(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv)); + tools::Long nNeed=tools::Long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv)); aTmpRect.AdjustLeft( -((nNeed-nWdt0b)/2) ); aTmpRect.SetRight(aTmpRect.Left()+nNeed ); } diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx index a098606ada05..f225e3d5d6b6 100644 --- a/svx/source/svdraw/svdtrans.cxx +++ b/svx/source/svdraw/svdtrans.cxx @@ -568,7 +568,7 @@ tools::Long BigMulDiv(tools::Long nVal, tools::Long nMul, tools::Long nDiv) if(nDiv) { aVal/=nDiv; - return sal_Int32(aVal); + return tools::Long(aVal); } return 0x7fffffff; } diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index e658f0f4d1b2..21d0451e7f3c 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -402,8 +402,8 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po nSizX *= aDstFr.GetDenominator(); nSizY *= double(aMapFact.Y() * rMap.GetScaleY()); nSizY /= aDstFr.GetNumerator(); - tools::Long xs=sal_Int32(nSizX); - tools::Long ys=sal_Int32(nSizY); + tools::Long xs=nSizX; + tools::Long ys=nSizY; Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2); tools::Rectangle aR(aPos.X(),aPos.Y(),aPos.X()+xs,aPos.Y()+ys); pObj->SetLogicRect(aR); diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 072448f7121c..f8b532ab554e 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -103,7 +103,7 @@ static tools::Long ScaleMetricValue( tools::Long nVal, tools::Long nMul, tools:: aVal/=nDiv; - return sal_Int32( aVal ); + return tools::Long( aVal ); } NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, sal_Int32 nIndex) : diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 1bab729db9a5..8251a9978142 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -337,13 +337,13 @@ void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter, if( aGrfSize.Width() > aBound.Width() ) { aGrfSize.setWidth( aBound.Width() ); - aGrfSize.setHeight( sal_Int32(BigInt(aBound.Width()) * aTempHeight / aTempWidth) ); + aGrfSize.setHeight( BigInt(aBound.Width()) * aTempHeight / aTempWidth ); } // Fit height if necessary, scale down the width proportional thereafter. if( aGrfSize.Height() > aBound.Height() ) { aGrfSize.setHeight( aBound.Height() ); - aGrfSize.setWidth( sal_Int32(BigInt(aBound.Height()) * aTempWidth / aTempHeight) ); + aGrfSize.setWidth( BigInt(aBound.Height()) * aTempWidth / aTempHeight ); } pFrameMgr->SetSize( aGrfSize ); pFrameMgr->UpdateFlyFrame(); diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 06f1c1787b2b..c25783764f27 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -774,7 +774,7 @@ Point ImplEdgePointFilter::EdgeSection( const Point& rPoint, int nEdge ) const else ady += mn/2; ady /= mn; - nNewX = static_cast<sal_Int32>(ady) + lx; + nNewX = static_cast<tools::Long>(ady) + lx; } } else @@ -800,7 +800,7 @@ Point ImplEdgePointFilter::EdgeSection( const Point& rPoint, int nEdge ) const else adx += md/2; adx /= md; - nNewY = static_cast<sal_Int32>(adx) + ly; + nNewY = static_cast<tools::Long>(adx) + ly; } } diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx index 192dc727dc48..5025c1d68ef0 100644 --- a/vcl/source/control/longcurr.cxx +++ b/vcl/source/control/longcurr.cxx @@ -52,8 +52,8 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt { SAL_WARN_IF( nDigits >= 10, "vcl", "LongCurrency may only have 9 decimal places" ); - if ( rNumber.IsZero() || static_cast<sal_Int32>(rNumber) ) - return rLocaleDataWrapper.getCurr( static_cast<sal_Int32>(rNumber), nDigits, rCurrSymbol, bShowThousandSep ); + if ( rNumber.IsZero() || static_cast<tools::Long>(rNumber) ) + return rLocaleDataWrapper.getCurr( static_cast<tools::Long>(rNumber), nDigits, rCurrSymbol, bShowThousandSep ); BigInt aTmp( ImplPower10( nDigits ) ); BigInt aInteger( rNumber ); @@ -70,7 +70,7 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt if ( rNumber.IsNeg() ) aFraction *= -1; - OUStringBuffer aTemplate = rLocaleDataWrapper.getCurr( static_cast<sal_Int32>(aFraction), nDigits, rCurrSymbol, bShowThousandSep ); + OUStringBuffer aTemplate = rLocaleDataWrapper.getCurr( static_cast<tools::Long>(aFraction), nDigits, rCurrSymbol, bShowThousandSep ); while( !aInteger.IsZero() ) { aFraction = aInteger; @@ -79,7 +79,7 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt if( !aInteger.IsZero() ) aFraction += aTmp; - OUString aFractionStr = rLocaleDataWrapper.getNum( static_cast<sal_Int32>(aFraction), 0 ); + OUString aFractionStr = rLocaleDataWrapper.getNum( static_cast<tools::Long>(aFraction), 0 ); sal_Int32 nSPos = aTemplate.indexOf( '1' ); if (nSPos == -1) diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index c7d7e3cc57da..515468386488 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -1412,7 +1412,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else aX += BigInt( aScaleX.GetNumerator()/2 ); aX /= BigInt( aScaleX.GetNumerator() ); - aOrigin.setX( static_cast<sal_Int32>(aX) + aMM.GetOrigin().X() ); + aOrigin.setX( static_cast<tools::Long>(aX) + aMM.GetOrigin().X() ); BigInt aY( aOrigin.Y() ); aY *= BigInt( aScaleY.GetDenominator() ); if( aOrigin.Y() >= 0 ) @@ -1426,7 +1426,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else aY += BigInt( aScaleY.GetNumerator()/2 ); aY /= BigInt( aScaleY.GetNumerator() ); - aOrigin.setY( static_cast<sal_Int32>(aY) + aMM.GetOrigin().Y() ); + aOrigin.setY( static_cast<tools::Long>(aY) + aMM.GetOrigin().Y() ); aSrcMapMode.SetOrigin( aOrigin ); aScaleX *= aSrcMapMode.GetScaleX(); diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 7af0649e2ef5..aba22cb4ef1f 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -279,7 +279,7 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, aX += BigInt(nXNumerator / 2); } aX /= BigInt(nXNumerator); - rMapRes.mnMapOfsX = static_cast<sal_Int32>(aX) + aOrigin.X(); + rMapRes.mnMapOfsX = static_cast<tools::Long>(aX) + aOrigin.X(); BigInt aY( rMapRes.mnMapOfsY ); aY *= BigInt( aScaleY.GetDenominator() ); if( rMapRes.mnMapOfsY >= 0 ) @@ -297,7 +297,7 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, aY += BigInt(nYNumerator / 2); } aY /= BigInt(nYNumerator); - rMapRes.mnMapOfsY = static_cast<sal_Int32>(aY) + aOrigin.Y(); + rMapRes.mnMapOfsY = static_cast<tools::Long>(aY) + aOrigin.Y(); } // calculate scaling factor according to MapMode @@ -1560,7 +1560,7 @@ static tools::Long fn5( const tools::Long n1, a7 /= n8; } // of else - return static_cast<sal_Int32>(a7); + return static_cast<tools::Long>(a7); } // of if else { @@ -1596,7 +1596,7 @@ static tools::Long fn5( const tools::Long n1, a7 /= n8; } // of else - return static_cast<sal_Int32>(a7); + return static_cast<tools::Long>(a7); } // of if else { @@ -1616,7 +1616,7 @@ static tools::Long fn5( const tools::Long n1, a7 += a9; a7 /= a8; - return static_cast<sal_Int32>(a7); + return static_cast<tools::Long>(a7); } // of if else { @@ -1653,7 +1653,7 @@ static tools::Long fn3( const tools::Long n1, const tools::Long n2, const tools: a4 += n3 / 2; a4 /= n3; - return static_cast<sal_Int32>(a4); + return static_cast<tools::Long>(a4); } // of if else { |