[Libreoffice-commits] core.git: drawinglayer/source include/vcl sd/source vcl/source vcl/win
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Fri Mar 26 10:58:46 UTC 2021
drawinglayer/source/texture/texture3d.cxx | 2 -
include/vcl/bitmap.hxx | 6 +++++
sd/source/ui/docshell/docshel2.cxx | 2 -
vcl/source/bitmap/BitmapEx.cxx | 34 +++++++++++++++---------------
vcl/source/bitmap/alpha.cxx | 4 +--
vcl/source/gdi/metaact.cxx | 6 ++---
vcl/win/window/salframe.cxx | 4 +--
7 files changed, 32 insertions(+), 26 deletions(-)
New commits:
commit 83b011b61e941250f8c58ff12c864830fe52f9c0
Author: Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Mar 26 10:30:34 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Mar 26 11:58:03 2021 +0100
create operator bool for Bitmap
so we can use a more natural syntax than "!!"
Change-Id: I8152a0d3ce37115fc83d332a26725ca1d28d959a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113147
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx
index ef53c94d0d10..2c8be33a2086 100644
--- a/drawinglayer/source/texture/texture3d.cxx
+++ b/drawinglayer/source/texture/texture3d.cxx
@@ -89,7 +89,7 @@ namespace drawinglayer::texture
mpReadTransparence = Bitmap::ScopedReadAccess(maTransparence);
}
- if (!!maBitmap)
+ if (maBitmap)
mpReadBitmap = Bitmap::ScopedReadAccess(maBitmap);
SAL_WARN_IF(!mpReadBitmap, "drawinglayer", "GeoTexSvxBitmapEx: Got no read access to Bitmap");
if (mpReadBitmap)
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 3a2baf9e24c7..4c1a3b3dbddf 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -124,6 +124,7 @@ public:
inline bool operator!() const;
bool operator==( const Bitmap& rBitmap ) const;
bool operator!=( const Bitmap& rBitmap ) const { return !operator==(rBitmap); }
+ inline operator bool() const;
inline bool IsEmpty() const;
void SetEmpty();
@@ -550,6 +551,11 @@ private:
};
+inline Bitmap::operator bool() const
+{
+ return mxSalBmp != nullptr;
+}
+
inline bool Bitmap::operator!() const
{
return( mxSalBmp == nullptr );
diff --git a/sd/source/ui/docshell/docshel2.cxx b/sd/source/ui/docshell/docshel2.cxx
index bfbb92ab61c5..68bdf0af1f7e 100644
--- a/sd/source/ui/docshell/docshel2.cxx
+++ b/sd/source/ui/docshell/docshel2.cxx
@@ -262,7 +262,7 @@ BitmapEx DrawDocShell::GetPagePreviewBitmap(SdPage* pPage)
BitmapEx aPreview( pVDev->GetBitmapEx( aNullPt, pVDev->GetOutputSizePixel() ) );
- DBG_ASSERT(!!aPreview, "Preview-Bitmap could not be generated");
+ DBG_ASSERT(aPreview, "Preview-Bitmap could not be generated");
return aPreview;
}
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index 60272c728485..8f1693193e78 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -127,7 +127,7 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
{
// Ensure a mask is exactly one bit deep,
// alternatively also allow 8bpp masks.
- if( !!maMask && maMask.GetBitCount() != 1 && !(maMask.GetBitCount() == 8 && maMask.HasGreyPalette8Bit()))
+ if( maMask && maMask.GetBitCount() != 1 && !(maMask.GetBitCount() == 8 && maMask.HasGreyPalette8Bit()))
{
SAL_WARN( "vcl", "BitmapEx: forced mask to monochrome");
BitmapEx aMaskEx(maMask);
@@ -135,7 +135,7 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
maMask = aMaskEx.GetBitmap();
}
- if (!!maBitmap && !!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel())
+ if (maBitmap && maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel())
{
OSL_ENSURE(false, "Mask size differs from Bitmap size, corrected Mask (!)");
maMask.Scale(maBitmap.GetSizePixel());
@@ -149,7 +149,7 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask ) :
meTransparent ( !rAlphaMask ? TransparentType::NONE : TransparentType::Bitmap ),
mbAlpha ( !rAlphaMask.IsEmpty() )
{
- if (!!maBitmap && !!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel())
+ if (maBitmap && maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel())
{
OSL_ENSURE(false, "Alpha size differs from Bitmap size, corrected Mask (!)");
maMask.Scale(rBmp.GetSizePixel());
@@ -306,7 +306,7 @@ bool BitmapEx::Invert()
{
bool bRet = false;
- if (!!maBitmap)
+ if (maBitmap)
bRet = maBitmap.Invert();
return bRet;
@@ -316,7 +316,7 @@ bool BitmapEx::Mirror( BmpMirrorFlags nMirrorFlags )
{
bool bRet = false;
- if( !!maBitmap )
+ if( maBitmap )
{
bRet = maBitmap.Mirror( nMirrorFlags );
@@ -331,7 +331,7 @@ bool BitmapEx::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag
{
bool bRet = false;
- if( !!maBitmap )
+ if( maBitmap )
{
bRet = maBitmap.Scale( rScaleX, rScaleY, nScaleFlag );
@@ -342,7 +342,7 @@ bool BitmapEx::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF( !!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF( maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
"BitmapEx::Scale(): size mismatch for bitmap and alpha mask." );
}
@@ -373,7 +373,7 @@ bool BitmapEx::Rotate( Degree10 nAngle10, const Color& rFillColor )
{
bool bRet = false;
- if( !!maBitmap )
+ if( maBitmap )
{
const bool bTransRotate = ( COL_TRANSPARENT == rFillColor );
@@ -401,7 +401,7 @@ bool BitmapEx::Rotate( Degree10 nAngle10, const Color& rFillColor )
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF(!!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF(maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
"BitmapEx::Rotate(): size mismatch for bitmap and alpha mask.");
}
@@ -412,7 +412,7 @@ bool BitmapEx::Crop( const tools::Rectangle& rRectPixel )
{
bool bRet = false;
- if( !!maBitmap )
+ if( maBitmap )
{
bRet = maBitmap.Crop( rRectPixel );
@@ -421,7 +421,7 @@ bool BitmapEx::Crop( const tools::Rectangle& rRectPixel )
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF(!!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF(maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
"BitmapEx::Crop(): size mismatch for bitmap and alpha mask.");
}
@@ -430,7 +430,7 @@ bool BitmapEx::Crop( const tools::Rectangle& rRectPixel )
bool BitmapEx::Convert( BmpConversion eConversion )
{
- return !!maBitmap && maBitmap.Convert( eConversion );
+ return maBitmap && maBitmap.Convert( eConversion );
}
void BitmapEx::Expand( sal_uLong nDX, sal_uLong nDY, bool bExpandTransparent )
@@ -450,7 +450,7 @@ void BitmapEx::Expand( sal_uLong nDX, sal_uLong nDY, bool bExpandTransparent )
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF(!!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF(maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
"BitmapEx::Expand(): size mismatch for bitmap and alpha mask.");
}
@@ -547,7 +547,7 @@ bool BitmapEx::Erase( const Color& rFillColor )
{
bool bRet = false;
- if( !!maBitmap )
+ if( maBitmap )
{
bRet = maBitmap.Erase( rFillColor );
@@ -572,13 +572,13 @@ bool BitmapEx::Erase( const Color& rFillColor )
void BitmapEx::Replace( const Color& rSearchColor, const Color& rReplaceColor )
{
- if (!!maBitmap)
+ if (maBitmap)
maBitmap.Replace( rSearchColor, rReplaceColor );
}
void BitmapEx::Replace( const Color* pSearchColors, const Color* pReplaceColors, size_t nColorCount )
{
- if (!!maBitmap)
+ if (maBitmap)
maBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, /*pTols*/nullptr );
}
@@ -586,7 +586,7 @@ bool BitmapEx::Adjust( short nLuminancePercent, short nContrastPercent,
short nChannelRPercent, short nChannelGPercent, short nChannelBPercent,
double fGamma, bool bInvert, bool msoBrightness )
{
- return !!maBitmap && maBitmap.Adjust( nLuminancePercent, nContrastPercent,
+ return maBitmap && maBitmap.Adjust( nLuminancePercent, nContrastPercent,
nChannelRPercent, nChannelGPercent, nChannelBPercent,
fGamma, bInvert, msoBrightness );
}
diff --git a/vcl/source/bitmap/alpha.cxx b/vcl/source/bitmap/alpha.cxx
index e361ee6dcae6..ccd8f49bbe65 100644
--- a/vcl/source/bitmap/alpha.cxx
+++ b/vcl/source/bitmap/alpha.cxx
@@ -31,7 +31,7 @@ AlphaMask::AlphaMask() = default;
AlphaMask::AlphaMask( const Bitmap& rBitmap ) :
Bitmap( rBitmap )
{
- if( !!rBitmap )
+ if( rBitmap )
Convert( BmpConversion::N8BitNoConversion );
}
@@ -52,7 +52,7 @@ AlphaMask& AlphaMask::operator=( const Bitmap& rBitmap )
{
*static_cast<Bitmap*>(this) = rBitmap;
- if( !!rBitmap )
+ if( rBitmap )
Convert( BmpConversion::N8BitNoConversion );
return *this;
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 5ae914e44091..871c646a02e0 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -1680,7 +1680,7 @@ void MetaBmpExAction::Scale( double fScaleX, double fScaleY )
void MetaBmpExAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
- if( !!maBmpEx.GetBitmap() )
+ if( maBmpEx.GetBitmap() )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
@@ -1738,7 +1738,7 @@ void MetaBmpExScaleAction::Scale( double fScaleX, double fScaleY )
void MetaBmpExScaleAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
- if( !!maBmpEx.GetBitmap() )
+ if( maBmpEx.GetBitmap() )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
@@ -1801,7 +1801,7 @@ void MetaBmpExScalePartAction::Scale( double fScaleX, double fScaleY )
void MetaBmpExScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
- if( !!maBmpEx.GetBitmap() )
+ if( maBmpEx.GetBitmap() )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 0d211d3bf3f2..c0c12dcd1cf7 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -4513,7 +4513,7 @@ static LRESULT ImplMeasureItem( HWND hWnd, WPARAM wParam, LPARAM lParam )
// image
Size bmpSize( 16, 16 );
- //if( !!pSalMenuItem->maBitmap )
+ //if( pSalMenuItem->maBitmap )
// bmpSize = pSalMenuItem->maBitmap.GetSizePixel();
// checkmark
@@ -4595,7 +4595,7 @@ static LRESULT ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam )
//Size bmpSize = aBitmap.GetSizePixel();
Size bmpSize(16, 16);
- if( !!pSalMenuItem->maBitmap )
+ if( pSalMenuItem->maBitmap )
{
Bitmap aBitmap( pSalMenuItem->maBitmap );
More information about the Libreoffice-commits
mailing list