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 /sd | |
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 'sd')
-rw-r--r-- | sd/source/filter/eppt/epptso.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx | 7 |
3 files changed, 16 insertions, 5 deletions
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 304c2b298b39..d36590a56200 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> + #include <osl/endian.h> #include <eppt.hxx> #include "text.hxx" @@ -1245,7 +1249,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u nDefaultTabSizeSrc = nTabStop; } const sal_uInt32 nDefaultTabSize = MapSize( awt::Size( nDefaultTabSizeSrc, 1 ) ).Width; - sal_uInt32 nDefaultTabs = abs( maRect.GetWidth() ) / nDefaultTabSize; + sal_uInt32 nDefaultTabs = std::abs( maRect.GetWidth() ) / nDefaultTabSize; if ( nTabs ) nDefaultTabs -= (sal_Int32)( ( ( pTabStop[ nTabs - 1 ].Position / 4.40972 ) + nTextOfs ) / nDefaultTabSize ); if ( (sal_Int32)nDefaultTabs < 0 ) diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx index 746e940a361c..647e2516c3e5 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> + #include "controller/SlsSelectionFunction.hxx" #include "SlideSorter.hxx" @@ -1361,8 +1365,8 @@ bool NormalModeHandler::ProcessMotionEvent ( { const sal_Int32 nDistance (maButtonDownLocation ? ::std::max ( - abs(maButtonDownLocation->X() - rDescriptor.maMousePosition.X()), - abs(maButtonDownLocation->Y() - rDescriptor.maMousePosition.Y())) + std::abs(maButtonDownLocation->X() - rDescriptor.maMousePosition.X()), + std::abs(maButtonDownLocation->Y() - rDescriptor.maMousePosition.Y())) : 0); if (nDistance > 3) StartDrag( diff --git a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx index 48b0898aad67..c6a4f1e5df28 100644 --- a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> #include "controller/SlsVisibleAreaManager.hxx" #include "controller/SlideSorterController.hxx" @@ -270,14 +273,14 @@ VisibleAreaScroller::VisibleAreaScroller ( // When the distance to scroll is larger than a threshold then first // jump to within this distance of the final value and start the // animation from there. - if (abs(aStart.X()-aEnd.X()) > gnMaxScrollDistance) + if (std::abs(aStart.X()-aEnd.X()) > gnMaxScrollDistance) { if (aStart.X() < aEnd.X()) maStart.X() = aEnd.X()-gnMaxScrollDistance; else maStart.X() = aEnd.X()+gnMaxScrollDistance; } - if (abs(aStart.Y()-aEnd.Y()) > gnMaxScrollDistance) + if (std::abs(aStart.Y()-aEnd.Y()) > gnMaxScrollDistance) { if (aStart.Y() < aEnd.Y()) maStart.Y() = aEnd.Y()-gnMaxScrollDistance; |