summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-11-12 17:07:22 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-11-14 08:52:21 +0000
commitaa3f954222a270d3e2fa531badd2fa7febd30338 (patch)
treef9921a240795044f00ce61718d052c26ebbc8ae0 /sw
parent90a77e9c13eb9b2aa6e83653d9d2d1409bc47f36 (diff)
coverity#703927 Unchecked return value
make these less odd and simply return the thing they selected, rather than a bool that indicates that the rpObj arg was successfully set to non-null, so there's one flag to check not two which both mean the same thing. Change-Id: If70e412f98dea8b7114fb77f26a9c59aab93be50 Reviewed-on: https://gerrit.libreoffice.org/30794 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/draw/dpage.cxx8
-rw-r--r--sw/source/core/frmedt/fefly1.cxx24
-rw-r--r--sw/source/core/frmedt/feshview.cxx26
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx14
-rw-r--r--sw/source/uibase/uiview/viewdraw.cxx11
5 files changed, 38 insertions, 45 deletions
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index a144ea8d8eb7..3a46620eec33 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -183,11 +183,11 @@ bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
aPos = pWindow->PixelToLogic( aPos );
SdrPageView* pPV;
- SdrObject* pObj;
- if( pView->PickObj( aPos, 0, pObj, pPV, SdrSearchOptions::PICKMACRO ) &&
- dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
+ SdrObject* pObj = pView->PickObj(aPos, 0, pPV, SdrSearchOptions::PICKMACRO);
+ SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
+ if (pDrawObj)
{
- SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
+ SwFlyFrame *pFly = pDrawObj->GetFlyFrame();
const SwFormatURL &rURL = pFly->GetFormat()->GetURL();
OUString sText;
if( rURL.GetMap() )
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index c78fc49a49a7..fd11278b9d89 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -1453,7 +1453,6 @@ const SwFrameFormat* SwFEShell::IsURLGrfAtPos( const Point& rPt, OUString* pURL,
if( !Imp()->HasDrawView() )
return nullptr;
- SdrObject* pObj;
SdrPageView* pPV;
const SwFrameFormat* pRet = nullptr;
SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
@@ -1461,11 +1460,8 @@ const SwFrameFormat* SwFEShell::IsURLGrfAtPos( const Point& rPt, OUString* pURL,
const auto nOld = pDView->GetHitTolerancePixel();
pDView->SetHitTolerancePixel( 2 );
- SwVirtFlyDrawObj* pFlyObj(nullptr);
- if (pDView->PickObj(rPt, pDView->getHitTolLog(), pObj, pPV, SdrSearchOptions::PICKMACRO))
- {
- pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
- }
+ SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMACRO);
+ SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
if (pFlyObj)
{
SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
@@ -1529,15 +1525,11 @@ const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt,
if( !Imp()->HasDrawView() )
return nullptr;
- SdrObject* pObj;
SdrPageView* pPV;
SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
- SwVirtFlyDrawObj* pFlyObj(nullptr);
- if (pDView->PickObj(rPt, pDView->getHitTolLog(), pObj, pPV))
- {
- pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
- }
+ SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV);
+ SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
if (pFlyObj)
{
SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
@@ -1571,7 +1563,6 @@ const SwFrameFormat* SwFEShell::GetFormatFromObj( const Point& rPt, SwRect** pRe
if( Imp()->HasDrawView() )
{
- SdrObject* pObj;
SdrPageView* pPView;
SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
@@ -1580,7 +1571,8 @@ const SwFrameFormat* SwFEShell::GetFormatFromObj( const Point& rPt, SwRect** pRe
// tolerance for Drawing-SS
pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
- if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SdrSearchOptions::PICKMARKABLE ) )
+ SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
+ if (pObj)
{
// first check it:
if (SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
@@ -1693,7 +1685,6 @@ ObjCntType SwFEShell::GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const
if( Imp()->HasDrawView() )
{
- SdrObject* pObj;
SdrPageView* pPView;
SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
@@ -1702,7 +1693,8 @@ ObjCntType SwFEShell::GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const
// tolerance for Drawing-SS
pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
- if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SdrSearchOptions::PICKMARKABLE ) )
+ SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
+ if (pObj)
eType = GetObjCntType( *(rpObj = pObj) );
pDView->SetHitTolerancePixel( nOld );
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 0a84b479083f..3bda5e2b1344 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1257,12 +1257,11 @@ bool SwFEShell::IsObjSelectable( const Point& rPt )
bool bRet = false;
if( pDView )
{
- SdrObject* pObj;
SdrPageView* pPV;
const auto nOld = pDView->GetHitTolerancePixel();
pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
- bRet = pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV, SdrSearchOptions::PICKMARKABLE );
+ bRet = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE) != nullptr;
pDView->SetHitTolerancePixel( nOld );
}
return bRet;
@@ -1279,7 +1278,7 @@ SdrObject* SwFEShell::GetObjAt( const Point& rPt )
const auto nOld = pDView->GetHitTolerancePixel();
pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
- pDView->PickObj( rPt, pDView->getHitTolLog(), pRet, pPV, SdrSearchOptions::PICKMARKABLE );
+ pRet = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE);
pDView->SetHitTolerancePixel( nOld );
}
return pRet;
@@ -1294,16 +1293,16 @@ bool SwFEShell::ShouldObjectBeSelected(const Point& rPt)
if(pDrawView)
{
- SdrObject* pObj;
SdrPageView* pPV;
const auto nOld(pDrawView->GetHitTolerancePixel());
pDrawView->SetHitTolerancePixel(pDrawView->GetMarkHdlSizePixel()/2);
- bRet = pDrawView->PickObj(rPt, pDrawView->getHitTolLog(), pObj, pPV, SdrSearchOptions::PICKMARKABLE);
+ SdrObject* pObj = pDrawView->PickObj(rPt, pDrawView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE);
pDrawView->SetHitTolerancePixel(nOld);
- if ( bRet && pObj )
+ if (pObj)
{
+ bRet = true;
const IDocumentDrawModelAccess& rIDDMA = getIDocumentDrawModelAccess();
// #i89920#
// Do not select object in background which is overlapping this text
@@ -1382,8 +1381,8 @@ bool SwFEShell::ShouldObjectBeSelected(const Point& rPt)
{
SdrObject *pCandidate = pPage->GetObj(a);
- if (dynamic_cast<const SwVirtFlyDrawObj*>( pCandidate) != nullptr &&
- static_cast<SwVirtFlyDrawObj*>(pCandidate)->GetCurrentBoundRect().IsInside(rPt) )
+ SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pCandidate);
+ if (pDrawObj && pDrawObj->GetCurrentBoundRect().IsInside(rPt))
{
bRet = false;
}
@@ -2749,15 +2748,15 @@ SwChainRet SwFEShell::Chainable( SwRect &rRect, const SwFrameFormat &rSource,
SwChainRet nRet = SwChainRet::NOT_FOUND;
if( Imp()->HasDrawView() )
{
- SdrObject* pObj;
SdrPageView* pPView;
SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
const auto nOld = pDView->GetHitTolerancePixel();
pDView->SetHitTolerancePixel( 0 );
- if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SdrSearchOptions::PICKMARKABLE ) &&
- dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
+ SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
+ SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
+ if (pDrawObj)
{
- SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
+ SwFlyFrame *pFly = pDrawObj->GetFlyFrame();
rRect = pFly->Frame();
// Target and source should not be equal and the list
@@ -2782,12 +2781,11 @@ SwChainRet SwFEShell::Chain( SwFrameFormat &rSource, const Point &rPt )
if ( nErr == SwChainRet::OK )
{
StartAllAction();
- SdrObject* pObj;
SdrPageView* pPView;
SwDrawView *pDView = Imp()->GetDrawView();
const auto nOld = pDView->GetHitTolerancePixel();
pDView->SetHitTolerancePixel( 0 );
- pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SdrSearchOptions::PICKMARKABLE );
+ SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
pDView->SetHitTolerancePixel( nOld );
SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 68b2c69df57e..e8665d2466a7 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -466,10 +466,12 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier )
}
else
{
- SdrObject* pObj; SdrPageView* pPV;
+ SdrPageView* pPV = nullptr;
pSdrView->SetHitTolerancePixel( HIT_PIX );
- if ( bNotInSelObj && bExecHyperlinks &&
- pSdrView->PickObj( rLPt, pSdrView->getHitTolLog(), pObj, pPV, SdrSearchOptions::PICKMACRO ))
+ SdrObject* pObj = (bNotInSelObj && bExecHyperlinks) ?
+ pSdrView->PickObj(rLPt, pSdrView->getHitTolLog(), pPV, SdrSearchOptions::PICKMACRO) :
+ nullptr;
+ if (pObj)
{
SdrObjMacroHitRec aTmp;
aTmp.aPos = rLPt;
@@ -4379,9 +4381,9 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
if ((PixelToLogic(m_aStartPos).Y() == (aDocPos.Y())) && (PixelToLogic(m_aStartPos).X() == (aDocPos.X())))//To make sure it was not moved
{
- SdrObject* pObj;
- SdrPageView* pPV;
- if (pSdrView && pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SdrSearchOptions::ALSOONMASTER ))
+ SdrPageView* pPV = nullptr;
+ SdrObject* pObj = pSdrView ? pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER) : nullptr;
+ if (pObj)
{
SwFrameFormat* pFormat = GetUserCall(pObj)->GetFormat();
SwFrameFormat* pShapeFormat = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_FLYFRMFMT);
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index dbe74d50549a..2b93959cfe86 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -457,7 +457,6 @@ static bool lcl_isTextBox(SdrObject* pObject)
bool SwView::EnterDrawTextMode(const Point& aDocPos)
{
- SdrObject* pObj;
SdrPageView* pPV;
SwWrtShell *pSh = &GetWrtShell();
SdrView *pSdrView = pSh->GetDrawView();
@@ -468,16 +467,18 @@ bool SwView::EnterDrawTextMode(const Point& aDocPos)
sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
pSdrView->SetHitTolerancePixel( 2 );
- if( pSdrView->IsMarkedHit( aDocPos ) &&
- !pSdrView->PickHandle( aDocPos ) && IsTextTool() &&
- pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SdrSearchOptions::PICKTEXTEDIT ) &&
+ SdrObject* pObj = (pSdrView->IsMarkedHit(aDocPos) &&
+ !pSdrView->PickHandle(aDocPos) && IsTextTool()) ?
+ pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pPV, SdrSearchOptions::PICKTEXTEDIT) :
+ nullptr;
+ if (pObj &&
// To allow SwDrawVirtObj text objects to be activated, allow their type, too.
( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr ||
( dynamic_cast< const SwDrawVirtObj *>( pObj ) != nullptr &&
dynamic_cast< const SdrTextObj *>(&static_cast<SwDrawVirtObj*>(pObj)->GetReferencedObj() ) != nullptr ) ) &&
- m_pWrtShell->IsSelObjProtected(FlyProtectFlags::Content) == FlyProtectFlags::NONE )
+ m_pWrtShell->IsSelObjProtected(FlyProtectFlags::Content) == FlyProtectFlags::NONE)
{
// Refuse to edit editeng text of the shape if it has textbox attached.
if (!lcl_isTextBox(pObj))