Kaydet (Commit) 27cd397b authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 5b19be03
......@@ -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
{
......
......@@ -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;
......
......@@ -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));
}
}
}
......
......@@ -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);
......
......@@ -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)))
{
}
......
......@@ -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(
......
......@@ -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))
{
......
......@@ -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;
}
......
......@@ -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))
{
......
......@@ -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))
{
......
......@@ -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
......
......@@ -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)) );
}
......
......@@ -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;
......
......@@ -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;
}
......
/* -*- 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: */
......@@ -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
......
......@@ -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
......
......@@ -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(
......
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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 )) );
}
}
......
......@@ -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));
......
......@@ -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
......