diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-06 10:12:29 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-10 12:23:42 +0100 |
commit | 065edb4c8e91170017df482843d0c3eb8d4db114 (patch) | |
tree | 1d030ec9868a56b375a563c9d6e6d81c6115d717 /vcl | |
parent | 0b34a5dd39e177ba99cd21b639d67ac8123b8458 (diff) |
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 <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/edit/texteng.cxx | 26 | ||||
-rw-r--r-- | vcl/source/treelist/svimpbox.cxx | 84 | ||||
-rw-r--r-- | vcl/source/treelist/treelistbox.cxx | 18 |
3 files changed, 57 insertions, 71 deletions
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index fd38f2413c57..a8fe3486be61 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -2000,25 +2000,21 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, tools: break; case PORTIONKIND_TAB: // for HideSelection() only Range, pSelection = 0. - if ( pSelStart ) + if ( pSelStart ) // also implies pSelEnd { const tools::Rectangle aTabArea( aTmpPos, Point( aTmpPos.X()+nTxtWidth, aTmpPos.Y()+mnCharHeight-1 ) ); - bool bDone = false; - if ( pSelStart ) + // is the Tab in the Selection??? + const TextPaM aTextStart(nPara, nIndex); + const TextPaM aTextEnd(nPara, nIndex + 1); + if ((aTextStart < *pSelEnd) && (aTextEnd > *pSelStart)) { - // is the Tab in the Selection??? - const TextPaM aTextStart( nPara, nIndex ); - const TextPaM aTextEnd( nPara, nIndex+1 ); - if ( ( aTextStart < *pSelEnd ) && ( aTextEnd > *pSelStart ) ) - { - const Color aOldColor = pOutDev->GetFillColor(); - pOutDev->SetFillColor( rStyleSettings.GetHighlightColor() ); - pOutDev->DrawRect( aTabArea ); - pOutDev->SetFillColor( aOldColor ); - bDone = true; - } + const Color aOldColor = pOutDev->GetFillColor(); + pOutDev->SetFillColor( + rStyleSettings.GetHighlightColor()); + pOutDev->DrawRect(aTabArea); + pOutDev->SetFillColor(aOldColor); } - if ( !bDone ) + else { pOutDev->Erase( aTabArea ); } diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx index 5b37c1b6960c..a70b99f4d421 100644 --- a/vcl/source/treelist/svimpbox.cxx +++ b/vcl/source/treelist/svimpbox.cxx @@ -2188,7 +2188,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) if( IsExpandable() && !pView->IsExpanded( pCursor ) ) pView->Expand( pCursor ); } - else if ( bIsCellFocusEnabled && pCursor ) + else if (bIsCellFocusEnabled) { if ( nCurTabPos < ( pView->TabCount() - 1 /*!2*/ ) ) { @@ -2219,7 +2219,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) case KEY_LEFT: { - if ( bIsCellFocusEnabled && pCursor ) + if (bIsCellFocusEnabled) { if ( nCurTabPos > FIRST_ENTRY_TAB ) { @@ -2394,24 +2394,19 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) break; case KEY_ADD: - if( pCursor ) + if (!pView->IsExpanded(pCursor)) + pView->Expand(pCursor); + if (bMod1) { - if( !pView->IsExpanded(pCursor)) - pView->Expand( pCursor ); - if( bMod1 ) + sal_uInt16 nRefDepth = pTree->GetDepth(pCursor); + SvTreeListEntry* pCur = pTree->Next(pCursor); + while (pCur && pTree->GetDepth(pCur) > nRefDepth) { - sal_uInt16 nRefDepth = pTree->GetDepth( pCursor ); - SvTreeListEntry* pCur = pTree->Next( pCursor ); - while( pCur && pTree->GetDepth(pCur) > nRefDepth ) - { - if( pCur->HasChildren() && !pView->IsExpanded(pCur)) - pView->Expand( pCur ); - pCur = pTree->Next( pCur ); - } + if (pCur->HasChildren() && !pView->IsExpanded(pCur)) + pView->Expand(pCur); + pCur = pTree->Next(pCur); } } - else - bKeyUsed = false; break; case KEY_A: @@ -2422,46 +2417,41 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) break; case KEY_SUBTRACT: - if( pCursor ) + if (pView->IsExpanded(pCursor)) + pView->Collapse(pCursor); + if (bMod1) { - if( pView->IsExpanded(pCursor)) - pView->Collapse( pCursor ); - if( bMod1 ) + // collapse all parents until we get to the root + SvTreeListEntry* pParentToCollapse = pTree->GetRootLevelParent(pCursor); + if (pParentToCollapse) { - // collapse all parents until we get to the root - SvTreeListEntry* pParentToCollapse = pTree->GetRootLevelParent(pCursor); - if( pParentToCollapse ) + sal_uInt16 nRefDepth; + // special case explorer: if the root only has a single + // entry, don't collapse the root entry + if (pTree->GetChildList(nullptr).size() < 2) { - sal_uInt16 nRefDepth; - // special case explorer: if the root only has a single - // entry, don't collapse the root entry - if (pTree->GetChildList(nullptr).size() < 2) + nRefDepth = 1; + pParentToCollapse = pCursor; + while (pTree->GetParent(pParentToCollapse) + && pTree->GetDepth(pTree->GetParent(pParentToCollapse)) > 0) { - nRefDepth = 1; - pParentToCollapse = pCursor; - while( pTree->GetParent(pParentToCollapse) && - pTree->GetDepth( pTree->GetParent(pParentToCollapse)) > 0) - { - pParentToCollapse = pTree->GetParent(pParentToCollapse); - } + pParentToCollapse = pTree->GetParent(pParentToCollapse); } - else - nRefDepth = 0; + } + else + nRefDepth = 0; - if( pView->IsExpanded(pParentToCollapse) ) - pView->Collapse( pParentToCollapse ); - SvTreeListEntry* pCur = pTree->Next( pParentToCollapse ); - while( pCur && pTree->GetDepth(pCur) > nRefDepth ) - { - if( pCur->HasChildren() && pView->IsExpanded(pCur) ) - pView->Collapse( pCur ); - pCur = pTree->Next( pCur ); - } + if (pView->IsExpanded(pParentToCollapse)) + pView->Collapse(pParentToCollapse); + SvTreeListEntry* pCur = pTree->Next(pParentToCollapse); + while (pCur && pTree->GetDepth(pCur) > nRefDepth) + { + if (pCur->HasChildren() && pView->IsExpanded(pCur)) + pView->Collapse(pCur); + pCur = pTree->Next(pCur); } } } - else - bKeyUsed = false; break; case KEY_DIVIDE : diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index dccdbda4db2f..667503bb7300 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -2674,17 +2674,17 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render SvViewDataEntry* pViewDataEntry = GetViewDataEntry( &rEntry ); - sal_uInt16 nTabCount = aTabs.size(); - sal_uInt16 nItemCount = rEntry.ItemCount(); - sal_uInt16 nCurTab = 0; - sal_uInt16 nCurItem = 0; + const size_t nTabCount = aTabs.size(); + const size_t nItemCount = rEntry.ItemCount(); + size_t nCurTab = 0; + size_t nCurItem = 0; while (nCurTab < nTabCount && nCurItem < nItemCount) { SvLBoxTab* pTab = aTabs[nCurTab].get(); - sal_uInt16 nNextTab = nCurTab + 1; + const size_t nNextTab = nCurTab + 1; SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab].get() : nullptr; - SvLBoxItem* pItem = nCurItem < nItemCount ? &rEntry.GetItem(nCurItem) : nullptr; + SvLBoxItem& rItem = rEntry.GetItem(nCurItem); SvLBoxTabFlags nFlags = pTab->nFlags; Size aSize(SvLBoxItem::GetSize(pViewDataEntry, nCurItem)); @@ -2715,7 +2715,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render Wallpaper aWallpaper = rRenderContext.GetBackground(); bool bSelTab = bool(nFlags & SvLBoxTabFlags::SHOW_SELECTION); - SvLBoxItemType nItemType = pItem->GetType(); + SvLBoxItemType nItemType = rItem.GetType(); if (pViewDataEntry->IsHighlighted() && bSelTab) { @@ -2811,10 +2811,10 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render aEntryPos.AdjustY((nTempEntryHeight - aSize.Height()) / 2 ); pViewDataEntry->SetPaintRectangle(aRect); - pItem->Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry); + rItem.Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry); // division line between tabs - if (pNextTab && pItem->GetType() == SvLBoxItemType::String && + if (pNextTab && rItem.GetType() == SvLBoxItemType::String && // not at the right edge of the window! aRect.Right() < nMaxRight) { |