From f14b9d30293f180500fc56d81e5390021758e7c1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 8 Jan 2018 17:01:49 +0200 Subject: 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/47602 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/source/control/button.cxx | 4 ++-- vcl/source/control/imp_listbox.cxx | 2 +- vcl/source/fontsubset/sft.cxx | 4 ++-- vcl/source/gdi/print3.cxx | 4 ++-- vcl/source/window/toolbox.cxx | 4 ++-- vcl/unx/generic/printer/ppdparser.cxx | 2 +- vcl/unx/gtk/salnativewidgets-gtk.cxx | 2 +- vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) (limited to 'vcl') diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 1f1699397770..bd03840e34bb 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -358,8 +358,8 @@ void Button::ImplDrawAlignedImage(OutputDevice* pDev, Point& rPos, } } - aMax.Width() = aTSSize.Width() > aImageSize.Width() ? aTSSize.Width() : aImageSize.Width(); - aMax.Height() = aTSSize.Height() > aImageSize.Height() ? aTSSize.Height() : aImageSize.Height(); + aMax.Width() = std::max(aTSSize.Width(), aImageSize.Width()); + aMax.Height() = std::max(aTSSize.Height(), aImageSize.Height()); // Now calculate the output area for the image and the text according to the image align flags diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 9470e9a68675..755d12cb22bb 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -290,7 +290,7 @@ long ImplEntryList::GetAddedHeight( sal_Int32 i_nEndIndex, sal_Int32 i_nBeginInd { long nHeight = 0; sal_Int32 nStart = i_nEndIndex > i_nBeginIndex ? i_nBeginIndex : i_nEndIndex; - sal_Int32 nStop = i_nEndIndex > i_nBeginIndex ? 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 ) { diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 098d54b41b2d..98cf6998bef0 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -595,14 +595,14 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo abs1 = (a < 0) ? -a : a; abs2 = (b < 0) ? -b : b; - m = (abs1 > abs2) ? abs1 : abs2; + m = std::max(abs1, abs2); abs3 = abs1 - abs2; if (abs3 < 0) abs3 = -abs3; if (abs3 <= 33) m *= 2; abs1 = (c < 0) ? -c : c; abs2 = (d < 0) ? -d : d; - n = (abs1 > abs2) ? abs1 : abs2; + n = std::max(abs1, abs2); abs3 = abs1 - abs2; if (abs3 < 0) abs3 = -abs3; if (abs3 <= 33) n *= 2; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 4aef505fc7c1..30cdc4aebaa9 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -414,8 +414,8 @@ bool Printer::PreparePrintJob(std::shared_ptr xController, if( nRows > 1 || nCols > 1 ) { PrinterController::MultiPageSetup aMPS; - aMPS.nRows = nRows > 1 ? nRows : 1; - aMPS.nColumns = nCols > 1 ? nCols : 1; + aMPS.nRows = std::max(nRows, 1); + aMPS.nColumns = std::max(nCols, 1); sal_Int32 nValue = xController->getIntProperty("NUpPageMarginLeft", aMPS.nLeftMargin); if( nValue >= 0 ) aMPS.nLeftMargin = nValue; diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 0eb843cf167c..d473684fd0bb 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -973,7 +973,7 @@ void ToolBox::ImplLineSizing( const Point& rPos, tools::Rectangle& rRect, sal_uI } Size aWinSize = GetSizePixel(); - ImplToolItems::size_type nMaxLines = (mnLines > mnCurLines) ? mnLines : mnCurLines; + ImplToolItems::size_type nMaxLines = std::max(mnLines, mnCurLines); if ( nMaxLines > TB_MAXLINES ) nMaxLines = TB_MAXLINES; if ( bHorz ) @@ -1881,7 +1881,7 @@ Size ToolBox::ImplGetOptimalFloatingSize() // try to preserve current width - long nLineHeight = ( mnWinHeight > mnMaxItemHeight ) ? mnWinHeight : mnMaxItemHeight; + long nLineHeight = std::max( mnWinHeight, mnMaxItemHeight ); int nBorderX = 2*TB_BORDER_OFFSET1 + mnLeftBorder + mnRightBorder; int nBorderY = 2*TB_BORDER_OFFSET2 + mnTopBorder + mnBottomBorder; Size aSz( aCurrentSize ); diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index b81359c8fea5..fc62e0590988 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -1979,7 +1979,7 @@ int PPDContext::getRenderResolution() const else m_pParser->getDefaultResolution( nDPIx, nDPIy ); - nDPI = (nDPIx > nDPIy) ? nDPIx : nDPIy; + nDPI = std::max(nDPIx, nDPIy); } return nDPI; } diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx index 313af6cc0518..640bfe5eab6b 100644 --- a/vcl/unx/gtk/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx @@ -1237,7 +1237,7 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, GtkRequisition aReq; gtk_widget_size_request( widget, &aReq ); tools::Rectangle aEditRect = rControlRegion; - long nHeight = (aEditRect.GetHeight() > aReq.height) ? aEditRect.GetHeight() : aReq.height; + long nHeight = std::max(aEditRect.GetHeight(), aReq.height); aEditRect = tools::Rectangle( aEditRect.TopLeft(), Size( aEditRect.GetWidth(), nHeight ) ); rNativeBoundingRegion = aEditRect; diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index 38b724be27d8..d605eaf241cd 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -2574,7 +2574,7 @@ tools::Rectangle GetWidgetSize(const tools::Rectangle& rControlRegion, GtkWidget { GtkRequisition aReq; gtk_widget_get_preferred_size(widget, nullptr, &aReq); - long nHeight = (rControlRegion.GetHeight() > aReq.height) ? rControlRegion.GetHeight() : aReq.height; + long nHeight = std::max(rControlRegion.GetHeight(), aReq.height); return tools::Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nHeight)); } -- cgit