Kaydet (Commit) 4347b597 authored tarafından Caolán McNamara's avatar Caolán McNamara

pvs-studio: V728 An excessive check can be simplified

for...

"The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression"

subcases, where the args are already bool

Change-Id: Ica8b5c4974c513f7f7ad8acf17ca931e85ebc8af
Reviewed-on: https://gerrit.libreoffice.org/62146
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst b55fda6d
......@@ -438,11 +438,7 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
break;
}
if( xCandleStickChartType.is() &&
( ( bHasVolume &&
xVolumeChartType.is() ) ||
( ! bHasVolume &&
! xVolumeChartType.is() )))
if (xCandleStickChartType.is() && bHasVolume == xVolumeChartType.is())
{
bResult = true;
......
......@@ -147,8 +147,7 @@ void SAL_CALL OReadImagesDocumentHandler::endDocument()
{
SolarMutexGuard g;
if (( m_bImageContainerStartFound && !m_bImageContainerEndFound ) ||
( !m_bImageContainerStartFound && m_bImageContainerEndFound ) )
if (m_bImageContainerStartFound != m_bImageContainerEndFound)
{
OUString aErrorMessage = getErrorLineString();
aErrorMessage += "No matching start or end element 'image:imagecontainer' found!";
......
......@@ -1441,10 +1441,7 @@ public:
{
pCurDVR = static_cast<const formula::DoubleVectorRefToken*>(tmpCur);
if (!
((!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
|| (pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()))
)
if (pCurDVR->IsStartFixed() != pCurDVR->IsEndFixed())
throw Unhandled(__FILE__, __LINE__);
}
}
......@@ -2182,8 +2179,7 @@ static DynamicKernelArgument* VectorRefFactory( const ScCalcConfig& config, cons
// Window being too small to justify a parallel reduction
if (pDVR->GetRefRowSize() < REDUCE_THRESHOLD)
return new DynamicKernelSlidingArgument<Base>(config, s, ft, pCodeGen, index);
if ((pDVR->IsStartFixed() && pDVR->IsEndFixed()) ||
(!pDVR->IsStartFixed() && !pDVR->IsEndFixed()))
if (pDVR->IsStartFixed() == pDVR->IsEndFixed())
return new ParallelReductionVectorRef<Base>(config, s, ft, pCodeGen, index);
else // Other cases are not supported as well
return new DynamicKernelSlidingArgument<Base>(config, s, ft, pCodeGen, index);
......
......@@ -961,7 +961,7 @@ static bool isValidSingleton( ScRefFlags nFlags, ScRefFlags nFlags2 )
{
bool bCols = (nFlags & ScRefFlags::COL_VALID) && ((nFlags & ScRefFlags::COL2_VALID) || (nFlags2 & ScRefFlags::COL_VALID));
bool bRows = (nFlags & ScRefFlags::ROW_VALID) && ((nFlags & ScRefFlags::ROW2_VALID) || (nFlags2 & ScRefFlags::ROW_VALID));
return (bCols && !bRows) || (!bCols && bRows);
return bCols != bRows;
}
static ScRefFlags lcl_ScRange_Parse_XL_A1( ScRange& r,
......
......@@ -421,8 +421,8 @@ namespace basprov
bool bCreate = false;
if ( m_bIsAppScriptCtx )
{
bool bShared = isLibraryShared( xLibContainer, pLibNames[i] );
if ( ( m_bIsUserCtx && !bShared ) || ( !m_bIsUserCtx && bShared ) )
const bool bShared = isLibraryShared( xLibContainer, pLibNames[i] );
if (m_bIsUserCtx != bShared)
bCreate = true;
}
else
......
......@@ -1175,7 +1175,7 @@ bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& r
if ( aGeoStat.nShearAngle )
{
double nTan = aGeoStat.nTan;
if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
if (bFlipV != bFlipH)
nTan = -nTan;
ShearPoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
}
......@@ -1220,7 +1220,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
if ( aGeoStat.nShearAngle )
{
double nTan = -aGeoStat.nTan;
if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
if (bFlipV != bFlipH)
nTan = -nTan;
ShearPoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
}
......
......@@ -328,7 +328,7 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
{
long nShearAngle = rGeoStat.nShearAngle;
double nTan = rGeoStat.nTan;
if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
if (bFlipV != bFlipH)
{
nShearAngle = -nShearAngle;
nTan = -nTan;
......@@ -429,7 +429,7 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
{
long nShearAngle = rGeoStat.nShearAngle;
double nTan = rGeoStat.nTan;
if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
if (bFlipV != bFlipH)
{
nShearAngle = -nShearAngle;
nTan = -nTan;
......
......@@ -955,8 +955,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_1).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight1)) ||
( !bOn && GetUILightState(*m_pBtnLight1)) )
if (bOn != GetUILightState(*m_pBtnLight1))
{
SetUILightState(*m_pBtnLight1, bOn);
bUpdate = true;
......@@ -1004,8 +1003,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_2).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight2)) ||
( !bOn && GetUILightState(*m_pBtnLight2)) )
if (bOn != GetUILightState(*m_pBtnLight2))
{
SetUILightState(*m_pBtnLight2, bOn);
bUpdate = true;
......@@ -1053,8 +1051,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_3).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight3)) ||
( !bOn && GetUILightState(*m_pBtnLight3)) )
if (bOn != GetUILightState(*m_pBtnLight3))
{
SetUILightState(*m_pBtnLight3, bOn);
bUpdate = true;
......@@ -1102,8 +1099,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_4).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight4)) ||
( !bOn && GetUILightState(*m_pBtnLight4)) )
if (bOn != GetUILightState(*m_pBtnLight4))
{
SetUILightState(*m_pBtnLight4, bOn);
bUpdate = true;
......@@ -1151,8 +1147,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_5).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight5)) ||
( !bOn && GetUILightState(*m_pBtnLight5)) )
if (bOn != GetUILightState(*m_pBtnLight5))
{
SetUILightState(*m_pBtnLight5, bOn);
bUpdate = true;
......@@ -1200,8 +1195,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_6).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight6)) ||
( !bOn && GetUILightState(*m_pBtnLight6)) )
if (bOn != GetUILightState(*m_pBtnLight6))
{
SetUILightState(*m_pBtnLight6, bOn);
bUpdate = true;
......@@ -1249,8 +1243,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_7).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight7)) ||
( !bOn && GetUILightState(*m_pBtnLight7)) )
if (bOn != GetUILightState(*m_pBtnLight7))
{
SetUILightState(*m_pBtnLight7 , bOn);
bUpdate = true;
......@@ -1298,8 +1291,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
if( eState != SfxItemState::DONTCARE )
{
bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_8).GetValue();
if( ( bOn && !GetUILightState(*m_pBtnLight8)) ||
( !bOn && GetUILightState(*m_pBtnLight8)) )
if (bOn != GetUILightState(*m_pBtnLight8))
{
SetUILightState(*m_pBtnLight8, bOn);
bUpdate = true;
......
......@@ -1728,7 +1728,7 @@ void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded()
sal_Int32 nXDiff = aBoundRect.Left() - maRect.Left();
sal_Int32 nYDiff = aBoundRect.Top() - maRect.Top();
if (nShearAngle&&((bMirroredX&&!bMirroredY)||(bMirroredY&&!bMirroredX)))
if (nShearAngle && bMirroredX != bMirroredY)
{
nShearAngle = -nShearAngle;
fTan = -fTan;
......
......@@ -735,7 +735,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
else
{
bool bCellHasText = xCell->hasText();
if ( (!bRowHasText && !bCellHasText) || ( bRowHasText && bCellHasText ) )
if (bRowHasText == bCellHasText)
{
nMinHeight = std::max( nMinHeight, xCell->getMinimumHeight() );
}
......
......@@ -287,8 +287,7 @@ static uno::Reference<drawing::XShape> lcl_getShape(const uno::Reference<lang::X
{
Graphic aGraphic(xGraphic);
if ((bEmbedded && aGraphic.getOriginURL().isEmpty()) ||
(!bEmbedded && !aGraphic.getOriginURL().isEmpty()))
if (bEmbedded == aGraphic.getOriginURL().isEmpty())
{
xShape.set(xShapeProperties, uno::UNO_QUERY);
return xShape;
......
......@@ -859,7 +859,7 @@ SwSbxValue SwCalc::Term()
GetToken();
bool bR = Prim().GetBool();
bool bL = left.GetBool();
left.PutBool( (bL && !bR) || (!bL && bR) );
left.PutBool(bL != bR);
}
break;
......
......@@ -1393,8 +1393,7 @@ bool SwFEShell::ShouldObjectBeSelected(const Point& rPt)
{
const SwPosition& rPos = pContact->GetContentAnchor();
bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode );
if ( ( IsHeaderFooterEdit() && !bInHdrFtr ) ||
( !IsHeaderFooterEdit() && bInHdrFtr ) )
if (IsHeaderFooterEdit() != bInHdrFtr)
{
bRet = false;
}
......
......@@ -67,8 +67,7 @@ namespace {
const SvxOpaqueItem& rOpaque = pAnchoredObj->GetFrameFormat().GetOpaque();
bool bInBackground = ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH ) && !rOpaque.GetValue();
bool bBackgroundMatches = ( bInBackground && bSearchBackground ) ||
( !bInBackground && !bSearchBackground );
bool bBackgroundMatches = bInBackground == bSearchBackground;
const SwFlyFrame* pFly = pObj ? pObj->GetFlyFrame() : nullptr;
if ( pFly && bBackgroundMatches &&
......
......@@ -501,9 +501,7 @@ long SwTextFrame::SwitchVerticalToHorizontal( long nLimit ) const
SwFrameSwapper::SwFrameSwapper( const SwTextFrame* pTextFrame, bool bSwapIfNotSwapped )
: pFrame( pTextFrame ), bUndo( false )
{
if ( pFrame->IsVertical() &&
( ( bSwapIfNotSwapped && ! pFrame->IsSwapped() ) ||
( ! bSwapIfNotSwapped && pFrame->IsSwapped() ) ) )
if (pFrame->IsVertical() && bSwapIfNotSwapped != pFrame->IsSwapped())
{
bUndo = true;
const_cast<SwTextFrame*>(pFrame)->SwapWidthAndHeight();
......
......@@ -433,8 +433,7 @@ namespace sw
{
// Check top only if both object have a header or if
// both object don't have a header
if ( ( HasHeader() && rOther.HasHeader() ) ||
( !HasHeader() && !rOther.HasHeader() ) )
if (HasHeader() == rOther.HasHeader())
{
if (dyaTop != rOther.dyaTop)
return false;
......@@ -442,8 +441,7 @@ namespace sw
// Check bottom only if both object have a footer or if
// both object don't have a footer
if ( ( HasFooter() && rOther.HasFooter() ) ||
( !HasFooter() && !rOther.HasFooter() ) )
if (HasFooter() == rOther.HasFooter())
{
if (dyaBottom != rOther.dyaBottom)
return false;
......
......@@ -86,9 +86,9 @@ std::unique_ptr<SfxItemSet> SwModule::CreateItemSet( sal_uInt16 nId )
pAppView = nullptr;
if(pAppView)
{
// if Text then no WebView and vice versa
bool bWebView = dynamic_cast<SwWebView*>( pAppView ) != nullptr;
if( (bWebView && !bTextDialog) ||(!bWebView && bTextDialog))
// if Text then no WebView and vice versa
if (bWebView != bTextDialog)
{
aViewOpt = *pAppView->GetWrtShell().GetViewOptions();
}
......
......@@ -2596,11 +2596,8 @@ bool RadioButton::PreNotify( NotifyEvent& rNEvt )
// trigger redraw if mouse over state has changed
if( IsNativeControlSupported(ControlType::Radiobutton, ControlPart::Entire) )
{
if( ( maMouseRect.IsInside( GetPointerPosPixel()) &&
!maMouseRect.IsInside( GetLastPointerPosPixel()) ) ||
( maMouseRect.IsInside( GetLastPointerPosPixel()) &&
!maMouseRect.IsInside( GetPointerPosPixel()) ) ||
pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
if (maMouseRect.IsInside(GetPointerPosPixel()) != maMouseRect.IsInside(GetLastPointerPosPixel()) ||
pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
{
Invalidate( maStateRect );
}
......@@ -3495,11 +3492,8 @@ bool CheckBox::PreNotify( NotifyEvent& rNEvt )
// trigger redraw if mouse over state has changed
if( IsNativeControlSupported(ControlType::Checkbox, ControlPart::Entire) )
{
if( ( maMouseRect.IsInside( GetPointerPosPixel()) &&
!maMouseRect.IsInside( GetLastPointerPosPixel()) ) ||
( maMouseRect.IsInside( GetLastPointerPosPixel()) &&
!maMouseRect.IsInside( GetPointerPosPixel()) ) ||
pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
if (maMouseRect.IsInside(GetPointerPosPixel()) != maMouseRect.IsInside(GetLastPointerPosPixel()) ||
pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
{
Invalidate( maStateRect );
}
......
......@@ -943,11 +943,8 @@ long TextEngine::ImpGetXPos( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nIndex
if ( ( pPortion->GetKind() == PORTIONKIND_TAB ) && ( (nTextPortion+1) < pParaPortion->GetTextPortions().size() ) )
{
TETextPortion* pNextPortion = pParaPortion->GetTextPortions()[ nTextPortion+1 ];
if ( ( pNextPortion->GetKind() != PORTIONKIND_TAB ) && (
( !IsRightToLeft() && pNextPortion->IsRightToLeft() ) ||
( IsRightToLeft() && !pNextPortion->IsRightToLeft() ) ) )
if (pNextPortion->GetKind() != PORTIONKIND_TAB && IsRightToLeft() != pNextPortion->IsRightToLeft())
{
// nX += pNextPortion->GetWidth();
// End of the tab portion, use start of next for cursor pos
SAL_WARN_IF( bPreferPortionStart, "vcl", "ImpGetXPos: How can we get here!" );
nX = ImpGetXPos( nPara, pLine, nIndex, true );
......@@ -962,8 +959,7 @@ long TextEngine::ImpGetXPos( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nIndex
long nPosInPortion = CalcTextWidth( nPara, nTextPortionStart, nIndex-nTextPortionStart );
if ( ( !IsRightToLeft() && !pPortion->IsRightToLeft() ) ||
( IsRightToLeft() && pPortion->IsRightToLeft() ) )
if (IsRightToLeft() == pPortion->IsRightToLeft())
{
nX += nPosInPortion;
}
......@@ -975,9 +971,7 @@ long TextEngine::ImpGetXPos( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nIndex
}
else // if ( nIndex == pLine->GetStart() )
{
if ( ( pPortion->GetKind() != PORTIONKIND_TAB ) &&
( ( !IsRightToLeft() && pPortion->IsRightToLeft() ) ||
( IsRightToLeft() && !pPortion->IsRightToLeft() ) ) )
if (pPortion->GetKind() != PORTIONKIND_TAB && IsRightToLeft() != pPortion->IsRightToLeft())
{
nX += nPortionTextWidth;
}
......
......@@ -147,7 +147,7 @@ bool XMLCharScriptHdl::equals( const css::uno::Any& r1, const css::uno::Any& r2
bool bEmptyVariant2 = aLocale2.Variant.isEmpty();
if (bEmptyVariant1 && bEmptyVariant2)
bRet = true;
else if ((bEmptyVariant1 && !bEmptyVariant2) || (!bEmptyVariant1 && bEmptyVariant2))
else if (bEmptyVariant1 != bEmptyVariant2)
; // stays false
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment