summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdmodel.cxx
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2017-12-28 23:34:28 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-02-11 15:42:53 +0100
commit9f74b6fee1082caf96d78c731c77e10a67c3bc41 (patch)
treeed5c444e5edd97e3095977903f6afd6213296856 /svx/source/svdraw/svdmodel.cxx
parent381d116290f6bfbb0106db29a33d51f56e4b8f08 (diff)
Simplify SdrModel::TakePercentStr
* Group checks on sign * Let OUString::number print the sign Change-Id: I1ae22141f813eb4ff5b527423354e195485f8037
Diffstat (limited to 'svx/source/svdraw/svdmodel.cxx')
-rw-r--r--svx/source/svdraw/svdmodel.cxx27
1 files changed, 13 insertions, 14 deletions
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 2e09b6c18814..6e878d5ee372 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1296,27 +1296,26 @@ void SdrModel::TakePercentStr(const Fraction& rVal, OUString& rStr)
{
sal_Int32 nMul(rVal.GetNumerator());
sal_Int32 nDiv(rVal.GetDenominator());
- bool bNeg(nMul < 0);
+ bool bNeg {false};
- if(nDiv < 0)
+ if (nDiv < 0)
+ {
bNeg = !bNeg;
-
- if(nMul < 0)
- nMul = -nMul;
-
- if(nDiv < 0)
nDiv = -nDiv;
+ }
- nMul *= 100;
- nMul += nDiv/2;
- nMul /= nDiv;
+ if (nMul < 0)
+ {
+ bNeg = !bNeg;
+ nMul = -nMul;
+ }
- rStr = OUString::number(nMul);
+ sal_Int32 nPct = ((nMul*100) + nDiv/2)/nDiv;
- if(bNeg)
- rStr = "-" + rStr;
+ if (bNeg)
+ nPct = -nPct;
- rStr += "%";
+ rStr = OUString::number(nPct) + "%";
}
void SdrModel::SetChanged(bool bFlg)