From 065edb4c8e91170017df482843d0c3eb8d4db114 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Tue, 6 Nov 2018 10:12:29 +0300 Subject: tdf#120703 PVS: V547 Expression is always true/false Change-Id: I0b3c407331bfa1fa0c5003250d327d4f26de3643 Reviewed-on: https://gerrit.libreoffice.org/63235 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- svx/source/accessibility/ShapeTypeHandler.cxx | 31 ++--- svx/source/svdraw/svddrgmt.cxx | 5 +- svx/source/svdraw/svdhdl.cxx | 6 +- svx/source/svdraw/svdpagv.cxx | 26 ++--- svx/source/table/svdotable.cxx | 82 ++++++------- svx/source/table/tablemodel.cxx | 4 +- svx/source/unodraw/unoshap3.cxx | 4 +- svx/source/unodraw/unoshtxt.cxx | 9 +- svx/source/xoutdev/xattr.cxx | 162 +++++++++++++------------- svx/source/xoutdev/xattr2.cxx | 7 +- 10 files changed, 146 insertions(+), 190 deletions(-) (limited to 'svx') diff --git a/svx/source/accessibility/ShapeTypeHandler.cxx b/svx/source/accessibility/ShapeTypeHandler.cxx index c569700ed0bc..e6454389c30f 100644 --- a/svx/source/accessibility/ShapeTypeHandler.cxx +++ b/svx/source/accessibility/ShapeTypeHandler.cxx @@ -269,33 +269,22 @@ OUString ShapeTypeHandler::CreateAccessibleBaseName (const uno::Reference(pShape->GetSdrObject())) { - SdrObject *pSdrObj = pShape->GetSdrObject(); - if (pSdrObj) + if (pCustomShape->IsTextPath()) + pResourceId = STR_ObjNameSingulFONTWORK; + else { - if(dynamic_cast( pSdrObj) != nullptr) - { - SdrObjCustomShape* pCustomShape = static_cast(pSdrObj); - if(pCustomShape) - { - if (pCustomShape->IsTextPath()) - pResourceId = STR_ObjNameSingulFONTWORK; - else - { - pResourceId = nullptr; - sName = pCustomShape->GetCustomShapeName(); - } - } - } + pResourceId = nullptr; + sName = pCustomShape->GetCustomShapeName(); } } - break; } + break; case DRAWING_TEXT: pResourceId = STR_ObjNameSingulTEXT; break; diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 6d099d6efb77..cb0c3d1fa2c5 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -168,10 +168,7 @@ void SdrDragEntrySdrObject::prepareCurrentState(SdrDragMethod& rDragMethod) if(mbModify) { - if(!mpClone) - { - mpClone = maOriginal.getFullDragClone(); - } + mpClone = maOriginal.getFullDragClone(); // apply original transformation, implemented at the DragMethods rDragMethod.applyCurrentTransformationToSdrObject(*mpClone); diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx index 7dc05bc1a086..a53725c6ee1e 100644 --- a/svx/source/svdraw/svdhdl.cxx +++ b/svx/source/svdraw/svdhdl.cxx @@ -2098,11 +2098,7 @@ void SdrHdlList::SetFocusHdl(SdrHdl* pNew) pActual->Touch(); } - if(pNew) - { - pNew->Touch(); - } - + pNew->Touch(); } } } diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 41158c70c2e5..6f2720601d77 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -788,7 +788,8 @@ bool SdrPageView::EnterGroup(SdrObject* pObj) void SdrPageView::LeaveOneGroup() { - if(!GetCurrentGroup()) + SdrObject* pLastGroup = GetCurrentGroup(); + if (!pLastGroup) return; bool bGlueInvalidate = GetView().ImpIsGlueVisible(); @@ -796,8 +797,7 @@ void SdrPageView::LeaveOneGroup() if(bGlueInvalidate) GetView().GlueInvalidate(); - SdrObject* pLastGroup = GetCurrentGroup(); - SdrObject* pParentGroup = GetCurrentGroup()->getParentSdrObjectFromSdrObject(); + SdrObject* pParentGroup = pLastGroup->getParentSdrObjectFromSdrObject(); SdrObjList* pParentList = GetPage(); if(pParentGroup) @@ -810,9 +810,8 @@ void SdrPageView::LeaveOneGroup() SetCurrentGroupAndList(pParentGroup, pParentList); // select the group we just left - if(pLastGroup) - if(GetView().GetSdrPageView()) - GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); + if (GetView().GetSdrPageView()) + GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); GetView().AdjustMarkHdl(); @@ -825,15 +824,13 @@ void SdrPageView::LeaveOneGroup() void SdrPageView::LeaveAllGroup() { - if(GetCurrentGroup()) + if (SdrObject* pLastGroup = GetCurrentGroup()) { bool bGlueInvalidate = GetView().ImpIsGlueVisible(); if(bGlueInvalidate) GetView().GlueInvalidate(); - SdrObject* pLastGroup = GetCurrentGroup(); - // deselect everything GetView().UnmarkAll(); @@ -841,14 +838,11 @@ void SdrPageView::LeaveAllGroup() SetCurrentGroupAndList(nullptr, GetPage()); // find and select uppermost group - if(pLastGroup) - { - while(pLastGroup->getParentSdrObjectFromSdrObject()) - pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject(); + while (pLastGroup->getParentSdrObjectFromSdrObject()) + pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject(); - if(GetView().GetSdrPageView()) - GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); - } + if (GetView().GetSdrPageView()) + GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); GetView().AdjustMarkHdl(); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 187f52af7a69..b800c7a06181 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -1169,46 +1169,43 @@ TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_ // get vertical edge number and check for a hit const bool bRTL = (GetWritingMode() == WritingMode_RL_TB); bool bVrtHit = false; - if( nX >= 0 ) + if( !bRTL ) { - if( !bRTL ) + while( rnX <= nColCount ) { - while( rnX <= nColCount ) + if( nX - aTol <= 0 ) { - if( nX - aTol <= 0 ) - { - bVrtHit = true; - break; - } + bVrtHit = true; + break; + } - if( rnX == nColCount ) - break; + if( rnX == nColCount ) + break; - nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); - if( nX < 0 ) - break; - rnX++; - } + nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); + if( nX < 0 ) + break; + rnX++; } - else + } + else + { + rnX = nColCount; + while( rnX >= 0 ) { - rnX = nColCount; - while( rnX >= 0 ) + if( nX - aTol <= 0 ) { - if( nX - aTol <= 0 ) - { - bVrtHit = true; - break; - } + bVrtHit = true; + break; + } - if( rnX == 0 ) - break; + if( rnX == 0 ) + break; - rnX--; - nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); - if( nX < 0 ) - break; - } + rnX--; + nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); + if( nX < 0 ) + break; } } @@ -1216,24 +1213,21 @@ TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_ // get vertical edge number and check for a hit bool bHrzHit = false; - if( nY >= 0 ) + while( rnY <= nRowCount ) { - while( rnY <= nRowCount ) + if( nY - aTol <= 0 ) { - if( nY - aTol <= 0 ) - { - bHrzHit = true; - break; - } + bHrzHit = true; + break; + } - if( rnY == nRowCount ) - break; + if( rnY == nRowCount ) + break; - nY -= mpImpl->mpLayouter->getRowHeight(rnY); - if( nY < 0 ) - break; - rnY++; - } + nY -= mpImpl->mpLayouter->getRowHeight(rnY); + if( nY < 0 ) + break; + rnY++; } // rnY is now the edge number above the pointer, if it was hit bVrtHit is also true diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index c35463b0c297..1b934d7731b1 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -979,7 +979,7 @@ void TableModel::optimize() if( bEmpty ) { - if( nCol > 0 ) try + try { const OUString sWidth("Width"); sal_Int32 nWidth1 = 0, nWidth2 = 0; @@ -1016,7 +1016,7 @@ void TableModel::optimize() if( bEmpty ) { - if( nRow > 0 ) try + try { const OUString sHeight("Height"); sal_Int32 nHeight1 = 0, nHeight2 = 0; diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx index 2d5871e00c1f..571a1d74ffb5 100644 --- a/svx/source/unodraw/unoshap3.cxx +++ b/svx/source/unodraw/unoshap3.cxx @@ -126,9 +126,7 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape if( dynamic_cast(pSdrShape) != nullptr ) { GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape ); - - if(pShape) - pShape->Create( pSdrShape, mxPage.get() ); + pShape->Create(pSdrShape, mxPage.get()); } else { diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 4dffab0d5906..287d2bd18b42 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -206,12 +206,9 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText mpText = pTextObj->getText( 0 ); } - if( mpModel ) - StartListening( *mpModel ); - if( mpView ) - StartListening( *mpView ); - if( mpObject ) - mpObject->AddObjectUser( *this ); + StartListening( *mpModel ); + StartListening( *mpView ); + mpObject->AddObjectUser( *this ); // Init edit mode state from shape info (IsTextEditActive()) mbShapeIsEditMode = IsEditMode(); diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 74912a9ded57..cafbe882ff37 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -1099,14 +1099,14 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const sal_uInt32 nCount, nSurrogate; - const SfxItemPool* pPool1 = &pModel->GetItemPool(); - if( !aUniqueName.isEmpty() && pPool1 ) + const SfxItemPool& rPool1 = pModel->GetItemPool(); + if (!aUniqueName.isEmpty()) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); + nCount = rPool1.GetItemCount2(XATTR_LINESTART); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate ); + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate); if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) { @@ -1124,11 +1124,11 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const if( !bForceNew ) { - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate ); + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate); if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) { @@ -1200,53 +1200,50 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const sal_Int32 nUserIndex = 1; const OUString aUser(SvxResId(RID_SVXSTR_LINEEND)); - if( pPool1 ) + nCount = rPool1.GetItemCount2(XATTR_LINESTART); + sal_uInt32 nSurrogate2; + + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); - sal_uInt32 nSurrogate2; + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate2); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + if (pItem && !pItem->GetName().isEmpty()) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate2 ); - - if( pItem && !pItem->GetName().isEmpty() ) + if (!bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue()) { - if( !bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } + } - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) - { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate2 ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) + { + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate2); - if( pItem && !pItem->GetName().isEmpty() ) + if (pItem && !pItem->GetName().isEmpty()) + { + if (!bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue()) { - if( !bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } } @@ -1353,14 +1350,14 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const sal_uInt16 nCount, nSurrogate; - const SfxItemPool* pPool1 = &pModel->GetItemPool(); - if( !aUniqueName.isEmpty() && pPool1 ) + const SfxItemPool& rPool1 = pModel->GetItemPool(); + if (!aUniqueName.isEmpty()) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); + nCount = rPool1.GetItemCount2(XATTR_LINESTART); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate ); + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate); if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) { @@ -1378,11 +1375,11 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const if( !bForceNew ) { - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate ); + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate); if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) { @@ -1454,53 +1451,50 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const sal_Int32 nUserIndex = 1; const OUString aUser(SvxResId(RID_SVXSTR_LINEEND)); - if( pPool1 ) + nCount = rPool1.GetItemCount2(XATTR_LINESTART); + sal_uInt32 nSurrogate2; + + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); - sal_uInt32 nSurrogate2; + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate2); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + if (pItem && !pItem->GetName().isEmpty()) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate2 ); - - if( pItem && !pItem->GetName().isEmpty() ) + if (!bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue()) { - if( !bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } + } - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) - { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate2 ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) + { + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate2); - if( pItem && !pItem->GetName().isEmpty() ) + if (pItem && !pItem->GetName().isEmpty()) + { + if (!bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue()) { - if( !bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } } diff --git a/svx/source/xoutdev/xattr2.cxx b/svx/source/xoutdev/xattr2.cxx index c8dc42be2a1c..3bf103d9469e 100644 --- a/svx/source/xoutdev/xattr2.cxx +++ b/svx/source/xoutdev/xattr2.cxx @@ -252,9 +252,7 @@ SfxPoolItem* XLineCapItem::Clone(SfxItemPool* /*pPool*/) const bool XLineCapItem::GetPresentation( SfxItemPresentation /*ePres*/, MapUnit /*eCoreUnit*/, MapUnit /*ePresUnit*/, OUString& rText, const IntlWrapper&) const { - rText.clear(); - - const char* pId = nullptr; + const char* pId; switch( GetValue() ) { @@ -271,8 +269,7 @@ bool XLineCapItem::GetPresentation( SfxItemPresentation /*ePres*/, MapUnit /*eCo break; } - if (pId) - rText = SvxResId(pId); + rText = SvxResId(pId); return true; } -- cgit