Kaydet (Commit) f14b9d30 authored tarafından Noel Grandin's avatar Noel Grandin

convert (a>b?a:b) to std::max(a,b)

with something like:
   git grep -nP '(.*)\s*>\s*(.*)\s*\?\s*\g1\s*:\s*\g2'

Change-Id: I60b9a3a2a09162bc0de4c13fdde2c209696e5413
Reviewed-on: https://gerrit.libreoffice.org/47602Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d11120b9
......@@ -81,7 +81,7 @@ VLCFrameGrabber::VLCFrameGrabber( wrapper::EventHandler& eh, const rtl::OUString
return ::uno::Reference< css::graphic::XGraphic >();
}
mPlayer.setTime( ( fMediaTime > 0 ? fMediaTime : 0 ) * MSEC_IN_SEC );
mPlayer.setTime( std::max(fMediaTime, 0) * MSEC_IN_SEC );
mPlayer.pause();
condition.wait(std::chrono::seconds(2));
......
......@@ -817,7 +817,7 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
sal_Int32 nLinespPage = aPaperSz.Height()/nLineHeight;
long nXTextWidth = pPrinter->approximate_char_width();
sal_Int32 nCharspLine = aPaperSz.Width() / (nXTextWidth > 1 ? nXTextWidth : 1);
sal_Int32 nCharspLine = aPaperSz.Width() / std::max<long>(nXTextWidth, 1);
const sal_uInt32 nParas = GetEditEngine()->GetParagraphCount();
sal_Int32 nPages = nParas/nLinespPage+1;
......
......@@ -297,7 +297,7 @@ void SeriesHeader::SetSeriesName( const OUString & rName )
void SeriesHeader::SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol )
{
m_nStartCol = nStartCol;
m_nEndCol = (nEndCol > nStartCol) ? nEndCol : nStartCol;
m_nEndCol = std::max(nEndCol, nStartCol);
m_spSeriesName->setStartColumn( nStartCol );
}
......
......@@ -1479,7 +1479,7 @@ void GL3DBarChart::processAutoFly(sal_uInt32 nId, sal_uInt32 nColor)
maRenderEvent = EVENT_AUTO_FLY;
mnSelectBarId = nColorRate > mnColorRate ? nId : mnSelectBarId;
mnPreSelectBarId = mnSelectBarId;
mnColorRate = nColorRate > mnColorRate ? nColorRate : mnColorRate;
mnColorRate = std::max(nColorRate, mnColorRate);
}
}
......
......@@ -420,7 +420,7 @@ bool createParameterT(const tPointVecType& rUniquePoints, double* t)
dx = rUniquePoints[i].first - rUniquePoints[i-1].first;
dy = rUniquePoints[i].second - rUniquePoints[i-1].second;
// scaling to avoid underflow or overflow
fDiffMax = (fabs(dx)>fabs(dy)) ? fabs(dx) : fabs(dy);
fDiffMax = std::max(fabs(dx), fabs(dy));
if (fDiffMax == 0.0)
{
bIsSuccessful = false;
......@@ -446,7 +446,7 @@ bool createParameterT(const tPointVecType& rUniquePoints, double* t)
{
dx = rUniquePoints[i].first - rUniquePoints[i-1].first;
dy = rUniquePoints[i].second - rUniquePoints[i-1].second;
fDiffMax = (fabs(dx)>fabs(dy)) ? fabs(dx) : fabs(dy);
fDiffMax = std::max(fabs(dx), fabs(dy));
// same as above, so should not be zero
dx /= fDiffMax;
dy /= fDiffMax;
......
......@@ -83,8 +83,8 @@ static void lcl_UpdateArea( const Reference<XCellRange>& xUsedRange, sal_Int32&
const CellRangeAddress* pData = aAddresses.getConstArray();
for ( sal_Int32 i=0; i<nCount; i++ )
{
rEndCol = pData[i].EndColumn > rEndCol ? pData[i].EndColumn : rEndCol;
rEndRow = pData[i].EndRow > rEndRow ? pData[i].EndRow : rEndRow;
rEndCol = std::max(pData[i].EndColumn, rEndCol);
rEndRow = std::max(pData[i].EndRow, rEndRow);
}
}
}
......
......@@ -875,7 +875,7 @@ Image SvxToolbarEntriesListBox::GetSizedImage(
// We need 2 pixels to have a bigger border to the next button image
sal_uInt16 nPosX = std::max( (sal_uInt16) (((( aNewSize.Width() - 2 ) - aImage.GetSizePixel().Width() ) / 2 ) - 1), (sal_uInt16) 0 );
sal_uInt16 nPosY = std::max( (sal_uInt16) (((( aNewSize.Height() - 2 ) - aImage.GetSizePixel().Height() ) / 2 ) + 1), (sal_uInt16) 0 );
Point aPos( nPosX > 0 ? nPosX : 0, nPosY > 0 ? nPosY : 0 );
Point aPos( std::max<sal_uInt16>(nPosX, 0), std::max<sal_uInt16>(nPosY, 0) );
rVDev.SetFillColor( aFillColor );
rVDev.SetLineColor( aFillColor );
rVDev.DrawRect( ::tools::Rectangle( Point(), aNewSize ));
......
......@@ -185,7 +185,7 @@ namespace dbaui
sal_Int32 nWidthAsc = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
sal_Int32 nWidthDesc = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
// maximum plus some additional space
return (nWidthAsc > nWidthDesc ? nWidthAsc : nWidthDesc) + GetTextWidth(OUString('0')) * 2;
return std::max(nWidthAsc, nWidthDesc) + GetTextWidth(OUString('0')) * 2;
}
return EditBrowseBox::GetTotalCellWidth(_nRow, _nColId);
}
......@@ -211,10 +211,10 @@ namespace dbaui
sal_Int32 nSortOrderColumnWidth = GetTextWidth(sColumnName);
// ("ascending" + scrollbar width)
sal_Int32 nOther = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther;
nSortOrderColumnWidth = std::max(nSortOrderColumnWidth, nOther);
// ("descending" + scrollbar width)
nOther = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther;
nSortOrderColumnWidth = std::max(nSortOrderColumnWidth, nOther);
// (plus some additional space)
nSortOrderColumnWidth += GetTextWidth(OUString('0')) * 2;
InsertDataColumn(COLUMN_ID_ORDER, sColumnName, nSortOrderColumnWidth, HeaderBarItemBits::STDSTYLE, 1);
......
......@@ -453,7 +453,7 @@ namespace drawinglayer
// TODO: eKerning
// set FontHeight and init to no FontScaling
o_rSize.setY(rFont.GetFontSize().getHeight() > 0 ? rFont.GetFontSize().getHeight() : 0);
o_rSize.setY(std::max<long>(rFont.GetFontSize().getHeight(), 0));
o_rSize.setX(o_rSize.getY());
#ifdef _WIN32
......
......@@ -234,7 +234,7 @@ namespace drawinglayer
// calculate logic pixel size in texture coordinates
const double fLogicTexSizeX(fLogicPixelSizeWorld / rPrimitive.getTextureSize().getX());
const double fLogicTexSizeY(fLogicPixelSizeWorld / rPrimitive.getTextureSize().getY());
const double fLogicTexSize(fLogicTexSizeX > fLogicTexSizeY ? fLogicTexSizeX : fLogicTexSizeY);
const double fLogicTexSize(std::max(fLogicTexSizeX, fLogicTexSizeY));
// create texture and set
mpGeoTexSvx.reset(new texture::GeoTexSvxMultiHatch(rPrimitive, fLogicTexSize));
......
......@@ -192,7 +192,7 @@ ConvertBorderWidthFromWord(SvxBorderLineStyle const eStyle, double const i_fWidt
case 2:
return (fWidth * 2.0); // thick
case 5: // fdo#55526: map 0 hairline width to > 0
return (fWidth > 1.0) ? fWidth : 1.0;
return std::max(fWidth, 1.0);
default:
return fWidth;
}
......
......@@ -144,7 +144,7 @@ bool SvxEditSourceHelper::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nE
nClosestStartIndex_e = nCurrIndex;
}
}
sal_Int32 nClosestStartIndex = nClosestStartIndex_s > nClosestStartIndex_e ? nClosestStartIndex_s : nClosestStartIndex_e;
sal_Int32 nClosestStartIndex = std::max(nClosestStartIndex_s, nClosestStartIndex_e);
// find closest index behind of nIndex
sal_Int32 nClosestEndIndex_s, nClosestEndIndex_e;
......
......@@ -56,7 +56,7 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase
sal_Int32 nStartPos = 0;
sal_Int32 nEndPos = mrText.GetEditSource()->GetTextForwarder()->GetTextLen( currentPara );
if( currentPara == maSelection.nStartPara )
nStartPos = nStartPos>maSelection.nStartPos ? nStartPos : maSelection.nStartPos;
nStartPos = std::max(nStartPos, maSelection.nStartPos);
if( currentPara == maSelection.nEndPara )
nEndPos = nEndPos<maSelection.nEndPos ? nEndPos : maSelection.nEndPos;
ESelection aCurrentParaSel = ESelection( currentPara, nStartPos, currentPara, nEndPos );
......@@ -399,7 +399,7 @@ SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration(const SvxUnoTextBase& rTe
if( nEndPos < mnSel.nStartPos )
continue;
nStartPos = nStartPos>mnSel.nStartPos ? nStartPos : mnSel.nStartPos;
nStartPos = std::max<int>(nStartPos, mnSel.nStartPos);
nEndPos = nEndPos<mnSel.nEndPos ? nEndPos : mnSel.nEndPos;
ESelection aSel( mnParagraph, nStartPos, mnParagraph, nEndPos );
......
......@@ -58,8 +58,8 @@ awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt
OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0,
"Offset must not be less then zero!" );
aResult.X = aRect1.X > aRect2.X ? aRect1.X : aRect2.X;
aResult.Y = aRect1.Y > aRect2.Y ? aRect1.Y : aRect2.Y;
aResult.X = std::max(aRect1.X, aRect2.X);
aResult.Y = std::max(aRect1.Y, aRect2.Y);
sal_Int32 nRight1 = aRect1.X + aRect1.Width;
sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
......
......@@ -6360,7 +6360,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >&
aTabItem.Insert( SvxTabStop( (sal_uInt16)0 ) );
if ( nDefaultTab )
{
nTab = ( nTextOfs2 > nLatestManTab ) ? nTextOfs2 : nLatestManTab;
nTab = std::max( nTextOfs2, nLatestManTab );
nTab /= nDefaultTab;
nTab = nDefaultTab * ( 1 + nTab );
for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ )
......
......@@ -350,7 +350,7 @@ WordBreakCache& xdictionary::getCache(const sal_Unicode *text, Boundary const &
rCache.size = len;
}
else
rCache.size = len > DEFAULT_SIZE ? len : DEFAULT_SIZE;
rCache.size = std::max<sal_Int32>(len, DEFAULT_SIZE);
rCache.contents = new sal_Unicode[rCache.size + 1];
rCache.wordboundary = new sal_Int32[rCache.size + 2];
}
......
......@@ -56,6 +56,7 @@
*/
#include <string.h>
#include <algorithm>
#if defined( _MSC_VER )
#pragma warning(once: 4068)
......@@ -63,10 +64,6 @@
#include "levdis.hxx"
#ifdef __sun
#undef min
#endif
#define LEVDISBIG (nLimit + 1) // Return value if distance > nLimit
#define LEVDISDOUBLEBUF 2048 // no doubling atop this border
......@@ -340,9 +337,9 @@ int WLevDistance::Mid3( int x, int y, int z )
int WLevDistance::Max3( int x, int y, int z )
{
if ( x > y )
return( x > z ? x : z );
return std::max(x, z);
else
return( y > z ? y : z );
return std::max(y, z);
}
// initialize data from CTOR
......
......@@ -37,7 +37,7 @@ TextConversionImpl::getConversions( const OUString& aText, sal_Int32 nStartPos,
sal_Int32 len = aText.getLength() - nStartPos;
if (nLength > len)
nLength = len > 0 ? len : 0;
nLength = std::max<sal_Int32>(len, 0);
return xTC->getConversions(aText, nStartPos, nLength, rLocale, nConversionType, nConversionOptions);
}
......@@ -49,7 +49,7 @@ TextConversionImpl::getConversion( const OUString& aText, sal_Int32 nStartPos, s
sal_Int32 len = aText.getLength() - nStartPos;
if (nLength > len)
nLength = len > 0 ? len : 0;
nLength = std::max<sal_Int32>(len, 0);
return xTC->getConversion(aText, nStartPos, nLength, rLocale, nConversionType, nConversionOptions);
}
......@@ -61,7 +61,7 @@ TextConversionImpl::getConversionWithOffset( const OUString& aText, sal_Int32 nS
sal_Int32 len = aText.getLength() - nStartPos;
if (nLength > len)
nLength = len > 0 ? len : 0;
nLength = std::max<sal_Int32>(len, 0);
return xTC->getConversionWithOffset(aText, nStartPos, nLength, rLocale, nConversionType, nConversionOptions, offset);
}
......
......@@ -151,8 +151,8 @@ namespace basegfx
const double fDistG(getDistanceGreen(rColor));
const double fDistB(getDistanceBlue(rColor));
double fRetval(fDistR > fDistG ? fDistR : fDistG);
return (fRetval > fDistB ? fRetval : fDistB);
double fRetval(std::max(fDistR, fDistG));
return std::max(fRetval, fDistB);
}
// clamp color to [0.0..1.0] values in all three intensity components
......
......@@ -23,6 +23,7 @@
#include <rtl/math.hxx>
#include <basegfx/basegfxdllapi.h>
#include <limits>
#include <algorithm>
// standard PI defines from solar.h, but we do not want to link against tools
......@@ -101,7 +102,7 @@ namespace basegfx
if(fVal < 0.0)
return (fVal < -0.00001 ? fVal : -0.00001);
else
return (fVal > 0.00001 ? fVal : 0.00001);
return std::max(fVal, 0.00001);
}
/** clamp given value against given minimum and maximum values
......
......@@ -314,7 +314,7 @@ static sal_Int32 PathRemoveFileSpec(LPWSTR lpPath, LPWSTR lpFileName, sal_Int32
lpFileName[0] = 0;
LPWSTR lpLastBkSlash = wcsrchr( lpPath, '\\' );
LPWSTR lpLastSlash = wcsrchr( lpPath, '/' );
LPWSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash;
LPWSTR lpLastDelimiter = std::max(lpLastSlash, lpLastBkSlash);
if ( lpLastDelimiter )
{
......
......@@ -213,7 +213,7 @@ int getBitsInFracPart(double fAbsValue)
int nFracSignificant = 53 - nLeastSignificant;
int nBitsInFracPart = nFracSignificant - nExponent;
return nBitsInFracPart > 0 ? nBitsInFracPart : 0;
return std::max(nBitsInFracPart, 0);
}
template< typename T >
......
......@@ -511,8 +511,8 @@ static void lcl_AdjustJumpMatrix( ScJumpMatrix* pJumpM, SCSIZE nParmCols, SCSIZE
{
if ( nJumpCols == 1 && nJumpRows == 1 )
{
nAdjustCols = nParmCols > nResCols ? nParmCols : nResCols;
nAdjustRows = nParmRows > nResRows ? nParmRows : nResRows;
nAdjustCols = std::max(nParmCols, nResCols);
nAdjustRows = std::max(nParmRows, nResRows);
}
else if ( nJumpCols == 1 )
{
......@@ -8772,7 +8772,7 @@ void ScInterpreter::ScMidB()
aStr = lcl_LeftB(aStr, (sal_Int32)fAnfang + (sal_Int32)fCnt - 1);
sal_Int32 nCnt = getLengthB(aStr) - (sal_Int32)fAnfang + 1;
aStr = lcl_RightB(aStr, nCnt>0 ? nCnt:0);
aStr = lcl_RightB(aStr, std::max<sal_Int32>(nCnt,0));
PushString(aStr);
}
}
......
......@@ -301,7 +301,7 @@ private:
return false;
T nMin = nMin1 < nMin2 ? nMin1 : nMin2;
T nMax = nMax1 > nMax2 ? nMax1 : nMax2;
T nMax = std::max(nMax1, nMax2);
rNewMin = nMin;
rNewMax = nMax;
......
......@@ -2726,8 +2726,8 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI
resultAddress.StartColumn = ( cell1.StartColumn < cell2.StartColumn ) ? cell1.StartColumn : cell2.StartColumn;
resultAddress.StartRow = ( cell1.StartRow < cell2.StartRow ) ? cell1.StartRow : cell2.StartRow;
resultAddress.EndColumn = ( cell1.EndColumn > cell2.EndColumn ) ? cell1.EndColumn : cell2.EndColumn;
resultAddress.EndRow = ( cell1.EndRow > cell2.EndRow ) ? cell1.EndRow : cell2.EndRow;
resultAddress.EndColumn = std::max( cell1.EndColumn, cell2.EndColumn );
resultAddress.EndRow = std::max( cell1.EndRow, cell2.EndRow );
if ( bForceUseInpuRangeTab )
{
// this is a call from Application.Range( x,y )
......
......@@ -2810,7 +2810,7 @@ void ScPrintFunc::CalcZoom( sal_uInt16 nRangeNo ) // calcu
// #i54993# use min forced by breaks if it's > # pages in
// scale parameter to avoid bottoming out at <= ZOOM_MIN
nPagesToFit = nMinPages > nPagesToFit ? nMinPages : nPagesToFit;
nPagesToFit = std::max(nMinPages, nPagesToFit);
}
sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
......@@ -2868,8 +2868,8 @@ void ScPrintFunc::CalcZoom( sal_uInt16 nRangeNo ) // calcu
// #i54993# use min forced by breaks if it's > # pages in
// scale parameters to avoid bottoming out at <= ZOOM_MIN
nW = nMinPagesW > nW ? nMinPagesW : nW;
nH = nMinPagesH > nH ? nMinPagesH : nH;
nW = std::max(nMinPagesW, nW);
nH = std::max(nMinPagesH, nH);
}
sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
......
......@@ -550,12 +550,12 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
if ( nBlockStartX <= nCurX + nColSpan - 1 )
{
SCCOL nCurXOffsetTemp = (nCurX < nCurX + nColSpan - 1) ? nColSpan - 1 : 0;
nCurXOffset = nCurXOffset > nCurXOffsetTemp ? nCurXOffset : nCurXOffsetTemp;
nCurXOffset = std::max(nCurXOffset, nCurXOffsetTemp);
}
if ( nBlockStartY <= nCurY + nRowSpan - 1 )
{
SCROW nCurYOffsetTemp = (nCurY < nCurY + nRowSpan - 1) ? nRowSpan - 1 : 0;
nCurYOffset = nCurYOffset > nCurYOffsetTemp ? nCurYOffset : nCurYOffsetTemp;
nCurYOffset = std::max(nCurYOffset, nCurYOffsetTemp);
}
if ( !( nBlockStartX <= nCurX && nBlockStartY <= nCurY ) &&
!( nBlockStartX > nCurX + nColSpan - 1 && nBlockStartY > nCurY + nRowSpan - 1 ) )
......
......@@ -2732,7 +2732,7 @@ sal_Int32 ScaDate::getDiff( const ScaDate& rFrom, const ScaDate& rTo )
}
// finally add remaining days in this month
nDiff += aTo.nDay - aFrom.nDay;
return nDiff > 0 ? nDiff : 0;
return std::max<sal_Int32>(nDiff, 0);
}
bool ScaDate::operator<( const ScaDate& rCmp ) const
......
......@@ -912,10 +912,10 @@ sal_Int32 Layouter::Implementation::GetIndex (
return ::tools::Rectangle(
Point (mnLeftBorder
+ nColumn * maPageObjectSize.Width()
+ (nColumn>0 ? nColumn : 0) * mnHorizontalGap,
+ std::max<sal_Int32>(nColumn,0) * mnHorizontalGap,
mnTopBorder
+ nRow * maPageObjectSize.Height()
+ (nRow>0 ? nRow : 0) * mnVerticalGap),
+ std::max<sal_Int32>(nRow,0) * mnVerticalGap),
maPageObjectSize);
}
......
......@@ -570,7 +570,7 @@ void OnMeasureItem(HWND hwnd, LPMEASUREITEMSTRUCT lpmis)
pMyItem->text.getLength(), &size);
lpmis->itemWidth = size.cx + 4 + GetSystemMetrics( SM_CXSMICON );
lpmis->itemHeight = (size.cy > GetSystemMetrics( SM_CYSMICON )) ? size.cy : GetSystemMetrics( SM_CYSMICON );
lpmis->itemHeight = std::max<int>(size.cy, GetSystemMetrics( SM_CYSMICON ));
lpmis->itemHeight += 4;
DeleteObject( SelectObject(hdc, hfntOld) );
......
......@@ -284,7 +284,7 @@ void SmEditWindow::Resize()
if (pEditView->GetVisArea().Top() > nMaxVisAreaStart)
{
tools::Rectangle aVisArea(pEditView->GetVisArea() );
aVisArea.Top() = (nMaxVisAreaStart > 0 ) ? nMaxVisAreaStart : 0;
aVisArea.Top() = std::max<long>(nMaxVisAreaStart, 0);
aVisArea.SetSize(pEditView->GetOutputArea().GetSize());
pEditView->SetVisArea(aVisArea);
pEditView->ShowCursor();
......
......@@ -675,7 +675,7 @@ void SmSetSelectionVisitor::Visit( SmTextNode* pNode ) {
pNode->SetSelected(true);
if( i1 != -1 && i2 != -1 ) {
start = i1 < i2 ? i1 : i2; //MIN
end = i1 > i2 ? i1 : i2; //MAX
end = std::max(i1, i2);
} else if( mbSelecting && i1 != -1 ) {
start = 0;
end = i1;
......
......@@ -544,7 +544,7 @@ static long ImplGetNativeCheckAndRadioSize(vcl::RenderContext const & rRenderCon
rMaxWidth = std::max (rMaxWidth, aNativeContent.GetWidth());
}
}
return (rCheckHeight > rRadioHeight) ? rCheckHeight : rRadioHeight;
return std::max(rCheckHeight, rRadioHeight);
}
#define gfxExtra 7
......
......@@ -57,7 +57,7 @@ Point GetAnglePnt(const tools::Rectangle& rR, long nAngle)
Point aCenter(rR.Center());
long nWdt=rR.Right()-rR.Left();
long nHgt=rR.Bottom()-rR.Top();
long nMaxRad=((nWdt>nHgt ? nWdt : nHgt)+1) /2;
long nMaxRad=(std::max(nWdt,nHgt)+1) /2;
double a;
a=nAngle*nPi180;
Point aRetval(svx::Round(cos(a)*nMaxRad),-svx::Round(sin(a)*nMaxRad));
......@@ -863,7 +863,7 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const Point& rRef2)
Point aCenter(maRect.Center());
long nWdt=maRect.GetWidth()-1;
long nHgt=maRect.GetHeight()-1;
long nMaxRad=((nWdt>nHgt ? nWdt : nHgt)+1) /2;
long nMaxRad=(std::max(nWdt,nHgt)+1) /2;
double a;
// starting point
a=nStartAngle*nPi180;
......
......@@ -336,7 +336,7 @@ void SdrMeasureObj::ImpTakeAttr(ImpMeasureRec& rRec) const
long impGetLineStartEndDistance(const basegfx::B2DPolyPolygon& rPolyPolygon, long nNewWidth, bool bCenter)
{
const basegfx::B2DRange aPolygonRange(rPolyPolygon.getB2DRange());
const double fOldWidth(aPolygonRange.getWidth() > 1.0 ? aPolygonRange.getWidth() : 1.0);
const double fOldWidth(std::max(aPolygonRange.getWidth(), 1.0));
const double fScale((double)nNewWidth / fOldWidth);
long nHeight(basegfx::fround(aPolygonRange.getHeight() * fScale));
......
......@@ -2782,7 +2782,7 @@ void SwTabFramePainter::Insert( SwLineEntry& rNew, bool bHori )
const svx::frame::Style& rOldAttr = rOld.maAttribute;
const svx::frame::Style& rNewAttr = rNew.maAttribute;
const svx::frame::Style& rCmpAttr = rNewAttr > rOldAttr ? rNewAttr : rOldAttr;
const svx::frame::Style& rCmpAttr = std::max(rNewAttr, rOldAttr);
if ( SwLineEntry::OVERLAP1 == nOverlapType )
{
......
......@@ -3038,7 +3038,7 @@ SwTwips SwTabFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo )
if ( nReal < nDist )
{
long nTmp = GetUpper()->Grow( nDist - ( nReal > 0 ? nReal : 0), bTst, bInfo );
long nTmp = GetUpper()->Grow( nDist - std::max<long>(nReal, 0), bTst, bInfo );
if ( IsRestrictTableGrowth() )
{
......
......@@ -2110,7 +2110,7 @@ SwTwips SwContentFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo )
if( GetUpper() )
{
if( bTst || !GetUpper()->IsFooterFrame() )
nReal = GetUpper()->Grow( nDist - (nReal > 0 ? nReal : 0),
nReal = GetUpper()->Grow( nDist - std::max<long>(nReal, 0),
bTst, bInfo );
else
{
......
......@@ -828,7 +828,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf )
const bool bFull = rInf.Width() < rInf.X() + Width();
const bool bFly = rInf.GetFly() ||
( rInf.GetLast() && rInf.GetLast()->IsFlyPortion() );
SetAscent( static_cast<sal_uInt16>(GetRelPos() > 0 ? GetRelPos() : 0) );
SetAscent( std::max<sal_uInt16>(GetRelPos(), 0) );
if( GetAscent() > Height() )
Height( GetAscent() );
......
......@@ -173,7 +173,7 @@ sal_Int32 SwWrongList::NextWrong( sal_Int32 nChk ) const
}
}
if( nRet > GetBeginInv() && nChk < GetEndInv() )
nRet = nChk > GetBeginInv() ? nChk : GetBeginInv();
nRet = std::max(nChk, GetBeginInv());
return nRet;
}
......
......@@ -2048,7 +2048,7 @@ void SwHTMLParser::SetVarSize( SvxCSS1PropertyInfo const &rPropInfo,
nWidth = MINFLY;
break;
case SVX_CSS1_LTYPE_TWIP:
nWidth = rPropInfo.m_nWidth > MINFLY ? rPropInfo.m_nWidth : MINFLY;
nWidth = std::max<long>(rPropInfo.m_nWidth, MINFLY);
nPrcWidth = 0;
break;
default:
......@@ -2062,7 +2062,7 @@ void SwHTMLParser::SetVarSize( SvxCSS1PropertyInfo const &rPropInfo,
case SVX_CSS1_LTYPE_TWIP:
// Netscape and MS-IE interpreting the height incorrectly as minimum height,
// therefore we are doing the same.
nHeight = rPropInfo.m_nHeight > MINFLY ? rPropInfo.m_nHeight : MINFLY;
nHeight = std::max<long>(rPropInfo.m_nHeight, MINFLY);
break;
default:
;
......
......@@ -303,7 +303,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
else
{
const sal_Int32 nLoop = rOption.GetSNumber();
nCount = static_cast<sal_uInt16>(nLoop>0 ? nLoop : 0);
nCount = std::max<sal_Int32>(nLoop, 0);
}
break;
......
......@@ -235,8 +235,8 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace,
if( nLeftSpace > 0 || nRightSpace > 0 )
{
SvxLRSpaceItem aLRItem( RES_LR_SPACE );
aLRItem.SetLeft( nLeftSpace > 0 ? nLeftSpace : 0 );
aLRItem.SetRight( nRightSpace > 0 ? nRightSpace : 0 );
aLRItem.SetLeft( std::max<sal_Int32>(nLeftSpace, 0) );
aLRItem.SetRight( std::max<sal_Int32>(nRightSpace, 0) );
rFlyItemSet.Put( aLRItem );
if( nLeftSpace )
{
......
......@@ -382,7 +382,7 @@ long SwWriteTable::GetAbsHeight(long nRawHeight, size_t const nRow,
}
OSL_ENSURE( nRawHeight > 0, "Row Height <= 0. OK?" );
return nRawHeight > 0 ? nRawHeight : 0;
return std::max<long>(nRawHeight, 0);
}
bool SwWriteTable::ShouldExpandSub(const SwTableBox *pBox, bool /*bExpandedBefore*/,
......
......@@ -1213,7 +1213,7 @@ static long lcl_GetTrueMargin(const SvxLRSpaceItem &rLR, const SwNumFormat &rFor
const long nReverseListIndented = GetListFirstLineIndent(rFormat);
long nExtraListIndent = nPseudoListBodyIndent + nReverseListIndented;
return nExtraListIndent > 0 ? nExtraListIndent : 0;
return std::max<long>(nExtraListIndent, 0);
}
// #i103711#
......
......@@ -259,8 +259,8 @@ void SwModule::InsertLab(SfxRequest& rReq, bool bLabel)
// Set page size
long lPgWidth, lPgHeight;
lPgWidth = (rItem.m_lPWidth > MINLAY ? rItem.m_lPWidth : MINLAY);
lPgHeight = (rItem.m_lPHeight > MINLAY ? rItem.m_lPHeight : MINLAY);
lPgWidth = std::max<sal_Int32>(rItem.m_lPWidth, MINLAY);
lPgHeight = std::max<sal_Int32>(rItem.m_lPHeight, MINLAY);
rFormat.SetFormatAttr( SwFormatFrameSize( ATT_FIX_SIZE, lPgWidth, lPgHeight ));
// Numbering type
SvxNumberType aType;
......
......@@ -111,7 +111,7 @@ SwInputWindow::SwInputWindow(vcl::Window* pParent, SfxDispatcher const * pDispat
Size aSizeTbx = CalcWindowSizePixel();
Size aEditSize = aEdit->GetSizePixel();
tools::Rectangle aItemRect( GetItemRect(FN_FORMULA_CALC) );
long nMaxHeight = (aEditSize.Height() > aItemRect.GetHeight()) ? aEditSize.Height() : aItemRect.GetHeight();
long nMaxHeight = std::max(aEditSize.Height(), aItemRect.GetHeight());
if( nMaxHeight+2 > aSizeTbx.Height() )
aSizeTbx.Height() = nMaxHeight+2;
Size aSize = GetSizePixel();
......
......@@ -1703,8 +1703,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const int nRgt = (bTableVertical ? nPageHeight : nPageWidth) -
(aTabCols.GetLeftMin() + aTabCols.GetRight());
const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
const sal_uInt16 nL = std::max< sal_uInt16 >(nLft, 0);
const sal_uInt16 nR = std::max< sal_uInt16 >(nRgt, 0);
SvxColumnItem aColItem(nNum, nL, nR);
......@@ -1940,8 +1940,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const int nRgt = (bVerticalWriting ? nPageWidth : nPageHeight) -
(aTabCols.GetLeftMin() + aTabCols.GetRight());
const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
const sal_uInt16 nL = std::max< sal_uInt16 >(nLft, 0);
const sal_uInt16 nR = std::max< sal_uInt16 >(nRgt, 0);
SvxColumnItem aColItem(0, nL, nR);
......@@ -2014,8 +2014,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
const int nRgt = nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);