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