From 4347b5975283ca1a591b6c3d4559ed360e187022 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 21 Oct 2018 15:53:34 +0100 Subject: pvs-studio: V728 An excessive check can be simplified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Caolán McNamara Tested-by: Caolán McNamara --- vcl/source/control/button.cxx | 14 ++++---------- vcl/source/edit/texteng.cxx | 12 +++--------- 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'vcl') diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index d81565a68666..52fe3b483573 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -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 ); } diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 08e1ba46212e..fd38f2413c57 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -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; } -- cgit