replace std::min(std::max()) with std::clamp
Change-Id: I76e34e8020d98292e8ffde387542b7029f85a42d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105754 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
using ::rtl::OUString;
|
||||
|
||||
#define AVMEDIA_DB_RANGE -40
|
||||
constexpr sal_Int32 AVMEDIA_DB_RANGE = -40;
|
||||
#define AVMEDIA_LINEINCREMENT 1.0
|
||||
#define AVMEDIA_PAGEINCREMENT 10.0
|
||||
|
||||
@@ -64,8 +64,7 @@ void MediaControlBase::UpdateVolumeSlider( MediaItem const & aMediaItem )
|
||||
{
|
||||
mxVolumeSlider->set_sensitive(true);
|
||||
const sal_Int32 nVolumeDB = aMediaItem.getVolumeDB();
|
||||
mxVolumeSlider->set_value( std::min( std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ),
|
||||
static_cast< sal_Int32 >( 0 ) ) );
|
||||
mxVolumeSlider->set_value( std::clamp( nVolumeDB, sal_Int32(0), AVMEDIA_DB_RANGE ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace basegfx::utils
|
||||
}
|
||||
|
||||
// min/max limitations
|
||||
nHorSeg = std::min(nMaxSegments, std::max(nMinSegments, nHorSeg));
|
||||
nHorSeg = std::clamp(nHorSeg, nMinSegments, nMaxSegments);
|
||||
|
||||
if(!nVerSeg)
|
||||
{
|
||||
@@ -229,7 +229,7 @@ namespace basegfx::utils
|
||||
}
|
||||
|
||||
// min/max limitations
|
||||
nVerSeg = std::min(nMaxSegments, std::max(nMinSegments, nVerSeg));
|
||||
nVerSeg = std::clamp(nVerSeg, nMinSegments, nMaxSegments);
|
||||
|
||||
// create constants
|
||||
const double fVerDiffPerStep((fVerStop - fVerStart) / static_cast<double>(nVerSeg));
|
||||
@@ -320,7 +320,7 @@ namespace basegfx::utils
|
||||
}
|
||||
|
||||
// min/max limitations
|
||||
nHorSeg = std::min(nMaxSegments, std::max(nMinSegments, nHorSeg));
|
||||
nHorSeg = std::clamp(nHorSeg, nMinSegments, nMaxSegments);
|
||||
|
||||
if(!nVerSeg)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ namespace basegfx::utils
|
||||
}
|
||||
|
||||
// min/max limitations
|
||||
nVerSeg = std::min(nMaxSegments, std::max(nMinSegments, nVerSeg));
|
||||
nVerSeg = std::clamp(nVerSeg, nMinSegments, nMaxSegments);
|
||||
|
||||
// vertical loop
|
||||
for(sal_uInt32 a(0); a < nVerSeg; a++)
|
||||
|
||||
@@ -1558,7 +1558,7 @@ namespace comphelper
|
||||
const sal_uInt16 nConfigNumCopies(static_cast<sal_uInt16>(sTokenOut.toUInt32()));
|
||||
|
||||
// limit to range [1..mnMaxAllowedBackups]
|
||||
mnNumBackups = std::min(std::max(nConfigNumCopies, mnNumBackups), mnMaxAllowedBackups);
|
||||
mnNumBackups = std::clamp(mnNumBackups, nConfigNumCopies, mnMaxAllowedBackups);
|
||||
}
|
||||
|
||||
if (mbActive && rtl::Bootstrap::get("SecureUserConfigMode", sTokenOut))
|
||||
|
||||
@@ -108,7 +108,7 @@ const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; ///< Relative character
|
||||
template< typename ReturnType, typename Type >
|
||||
inline ReturnType getLimitedValue( Type nValue, Type nMin, Type nMax )
|
||||
{
|
||||
return static_cast< ReturnType >( ::std::min( ::std::max( nValue, nMin ), nMax ) );
|
||||
return static_cast< ReturnType >( ::std::clamp( nValue, nMin, nMax ) );
|
||||
}
|
||||
|
||||
template< typename ReturnType, typename Type >
|
||||
|
||||
@@ -4113,7 +4113,7 @@ void ChartExport::exportMarker(const Reference< XPropertySet >& xPropSet)
|
||||
|
||||
nSize = nSize/250.0*7.0 + 1; // just guessed based on some test cases,
|
||||
//the value is always 1 less than the actual value.
|
||||
nSize = std::min<sal_Int32>( 72, std::max<sal_Int32>( 2, nSize ) );
|
||||
nSize = std::clamp( int(nSize), 2, 72 );
|
||||
pFS->singleElement(FSNS(XML_c, XML_size), XML_val, OString::number(nSize));
|
||||
|
||||
pFS->startElement(FSNS(XML_c, XML_spPr));
|
||||
|
||||
@@ -274,7 +274,7 @@ XclBoolError XclTools::ErrorToEnum( double& rfDblValue, bool bErrOrBool, sal_uIn
|
||||
sal_uInt16 XclTools::GetTwipsFromInch( double fInches )
|
||||
{
|
||||
return static_cast< sal_uInt16 >(
|
||||
::std::min( ::std::max( (fInches * EXC_TWIPS_PER_INCH + 0.5), 0.0 ), 65535.0 ) );
|
||||
::std::clamp( fInches * EXC_TWIPS_PER_INCH + 0.5, 0.0, 65535.0 ) );
|
||||
}
|
||||
|
||||
sal_uInt16 XclTools::GetTwipsFromHmm( sal_Int32 nHmm )
|
||||
|
||||
@@ -391,7 +391,7 @@ sal_Int32 SAL_CALL ScAccessibleCsvRuler::getIndexAtPoint( const css::awt::Point&
|
||||
ensureAlive();
|
||||
ScCsvRuler& rRuler = implGetRuler();
|
||||
// use object's coordinate system, convert to API position
|
||||
return lcl_GetApiPos( ::std::min( ::std::max( rRuler.GetPosFromX( rPoint.X ), static_cast<sal_Int32>(0) ), rRuler.GetPosCount() ) );
|
||||
return lcl_GetApiPos( ::std::clamp( rRuler.GetPosFromX( rPoint.X ), sal_Int32(0), rRuler.GetPosCount() ) );
|
||||
}
|
||||
|
||||
OUString SAL_CALL ScAccessibleCsvRuler::getSelectedText()
|
||||
|
||||
@@ -659,7 +659,7 @@ void PresenterVerticalScrollBar::UpdateBorders()
|
||||
else
|
||||
{
|
||||
const double nThumbSize = ::std::min(mnThumbSize,mnTotalSize);
|
||||
const double nThumbPosition = ::std::min(::std::max(0.0,mnThumbPosition), mnTotalSize - nThumbSize);
|
||||
const double nThumbPosition = ::std::clamp(mnThumbPosition, 0.0, mnTotalSize - nThumbSize);
|
||||
maBox[Thumb] = geometry::RealRectangle2D(
|
||||
0, nThumbPosition / mnTotalSize * nPagerHeight,
|
||||
aWindowBox.Width,
|
||||
|
||||
@@ -575,7 +575,7 @@ void SmGraphicWindow::Command(const CommandEvent& rCEvt)
|
||||
|
||||
void SmGraphicWindow::SetZoom(sal_uInt16 Factor)
|
||||
{
|
||||
nZoom = std::min(std::max(Factor, MINZOOM), MAXZOOM);
|
||||
nZoom = std::clamp(Factor, MINZOOM, MAXZOOM);
|
||||
Fraction aFraction (nZoom, 100);
|
||||
SetMapMode( MapMode(MapUnit::Map100thMM, Point(), aFraction, aFraction) );
|
||||
SetTotalSize();
|
||||
|
||||
@@ -458,7 +458,7 @@ namespace
|
||||
nBaseIndex = bUpper ? nVisEdgeUp : nVisEdgeDn;
|
||||
}
|
||||
|
||||
const size_t nSecuredIndex(std::min(nNumCutSets - 1, std::max(nBaseIndex, static_cast< size_t >(0))));
|
||||
const size_t nSecuredIndex(std::clamp(nBaseIndex, size_t(0), size_t(nNumCutSets - 1)));
|
||||
const CutSet& rCutSet(aCutSets[nSecuredIndex]);
|
||||
ExtendSet& rExt(rExtendSet[my]);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ PointerStyle TableEdgeHdl::GetPointer() const
|
||||
|
||||
sal_Int32 TableEdgeHdl::GetValidDragOffset( const SdrDragStat& rDrag ) const
|
||||
{
|
||||
return std::min( std::max( static_cast<sal_Int32>(mbHorizontal ? rDrag.GetDY() : rDrag.GetDX()), mnMin ), mnMax );
|
||||
return std::clamp( static_cast<sal_Int32>(mbHorizontal ? rDrag.GetDY() : rDrag.GetDX()), mnMin, mnMax );
|
||||
}
|
||||
|
||||
basegfx::B2DPolyPolygon TableEdgeHdl::getSpecialDragPoly(const SdrDragStat& rDrag) const
|
||||
|
||||
@@ -3049,7 +3049,7 @@ namespace
|
||||
|
||||
sal_uInt16 lcl_BoundListLevel(const int nActualLevel)
|
||||
{
|
||||
return static_cast<sal_uInt16>( std::min( std::max(nActualLevel, 0), MAXLEVEL-1 ) );
|
||||
return static_cast<sal_uInt16>( std::clamp( nActualLevel, 0, MAXLEVEL-1 ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& r
|
||||
MapMode aMap( MapUnit::Map100thInch );
|
||||
|
||||
sal_Int32 nDPI = rConfigItem.ReadInt32( "Resolution", 75 );
|
||||
Fraction aFrac( 1, std::min( std::max( nDPI, sal_Int32( 75 ) ), sal_Int32( 600 ) ) );
|
||||
Fraction aFrac( 1, std::clamp( nDPI, sal_Int32(75), sal_Int32(600) ) );
|
||||
|
||||
aMap.SetScaleX( aFrac );
|
||||
aMap.SetScaleY( aFrac );
|
||||
|
||||
@@ -1361,7 +1361,7 @@ void OutputDevice::DrawTransformedBitmapEx(
|
||||
const Size& rOriginalSizePixel(rBitmapEx.GetSizePixel());
|
||||
const double fOrigArea(rOriginalSizePixel.Width() * rOriginalSizePixel.Height() * 0.5);
|
||||
const double fOrigAreaScaled(fOrigArea * 1.44);
|
||||
double fMaximumArea(std::min(4500000.0, std::max(1000000.0, fOrigAreaScaled)));
|
||||
double fMaximumArea(std::clamp(fOrigAreaScaled, 1000000.0, 4500000.0));
|
||||
// tdf#130768 CAUTION(!) using GetViewTransformation() is *not* enough here, it may
|
||||
// be that mnOutOffX/mnOutOffY is used - see AOO bug 75163, mentioned at
|
||||
// ImplGetDeviceTransformation declaration
|
||||
|
||||
Reference in New Issue
Block a user