diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-03-03 18:27:00 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-03-03 18:36:55 +0100 |
commit | b2371492dfd5c8003f89ed8acf3dbc690d6af8d0 (patch) | |
tree | 876a32c415fa06d41a51a2a4a9cc16b1e97bdf76 /svx/source | |
parent | 768ea2924680fc4beb75a782cb0faf26695fee53 (diff) |
Use cstdlib std::abs instead of stdlib.h abs
...because the latter lacks the abs(long) overload in some popular environments,
cf. <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60401> "stdlib.h does not
provide abs(long) overload."
Similarly, stdlib.h lacks the abs(float), abs(double), abs(long double)
overloads compared to cmath there, whose use was apparently intended in
sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx. Rewrote that to use
CPPUNIT_ASSERT_DOUBLES_EQUAL instead, which revealed that the comparisons need
rather large deltas of .1 resp. .2 (which the original code hid with an
implicit conversion to integral type, thus using an effective delta of 1).
Discovered with -Wabsolute-value ("absolute value function 'abs' given an
argument of type 'long' but has parameter of type 'int' which may cause
truncation of value") recently introduced on Clang trunk towards 3.5.
Change-Id: I4c41575ffdccb2944498b662bd3a53fd510cb0c0
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/dialog/framelink.cxx | 16 | ||||
-rw-r--r-- | svx/source/fmcomp/gridctrl.cxx | 3 |
2 files changed, 12 insertions, 7 deletions
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx index e30155e34573..a6a4f7224ef1 100644 --- a/svx/source/dialog/framelink.cxx +++ b/svx/source/dialog/framelink.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> + #include <svx/framelink.hxx> #include <math.h> @@ -765,9 +769,9 @@ void lclDrawHorLine( LinePoints aTPoints( rLPos + lclToMapUnit( rLRes.mnOffs1, nTOffs ), rRPos + lclToMapUnit( rRRes.mnOffs1, nTOffs ) ); LinePoints aBPoints( rLPos + lclToMapUnit( rLRes.mnOffs2, nBOffs ), rRPos + lclToMapUnit( rRRes.mnOffs2, nBOffs ) ); - sal_uInt32 nWidth = lclToMapUnit( abs( nTOffs ) ) + lclToMapUnit( abs( nBOffs ) ); + sal_uInt32 nWidth = lclToMapUnit( std::abs( nTOffs ) ) + lclToMapUnit( std::abs( nBOffs ) ); if ( ( nTOffs >= 0 && nBOffs >= 0 ) || ( nTOffs <= 0 && nBOffs <= 0 ) ) - nWidth = abs( lclToMapUnit( nTOffs ) - lclToMapUnit( nBOffs ) ) + 1; + nWidth = std::abs( lclToMapUnit( nTOffs ) - lclToMapUnit( nBOffs ) ) + 1; Point rLMid = ( aTPoints.maBeg + aBPoints.maBeg ) / 2; Point rRMid = ( aTPoints.maEnd + aBPoints.maEnd ) / 2; @@ -835,9 +839,9 @@ void lclDrawVerLine( LinePoints aLPoints( rTPos + lclToMapUnit( nLOffs, rTRes.mnOffs1 ), rBPos + lclToMapUnit( nLOffs, rBRes.mnOffs1 ) ); LinePoints aRPoints( rTPos + lclToMapUnit( nROffs, rTRes.mnOffs2 ), rBPos + lclToMapUnit( nROffs, rBRes.mnOffs2 ) ); - sal_uInt32 nWidth = lclToMapUnit( abs( nLOffs ) ) + lclToMapUnit( abs( nROffs ) ); + sal_uInt32 nWidth = lclToMapUnit( std::abs( nLOffs ) ) + lclToMapUnit( std::abs( nROffs ) ); if ( ( nLOffs >= 0 && nROffs >= 0 ) || ( nLOffs <= 0 && nROffs <= 0 ) ) - nWidth = abs( lclToMapUnit( nLOffs ) - lclToMapUnit( nROffs ) ) + 1; + nWidth = std::abs( lclToMapUnit( nLOffs ) - lclToMapUnit( nROffs ) ) + 1; Point rTMid = ( aLPoints.maBeg + aRPoints.maBeg ) / 2; Point rBMid = ( aLPoints.maEnd + aRPoints.maEnd ) / 2; @@ -1023,9 +1027,9 @@ void lclDrawDiagLine( Point aSMid( ( aLPoints.maBeg + aL2Points.maBeg ) / 2 ); Point aEMid( ( aLPoints.maEnd + aL2Points.maEnd ) / 2 ); - sal_uInt32 nWidth = lclToMapUnit( abs( nDiagOffs1 ) ) + lclToMapUnit( abs( nDiagOffs2 ) ); + sal_uInt32 nWidth = lclToMapUnit( std::abs( nDiagOffs1 ) ) + lclToMapUnit( std::abs( nDiagOffs2 ) ); if ( ( nDiagOffs1 <= 0 && nDiagOffs2 <= 0 ) || ( nDiagOffs1 >=0 && nDiagOffs2 >=0 ) ) - nWidth = lclToMapUnit( abs( nDiagOffs1 - nDiagOffs2 ) ); + nWidth = lclToMapUnit( std::abs( nDiagOffs1 - nDiagOffs2 ) ); svtools::DrawLine( rDev, aSMid, aEMid, nWidth, nDashing ); rDev.Pop(); // clipping region diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index cf2351250f75..82ff2bcd7522 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -56,6 +56,7 @@ #include <comphelper/property.hxx> #include <algorithm> +#include <cstdlib> #include <map> using namespace ::svxform; @@ -2302,7 +2303,7 @@ sal_Bool DbGridControl::SeekCursor(long nRow, sal_Bool bAbsolute) DBG_ASSERT( !m_pSeekCursor->isAfterLast() && !m_pSeekCursor->isBeforeFirst(), "DbGridControl::SeekCursor: how did the seek cursor get to this position?!" ); nSteps = nRow - (m_pSeekCursor->getRow() - 1); - bAbsolute = bAbsolute || (abs(nSteps) > 100); + bAbsolute = bAbsolute || (std::abs(nSteps) > 100); } if ( bAbsolute ) |