cppcheck: redundantCondition [part1]

Change-Id: I21c5340e7b5ec09248b08aa76f43acf883c56cd8
This commit is contained in:
Julien Nabet 2015-06-14 12:17:55 +02:00
parent 01a189abcd
commit b226928c6d
19 changed files with 26 additions and 31 deletions

View File

@ -831,7 +831,7 @@ void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChange
if ( pWindow_->GetDocument().isInVBAMode() ) if ( pWindow_->GetDocument().isInVBAMode() )
{ {
SbModule* pMod = StarBASIC::GetActiveModule(); SbModule* pMod = StarBASIC::GetActiveModule();
if ( !pMod || ( pMod && ( !pMod->GetName().equals(pWindow_->GetName()) ) ) ) if ( !pMod || !pMod->GetName().equals(pWindow_->GetName()))
{ {
bStop = false; bStop = false;
} }

View File

@ -382,7 +382,7 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt
SbModuleRef xModule; SbModuleRef xModule;
// Only reparse modules if ScriptDocument source is out of sync // Only reparse modules if ScriptDocument source is out of sync
// with basic's Module // with basic's Module
if ( !pMod || ( pMod && pMod->GetSource() != aOUSource ) ) if ( !pMod || pMod->GetSource() != aOUSource )
{ {
xModule = new SbModule( rModName ); xModule = new SbModule( rModName );
xModule->SetSource32( aOUSource ); xModule->SetSource32( aOUSource );
@ -432,7 +432,7 @@ bool HasMethod (
SbModuleRef xModule; SbModuleRef xModule;
// Only reparse modules if ScriptDocument source is out of sync // Only reparse modules if ScriptDocument source is out of sync
// with basic's Module // with basic's Module
if ( !pMod || ( pMod && pMod->GetSource() != aOUSource )) if ( !pMod || pMod->GetSource() != aOUSource )
{ {
xModule = new SbModule( rModName ); xModule = new SbModule( rModName );
xModule->SetSource32( aOUSource ); xModule->SetSource32( aOUSource );

View File

@ -302,8 +302,7 @@ namespace basegfx
{ {
OSL_PRECOND( !mbIsFinished, OSL_PRECOND( !mbIsFinished,
"ImplPolygon::intersect(): called on already finished polygon!" ); "ImplPolygon::intersect(): called on already finished polygon!" );
OSL_PRECOND( !isFinishingEdge OSL_PRECOND( !isFinishingEdge || &rEvent.getRect() == &rActiveEdge.getRect(),
|| (isFinishingEdge && &rEvent.getRect() == &rActiveEdge.getRect()),
"ImplPolygon::intersect(): inconsistent ending!" ); "ImplPolygon::intersect(): inconsistent ending!" );
const B2DPoint aIntersectionPoint( rEvent.getPos(), const B2DPoint aIntersectionPoint( rEvent.getPos(),

View File

@ -1628,7 +1628,7 @@ inline bool checkUnoStructCopy( bool bVBA, SbxVariableRef& refVal, SbxVariableRe
SbxDataType eVarType = refVar->GetType(); SbxDataType eVarType = refVar->GetType();
SbxDataType eValType = refVal->GetType(); SbxDataType eValType = refVal->GetType();
if ( !( !bVBA|| ( bVBA && refVar->GetType() != SbxEMPTY ) ) || !refVar->CanWrite() ) if ( !( !bVBA || refVar->GetType() != SbxEMPTY ) || !refVar->CanWrite() )
return false; return false;
if ( eValType != SbxOBJECT ) if ( eValType != SbxOBJECT )
@ -1825,7 +1825,7 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
// Getting in here causes problems with objects with default properties // Getting in here causes problems with objects with default properties
// if they are SbxEMPTY I guess // if they are SbxEMPTY I guess
if ( !bHandleDefaultProp || ( bHandleDefaultProp && eValType == SbxOBJECT ) ) if ( !bHandleDefaultProp || eValType == SbxOBJECT )
{ {
// activate GetOject for collections on refVal // activate GetOject for collections on refVal
SbxBase* pObjVarObj = refVal->GetObject(); SbxBase* pObjVarObj = refVal->GetObject();
@ -3842,7 +3842,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
} }
} }
// consider index-access for UnoObjects // consider index-access for UnoObjects
else if( pElem->GetType() == SbxOBJECT && !pElem->ISA(SbxMethod) && ( !bVBAEnabled || ( bVBAEnabled && !pElem->ISA(SbxProperty) ) ) ) else if( pElem->GetType() == SbxOBJECT && !pElem->ISA(SbxMethod) && ( !bVBAEnabled || !pElem->ISA(SbxProperty) ) )
{ {
pPar = pElem->GetParameters(); pPar = pElem->GetParameters();
if ( pPar ) if ( pPar )

View File

@ -885,8 +885,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet
bool bPropExisted = bool bPropExisted =
( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldVal ); ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldVal );
if( ! bPropExisted || if( ! bPropExisted || fOldVal != fVal )
( bPropExisted && fOldVal != fVal ))
{ {
GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fVal )); GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fVal ));
bChangedOtherwise = true; bChangedOtherwise = true;

View File

@ -505,8 +505,7 @@ bool DataPointItemConverter::ApplySpecialItem(
bool bPropExisted = bool bPropExisted =
( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue ); ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue );
if( ! bPropExisted || if( ! bPropExisted || fOldValue != fValue )
( bPropExisted && fOldValue != fValue ))
{ {
GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fValue )); GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fValue ));
bChanged = true; bChanged = true;

View File

@ -459,8 +459,7 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte
bool bPropExisted = bool bPropExisted =
(GetPropertySet()->getPropertyValue("TextRotation") >>= fOldValue); (GetPropertySet()->getPropertyValue("TextRotation") >>= fOldValue);
if (!bPropExisted || if (!bPropExisted || fOldValue != fValue)
(bPropExisted && fOldValue != fValue))
{ {
GetPropertySet()->setPropertyValue("TextRotation", uno::makeAny(fValue)); GetPropertySet()->setPropertyValue("TextRotation", uno::makeAny(fValue));
bChanged = true; bChanged = true;

View File

@ -186,8 +186,7 @@ bool TitleItemConverter::ApplySpecialItem(
bool bPropExisted = bool bPropExisted =
( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldVal ); ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldVal );
if( ! bPropExisted || if( ! bPropExisted || fOldVal != fVal )
( bPropExisted && fOldVal != fVal ))
{ {
GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fVal )); GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fVal ));
bChanged = true; bChanged = true;

View File

@ -265,7 +265,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
{ {
aName = aName.copy(0, (aName.getLength()-(aFilenameExtension.getLength()+1))); aName = aName.copy(0, (aName.getLength()-(aFilenameExtension.getLength()+1)));
sal_Unicode nChar = aName.toChar(); sal_Unicode nChar = aName.toChar();
if ( match(tableNamePattern,aName,'\0') && ( !bCheckEnabled || ( bCheckEnabled && ((nChar < '0' || nChar > '9')))) ) if ( match(tableNamePattern,aName,'\0') && ( !bCheckEnabled || (nChar < '0' || nChar > '9')) )
{ {
aRow.push_back(new ORowSetValueDecorator(aName)); aRow.push_back(new ORowSetValueDecorator(aName));
bNewRow = true; bNewRow = true;
@ -280,7 +280,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
if (aURL.getExtension().isEmpty()) if (aURL.getExtension().isEmpty())
{ {
sal_Unicode nChar = aURL.getBase()[0]; sal_Unicode nChar = aURL.getBase()[0];
if(match(tableNamePattern,aURL.getBase(),'\0') && ( !bCheckEnabled || ( bCheckEnabled && ((nChar < '0' || nChar > '9')))) ) if(match(tableNamePattern,aURL.getBase(),'\0') && ( !bCheckEnabled || (nChar < '0' || nChar > '9') ) )
{ {
aRow.push_back(new ORowSetValueDecorator(OUString(aURL.getBase()))); aRow.push_back(new ORowSetValueDecorator(OUString(aURL.getBase())));
bNewRow = true; bNewRow = true;

View File

@ -296,7 +296,7 @@ private:
const bool bTextureActive(mrProcessor.getGeoTexSvx().get() || mrProcessor.getTransparenceGeoTexSvx().get()); const bool bTextureActive(mrProcessor.getGeoTexSvx().get() || mrProcessor.getTransparenceGeoTexSvx().get());
mbUseTex = bTextureActive && (mbHasTexCoor || mbHasInvTexCoor || mrProcessor.getSimpleTextureActive()); mbUseTex = bTextureActive && (mbHasTexCoor || mbHasInvTexCoor || mrProcessor.getSimpleTextureActive());
const bool bUseColorTex(mbUseTex && mrProcessor.getGeoTexSvx().get()); const bool bUseColorTex(mbUseTex && mrProcessor.getGeoTexSvx().get());
const bool bNeedNrmOrCol(!bUseColorTex || (bUseColorTex && mrProcessor.getModulate())); const bool bNeedNrmOrCol(!bUseColorTex || mrProcessor.getModulate());
mbUseNrm = bNeedNrmOrCol && SCANLINE_EMPTY_INDEX != rA.getNormalIndex() && SCANLINE_EMPTY_INDEX != rB.getNormalIndex(); mbUseNrm = bNeedNrmOrCol && SCANLINE_EMPTY_INDEX != rA.getNormalIndex() && SCANLINE_EMPTY_INDEX != rB.getNormalIndex();
mbUseCol = !mbUseNrm && bNeedNrmOrCol && SCANLINE_EMPTY_INDEX != rA.getColorIndex() && SCANLINE_EMPTY_INDEX != rB.getColorIndex(); mbUseCol = !mbUseNrm && bNeedNrmOrCol && SCANLINE_EMPTY_INDEX != rA.getColorIndex() && SCANLINE_EMPTY_INDEX != rB.getColorIndex();

View File

@ -398,7 +398,7 @@ void SvxNumberFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem,
delete pGraphicBrush; delete pGraphicBrush;
pGraphicBrush = 0; pGraphicBrush = 0;
} }
else if ( !pGraphicBrush || (pGraphicBrush && !(*pBrushItem == *pGraphicBrush)) ) else if ( !pGraphicBrush || !(*pBrushItem == *pGraphicBrush) )
{ {
delete pGraphicBrush; delete pGraphicBrush;
pGraphicBrush = static_cast<SvxBrushItem*>(pBrushItem->Clone()); pGraphicBrush = static_cast<SvxBrushItem*>(pBrushItem->Clone());

View File

@ -320,7 +320,7 @@ ContextHandlerRef WorksheetFragment::onCreateContext( sal_Int32 nElement, const
case XLS_TOKEN( oleObjects ): case XLS_TOKEN( oleObjects ):
if ( getCurrentElement() == XLS_TOKEN( controls ) ) if ( getCurrentElement() == XLS_TOKEN( controls ) )
{ {
if( aMceState.empty() || ( !aMceState.empty() && aMceState.back() == MCE_STARTED ) ) if( aMceState.empty() || aMceState.back() == MCE_STARTED )
{ {
if ( getCurrentElement() == XLS_TOKEN( oleObjects ) ) importOleObject( rAttribs ); if ( getCurrentElement() == XLS_TOKEN( oleObjects ) ) importOleObject( rAttribs );
else else

View File

@ -3107,7 +3107,7 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
if (aCell.maBaseCell.meType == CELLTYPE_FORMULA) if (aCell.maBaseCell.meType == CELLTYPE_FORMULA)
{ {
ScFormulaCell* pFormulaCell = aCell.maBaseCell.mpFormula; ScFormulaCell* pFormulaCell = aCell.maBaseCell.mpFormula;
if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell)) if (!bIsMatrix || bIsFirstMatrixCell)
{ {
if (!mpCompileFormulaCxt) if (!mpCompileFormulaCxt)
{ {

View File

@ -556,7 +556,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
{ {
ScRange aDelRange; ScRange aDelRange;
bool bIsDel = rViewData.GetDelMark( aDelRange ); bool bIsDel = rViewData.GetDelMark( aDelRange );
if ( (!bIsDel || (bIsDel && aMarkRange != aDelRange)) && if ( (!bIsDel || aMarkRange != aDelRange) &&
bNewMarked && bNewMarked &&
nNewMarkCount > 0 && nNewMarkCount > 0 &&
!IsSameMarkCell() ) !IsSameMarkCell() )

View File

@ -545,7 +545,7 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor
const bool bEndRowEmpty = pDoc->IsBlockEmpty( nTab, nStartCol, nEndRow, nEndCol, nEndRow ); const bool bEndRowEmpty = pDoc->IsBlockEmpty( nTab, nStartCol, nEndRow, nEndCol, nEndRow );
const bool bEndColEmpty = pDoc->IsBlockEmpty( nTab, nEndCol, nStartRow, nEndCol, nEndRow ); const bool bEndColEmpty = pDoc->IsBlockEmpty( nTab, nEndCol, nStartRow, nEndCol, nEndRow );
bool bRow = ( ( nStartRow != nEndRow ) && ( bEndRowEmpty || ( !bEndRowEmpty && !bEndColEmpty ) ) ); bool bRow = ( ( nStartRow != nEndRow ) && ( bEndRowEmpty || !bEndColEmpty ) );
bool bCol = ( ( nStartCol != nEndCol ) && ( bEndColEmpty || nStartRow == nEndRow ) ); bool bCol = ( ( nStartCol != nEndCol ) && ( bEndColEmpty || nStartRow == nEndRow ) );
// find an empty row for entering the result // find an empty row for entering the result

View File

@ -175,7 +175,7 @@ void AnnotationTextWindow::KeyInput( const KeyEvent& rKeyEvt )
if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) ) if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
{ {
bool bIsProtected = mpAnnotationWindow->IsProtected(); bool bIsProtected = mpAnnotationWindow->IsProtected();
if (!bIsProtected || (bIsProtected && !EditEngine::DoesKeyChangeText(rKeyEvt)) ) if (!bIsProtected || !EditEngine::DoesKeyChangeText(rKeyEvt) )
bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); bDone = mpOutlinerView->PostKeyEvent( rKeyEvt );
} }

View File

@ -717,7 +717,7 @@ void SfxDispatcher::DoDeactivate_Impl(bool bMDI, SfxViewFrame* pNew)
for (size_t n=0; n<xImp->aChildWins.size();) for (size_t n=0; n<xImp->aChildWins.size();)
{ {
SfxChildWindow *pWin = pWorkWin->GetChildWindow_Impl( (sal_uInt16) ( xImp->aChildWins[n] & 0xFFFF ) ); SfxChildWindow *pWin = pWorkWin->GetChildWindow_Impl( (sal_uInt16) ( xImp->aChildWins[n] & 0xFFFF ) );
if (!pWin || (pWin && pWin->GetAlignment() == SfxChildAlignment::NOALIGNMENT)) if (!pWin || pWin->GetAlignment() == SfxChildAlignment::NOALIGNMENT)
xImp->aChildWins.erase(xImp->aChildWins.begin()+n); xImp->aChildWins.erase(xImp->aChildWins.begin()+n);
else else
n++; n++;

View File

@ -1016,7 +1016,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern )
{ {
EnableControl_Impl(m_pSearchBtn); EnableControl_Impl(m_pSearchBtn);
EnableControl_Impl(m_pReplaceBtn); EnableControl_Impl(m_pReplaceBtn);
if (!bWriter || (bWriter && !m_pNotesBtn->IsChecked())) if (!bWriter || !m_pNotesBtn->IsChecked())
{ {
EnableControl_Impl(m_pSearchAllBtn); EnableControl_Impl(m_pSearchAllBtn);
EnableControl_Impl(m_pReplaceAllBtn); EnableControl_Impl(m_pReplaceAllBtn);
@ -1416,7 +1416,7 @@ IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, ComboBox *, pEd )
{ {
EnableControl_Impl(m_pSearchBtn); EnableControl_Impl(m_pSearchBtn);
EnableControl_Impl(m_pReplaceBtn); EnableControl_Impl(m_pReplaceBtn);
if (!bWriter || (bWriter && !m_pNotesBtn->IsChecked())) if (!bWriter || !m_pNotesBtn->IsChecked())
{ {
EnableControl_Impl(m_pSearchAllBtn); EnableControl_Impl(m_pSearchAllBtn);
EnableControl_Impl(m_pReplaceAllBtn); EnableControl_Impl(m_pReplaceAllBtn);

View File

@ -209,7 +209,7 @@ void GradTransformer::VecToGrad(GradTransVector& rV, GradTransGradient& rG, Grad
{ {
case css::awt::GradientStyle_LINEAR : case css::awt::GradientStyle_LINEAR :
{ {
if(!bMoveSingle || (bMoveSingle && !bMoveFirst)) if(!bMoveSingle || !bMoveFirst)
{ {
basegfx::B2DVector aFullVec(aEndPos - aStartPos); basegfx::B2DVector aFullVec(aEndPos - aStartPos);
@ -245,7 +245,7 @@ void GradTransformer::VecToGrad(GradTransVector& rV, GradTransGradient& rG, Grad
} }
} }
if(!bMoveSingle || (bMoveSingle && bMoveFirst)) if(!bMoveSingle || bMoveFirst)
{ {
const basegfx::B2DVector aFullVec(aEndPos - aStartPos); const basegfx::B2DVector aFullVec(aEndPos - aStartPos);
const basegfx::B2DPoint aBottomLeft(aRange.getMinX(), aRange.getMaximum().getY()); const basegfx::B2DPoint aBottomLeft(aRange.getMinX(), aRange.getMaximum().getY());
@ -278,7 +278,7 @@ void GradTransformer::VecToGrad(GradTransVector& rV, GradTransGradient& rG, Grad
} }
case css::awt::GradientStyle_AXIAL : case css::awt::GradientStyle_AXIAL :
{ {
if(!bMoveSingle || (bMoveSingle && !bMoveFirst)) if(!bMoveSingle || !bMoveFirst)
{ {
basegfx::B2DVector aFullVec(aEndPos - aCenter); basegfx::B2DVector aFullVec(aEndPos - aCenter);
const basegfx::B2DVector aOldVec(basegfx::B2DPoint(aCenter.getX(), aRange.getMaximum().getY()) - aCenter); const basegfx::B2DVector aOldVec(basegfx::B2DPoint(aCenter.getX(), aRange.getMaximum().getY()) - aCenter);