Kaydet (Commit) 00269d39 authored tarafından Michael Stahl's avatar Michael Stahl

svx: remove duplicate "Kuerzen" function

Change-Id: I319ba12684398bcdfcd8d8ede1648e1d213e75a7
üst f08ffc15
......@@ -249,12 +249,6 @@ SVX_DLLPUBLIC void OrthoDistance4(const Point& rPt0, Point& rPt, bool bBigOrtho)
// Calculation and intermediate values are in BigInt
SVX_DLLPUBLIC long BigMulDiv(long nVal, long nMul, long nDiv);
// Lossy cancellation of a fraction
// nDigits specifies, how many significant digits the numerator
// and denominator should at least be retained
void Kuerzen(Fraction& rF, unsigned nDigits);
class FrPair {
Fraction aX;
Fraction aY;
......
......@@ -2422,7 +2422,7 @@ void SdrDragShear::MoveSdrDrag(const Point& rPnt)
bResize=true;
double nCos=cos(nTmpAngle*nPi180);
aNeuFact=nCos;
Kuerzen(aFact,10); // three decimals should be enough
aFact.ReduceInaccurate(10); // three decimals should be enough
}
if (nNewAngle>8900)
......
......@@ -2225,8 +2225,8 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei
aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
// reduce to 10 binary digits
Kuerzen(aScaleHeight, 10);
Kuerzen(aScaleWidth, 10);
aScaleHeight.ReduceInaccurate(10);
aScaleWidth.ReduceInaccurate(10);
return true;
}
......
......@@ -584,39 +584,6 @@ long BigMulDiv(long nVal, long nMul, long nDiv)
return 0x7fffffff;
}
void Kuerzen(Fraction& rF, unsigned nDigits)
{
sal_Int32 nMul=rF.GetNumerator();
sal_Int32 nDiv=rF.GetDenominator();
bool bNeg = false;
if (nMul<0) { nMul=-nMul; bNeg=!bNeg; }
if (nDiv<0) { nDiv=-nDiv; bNeg=!bNeg; }
if (nMul==0 || nDiv==0) return;
sal_uInt32 a;
a=sal_uInt32(nMul); unsigned nMulZ=0; // count leading zeros
while (a<0x00800000) { nMulZ+=8; a<<=8; }
while (a<0x80000000) { nMulZ++; a<<=1; }
a=sal_uInt32(nDiv); unsigned nDivZ=0; // count leading zeros
while (a<0x00800000) { nDivZ+=8; a<<=8; }
while (a<0x80000000) { nDivZ++; a<<=1; }
// count the number of digits
int nMulDigits=32-nMulZ;
int nDivDigits=32-nDivZ;
// count how many decimal places can be removed
int nMulWeg=nMulDigits-nDigits; if (nMulWeg<0) nMulWeg=0;
int nDivWeg=nDivDigits-nDigits; if (nDivWeg<0) nDivWeg=0;
int nWeg=std::min(nMulWeg,nDivWeg);
nMul>>=nWeg;
nDiv>>=nWeg;
if (nMul==0 || nDiv==0) {
DBG_WARNING("Math error after canceling decimal places.");
return;
}
if (bNeg) nMul=-nMul;
rF=Fraction(nMul,nDiv);
}
// How many eU units fit into a mm, respectively an inch?
// Or: How many mm, respectively inches, are there in an eU (and then give me the inverse)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment