Kaydet (Commit) a208ece6 authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#120703 PVS: V560 A part of conditional expression is always true/false

Change-Id: I60bb778a88dd5619efd4858eb74d56d28616c777
Reviewed-on: https://gerrit.libreoffice.org/63520
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst cf6b3bec
......@@ -256,43 +256,39 @@ bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
}
}
}
else
else if (nX || nY)
{
// move the handle
if ( pHdl && ( nX || nY ) )
{
Point aStartPoint( pHdl->GetPos() );
Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) );
const SdrDragStat& rDragStat = rView.GetDragStat();
Point aStartPoint(pHdl->GetPos());
Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
const SdrDragStat& rDragStat = rView.GetDragStat();
// start dragging
rView.BegDragObj( aStartPoint, nullptr, pHdl, 0 );
// start dragging
rView.BegDragObj(aStartPoint, nullptr, pHdl, 0);
if ( rView.IsDragObj() )
{
bool const bWasNoSnap = rDragStat.IsNoSnap();
bool const bWasSnapEnabled = rView.IsSnapEnabled();
// switch snapping off
if ( !bWasNoSnap )
const_cast<SdrDragStat&>(rDragStat).SetNoSnap();
if ( bWasSnapEnabled )
rView.SetSnapEnabled(false);
rView.MovAction( aEndPoint );
rView.EndDragObj();
// restore snap
if ( !bWasNoSnap )
const_cast<SdrDragStat&>(rDragStat).SetNoSnap( bWasNoSnap );
if ( bWasSnapEnabled )
rView.SetSnapEnabled( bWasSnapEnabled );
}
// make moved handle visible
tools::Rectangle aVisRect( aEndPoint - Point( 100, 100 ), Size( 200, 200 ) );
rView.MakeVisible( aVisRect, rWindow );
if (rView.IsDragObj())
{
bool const bWasNoSnap = rDragStat.IsNoSnap();
bool const bWasSnapEnabled = rView.IsSnapEnabled();
// switch snapping off
if (!bWasNoSnap)
const_cast<SdrDragStat&>(rDragStat).SetNoSnap();
if (bWasSnapEnabled)
rView.SetSnapEnabled(false);
rView.MovAction(aEndPoint);
rView.EndDragObj();
// restore snap
if (!bWasNoSnap)
const_cast<SdrDragStat&>(rDragStat).SetNoSnap(bWasNoSnap);
if (bWasSnapEnabled)
rView.SetSnapEnabled(bWasSnapEnabled);
}
// make moved handle visible
tools::Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
rView.MakeVisible(aVisRect, rWindow);
}
}
else
......
......@@ -52,7 +52,7 @@ namespace {
char nSign = ( nValue / ( 1 << ( ( nLen - nInd - 1 ) * 4 ) ) ) % 16;
if ( nSign >= 0 && nSign <= 9 )
pBuf[nInd] = nSign + L'0';
else if ( nSign >= 10 && nSign <= 15 )
else if (nSign >= 10)
pBuf[nInd] = nSign - 10 + L'a';
nInd++;
......
......@@ -292,9 +292,8 @@ void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& )
// Check if some modes have changed so we have to update our menu images
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
bool bShowMenuImages = rSettings.GetUseImagesInMenus();
bool bUpdateImages = (bShowMenuImages != m_bShowMenuImages);
if ( bUpdateImages )
if (bShowMenuImages != m_bShowMenuImages)
{
m_bShowMenuImages = bShowMenuImages;
......@@ -302,7 +301,7 @@ void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& )
if ( pPopupMenu )
{
PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
if ( pVCLPopupMenu && bUpdateImages )
if (pVCLPopupMenu)
updateImagesPopupMenu( pVCLPopupMenu );
}
}
......
......@@ -415,7 +415,7 @@ void ScChartHelper::CreateProtectedChartListenersAndNotify( ScDocument* pDoc, co
}
}
if ( pModelObj && pModelObj->HasChangesListeners() )
if (pModelObj->HasChangesListeners())
{
tools::Rectangle aRectangle = pSdrOle2Obj->GetSnapRect();
ScRange aRange( pDoc->GetRange( nTab, aRectangle ) );
......
......@@ -1862,13 +1862,12 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
ScDocAttrIterator aTestIter( &rDoc, i, nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow );
ScRange aExtendRange( nMergeTestStartCol, nMergeTestStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i );
const ScPatternAttr* pPattern = nullptr;
const ScMergeFlagAttr* pMergeFlagAttr = nullptr;
while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != nullptr )
{
const ScMergeAttr* pMergeFlag = &pPattern->GetItem(ATTR_MERGE);
pMergeFlagAttr = &pPattern->GetItem(ATTR_MERGE_FLAG);
ScMF nNewFlags = pMergeFlagAttr->GetValue() & ( ScMF::Hor | ScMF::Ver );
if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver )
const ScMergeAttr& rMergeFlag = pPattern->GetItem(ATTR_MERGE);
const ScMergeFlagAttr& rMergeFlagAttr = pPattern->GetItem(ATTR_MERGE_FLAG);
ScMF nNewFlags = rMergeFlagAttr.GetValue() & (ScMF::Hor | ScMF::Ver);
if (rMergeFlag.IsMerged() || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver)
{
ScRange aRange( nTestCol, nTestRow1, i );
rDoc.ExtendOverlapped(aRange);
......@@ -2338,13 +2337,12 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
ScDocAttrIterator aTestIter( &rDoc, i, nUndoStartCol, nUndoStartRow, nMergeTestEndCol, nMergeTestEndRow );
ScRange aExtendRange( nUndoStartCol, nUndoStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i );
const ScPatternAttr* pPattern = nullptr;
const ScMergeFlagAttr* pMergeFlagAttr = nullptr;
while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != nullptr )
{
const ScMergeAttr* pMergeFlag = &pPattern->GetItem( ATTR_MERGE );
pMergeFlagAttr = &pPattern->GetItem( ATTR_MERGE_FLAG );
ScMF nNewFlags = pMergeFlagAttr->GetValue() & ( ScMF::Hor | ScMF::Ver );
if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver )
const ScMergeAttr& rMergeFlag = pPattern->GetItem(ATTR_MERGE);
const ScMergeFlagAttr& rMergeFlagAttr = pPattern->GetItem(ATTR_MERGE_FLAG);
ScMF nNewFlags = rMergeFlagAttr.GetValue() & (ScMF::Hor | ScMF::Ver);
if (rMergeFlag.IsMerged() || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver)
{
ScRange aRange( nTestCol, nTestRow1, i );
rDoc.ExtendOverlapped( aRange );
......
......@@ -95,8 +95,7 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument (
for (sal_uInt16 nMaster=0; nMaster<nMasterPageCount; nMaster++)
{
SdPage* pCandidate = rTargetDocument.GetMasterSdPage (nMaster, PageKind::Standard);
if (pMasterPage!=nullptr
&& pCandidate->GetName() == pMasterPage->GetName())
if (pCandidate->GetName() == pMasterPage->GetName())
{
bPageExists = true;
pNewMasterPage = pCandidate;
......
......@@ -490,14 +490,12 @@ bool SfxClassificationHelper::IsClassified(const uno::Reference<document::XDocum
SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(const uno::Reference<document::XDocumentProperties>& xSource,
const uno::Reference<document::XDocumentProperties>& xDestination)
{
bool bSourceClassified = SfxClassificationHelper::IsClassified(xSource);
if (!bSourceClassified)
if (!SfxClassificationHelper::IsClassified(xSource))
// No classification on the source side. Return early, regardless the
// state of the destination side.
return SfxClassificationCheckPasteResult::None;
bool bDestinationClassified = SfxClassificationHelper::IsClassified(xDestination);
if (bSourceClassified && !bDestinationClassified)
if (!SfxClassificationHelper::IsClassified(xDestination))
{
// Paste from a classified document to a non-classified one -> deny.
return SfxClassificationCheckPasteResult::TargetDocNotClassified;
......
......@@ -155,14 +155,14 @@ long BorderWidthImpl::GuessWidth( long nLine1, long nLine2, long nGap )
double nWidth1 = lcl_getGuessedWidth( nLine1, m_nRate1, bLine1Change );
if ( bLine1Change )
aToCompare.push_back( nWidth1 );
else if ( !bLine1Change && nWidth1 < 0 )
else if (nWidth1 < 0)
bInvalid = true;
bool bLine2Change = bool( m_nFlags & BorderWidthImplFlags::CHANGE_LINE2 );
double nWidth2 = lcl_getGuessedWidth( nLine2, m_nRate2, bLine2Change );
if ( bLine2Change )
aToCompare.push_back( nWidth2 );
else if ( !bLine2Change && nWidth2 < 0 )
else if (nWidth2 < 0)
bInvalid = true;
bool bGapChange = bool( m_nFlags & BorderWidthImplFlags::CHANGE_DIST );
......
......@@ -783,12 +783,12 @@ AccessibleControlShape * ChildrenManagerImpl::GetAccControlShapeFromModel(css::b
for (sal_Int32 index=0;index<count;index++)
{
AccessibleShape* pAccShape = maVisibleChildren[index].GetAccessibleShape();
if (pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == DRAWING_CONTROL)
{
::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape);
if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet)
if (pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId(pAccShape->GetXShape()) == DRAWING_CONTROL)
{
auto* pCtlAccShape = static_cast<::accessibility::AccessibleControlShape*>(pAccShape);
if (pCtlAccShape->GetControlModel() == pSet)
return pCtlAccShape;
}
}
}
return nullptr;
}
......
......@@ -1714,7 +1714,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
m_pVisibleCursor->Show(); // show again
}
m_eMvState = MV_NONE; // state for cursor travelling - GetCursorOfst
if( pTableFrame && Imp()->IsAccessible() )
if (Imp()->IsAccessible())
Imp()->InvalidateAccessibleCursorPosition( pTableFrame );
return;
}
......@@ -1957,6 +1957,8 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
} while( eFlags & SwCursorShell::SCROLLWIN );
assert(pFrame);
if( m_pBlockCursor )
RefreshBlockCursor();
......@@ -1984,7 +1986,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
m_eMvState = MV_NONE; // state for cursor travelling - GetCursorOfst
if( pFrame && Imp()->IsAccessible() )
if (Imp()->IsAccessible())
Imp()->InvalidateAccessibleCursorPosition( pFrame );
// switch from blinking cursor to read-only-text-selection cursor
......
......@@ -1314,8 +1314,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
{
if( !aTmpState.m_bPosCorr )
{
if ( !bRet
&& IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos
if ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos
&& !aTmpState.m_bFootnoteNoInfo )
{
const SwWrongList* pSmartTagList = pTextNd->GetSmartTags();
......@@ -1427,7 +1426,8 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
{
IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( );
sw::mark::IFieldmark* pFieldBookmark = pMarksAccess->getFieldmarkFor( aPos );
if( bCursorFoundExact && pTextNd && pFieldBookmark) {
if (bCursorFoundExact && pFieldBookmark)
{
rContentAtPos.eContentAtPos = IsAttrAtPos::FormControl;
rContentAtPos.aFnd.pFieldmark = pFieldBookmark;
bRet=true;
......
......@@ -446,7 +446,7 @@ namespace
bRet = false;
break;
}
} while ( pTextNd && pTextNd != pEndTextNd );
} while (pTextNd != pEndTextNd);
}
return bRet;
......
......@@ -1442,7 +1442,7 @@ void DocumentFieldsManager::SetFixFields( const DateTime* pNewDateTime )
SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
{
if( pFormatField && pFormatField->GetTextField() )
if (pFormatField->GetTextField())
{
bool bChgd = false;
switch( aType )
......
......@@ -1453,7 +1453,7 @@ void SwRangeRedline::CopyToSection()
if( pCSttNd )
{
SwTextFormatColl* pColl = (pCSttNd && pCSttNd->IsTextNode() )
SwTextFormatColl* pColl = pCSttNd->IsTextNode()
? pCSttNd->GetTextNode()->GetTextColl()
: pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD);
......
......@@ -1402,12 +1402,11 @@ bool SwDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPas
bool bRes = false;
const SfxAllItemSet aSet( GetPool() );
const SfxItemSet* pArgs = &aSet;
const SfxPoolItem* pItem = nullptr;
IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
const Sequence< sal_Int8 >& aPasswdHash( rIDRA.GetRedlinePassword() );
if (pArgs && SfxItemState::SET == pArgs->GetItemState( FN_REDLINE_PROTECT, false, &pItem )
if (SfxItemState::SET == aSet.GetItemState(FN_REDLINE_PROTECT, false, &pItem)
&& static_cast<const SfxBoolItem*>(pItem)->GetValue() == (aPasswdHash.getLength() != 0))
return false;
rPasswordHash = aPasswdHash;
......
......@@ -148,7 +148,7 @@ vcl::Window * nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::
pChild = pParent->GetWindow(GetWindowType::Next);
}
if (pChild && isContainerWindow(*pChild))
if (isContainerWindow(*pChild))
pChild = nextLogicalChildOfParent(pTopLevel, pChild);
return const_cast<vcl::Window *>(pChild);
......@@ -176,7 +176,7 @@ vcl::Window * prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::
pChild = pParent->GetWindow(GetWindowType::Prev);
}
if (pChild && isContainerWindow(*pChild))
if (isContainerWindow(*pChild))
pChild = prevLogicalChildOfParent(pTopLevel, pChild);
return const_cast<vcl::Window *>(pChild);
......
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