[Libreoffice-commits] core.git: basegfx/source cui/source drawinglayer/source editeng/source filter/source include/basegfx include/o3tl sd/source slideshow/source svgio/source svx/source tools/source vcl/source writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 11 19:25:34 UTC 2019


 basegfx/source/color/bcolormodifier.cxx                      |   21 +++--
 basegfx/source/polygon/b2dpolypolygontools.cxx               |    5 -
 basegfx/source/tools/keystoplerp.cxx                         |    3 
 cui/source/tabpages/transfrm.cxx                             |   11 +--
 drawinglayer/source/attribute/fillgraphicattribute.cxx       |    9 +-
 drawinglayer/source/attribute/sdrfillgraphicattribute.cxx    |    9 +-
 drawinglayer/source/primitive2d/graphicprimitive2d.cxx       |   19 +++--
 drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx |    9 +-
 drawinglayer/source/texture/texture.cxx                      |    9 +-
 drawinglayer/source/texture/texture3d.cxx                    |    9 +-
 editeng/source/items/numitem.cxx                             |    8 +-
 filter/source/msfilter/escherex.cxx                          |    7 +
 filter/source/msfilter/svdfppt.cxx                           |    9 +-
 include/basegfx/color/bcolor.hxx                             |    9 +-
 include/o3tl/clamp.hxx                                       |   39 -----------
 sd/source/ui/slideshow/slideshowimpl.cxx                     |    7 +
 slideshow/source/engine/activities/activitybase.cxx          |    5 -
 slideshow/source/engine/animationnodes/animationbasenode.cxx |    3 
 slideshow/source/engine/shapes/viewshape.cxx                 |    4 -
 svgio/source/svgreader/svgstyleattributes.cxx                |   17 ++--
 svx/source/customshapes/EnhancedCustomShape2d.cxx            |   21 +++--
 svx/source/sidebar/possize/PosSizePropertyPanel.cxx          |   11 +--
 svx/source/unodraw/unobrushitemhelper.cxx                    |    5 -
 tools/source/generic/color.cxx                               |   20 ++---
 vcl/source/bitmap/BitmapEmbossGreyFilter.cxx                 |    7 +
 vcl/source/bitmap/BitmapSepiaFilter.cxx                      |    5 -
 vcl/source/bitmap/BitmapSobelGreyFilter.cxx                  |    5 -
 writerfilter/source/rtftok/rtfdocumentimpl.cxx               |   10 +-
 28 files changed, 145 insertions(+), 151 deletions(-)

New commits:
commit 27cd397b1a1a8a39843c093eff68c5ea6cb249e7
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jan 11 15:26:59 2019 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Jan 11 20:25:08 2019 +0100

    Drop o3tl/clamp.hxx, use C++17 std::clamp instead
    
    Change-Id: I5043c787dcc3b78bc7fdff130564801194e39f46
    Reviewed-on: https://gerrit.libreoffice.org/66177
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx
index f656552f69b2..182083f6fbdb 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -17,8 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <basegfx/color/bcolormodifier.hxx>
-#include <o3tl/clamp.hxx>
 
 namespace basegfx
 {
@@ -217,11 +220,11 @@ namespace basegfx
 {
     BColorModifier_RGBLuminanceContrast::BColorModifier_RGBLuminanceContrast(double fRed, double fGreen, double fBlue, double fLuminance, double fContrast)
     :   BColorModifier(),
-        mfRed(o3tl::clamp(fRed, -1.0, 1.0)),
-        mfGreen(o3tl::clamp(fGreen, -1.0, 1.0)),
-        mfBlue(o3tl::clamp(fBlue, -1.0, 1.0)),
-        mfLuminance(o3tl::clamp(fLuminance, -1.0, 1.0)),
-        mfContrast(o3tl::clamp(fContrast, -1.0, 1.0)),
+        mfRed(std::clamp(fRed, -1.0, 1.0)),
+        mfGreen(std::clamp(fGreen, -1.0, 1.0)),
+        mfBlue(std::clamp(fBlue, -1.0, 1.0)),
+        mfLuminance(std::clamp(fLuminance, -1.0, 1.0)),
+        mfContrast(std::clamp(fContrast, -1.0, 1.0)),
         mfContrastOff(1.0),
         mfRedOff(0.0),
         mfGreenOff(0.0),
@@ -283,9 +286,9 @@ namespace basegfx
         if(mbUseIt)
         {
             return basegfx::BColor(
-                o3tl::clamp(aSourceColor.getRed() * mfContrastOff + mfRedOff, 0.0, 1.0),
-                o3tl::clamp(aSourceColor.getGreen() * mfContrastOff + mfGreenOff, 0.0, 1.0),
-                o3tl::clamp(aSourceColor.getBlue() * mfContrastOff + mfBlueOff, 0.0, 1.0));
+                std::clamp(aSourceColor.getRed() * mfContrastOff + mfRedOff, 0.0, 1.0),
+                std::clamp(aSourceColor.getGreen() * mfContrastOff + mfGreenOff, 0.0, 1.0),
+                std::clamp(aSourceColor.getBlue() * mfContrastOff + mfBlueOff, 0.0, 1.0));
         }
         else
         {
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx
index 305934579ec5..d156506c147c 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <o3tl/clamp.hxx>
 #include <osl/diagnose.h>
 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
 #include <basegfx/polygon/b2dpolypolygon.hxx>
@@ -26,6 +25,8 @@
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/numeric/ftools.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+
+#include <algorithm>
 #include <numeric>
 
 namespace basegfx
@@ -511,7 +512,7 @@ namespace basegfx
             }
             else
             {
-                nNumber=o3tl::clamp<sal_uInt32>(nNumber,'0','9') - '0';
+                nNumber=std::clamp<sal_uInt32>(nNumber,'0','9') - '0';
             }
 
             B2DPolygon aCurrSegment;
diff --git a/basegfx/source/tools/keystoplerp.cxx b/basegfx/source/tools/keystoplerp.cxx
index 8e9941519e44..0d7ac7537be6 100644
--- a/basegfx/source/tools/keystoplerp.cxx
+++ b/basegfx/source/tools/keystoplerp.cxx
@@ -19,7 +19,6 @@
 
 #include <basegfx/utils/keystoplerp.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
-#include <o3tl/clamp.hxx>
 #include <osl/diagnose.h>
 
 #include <algorithm>
@@ -87,7 +86,7 @@ namespace basegfx
             // everything)
             return ResultType(
                 mnLastIndex,
-                o3tl::clamp(fRawLerp,0.0,1.0));
+                std::clamp(fRawLerp,0.0,1.0));
         }
     }
 }
diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx
index 1918f676a15d..3c086e288ce4 100644
--- a/cui/source/tabpages/transfrm.cxx
+++ b/cui/source/tabpages/transfrm.cxx
@@ -19,7 +19,8 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
+#include <algorithm>
+
 #include <sfx2/app.hxx>
 #include <svx/EnhancedCustomShape2d.hxx>
 #include <svx/svdundo.hxx>
@@ -1347,10 +1348,10 @@ void SvxPositionSizeTabPage::SetMinMaxPosition()
     }
 
     const double fMaxLong(static_cast<double>(MetricField::ConvertValue( LONG_MAX, 0, MapUnit::Map100thMM, meDlgUnit ) - 1));
-    fLeft = o3tl::clamp(fLeft, -fMaxLong, fMaxLong);
-    fRight = o3tl::clamp(fRight, -fMaxLong, fMaxLong);
-    fTop = o3tl::clamp(fTop, - fMaxLong, fMaxLong);
-    fBottom = o3tl::clamp(fBottom, -fMaxLong, fMaxLong);
+    fLeft = std::clamp(fLeft, -fMaxLong, fMaxLong);
+    fRight = std::clamp(fRight, -fMaxLong, fMaxLong);
+    fTop = std::clamp(fTop, - fMaxLong, fMaxLong);
+    fBottom = std::clamp(fBottom, -fMaxLong, fMaxLong);
 
     // #i75273# normalizing when setting the min/max values was wrong, removed
     m_xMtrPosX->set_range(basegfx::fround64(fLeft), basegfx::fround64(fRight), FieldUnit::NONE);
diff --git a/drawinglayer/source/attribute/fillgraphicattribute.cxx b/drawinglayer/source/attribute/fillgraphicattribute.cxx
index 406486ce794b..72da948fc96c 100644
--- a/drawinglayer/source/attribute/fillgraphicattribute.cxx
+++ b/drawinglayer/source/attribute/fillgraphicattribute.cxx
@@ -17,8 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <drawinglayer/attribute/fillgraphicattribute.hxx>
-#include <o3tl/clamp.hxx>
 #include <vcl/graph.hxx>
 
 namespace drawinglayer
@@ -99,8 +102,8 @@ namespace drawinglayer
             double fOffsetY)
         :   mpFillGraphicAttribute(ImpFillGraphicAttribute(
                 rGraphic, rGraphicRange, bTiling,
-                    o3tl::clamp(fOffsetX, 0.0, 1.0),
-                    o3tl::clamp(fOffsetY, 0.0, 1.0)))
+                    std::clamp(fOffsetX, 0.0, 1.0),
+                    std::clamp(fOffsetY, 0.0, 1.0)))
         {
         }
 
diff --git a/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx b/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx
index 84fbaea1d998..b88b2a9a31a5 100644
--- a/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx
+++ b/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx
@@ -17,9 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
 #include <drawinglayer/attribute/fillgraphicattribute.hxx>
-#include <o3tl/clamp.hxx>
 #include <rtl/instance.hxx>
 #include <vcl/graph.hxx>
 
@@ -290,8 +293,8 @@ namespace drawinglayer
             }
 
             // get offset in percent
-            const double fOffsetX(o3tl::clamp(getOffset().getX() * 0.01, 0.0, 1.0));
-            const double fOffsetY(o3tl::clamp(getOffset().getY() * 0.01, 0.0, 1.0));
+            const double fOffsetX(std::clamp(getOffset().getX() * 0.01, 0.0, 1.0));
+            const double fOffsetY(std::clamp(getOffset().getY() * 0.01, 0.0, 1.0));
 
             // create FillGraphicAttribute
             return FillGraphicAttribute(
diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
index 50aa48efe333..f684227ba1c8 100644
--- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
 #include <drawinglayer/primitive2d/cropprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
@@ -25,7 +29,6 @@
 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
-#include <o3tl/clamp.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/outdev.hxx>
 
@@ -123,12 +126,12 @@ namespace drawinglayer
                 aRetval = create2DColorModifierEmbeddingsAsNeeded(
                     aRetval,
                     aSuppressGraphicAttr.GetDrawMode(),
-                    o3tl::clamp(aSuppressGraphicAttr.GetLuminance() * 0.01, -1.0, 1.0),
-                    o3tl::clamp(aSuppressGraphicAttr.GetContrast() * 0.01, -1.0, 1.0),
-                    o3tl::clamp(aSuppressGraphicAttr.GetChannelR() * 0.01, -1.0, 1.0),
-                    o3tl::clamp(aSuppressGraphicAttr.GetChannelG() * 0.01, -1.0, 1.0),
-                    o3tl::clamp(aSuppressGraphicAttr.GetChannelB() * 0.01, -1.0, 1.0),
-                    o3tl::clamp(aSuppressGraphicAttr.GetGamma(), 0.0, 10.0),
+                    std::clamp(aSuppressGraphicAttr.GetLuminance() * 0.01, -1.0, 1.0),
+                    std::clamp(aSuppressGraphicAttr.GetContrast() * 0.01, -1.0, 1.0),
+                    std::clamp(aSuppressGraphicAttr.GetChannelR() * 0.01, -1.0, 1.0),
+                    std::clamp(aSuppressGraphicAttr.GetChannelG() * 0.01, -1.0, 1.0),
+                    std::clamp(aSuppressGraphicAttr.GetChannelB() * 0.01, -1.0, 1.0),
+                    std::clamp(aSuppressGraphicAttr.GetGamma(), 0.0, 10.0),
                     aSuppressGraphicAttr.IsInvert());
 
                 if(aRetval.empty())
@@ -141,7 +144,7 @@ namespace drawinglayer
             if(getGraphicAttr().IsTransparent())
             {
                 // check for transparency
-                const double fTransparency(o3tl::clamp(getGraphicAttr().GetTransparency() * (1.0 / 255.0), 0.0, 1.0));
+                const double fTransparency(std::clamp(getGraphicAttr().GetTransparency() * (1.0 / 255.0), 0.0, 1.0));
 
                 if(!basegfx::fTools::equalZero(fTransparency))
                 {
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
index 48f22b6a3b6c..bdedee85417b 100644
--- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <drawinglayer/primitive2d/graphicprimitivehelper2d.hxx>
 #include <drawinglayer/animation/animationtiming.hxx>
 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
@@ -29,7 +33,6 @@
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/numeric/ftools.hxx>
-#include <o3tl/clamp.hxx>
 
 // helper class for animated graphics
 
@@ -591,8 +594,8 @@ namespace drawinglayer
                 // original in svtools uses:
                 // #define WATERMARK_LUM_OFFSET        50
                 // #define WATERMARK_CON_OFFSET        -70
-                fLuminance = o3tl::clamp(fLuminance + 0.5, -1.0, 1.0);
-                fContrast = o3tl::clamp(fContrast - 0.7, -1.0, 1.0);
+                fLuminance = std::clamp(fLuminance + 0.5, -1.0, 1.0);
+                fContrast = std::clamp(fContrast - 0.7, -1.0, 1.0);
                 aGraphicDrawMode = GraphicDrawMode::Standard;
             }
 
diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx
index d8cd40e4e919..c2d1a5468e78 100644
--- a/drawinglayer/source/texture/texture.cxx
+++ b/drawinglayer/source/texture/texture.cxx
@@ -17,11 +17,14 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <drawinglayer/texture/texture.hxx>
 #include <basegfx/numeric/ftools.hxx>
 #include <basegfx/utils/gradienttools.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
-#include <o3tl/clamp.hxx>
 
 #include <converters.hxx>
 
@@ -698,8 +701,8 @@ namespace drawinglayer
             double fOffsetX,
             double fOffsetY)
         :   maRange(rRange),
-            mfOffsetX(o3tl::clamp(fOffsetX, 0.0, 1.0)),
-            mfOffsetY(o3tl::clamp(fOffsetY, 0.0, 1.0))
+            mfOffsetX(std::clamp(fOffsetX, 0.0, 1.0)),
+            mfOffsetY(std::clamp(fOffsetY, 0.0, 1.0))
         {
             if(!basegfx::fTools::equalZero(mfOffsetX))
             {
diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx
index 68d2826bfa46..74c0766ad51c 100644
--- a/drawinglayer/source/texture/texture3d.cxx
+++ b/drawinglayer/source/texture/texture3d.cxx
@@ -17,8 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <drawinglayer/texture/texture3d.hxx>
-#include <o3tl/clamp.hxx>
 #include <vcl/bitmapaccess.hxx>
 #include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx>
 #include <sal/log.hxx>
@@ -289,8 +292,8 @@ namespace drawinglayer
             double fOffsetX,
             double fOffsetY)
         :   GeoTexSvxBitmapEx(rBitmapEx, rRange),
-            mfOffsetX(o3tl::clamp(fOffsetX, 0.0, 1.0)),
-            mfOffsetY(o3tl::clamp(fOffsetY, 0.0, 1.0)),
+            mfOffsetX(std::clamp(fOffsetX, 0.0, 1.0)),
+            mfOffsetY(std::clamp(fOffsetY, 0.0, 1.0)),
             mbUseOffsetX(!basegfx::fTools::equalZero(mfOffsetX)),
             mbUseOffsetY(!mbUseOffsetX && !basegfx::fTools::equalZero(mfOffsetY))
         {
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index 6510a6d0dafa..c636ceae7473 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
 
 #include <editeng/numitem.hxx>
 
@@ -24,7 +27,6 @@
 #include <com/sun/star/text/VertOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <editeng/brushitem.hxx>
-#include <o3tl/clamp.hxx>
 #include <vcl/font.hxx>
 #include <vcl/settings.hxx>
 #include <editeng/editids.hrc>
@@ -263,10 +265,10 @@ void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverte
     rStream.WriteUInt16( cBullet );
 
     rStream.WriteInt16(
-        sal_Int16(o3tl::clamp<sal_Int32>(nFirstLineOffset, SAL_MIN_INT16, SAL_MAX_INT16)) );
+        sal_Int16(std::clamp<sal_Int32>(nFirstLineOffset, SAL_MIN_INT16, SAL_MAX_INT16)) );
         //TODO: better way to handle out-of-bounds value?
     rStream.WriteInt16(
-        sal_Int16(o3tl::clamp<sal_Int32>(nAbsLSpace, SAL_MIN_INT16, SAL_MAX_INT16)) );
+        sal_Int16(std::clamp<sal_Int32>(nAbsLSpace, SAL_MIN_INT16, SAL_MAX_INT16)) );
         //TODO: better way to handle out-of-bounds value?
     rStream.WriteInt16( 0 ); // write a dummy for old now unused nLSpace
 
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 9cf10f14acbf..52f83f00f8ab 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -19,7 +19,6 @@
 
 #include "eschesdo.hxx"
 #include <o3tl/any.hxx>
-#include <o3tl/clamp.hxx>
 #include <o3tl/make_unique.hxx>
 #include <svx/svdxcgv.hxx>
 #include <svx/svdomedia.hxx>
@@ -98,6 +97,8 @@
 #include <sal/log.hxx>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
+
+#include <algorithm>
 #include <memory>
 
 using namespace css;
@@ -2929,12 +2930,12 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT
                             {
                                 aMemStrm.WriteUInt16( equation.nOperation )
                                     .WriteInt16(
-                                        o3tl::clamp(
+                                        std::clamp(
                                             equation.nPara[ 0 ], sal_Int32(SAL_MIN_INT16),
                                             sal_Int32(SAL_MAX_INT16)) )
                                     .WriteInt16( equation.nPara[ 1 ] )
                                     .WriteInt16(
-                                        o3tl::clamp(
+                                        std::clamp(
                                             equation.nPara[ 2 ], sal_Int32(SAL_MIN_INT16),
                                             sal_Int32(SAL_MAX_INT16)) );
                             }
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 18aacd8e6803..03f9dc9d1cf7 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -19,7 +19,6 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
 #include <osl/endian.h>
 #include <vcl/svapp.hxx>
 #include <unotools/tempfile.hxx>
@@ -287,11 +286,11 @@ SvStream& ReadPptDocumentAtom(SvStream& rIn, PptDocumentAtom& rAtom)
        .ReadSChar( nShowComments );
     // clamp dodgy data to avoid overflow in later calculations
     const sal_Int32 nPageClamp = SAL_MAX_INT32/5;
-    rAtom.aSlidesPageSize.setWidth( o3tl::clamp<sal_Int32>(nSlideX, -nPageClamp, nPageClamp) );
-    rAtom.aSlidesPageSize.setHeight( o3tl::clamp<sal_Int32>(nSlideY, -nPageClamp, nPageClamp) );
+    rAtom.aSlidesPageSize.setWidth( std::clamp<sal_Int32>(nSlideX, -nPageClamp, nPageClamp) );
+    rAtom.aSlidesPageSize.setHeight( std::clamp<sal_Int32>(nSlideY, -nPageClamp, nPageClamp) );
     const sal_Int32 nNoteClamp = 65536;
-    rAtom.aNotesPageSize.setWidth( o3tl::clamp<sal_Int32>(nNoticeX, -nNoteClamp, nNoteClamp) );
-    rAtom.aNotesPageSize.setHeight( o3tl::clamp<sal_Int32>(nNoticeY, -nNoteClamp, nNoteClamp) );
+    rAtom.aNotesPageSize.setWidth( std::clamp<sal_Int32>(nNoticeX, -nNoteClamp, nNoteClamp) );
+    rAtom.aNotesPageSize.setHeight( std::clamp<sal_Int32>(nNoticeY, -nNoteClamp, nNoteClamp) );
     rAtom.eSlidesPageFormat = static_cast<PptPageFormat>(nSlidePageFormat);
     rAtom.bEmbeddedTrueType = nEmbeddedTrueType;
     rAtom.bTitlePlaceholdersOmitted = nTitlePlaceHoldersOmitted;
diff --git a/include/basegfx/color/bcolor.hxx b/include/basegfx/color/bcolor.hxx
index 6a6c6886acb6..ef4857bba598 100644
--- a/include/basegfx/color/bcolor.hxx
+++ b/include/basegfx/color/bcolor.hxx
@@ -22,12 +22,11 @@
 
 #include <sal/config.h>
 
+#include <algorithm>
 #include <ostream>
 
 #include <basegfx/tuple/b3dtuple.hxx>
 #include <basegfx/basegfxdllapi.h>
-#include <o3tl/clamp.hxx>
-
 
 namespace basegfx
 {
@@ -155,9 +154,9 @@ namespace basegfx
         // clamp color to [0.0..1.0] values in all three intensity components
         BColor& clamp()
         {
-            mfX = o3tl::clamp(mfX, 0.0, 1.0);
-            mfY = o3tl::clamp(mfY, 0.0, 1.0);
-            mfZ = o3tl::clamp(mfZ, 0.0, 1.0);
+            mfX = std::clamp(mfX, 0.0, 1.0);
+            mfY = std::clamp(mfY, 0.0, 1.0);
+            mfZ = std::clamp(mfZ, 0.0, 1.0);
             return *this;
         }
 
diff --git a/include/o3tl/clamp.hxx b/include/o3tl/clamp.hxx
deleted file mode 100644
index 06fa22e48cec..000000000000
--- a/include/o3tl/clamp.hxx
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_O3TL_CLAMP_HXX
-#define INCLUDED_O3TL_CLAMP_HXX
-
-#include <sal/config.h>
-
-#include <algorithm>
-#include <cassert>
-
-// C++17 std::clamp
-
-namespace o3tl
-{
-#if defined __cpp_lib_clamp
-
-using std::clamp;
-
-#else
-
-template <typename T> constexpr const T& clamp(const T& v, const T& lo, const T& hi)
-{
-    assert(!(hi < lo));
-    return v < lo ? lo : (hi < v ? hi : v);
-}
-
-#endif
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index 128909f2c6c4..5504729659b5 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <config_features.h>
 
 #include <com/sun/star/frame/theAutoRecovery.hpp>
@@ -33,7 +37,6 @@
 #include <com/sun/star/frame/XDispatch.hpp>
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <com/sun/star/presentation/SlideShow.hpp>
-#include <o3tl/clamp.hxx>
 #include <svl/aeitem.hxx>
 #include <svl/urihelper.hxx>
 
@@ -1679,7 +1682,7 @@ void SlideshowImpl::updateSlideShow()
                 const static sal_Int32 nMaximumFrameCount (60);
                 const static double nMinimumTimeout (1.0 / nMaximumFrameCount);
                 const static double nMaximumTimeout (4.0);
-                fUpdate = o3tl::clamp(fUpdate, nMinimumTimeout, nMaximumTimeout);
+                fUpdate = std::clamp(fUpdate, nMinimumTimeout, nMaximumTimeout);
 
                 // Make sure that the maximum frame count has not been set
                 // too high (only then conversion to milliseconds and long
diff --git a/slideshow/source/engine/activities/activitybase.cxx b/slideshow/source/engine/activities/activitybase.cxx
index 4ee7c84bcc72..1050bc033322 100644
--- a/slideshow/source/engine/activities/activitybase.cxx
+++ b/slideshow/source/engine/activities/activitybase.cxx
@@ -19,7 +19,8 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
+#include <algorithm>
+
 #include <tools/diagnose_ex.h>
 #include <canvas/canvastools.hxx>
 
@@ -148,7 +149,7 @@ namespace slideshow
             // ================================
 
             // clamp nT to permissible [0,1] range
-            nT = o3tl::clamp( nT, 0.0, 1.0 );
+            nT = std::clamp( nT, 0.0, 1.0 );
 
             // take acceleration/deceleration into account. if the sum
             // of mnAccelerationFraction and mnDecelerationFraction
diff --git a/slideshow/source/engine/animationnodes/animationbasenode.cxx b/slideshow/source/engine/animationnodes/animationbasenode.cxx
index 0b7dae6bc70b..a1b92517e549 100644
--- a/slideshow/source/engine/animationnodes/animationbasenode.cxx
+++ b/slideshow/source/engine/animationnodes/animationbasenode.cxx
@@ -20,7 +20,6 @@
 
 #include <cppuhelper/exc_hlp.hxx>
 #include <comphelper/anytostring.hxx>
-#include <o3tl/clamp.hxx>
 #include <sal/log.hxx>
 #include <com/sun/star/presentation/ParagraphTarget.hpp>
 #include <com/sun/star/animations/Timing.hpp>
@@ -448,7 +447,7 @@ AnimationBaseNode::fillCommonParameters() const
 
     // Calculate the minimum frame count that depends on the duration and
     // the minimum frame count.
-    const sal_Int32 nMinFrameCount (o3tl::clamp<sal_Int32>(
+    const sal_Int32 nMinFrameCount (std::clamp<sal_Int32>(
         basegfx::fround(nDuration * FrameRate::MinimumFramesPerSecond), 1, 10));
 
     return ActivitiesFactory::CommonParameters(
diff --git a/slideshow/source/engine/shapes/viewshape.cxx b/slideshow/source/engine/shapes/viewshape.cxx
index 2ab95b9267c0..b89804000ebd 100644
--- a/slideshow/source/engine/shapes/viewshape.cxx
+++ b/slideshow/source/engine/shapes/viewshape.cxx
@@ -19,9 +19,9 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
 #include <tools/diagnose_ex.h>
 
+#include <algorithm>
 #include <math.h>
 
 #include <rtl/math.hxx>
@@ -436,7 +436,7 @@ namespace slideshow
             if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Alpha) )
             {
                 mpSprite->setAlpha( (pAttr && pAttr->isAlphaValid()) ?
-                                    o3tl::clamp(pAttr->getAlpha(),
+                                    std::clamp(pAttr->getAlpha(),
                                                      0.0,
                                                      1.0) :
                                     1.0 );
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index fd17e3ee3241..b0c45fb90372 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -19,7 +19,8 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
+#include <algorithm>
+
 #include <svgstyleattributes.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
@@ -1330,7 +1331,7 @@ namespace svgio
                         setFill(aSvgPaint);
                         if(aOpacity.isSet())
                         {
-                            setOpacity(SvgNumber(o3tl::clamp(aOpacity.getNumber(), 0.0, 1.0)));
+                            setOpacity(SvgNumber(std::clamp(aOpacity.getNumber(), 0.0, 1.0)));
                         }
                     }
                     else if(!aURL.isEmpty())
@@ -1357,7 +1358,7 @@ namespace svgio
 
                     if(readSingleNumber(aContent, aNum))
                     {
-                        maFillOpacity = SvgNumber(o3tl::clamp(aNum.getNumber(), 0.0, 1.0), aNum.getUnit(), aNum.isSet());
+                        maFillOpacity = SvgNumber(std::clamp(aNum.getNumber(), 0.0, 1.0), aNum.getUnit(), aNum.isSet());
                     }
                     break;
                 }
@@ -1387,7 +1388,7 @@ namespace svgio
                         maStroke = aSvgPaint;
                         if(aOpacity.isSet())
                         {
-                            setOpacity(SvgNumber(o3tl::clamp(aOpacity.getNumber(), 0.0, 1.0)));
+                            setOpacity(SvgNumber(std::clamp(aOpacity.getNumber(), 0.0, 1.0)));
                         }
                     }
                     else if(!aURL.isEmpty())
@@ -1500,7 +1501,7 @@ namespace svgio
 
                     if(readSingleNumber(aContent, aNum))
                     {
-                        maStrokeOpacity = SvgNumber(o3tl::clamp(aNum.getNumber(), 0.0, 1.0), aNum.getUnit(), aNum.isSet());
+                        maStrokeOpacity = SvgNumber(std::clamp(aNum.getNumber(), 0.0, 1.0), aNum.getUnit(), aNum.isSet());
                     }
                     break;
                 }
@@ -1528,7 +1529,7 @@ namespace svgio
                         maStopColor = aSvgPaint;
                         if(aOpacity.isSet())
                         {
-                            setOpacity(SvgNumber(o3tl::clamp(aOpacity.getNumber(), 0.0, 1.0)));
+                            setOpacity(SvgNumber(std::clamp(aOpacity.getNumber(), 0.0, 1.0)));
                         }
                     }
                     break;
@@ -1841,7 +1842,7 @@ namespace svgio
                         maColor = aSvgPaint;
                         if(aOpacity.isSet())
                         {
-                            setOpacity(SvgNumber(o3tl::clamp(aOpacity.getNumber(), 0.0, 1.0)));
+                            setOpacity(SvgNumber(std::clamp(aOpacity.getNumber(), 0.0, 1.0)));
                         }
                     }
                     break;
@@ -1852,7 +1853,7 @@ namespace svgio
 
                     if(readSingleNumber(aContent, aNum))
                     {
-                        setOpacity(SvgNumber(o3tl::clamp(aNum.getNumber(), 0.0, 1.0), aNum.getUnit(), aNum.isSet()));
+                        setOpacity(SvgNumber(std::clamp(aNum.getNumber(), 0.0, 1.0), aNum.getUnit(), aNum.isSet()));
                     }
                     break;
                 }
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index c01c49949f94..c268899ad5c5 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -19,7 +19,6 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
 #include <svx/EnhancedCustomShape2d.hxx>
 #include <svx/EnhancedCustomShapeGeometry.hxx>
 #include <svx/EnhancedCustomShapeTypeNames.hxx>
@@ -56,6 +55,8 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <rtl/strbuf.hxx>
 #include <sal/log.hxx>
+
+#include <algorithm>
 #include <math.h>
 
 using namespace ::com::sun::star;
@@ -1045,15 +1046,15 @@ Color EnhancedCustomShape2d::GetColorData( const Color& rFillColor, sal_uInt32 n
         {
             if (dBrightness >=0.0)
             { //lighten, blending with white
-                return Color( static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(rFillColor.GetRed() * (1.0-dBrightness) + dBrightness * 255.0, 0.0, 255.0)  )),
-                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(rFillColor.GetGreen() * (1.0-dBrightness) + dBrightness * 255.0, 0.0, 255.0) )),
-                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(rFillColor.GetBlue() * (1.0-dBrightness) + dBrightness * 255.0, 0.0, 255.0) ))  );
+                return Color( static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(rFillColor.GetRed() * (1.0-dBrightness) + dBrightness * 255.0, 0.0, 255.0)  )),
+                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(rFillColor.GetGreen() * (1.0-dBrightness) + dBrightness * 255.0, 0.0, 255.0) )),
+                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(rFillColor.GetBlue() * (1.0-dBrightness) + dBrightness * 255.0, 0.0, 255.0) ))  );
             }
             else
             { //darken (indicated by negative sign), blending with black
-                return Color( static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(rFillColor.GetRed() * (1.0+dBrightness), 0.0, 255.0)  )),
-                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(rFillColor.GetGreen() * (1.0+dBrightness), 0.0, 255.0) )),
-                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(rFillColor.GetBlue() * (1.0+dBrightness), 0.0, 255.0) ))  );
+                return Color( static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(rFillColor.GetRed() * (1.0+dBrightness), 0.0, 255.0)  )),
+                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(rFillColor.GetGreen() * (1.0+dBrightness), 0.0, 255.0) )),
+                              static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(rFillColor.GetBlue() * (1.0+dBrightness), 0.0, 255.0) ))  );
             }
         }
     }
@@ -1084,9 +1085,9 @@ Color EnhancedCustomShape2d::GetColorData( const Color& rFillColor, sal_uInt32 n
         }
 
         aHSVColor = basegfx::utils::hsv2rgb(aHSVColor);
-        return Color( static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(aHSVColor.getRed(),0.0,1.0) * 255.0 + 0.5 )),
-                    static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(aHSVColor.getGreen(),0.0,1.0) * 255.0 + 0.5 )),
-                    static_cast<sal_uInt8>(static_cast< sal_Int32 >( o3tl::clamp(aHSVColor.getBlue(),0.0,1.0) * 255.0 + 0.5 )) );
+        return Color( static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(aHSVColor.getRed(),0.0,1.0) * 255.0 + 0.5 )),
+                    static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(aHSVColor.getGreen(),0.0,1.0) * 255.0 + 0.5 )),
+                    static_cast<sal_uInt8>(static_cast< sal_Int32 >( std::clamp(aHSVColor.getBlue(),0.0,1.0) * 255.0 + 0.5 )) );
     }
 }
 
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index 1df15cf8b4b2..7c4adfa7ef4b 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -19,7 +19,8 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
+#include <algorithm>
+
 #include <sfx2/sidebar/ControlFactory.hxx>
 #include "PosSizePropertyPanel.hxx"
 #include <svx/sidebar/SidebarDialControl.hxx>
@@ -1103,10 +1104,10 @@ void PosSizePropertyPanel::SetPosSizeMinMax()
     fBottom -= maRect.getHeight();
 
     const double fMaxLong(static_cast<double>(MetricField::ConvertValue( LONG_MAX, 0, MapUnit::Map100thMM, meDlgUnit ) - 1));
-    fLeft = o3tl::clamp(fLeft, -fMaxLong, fMaxLong);
-    fRight = o3tl::clamp(fRight, -fMaxLong, fMaxLong);
-    fTop = o3tl::clamp(fTop, - fMaxLong, fMaxLong);
-    fBottom = o3tl::clamp(fBottom, -fMaxLong, fMaxLong);
+    fLeft = std::clamp(fLeft, -fMaxLong, fMaxLong);
+    fRight = std::clamp(fRight, -fMaxLong, fMaxLong);
+    fTop = std::clamp(fTop, - fMaxLong, fMaxLong);
+    fBottom = std::clamp(fBottom, -fMaxLong, fMaxLong);
 
     mpMtrPosX->SetMin(basegfx::fround64(fLeft));
     mpMtrPosX->SetFirst(basegfx::fround64(fLeft));
diff --git a/svx/source/unodraw/unobrushitemhelper.cxx b/svx/source/unodraw/unobrushitemhelper.cxx
index fe4d636a55a4..7f8738d0f6ba 100644
--- a/svx/source/unodraw/unobrushitemhelper.cxx
+++ b/svx/source/unodraw/unobrushitemhelper.cxx
@@ -19,7 +19,8 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
+#include <algorithm>
+
 #include <svx/unobrushitemhelper.hxx>
 #include <svx/xfillit0.hxx>
 #include <svx/xbtmpit.hxx>
@@ -272,7 +273,7 @@ SvxBrushItem getSvxBrushItemFromSourceSet(const SfxItemSet& rSourceSet, sal_uInt
                 sal_uInt16 nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
 
                 // take half orig transparence, add half transparent, clamp result
-                nFillTransparence = o3tl::clamp(static_cast<sal_uInt16>((nFillTransparence / 2) + 50), sal_uInt16(0), sal_uInt16(255));
+                nFillTransparence = std::clamp(static_cast<sal_uInt16>((nFillTransparence / 2) + 50), sal_uInt16(0), sal_uInt16(255));
 
                 // #i125189# nFillTransparence is in range [0..100] and needs to be in [0..254] unsigned
                 // It is necessary to use the maximum of 0xfe for transparence for the SvxBrushItem
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index 9b03e0916d84..4c26d76e98c8 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -19,11 +19,11 @@
 
 #include <sal/config.h>
 
+#include <algorithm>
 #include <iomanip>
 #include <sstream>
 #include <stdlib.h>
 
-#include <o3tl/clamp.hxx>
 #include <tools/color.hxx>
 #include <tools/stream.hxx>
 #include <tools/helpers.hxx>
@@ -40,16 +40,16 @@ sal_uInt8 Color::GetColorError( const Color& rCompareColor ) const
 
 void Color::IncreaseLuminance( sal_uInt8 cLumInc )
 {
-    SetRed( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_RED( mnColor )) + cLumInc, 0L, 255L )) );
-    SetGreen( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_GREEN( mnColor )) + cLumInc, 0L, 255L )) );
-    SetBlue( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_BLUE( mnColor )) + cLumInc, 0L, 255L )) );
+    SetRed( static_cast<sal_uInt8>(std::clamp( static_cast<long>(COLORDATA_RED( mnColor )) + cLumInc, 0L, 255L )) );
+    SetGreen( static_cast<sal_uInt8>(std::clamp( static_cast<long>(COLORDATA_GREEN( mnColor )) + cLumInc, 0L, 255L )) );
+    SetBlue( static_cast<sal_uInt8>(std::clamp( static_cast<long>(COLORDATA_BLUE( mnColor )) + cLumInc, 0L, 255L )) );
 }
 
 void Color::DecreaseLuminance( sal_uInt8 cLumDec )
 {
-    SetRed( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_RED( mnColor )) - cLumDec, 0L, 255L )) );
-    SetGreen( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_GREEN( mnColor )) - cLumDec, 0L, 255L )) );
-    SetBlue( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_BLUE( mnColor )) - cLumDec, 0L, 255L )) );
+    SetRed( static_cast<sal_uInt8>(std::clamp( static_cast<long>(COLORDATA_RED( mnColor )) - cLumDec, 0L, 255L )) );
+    SetGreen( static_cast<sal_uInt8>(std::clamp( static_cast<long>(COLORDATA_GREEN( mnColor )) - cLumDec, 0L, 255L )) );
+    SetBlue( static_cast<sal_uInt8>(std::clamp( static_cast<long>(COLORDATA_BLUE( mnColor )) - cLumDec, 0L, 255L )) );
 }
 
 void Color::DecreaseContrast( sal_uInt8 cContDec )
@@ -59,9 +59,9 @@ void Color::DecreaseContrast( sal_uInt8 cContDec )
         const double fM = ( 128.0 - 0.4985 * cContDec ) / 128.0;
         const double fOff = 128.0 - fM * 128.0;
 
-        SetRed( static_cast<sal_uInt8>(o3tl::clamp( FRound( COLORDATA_RED( mnColor ) * fM + fOff ), 0L, 255L )) );
-        SetGreen( static_cast<sal_uInt8>(o3tl::clamp( FRound( COLORDATA_GREEN( mnColor ) * fM + fOff ), 0L, 255L )) );
-        SetBlue( static_cast<sal_uInt8>(o3tl::clamp( FRound( COLORDATA_BLUE( mnColor ) * fM + fOff ), 0L, 255L )) );
+        SetRed( static_cast<sal_uInt8>(std::clamp( FRound( COLORDATA_RED( mnColor ) * fM + fOff ), 0L, 255L )) );
+        SetGreen( static_cast<sal_uInt8>(std::clamp( FRound( COLORDATA_GREEN( mnColor ) * fM + fOff ), 0L, 255L )) );
+        SetBlue( static_cast<sal_uInt8>(std::clamp( FRound( COLORDATA_BLUE( mnColor ) * fM + fOff ), 0L, 255L )) );
     }
 }
 
diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
index 3b20d14657df..4ea239b1a549 100644
--- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
+++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
@@ -10,8 +10,9 @@
 
 #include <sal/config.h>
 
+#include <algorithm>
+
 #include <tools/helpers.hxx>
-#include <o3tl/clamp.hxx>
 #include <vcl/bitmap.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/bitmapaccess.hxx>
@@ -54,7 +55,7 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const
                 const long nLz = FRound(sin(fElev) * 255.0);
                 const auto nZ2 = ((6 * 255) / 4) * ((6 * 255) / 4);
                 const long nNzLz = ((6 * 255) / 4) * nLz;
-                const sal_uInt8 cLz = static_cast<sal_uInt8>(o3tl::clamp(nLz, 0L, 255L));
+                const sal_uInt8 cLz = static_cast<sal_uInt8>(std::clamp(nLz, 0L, 255L));
 
                 // fill mapping tables
                 pHMap[0] = 0;
@@ -105,7 +106,7 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const
                         {
                             const double fGrey
                                 = nDotL / sqrt(static_cast<double>(nNx * nNx + nNy * nNy + nZ2));
-                            aGrey.SetIndex(static_cast<sal_uInt8>(o3tl::clamp(fGrey, 0.0, 255.0)));
+                            aGrey.SetIndex(static_cast<sal_uInt8>(std::clamp(fGrey, 0.0, 255.0)));
                         }
 
                         pWriteAcc->SetPixelOnData(pScanline, nX, aGrey);
diff --git a/vcl/source/bitmap/BitmapSepiaFilter.cxx b/vcl/source/bitmap/BitmapSepiaFilter.cxx
index 6df4fe1b5221..5123bf13075c 100644
--- a/vcl/source/bitmap/BitmapSepiaFilter.cxx
+++ b/vcl/source/bitmap/BitmapSepiaFilter.cxx
@@ -10,7 +10,8 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
+#include <algorithm>
+
 #include <vcl/bitmap.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/bitmapaccess.hxx>
@@ -27,7 +28,7 @@ BitmapEx BitmapSepiaFilter::execute(BitmapEx const& rBitmapEx) const
     if (pReadAcc)
     {
         const long nSepia
-            = 10000 - 100 * o3tl::clamp(mnSepiaPercent, sal_uInt16(0), sal_uInt16(100));
+            = 10000 - 100 * std::clamp(mnSepiaPercent, sal_uInt16(0), sal_uInt16(100));
         BitmapPalette aSepiaPal(256);
 
         for (sal_uInt16 i = 0; i < 256; i++)
diff --git a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
index 397d0e6d1d5c..5ce4987a26fd 100644
--- a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
+++ b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
@@ -10,7 +10,8 @@
 
 #include <sal/config.h>
 
-#include <o3tl/clamp.hxx>
+#include <algorithm>
+
 #include <vcl/bitmap.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/bitmapaccess.hxx>
@@ -119,7 +120,7 @@ BitmapEx BitmapSobelGreyFilter::execute(BitmapEx const& rBitmapEx) const
                         nSum1 = static_cast<long>(
                             sqrt(static_cast<double>(nSum1 * nSum1 + nSum2 * nSum2)));
 
-                        aGrey.SetIndex(~static_cast<sal_uInt8>(o3tl::clamp(nSum1, 0L, 255L)));
+                        aGrey.SetIndex(~static_cast<sal_uInt8>(std::clamp(nSum1, 0L, 255L)));
                         pWriteAcc->SetPixelOnData(pScanline, nX, aGrey);
 
                         if (nX < (nWidth - 1))
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index fca398968320..1cc8230f6c7c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -8,6 +8,7 @@
  */
 
 #include "rtfdocumentimpl.hxx"
+#include <algorithm>
 #include <memory>
 #include <string_view>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
@@ -16,7 +17,6 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/text/WrapTextMode.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
-#include <o3tl/clamp.hxx>
 #include <i18nlangtag/languagetag.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 #include <unotools/streamwrap.hxx>
@@ -893,11 +893,11 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
     WmfExternal aExtHeader;
     aExtHeader.mapMode = m_aStates.top().aPicture.eWMetafile;
     aExtHeader.xExt = sal_uInt16(
-        o3tl::clamp<sal_Int32>(m_aStates.top().aPicture.nWidth, 0,
-                               SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
+        std::clamp<sal_Int32>(m_aStates.top().aPicture.nWidth, 0,
+                              SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
     aExtHeader.yExt = sal_uInt16(
-        o3tl::clamp<sal_Int32>(m_aStates.top().aPicture.nHeight, 0,
-                               SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
+        std::clamp<sal_Int32>(m_aStates.top().aPicture.nHeight, 0,
+                              SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
     WmfExternal* pExtHeader = &aExtHeader;
     uno::Reference<lang::XServiceInfo> xServiceInfo(m_aStates.top().aDrawingObject.xShape,
                                                     uno::UNO_QUERY);


More information about the Libreoffice-commits mailing list