Kaydet (Commit) 2dfe7702 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1441522 FontWorkGalleryDialog mpSdrView member is never null

Change-Id: If17d2984831b0881d39101648206accdadde12aa
Reviewed-on: https://gerrit.libreoffice.org/65163
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 12e878d3
......@@ -48,7 +48,7 @@ public:
FontworkBar(SfxViewShell* pViewShell);
virtual ~FontworkBar() override;
static void execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindings& rBindings );
static void execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindings& rBindings );
static void getState( SdrView const * pSdrView, SfxItemSet& rSet );
};
......
......@@ -51,7 +51,7 @@ public:
class SAL_WARN_UNUSED SVX_DLLPUBLIC FontWorkGalleryDialog : public weld::GenericDialogController
{
sal_uInt16 mnThemeId;
SdrView* mpSdrView;
SdrView& mrSdrView;
SdrObject** mppSdrObject;
SdrModel* mpDestModel;
......@@ -70,7 +70,7 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC FontWorkGalleryDialog : public weld::Generic
DECL_LINK(ClickOKHdl, weld::Button&, void );
public:
FontWorkGalleryDialog(weld::Window* pParent, SdrView* pView);
FontWorkGalleryDialog(weld::Window* pParent, SdrView& rView);
virtual ~FontWorkGalleryDialog() override;
// SJ: if the SdrObject** is set, the SdrObject is not inserted into the page when executing the dialog
......
......@@ -606,7 +606,7 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
case SID_FONTWORK_ALIGNMENT_FLOATER:
case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
svx::FontworkBar::execute( pView, rReq, rBindings );
svx::FontworkBar::execute( *pView, rReq, rBindings );
rReq.Ignore ();
break;
......
......@@ -470,7 +470,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
break;
case SID_FONTWORK_GALLERY_FLOATER:
svx::FontworkBar::execute( pView, rReq, GetViewFrame()->GetBindings() );
svx::FontworkBar::execute(*pView, rReq, GetViewFrame()->GetBindings());
rReq.Ignore();
break;
}
......
......@@ -1284,7 +1284,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
case SID_DRAW_FONTWORK:
case SID_DRAW_FONTWORK_VERTICAL:
{
svx::FontworkBar::execute( mpView, rReq, GetViewFrame()->GetBindings() ); // SJ: can be removed (I think)
svx::FontworkBar::execute(*mpView, rReq, GetViewFrame()->GetBindings()); // SJ: can be removed (I think)
Cancel();
rReq.Done();
}
......@@ -3103,7 +3103,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
case SID_FONTWORK_ALIGNMENT_FLOATER:
case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
svx::FontworkBar::execute( mpDrawView.get(), rReq, GetViewFrame()->GetBindings() );
svx::FontworkBar::execute(*mpDrawView, rReq, GetViewFrame()->GetBindings());
Cancel();
rReq.Ignore ();
break;
......
......@@ -65,10 +65,10 @@ namespace svx
const int nColCount = 4;
const int nLineCount = 4;
FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView* pSdrView)
FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& rSdrView)
: GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog")
, mnThemeId(0xffff)
, mpSdrView(pSdrView)
, mrSdrView(rSdrView)
, mppSdrObject(nullptr)
, mpDestModel(nullptr)
, maCtlFavorites(m_xBuilder->weld_scrolled_window("ctlFavoriteswin"))
......@@ -191,20 +191,20 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
// only caller of ::SetSdrObjectRef. Only in that case mpDestModel seems
// to be the correct target SdrModel.
// If this is not used, the correct SdrModel seems to be the one from
// the mpSdrView that is used to insert (InsertObjectAtView below) the
// the mrSdrView that is used to insert (InsertObjectAtView below) the
// cloned SdrObject.
const bool bUseSpecialCalcMode(nullptr != mppSdrObject && nullptr != mpDestModel);
const bool bSdrViewInsertMode(nullptr != mpSdrView);
const bool bSdrViewInsertMode(true);
// center shape on current view
OutputDevice* pOutDev(mpSdrView->GetFirstOutputDevice());
OutputDevice* pOutDev(mrSdrView.GetFirstOutputDevice());
if(pOutDev && (bUseSpecialCalcMode || bSdrViewInsertMode))
{
// Clone directly to target SdrModel (may be different due to user/caller (!))
SdrObject* pNewObject(
pPage->GetObj(0)->CloneSdrObject(
bUseSpecialCalcMode ? *mpDestModel : mpSdrView->getSdrModelFromSdrView()));
bUseSpecialCalcMode ? *mpDestModel : mrSdrView.getSdrModelFromSdrView()));
// tdf#117629
// Since the 'old' ::CloneSdrObject also copies the SdrPage* the
......@@ -232,11 +232,11 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
}
else // bSdrViewInsertMode
{
SdrPageView* pPV(mpSdrView->GetSdrPageView());
SdrPageView* pPV(mrSdrView.GetSdrPageView());
if(nullptr != pPV)
if (nullptr != pPV)
{
mpSdrView->InsertObjectAtView( pNewObject, *pPV );
mrSdrView.InsertObjectAtView( pNewObject, *pPV );
}
else
{
......
......@@ -406,7 +406,7 @@ static void GetGeometryForCustomShape( SdrCustomShapeGeometryItem& rGeometryItem
}
void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindings& rBindings )
void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindings& rBindings )
{
const char* pStrResId = nullptr;
......@@ -415,7 +415,7 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindin
{
case SID_FONTWORK_GALLERY_FLOATER:
{
FontWorkGalleryDialog aDlg(rReq.GetFrameWeld(), pSdrView);
FontWorkGalleryDialog aDlg(rReq.GetFrameWeld(), rSdrView);
aDlg.run();
}
break;
......@@ -431,20 +431,20 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindin
}
if ( !aCustomShape.isEmpty() )
{
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
const SdrMarkList& rMarkList = rSdrView.GetMarkedObjectList();
const size_t nCount = rMarkList.GetMarkCount();
for( size_t i = 0; i < nCount; ++i )
{
SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
{
const bool bUndo = pSdrView->IsUndoEnabled();
const bool bUndo = rSdrView.IsUndoEnabled();
if( bUndo )
{
OUString aStr( SvxResId( RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE ) );
pSdrView->BegUndo( aStr );
pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
rSdrView.BegUndo(aStr);
rSdrView.AddUndo(rSdrView.GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
}
SdrCustomShapeGeometryItem aGeometryItem( pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
GetGeometryForCustomShape( aGeometryItem, aCustomShape );
......@@ -459,9 +459,9 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindin
}
pObj->BroadcastObjectChange();
if( bUndo )
pSdrView->EndUndo();
pSdrView->AdjustMarkHdl(); //HMH sal_True );
if (bUndo)
rSdrView.EndUndo();
rSdrView.AdjustMarkHdl(); //HMH sal_True );
rBindings.Invalidate( SID_FONTWORK_SHAPE_TYPE );
}
}
......@@ -510,26 +510,26 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindin
if ( !pStrResId )
pStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_SAME_LETTER_HEIGHT;
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
const SdrMarkList& rMarkList = rSdrView.GetMarkedObjectList();
const size_t nCount = rMarkList.GetMarkCount();
for( size_t i = 0; i < nCount; ++i )
{
SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
{
const bool bUndo = pSdrView->IsUndoEnabled();
const bool bUndo = rSdrView.IsUndoEnabled();
if( bUndo )
{
OUString aStr( SvxResId( pStrResId ) );
pSdrView->BegUndo( aStr );
pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
rSdrView.BegUndo(aStr);
rSdrView.AddUndo(rSdrView.GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
}
SdrCustomShapeGeometryItem aGeometryItem( pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
impl_execute( rReq, aGeometryItem, pObj );
pObj->SetMergedItem( aGeometryItem );
pObj->BroadcastObjectChange();
if( bUndo )
pSdrView->EndUndo();
if (bUndo)
rSdrView.EndUndo();
}
}
}
......
......@@ -341,7 +341,7 @@ void SwDrawShell::Execute(SfxRequest &rReq)
case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
case SID_FONTWORK_ALIGNMENT_FLOATER:
case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
svx::FontworkBar::execute( pSdrView, rReq, rBnd );
svx::FontworkBar::execute(*pSdrView, rReq, rBnd);
rReq.Ignore ();
break;
......
......@@ -152,10 +152,10 @@ void SwView::ExecDraw(SfxRequest& rReq)
m_pWrtShell->MakeDrawView();
pSdrView = m_pWrtShell->GetDrawView();
if ( pSdrView )
if (pSdrView)
{
SdrObject* pObj = nullptr;
svx::FontWorkGalleryDialog aDlg(rWin.GetFrameWeld(), pSdrView);
svx::FontWorkGalleryDialog aDlg(rWin.GetFrameWeld(), *pSdrView);
aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
aDlg.run();
if ( pObj )
......
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