summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdmodel.cxx
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2017-12-29 10:38:01 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-02-11 15:42:53 +0100
commit5cc52ae22c94c734add5e0654e7ce1dbeebebe3e (patch)
tree239f83416c6adc97f21c6a53694d266758c7c221 /svx/source/svdraw/svdmodel.cxx
parent9f74b6fee1082caf96d78c731c77e10a67c3bc41 (diff)
Simplify SdrModel::TakeMetricStr truncation for trailing 0s
Change-Id: If2f3bceaada841f7a085e7c97786ef7234c85c61
Diffstat (limited to 'svx/source/svdraw/svdmodel.cxx')
-rw-r--r--svx/source/svdraw/svdmodel.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 6e878d5ee372..2ae0fe62856f 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1212,7 +1212,7 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I
aBuf.insert(0, '0');
}
- sal_Unicode cDec( rLoc.getNumDecimalSep()[0] );
+ const sal_Unicode cDec( rLoc.getNumDecimalSep()[0] );
// insert the decimal mark character
sal_Int32 nBeforeDecimalMark = aBuf.getLength() - nDecimalMark;
@@ -1222,13 +1222,19 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I
if(!LocaleDataWrapper::isNumTrailingZeros())
{
+ sal_Int32 aPos=aBuf.getLength()-1;
+
// Remove all trailing zeros.
- while (!aBuf.isEmpty() && aBuf[aBuf.getLength()-1] == '0')
- aBuf.remove(aBuf.getLength()-1, 1);
+ while (aPos>=0 && aBuf[aPos]=='0')
+ --aPos;
// Remove decimal if it's the last character.
- if (!aBuf.isEmpty() && aBuf[aBuf.getLength()-1] == cDec)
- aBuf.remove(aBuf.getLength()-1, 1);
+ if (aPos>=0 && aBuf[aPos]==cDec)
+ --aPos;
+
+ // Adjust aPos to index first char to be truncated, if any
+ if (++aPos<aBuf.getLength())
+ aBuf.truncate(aPos);
}
// if necessary, add separators before every third digit