replace std::max(std::min()) with std::clamp
Change-Id: I890d19f5e2177294dc1175c90c98b964347f9e85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105751
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index a03d9ce..a341c19 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -110,9 +110,9 @@ static void CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKe
fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
dR = std::max( std::min( ( 1.0 - fCyan ), 1.0), 0.0 );
dG = std::max( std::min( ( 1.0 - fMagenta ), 1.0), 0.0 );
dB = std::max( std::min( ( 1.0 - fYellow ), 1.0), 0.0 );
dR = std::clamp( 1.0 - fCyan, 0.0, 1.0 );
dG = std::clamp( 1.0 - fMagenta, 0.0, 1.0 );
dB = std::clamp( 1.0 - fYellow, 0.0, 1.0 );
}
// CMY results from 0 to 1
diff --git a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
index 6cd65d6..a4f0deb 100644
--- a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
+++ b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
@@ -298,7 +298,7 @@ void ZBufferRasterConverter3D::processLineSpan(const basegfx::RasterConversionLi
while(nXA < nXB)
{
// early-test Z values if we need to do anything at all
const double fNewZ(std::max(0.0, std::min(double(0xffff), maIntZ.getVal())));
const double fNewZ(std::clamp(maIntZ.getVal(), 0.0, 65535.0));
const sal_uInt16 nNewZ(static_cast< sal_uInt16 >(fNewZ));
sal_uInt16& rOldZ(mrBuffer.getZ(nScanlineIndex));
diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx
index 583be2e..45e381f 100644
--- a/drawinglayer/source/tools/wmfemfhelper.cxx
+++ b/drawinglayer/source/tools/wmfemfhelper.cxx
@@ -1652,8 +1652,8 @@ namespace wmfemfhelper
{
double fRadiusX((nHor * 2.0) / (aRange.getWidth() > 0.0 ? aRange.getWidth() : 1.0));
double fRadiusY((nVer * 2.0) / (aRange.getHeight() > 0.0 ? aRange.getHeight() : 1.0));
fRadiusX = std::max(0.0, std::min(1.0, fRadiusX));
fRadiusY = std::max(0.0, std::min(1.0, fRadiusY));
fRadiusX = std::clamp(fRadiusX, 0.0, 1.0);
fRadiusY = std::clamp(fRadiusY, 0.0, 1.0);
aOutline = basegfx::utils::createPolygonFromRect(aRange, fRadiusX, fRadiusY);
}
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index afafbd1..9126751 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -2714,8 +2714,8 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
{
if ( bHorizontalDockArea )
{
sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32( aContainerWinSize.Width() - aWindowRect.Left() ),
sal_Int32( aTrackingRect.getWidth() )));
sal_Int32 nSize = std::clamp( sal_Int32(aContainerWinSize.Width() - aWindowRect.Left()),
sal_Int32(0), sal_Int32(aTrackingRect.getWidth()) );
if ( nSize == 0 )
nSize = aWindowRect.getWidth();
@@ -2728,9 +2728,8 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
}
else
{
sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32(
nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Top() ),
sal_Int32( aTrackingRect.getHeight() )));
sal_Int32 nSize = std::clamp( sal_Int32(nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Top()),
sal_Int32(0), sal_Int32(aTrackingRect.getHeight()) );
if ( nSize == 0 )
nSize = aWindowRect.getHeight();
@@ -2751,8 +2750,8 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
{
if ( bHorizontalDockArea )
{
sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32(( aContainerWinSize.Width() ) - aWindowRect.Right() ),
sal_Int32( aTrackingRect.getWidth() )));
sal_Int32 nSize = ::std::clamp( sal_Int32(aContainerWinSize.Width() - aWindowRect.Right()),
sal_Int32(0), sal_Int32(aTrackingRect.getWidth()) );
if ( nSize == 0 )
{
aUIElementRect.SetPos( ::Point( aContainerWinSize.Width() - aTrackingRect.getWidth(), aWindowRect.Top() ));
@@ -2772,8 +2771,8 @@ void ToolbarLayoutManager::implts_calcDockingPosSize(
}
else
{
sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32( nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Bottom() ),
sal_Int32( aTrackingRect.getHeight() )));
sal_Int32 nSize = std::clamp( sal_Int32(nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Bottom()),
sal_Int32(0), sal_Int32(aTrackingRect.getHeight()) );
aUIElementRect.SetPos( ::Point( aWindowRect.Left(), aWindowRect.Bottom() ));
aUIElementRect.SetSize( ::Size( aWindowRect.getWidth(), nSize ));
diff --git a/framework/source/uielement/progressbarwrapper.cxx b/framework/source/uielement/progressbarwrapper.cxx
index 537129b..68e0220 100644
--- a/framework/source/uielement/progressbarwrapper.cxx
+++ b/framework/source/uielement/progressbarwrapper.cxx
@@ -203,7 +203,7 @@ void ProgressBarWrapper::setValue( ::sal_Int32 nValue )
if ( m_nRange > 0 )
{
fVal = ( double( nValue ) / double( m_nRange )) * 100;
fVal = std::max( double( 0 ), std::min( fVal, double( 100 )));
fVal = std::clamp( fVal, 0.0, 100.0 );
}
if ( m_nValue != sal_Int32( fVal ))
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 5ade9c1..f1ba9e3 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -78,7 +78,7 @@ OptValue< double > lclDecodeOpacity( const AttributeList& rAttribs, sal_Int32 nT
{
if(aString.endsWith("f"))
{
fRetval = std::max(0.0, std::min(1.0, aString.toDouble() / 65536.0));
fRetval = std::clamp(aString.toDouble() / 65536.0, 0.0, 1.0);
}
else
{
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index fe81f4c..af3e52f 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -288,7 +288,7 @@ void doubleToString(typename T::String ** pResult,
if (nDecPlaces == rtl_math_DecimalPlaces_Max)
nDecPlaces = 0;
else
nDecPlaces = ::std::max< sal_Int32 >(::std::min<sal_Int32>(nDecPlaces, 15), -15);
nDecPlaces = ::std::clamp< sal_Int32 >(nDecPlaces, -15, 15);
if (bEraseTrailingDecZeros && nDecPlaces > 0)
nDecPlaces = 0;
@@ -437,7 +437,7 @@ void doubleToString(typename T::String ** pResult,
// rtl_math_DecimalPlaces_Max was passed with rtl_math_StringFormat_F or
// others, but we don't want to allocate/deallocate 2GB just to fill it
// with trailing '0' characters..
nDecPlaces = std::max<sal_Int32>(std::min<sal_Int32>(nDecPlaces, 20), -20);
nDecPlaces = std::clamp<sal_Int32>(nDecPlaces, -20, 20);
sal_Int32 nDigits = nDecPlaces + 1;
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 747b3e4..d56cea7 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -106,8 +106,8 @@ bool ScDocument::LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_
// Limit the sheet range to bounds.
o_bEntirelyOutOfBounds = false;
nTab1 = std::max<SCTAB>( 0, std::min( nMaxTab, nTab1));
nTab2 = std::max<SCTAB>( 0, std::min( nMaxTab, nTab2));
nTab1 = std::clamp<SCTAB>( nTab1, 0, nMaxTab);
nTab2 = std::clamp<SCTAB>( nTab2, 0, nMaxTab);
o_rRange = rRange;
o_rRange.aStart.SetTab(nTab1);
o_rRange.aEnd.SetTab(nTab2);
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index a5fe92c..bafd2e9 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -237,8 +237,8 @@ void ScCaptionCreator::FitCaptionToRect( const tools::Rectangle* pVisRect )
// tail position
Point aTailPos = mxCaption->GetTailPos();
aTailPos.setX( ::std::max( ::std::min( aTailPos.X(), rVisRect.Right() ), rVisRect.Left() ) );
aTailPos.setY( ::std::max( ::std::min( aTailPos.Y(), rVisRect.Bottom() ), rVisRect.Top() ) );
aTailPos.setX( ::std::clamp( aTailPos.X(), rVisRect.Left(), rVisRect.Right() ) );
aTailPos.setY( ::std::clamp( aTailPos.Y(), rVisRect.Top(), rVisRect.Bottom() ) );
mxCaption->SetTailPos( aTailPos );
// caption rectangle
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 79638f5..d0451b4 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1164,7 +1164,7 @@ void ScTable::LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol
SCROW lastDataPos = 0;
for (SCCOL i=rStartCol; i<=rEndCol; i++)
lastDataPos = std::max(lastDataPos, aCol[i].GetLastDataPos());
rEndRow = std::max( rStartRow, std::min(rEndRow, lastDataPos));
rEndRow = std::clamp( rEndRow, rStartRow, lastDataPos );
}
SCCOL ScTable::FindNextVisibleCol( SCCOL nCol, bool bRight ) const
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 5490c49..315d180 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1640,7 +1640,7 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo )
template< typename Type >
static Type getLimitedValue( const Type& rValue, const Type& rMin, const Type& rMax )
{ return std::max( std::min( rValue, rMax ), rMin ); }
{ return std::clamp( rValue, rMin, rMax ); }
ScHTMLEntry::ScHTMLEntry( const SfxItemSet& rItemSet, ScHTMLTableId nTableId ) :
ScEEParseEntry( rItemSet ),
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index be87127..dc216a5 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_SC_SOURCE_FILTER_INC_FTOOLS_HXX
#define INCLUDED_SC_SOURCE_FILTER_INC_FTOOLS_HXX
#include <algorithm>
#include <vector>
#include <limits>
#include <tools/ref.hxx>
@@ -59,7 +60,7 @@ inline ReturnType ulimit_cast( Type nValue )
/** Returns the value, if it is not less than nMin and not greater than nMax, otherwise one of the limits. */
template< typename ReturnType, typename Type >
inline ReturnType limit_cast( Type nValue, ReturnType nMin, ReturnType nMax )
{ return static_cast< ReturnType >( ::std::max< Type >( ::std::min< Type >( nValue, nMax ), nMin ) ); }
{ return static_cast< ReturnType >( ::std::clamp< Type >( nValue, nMin, nMax ) ); }
/** Returns the value, if it fits into ReturnType, otherwise one of the limits of ReturnType. */
template< typename ReturnType, typename Type >
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index 056bf40..1fd2cea 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -929,7 +929,7 @@ bool ScCsvGrid::MouseMove( const MouseEvent& rMEvt )
sal_Int32 nPos = (rMEvt.GetPosPixel().X() - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
// on mouse tracking: keep position valid
nPos = std::max( std::min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 0 ) );
nPos = std::clamp( nPos, sal_Int32(0), GetPosCount() - 1 );
Execute( CSVCMD_MAKEPOSVISIBLE, nPos );
sal_uInt32 nColIx = GetColumnFromPos( nPos );
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
index 94e733e..95e0422 100644
--- a/sc/source/ui/dbgui/csvruler.cxx
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -432,7 +432,7 @@ bool ScCsvRuler::MouseMove( const MouseEvent& rMEvt )
if( mbTracking )
{
// on mouse tracking: keep position valid
nPos = std::max( std::min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 1 ) );
nPos = std::clamp( nPos, sal_Int32(1), GetPosCount() - 1 );
MoveMouseTracking( nPos );
}
else
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 8b09e45..4db4358 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1825,7 +1825,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
if (bFail || nCol < 0 || rDoc.MaxCol() < nCol)
{
SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol);
nCol = std::max<SCCOL>(0, std::min<SCCOL>(nCol, rDoc.MaxCol()));
nCol = std::clamp<SCCOL>(nCol, 0, rDoc.MaxCol());
bInvalidCol = bOverflowCol = true;
}
break;
@@ -1837,7 +1837,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
if (bFail || nRow < 0 || nMaxImportRow < nRow)
{
SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
nRow = std::max<SCROW>(0, std::min<SCROW>(nRow, nMaxImportRow));
nRow = std::clamp<SCROW>(nRow, 0, nMaxImportRow);
bInvalidRow = bOverflowRow = true;
}
break;
@@ -1849,7 +1849,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
if (bFail || nRefCol < 0 || rDoc.MaxCol() < nRefCol)
{
SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;C invalid nRefCol=" << nRefCol);
nRefCol = std::max<SCCOL>(0, std::min<SCCOL>(nRefCol, rDoc.MaxCol()));
nRefCol = std::clamp<SCCOL>(nRefCol, 0, rDoc.MaxCol());
bInvalidRefCol = bOverflowCol = true;
}
break;
@@ -1861,7 +1861,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
if (bFail || nRefRow < 0 || nMaxImportRow < nRefRow)
{
SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;R invalid nRefRow=" << nRefRow);
nRefRow = std::max<SCROW>(0, std::min<SCROW>(nRefRow, nMaxImportRow));
nRefRow = std::clamp<SCROW>(nRefRow, 0, nMaxImportRow);
bInvalidRefRow = bOverflowRow = true;
}
break;
@@ -1986,7 +1986,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
if (bFail || nCol < 0 || rDoc.MaxCol() < nCol)
{
SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol);
nCol = std::max<SCCOL>(0, std::min<SCCOL>(nCol, rDoc.MaxCol()));
nCol = std::clamp<SCCOL>(nCol, 0, rDoc.MaxCol());
bInvalidCol = bOverflowCol = true;
}
break;
@@ -1998,7 +1998,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
if (bFail || nRow < 0 || nMaxImportRow < nRow)
{
SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
nRow = std::max<SCROW>(0, std::min<SCROW>(nRow, nMaxImportRow));
nRow = std::clamp<SCROW>(nRow, 0, nMaxImportRow);
bInvalidRow = bOverflowRow = true;
}
break;
diff --git a/sc/source/ui/inc/csvtablebox.hxx b/sc/source/ui/inc/csvtablebox.hxx
index 67506f1..28c0f36 100644
--- a/sc/source/ui/inc/csvtablebox.hxx
+++ b/sc/source/ui/inc/csvtablebox.hxx
@@ -92,10 +92,10 @@ private:
/** Calculates and sets valid position offset nearest to nPos. */
SAL_DLLPRIVATE void ImplSetPosOffset( sal_Int32 nPos )
{ maData.mnPosOffset = std::max( std::min( nPos, mxGrid->GetMaxPosOffset() ), sal_Int32( 0 ) ); }
{ maData.mnPosOffset = std::clamp( nPos, sal_Int32(0), mxGrid->GetMaxPosOffset() ); }
/** Calculates and sets valid line offset nearest to nLine. */
SAL_DLLPRIVATE void ImplSetLineOffset( sal_Int32 nLine )
{ maData.mnLineOffset = std::max( std::min( nLine, mxGrid->GetMaxLineOffset() ), sal_Int32( 0 ) ); }
{ maData.mnLineOffset = std::clamp( nLine, sal_Int32(0), mxGrid->GetMaxLineOffset() ); }
/** Moves controls (not cursors!) so that nPos becomes visible. */
SAL_DLLPRIVATE void MakePosVisible( sal_Int32 nPos );
diff --git a/sccomp/source/solver/SwarmSolver.cxx b/sccomp/source/solver/SwarmSolver.cxx
index d59df28..a55f410 100644
--- a/sccomp/source/solver/SwarmSolver.cxx
+++ b/sccomp/source/solver/SwarmSolver.cxx
@@ -373,7 +373,7 @@ void SwarmSolver::initializeVariables(std::vector<double>& rVariables, std::mt19
double SwarmSolver::clampVariable(size_t nVarIndex, double fValue)
{
Bound const& rBound = maBounds[nVarIndex];
double fResult = std::max(std::min(fValue, rBound.upper), rBound.lower);
double fResult = std::clamp(fValue, rBound.lower, rBound.upper);
if (mbInteger)
return std::trunc(fResult);
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 638a41b..9bf6a30 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -976,7 +976,7 @@ Size SmViewShell::GetTextSize(OutputDevice const & rDevice, const OUString& rTex
aLine = aLine.replaceAt(0, m, "");
aSize = GetTextLineSize(rDevice, aText);
aTextSize.AdjustHeight(aSize.Height() );
aTextSize.setWidth( std::max(aTextSize.Width(), std::min(aSize.Width(), MaxWidth)) );
aTextSize.setWidth( std::clamp(aSize.Width(), aTextSize.Width(), MaxWidth) );
aLine = comphelper::string::stripStart(aLine, ' ');
aLine = comphelper::string::stripStart(aLine, '\t');
@@ -1193,7 +1193,7 @@ void SmViewShell::Impl_Print(OutputDevice &rOutDev, const SmPrintUIOptions &rPri
sal_uInt16 nZ = sal::static_int_cast<sal_uInt16>(std::min(tools::Long(Fraction(OutputSize.Width() * 100, GraphicSize.Width())),
tools::Long(Fraction(OutputSize.Height() * 100, GraphicSize.Height()))));
nZ -= 10;
Fraction aFraction (std::max(MINZOOM, std::min(MAXZOOM, nZ)), 100);
Fraction aFraction (std::clamp(nZ, MINZOOM, sal_uInt16(100)));
OutputMapMode = MapMode(MapUnit::Map100thMM, Point(), aFraction, aFraction);
}
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index ccfe7b8..b83b206 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -72,9 +72,9 @@ static void lcl_CMYKtoRGB( float fCyan, float fMagenta, float fYellow, float fKe
fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
dR = std::max( std::min( ( 1.0 - fCyan ), 1.0), 0.0 );
dG = std::max( std::min( ( 1.0 - fMagenta ), 1.0), 0.0 );
dB = std::max( std::min( ( 1.0 - fYellow ), 1.0), 0.0 );
dR = std::clamp( 1.0 - fCyan, 0.0, 1.0 );
dG = std::clamp( 1.0 - fMagenta, 0.0, 1.0 );
dB = std::clamp( 1.0 - fYellow, 0.0, 1.0 );
}
void PaletteASE::LoadPalette()
diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx
index e2fa7b9..39013c2 100644
--- a/svx/source/unogallery/unogaltheme.cxx
+++ b/svx/source/unogallery/unogaltheme.cxx
@@ -176,7 +176,7 @@ void SAL_CALL GalleryTheme::update( )
{
const INetURLObject aURL( rURL );
nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
nIndex = std::clamp( nIndex, sal_Int32(0), getCount() );
if( ( aURL.GetProtocol() != INetProtocol::NotValid ) && mpTheme->InsertURL( aURL, nIndex ) )
{
@@ -207,7 +207,7 @@ void SAL_CALL GalleryTheme::update( )
{
const Graphic aGraphic( rxGraphic );
nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
nIndex = std::clamp( nIndex, sal_Int32(0), getCount() );
if( mpTheme->InsertGraphic( aGraphic, nIndex ) )
nRet = nIndex;
@@ -234,7 +234,7 @@ void SAL_CALL GalleryTheme::update( )
if( pModel && dynamic_cast<const FmFormModel*>(pModel->GetDoc()) )
{
// Here we're inserting something that's already a gallery theme drawing
nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
nIndex = std::clamp( nIndex, sal_Int32(0), getCount() );
if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ), nIndex ) )
nRet = nIndex;
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index fdfff47..688c28f 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -131,14 +131,14 @@ tools::Long SwView::SetHScrollMax( tools::Long lMax )
// At negative values the document is completely visible.
// In this case, no scrolling.
return std::max( std::min( lMax, lSize ), tools::Long(0) );
return std::clamp( lSize, tools::Long(0), lMax );
}
tools::Long SwView::SetVScrollMax( tools::Long lMax )
{
const tools::Long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
tools::Long lSize = GetDocSz().Height() + lBorder - m_aVisArea.GetHeight();
return std::max( std::min( lMax, lSize), tools::Long(0) ); // see horizontal
return std::clamp( lSize, tools::Long(0), lMax ); // see horizontal
}
Point SwView::AlignToPixel(const Point &rPt) const
diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index 356f199..0049c33 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -306,7 +306,7 @@ void tools::Time::GetClock( double fTimeInDays,
if (fAbsTimeInDays >= 1.0)
{
const int nDig = static_cast<int>(ceil( log10( fAbsTimeInDays)));
nDec = std::max( std::min( 10 - nDig, 9), 2);
nDec = std::clamp( 10 - nDig, 2, 9 );
}
double fSeconds = rtl::math::round( fRawSeconds, nDec);
diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx
index f16b368..e0b96a6b 100644
--- a/vcl/source/gdi/gdimetafiletools.cxx
+++ b/vcl/source/gdi/gdimetafiletools.cxx
@@ -542,8 +542,8 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource)
{
double fRadiusX((nHor * 2.0) / (aRange.getWidth() > 0.0 ? aRange.getWidth() : 1.0));
double fRadiusY((nVer * 2.0) / (aRange.getHeight() > 0.0 ? aRange.getHeight() : 1.0));
fRadiusX = std::max(0.0, std::min(1.0, fRadiusX));
fRadiusY = std::max(0.0, std::min(1.0, fRadiusY));
fRadiusX = std::clamp(fRadiusX, 0.0, 1.0);
fRadiusY = std::clamp(fRadiusY, 0.0, 1.0);
aOutline = basegfx::utils::createPolygonFromRect(aRange, fRadiusX, fRadiusY);
}