diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-11-16 16:07:30 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-11-16 21:43:09 +0100 |
commit | 50d3ad9127aaf63afcfa299adcea060c9b09faa4 (patch) | |
tree | af3bf48ae8e31e180003c9f998831dd7777d1f5b | |
parent | cd4a239063a77d49fe178255c20f0558e337a82f (diff) |
Instead of labs, use overloaded abs
...more likely to pick an appropriate version for the involved integer types,
esp. after the recent long -> tools::Long changes
Change-Id: Ia91259ca35aaf74b0e907de6831fc926f30057f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105949
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
30 files changed, 129 insertions, 75 deletions
diff --git a/canvas/source/directx/dx_canvashelper_texturefill.cxx b/canvas/source/directx/dx_canvashelper_texturefill.cxx index f60dffb3b870..0bea70fc83a2 100644 --- a/canvas/source/directx/dx_canvashelper_texturefill.cxx +++ b/canvas/source/directx/dx_canvashelper_texturefill.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <cstdlib> #include <memory> #include <tuple> @@ -188,10 +189,10 @@ namespace dxcanvas int numColorSteps( const Gdiplus::Color& rColor1, const Gdiplus::Color& rColor2 ) { return std::max( - labs( rColor1.GetRed() - rColor2.GetRed() ), + std::abs( rColor1.GetRed() - rColor2.GetRed() ), std::max( - labs( rColor1.GetGreen() - rColor2.GetGreen() ), - labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ); + std::abs( rColor1.GetGreen() - rColor2.GetGreen() ), + std::abs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ); } bool fillPolygonalGradient( const ::canvas::ParametricPolyPolygon::Values& rValues, diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx index 81d97138b22c..501e91f2782c 100644 --- a/canvas/source/vcl/canvashelper_texturefill.cxx +++ b/canvas/source/vcl/canvashelper_texturefill.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <cstdlib> #include <tuple> #include <basegfx/matrix/b2dhommatrix.hxx> @@ -427,10 +428,10 @@ namespace vclcanvas int numColorSteps( const ::Color& rColor1, const ::Color& rColor2 ) { return std::max( - labs( rColor1.GetRed() - rColor2.GetRed() ), + std::abs( rColor1.GetRed() - rColor2.GetRed() ), std::max( - labs( rColor1.GetGreen() - rColor2.GetGreen() ), - labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ); + std::abs( rColor1.GetGreen() - rColor2.GetGreen() ), + std::abs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ); } bool gradientFill( OutputDevice& rOutDev, diff --git a/editeng/source/accessibility/AccessibleStringWrap.cxx b/editeng/source/accessibility/AccessibleStringWrap.cxx index a2439705a7fd..de11c4a0732c 100644 --- a/editeng/source/accessibility/AccessibleStringWrap.cxx +++ b/editeng/source/accessibility/AccessibleStringWrap.cxx @@ -19,6 +19,8 @@ #include <algorithm> +#include <cstdlib> + #include <tools/debug.hxx> #include <vcl/outdev.hxx> @@ -58,7 +60,7 @@ void AccessibleStringWrap::GetCharacterBounds( sal_Int32 nIndex, tools::Rectangl mrDev.GetCaretPositions( maText, aXArray, nIndex, 1 ); rRect.SetLeft( 0 ); rRect.SetTop( 0 ); - rRect.SetSize( Size(mrDev.GetTextHeight(), labs(aXArray[0] - aXArray[1])) ); + rRect.SetSize( Size(mrDev.GetTextHeight(), std::abs(aXArray[0] - aXArray[1])) ); rRect.Move( std::min(aXArray[0], aXArray[1]), 0 ); } diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index cd3110ba9cbc..e376e6f501c1 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -19,6 +19,7 @@ #include <mtftools.hxx> +#include <cstdlib> #include <memory> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> @@ -1160,7 +1161,7 @@ namespace emfio UpdateClipRegion(); UpdateLineStyle(); UpdateFillStyle(); - mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), labs( ImplMap( rSize ).Width() ), labs( ImplMap( rSize ).Height() ) ) ); + mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), std::abs( ImplMap( rSize ).Width() ), std::abs( ImplMap( rSize ).Height() ) ) ); } void MtfTools::DrawEllipse( const tools::Rectangle& rRect ) diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 1473930e83ec..0022fe9b1cb6 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -20,6 +20,7 @@ #include <wmfreader.hxx> #include <emfreader.hxx> +#include <cstdlib> #include <memory> #include <optional> #include <o3tl/safeint.hxx> @@ -1328,18 +1329,19 @@ namespace emfio } SetWinOrg( aPlaceableBound.TopLeft() ); - Size aWMFSize( labs( aPlaceableBound.GetWidth() ), labs( aPlaceableBound.GetHeight() ) ); + Size aWMFSize( + std::abs( aPlaceableBound.GetWidth() ), std::abs( aPlaceableBound.GetHeight() ) ); SetWinExt( aWMFSize ); SAL_INFO("vcl.wmf", "WMF size w: " << aWMFSize.Width() << " h: " << aWMFSize.Height()); Size aDevExt( 10000, 10000 ); - if( ( labs( aWMFSize.Width() ) > 1 ) && ( labs( aWMFSize.Height() ) > 1 ) ) + if( ( std::abs( aWMFSize.Width() ) > 1 ) && ( std::abs( aWMFSize.Height() ) > 1 ) ) { const Fraction aFrac( 1, mnUnitsPerInch); MapMode aWMFMap( MapUnit::MapInch, Point(), aFrac, aFrac ); Size aSize100(OutputDevice::LogicToLogic(aWMFSize, aWMFMap, MapMode(MapUnit::Map100thMM))); - aDevExt = Size( labs( aSize100.Width() ), labs( aSize100.Height() ) ); + aDevExt = Size( std::abs( aSize100.Width() ), std::abs( aSize100.Height() ) ); } SetDevExt( aDevExt ); diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index 3d110bf21941..79ec4830c19d 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -39,6 +39,7 @@ #include <osl/diagnose.h> #include <com/sun/star/task/XStatusIndicator.hpp> +#include <cstdlib> #include <memory> using namespace ::com::sun::star::uno; @@ -2369,7 +2370,7 @@ void PSWriter::ImplWriteLong(sal_Int32 nNumber, NMode nMode) void PSWriter::ImplWriteDouble( double fNumber ) { sal_Int32 nPTemp = static_cast<sal_Int32>(fNumber); - sal_Int32 nATemp = labs( static_cast<sal_Int32>( ( fNumber - nPTemp ) * 100000 ) ); + sal_Int32 nATemp = std::abs( static_cast<sal_Int32>( ( fNumber - nPTemp ) * 100000 ) ); if ( !nPTemp && nATemp && ( fNumber < 0.0 ) ) mpPS->WriteChar( '-' ); diff --git a/i18nutil/source/utility/paper.cxx b/i18nutil/source/utility/paper.cxx index 1b87b37871c9..4e94f9b36a14 100644 --- a/i18nutil/source/utility/paper.cxx +++ b/i18nutil/source/utility/paper.cxx @@ -173,10 +173,10 @@ void PaperInfo::doSloppyFit() { if (i == PAPER_USER) continue; - tools::Long lDiffW = labs(aDinTab[i].m_nWidth - m_nPaperWidth); - tools::Long lDiffH = labs(aDinTab[i].m_nHeight - m_nPaperHeight); - tools::Long lFlipDiffW = labs(aDinTab[i].m_nHeight - m_nPaperWidth); - tools::Long lFlipDiffH = labs(aDinTab[i].m_nWidth - m_nPaperHeight); + tools::Long lDiffW = std::abs(aDinTab[i].m_nWidth - m_nPaperWidth); + tools::Long lDiffH = std::abs(aDinTab[i].m_nHeight - m_nPaperHeight); + tools::Long lFlipDiffW = std::abs(aDinTab[i].m_nHeight - m_nPaperWidth); + tools::Long lFlipDiffH = std::abs(aDinTab[i].m_nWidth - m_nPaperHeight); if ( (lDiffW < MAXSLOPPY && lDiffH < MAXSLOPPY) || (lFlipDiffW < MAXSLOPPY && lFlipDiffH < MAXSLOPPY) ) @@ -193,8 +193,8 @@ bool PaperInfo::sloppyEqual(const PaperInfo &rOther) const { return ( - (labs(m_nPaperWidth - rOther.m_nPaperWidth) < MAXSLOPPY) && - (labs(m_nPaperHeight - rOther.m_nPaperHeight) < MAXSLOPPY) + (std::abs(m_nPaperWidth - rOther.m_nPaperWidth) < MAXSLOPPY) && + (std::abs(m_nPaperHeight - rOther.m_nPaperHeight) < MAXSLOPPY) ); } @@ -205,11 +205,11 @@ tools::Long PaperInfo::sloppyFitPageDimension(tools::Long nDimension) if (i == PAPER_USER) continue; tools::Long lDiff; - lDiff = labs(aDinTab[i].m_nWidth - nDimension); + lDiff = std::abs(aDinTab[i].m_nWidth - nDimension); if ( lDiff < MAXSLOPPY ) return aDinTab[i].m_nWidth; - lDiff = labs(aDinTab[i].m_nHeight - nDimension); + lDiff = std::abs(aDinTab[i].m_nHeight - nDimension); if ( lDiff < MAXSLOPPY ) return aDinTab[i].m_nHeight; } diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index 2d815bb10c93..be2a00a94e76 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <cstdlib> + #include <postit.hxx> #include <validat.hxx> #include <tabvwsh.hxx> @@ -90,24 +94,25 @@ static void lcl_AssertRectEqualWithTolerance(const OString& sInfo, // Left OString sMsg = sInfo + " Left expected " + OString::number(rExpected.Left()) + " actual " + OString::number(rActual.Left()) + " Tolerance " + OString::number(nTolerance); - CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Left() - rActual.Left()) <= nTolerance); + CPPUNIT_ASSERT_MESSAGE( + sMsg.getStr(), std::abs(rExpected.Left() - rActual.Left()) <= nTolerance); // Top sMsg = sInfo + " Top expected " + OString::number(rExpected.Top()) + " actual " + OString::number(rActual.Top()) + " Tolerance " + OString::number(nTolerance); - CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Top() - rActual.Top()) <= nTolerance); + CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - rActual.Top()) <= nTolerance); // Width sMsg = sInfo + " Width expected " + OString::number(rExpected.GetWidth()) + " actual " + OString::number(rActual.GetWidth()) + " Tolerance " + OString::number(nTolerance); CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), - labs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance); + std::abs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance); // Height sMsg = sInfo + " Height expected " + OString::number(rExpected.GetHeight()) + " actual " + OString::number(rActual.GetHeight()) + " Tolerance " + OString::number(nTolerance); CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), - labs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); + std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); } static void lcl_AssertPointEqualWithTolerance(const OString& sInfo, const Point rExpected, @@ -116,11 +121,11 @@ static void lcl_AssertPointEqualWithTolerance(const OString& sInfo, const Point // X OString sMsg = sInfo + " X expected " + OString::number(rExpected.X()) + " actual " + OString::number(rActual.X()) + " Tolerance " + OString::number(nTolerance); - CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.X() - rActual.X()) <= nTolerance); + CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.X() - rActual.X()) <= nTolerance); // Y sMsg = sInfo + " Y expected " + OString::number(rExpected.Y()) + " actual " + OString::number(rActual.Y()) + " Tolerance " + OString::number(nTolerance); - CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Y() - rActual.Y()) <= nTolerance); + CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Y() - rActual.Y()) <= nTolerance); } void ScFiltersTest::testTdf137576_Measureline() diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 2ba82ae91944..c481260378c7 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -39,6 +39,7 @@ #include <orcus/csv_parser.hpp> +#include <cstdlib> #include <fstream> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -99,7 +100,7 @@ const FileFormat ScBootstrapFixture::aFileFormats[] = { bool testEqualsWithTolerance( tools::Long nVal1, tools::Long nVal2, tools::Long nTol ) { - return ( labs( nVal1 - nVal2 ) <= nTol ); + return ( std::abs( nVal1 - nVal2 ) <= nTol ); } void loadFile(const OUString& aFileName, std::string& aContent) diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index 6eac2bc2b859..c8753cb99aa9 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <cstdlib> + #include <test/calc_unoapi_test.hxx> #include <comphelper/dispatchcommand.hxx> @@ -83,24 +87,25 @@ static void lcl_AssertRectEqualWithTolerance(const OString& sInfo, // Left OString sMsg = sInfo + " Left expected " + OString::number(rExpected.Left()) + " actual " + OString::number(rActual.Left()) + " Tolerance " + OString::number(nTolerance); - CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Left() - rActual.Left()) <= nTolerance); + CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), + std::abs(rExpected.Left() - rActual.Left()) <= nTolerance); // Top sMsg = sInfo + " Top expected " + OString::number(rExpected.Top()) + " actual " + OString::number(rActual.Top()) + " Tolerance " + OString::number(nTolerance); - CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Top() - rActual.Top()) <= nTolerance); + CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - rActual.Top()) <= nTolerance); // Width sMsg = sInfo + " Width expected " + OString::number(rExpected.GetWidth()) + " actual " + OString::number(rActual.GetWidth()) + " Tolerance " + OString::number(nTolerance); CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), - labs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance); + std::abs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance); // Height sMsg = sInfo + " Height expected " + OString::number(rExpected.GetHeight()) + " actual " + OString::number(rActual.GetHeight()) + " Tolerance " + OString::number(nTolerance); CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), - labs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); + std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); } void ScShapeTest::testHideColsShow() diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 4a8d4b86469b..5e7f367d6445 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -75,6 +75,7 @@ #include <vcl/fieldvalues.hxx> #include <memory> #include <algorithm> +#include <cstdlib> namespace com::sun::star::embed { class XEmbeddedObject; } @@ -646,13 +647,13 @@ bool lcl_AreRectanglesApproxEqual(const tools::Rectangle& rRectA, const tools::R { // Twips <-> Hmm conversions introduce +-1 differences although there are no real changes in the object. // Therefore test with == is not appropriate in some cases. - if (std::labs(rRectA.Left() - rRectB.Left()) > 1) + if (std::abs(rRectA.Left() - rRectB.Left()) > 1) return false; - if (std::labs(rRectA.Top() - rRectB.Top()) > 1) + if (std::abs(rRectA.Top() - rRectB.Top()) > 1) return false; - if (std::labs(rRectA.Right() - rRectB.Right()) > 1) + if (std::abs(rRectA.Right() - rRectB.Right()) > 1) return false; - if (std::labs(rRectA.Bottom() - rRectB.Bottom()) > 1) + if (std::abs(rRectA.Bottom() - rRectB.Bottom()) > 1) return false; return true; } diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx index 055e1941f9d8..44aa1edaa51c 100644 --- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx +++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx @@ -42,6 +42,7 @@ #include <strings.hrc> #include <algorithm> +#include <cstdlib> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; @@ -535,7 +536,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint refScMarkData.FillRangeListWithMarks(mpMarkedRanges.get(), true); //For Whole Col Row - bool bWholeRow = ::labs(aMarkRange.aStart.Row() - aMarkRange.aEnd.Row()) == pDoc->MaxRow() ; + bool bWholeRow = std::abs(aMarkRange.aStart.Row() - aMarkRange.aEnd.Row()) == pDoc->MaxRow() ; bool bWholeCol = ::abs(aMarkRange.aStart.Col() - aMarkRange.aEnd.Col()) == pDoc->MaxCol() ; if ((bNewMarked || bIsMark || bIsMultMark ) && (bWholeCol || bWholeRow)) { @@ -547,7 +548,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint CommitFocusCell(aNewCell); } bool bLastIsWholeColRow = - (::labs(m_aLastWithInMarkRange.aStart.Row() - m_aLastWithInMarkRange.aEnd.Row()) == pDoc->MaxRow() && bWholeRow) || + (std::abs(m_aLastWithInMarkRange.aStart.Row() - m_aLastWithInMarkRange.aEnd.Row()) == pDoc->MaxRow() && bWholeRow) || (::abs(m_aLastWithInMarkRange.aStart.Col() - m_aLastWithInMarkRange.aEnd.Col()) == pDoc->MaxCol() && bWholeCol); bool bSelSmaller= bLastIsWholeColRow && diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx index 1d3c476ee0fb..f52e5947cbfa 100644 --- a/sc/source/ui/view/drawvie3.cxx +++ b/sc/source/ui/view/drawvie3.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> + #include <svx/svdograf.hxx> #include <svx/svdoole2.hxx> #include <svx/ImageMapInfo.hxx> @@ -142,13 +146,13 @@ bool lcl_AreRectanglesApproxEqual(const tools::Rectangle& rRectA, const tools::R { // Twips <-> Hmm conversions introduce +-1 differences although the rectangles should actually // be equal. Therefore test with == is not appropriate in some cases. - if (std::labs(rRectA.Left() - rRectB.Left()) > 1) + if (std::abs(rRectA.Left() - rRectB.Left()) > 1) return false; - if (std::labs(rRectA.Top() - rRectB.Top()) > 1) + if (std::abs(rRectA.Top() - rRectB.Top()) > 1) return false; - if (std::labs(rRectA.Right() - rRectB.Right()) > 1) + if (std::abs(rRectA.Right() - rRectB.Right()) > 1) return false; - if (std::labs(rRectA.Bottom() - rRectB.Bottom()) > 1) + if (std::abs(rRectA.Bottom() - rRectB.Bottom()) > 1) return false; return true; } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index c5274ec4c23b..f15418a4e998 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -19,6 +19,7 @@ #include <scitems.hxx> +#include <cstdlib> #include <memory> #include <editeng/adjustitem.hxx> #include <sot/storage.hxx> @@ -3676,8 +3677,8 @@ sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt ) { if ( &rThisDoc == pSourceDoc && nTab == aSourceRange.aStart.Tab() ) { - tools::Long nDeltaX = labs( static_cast< tools::Long >( nNewDragX - nSourceStartX ) ); - tools::Long nDeltaY = labs( static_cast< tools::Long >( nNewDragY - nSourceStartY ) ); + tools::Long nDeltaX = std::abs( static_cast< tools::Long >( nNewDragX - nSourceStartX ) ); + tools::Long nDeltaY = std::abs( static_cast< tools::Long >( nNewDragY - nSourceStartY ) ); if ( nDeltaX <= nDeltaY ) { eDragInsertMode = INS_CELLSDOWN; diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index fba5f93f5499..4c7dc3d0eb42 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -41,6 +41,8 @@ #include <sdpage.hxx> #include <cfloat> +#include <cstdlib> + #include <rtl/character.hxx> using namespace css; @@ -2695,14 +2697,14 @@ void SdOOXMLExportTest2::testTdf1225573_FontWorkScaleX() awt::Rectangle aBoundRectArch; xShapeArchProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectArch; // difference should be zero, but allow some range for stroke thickness - CPPUNIT_ASSERT_LESS(50L, labs(aBoundRectArch.Width - 13081)); + CPPUNIT_ASSERT_LESS(sal_Int32(50), std::abs(aBoundRectArch.Width - 13081)); // Error was, that text in shapes of category "Warp" was not scaled to the path. uno::Reference<beans::XPropertySet> xShapeWaveProps(getShapeFromPage(0, 1, xDocShRef)); awt::Rectangle aBoundRectWave; xShapeWaveProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectWave; // difference should be zero, but allow some range for stroke thickness - CPPUNIT_ASSERT_LESS(50L, labs(aBoundRectWave.Width - 11514)); + CPPUNIT_ASSERT_LESS(sal_Int32(50), std::abs(aBoundRectWave.Width - 11514)); xDocShRef->DoClose(); } diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index c45e782be567..25e2aaea7b56 100644 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -20,6 +20,7 @@ #include <sal/config.h> #include <cassert> +#include <cstdlib> #include <controller/SlsClipboard.hxx> @@ -699,9 +700,9 @@ sal_Int8 Clipboard::ExecuteDrop ( SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; const Point aEventModelPosition ( pTargetWindow->PixelToLogic (rEvent.maPosPixel)); - const sal_Int32 nXOffset (labs (pDragTransferable->GetStartPos().X() + const sal_Int32 nXOffset (std::abs (pDragTransferable->GetStartPos().X() - aEventModelPosition.X())); - const sal_Int32 nYOffset (labs (pDragTransferable->GetStartPos().Y() + const sal_Int32 nYOffset (std::abs (pDragTransferable->GetStartPos().Y() - aEventModelPosition.Y())); bool bContinue = ( pDragTransferable->GetView() != &mrSlideSorter.GetView() ) diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 3c78de3ba5b0..9408e62dbdfa 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -39,6 +39,7 @@ #include <rtl/math.hxx> #include <cassert> +#include <cstdlib> #include <math.h> #include <memory> #include <float.h> @@ -871,7 +872,7 @@ bool IsPointInLine(const Point &rPoint1, static const double eps = 5.0 * DBL_EPSILON; double fLambda; - if (labs(rHeading2.X()) > labs(rHeading2.Y())) + if (std::abs(rHeading2.X()) > std::abs(rHeading2.Y())) { fLambda = (rPoint1.X() - rPoint2.X()) / static_cast<double>(rHeading2.X()); bRes = fabs(rPoint1.Y() - (rPoint2.Y() + fLambda * rHeading2.Y())) < eps; diff --git a/starmath/source/rect.cxx b/starmath/source/rect.cxx index 1c9ecb71ccdc..e3506c67de77 100644 --- a/starmath/source/rect.cxx +++ b/starmath/source/rect.cxx @@ -30,6 +30,7 @@ #include <smmod.hxx> #include <cassert> +#include <cstdlib> namespace { @@ -588,8 +589,8 @@ tools::Long SmRect::OrientedDist(const Point &rPoint) const // build distance vector Point aDist (aRef - rPoint); - tools::Long nAbsX = labs(aDist.X()), - nAbsY = labs(aDist.Y()); + tools::Long nAbsX = std::abs(aDist.X()), + nAbsY = std::abs(aDist.Y()); return bIsInside ? - std::min(nAbsX, nAbsY) : std::max (nAbsX, nAbsY); } diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index 3007806c61af..737ab5bdf6d0 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <cstdlib> + #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> #include <rtl/ustring.hxx> @@ -104,7 +108,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testViewBoxLeftTop) awt::Rectangle aBoundRectLR; xShapeLRProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectLR; // difference should be zero, but allow some rounding errors - CPPUNIT_ASSERT_LESS(3L, labs(aFrameRectLR.X - aBoundRectLR.X)); + CPPUNIT_ASSERT_LESS(sal_Int32(3), std::abs(aFrameRectLR.X - aBoundRectLR.X)); // Get the shape "topbottom". Error was, that the identifier "top" was always set to zero, thus // the path was outside the frame rectangle for a viewBox having a positive "top" value. @@ -116,7 +120,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testViewBoxLeftTop) awt::Rectangle aBoundRectTB; xShapeTBProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectTB; // difference should be zero, but allow some rounding errors - CPPUNIT_ASSERT_LESS(3L, labs(aFrameRectTB.Y - aBoundRectTB.Y)); + CPPUNIT_ASSERT_LESS(sal_Int32(3), std::abs(aFrameRectTB.Y - aBoundRectTB.Y)); } CPPUNIT_TEST_FIXTURE(CustomshapesTest, testAccuracyCommandX) diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx index 625a9034831b..f11ce49b3beb 100644 --- a/svx/source/accessibility/AccessibleTextHelper.cxx +++ b/svx/source/accessibility/AccessibleTextHelper.cxx @@ -17,10 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> -// Global header - - +#include <cstdlib> #include <memory> #include <utility> #include <algorithm> @@ -1043,7 +1042,7 @@ namespace accessibility // repeat that later on, e.g. for PARA_MOVED events) bool bEverythingUpdated( false ); - if( labs( nNewParas - nCurrParas ) == 1 && + if( std::abs( nNewParas - nCurrParas ) == 1 && aFunctor.GetNumberOfParasChanged() == 1 ) { // #103483# Exactly one paragraph added/removed. This is diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 8ef5a6ebec4f..a509520ba08c 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -58,6 +58,7 @@ #include <sal/log.hxx> #include <algorithm> +#include <cstdlib> #include <math.h> #include <unordered_set> @@ -552,8 +553,8 @@ void EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryIt { nCoordLeft = aViewBox.X; nCoordTop = aViewBox.Y; - nCoordWidthG = labs( aViewBox.Width ); - nCoordHeightG = labs( aViewBox.Height); + nCoordWidthG = std::abs( aViewBox.Width ); + nCoordHeightG = std::abs( aViewBox.Height); } const OUString sPath( "Path" ); diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx index abd592d6ce01..5c9989320695 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> #include <svx/strings.hrc> #include <svx/dialmgr.hxx> @@ -529,9 +532,9 @@ void E3dScene::RotateScene (const Point& rRef, double sn, double cs) UpperLeft = aOutRect.TopLeft(); LowerRight = aOutRect.BottomRight(); - tools::Long dxOutRectHalf = labs(UpperLeft.X() - LowerRight.X()); + tools::Long dxOutRectHalf = std::abs(UpperLeft.X() - LowerRight.X()); dxOutRectHalf /= 2; - tools::Long dyOutRectHalf = labs(UpperLeft.Y() - LowerRight.Y()); + tools::Long dyOutRectHalf = std::abs(UpperLeft.Y() - LowerRight.Y()); dyOutRectHalf /= 2; // Only the center is moved. The corners are moved by NbcMove. For the diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index c25783764f27..5a4a79be984c 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -40,6 +40,7 @@ #include <vector> #include <iterator> #include <algorithm> +#include <cstdlib> #include <cstring> #include <limits.h> #include <cmath> @@ -122,8 +123,8 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, tools::Rectangle aRect( rRect ); aRect.Justify(); // SJ: i9140 - nHorzRound = std::min( nHorzRound, static_cast<sal_uInt32>(labs( aRect.GetWidth() >> 1 )) ); - nVertRound = std::min( nVertRound, static_cast<sal_uInt32>(labs( aRect.GetHeight() >> 1 )) ); + nHorzRound = std::min( nHorzRound, static_cast<sal_uInt32>(std::abs( aRect.GetWidth() >> 1 )) ); + nVertRound = std::min( nVertRound, static_cast<sal_uInt32>(std::abs( aRect.GetHeight() >> 1 )) ); if( !nHorzRound && !nVertRound ) { @@ -179,7 +180,7 @@ ImplPolygon::ImplPolygon( const Point& rCenter, tools::Long nRadX, tools::Long n { nPoints = static_cast<sal_uInt16>(MinMax( ( F_PI * ( 1.5 * ( nRadX + nRadY ) - - sqrt( static_cast<double>(labs(nRadXY)) ) ) ), + sqrt( static_cast<double>(std::abs(nRadXY)) ) ) ), 32, 256 )); } else @@ -242,7 +243,7 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c { nPoints = static_cast<sal_uInt16>(MinMax( ( F_PI * ( 1.5 * ( nRadX + nRadY ) - - sqrt( static_cast<double>(labs(nRadXY)) ) ) ), + sqrt( static_cast<double>(std::abs(nRadXY)) ) ) ), 32, 256 )); } else diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx index 6c0b4b8dfaf7..8020848b6e38 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <cstdlib> + #include <unotest/filters-test.hxx> #include <test/bootstrapfixture.hxx> @@ -95,7 +99,7 @@ void VclFiltersTest::testScaling() CPPUNIT_ASSERT( aBitmapEx.Scale( 0.1937046, 0.193154, i ) ); Size aAfter( aBitmapEx.GetSizePixel() ); fprintf( stderr, "size %" SAL_PRIdINT64 ", %" SAL_PRIdINT64 "\n", sal_Int64(aAfter.Width()), sal_Int64(aAfter.Height()) ); - CPPUNIT_ASSERT( labs (aAfter.Height() - aAfter.Width()) <= 1 ); + CPPUNIT_ASSERT( std::abs (aAfter.Height() - aAfter.Width()) <= 1 ); } } diff --git a/vcl/source/gdi/bmpacc3.cxx b/vcl/source/gdi/bmpacc3.cxx index bfc9a46ba291..dcd449aa820d 100644 --- a/vcl/source/gdi/bmpacc3.cxx +++ b/vcl/source/gdi/bmpacc3.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> + #include <vcl/bitmap.hxx> #include <bmpfast.hxx> @@ -145,8 +149,8 @@ void BitmapWriteAccess::DrawLine( const Point& rStart, const Point& rEnd ) } else { - const tools::Long nDX = labs( rEnd.X() - rStart.X() ); - const tools::Long nDY = labs( rEnd.Y() - rStart.Y() ); + const tools::Long nDX = std::abs( rEnd.X() - rStart.X() ); + const tools::Long nDY = std::abs( rEnd.Y() - rStart.Y() ); tools::Long nX1; tools::Long nY1; tools::Long nX2; diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 454363c6d88c..8ffa24994ebb 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -2790,7 +2790,7 @@ bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, BmpConversion eColorConve const Point aTLPix( aVDev->LogicToPixel( aNullPt, GetPrefMapMode() ) ); const Point aBRPix( aVDev->LogicToPixel( Point( GetPrefSize().Width() - 1, GetPrefSize().Height() - 1 ), GetPrefMapMode() ) ); Size aDrawSize( aVDev->LogicToPixel( GetPrefSize(), GetPrefMapMode() ) ); - Size aSizePix( labs( aBRPix.X() - aTLPix.X() ) + 1, labs( aBRPix.Y() - aTLPix.Y() ) + 1 ); + Size aSizePix( std::abs( aBRPix.X() - aTLPix.X() ) + 1, std::abs( aBRPix.Y() - aTLPix.Y() ) + 1 ); sal_uInt32 nMaximumExtent = 256; if (!rBitmapEx.IsEmpty()) diff --git a/vcl/source/gdi/regionband.cxx b/vcl/source/gdi/regionband.cxx index ed309b140edc..31d942735d0b 100644 --- a/vcl/source/gdi/regionband.cxx +++ b/vcl/source/gdi/regionband.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstdlib> + #include <tools/stream.hxx> #include <regionband.hxx> #include <osl/diagnose.h> @@ -480,8 +484,8 @@ void RegionBand::InsertLine(const Point& rStartPt, const Point& rEndPt, tools::L } else if ( rStartPt.Y() != rEndPt.Y() ) { - const tools::Long nDX = labs( rEndPt.X() - rStartPt.X() ); - const tools::Long nDY = labs( rEndPt.Y() - rStartPt.Y() ); + const tools::Long nDX = std::abs( rEndPt.X() - rStartPt.X() ); + const tools::Long nDY = std::abs( rEndPt.Y() - rStartPt.Y() ); const tools::Long nStartX = rStartPt.X(); const tools::Long nStartY = rStartPt.Y(); const tools::Long nEndX = rEndPt.X(); diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 7d3d6485d2e7..519f975a0f12 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -18,6 +18,7 @@ */ #include <cassert> +#include <cstdlib> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> @@ -203,7 +204,7 @@ Bitmap OutputDevice::GetDownsampledBitmap( const Size& rDstSz, Size aDstSizeTwip( PixelToLogic(LogicToPixel(rDstSz), MapMode(MapUnit::MapTwip)) ); // #103209# Normalize size (mirroring has to happen outside of this method) - aDstSizeTwip = Size( labs(aDstSizeTwip.Width()), labs(aDstSizeTwip.Height()) ); + aDstSizeTwip = Size( std::abs(aDstSizeTwip.Width()), std::abs(aDstSizeTwip.Height()) ); const Size aBmpSize( aBmp.GetSizePixel() ); const double fBmpPixelX = aBmpSize.Width(); diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx index 44cf941149bb..374282c374df 100644 --- a/vcl/source/outdev/hatch.cxx +++ b/vcl/source/outdev/hatch.cxx @@ -18,6 +18,7 @@ */ #include <cassert> +#include <cstdlib> #include <osl/diagnose.h> #include <tools/line.hxx> @@ -255,7 +256,7 @@ void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long n } else if( nAngle >= Degree10(-450) && nAngle <= Degree10(450) ) { - const double fAngle = F_PI1800 * labs( nAngle.get() ); + const double fAngle = F_PI1800 * std::abs( nAngle.get() ); const double fTan = tan( fAngle ); const tools::Long nYOff = FRound( ( rRect.Right() - rRect.Left() ) * fTan ); tools::Long nPY; @@ -288,7 +289,7 @@ void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long n } else { - const double fAngle = F_PI1800 * labs( nAngle.get() ); + const double fAngle = F_PI1800 * std::abs( nAngle.get() ); const double fTan = tan( fAngle ); const tools::Long nXOff = FRound( ( rRect.Bottom() - rRect.Top() ) / fTan ); tools::Long nPX; diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index cff1ccb59ad6..de022280c4b2 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <cstdlib> #include <memory> #include <numeric> @@ -801,8 +802,8 @@ std::shared_ptr<SalBitmap> WinSalGraphicsImpl::getBitmap( tools::Long nX, tools: std::shared_ptr<WinSalBitmap> pSalBitmap; - nDX = labs( nDX ); - nDY = labs( nDY ); + nDX = std::abs( nDX ); + nDY = std::abs( nDY ); HDC hDC = mrParent.getHDC(); HBITMAP hBmpBitmap = CreateCompatibleBitmap( hDC, nDX, nDY ); |