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 /sw | |
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 'sw')
-rw-r--r-- | sw/qa/core/Test-BigPtrArray.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/table/swnewtable.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/EnhancedPDFExportHelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/itratr.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/itrtxt.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/undo/unnum.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/html/htmlatr.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/html/htmlcss1.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltbli.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/envelp/labfmt.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/table/instable.cxx | 2 |
16 files changed, 18 insertions, 18 deletions
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 ) |