summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-03-03 18:27:00 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-03-03 18:36:55 +0100
commitb2371492dfd5c8003f89ed8acf3dbc690d6af8d0 (patch)
tree876a32c415fa06d41a51a2a4a9cc16b1e97bdf76 /svtools
parent768ea2924680fc4beb75a782cb0faf26695fee53 (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 'svtools')
-rw-r--r--svtools/source/contnr/svimpbox.cxx5
-rw-r--r--svtools/source/graphic/grfcache.cxx8
-rw-r--r--svtools/source/graphic/grfmgr2.cxx8
-rw-r--r--svtools/source/table/tablecontrol_impl.cxx5
4 files changed, 18 insertions, 8 deletions
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index dac2f9866ece..d6312cbc0874 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -22,6 +22,7 @@
#include <vcl/help.hxx>
#include <vcl/settings.hxx>
+#include <cstdlib>
#include <stack>
#include <svtools/treelistbox.hxx>
@@ -3141,8 +3142,8 @@ IMPL_LINK_NOARG(SvImpLBox, EditTimerCall)
if ( bIsMouseTriggered )
{
Point aCurrentMousePos = pView->GetPointerPosPixel();
- if ( ( abs( aCurrentMousePos.X() - aEditClickPos.X() ) > 5 )
- || ( abs( aCurrentMousePos.Y() - aEditClickPos.Y() ) > 5 )
+ if ( ( std::abs( aCurrentMousePos.X() - aEditClickPos.X() ) > 5 )
+ || ( std::abs( aCurrentMousePos.Y() - aEditClickPos.Y() ) > 5 )
)
{
return 0L;
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index c1f4324dc668..89bfb608599b 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstdlib>
+
#include <salhelper/timer.hxx>
#include <svtools/grfmgr.hxx>
#include <tools/debug.hxx>
@@ -494,8 +498,8 @@ static void checkMetadataBitmap( const BitmapEx& rBmpEx,
}
if( rDestSize != rRefSize )
{ if( rBmpEx.GetSizePixel().Width() > 100 && rBmpEx.GetSizePixel().Height() > 100
- && abs( rDestSize.Width() - rRefSize.Width()) < 5
- && abs( rDestSize.Height() - rRefSize.Height()) < 5 )
+ && std::abs( rDestSize.Width() - rRefSize.Width()) < 5
+ && std::abs( rDestSize.Height() - rRefSize.Height()) < 5 )
; // ok, assume it's close enough
else
{ // fall back to mtf rendering
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index e439ca7b8760..f1048e10a8ae 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstdlib>
+
#include <vcl/bmpacc.hxx>
#include <tools/poly.hxx>
#include <vcl/outdev.hxx>
@@ -1007,8 +1011,8 @@ static BitmapEx checkMetadataBitmap( const BitmapEx& rBmpEx,
// caused by this small difference). This will allow caching of the resulting
// (scaled) pixmap, which can make a noticeable performance difference.
if( rBmpEx.GetSizePixel().Width() > 100 && rBmpEx.GetSizePixel().Height() > 100
- && abs( rDestSize.Width() - rRefSize.Width()) < 5
- && abs( rDestSize.Height() - rRefSize.Height()) < 5 )
+ && std::abs( rDestSize.Width() - rRefSize.Width()) < 5
+ && std::abs( rDestSize.Height() - rRefSize.Height()) < 5 )
; // ok, assume it's close enough
else
{ // fall back to mtf rendering
diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx
index 4565a1eafe61..31372d00ee9f 100644
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -39,6 +39,7 @@
#include <vcl/image.hxx>
#include <tools/diagnose_ex.h>
+#include <cstdlib>
#include <functional>
#include <numeric>
@@ -2338,7 +2339,7 @@ namespace svt { namespace table
Rectangle aDataArea( Point( 0, m_nColHeaderHeightPixel ), m_pDataWindow->GetOutputSizePixel() );
if ( m_pDataWindow->GetBackground().IsScrollable()
- && abs( nPixelDelta ) < aDataArea.GetHeight()
+ && std::abs( nPixelDelta ) < aDataArea.GetHeight()
)
{
m_pDataWindow->Scroll( 0, (long)-nPixelDelta, aDataArea, SCROLL_CLIP | SCROLL_UPDATE | SCROLL_CHILDREN);
@@ -2418,7 +2419,7 @@ namespace svt { namespace table
// scroll the window content (if supported and possible), or invalidate the complete window
if ( m_pDataWindow->GetBackground().IsScrollable()
- && abs( nPixelDelta ) < aDataArea.GetWidth()
+ && std::abs( nPixelDelta ) < aDataArea.GetWidth()
)
{
m_pDataWindow->Scroll( nPixelDelta, 0, aDataArea, SCROLL_CLIP | SCROLL_UPDATE );