summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-08-03 14:24:10 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-08-03 15:35:55 +0200
commitb5b601b1a56891d46f126d4d1a561c201de7300b (patch)
tree62be9b7c79373b2dbd2dc6d18bcaf5295329d097
parentforcepoint#70 give all escher client data objects a common parent class (diff)
downloadcore-b5b601b1a56891d46f126d4d1a561c201de7300b.tar.gz
core-b5b601b1a56891d46f126d4d1a561c201de7300b.zip
Remove svx::Round; use FRound from tools instead
Change-Id: Idb8d16f59823d9065b82d6312def36601457af1a Reviewed-on: https://gerrit.libreoffice.org/58546 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--include/svx/svdtrans.hxx17
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx4
-rw-r--r--svx/source/svdraw/svdedtv1.cxx4
-rw-r--r--svx/source/svdraw/svdocirc.cxx8
-rw-r--r--svx/source/svdraw/svdomeas.cxx16
-rw-r--r--svx/source/svdraw/svdopath.cxx14
-rw-r--r--svx/source/svdraw/svdorect.cxx2
-rw-r--r--svx/source/svdraw/svdtrans.cxx24
8 files changed, 43 insertions, 46 deletions
diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx
index 75a1bcff5789..89b29d4b5903 100644
--- a/include/svx/svdtrans.hxx
+++ b/include/svx/svdtrans.hxx
@@ -25,6 +25,7 @@
#include <svx/svxdllapi.h>
#include <tools/fract.hxx>
#include <tools/gen.hxx>
+#include <tools/helpers.hxx>
#include <tools/poly.hxx>
#include <vcl/field.hxx>
#include <vcl/mapmod.hxx>
@@ -49,10 +50,6 @@ const double nPi180=0.000174532925199432957692222; // If we have too few digits,
class XPolygon;
class XPolyPolygon;
-namespace svx
-{
- inline long Round(double a) { return a>0.0 ? static_cast<long>(a+0.5) : -static_cast<long>((-a)+0.5); }
-}
inline void MovePoly(tools::Polygon& rPoly, const Size& S) { rPoly.Move(S.Width(),S.Height()); }
void MoveXPoly(XPolygon& rPoly, const Size& S);
@@ -113,27 +110,27 @@ inline void ResizePoint(Point& rPnt, const Point& rRef, const Fraction& xFract,
{
double nxFract = xFract.IsValid() ? static_cast<double>(xFract) : 1.0;
double nyFract = yFract.IsValid() ? static_cast<double>(yFract) : 1.0;
- rPnt.setX(rRef.X() + svx::Round( (rPnt.X() - rRef.X()) * nxFract ));
- rPnt.setY(rRef.Y() + svx::Round( (rPnt.Y() - rRef.Y()) * nyFract ));
+ rPnt.setX(rRef.X() + FRound( (rPnt.X() - rRef.X()) * nxFract ));
+ rPnt.setY(rRef.Y() + FRound( (rPnt.Y() - rRef.Y()) * nyFract ));
}
inline void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs)
{
long dx=rPnt.X()-rRef.X();
long dy=rPnt.Y()-rRef.Y();
- rPnt.setX(svx::Round(rRef.X()+dx*cs+dy*sn));
- rPnt.setY(svx::Round(rRef.Y()+dy*cs-dx*sn));
+ rPnt.setX(FRound(rRef.X()+dx*cs+dy*sn));
+ rPnt.setY(FRound(rRef.Y()+dy*cs-dx*sn));
}
inline void ShearPoint(Point& rPnt, const Point& rRef, double tn, bool bVShear)
{
if (!bVShear) { // Horizontal
if (rPnt.Y()!=rRef.Y()) { // else not needed
- rPnt.AdjustX(-svx::Round((rPnt.Y()-rRef.Y())*tn));
+ rPnt.AdjustX(-FRound((rPnt.Y()-rRef.Y())*tn));
}
} else { // or else vertical
if (rPnt.X()!=rRef.X()) { // else not needed
- rPnt.AdjustY(-svx::Round((rPnt.X()-rRef.X())*tn));
+ rPnt.AdjustY(-FRound((rPnt.X()-rRef.X())*tn));
}
}
}
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index ea6e526e6054..6c64f2e9de23 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1150,9 +1150,9 @@ bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& r
double fY =-dx * sin( a );
rReturnPosition =
Point(
- svx::Round( fX + aReferencePoint.X() ),
+ FRound( fX + aReferencePoint.X() ),
basegfx::fTools::equalZero(fXScale) ? aReferencePoint.Y() :
- svx::Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) );
+ FRound( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) );
}
else
{
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 9b1a5e269225..93d1d87850d4 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -563,7 +563,7 @@ void SdrEditView::ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRa
aCtr1 -= aCtr0;
if(bRotOk)
- pO->Rotate(aCtr0, svx::Round(nAngle/nPi180), nSin, nCos);
+ pO->Rotate(aCtr0, FRound(nAngle/nPi180), nSin, nCos);
pO->Move(Size(aCtr1.X(),aCtr1.Y()));
}
@@ -1540,7 +1540,7 @@ void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr)
double nNew=tan(static_cast<double>(nNewShearAngle)*nPi180);
nNew-=nOld;
nNew=atan(nNew)/nPi180;
- nShearAngle=svx::Round(nNew);
+ nShearAngle=FRound(nNew);
} else {
nShearAngle=nNewShearAngle-nOldShearAngle;
}
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index d0a9d3a3010f..0cdaeefe3a4e 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -61,7 +61,7 @@ Point GetAnglePnt(const tools::Rectangle& rR, long nAngle)
long nMaxRad=(std::max(nWdt,nHgt)+1) /2;
double a;
a=nAngle*nPi180;
- Point aRetval(svx::Round(cos(a)*nMaxRad),-svx::Round(sin(a)*nMaxRad));
+ Point aRetval(FRound(cos(a)*nMaxRad),-FRound(sin(a)*nMaxRad));
if (nWdt==0) aRetval.setX(0 );
if (nHgt==0) aRetval.setY(0 );
if (nWdt!=nHgt) {
@@ -891,13 +891,13 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const Point& rRef2)
double a;
// starting point
a=nStartAngle*nPi180;
- aTmpPt1=Point(svx::Round(cos(a)*nMaxRad),-svx::Round(sin(a)*nMaxRad));
+ aTmpPt1=Point(FRound(cos(a)*nMaxRad),-FRound(sin(a)*nMaxRad));
if (nWdt==0) aTmpPt1.setX(0 );
if (nHgt==0) aTmpPt1.setY(0 );
aTmpPt1+=aCenter;
// finishing point
a=nEndAngle*nPi180;
- aTmpPt2=Point(svx::Round(cos(a)*nMaxRad),-svx::Round(sin(a)*nMaxRad));
+ aTmpPt2=Point(FRound(cos(a)*nMaxRad),-FRound(sin(a)*nMaxRad));
if (nWdt==0) aTmpPt2.setX(0 );
if (nHgt==0) aTmpPt2.setY(0 );
aTmpPt2+=aCenter;
@@ -1009,7 +1009,7 @@ void SdrCircObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
}
}
if (aGeo.nShearAngle!=0) {
- long nDst=svx::Round((rRect.Bottom()-rRect.Top())*aGeo.nTan);
+ long nDst=FRound((rRect.Bottom()-rRect.Top())*aGeo.nTan);
if (aGeo.nShearAngle>0) {
Point aRef(rRect.TopLeft());
rRect.AdjustLeft( -nDst );
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 8d58f797b6a5..e2420e7d2884 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -454,14 +454,14 @@ void SdrMeasureObj::ImpCalcGeometrics(const ImpMeasureRec& rRec, ImpMeasurePoly&
long nOverhang=rRec.nHelplineOverhang;
long nHelplineDist=rRec.nHelplineDist;
- long dx= svx::Round(nLineDist*nHlpCos);
- long dy=-svx::Round(nLineDist*nHlpSin);
- long dxh1a= svx::Round((nHelplineDist-rRec.nHelpline1Len)*nHlpCos);
- long dyh1a=-svx::Round((nHelplineDist-rRec.nHelpline1Len)*nHlpSin);
- long dxh1b= svx::Round((nHelplineDist-rRec.nHelpline2Len)*nHlpCos);
- long dyh1b=-svx::Round((nHelplineDist-rRec.nHelpline2Len)*nHlpSin);
- long dxh2= svx::Round((nLineDist+nOverhang)*nHlpCos);
- long dyh2=-svx::Round((nLineDist+nOverhang)*nHlpSin);
+ long dx= FRound(nLineDist*nHlpCos);
+ long dy=-FRound(nLineDist*nHlpSin);
+ long dxh1a= FRound((nHelplineDist-rRec.nHelpline1Len)*nHlpCos);
+ long dyh1a=-FRound((nHelplineDist-rRec.nHelpline1Len)*nHlpSin);
+ long dxh1b= FRound((nHelplineDist-rRec.nHelpline2Len)*nHlpCos);
+ long dyh1b=-FRound((nHelplineDist-rRec.nHelpline2Len)*nHlpSin);
+ long dxh2= FRound((nLineDist+nOverhang)*nHlpCos);
+ long dyh2=-FRound((nLineDist+nOverhang)*nHlpSin);
// extension line 1
rPol.aHelpline1.aP1=Point(aP1.X()+dxh1a,aP1.Y()+dyh1a);
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index c1b8e57b7d34..5173a9ff8bf3 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -322,18 +322,18 @@ void ImpPathCreateUser::CalcCircle(const Point& rP1, const Point& rP2, const Poi
if (bRet) {
double cs=cos(nTmpAngle*nPi180);
double nR=static_cast<double>(GetLen(Point(dx,dy)))/cs/2;
- nRad=std::abs(svx::Round(nR));
+ nRad=std::abs(FRound(nR));
}
if (dAngle<18000) {
nCircStAngle=NormAngle360(nTangAngle-9000);
nCircRelAngle=NormAngle360(2*dAngle);
- aCircCenter.AdjustX(svx::Round(nRad*cos((nTangAngle+9000)*nPi180)) );
- aCircCenter.AdjustY( -(svx::Round(nRad*sin((nTangAngle+9000)*nPi180))) );
+ aCircCenter.AdjustX(FRound(nRad*cos((nTangAngle+9000)*nPi180)) );
+ aCircCenter.AdjustY( -(FRound(nRad*sin((nTangAngle+9000)*nPi180))) );
} else {
nCircStAngle=NormAngle360(nTangAngle+9000);
nCircRelAngle=-NormAngle360(36000-2*dAngle);
- aCircCenter.AdjustX(svx::Round(nRad*cos((nTangAngle-9000)*nPi180)) );
- aCircCenter.AdjustY( -(svx::Round(nRad*sin((nTangAngle-9000)*nPi180))) );
+ aCircCenter.AdjustX(FRound(nRad*cos((nTangAngle-9000)*nPi180)) );
+ aCircCenter.AdjustY( -(FRound(nRad*sin((nTangAngle-9000)*nPi180))) );
}
bAngleSnap=pView!=nullptr && pView->IsAngleSnapEnabled();
if (bAngleSnap) {
@@ -455,8 +455,8 @@ void ImpPathCreateUser::CalcRect(const Point& rP1, const Point& rP2, const Point
double sn=sin(a);
double cs=cos(a);
double nGKathLen=nHypLen*sn;
- y+=svx::Round(nGKathLen*sn);
- x+=svx::Round(nGKathLen*cs);
+ y+=FRound(nGKathLen*sn);
+ x+=FRound(nGKathLen*cs);
}
aRectP2.AdjustX(x );
aRectP2.AdjustY(y );
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index fdba01575f28..e1169699b017 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -189,7 +189,7 @@ void SdrRectObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
rRect = maRect;
if (aGeo.nShearAngle!=0)
{
- long nDst=svx::Round((maRect.Bottom()-maRect.Top())*aGeo.nTan);
+ long nDst=FRound((maRect.Bottom()-maRect.Top())*aGeo.nTan);
if (aGeo.nShearAngle>0)
{
Point aRef(rRect.TopLeft());
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index 58deac96de04..c9e7326b26d3 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -43,8 +43,8 @@ void ResizeRect(tools::Rectangle& rRect, const Point& rRef, const Fraction& rxFa
long nWdt = rRect.Right() - rRect.Left();
if (nWdt == 0) rRect.AdjustRight( 1 );
}
- rRect.SetLeft( rRef.X() + svx::Round( (rRect.Left() - rRef.X()) * double(aXFact) ) );
- rRect.SetRight( rRef.X() + svx::Round( (rRect.Right() - rRef.X()) * double(aXFact) ) );
+ rRect.SetLeft( rRef.X() + FRound( (rRect.Left() - rRef.X()) * double(aXFact) ) );
+ rRect.SetRight( rRef.X() + FRound( (rRect.Right() - rRef.X()) * double(aXFact) ) );
if (!aYFact.IsValid()) {
SAL_WARN( "svx.svdraw", "invalid fraction yFract, using Fraction(1,1)" );
@@ -52,8 +52,8 @@ void ResizeRect(tools::Rectangle& rRect, const Point& rRef, const Fraction& rxFa
long nHgt = rRect.Bottom() - rRect.Top();
if (nHgt == 0) rRect.AdjustBottom( 1 );
}
- rRect.SetTop( rRef.Y() + svx::Round( (rRect.Top() - rRef.Y()) * double(aYFact) ) );
- rRect.SetBottom( rRef.Y() + svx::Round( (rRect.Bottom() - rRef.Y()) * double(aYFact) ) );
+ rRect.SetTop( rRef.Y() + FRound( (rRect.Top() - rRef.Y()) * double(aYFact) ) );
+ rRect.SetBottom( rRef.Y() + FRound( (rRect.Bottom() - rRef.Y()) * double(aYFact) ) );
rRect.Justify();
}
@@ -175,7 +175,7 @@ double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCent
// move into the direction of the center, as a basic position for the rotation
pC1->AdjustY( -y0 );
// resize, account for the distance from the center
- pC1->setY(svx::Round(static_cast<double>(pC1->Y()) /rRad.X()*(cx-pC1->X())) );
+ pC1->setY(FRound(static_cast<double>(pC1->Y()) /rRad.X()*(cx-pC1->X())) );
pC1->AdjustY(cy );
} else {
// move into the direction of the center, as a basic position for the rotation
@@ -183,7 +183,7 @@ double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCent
// resize, account for the distance from the center
long nPntRad=cy-pC1->Y();
double nFact=static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
- pC1->setX(svx::Round(static_cast<double>(pC1->X())*nFact) );
+ pC1->setX(FRound(static_cast<double>(pC1->X())*nFact) );
pC1->AdjustX(cx );
}
RotatePoint(*pC1,rCenter,sn,cs);
@@ -193,7 +193,7 @@ double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCent
// move into the direction of the center, as a basic position for the rotation
pC2->AdjustY( -y0 );
// resize, account for the distance from the center
- pC2->setY(svx::Round(static_cast<double>(pC2->Y()) /rRad.X()*(rCenter.X()-pC2->X())) );
+ pC2->setY(FRound(static_cast<double>(pC2->Y()) /rRad.X()*(rCenter.X()-pC2->X())) );
pC2->AdjustY(cy );
} else {
// move into the direction of the center, as a basic position for the rotation
@@ -201,7 +201,7 @@ double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCent
// resize, account for the distance from the center
long nPntRad=rCenter.Y()-pC2->Y();
double nFact=static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
- pC2->setX(svx::Round(static_cast<double>(pC2->X())*nFact) );
+ pC2->setX(FRound(static_cast<double>(pC2->X())*nFact) );
pC2->AdjustX(cx );
}
RotatePoint(*pC2,rCenter,sn,cs);
@@ -280,7 +280,7 @@ double CrookStretchXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCen
long dy=rPnt.Y()-y0;
double a=static_cast<double>(y0-nTop)/nHgt;
a*=dy;
- rPnt.setY(y0+svx::Round(a) );
+ rPnt.setY(y0+FRound(a) );
} return 0.0;
}
@@ -389,7 +389,7 @@ long GetAngle(const Point& rPnt)
if (rPnt.Y()>0) a=-9000;
else a=9000;
} else {
- a=svx::Round(atan2(static_cast<double>(-rPnt.Y()),static_cast<double>(rPnt.X()))/nPi180);
+ a=FRound(atan2(static_cast<double>(-rPnt.Y()),static_cast<double>(rPnt.X()))/nPi180);
}
return a;
}
@@ -426,7 +426,7 @@ long GetLen(const Point& rPnt)
x*=x;
y*=y;
x+=y;
- x=svx::Round(sqrt(static_cast<double>(x)));
+ x=FRound(sqrt(static_cast<double>(x)));
return x;
} else {
double nx=x;
@@ -438,7 +438,7 @@ long GetLen(const Point& rPnt)
if (nx>0x7FFFFFFF) {
return 0x7FFFFFFF; // we can't go any further, for fear of an overrun!
} else {
- return svx::Round(nx);
+ return FRound(nx);
}
}
}