diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-06-10 21:32:54 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-06-10 22:11:33 +0100 |
commit | 88b104f44acff8087dfe3833bb91c63604ced98b (patch) | |
tree | 6c7aee2f8cf919d994e1b9640ab8c1dd921837f8 /svtools | |
parent | dc4d9481f36a18db1dfe3b931780edbe32266e5f (diff) |
coverity#1302618 deref of NULL
on examination this PreparePaint virtual is only called from
SvTreeListBox::PaintEntry1
and PaintEntry1 is only called from SvImpLBox::Paint in a
for(sal_uInt16 n=0; n< nCount && pEntry; n++)
{
/*long nMaxRight=*/
pView->PaintEntry1
loop so pEntry always exists given that test. Re-jig things
so these families of method take a reference instead of a pointer
so verifying it cannot be NULL and a whole pile of else paths
fall away
Change-Id: Ied40acb1c2263c21b4447832f8cb86f64ed9e80d
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/contnr/svimpbox.cxx | 2 | ||||
-rw-r--r-- | svtools/source/contnr/svlbitm.cxx | 24 | ||||
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 52 | ||||
-rw-r--r-- | svtools/source/uno/treecontrolpeer.cxx | 30 |
4 files changed, 45 insertions, 63 deletions
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index 45f03f4e7317..8771f040b965 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -944,7 +944,7 @@ void SvImpLBox::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect for(sal_uInt16 n=0; n< nCount && pEntry; n++) { /*long nMaxRight=*/ - pView->PaintEntry1(pEntry, nY, rRenderContext, SvLBoxTabFlags::ALL, true ); + pView->PaintEntry1(*pEntry, nY, rRenderContext, SvLBoxTabFlags::ALL, true ); nY += nEntryHeight; pEntry = pView->NextVisible(pEntry); } diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx index 2721d27e7a89..aa4e86993b60 100644 --- a/svtools/source/contnr/svlbitm.cxx +++ b/svtools/source/contnr/svlbitm.cxx @@ -194,18 +194,12 @@ sal_uInt16 SvLBoxString::GetType() const void SvLBoxString::Paint( const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* /*pView*/, const SvTreeListEntry* pEntry) + const SvViewDataEntry* /*pView*/, const SvTreeListEntry& rEntry) { - if (pEntry) - { - DrawTextFlags nStyle = rDev.IsEnabled() ? DrawTextFlags::NONE : DrawTextFlags::Disable; - if (rDev.IsEntryMnemonicsEnabled()) - nStyle |= DrawTextFlags::Mnemonic; - rRenderContext.DrawText(Rectangle(rPos, GetSize(&rDev, pEntry)), maText, nStyle); - } - else - rRenderContext.DrawText(rPos, maText); - + DrawTextFlags nStyle = rDev.IsEnabled() ? DrawTextFlags::NONE : DrawTextFlags::Disable; + if (rDev.IsEntryMnemonicsEnabled()) + nStyle |= DrawTextFlags::Mnemonic; + rRenderContext.DrawText(Rectangle(rPos, GetSize(&rDev, &rEntry)), maText, nStyle); } SvLBoxItem* SvLBoxString::Create() const @@ -271,7 +265,7 @@ void SvLBoxBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry, } void SvLBoxBmp::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* /*pView*/, const SvTreeListEntry* /*pEntry*/) + const SvViewDataEntry* /*pView*/, const SvTreeListEntry& /*rEntry*/) { DrawImageFlags nStyle = rDev.IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable; rRenderContext.DrawImage(rPos, aBmp ,nStyle); @@ -338,7 +332,7 @@ bool SvLBoxButton::ClickHdl( SvTreeListBox*, SvTreeListEntry* pEntry ) void SvLBoxButton::Paint( const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* /*pView*/, const SvTreeListEntry* /*pEntry*/) + const SvViewDataEntry* /*pView*/, const SvTreeListEntry& /*rEntry*/) { SvBmp nIndex = eKind == SvLBoxButtonKind_staticImage ? SvBmp::STATICIMAGE : SvLBoxButtonData::GetIndex(nItemFlags); DrawImageFlags nStyle = eKind != SvLBoxButtonKind_disabledCheckbox && rDev.IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable; @@ -506,13 +500,13 @@ void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntr void SvLBoxContextBmp::Paint( const Point& _rPos, SvTreeListBox& _rDev, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) + const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) { // get the image. const Image& rImage = implGetImageStore(pView->IsExpanded() != m_pImpl->m_bExpanded); - bool _bSemiTransparent = pEntry && bool( SvTLEntryFlags::SEMITRANSPARENT & pEntry->GetFlags( ) ); + bool _bSemiTransparent = bool( SvTLEntryFlags::SEMITRANSPARENT & rEntry.GetFlags( ) ); // draw DrawImageFlags nStyle = _rDev.IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable; if (_bSemiTransparent) diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index afcd5375439c..2730afeae235 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -2864,16 +2864,16 @@ void SvTreeListBox::InvalidateEntry(SvTreeListEntry* pEntry) } } -long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::RenderContext& rRenderContext, +long SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::RenderContext& rRenderContext, SvLBoxTabFlags nTabFlags, bool bHasClipRegion) { Rectangle aRect; // multi purpose bool bHorSBar = pImp->HasHorScrollBar(); - PreparePaint(rRenderContext, pEntry); + PreparePaint(rRenderContext, rEntry); - pImp->UpdateContextBmpWidthMax(pEntry); + pImp->UpdateContextBmpWidthMax(&rEntry); if (nTreeFlags & SvTreeFlags::RECALCTABS) SetTabs(); @@ -2895,7 +2895,7 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render Color aBackupColor = rRenderContext.GetFillColor(); bool bCurFontIsSel = false; - bool bInUse = pEntry->HasInUseEmphasis(); + bool bInUse = rEntry.HasInUseEmphasis(); // if a ClipRegion was set from outside, we don't have to reset it const WinBits nWindowStyle = GetStyle(); const bool bResetClipRegion = !bHasClipRegion; @@ -2914,10 +2914,10 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render bHasClipRegion = true; } - SvViewDataEntry* pViewDataEntry = GetViewDataEntry( pEntry ); + SvViewDataEntry* pViewDataEntry = GetViewDataEntry( &rEntry ); sal_uInt16 nTabCount = aTabs.size(); - sal_uInt16 nItemCount = pEntry->ItemCount(); + sal_uInt16 nItemCount = rEntry.ItemCount(); sal_uInt16 nCurTab = 0; sal_uInt16 nCurItem = 0; @@ -2926,15 +2926,15 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render SvLBoxTab* pTab = aTabs[nCurTab]; sal_uInt16 nNextTab = nCurTab + 1; SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : 0; - SvLBoxItem* pItem = nCurItem < nItemCount ? pEntry->GetItem(nCurItem) : 0; + SvLBoxItem* pItem = nCurItem < nItemCount ? rEntry.GetItem(nCurItem) : 0; SvLBoxTabFlags nFlags = pTab->nFlags; Size aSize(SvLBoxItem::GetSize(pViewDataEntry, nCurItem)); - long nTabPos = GetTabPos(pEntry, pTab); + long nTabPos = GetTabPos(&rEntry, pTab); long nNextTabPos; if (pNextTab) - nNextTabPos = GetTabPos(pEntry, pNextTab); + nNextTabPos = GetTabPos(&rEntry, pNextTab); else { nNextTabPos = nMaxRight; @@ -3002,7 +3002,7 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render } else { - aWallpaper.SetColor(pEntry->GetBackColor()); + aWallpaper.SetColor(rEntry.GetBackColor()); } } @@ -3028,7 +3028,7 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render if (pNextTab) { long nRight; - nRight = GetTabPos(pEntry, pNextTab) - 1; + nRight = GetTabPos(&rEntry, pNextTab) - 1; if (nRight > nMaxRight) nRight = nMaxRight; aRect.Right() = nRight; @@ -3057,7 +3057,7 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render aEntryPos.Y() += (nTempEntryHeight - aSize.Height()) / 2; pViewDataEntry->SetPaintRectangle(aRect); - pItem->Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, pEntry); + pItem->Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry); // division line between tabs if (pNextTab && pItem->GetType() == SV_ITEM_ID_LBOXSTRING && @@ -3079,7 +3079,7 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render rRenderContext.SetFillColor(); Color aOldLineColor = rRenderContext.GetLineColor(); rRenderContext.SetLineColor(Color(COL_BLACK)); - aRect = GetFocusRect(pEntry, nLine); + aRect = GetFocusRect(&rEntry, nLine); aRect.Top()++; aRect.Bottom()--; rRenderContext.DrawRect(aRect); @@ -3095,15 +3095,15 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render sal_uInt16 nFirstDynTabPos; SvLBoxTab* pFirstDynamicTab = GetFirstDynamicTab(nFirstDynTabPos); - long nDynTabPos = GetTabPos(pEntry, pFirstDynamicTab); + long nDynTabPos = GetTabPos(&rEntry, pFirstDynamicTab); nDynTabPos += pImp->nNodeBmpTabDistance; nDynTabPos += pImp->nNodeBmpWidth / 2; nDynTabPos += 4; // 4 pixels of buffer, so the node bitmap is not too close // to the next tab - if( (!(pEntry->GetFlags() & SvTLEntryFlags::NO_NODEBMP)) && + if( (!(rEntry.GetFlags() & SvTLEntryFlags::NO_NODEBMP)) && (nWindowStyle & WB_HASBUTTONS) && pFirstDynamicTab && - (pEntry->HasChildren() || pEntry->HasChildrenOnDemand())) + (rEntry.HasChildren() || rEntry.HasChildrenOnDemand())) { // find first tab and check if the node bitmap extends into it sal_uInt16 nNextTab = nFirstDynTabPos; @@ -3114,21 +3114,21 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : 0; } while (pNextTab && pNextTab->IsDynamic()); - if (!pNextTab || (GetTabPos( pEntry, pNextTab ) > nDynTabPos)) + if (!pNextTab || (GetTabPos( &rEntry, pNextTab ) > nDynTabPos)) { - if ((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(pEntry) > 0) + if ((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(&rEntry) > 0) { - Point aPos(GetTabPos(pEntry, pFirstDynamicTab), nLine); + Point aPos(GetTabPos(&rEntry, pFirstDynamicTab), nLine); aPos.X() += pImp->nNodeBmpTabDistance; const Image* pImg = 0; - if (IsExpanded(pEntry)) + if (IsExpanded(&rEntry)) pImg = &pImp->GetExpandedNodeBmp(); else { - if ((!pEntry->HasChildren()) && pEntry->HasChildrenOnDemand() && - (!(pEntry->GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && + if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() && + (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && pImp->GetDontKnowNodeBmp().GetSizePixel().Width()) { pImg = &pImp->GetDontKnowNodeBmp( ); @@ -3155,12 +3155,12 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render if (IsEnabled()) nState |= ControlState::ENABLED; - if (IsExpanded(pEntry)) + if (IsExpanded(&rEntry)) aControlValue.setTristateVal(BUTTONVALUE_ON); //expanded node else { - if ((!pEntry->HasChildren()) && pEntry->HasChildrenOnDemand() && - (!(pEntry->GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && + if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() && + (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && pImp->GetDontKnowNodeBmp().GetSizePixel().Width()) { aControlValue.setTristateVal( BUTTONVALUE_DONTKNOW ); //dont know @@ -3188,7 +3188,7 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry, long nLine, vcl::Render return 0; // nRowLen; } -void SvTreeListBox::PreparePaint(vcl::RenderContext& /*rRenderContext*/, SvTreeListEntry* /*pEntry*/) +void SvTreeListBox::PreparePaint(vcl::RenderContext& /*rRenderContext*/, SvTreeListEntry& /*rEntry*/) { } diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index fc65129125d0..864cc56f5469 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -116,7 +116,7 @@ public: OUString GetGraphicURL() const { return maGraphicURL;} void SetGraphicURL( const OUString& rGraphicURL ); virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE; + const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) SAL_OVERRIDE; SvLBoxItem* Create() const SAL_OVERRIDE; void Clone( SvLBoxItem* pSource ) SAL_OVERRIDE; @@ -1593,30 +1593,18 @@ UnoTreeListItem::~UnoTreeListItem() void UnoTreeListItem::Paint( - const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* /*pView*/, const SvTreeListEntry* pEntry) + const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* /*pView*/, const SvTreeListEntry& rEntry) { Point aPos(rPos); - if (pEntry) + Size aSize(GetSize(&rDev, &rEntry)); + if (!!maImage) { - Size aSize(GetSize(&rDev, pEntry)); - if (!!maImage) - { - rRenderContext.DrawImage(aPos, maImage, rDev.IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable); - int nWidth = maImage.GetSizePixel().Width() + 6; - aPos.X() += nWidth; - aSize.Width() -= nWidth; - } - rRenderContext.DrawText(Rectangle(aPos,aSize),maText, rDev.IsEnabled() ? DrawTextFlags::NONE : DrawTextFlags::Disable); - } - else - { - if (!!maImage) - { - rRenderContext.DrawImage(aPos, maImage, rDev.IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable); - aPos.X() += maImage.GetSizePixel().Width() + 6; - } - rRenderContext.DrawText(aPos, maText); + rRenderContext.DrawImage(aPos, maImage, rDev.IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable); + int nWidth = maImage.GetSizePixel().Width() + 6; + aPos.X() += nWidth; + aSize.Width() -= nWidth; } + rRenderContext.DrawText(Rectangle(aPos,aSize),maText, rDev.IsEnabled() ? DrawTextFlags::NONE : DrawTextFlags::Disable); } |