[Libreoffice-commits] core.git: basic/source connectivity/source cppu/source cui/source editeng/source embeddedobj/source filter/source formula/source framework/source hwpfilter/source i18npool/source include/basegfx libreofficekit/source linguistic/source lotuswordpro/source onlineupdate/source oox/source opencl/source package/source registry/source sal/osl sal/rtl sc/inc sc/source sdext/source sd/source slideshow/source starmath/source svx/source sw/qa sw/source toolkit/source tools/source vcl/backendtest vcl/opengl vcl/source vcl/unx vcl/workben

Noel Grandin noel.grandin at collabora.co.uk
Mon Jan 15 06:26:53 UTC 2018


 basic/source/sbx/sbxscan.cxx                               |    2 +-
 connectivity/source/drivers/firebird/Blob.cxx              |    4 ++--
 connectivity/source/drivers/firebird/PreparedStatement.cxx |    6 +++---
 connectivity/source/drivers/postgresql/pq_resultset.cxx    |    2 +-
 cppu/source/typelib/typelib.cxx                            |    2 +-
 cui/source/tabpages/numpages.cxx                           |    2 +-
 editeng/source/uno/unoedhlp.cxx                            |    2 +-
 editeng/source/uno/unotext2.cxx                            |    4 ++--
 embeddedobj/source/commonembedding/embedobj.cxx            |    4 ++--
 embeddedobj/source/msole/ownview.cxx                       |    2 +-
 filter/source/msfilter/escherex.cxx                        |    2 +-
 filter/source/msfilter/svdfppt.cxx                         |    8 ++++----
 formula/source/ui/dlg/parawin.cxx                          |    4 ++--
 framework/source/uielement/recentfilesmenucontroller.cxx   |    2 +-
 hwpfilter/source/hwpread.cxx                               |    6 +++---
 i18npool/source/breakiterator/breakiterator_ctl.cxx        |    4 ++--
 i18npool/source/breakiterator/xdictionary.cxx              |    2 +-
 i18npool/source/search/levdis.cxx                          |   10 +++++-----
 i18npool/source/search/textsearch.cxx                      |    4 ++--
 i18npool/source/transliteration/textToPronounce_zh.cxx     |    2 +-
 i18npool/source/transliteration/transliteration_Ignore.cxx |    4 +---
 include/basegfx/numeric/ftools.hxx                         |    2 +-
 libreofficekit/source/gtk/lokdocview.cxx                   |    2 +-
 linguistic/source/misc.cxx                                 |    3 +--
 lotuswordpro/source/filter/explode.cxx                     |    2 +-
 lotuswordpro/source/filter/lwptable.cxx                    |    2 +-
 onlineupdate/source/update/updater/bspatch.cxx             |    2 +-
 oox/source/crypto/AgileEngine.cxx                          |    2 +-
 oox/source/ole/vbaexport.cxx                               |    2 +-
 opencl/source/opencl_device.cxx                            |    3 ++-
 package/source/zipapi/XUnbufferedStream.cxx                |    2 +-
 registry/source/reflwrit.cxx                               |    5 +++--
 sal/osl/unx/profile.cxx                                    |    2 +-
 sal/osl/unx/security.cxx                                   |    2 +-
 sal/osl/w32/profile.cxx                                    |    2 +-
 sal/rtl/alloc_cache.cxx                                    |    3 ++-
 sal/rtl/alloc_global.cxx                                   |    2 +-
 sal/rtl/cipher.cxx                                         |    3 ++-
 sal/rtl/math.cxx                                           |    2 +-
 sal/rtl/ustring.cxx                                        |    2 +-
 sc/inc/address.hxx                                         |    6 +++---
 sc/source/core/data/dpfilteredcache.cxx                    |    2 +-
 sc/source/core/data/table6.cxx                             |    4 ++--
 sc/source/core/opencl/op_spreadsheet.cxx                   |    2 +-
 sc/source/core/tool/compiler.cxx                           |    2 +-
 sc/source/core/tool/dbdata.cxx                             |    2 +-
 sc/source/core/tool/interpr3.cxx                           |    2 +-
 sc/source/core/tool/reftokenhelper.cxx                     |    2 +-
 sc/source/core/tool/scmatrix.cxx                           |    2 +-
 sc/source/filter/lotus/lotimpop.cxx                        |    2 +-
 sc/source/filter/lotus/op.cxx                              |   10 +++++-----
 sc/source/filter/qpro/qpro.cxx                             |    2 +-
 sc/source/filter/xml/xmlcelli.cxx                          |    8 ++++----
 sc/source/ui/view/tabview2.cxx                             |    4 ++--
 sd/source/filter/eppt/pptexsoundcollection.cxx             |    2 +-
 sdext/source/pdfimport/filterdet.cxx                       |    2 +-
 slideshow/source/engine/opengl/TransitionImpl.cxx          |    4 ++--
 slideshow/source/engine/transitions/spiralwipe.cxx         |    2 +-
 starmath/source/view.cxx                                   |    2 +-
 starmath/source/visitors.cxx                               |    2 +-
 svx/source/gallery2/galbrws2.cxx                           |    2 +-
 svx/source/svdraw/svdedtv2.cxx                             |    8 ++++----
 svx/source/svdraw/svdoashp.cxx                             |    2 +-
 sw/qa/core/Test-BigPtrArray.cxx                            |    2 +-
 sw/source/core/crsr/crsrsh.cxx                             |    2 +-
 sw/source/core/table/swnewtable.cxx                        |    4 ++--
 sw/source/core/text/EnhancedPDFExportHelper.cxx            |    2 +-
 sw/source/core/text/itratr.cxx                             |    2 +-
 sw/source/core/text/itrtxt.hxx                             |    2 +-
 sw/source/core/undo/unnum.cxx                              |    2 +-
 sw/source/filter/html/htmlatr.cxx                          |    2 +-
 sw/source/filter/html/htmlcss1.cxx                         |    2 +-
 sw/source/filter/ww8/wrtw8sty.cxx                          |    2 +-
 sw/source/filter/ww8/wrtww8.cxx                            |    2 +-
 sw/source/filter/ww8/ww8par.cxx                            |    4 ++--
 sw/source/filter/ww8/ww8scan.cxx                           |    2 +-
 sw/source/filter/xml/xmltbli.cxx                           |    2 +-
 sw/source/ui/envelp/labfmt.cxx                             |    2 +-
 sw/source/ui/table/instable.cxx                            |    2 +-
 toolkit/source/awt/vclxmenu.cxx                            |    4 ++--
 tools/source/zcodec/zcodec.cxx                             |    6 +++---
 vcl/backendtest/VisualBackendTest.cxx                      |    2 +-
 vcl/opengl/scale.cxx                                       |    2 +-
 vcl/source/bitmap/BitmapScaleConvolution.cxx               |    2 +-
 vcl/source/control/field2.cxx                              |    2 +-
 vcl/source/control/imp_listbox.cxx                         |    4 ++--
 vcl/source/filter/graphicfilter.cxx                        |   10 +++++-----
 vcl/source/gdi/pdfwriter_impl.cxx                          |    2 +-
 vcl/source/gdi/pdfwriter_impl2.cxx                         |    4 ++--
 vcl/source/window/printdlg.cxx                             |    4 ++--
 vcl/source/window/status.cxx                               |    2 +-
 vcl/unx/generic/dtrans/X11_selection.cxx                   |    7 ++++---
 vcl/unx/generic/print/common_gfx.cxx                       |    2 +-
 vcl/unx/generic/printer/ppdparser.cxx                      |    2 +-
 vcl/workben/svptest.cxx                                    |   12 ++++++------
 95 files changed, 152 insertions(+), 150 deletions(-)

New commits:
commit 7d8e94444d989d0ac4a4055b207726708e9ec0da
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Jan 11 08:47:15 2018 +0200

    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index 10e4ada3516d..4a829e09d8f6 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -351,7 +351,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth,
         nDig = nExp + 1;
 
     // round number
-    if( (nNum += roundArray [( nDig > 16 ) ? 16 : nDig] ) >= 10.0 )
+    if( (nNum += roundArray [std::min<short>( nDig, 16 )] ) >= 10.0 )
     {
         nNum = 1.0;
         ++nExp;
diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx
index 3bf9252c7fdb..71828e5563c0 100644
--- a/connectivity/source/drivers/firebird/Blob.cxx
+++ b/connectivity/source/drivers/firebird/Blob.cxx
@@ -278,7 +278,7 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut,
 
     // Ensure we have enough space for the amount of data we can actually read.
     const sal_Int64 nBytesAvailable = m_nBlobLength - m_nBlobPosition;
-    const sal_Int32 nBytesToRead = nBytes < nBytesAvailable ? nBytes : nBytesAvailable;
+    const sal_Int32 nBytesToRead = std::min<sal_Int64>(nBytes, nBytesAvailable);
 
     if (rDataOut.getLength() < nBytesToRead)
         rDataOut.realloc(nBytesToRead);
@@ -289,7 +289,7 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut,
     {
         sal_uInt16 nBytesRead = 0;
         sal_uInt64 nDataRemaining = nBytesToRead - nTotalBytesRead;
-        sal_uInt16 nReadSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining;
+        sal_uInt16 nReadSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16);
         aErr = isc_get_segment(m_statusVector,
                                &m_blobHandle,
                                &nBytesRead,
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 8b00beb20626..9d9a6853e1fa 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -552,7 +552,7 @@ void SAL_CALL OPreparedStatement::setClob(sal_Int32 nParameterIndex, const Refer
     {
         sal_Int64 nCharRemain = nLen - nCharWritten;
         constexpr sal_uInt16 MAX_SIZE = SAL_MAX_UINT16 / 4;
-        sal_uInt16 nWriteSize = (nCharRemain > MAX_SIZE) ? MAX_SIZE : nCharRemain;
+        sal_uInt16 nWriteSize = std::min<sal_Int64>(nCharRemain, MAX_SIZE);
         OString sData = OUStringToOString(
                 xClob->getSubString(nCharWritten, nWriteSize),
                 RTL_TEXTENCODING_UTF8);
@@ -642,7 +642,7 @@ void SAL_CALL OPreparedStatement::setBlob(sal_Int32 nParameterIndex,
     while (xBlob->length() - nDataWritten > 0)
     {
         sal_uInt64 nDataRemaining = xBlob->length() - nDataWritten;
-        sal_uInt16 nWriteSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining;
+        sal_uInt16 nWriteSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16);
         aErr = isc_put_segment(m_statusVector,
                                &aBlobHandle,
                                nWriteSize,
@@ -802,7 +802,7 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex,
     while (xBytes.getLength() - nDataWritten > 0)
     {
         sal_uInt64 nDataRemaining = xBytes.getLength() - nDataWritten;
-        sal_uInt16 nWriteSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining;
+        sal_uInt16 nWriteSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16);
         aErr = isc_put_segment(m_statusVector,
                                &aBlobHandle,
                                nWriteSize,
diff --git a/connectivity/source/drivers/postgresql/pq_resultset.cxx b/connectivity/source/drivers/postgresql/pq_resultset.cxx
index 3839e72e3a73..85be755818d6 100644
--- a/connectivity/source/drivers/postgresql/pq_resultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_resultset.cxx
@@ -257,7 +257,7 @@ sal_Int32 ResultSet::guessDataType( sal_Int32 column )
     // we don't look into more than 100 rows ...
     sal_Int32 ret = css::sdbc::DataType::INTEGER;
 
-    int maxRows = ( m_rowCount > 100 ? 100 : m_rowCount );
+    int maxRows = std::min<sal_Int32>( m_rowCount, 100 );
     for( int i = 0 ; i < maxRows ; i ++ )
     {
         if( ! PQgetisnull( m_result, i , column-1  ) )
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 676fa0ff2b83..9bdd27c257ec 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -1664,7 +1664,7 @@ extern "C" sal_Int32 typelib_typedescription_getAlignedUnoSize(
 #ifdef __m68k__
                 // Anything that is at least 16 bits wide is aligned on a 16-bit
                 // boundary on the m68k default abi
-                sal_Int32 nMaxAlign = (rMaxIntegralTypeSize > 2) ? 2 : rMaxIntegralTypeSize;
+                sal_Int32 nMaxAlign = std::min(rMaxIntegralTypeSize, 2);
                 nStructSize = (nStructSize + nMaxAlign -1) / nMaxAlign * nMaxAlign;
 #else
                 // Example: A { double; int; } structure has a size of 16 instead of 10. The
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 53495f6168af..9708119125ed 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -200,7 +200,7 @@ SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(vcl::Window* pParent,
                 xDefNum->getDefaultContinuousNumberingLevels( rLocale );
 
 
-            sal_Int32 nLength = aNumberings.getLength() > NUM_VALUSET_COUNT ? NUM_VALUSET_COUNT :aNumberings.getLength();
+            sal_Int32 nLength = std::min<sal_Int32>(aNumberings.getLength(), NUM_VALUSET_COUNT);
 
             const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
             for(sal_Int32 i = 0; i < nLength; i++)
diff --git a/editeng/source/uno/unoedhlp.cxx b/editeng/source/uno/unoedhlp.cxx
index ee34063b5a67..3c86fddc35dc 100644
--- a/editeng/source/uno/unoedhlp.cxx
+++ b/editeng/source/uno/unoedhlp.cxx
@@ -165,7 +165,7 @@ bool SvxEditSourceHelper::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nE
             nClosestEndIndex_s = nCurrIndex;
         }
     }
-    sal_Int32 nClosestEndIndex = nClosestEndIndex_s < nClosestEndIndex_e ? nClosestEndIndex_s : nClosestEndIndex_e;
+    sal_Int32 nClosestEndIndex = std::min(nClosestEndIndex_s, nClosestEndIndex_e);
 
     nStartIndex = nClosestStartIndex;
     nEndIndex = nClosestEndIndex;
diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx
index 77405e435fa8..5adb8f73d3ae 100644
--- a/editeng/source/uno/unotext2.cxx
+++ b/editeng/source/uno/unotext2.cxx
@@ -58,7 +58,7 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase
             if( currentPara == maSelection.nStartPara )
                 nStartPos = std::max(nStartPos, maSelection.nStartPos);
             if( currentPara == maSelection.nEndPara )
-                nEndPos = nEndPos<maSelection.nEndPos ? nEndPos : maSelection.nEndPos;
+                nEndPos = std::min(nEndPos, maSelection.nEndPos);
             ESelection aCurrentParaSel = ESelection( currentPara, nStartPos, currentPara, nEndPos );
             for( auto aIter = rRanges.begin(); (aIter != rRanges.end()) && (pContent == nullptr); ++aIter )
             {
@@ -400,7 +400,7 @@ SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration(const SvxUnoTextBase& rTe
                 continue;
 
             nStartPos = std::max<int>(nStartPos, mnSel.nStartPos);
-            nEndPos = nEndPos<mnSel.nEndPos ? nEndPos : mnSel.nEndPos;
+            nEndPos = std::min<sal_uInt16>(nEndPos, mnSel.nEndPos);
             ESelection aSel( mnParagraph, nStartPos, mnParagraph, nEndPos );
 
             const SvxUnoTextRangeBaseList& rRanges( mpEditSource->getRanges() );
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx
index 32c5085232dc..9aefab91ae79 100644
--- a/embeddedobj/source/commonembedding/embedobj.cxx
+++ b/embeddedobj/source/commonembedding/embedobj.cxx
@@ -65,8 +65,8 @@ awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt
     sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
     sal_Int32 nRight2 = aRect2.X + aRect2.Width;
     sal_Int32 nBottom2 = aRect2.Y + aRect2.Height;
-    aResult.Width = ( nRight1 < nRight2 ? nRight1 : nRight2 ) - aResult.X;
-    aResult.Height = ( nBottom1 < nBottom2 ? nBottom1 : nBottom2 ) - aResult.Y;
+    aResult.Width = std::min( nRight1, nRight2 ) - aResult.X;
+    aResult.Height = std::min( nBottom1, nBottom2 ) - aResult.Y;
 
     return aResult;
 }
diff --git a/embeddedobj/source/msole/ownview.cxx b/embeddedobj/source/msole/ownview.cxx
index cff8b66ea56b..9ab6cc0f1654 100644
--- a/embeddedobj/source/msole/ownview.cxx
+++ b/embeddedobj/source/msole/ownview.cxx
@@ -330,7 +330,7 @@ bool OwnView_Impl::ReadContentsAndGenerateTempFile( const uno::Reference< io::XI
         sal_uInt32 nRead = 0;
         while ( nRead < nDataSize )
         {
-            sal_uInt32 nToRead = ( nDataSize - nRead > 32000 ) ? 32000 : nDataSize - nRead;
+            sal_uInt32 nToRead = std::min<sal_uInt32>( nDataSize - nRead, 32000 );
             sal_uInt32 nLocalRead = xInStream->readBytes( aReadSeq, nToRead );
 
 
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index d3fc465bff20..1e3d9cb8e592 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4121,7 +4121,7 @@ void EscherGraphicProvider::WriteBlibStoreContainer( SvStream& rSt, SvStream* pM
                 // record
                 while ( nBlipSize )
                 {
-                    sal_uInt32 nBytes = ( nBlipSize > nBuf ? nBuf : nBlipSize );
+                    sal_uInt32 nBytes = std::min( nBlipSize, nBuf );
                     pMergePicStreamBSE->ReadBytes(pBuf.get(), nBytes);
                     rSt.WriteBytes(pBuf.get(), nBytes);
                     nBlipSize -= nBytes;
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 78d185bd0785..8900fd5a60fb 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -5425,7 +5425,7 @@ PPTPortionObj::PPTPortionObj( const PPTStyleSheet& rStyleSheet, TSS_Type nInstan
     PPTCharPropSet  ( 0 ),
     mrStyleSheet    ( rStyleSheet ),
     mnInstance      ( nInstance ),
-    mnDepth         ( ( nDepth > 4 ) ? 4 : nDepth )
+    mnDepth         ( std::min<sal_uInt32>( nDepth, 4 ) )
 {
 }
 
@@ -5433,7 +5433,7 @@ PPTPortionObj::PPTPortionObj( const PPTCharPropSet& rCharPropSet, const PPTStyle
     PPTCharPropSet  ( rCharPropSet ),
     mrStyleSheet    ( rStyleSheet ),
     mnInstance      ( nInstance ),
-    mnDepth         ( ( nDepth > 4 ) ? 4 : nDepth )
+    mnDepth         ( std::min<sal_uInt32>( nDepth, 4 ) )
 {
 }
 
@@ -7299,8 +7299,8 @@ void GetLinePositions( const SdrObject* pObj, const std::set< sal_Int32 >& rRows
         else
             nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionBLTR : LinePositionTLBR;
 
-        std::set< sal_Int32 >::const_iterator aRow( rRows.find( aPt1.Y() < aPt2.Y() ? aPt1.Y() : aPt2.Y() ) );
-        std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aPt1.X() < aPt2.X() ? aPt1.X() : aPt2.X() ) );
+        std::set< sal_Int32 >::const_iterator aRow( rRows.find( std::min(aPt1.Y(), aPt2.Y() ) ) );
+        std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( std::min(aPt1.X(), aPt2.X() ) ) );
         if ( ( aRow != rRows.end() ) && ( aColumn != rColumns.end() ) )
         {
             nPosition |= ( std::distance( rRows.begin(), aRow ) * rColumns.size() ) + std::distance( rColumns.begin(), aColumn );
diff --git a/formula/source/ui/dlg/parawin.cxx b/formula/source/ui/dlg/parawin.cxx
index 10493bd9fd33..2a7d04cda253 100644
--- a/formula/source/ui/dlg/parawin.cxx
+++ b/formula/source/ui/dlg/parawin.cxx
@@ -129,7 +129,7 @@ void ParaWin::UpdateArgDesc( sal_uInt16 nArg )
         else if ( nArgs < PAIRED_VAR_ARGS )
         {
             sal_uInt16 nFix = nArgs - VAR_ARGS;
-            sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix );
+            sal_uInt16 nPos = std::min( nArg, nFix );
             sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
                     aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
             aArgDesc  = pFuncDesc->getParameterDescription(nRealArg);
@@ -182,7 +182,7 @@ void ParaWin::UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i )
     else if ( nArgs < PAIRED_VAR_ARGS)
     {
         sal_uInt16 nFix = nArgs - VAR_ARGS;
-        sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix );
+        sal_uInt16 nPos = std::min( nArg, nFix );
         sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
                 aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
         SetArgNameFont( i,
diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx
index aa2beac0cd25..d0ae6c355b95 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -130,7 +130,7 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
     {
         Sequence< Sequence< PropertyValue > > aHistoryList = SvtHistoryOptions().GetList( ePICKLIST );
 
-        int nPickListMenuItems = ( aHistoryList.getLength() > MAX_MENU_ITEMS ) ? MAX_MENU_ITEMS : aHistoryList.getLength();
+        int nPickListMenuItems = std::min<sal_Int32>( aHistoryList.getLength(), MAX_MENU_ITEMS );
         m_aRecentFilesItems.clear();
         if (( nPickListMenuItems > 0 ) && !m_bDisabled )
         {
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index cd29aae17e25..25d1d5188fc4 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -80,9 +80,9 @@ bool FieldCode::Read(HWPFile & hwpf)
     hwpf.Read4b(&len3, 1);
     hwpf.Read4b(&binlen, 1);
 
-    uint const len1_ = ((len1 > 1024) ? 1024 : len1) / sizeof(hchar);
-    uint const len2_ = ((len2 > 1024) ? 1024 : len2) / sizeof(hchar);
-    uint const len3_ = ((len3 > 1024) ? 1024 : len3) / sizeof(hchar);
+    uint const len1_ = std::min<uint>(len1, 1024) / sizeof(hchar);
+    uint const len2_ = std::min<uint>(len2, 1024) / sizeof(hchar);
+    uint const len3_ = std::min<uint>(len3, 1024) / sizeof(hchar);
 
     str1.reset( new hchar[len1_ ? len1_ : 1] );
     str2.reset( new hchar[len2_ ? len2_ : 1] );
diff --git a/i18npool/source/breakiterator/breakiterator_ctl.cxx b/i18npool/source/breakiterator/breakiterator_ctl.cxx
index 4f4410e2f369..b307c37fd9ac 100644
--- a/i18npool/source/breakiterator/breakiterator_ctl.cxx
+++ b/i18npool/source/breakiterator/breakiterator_ctl.cxx
@@ -71,7 +71,7 @@ sal_Int32 SAL_CALL BreakIterator_CTL::previousCharacters( const OUString& Text,
         } else
             nStartPos = 0;
     } else { // for BS to delete one char.
-        nDone = (nStartPos > nCount) ? nCount : nStartPos;
+        nDone = std::min(nStartPos, nCount);
         nStartPos -= nDone;
     }
 
@@ -98,7 +98,7 @@ sal_Int32 SAL_CALL BreakIterator_CTL::nextCharacters(const OUString& Text,
         } else
             nStartPos = len;
     } else {
-        nDone = (len - nStartPos > nCount) ? nCount : len - nStartPos;
+        nDone = std::min(len - nStartPos, nCount);
         nStartPos += nDone;
     }
 
diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx
index 5826b5cca6a8..b177b07973a4 100644
--- a/i18npool/source/breakiterator/xdictionary.cxx
+++ b/i18npool/source/breakiterator/xdictionary.cxx
@@ -459,7 +459,7 @@ Boundary const & xdictionary::getWordBoundary(const OUString& rText, sal_Int32 a
         } else {
             boundary.startPos = anyPos;
             if (anyPos < len) rText.iterateCodePoints(&anyPos);
-            boundary.endPos = anyPos < len ? anyPos : len;
+            boundary.endPos = std::min(anyPos, len);
         }
         if (wordType == WordType::WORD_COUNT) {
             // skip punctuation for word count.
diff --git a/i18npool/source/search/levdis.cxx b/i18npool/source/search/levdis.cxx
index 7795cf7bc168..9e4d9afe527c 100644
--- a/i18npool/source/search/levdis.cxx
+++ b/i18npool/source/search/levdis.cxx
@@ -316,9 +316,9 @@ int WLevDistance::LCM( int a, int b )
 inline int WLevDistance::Min3( int x, int y, int z )
 {
     if ( x < y )
-        return( x < z ? x : z );
+        return std::min(x, z);
     else
-        return( y < z ? y : z );
+        return std::min(y, z);
 }
 
 // The value in the middle
@@ -326,11 +326,11 @@ int WLevDistance::Mid3( int x, int y, int z )
 {
     int min = Min3(x,y,z);
     if ( x == min )
-        return( y < z ? y : z);
+        return std::min(y, z);
     else if ( y == min )
-        return( x < z ? x : z);
+        return std::min(x, z);
     else        // z == min
-        return( x < y ? x : y);
+        return std::min(x, y);
 }
 
 // Maximum of three values
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 6f51d3b2cbf0..a2c20342bee3 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -1062,7 +1062,7 @@ SearchResult TextSearch::ApproxSrchFrwrd( const OUString& searchStr,
         if( aWBnd.startPos >= endPos )
             break;
         nStt = aWBnd.startPos < startPos ? startPos : aWBnd.startPos;
-        nEnd = aWBnd.endPos > endPos ? endPos : aWBnd.endPos;
+        nEnd = std::min(aWBnd.endPos, endPos);
 
         if( nStt < nEnd &&
                 pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
@@ -1106,7 +1106,7 @@ SearchResult TextSearch::ApproxSrchBkwrd( const OUString& searchStr,
         if( aWBnd.endPos <= endPos )
             break;
         nStt = aWBnd.startPos < endPos ? endPos : aWBnd.startPos;
-        nEnd = aWBnd.endPos > startPos ? startPos : aWBnd.endPos;
+        nEnd = std::min(aWBnd.endPos, startPos);
 
         if( nStt < nEnd &&
                 pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
diff --git a/i18npool/source/transliteration/textToPronounce_zh.cxx b/i18npool/source/transliteration/textToPronounce_zh.cxx
index 6baf434f5e7e..d9ca2ece5dd2 100644
--- a/i18npool/source/transliteration/textToPronounce_zh.cxx
+++ b/i18npool/source/transliteration/textToPronounce_zh.cxx
@@ -103,7 +103,7 @@ TextToPronounce_zh::equals( const OUString & str1, sal_Int32 pos1, sal_Int32 nCo
     if (nCount2 + pos2 > str2.getLength())
         nCount2 = str2.getLength() - pos2;
 
-    realCount = ((nCount1 > nCount2) ? nCount2 : nCount1);
+    realCount = std::min(nCount1, nCount2);
 
     s1 = str1.getStr() + pos1;
     s2 = str2.getStr() + pos2;
diff --git a/i18npool/source/transliteration/transliteration_Ignore.cxx b/i18npool/source/transliteration/transliteration_Ignore.cxx
index 503bf7d1858e..3a256fd34ae0 100644
--- a/i18npool/source/transliteration/transliteration_Ignore.cxx
+++ b/i18npool/source/transliteration/transliteration_Ignore.cxx
@@ -24,8 +24,6 @@ using namespace com::sun::star::uno;
 
 namespace i18npool {
 
-inline sal_Int32 Min( sal_Int32 a, sal_Int32 b ) { return a > b ? b : a; }
-
 sal_Bool SAL_CALL
 transliteration_Ignore::equals(const OUString& str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32& nMatch1,
         const OUString& str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32& nMatch2 )
@@ -39,7 +37,7 @@ transliteration_Ignore::equals(const OUString& str1, sal_Int32 pos1, sal_Int32 n
 
     const sal_Unicode * p1 = s1.getStr();
     const sal_Unicode * p2 = s2.getStr();
-    sal_Int32 length = Min(s1.getLength(), s2.getLength());
+    sal_Int32 length = std::min(s1.getLength(), s2.getLength());
     sal_Int32 nmatch;
 
     for ( nmatch = 0; nmatch < length; nmatch++)
diff --git a/include/basegfx/numeric/ftools.hxx b/include/basegfx/numeric/ftools.hxx
index 5836b48406ae..52909c9cd75b 100644
--- a/include/basegfx/numeric/ftools.hxx
+++ b/include/basegfx/numeric/ftools.hxx
@@ -100,7 +100,7 @@ namespace basegfx
         //    (::std::max(fVal,0.00001));
 
         if(fVal < 0.0)
-            return (fVal < -0.00001 ? fVal : -0.00001);
+            return std::min(fVal, -0.00001);
         else
             return std::max(fVal, 0.00001);
     }
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index b5b1ff433340..ac131ddabe30 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -3426,7 +3426,7 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 
     // Clamp the input value in [MIN_ZOOM, MAX_ZOOM]
     fZoom = fZoom < MIN_ZOOM ? MIN_ZOOM : fZoom;
-    fZoom = fZoom > MAX_ZOOM ? MAX_ZOOM : fZoom;
+    fZoom = std::min(fZoom, MAX_ZOOM);
 
     if (lok_approxEqual(fZoom, priv->m_fZoom))
         return;
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index 49b3f2fcaa59..ac0f508751d3 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -111,8 +111,7 @@ bool LinguIsUnspecified( const OUString & rBcp47 )
 
 static inline sal_Int32 Minimum( sal_Int32 n1, sal_Int32 n2, sal_Int32 n3 )
 {
-    sal_Int32 nMin = n1 < n2 ? n1 : n2;
-    return nMin < n3 ? nMin : n3;
+    return std::min(std::min(n1, n2), n3);
 }
 
 class IntArray2D
diff --git a/lotuswordpro/source/filter/explode.cxx b/lotuswordpro/source/filter/explode.cxx
index 1cc895ec6c8a..fa04eac514d2 100644
--- a/lotuswordpro/source/filter/explode.cxx
+++ b/lotuswordpro/source/filter/explode.cxx
@@ -311,7 +311,7 @@ sal_Int32 Decompression::explode()
         // point back to copy position and read bytes
         m_pOutStream->SeekRel(-static_cast<long>(distance));
         sal_uInt8 sTemp[MAXWIN];
-        sal_uInt32 nRead = distance > Length? Length:distance;
+        sal_uInt32 nRead = std::min(distance, Length);
         m_pOutStream->ReadBytes(sTemp, nRead);
         if (nRead != Length)
         {
diff --git a/lotuswordpro/source/filter/lwptable.cxx b/lotuswordpro/source/filter/lwptable.cxx
index d6c1cb17cd43..63ecd92b6e52 100644
--- a/lotuswordpro/source/filter/lwptable.cxx
+++ b/lotuswordpro/source/filter/lwptable.cxx
@@ -205,7 +205,7 @@ void LwpGlossary::Read()
     {
         if (NumIndexRows)
         {
-            sal_uInt16 EntriesRead = (FiledEntries > NumIndexRows)? NumIndexRows:FiledEntries;
+            sal_uInt16 EntriesRead = std::min(FiledEntries, NumIndexRows);
 
             for (sal_uInt16 EntryCount = 1; EntryCount <= EntriesRead; EntryCount++)
                 m_pObjStrm->QuickReaduInt16();
diff --git a/onlineupdate/source/update/updater/bspatch.cxx b/onlineupdate/source/update/updater/bspatch.cxx
index b39c50f92627..10ec56200511 100644
--- a/onlineupdate/source/update/updater/bspatch.cxx
+++ b/onlineupdate/source/update/updater/bspatch.cxx
@@ -104,7 +104,7 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile,
     unsigned char *wb = buf;
     while (r)
     {
-        const size_t count = (r > SSIZE_MAX) ? SSIZE_MAX : r;
+        const size_t count = std::min(r, SSIZE_MAX);
         size_t c = fread(wb, 1, count, patchFile);
         if (c != count)
         {
diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx
index ef1440f5c96e..b8a791848a49 100644
--- a/oox/source/crypto/AgileEngine.cxx
+++ b/oox/source/crypto/AgileEngine.cxx
@@ -179,7 +179,7 @@ bool AgileEngine::decrypt(BinaryXInputStream& aInputStream,
         Decrypt aDecryptor(mKey, iv, AgileEngine::cryptoType(mInfo));
         outputLength = aDecryptor.update(outputBuffer, inputBuffer, inputLength);
 
-        sal_uInt32 writeLength = outputLength > remaining ? remaining : outputLength;
+        sal_uInt32 writeLength = std::min(outputLength, remaining);
         aOutputStream.writeMemory(outputBuffer.data(), writeLength);
 
         remaining -= outputLength;
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 658f072497aa..b5a45b31c1ca 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -359,7 +359,7 @@ void VBACompression::write()
     std::size_t nRemainingSize = nSize;
     while(bStreamNotEnded)
     {
-        std::size_t nChunkSize = nRemainingSize > 4096 ? 4096 : nRemainingSize;
+        std::size_t nChunkSize = std::min<size_t>(nRemainingSize, 4096);
         VBACompressionChunk aChunk(mrCompressedStream, &pData[nSize - nRemainingSize], nChunkSize);
         aChunk.write();
 
diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx
index f803076c97b4..c4de9284c8df 100644
--- a/opencl/source/opencl_device.cxx
+++ b/opencl/source/opencl_device.cxx
@@ -13,6 +13,7 @@
 #include <sstream>
 #include <memory>
 #include <vector>
+#include <algorithm>
 
 #include <comphelper/random.hxx>
 #include <opencl/openclconfig.hxx>
@@ -285,7 +286,7 @@ ds_status evaluateScoreForDevice(ds_device& rDevice, std::unique_ptr<LibreOffice
             for (unsigned long i = 0; i < testData->inputSize; i++)
             {
                 fAverage += testData->input0[i];
-                fMin = ((fMin < testData->input1[i]) ? fMin : testData->input1[i]);
+                fMin = std::min(fMin, testData->input1[i]);
                 fSoP += testData->input2[i] * testData->input3[i];
             }
             fAverage /= testData->inputSize;
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index d20b46195c3a..1f992ca14e58 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -210,7 +210,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
 
                 nRead = mxZipStream->readBytes (
                                         aData,
-                                        static_cast < sal_Int32 > ( nDiff < nRequestedBytes ? nDiff : nRequestedBytes ) );
+                                        std::min<sal_Int32>(nDiff, nRequestedBytes) );
 
                 mnZipCurrent += nRead;
 
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index 10742fcf789e..9996284cb4a6 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -20,6 +20,7 @@
 
 #include <new>
 #include <memory>
+#include <algorithm>
 #include <sal/types.h>
 #include <sal/macros.h>
 #include <osl/endian.h>
@@ -570,7 +571,7 @@ void MethodEntry::reallocParams(sal_uInt16 size)
     if (m_paramCount)
     {
         sal_uInt16 i;
-        sal_uInt16 mn = size < m_paramCount ? size : m_paramCount;
+        sal_uInt16 mn = std::min(size, m_paramCount);
 
         for (i = 0; i < mn; i++)
         {
@@ -594,7 +595,7 @@ void MethodEntry::reallocExcs(sal_uInt16 size)
         newExcNames = nullptr;
 
     sal_uInt16 i;
-    sal_uInt16 mn = size < m_excCount ? size : m_excCount;
+    sal_uInt16 mn = std::min(size, m_excCount);
 
     for (i = 0; i < mn; i++)
     {
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index fa44ea934e5f..9eee8ce54e0e 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -1252,7 +1252,7 @@ static sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Line, sa
         }
     }
 
-    LineNo = LineNo > pProfile->m_NoLines ? pProfile->m_NoLines : LineNo;
+    LineNo = std::min(LineNo, pProfile->m_NoLines);
 
     if (LineNo < pProfile->m_NoLines)
     {
diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx
index e0d0ad210ed1..bdd9db6b7b94 100644
--- a/sal/osl/unx/security.cxx
+++ b/sal/osl/unx/security.cxx
@@ -263,7 +263,7 @@ static bool osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszDirectory, sal
                                OUSTRING_TO_OSTRING_CVTFLAGS);
             if (pStrValue && pStrValue->length > 0)
             {
-                sal_Int32 nCopy = (sal_Int32)(nMax-1) < pStrValue->length ? (sal_Int32)(nMax-1) : pStrValue->length ;
+                sal_Int32 nCopy = (sal_Int32)std::min(nMax-1, pStrValue->length) ;
                 strncpy (pszDirectory, pStrValue->buffer, nCopy);
                 pszDirectory[nCopy] = '\0';
                 bRet = (std::size_t)pStrValue->length < nMax;
diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx
index 96dc7fcdbcec..d4e0ed6e5dbb 100644
--- a/sal/osl/w32/profile.cxx
+++ b/sal/osl/w32/profile.cxx
@@ -1374,7 +1374,7 @@ static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Li
         }
     }
 
-    LineNo = LineNo > pProfile->m_NoLines ? pProfile->m_NoLines : LineNo;
+    LineNo = std::min(LineNo, pProfile->m_NoLines);
 
     if (LineNo < pProfile->m_NoLines)
     {
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index 6a3eea86d6a0..d9aeb7edcc77 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -31,6 +31,7 @@
 #if defined(SAL_UNX)
 #include <sys/time.h>
 #endif
+#include <algorithm>
 
 /**
  *  @internal
@@ -1283,7 +1284,7 @@ static void rtl_cache_depot_wsupdate(
     depot->m_prev_min = depot->m_curr_min;
     depot->m_curr_min = depot->m_mag_count;
 
-    npurge = depot->m_curr_min < depot->m_prev_min ? depot->m_curr_min : depot->m_prev_min;
+    npurge = std::min(depot->m_curr_min, depot->m_prev_min);
     for (; npurge > 0; npurge--)
     {
         rtl_cache_magazine_type * mag = rtl_cache_depot_dequeue (depot);
diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx
index 25e2c1ea78b6..efbd2748dbf8 100644
--- a/sal/rtl/alloc_global.cxx
+++ b/sal/rtl/alloc_global.cxx
@@ -137,7 +137,7 @@ void * rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXTERN_C()
             p = rtl_allocateMemory (n);
             if (p)
             {
-                memcpy (p, p_old, (n < n_old) ? n : n_old);
+                memcpy (p, p_old, std::min(n, n_old));
                 rtl_freeMemory (p_old);
             }
         }
diff --git a/sal/rtl/cipher.cxx b/sal/rtl/cipher.cxx
index 9a64ac4364b0..62f3104be3ed 100644
--- a/sal/rtl/cipher.cxx
+++ b/sal/rtl/cipher.cxx
@@ -22,6 +22,7 @@
 #include <sal/types.h>
 #include <rtl/alloc.h>
 #include <rtl/cipher.h>
+#include <algorithm>
 
 #define RTL_CIPHER_NTOHL(c, l) \
     ((l)  = (static_cast<sal_uInt32>(*((c)++))) << 24, \
@@ -660,7 +661,7 @@ static rtlCipherError BF_init(
 
     if (pArgData && nArgLen)
     {
-        nArgLen = ((nArgLen < 8) ? nArgLen : 8);
+        nArgLen = std::min<sal_Size>(nArgLen, 8);
         if (eMode == rtl_Cipher_ModeStream)
         {
             memcpy(ctx->m_iv.m_byte, pArgData, nArgLen);
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index f8a0f9dcec47..4b149b9f99dd 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -443,7 +443,7 @@ inline void doubleToString(typename T::String ** pResult,
     // Round the number
     if(nDigits >= 0)
     {
-        if ((fValue += nRoundVal[nDigits > 15 ? 15 : nDigits] ) >= 10)
+        if ((fValue += nRoundVal[std::min<sal_Int32>(nDigits, 15)] ) >= 10)
         {
             fValue = 1.0;
             nExp++;
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index d562c7c736a1..64fb1c3edd39 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -436,7 +436,7 @@ sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
 {
     assert(firstLen >= 0 && secondLen >= 0);
     sal_Int32 i;
-    sal_Int32 len = firstLen < secondLen ? firstLen : secondLen;
+    sal_Int32 len = std::min(firstLen, secondLen);
     for (i = 0; i < len; ++i) {
         /* Check ASCII range */
         SAL_WARN_IF( (static_cast<unsigned char>(*second)) > 127, "rtl.string",
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 0c4610d98474..2be0ff1ccb7b 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -121,17 +121,17 @@ SAL_WARN_UNUSED_RESULT inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, SCTAB
 
 SAL_WARN_UNUSED_RESULT inline SCCOL SanitizeCol( SCCOL nCol )
 {
-    return nCol < 0 ? 0 : (nCol > MAXCOL ? MAXCOL : nCol);
+    return nCol < 0 ? 0 : std::min(nCol, MAXCOL);
 }
 
 SAL_WARN_UNUSED_RESULT inline SCROW SanitizeRow( SCROW nRow )
 {
-    return nRow < 0 ? 0 : (nRow > MAXROW ? MAXROW : nRow);
+    return nRow < 0 ? 0 : std::min(nRow, MAXROW);
 }
 
 SAL_WARN_UNUSED_RESULT inline SCTAB SanitizeTab( SCTAB nTab )
 {
-    return nTab < 0 ? 0 : (nTab > MAXTAB ? MAXTAB : nTab);
+    return nTab < 0 ? 0 : std::min(nTab, MAXTAB);
 }
 
 // The result of ConvertRef() is a bit group of the following:
diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx
index 3b53741064fb..de5c139b30de 100644
--- a/sc/source/core/data/dpfilteredcache.cxx
+++ b/sc/source/core/data/dpfilteredcache.cxx
@@ -235,7 +235,7 @@ bool ScDPFilteredCache::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
     if (pLastRow)
     {
         // Return the last row of current segment.
-        *pLastRow = nLastRowFilter < nLastRowPage ? nLastRowFilter : nLastRowPage;
+        *pLastRow = std::min(nLastRowFilter, nLastRowPage);
         *pLastRow -= 1; // End position is not inclusive. Move back one.
     }
 
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index af36752dc05a..4e0666846cb0 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -949,7 +949,7 @@ bool ScTable::SearchRangeForEmptyCell(
         {
             // row direction.
             SCROW nLastNonFilteredRow = MAXROW + 1;
-            SCROW nBeginRow = rRange.aEnd.Row() > rRow ? rRow : rRange.aEnd.Row();
+            SCROW nBeginRow = std::min(rRange.aEnd.Row(), rRow);
             for (SCROW nRow = nBeginRow; nRow >= rRange.aStart.Row(); --nRow)
             {
                 if (bSkipFiltered)
@@ -972,7 +972,7 @@ bool ScTable::SearchRangeForEmptyCell(
         else
         {
             // column direction.
-            SCCOL nBeginCol = rRange.aEnd.Col() > rCol ? rCol : rRange.aEnd.Col();
+            SCCOL nBeginCol = std::min(rRange.aEnd.Col(), rCol);
             for (SCCOL nCol = nBeginCol; nCol >= rRange.aStart.Col(); --nCol)
             {
                 SCROW nLastNonFilteredRow = MAXROW + 1;
diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx
index 301deeeabc9a..be5fc318bce6 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -98,7 +98,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
     {
         tmpCur = vSubArguments[1]->GetFormulaToken();
         pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
-        size_t nCurWindowSize = pCurDVR->GetArrayLength() < pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength() : pCurDVR->GetRefRowSize() ;
+        size_t nCurWindowSize = std::min(pCurDVR->GetArrayLength(), pCurDVR->GetRefRowSize());
         int unrollSize = 8;
         ss << "    int loop;\n";
         if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed())
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a7b7b8d9629b..ba03e59ff95a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4111,7 +4111,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
     {
         ScRawToken aToken;
         aToken.SetOpCode( ocSpaces );
-        aToken.sbyte.cByte = static_cast<sal_uInt8>( nSpaces > 255 ? 255 : nSpaces );
+        aToken.sbyte.cByte = static_cast<sal_uInt8>( std::min<sal_Int32>(nSpaces, 255) );
         if( !static_cast<ScTokenArray*>(pArr)->AddRawToken( aToken ) )
         {
             SetError(FormulaError::CodeOverflow);
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 633af20860b9..efb3f15671cf 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -678,7 +678,7 @@ void ScDBData::AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx,
         // nCol1 is the first column of the block that gets shifted, determine
         // the head and tail elements that are to be copied for deletion or
         // insertion.
-        size_t nHead = static_cast<size_t>(::std::max( nCol1 + (nDx < 0 ? nDx : 0) - nOldCol1, 0));
+        size_t nHead = static_cast<size_t>(::std::max( nCol1 + std::min<SCCOL>(nDx, 0) - nOldCol1, 0));
         size_t nTail = static_cast<size_t>(::std::max( nOldCol2 - nCol1 + 1, 0));
         size_t n = nHead + nTail;
         if (0 < n && n <= maTableColumnNames.size())
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 723c75d8139f..55b80a6612e9 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -1261,7 +1261,7 @@ double lcl_GetBinomDistRange(double n, double xs,double xe,
         fFactor *= (n-i+1)/i * p/q;
         fSum += fFactor;
     }
-    return (fSum>1.0) ? 1.0 : fSum;
+    return std::min(fSum,1.0);
 }
 
 void ScInterpreter::ScB()
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 1d792f7222c8..d1422f1ab266 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -300,7 +300,7 @@ private:
             // These two ranges cannot be joined.  Move on.
             return false;
 
-        T nMin = nMin1 < nMin2 ? nMin1 : nMin2;
+        T nMin = std::min(nMin1, nMin2);
         T nMax = std::max(nMax1, nMax2);
 
         rNewMin = nMin;
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 19d4b62394b6..d22fdd347e26 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -363,7 +363,7 @@ static size_t GetElementsMax( size_t nMemory )
     // With MAXROWCOUNT==1048576 and 128 columns => 128M elements, 1.5GB
     constexpr size_t nArbitraryLimit = size_t(MAXROWCOUNT) * 128;
     // With the constant 1GB from above that's the actual value.
-    return nElemMax < nArbitraryLimit ? nElemMax : nArbitraryLimit;
+    return std::min(nElemMax, nArbitraryLimit);
 }
 
 ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) :
diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx
index 4ee58da7d29c..51367b9d08e5 100644
--- a/sc/source/filter/lotus/lotimpop.cxx
+++ b/sc/source/filter/lotus/lotimpop.cxx
@@ -267,7 +267,7 @@ void ImportLotus::Formulacell( sal_uInt16 n )
     Read( aAddr );
     Skip( 10 );
 
-    n -= (n > 14) ? 14 : n;
+    n -= std::min<sal_uInt16>(n, 14);
 
     const ScTokenArray* pErg;
     sal_Int32 nRest = n;
diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx
index ffd47264a316..3998a08ca088 100644
--- a/sc/source/filter/lotus/op.cxx
+++ b/sc/source/filter/lotus/op.cxx
@@ -114,7 +114,7 @@ void OP_Label(LotusContext& rContext, SvStream& r, sal_uInt16 n)
     SCCOL nCol(static_cast<SCCOL>(nTmpCol));
     SCROW nRow(static_cast<SCROW>(nTmpRow));
 
-    n -= (n > 5) ? 5 : n;
+    n -= std::min<sal_uInt16>(n, 5);
 
     std::unique_ptr<sal_Char[]> pText(new sal_Char[n + 1]);
     r.ReadBytes(pText.get(), n);
@@ -356,7 +356,7 @@ void OP_Label123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
     SCCOL nCol(static_cast<SCCOL>(nTmpCol));
     SCROW nRow(static_cast<SCROW>(nTmpRow));
 
-    n -= (n > 4) ? 4 : n;
+    n -= std::min<sal_uInt16>(n, 4);
 
     std::unique_ptr<sal_Char[]> pText(new sal_Char[n + 1]);
     r.ReadBytes(pText.get(), n);
@@ -439,7 +439,7 @@ void OP_Note123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
     SCCOL nCol(static_cast<SCCOL>(nTmpCol));
     SCROW nRow(static_cast<SCROW>(nTmpRow));
 
-    n -= (n > 4) ? 4 : n;
+    n -= std::min<sal_uInt16>(n, 4);
 
     std::unique_ptr<sal_Char[]> pText(new sal_Char[n + 1]);
     r.ReadBytes(pText.get(), n);
@@ -522,7 +522,7 @@ void OP_CreatePattern123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
     SfxItemSet& rItemSet = aPattern.GetItemSet();
 
     r.ReadUInt16( nCode );
-    n -= (n > 2) ? 2 : n;
+    n -= std::min<sal_uInt16>(n, 2);
 
     if ( nCode == 0x0fd2 )
     {
@@ -557,7 +557,7 @@ void OP_CreatePattern123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
         OP_VerAlign123(rContext, Ver_Align, rItemSet );
 
         rContext.aLotusPatternPool.emplace( nPatternId, aPattern );
-        n -= (n > 20) ? 20 : n;
+        n -= std::min<sal_uInt16>(n, 20);
     }
     r.SeekRel(n);
 }
diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx
index 0c1d18d59ffd..13bb055e1c3a 100644
--- a/sc/source/filter/qpro/qpro.cxx
+++ b/sc/source/filter/qpro/qpro.cxx
@@ -251,7 +251,7 @@ bool ScQProReader::nextRecord()
 #if 1  // rather verbose
     int len = mnLength;
     while (len > 0) {
-        int i, chunk = len < 16 ? len : 16;
+        int i, chunk = std::min(len, 16);
         unsigned char data[16];
         mpStream->Read( data, chunk );
 
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 0148dc965026..4d393f9f1e61 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1341,10 +1341,10 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
 
     if( CellsAreRepeated() )
     {
-        SCCOL nStartCol( rCellPos.Col() < MAXCOL ? rCellPos.Col() : MAXCOL );
-        SCROW nStartRow( rCellPos.Row() < MAXROW ? rCellPos.Row() : MAXROW );
-        SCCOL nEndCol( rCellPos.Col() + nColsRepeated - 1 < MAXCOL ? rCellPos.Col() + nColsRepeated - 1 : MAXCOL );
-        SCROW nEndRow( rCellPos.Row() + nRepeatedRows - 1 < MAXROW ? rCellPos.Row() + nRepeatedRows - 1 : MAXROW );
+        SCCOL nStartCol( std::min(rCellPos.Col(), MAXCOL) );
+        SCROW nStartRow( std::min(rCellPos.Row(), MAXROW) );
+        SCCOL nEndCol( std::min<SCCOL>(rCellPos.Col() + nColsRepeated - 1, MAXCOL) );
+        SCROW nEndRow( std::min(rCellPos.Row() + nRepeatedRows - 1, MAXROW) );
         ScRange aScRange( nStartCol, nStartRow, rCellPos.Tab(), nEndCol, nEndRow, rCellPos.Tab() );
         SetContentValidation( aScRange );
         rXMLImport.GetStylesImportHelper()->AddRange( aScRange );
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index cf4770798a19..da36ab8dff66 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -578,8 +578,8 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
 
             nBlockStartX = nBlockStartX + nBlockStartXOffset >= 0 ? nBlockStartX + nBlockStartXOffset : 0;
             nBlockStartY = nBlockStartY + nBlockStartYOffset >= 0 ? nBlockStartY + nBlockStartYOffset : 0;
-            nBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
-            nBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
+            nBlockEndX = std::min<SCCOL>(nCurX + nCurXOffset, MAXCOL);
+            nBlockEndY = std::min(nCurY + nCurYOffset, MAXROW);
         }
         else
         {
diff --git a/sd/source/filter/eppt/pptexsoundcollection.cxx b/sd/source/filter/eppt/pptexsoundcollection.cxx
index 080bf0bc6203..287853b05c51 100644
--- a/sd/source/filter/eppt/pptexsoundcollection.cxx
+++ b/sd/source/filter/eppt/pptexsoundcollection.cxx
@@ -133,7 +133,7 @@ void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) const
             std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ 0x10000 ] );   // 64 kB  Buffer
             while ( nBytesLeft )
             {
-                sal_uInt32 nToDo = ( nBytesLeft > 0x10000 ) ? 0x10000 : nBytesLeft;
+                sal_uInt32 nToDo = std::min<sal_uInt32>( nBytesLeft, 0x10000 );
                 pSourceFile->ReadBytes(pBuf.get(), nToDo);
                 rSt.WriteBytes(pBuf.get(), nToDo);
                 nBytesLeft -= nToDo;
diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx
index 5ca60e4282e5..99c0f0359fa4 100644
--- a/sdext/source/pdfimport/filterdet.cxx
+++ b/sdext/source/pdfimport/filterdet.cxx
@@ -443,7 +443,7 @@ bool checkDocChecksum( const OUString& rInPDFFileURL,
         sal_uInt64 nBytesRead = 0;
         while( nCur < nBytes )
         {
-            sal_uInt32 nPass = (nBytes - nCur) > sizeof( aBuf ) ? sizeof( aBuf ) : nBytes - nCur;
+            sal_uInt32 nPass = std::min<sal_uInt32>(nBytes - nCur, sizeof( aBuf ));
             if( (aErr = osl_readFile( aRead, aBuf, nPass, &nBytesRead)) != osl_File_E_None
                 || nBytesRead == 0 )
             {
diff --git a/slideshow/source/engine/opengl/TransitionImpl.cxx b/slideshow/source/engine/opengl/TransitionImpl.cxx
index bb6557f4638f..927e0d72130d 100644
--- a/slideshow/source/engine/opengl/TransitionImpl.cxx
+++ b/slideshow/source/engine/opengl/TransitionImpl.cxx
@@ -1094,9 +1094,9 @@ float fdiv(int a, int b)
 glm::vec2 vec(float x, float y, float nx, float ny)
 {
     x = x < 0.0 ? 0.0 : x;
-    x = x > nx  ? nx  : x;
+    x = std::min(x, nx);
     y = y < 0.0 ? 0.0 : y;
-    y = y > ny  ? ny  : y;
+    y = std::min(y, ny);
     return glm::vec2(fdiv(x, nx), fdiv(y, ny));
 }
 
diff --git a/slideshow/source/engine/transitions/spiralwipe.cxx b/slideshow/source/engine/transitions/spiralwipe.cxx
index 216c513ff470..6ecad1712ed4 100644
--- a/slideshow/source/engine/transitions/spiralwipe.cxx
+++ b/slideshow/source/engine/transitions/spiralwipe.cxx
@@ -58,7 +58,7 @@ SpiralWipe::SpiralWipe( sal_Int32 nElements, bool flipOnYAxis )
         sal_Int32 len = static_cast<sal_Int32>( (e - (edge /2)) * edge1 * 4 );
         double w = M_PI_2;
         while (len > 0) {
-            const sal_Int32 alen = (len > edge1 ? edge1 : len);
+            const sal_Int32 alen = std::min(len, edge1);
             len -= alen;
             poly = createUnitRect();
             aTransform = basegfx::utils::createScaleB2DHomMatrix(
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 0a5ef6970b07..21e3e619a978 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -912,7 +912,7 @@ void SmViewShell::QueryObjAreaPixel( tools::Rectangle& rRect ) const
 
 void SmViewShell::SetZoomFactor( const Fraction &rX, const Fraction &rY )
 {
-    const Fraction &rFrac = rX < rY ? rX : rY;
+    const Fraction &rFrac = std::min(rX, rY);
     GetGraphicWindow().SetZoom(sal::static_int_cast<sal_uInt16>(long(rFrac * Fraction( 100, 1 ))));
 
     //To avoid rounding errors base class regulates crooked values too
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index a9d090251368..004c153bfdc4 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -674,7 +674,7 @@ void SmSetSelectionVisitor::Visit( SmTextNode* pNode ) {
     long start, end;
     pNode->SetSelected(true);
     if( i1 != -1 && i2 != -1 ) {
-        start = i1 < i2 ? i1 : i2; //MIN
+        start = std::min(i1, i2);
         end   = std::max(i1, i2);
     } else if( mbSelecting && i1 != -1 ) {
         start = 0;
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index d713593d9bff..18e9c814f47b 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -896,7 +896,7 @@ void GalleryBrowser2::ImplUpdateViews( sal_uInt16 nSelectionId )
             mpIconView->InsertItem( static_cast<sal_uInt16>(i) );
         }
 
-        ImplSelectItemId( ( nSelectionId > mpCurTheme->GetObjectCount() ) ? mpCurTheme->GetObjectCount() : nSelectionId );
+        ImplSelectItemId( std::min<sal_uInt16>( nSelectionId, mpCurTheme->GetObjectCount() ) );
     }
 
     switch( GetMode() )
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 1ebde1442249..430b987db155 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -717,8 +717,8 @@ basegfx::B2DPolygon SdrEditView::ImpCombineToSinglePolygon(const basegfx::B2DPol
                     const double fRBCA(basegfx::B2DVector(aCA - aRB).getLength());
                     const double fRBCB(basegfx::B2DVector(aCB - aRB).getLength());
 
-                    const double fSmallestRA(fRACA < fRACB ? fRACA : fRACB);
-                    const double fSmallestRB(fRBCA < fRBCB ? fRBCA : fRBCB);
+                    const double fSmallestRA(std::min(fRACA, fRACB));
+                    const double fSmallestRB(std::min(fRBCA, fRBCB));
 
                     if(fSmallestRA < fSmallestRB)
                     {
@@ -726,8 +726,8 @@ basegfx::B2DPolygon SdrEditView::ImpCombineToSinglePolygon(const basegfx::B2DPol
                         aRetval.flip();
                     }
 
-                    const double fSmallestCA(fRACA < fRBCA ? fRACA : fRBCA);
-                    const double fSmallestCB(fRACB < fRBCB ? fRACB : fRBCB);
+                    const double fSmallestCA(std::min(fRACA, fRBCA));
+                    const double fSmallestCB(std::min(fRACB, fRBCB));
 
                     if(fSmallestCB < fSmallestCA)
                     {
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index ad591651b37e..391196740508 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -899,7 +899,7 @@ void SdrObjCustomShape::MergeDefaultAttributes( const OUString* pType )
             }
         }
         // check if there are defaulted adjustment values that should be filled the hard coded defaults (pDefValue)
-        sal_Int32 nCount = nAdjustmentValues > nAdjustmentDefaults ? nAdjustmentDefaults : nAdjustmentValues;
+        sal_Int32 nCount = std::min(nAdjustmentValues, nAdjustmentDefaults);
         for ( i = 0; i < nCount; i++ )
         {
             if ( seqAdjustmentValues[ i ].State != css::beans::PropertyState_DIRECT_VALUE )
diff --git a/sw/qa/core/Test-BigPtrArray.cxx b/sw/qa/core/Test-BigPtrArray.cxx
index aaa8a911d00e..bc033a399d40 100644
--- a/sw/qa/core/Test-BigPtrArray.cxx
+++ b/sw/qa/core/Test-BigPtrArray.cxx
@@ -342,7 +342,7 @@ public:
 
         while(bparr.Count())
         {
-            sal_uLong nRemove = (bparr.Count() > 3) ? 3 : bparr.Count();
+            sal_uLong nRemove = std::min<sal_uLong>(bparr.Count(), 3);
             sal_uLong oldCount = bparr.Count();
 
             for (sal_uLong i = 0; i < nRemove; i++)
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index bffde7e0a90e..5f58c77ecc49 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3507,7 +3507,7 @@ void SwCursorShell::GetSmartTagRect( const Point& rPt, SwRect& rSelectRect )
             const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
             // take one less than the line end - otherwise the next line would
             // be calculated
-            const sal_Int32 nWordEnd = (nBegin + nLen - nLeft - nRight) > nLineEnd ? nLineEnd : (nBegin + nLen - nLeft - nRight);
+            const sal_Int32 nWordEnd = std::min(nBegin + nLen - nLeft - nRight, nLineEnd);
             Push();
             pCursor->DeleteMark();
             SwIndex& rContent = GetCursor()->GetPoint()->nContent;
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 059e160ea0bb..571a3c62a2cf 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1758,7 +1758,7 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd,
         long nTmp = nLowerMax - nLowerMin;
         if( nMinWidth > nTmp )
             nMinWidth = nTmp;
-        nTmp = nLowerMax < nUpperMax ? nLowerMax : nUpperMax;
+        nTmp = std::min(nLowerMax, nUpperMax);
         nTmp -= ( nLowerMin < nUpperMin ) ? nUpperMin : nLowerMin;
         // If the overlapping between upper and lower box is less than half
         // of the width (of the smaller cell), bCombine is set,
@@ -1785,7 +1785,7 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd,
     }
 
     {
-        long nMin = nUpperMin < nLowerMin ? nUpperMin : nLowerMin;
+        long nMin = std::min(nUpperMin, nLowerMin);
         long nMax = nUpperMax < nLowerMax ? nLowerMax : nUpperMax;
         for( size_t i = nTop; i <= nBottom; ++i )
             lcl_SearchSelBox( *this, rBoxes, nMin, nMax, *m_aLines[i],
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index b07aa1a9b23f..d24bb5a0cc60 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1114,7 +1114,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
                 if ( pTextNd->IsOutline() )
                 {
                     int nRealLevel = pTextNd->GetAttrOutlineLevel()-1;
-                    nRealLevel = nRealLevel > 5 ? 5 : nRealLevel;
+                    nRealLevel = std::min(nRealLevel, 5);
 
                     nPDFType =  static_cast<sal_uInt16>(vcl::PDFWriter::H1 + nRealLevel);
                     switch(nRealLevel)
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 7d2915b02e28..10fb397e3092 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -308,7 +308,7 @@ sal_Int32 SwAttrIter::GetNextAttr( ) const
     }
     if (m_pTextNode!=nullptr) {
         // TODO: maybe use hints like FieldHints for this instead of looking at the text...
-        const sal_Int32 l = nNext<m_pTextNode->Len() ? nNext : m_pTextNode->Len();
+        const sal_Int32 l = std::min(nNext, m_pTextNode->Len());
         sal_Int32 p=m_nPosition;
         const sal_Unicode* aStr = m_pTextNode->GetText().getStr();
         while (p<l)
diff --git a/sw/source/core/text/itrtxt.hxx b/sw/source/core/text/itrtxt.hxx
index 65829dc7a532..f105cf44b5bb 100644
--- a/sw/source/core/text/itrtxt.hxx
+++ b/sw/source/core/text/itrtxt.hxx
@@ -191,7 +191,7 @@ public:
     SvxAdjust GetAdjust() const { return nAdjust; }
     sal_uInt16 GetLineWidth() const
            { return sal_uInt16( Right() - GetLeftMargin() + 1 ); }
-    SwTwips GetLeftMin() const { return nFirst < nLeft ? nFirst : nLeft; }
+    SwTwips GetLeftMin() const { return std::min(nFirst, nLeft); }
     bool HasNegFirst() const { return nFirst < nLeft; }
 
     // #i91133#
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index cf1fbfa0e8fc..a4b4e766f2f7 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -165,7 +165,7 @@ void SwUndoInsNum::SaveOldNumRule( const SwNumRule& rOld )
 SwUndoDelNum::SwUndoDelNum( const SwPaM& rPam )
     : SwUndo( SwUndoId::DELNUM, rPam.GetDoc() ), SwUndRng( rPam )
 {
-    aNodes.reserve( nEndNode - nSttNode > 255 ? 255 : nEndNode - nSttNode );
+    aNodes.reserve( std::min<sal_uLong>(nEndNode - nSttNode, 255) );
     pHistory.reset( new SwHistory );
 }
 
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index f39989bffb98..f96d295d2513 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -2316,7 +2316,7 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode )
                 else
                 {
                     sal_Int32 nTmpStt = nHtStt < nStrPos ? nStrPos : nHtStt;
-                    sal_Int32 nTmpEnd = nHtEnd < nEnd ? nHtEnd : nEnd;
+                    sal_Int32 nTmpEnd = std::min(nHtEnd, nEnd);
                     aEndPosLst.Insert( pHt->GetAttr(), nTmpStt + nOffset,
                                        nTmpEnd + nOffset,
                                        rHTMLWrt.m_CharFormatInfos );
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
index c61f12ed55e9..555d9b066269 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -1112,7 +1112,7 @@ void SwCSS1Parser::StyleParsed( const CSS1Selector *pSelector,
 
 sal_uInt32 SwCSS1Parser::GetFontHeight( sal_uInt16 nSize ) const
 {
-    return m_aFontHeights[ nSize>6 ? 6 : nSize ];
+    return m_aFontHeights[ std::min<sal_uInt16>(nSize,6) ];
 }
 
 const FontList *SwCSS1Parser::GetFontList() const
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 51fad2582a4e..5257679489ed 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -675,7 +675,7 @@ void MSWordStyles::OutputStylesTable()
     // so simply if there are more styles, don't export those
     // Implementing check for all exports DOCX, DOC, RTF
     sal_uInt16 nLimit = MSWORD_MAX_STYLES_LIMIT;
-    m_nUsedSlots = (nLimit > m_nUsedSlots)? m_nUsedSlots : nLimit;
+    m_nUsedSlots = std::min(nLimit, m_nUsedSlots);
 
     for ( n = 0; n < m_nUsedSlots; n++ )
     {
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index c5f1429262f7..cfc7123e3673 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3125,7 +3125,7 @@ namespace
         sal_uInt8 in[WW_BLOCKSIZE];
         for (std::size_t nI = 0, nBlock = 0; nI < nLen; nI += WW_BLOCKSIZE, ++nBlock)
         {
-            std::size_t nBS = (nLen - nI > WW_BLOCKSIZE) ? WW_BLOCKSIZE : nLen - nI;
+            std::size_t nBS = std::min(nLen - nI, WW_BLOCKSIZE);
             nBS = rIn.ReadBytes(in, nBS);
             rCtx.InitCipher(nBlock);
             rCtx.Encode(in, nBS, in, nBS);
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index e875205ae5c9..50f57141a9ab 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5478,7 +5478,7 @@ namespace
         sal_uInt8 in[WW_BLOCKSIZE];
         for (std::size_t nI = 0, nBlock = 0; nI < nLen; nI += WW_BLOCKSIZE, ++nBlock)
         {
-            std::size_t nBS = (nLen - nI > WW_BLOCKSIZE) ? WW_BLOCKSIZE : nLen - nI;
+            std::size_t nBS = std::min<size_t>(nLen - nI, WW_BLOCKSIZE);
             nBS = rIn.ReadBytes(in, nBS);
             rCtx.InitCipher(nBlock);
             rCtx.Decode(in, nBS, in, nBS);
@@ -5499,7 +5499,7 @@ namespace
         sal_uInt8 in[0x4096];
         for (std::size_t nI = nSt; nI < nLen; nI += 0x4096)
         {
-            std::size_t nBS = (nLen - nI > 0x4096 ) ? 0x4096 : nLen - nI;
+            std::size_t nBS = std::min<size_t>(nLen - nI, 0x4096 );
             nBS = rIn.ReadBytes(in, nBS);
             rCtx.Decode(in, nBS);
             rOut.WriteBytes(in, nBS);
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index a881fab5be0c..0ab07dfcadce 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -7471,7 +7471,7 @@ WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize)
     std::unique_ptr<sal_uInt8[]> pDataPtr( new sal_uInt8[ nMaxDopSize ] );
     sal_uInt8* pData = pDataPtr.get();
 
-    sal_uInt32 nRead = nMaxDopSize < nSize ? nMaxDopSize : nSize;
+    sal_uInt32 nRead = std::min(nMaxDopSize, nSize);
     if (nSize < 2 || !checkSeek(rSt, nPos) || nRead != rSt.ReadBytes(pData, nRead))
         nDopError = ERR_SWG_READ_ERROR;     // report error
     else
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index f1738423c6b4..bd6f50c6fc93 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -2396,7 +2396,7 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
             // In this case, the columns get the correct width even if
             // the sum of the relative widths is smaller than the available
             // width in TWIP. Therefore, we can use the relative width.
-            m_nWidth = nRelWidth > USHRT_MAX ? USHRT_MAX : nRelWidth;
+            m_nWidth = std::min<sal_Int32>(nRelWidth, USHRT_MAX);
         }
         if( nRelWidth != m_nWidth && nRelWidth && nCols )
         {
diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index 5bf8ee7caf76..89f4d63f615e 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -181,7 +181,7 @@ void SwLabPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
     // Scale factor
     const float fx = float(lOutWPix23) / std::max(1L, lDispW);
     const float fy = float(lOutHPix23) / std::max(1L, lDispH);
-    const float f  = fx < fy ? fx : fy;
+    const float f  = std::min(fx, fy);
 
     // zero point
     const long lOutlineW = ROUND(f * lDispW);
diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx
index 07d1c56bb662..90f50d67ace1 100644
--- a/sw/source/ui/table/instable.cxx
+++ b/sw/source/ui/table/instable.cxx
@@ -191,7 +191,7 @@ IMPL_LINK( SwInsTableDlg, ModifyRowCol, Edit&, rEdit, void )
         if( nActVal > nMax )
             m_pRepeatHeaderNF->SetValue( nMax );
         else if( nActVal < nEnteredValRepeatHeaderNF )
-            m_pRepeatHeaderNF->SetValue( ( nEnteredValRepeatHeaderNF < nMax )? nEnteredValRepeatHeaderNF : nMax );
+            m_pRepeatHeaderNF->SetValue( std::min( nEnteredValRepeatHeaderNF, nMax ) );
     }
 }
 IMPL_LINK( SwInsTableDlg, AutoFormatHdl, Button*, pButton, void )
diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index 741f38dffdaa..1aeb497bfa8f 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -581,8 +581,8 @@ namespace
         {
             if ( bResize && ( nCurWidth > nIdeal || nCurHeight > nIdeal ) )
             {
-                sal_Int32 nIdealWidth  = nCurWidth  > nIdeal ? nIdeal : nCurWidth;
-                sal_Int32 nIdealHeight = nCurHeight > nIdeal ? nIdeal : nCurHeight;
+                sal_Int32 nIdealWidth  = std::min(nCurWidth, nIdeal);
+                sal_Int32 nIdealHeight = std::min(nCurHeight, nIdeal);
 
                 ::Size aNewSize( nIdealWidth, nIdealHeight );
 
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 174753bac248..ffa53955719b 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -146,7 +146,7 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
         if ( PZSTREAM->avail_out == 0 ) ImplWriteBack();
         if ( PZSTREAM->avail_in == 0 && mnInToRead )
         {
-            nInToRead = ( mnInBufSize > mnInToRead ) ? mnInToRead : mnInBufSize;
+            nInToRead = std::min( mnInBufSize, mnInToRead );
             PZSTREAM->next_in = mpInBuf;
             PZSTREAM->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead);
             mnInToRead -= nInToRead;
@@ -212,7 +212,7 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize )
     {
         if ( PZSTREAM->avail_in == 0 && mnInToRead )
         {
-            nInToRead = (mnInBufSize > mnInToRead) ? mnInToRead : mnInBufSize;
+            nInToRead = std::min(mnInBufSize, mnInToRead);
             PZSTREAM->next_in = mpInBuf;
             PZSTREAM->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead);
             mnInToRead -= nInToRead;
@@ -256,7 +256,7 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize
     {
         if ( PZSTREAM->avail_in == 0 && mnInToRead )
         {
-            nInToRead = (mnInBufSize > mnInToRead) ? mnInToRead : mnInBufSize;
+            nInToRead = std::min(mnInBufSize, mnInToRead);
 
             sal_uInt32 const nRemaining = rIStm.remainingSize();
             if (nRemaining < nInToRead)
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() );


More information about the Libreoffice-commits mailing list