summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-12-19 21:44:27 +0100
committerMichael Stahl <mstahl@redhat.com>2013-12-20 23:56:11 +0100
commitf0c03edd639fd792b36d1bfc5fe54a52d67c9dee (patch)
tree26d30b9018c61cf96a70c7feb5411ce7ffa28f80
parent09af884e7b5712e0311a4c122a5213e7c89f626e (diff)
sw: remove silly BigInt based SqRt
Change-Id: I0a23682998fcf23f917289a0137d137b240a9d92
-rw-r--r--sw/source/core/inc/frmtool.hxx3
-rw-r--r--sw/source/core/layout/flycnt.cxx33
-rw-r--r--sw/source/core/layout/frmtool.cxx24
-rw-r--r--sw/source/core/layout/trvlfrm.cxx16
4 files changed, 23 insertions, 53 deletions
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index 33043516190c..e44862c958c5 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -35,7 +35,6 @@ class SwRootFrm;
class SwDoc;
class SwAttrSet;
class SdrObject;
-class BigInt;
class SvxBrushItem;
class XFillStyleItem;
class XFillGradientItem;
@@ -82,8 +81,6 @@ void PaintCharacterBorder(
// Implementation in feshview.cxx
SwFlyFrm *GetFlyFromMarked( const SdrMarkList *pLst, SwViewShell *pSh );
-sal_uLong SqRt( BigInt nX );
-
SwFrm *SaveCntnt( SwLayoutFrm *pLay, SwFrm *pStart = NULL );
void RestoreCntnt( SwFrm *pSav, SwLayoutFrm *pParent, SwFrm *pSibling, bool bGrow );
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 7b7ef16b67db..06c6885b0d0c 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -877,7 +877,7 @@ static const SwFrm * lcl_CalcDownDist( SwDistance &rRet,
return 0;
}
-static sal_uLong lcl_FindCntDiff( const Point &rPt, const SwLayoutFrm *pLay,
+static sal_uInt64 lcl_FindCntDiff( const Point &rPt, const SwLayoutFrm *pLay,
const SwCntntFrm *& rpCnt,
const bool bBody, const sal_Bool bFtn )
{
@@ -890,8 +890,8 @@ static sal_uLong lcl_FindCntDiff( const Point &rPt, const SwLayoutFrm *pLay,
#endif
rpCnt = 0;
- sal_uLong nDistance = ULONG_MAX;
- sal_uLong nNearest = ULONG_MAX;
+ sal_uInt64 nDistance = SAL_MAX_UINT64;
+ sal_uInt64 nNearest = SAL_MAX_UINT64;
const SwCntntFrm *pCnt = pLay->ContainsCntnt();
while ( pCnt && (bBody != pCnt->IsInDocBody() || bFtn != pCnt->IsInFtn()))
@@ -907,13 +907,12 @@ static sal_uLong lcl_FindCntDiff( const Point &rPt, const SwLayoutFrm *pLay,
{
//Calculate the distance between those two points.
//'delta' X^2 + 'delta' Y^2 = 'distance'^2
- sal_uInt32 dX = std::max( pCnt->Frm().Left(), rPt.X() ) -
+ sal_uInt64 dX = std::max( pCnt->Frm().Left(), rPt.X() ) -
std::min( pCnt->Frm().Left(), rPt.X() ),
dY = std::max( pCnt->Frm().Top(), rPt.Y() ) -
std::min( pCnt->Frm().Top(), rPt.Y() );
- BigInt dX1( dX ), dY1( dY );
- dX1 *= dX1; dY1 *= dY1;
- const sal_uLong nDiff = ::SqRt( dX1 + dY1 );
+ // square of the difference will do fine here
+ const sal_uInt64 nDiff = (dX * dX) + (dY * dY);
if ( pCnt->Frm().Top() <= rPt.Y() )
{
if ( nDiff < nDistance )
@@ -935,7 +934,7 @@ static sal_uLong lcl_FindCntDiff( const Point &rPt, const SwLayoutFrm *pLay,
} while ( pCnt && pLay->IsAnLower( pCnt ) );
}
- if ( nDistance == ULONG_MAX )
+ if (nDistance == SAL_MAX_UINT64)
{ rpCnt = pNearest;
return nNearest;
}
@@ -955,26 +954,26 @@ static const SwCntntFrm * lcl_FindCnt( const Point &rPt, const SwCntntFrm *pCnt,
//above the point.
const SwCntntFrm *pRet, *pNew;
const SwLayoutFrm *pLay = pCnt->FindPageFrm();
- sal_uLong nDist;
+ sal_uInt64 nDist; // not sure if a sal_Int32 would be enough?
nDist = ::lcl_FindCntDiff( rPt, pLay, pNew, bBody, bFtn );
if ( pNew )
pRet = pNew;
else
{ pRet = pCnt;
- nDist = ULONG_MAX;
+ nDist = SAL_MAX_UINT64;
}
const SwCntntFrm *pNearest = pRet;
- sal_uLong nNearest = nDist;
+ sal_uInt64 nNearest = nDist;
if ( pLay )
{
const SwLayoutFrm *pPge = pLay;
- sal_uLong nOldNew = ULONG_MAX;
+ sal_uInt64 nOldNew = SAL_MAX_UINT64;
for ( sal_uInt16 i = 0; pPge->GetPrev() && (i < 3); ++i )
{
pPge = (SwLayoutFrm*)pPge->GetPrev();
- const sal_uLong nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFtn );
+ const sal_uInt64 nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFtn );
if ( nNew < nDist )
{
if ( pNew->Frm().Top() <= rPt.Y() )
@@ -988,18 +987,18 @@ static const SwCntntFrm * lcl_FindCnt( const Point &rPt, const SwCntntFrm *pCnt,
nNearest = nNew;
}
}
- else if ( nOldNew != ULONG_MAX && nNew > nOldNew )
+ else if (nOldNew != SAL_MAX_UINT64 && nNew > nOldNew)
break;
else
nOldNew = nNew;
}
pPge = pLay;
- nOldNew = ULONG_MAX;
+ nOldNew = SAL_MAX_UINT64;
for ( sal_uInt16 j = 0; pPge->GetNext() && (j < 3); ++j )
{
pPge = (SwLayoutFrm*)pPge->GetNext();
- const sal_uLong nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFtn );
+ const sal_uInt64 nNew = ::lcl_FindCntDiff( rPt, pPge, pNew, bBody, bFtn );
if ( nNew < nDist )
{
if ( pNew->Frm().Top() <= rPt.Y() )
@@ -1013,7 +1012,7 @@ static const SwCntntFrm * lcl_FindCnt( const Point &rPt, const SwCntntFrm *pCnt,
nNearest = nNew;
}
}
- else if ( nOldNew != ULONG_MAX && nNew > nOldNew )
+ else if (nOldNew != SAL_MAX_UINT64 && nNew > nOldNew)
break;
else
nOldNew = nNew;
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index ac95bf87fa0e..631a60ce1538 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <tools/bigint.hxx>
#include <svx/svdmodel.hxx>
#include <svx/svdpage.hxx>
#include <editeng/brushitem.hxx>
@@ -2683,29 +2682,6 @@ void RestoreCntnt( SwFrm *pSav, SwLayoutFrm *pParent, SwFrm *pSibling, bool bGro
pParent->Grow( nGrowVal );
}
-/*************************************************************************
-|*
-|* SqRt() Berechnung der Quadratwurzel, damit die math.lib
-|* nicht auch noch dazugelinkt werden muss.
-|*
-|*************************************************************************/
-
-sal_uLong SqRt( BigInt nX )
-{
- BigInt nErg = 1;
-
- if ( !nX.IsNeg() )
- {
- BigInt nOldErg = 1;
- for ( int i = 0; i <= 5; i++ )
- {
- nErg = (nOldErg + (nX / nOldErg)) / BigInt(2);
- nOldErg = nErg;
- }
- }
- return nErg >= BigInt(SAL_MAX_UINT32) ? ULONG_MAX : (sal_uLong)nErg;
-}
-
/*************************************************************************/
SwPageFrm * InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index c67008d63df9..f33cfcb6422f 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1142,17 +1142,15 @@ sal_Bool GetFrmInPage( const SwCntntFrm *pCnt, SwWhichPage fnWhichPage,
}
}
-sal_uLong CalcDiff( const Point &rPt1, const Point &rPt2 )
+static sal_uInt64 CalcDiff(const Point &rPt1, const Point &rPt2)
{
//Calculate the distance between the two points.
//'delta' X^2 + 'delta'Y^2 = 'distance'^2
- sal_uInt32 dX = std::max( rPt1.X(), rPt2.X() ) -
+ sal_uInt64 dX = std::max( rPt1.X(), rPt2.X() ) -
std::min( rPt1.X(), rPt2.X() ),
dY = std::max( rPt1.Y(), rPt2.Y() ) -
std::min( rPt1.Y(), rPt2.Y() );
- BigInt dX1( dX ), dY1( dY );
- dX1 *= dX1; dY1 *= dY1;
- return ::SqRt( dX1 + dY1 );
+ return (dX * dX) + (dY * dY);
}
/** Check if the point lies inside the page part in wich also the CntntFrame lies.
@@ -1209,7 +1207,7 @@ const SwCntntFrm *SwLayoutFrm::GetCntntPos( Point& rPoint,
const SwLayoutFrm *pInside = NULL;
sal_uInt16 nMaxPage = GetPhyPageNum() + (bDefaultExpand ? 1 : 0);
Point aPoint = rPoint;
- sal_uLong nDistance = ULONG_MAX;
+ sal_uInt64 nDistance = SAL_MAX_UINT64;
while ( true ) //A loop to be sure we always find one.
{
@@ -1262,7 +1260,7 @@ const SwCntntFrm *SwLayoutFrm::GetCntntPos( Point& rPoint,
if( !pInside || ( pInside->IsAnLower( pCntnt ) &&
( !pCntnt->IsInFtn() || pInside->IsFtnContFrm() ) ) )
{
- const sal_uLong nDiff = ::CalcDiff( aCntntPoint, rPoint );
+ const sal_uInt64 nDiff = ::CalcDiff(aCntntPoint, rPoint);
sal_Bool bBetter = nDiff < nDistance; // This one is nearer
if( !pInside )
{
@@ -1406,7 +1404,7 @@ void SwPageFrm::GetCntntPosition( const Point &rPt, SwPosition &rPos ) const
const SwCntntFrm *pAct = pCntnt;
Point aAct = rPt;
- sal_uLong nDist = ULONG_MAX;
+ sal_uLong nDist = SAL_MAX_UINT64;
while ( pCntnt )
{
@@ -1433,7 +1431,7 @@ void SwPageFrm::GetCntntPosition( const Point &rPt, SwPosition &rPos ) const
else if ( aCntFrm.Right() < rPt.X() )
aPoint.X() = aCntFrm.Right();
- const sal_uLong nDiff = ::CalcDiff( aPoint, rPt );
+ const sal_uInt64 nDiff = ::CalcDiff( aPoint, rPt );
if ( nDiff < nDist )
{
aAct = aPoint;