diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-11 08:47:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-15 07:26:17 +0100 |
commit | 7d8e94444d989d0ac4a4055b207726708e9ec0da (patch) | |
tree | ce3e4a09ed7932496c4d901360ff23787c8f6e24 /vcl | |
parent | 80fb8d406ced47e6a2089f0c8ba5c103d2fec91f (diff) |
convert a<b?a:b to std::min(a,b)
with something like
git grep -nP '(.*)\s*<\s*(.*)\s*\?\s*\g1\s*:\s*\g2' -- *.?xx
Change-Id: Id5078b35961847feb78a66204fdb7598ee63fd23
Note: we also convert a>b?b:a
Reviewed-on: https://gerrit.libreoffice.org/47736
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/backendtest/VisualBackendTest.cxx | 2 | ||||
-rw-r--r-- | vcl/opengl/scale.cxx | 2 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapScaleConvolution.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/field2.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/imp_listbox.cxx | 4 | ||||
-rw-r--r-- | vcl/source/filter/graphicfilter.cxx | 10 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl2.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/status.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/dtrans/X11_selection.cxx | 7 | ||||
-rw-r--r-- | vcl/unx/generic/print/common_gfx.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 2 | ||||
-rw-r--r-- | vcl/workben/svptest.cxx | 12 |
14 files changed, 29 insertions, 28 deletions
diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx index 02623767cf94..ad72868545a5 100644 --- a/vcl/backendtest/VisualBackendTest.cxx +++ b/vcl/backendtest/VisualBackendTest.cxx @@ -72,7 +72,7 @@ void drawBitmapScaledAndCentered(tools::Rectangle const & rRect, Bitmap aBitmap, Size aBitmapSize(aBitmap.GetSizePixel()); - double fWidthHeight = nWidth > nHeight ? nHeight : nWidth; + double fWidthHeight = std::min(nWidth, nHeight); double fScale = fWidthHeight / aBitmapSize.Width(); aBitmap.Scale(fScale, fScale, aFlag); diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx index 7981a59ef89d..6da1526e7c01 100644 --- a/vcl/opengl/scale.cxx +++ b/vcl/opengl/scale.cxx @@ -80,7 +80,7 @@ void OpenGLSalBitmap::ImplCreateKernel( { const double fSamplingRadius(rKernel.GetWidth()); const double fScaledRadius((fScale < 1.0) ? fSamplingRadius / fScale : fSamplingRadius); - const double fFilterFactor((fScale < 1.0) ? fScale : 1.0); + const double fFilterFactor(std::min(fScale, 1.0)); int aNumberOfContributions; double aSum( 0 ); diff --git a/vcl/source/bitmap/BitmapScaleConvolution.cxx b/vcl/source/bitmap/BitmapScaleConvolution.cxx index 498d1084ab73..5ecdc39da1cd 100644 --- a/vcl/source/bitmap/BitmapScaleConvolution.cxx +++ b/vcl/source/bitmap/BitmapScaleConvolution.cxx @@ -44,7 +44,7 @@ void ImplCalculateContributions( const double fSamplingRadius(aKernel.GetWidth()); const double fScale(aDestinationSize / static_cast< double >(aSourceSize)); const double fScaledRadius((fScale < 1.0) ? fSamplingRadius / fScale : fSamplingRadius); - const double fFilterFactor((fScale < 1.0) ? fScale : 1.0); + const double fFilterFactor(std::min(fScale, 1.0)); aNumberOfContributions = (long(fabs(ceil(fScaledRadius))) * 2) + 1; const long nAllocSize(aDestinationSize * aNumberOfContributions); diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 015695df2c1f..746113b6b92f 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -2236,7 +2236,7 @@ void TimeField::ImplTimeSpinArea( bool bUp ) sal_Int32 nPos2 = aText.indexOf( ImplGetLocaleDataWrapper().getTime100SecSep(), nPos ); //which ever comes first, bearing in mind that one might not be there if (nPos1 >= 0 && nPos2 >= 0) - nPos = nPos1 < nPos2 ? nPos1 : nPos2; + nPos = std::min(nPos1, nPos2); else if (nPos1 >= 0) nPos = nPos1; else diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 98c88b674cd7..a6ca96f0a79a 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -289,7 +289,7 @@ sal_Int32 ImplEntryList::FindEntry( const void* pData ) const long ImplEntryList::GetAddedHeight( sal_Int32 i_nEndIndex, sal_Int32 i_nBeginIndex ) const { long nHeight = 0; - sal_Int32 nStart = i_nEndIndex > i_nBeginIndex ? i_nBeginIndex : i_nEndIndex; + sal_Int32 nStart = std::min(i_nEndIndex, i_nBeginIndex); sal_Int32 nStop = std::max(i_nEndIndex, i_nBeginIndex); sal_Int32 nEntryCount = GetEntryCount(); if( 0 <= nStop && nStop != LISTBOX_ENTRY_NOTFOUND && nEntryCount != 0 ) @@ -1995,7 +1995,7 @@ void ImplListBoxWindow::ScrollHorz( long n ) if( mnLeft ) { long nAbs = -n; - nDiff = - ( ( mnLeft > nAbs ) ? nAbs : mnLeft ); + nDiff = - std::min( mnLeft, nAbs ); } } diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 970af31dd060..80d7a5ac8d77 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -608,7 +608,7 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, //--------------------------- XBM ------------------------------------ if( !bTest ) { - sal_uLong nSize = ( nStreamLen > 2048 ) ? 2048 : nStreamLen; + sal_uLong nSize = std::min<sal_uLong>( nStreamLen, 2048 ); std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8 [ nSize ]); rStream.Seek( nStreamPos ); @@ -633,7 +633,7 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, if( !bTest ) { sal_uInt8* pCheckArray = sFirstBytes; - sal_uLong nCheckSize = nStreamLen < 256 ? nStreamLen : 256; + sal_uLong nCheckSize = std::min<sal_uLong>(nStreamLen, 256); sal_uInt8 sExtendedOrDecompressedFirstBytes[2048]; sal_uLong nDecompressedSize = nCheckSize; @@ -647,7 +647,7 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, rStream.Seek(nStreamPos); aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, false, true); nDecompressedSize = aCodec.Read(rStream, sExtendedOrDecompressedFirstBytes, 2048); - nCheckSize = nDecompressedSize < 256 ? nDecompressedSize : 256; + nCheckSize = std::min<sal_uLong>(nDecompressedSize, 256); aCodec.EndCompression(); pCheckArray = sExtendedOrDecompressedFirstBytes; @@ -688,11 +688,11 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, if (bIsGZip) { - nCheckSize = nDecompressedSize < 2048 ? nDecompressedSize : 2048; + nCheckSize = std::min<sal_uLong>(nDecompressedSize, 2048); } else { - nCheckSize = nStreamLen < 2048 ? nStreamLen : 2048; + nCheckSize = std::min<sal_uLong>(nStreamLen, 2048); rStream.Seek(nStreamPos); nCheckSize = rStream.ReadBytes(sExtendedOrDecompressedFirstBytes, nCheckSize); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 89204dad077c..44174f392f70 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3057,7 +3057,7 @@ sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 const * pEncoding, { if( nCount ) aContents.append( "endbfchar\n" ); - aContents.append( static_cast<sal_Int32>((nMapped-nCount > 100) ? 100 : nMapped-nCount ) ); + aContents.append( static_cast<sal_Int32>(std::min(nMapped-nCount, 100)) ); aContents.append( " beginbfchar\n" ); } aContents.append( '<' ); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index a97fa4b22108..f1f5c2661783 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -1624,7 +1624,7 @@ long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_b while( nBitInByte != 8 ) { if( (nByte & nMask) != (i_bSet ? nMask : 0) ) - return nIndex < i_nW ? nIndex : i_nW; + return std::min(nIndex, i_nW); nMask = nMask >> 1; nBitInByte++; nIndex++; @@ -1668,7 +1668,7 @@ long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_b nIndex += pRunTable[nByte]; } } - return nIndex < i_nW ? nIndex : i_nW; + return std::min(nIndex, i_nW); } struct BitStreamState diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index c7361e03094c..4c2c4852db51 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1435,7 +1435,7 @@ void PrintDialog::updateNupFromPages() maNUpPage.mpSheetMarginEdt->SetMax( maNUpPage.mpSheetMarginEdt->Normalize( - nHorzMax > nVertMax ? nVertMax : nHorzMax ), FUNIT_100TH_MM ); + std::min(nHorzMax, nVertMax) ), FUNIT_100TH_MM ); // maximum page distance nHorzMax = (aSize.Width() - 2*nSheetMargin); @@ -1452,7 +1452,7 @@ void PrintDialog::updateNupFromPages() maNUpPage.mpPageMarginEdt->SetMax( maNUpPage.mpSheetMarginEdt->Normalize( - nHorzMax > nVertMax ? nVertMax : nHorzMax ), FUNIT_100TH_MM ); + std::min(nHorzMax, nVertMax ) ), FUNIT_100TH_MM ); } maNUpPage.mpNupRowsEdt->SetValue( nRows ); diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 82f9ab0aae2d..0439acd3b7c6 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -470,7 +470,7 @@ void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, cons bool bNeedErase = ImplGetSVData()->maNWFData.mbProgressNeedsErase; long nFullWidth = (nPrgsWidth + nOffset) * (10000 / nPercentCount); - long nPerc = (nPercent2 > 10000) ? 10000 : nPercent2; + long nPerc = std::min<sal_uInt16>(nPercent2, 10000); ImplControlValue aValue(nFullWidth * nPerc / 10000); tools::Rectangle aDrawRect(rPos, Size(nFullWidth, nPrgsHeight)); tools::Rectangle aControlRegion(aDrawRect); diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index 605670ff3b7a..e0c257c45eb2 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -70,6 +70,7 @@ #include <comphelper/solarmutex.hxx> #include <cppuhelper/supportsservice.hxx> +#include <algorithm> #define DRAG_EVENT_MASK ButtonPressMask |\ ButtonReleaseMask |\ @@ -1932,12 +1933,12 @@ bool SelectionManager::handleSendPropertyNotify( XPropertyEvent const & rNotify IncrementalTransfer& rInc = inc_it->second; int nBytes = rInc.m_aData.getLength() - rInc.m_nBufferPos; - nBytes = (nBytes > m_nIncrementalThreshold) ? m_nIncrementalThreshold : nBytes; + nBytes = std::min(nBytes, m_nIncrementalThreshold); if( nBytes < 0 ) // sanity check nBytes = 0; #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "pushing %d bytes: \"%.*s\"...\n", - nBytes, nBytes > 32 ? 32 : nBytes, + nBytes, std::min(nBytes, 32), (const unsigned char*)rInc.m_aData.getConstArray()+rInc.m_nBufferPos ); #endif @@ -2939,7 +2940,7 @@ int SelectionManager::getXdndVersion( ::Window aWindow, ::Window& rProxy ) XFree( pBytes ); } - nVersion = nVersion > nXdndProtocolRevision ? nXdndProtocolRevision : nVersion; + nVersion = std::min<int>(nVersion, nXdndProtocolRevision); return nVersion; } diff --git a/vcl/unx/generic/print/common_gfx.cxx b/vcl/unx/generic/print/common_gfx.cxx index b0bad19cc41b..0bd2ffa2ea82 100644 --- a/vcl/unx/generic/print/common_gfx.cxx +++ b/vcl/unx/generic/print/common_gfx.cxx @@ -1029,7 +1029,7 @@ PrinterGfx::PSShowGlyph (const unsigned char nGlyphId) if( nLW == 0 ) nLW = maVirtualStatus.mnTextHeight; else - nLW = nLW < maVirtualStatus.mnTextHeight ? nLW : maVirtualStatus.mnTextHeight; + nLW = std::min(nLW, maVirtualStatus.mnTextHeight); psp::getValueOfDouble( pBuffer, static_cast<double>(nLW) / 30.0 ); } diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 8611141b424b..335b72db59de 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -143,7 +143,7 @@ namespace psp { OString aStr( pEnvLocale ); sal_Int32 nLen = aStr.getLength(); - aLoc.Language = OStringToOUString( aStr.copy( 0, nLen > 2 ? 2 : nLen ), RTL_TEXTENCODING_MS_1252 ); + aLoc.Language = OStringToOUString( aStr.copy( 0, std::min(nLen, 2) ), RTL_TEXTENCODING_MS_1252 ); if( nLen >=5 && aStr[2] == '_' ) aLoc.Country = OStringToOUString( aStr.copy( 3, 2 ), RTL_TEXTENCODING_MS_1252 ); else diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx index 21a6a86d20fe..e1d36cfe46b7 100644 --- a/vcl/workben/svptest.cxx +++ b/vcl/workben/svptest.cxx @@ -152,12 +152,12 @@ static Color approachColor( const Color& rFrom, const Color& rTo ) if( rFrom.GetRed() < rTo.GetRed() ) { nDiff = rTo.GetRed() - rFrom.GetRed(); - aColor.SetRed( rFrom.GetRed() + ( nDiff < 10 ? nDiff : 10 ) ); + aColor.SetRed( rFrom.GetRed() + std::min<sal_uInt8>( nDiff, 10 ) ); } else if( rFrom.GetRed() > rTo.GetRed() ) { nDiff = rFrom.GetRed() - rTo.GetRed(); - aColor.SetRed( rFrom.GetRed() - ( nDiff < 10 ? nDiff : 10 ) ); + aColor.SetRed( rFrom.GetRed() - std::min<sal_uInt8>( nDiff, 10 ) ); } else aColor.SetRed( rFrom.GetRed() ); @@ -166,12 +166,12 @@ static Color approachColor( const Color& rFrom, const Color& rTo ) if( rFrom.GetGreen() < rTo.GetGreen() ) { nDiff = rTo.GetGreen() - rFrom.GetGreen(); - aColor.SetGreen( rFrom.GetGreen() + ( nDiff < 10 ? nDiff : 10 ) ); + aColor.SetGreen( rFrom.GetGreen() + std::min<sal_uInt8>( nDiff, 10 ) ); } else if( rFrom.GetGreen() > rTo.GetGreen() ) { nDiff = rFrom.GetGreen() - rTo.GetGreen(); - aColor.SetGreen( rFrom.GetGreen() - ( nDiff < 10 ? nDiff : 10 ) ); + aColor.SetGreen( rFrom.GetGreen() - std::min<sal_uInt8>( nDiff, 10 ) ); } else aColor.SetGreen( rFrom.GetGreen() ); @@ -180,12 +180,12 @@ static Color approachColor( const Color& rFrom, const Color& rTo ) if( rFrom.GetBlue() < rTo.GetBlue() ) { nDiff = rTo.GetBlue() - rFrom.GetBlue(); - aColor.SetBlue( rFrom.GetBlue() + ( nDiff < 10 ? nDiff : 10 ) ); + aColor.SetBlue( rFrom.GetBlue() + std::min<sal_uInt8>( nDiff, 10 ) ); } else if( rFrom.GetBlue() > rTo.GetBlue() ) { nDiff = rFrom.GetBlue() - rTo.GetBlue(); - aColor.SetBlue( rFrom.GetBlue() - ( nDiff < 10 ? nDiff : 10 ) ); + aColor.SetBlue( rFrom.GetBlue() - std::min<sal_uInt8>( nDiff, 10 ) ); } else aColor.SetBlue( rFrom.GetBlue() ); |