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

coverity#1326267 Unchecked dynamic_cast

Change-Id: I93e68a9e19ba927a958a7d0b12607ec7bf4a40e1
üst 32d573cd
...@@ -742,18 +742,17 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -742,18 +742,17 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
m_aTimer.SetTimeout( 120 ); m_aTimer.SetTimeout( 120 );
SwDocShell* pDocSh = dynamic_cast<SwDocShell*>( _pFrame->GetObjectShell() ); SwDocShell& rDocSh = dynamic_cast<SwDocShell&>(*_pFrame->GetObjectShell());
OSL_ENSURE( pDocSh, "view without DocShell." ); bool bOldModifyFlag = rDocSh.IsEnableSetModified();
bool bOldModifyFlag = pDocSh->IsEnableSetModified(); if (bOldModifyFlag)
if(bOldModifyFlag) rDocSh.EnableSetModified( false );
pDocSh->EnableSetModified( false );
// HACK: SwDocShell has some cached font info, VCL informs about font updates, // HACK: SwDocShell has some cached font info, VCL informs about font updates,
// but loading of docs with embedded fonts happens after SwDocShell is created // but loading of docs with embedded fonts happens after SwDocShell is created
// but before SwEditWin (which handles the VCL event) is created. So update // but before SwEditWin (which handles the VCL event) is created. So update
// manually. // manually.
if( pDocSh->GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS )) if (rDocSh.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
pDocSh->UpdateFontList(); rDocSh.UpdateFontList();
bool bWebDShell = dynamic_cast< const SwWebDocShell *>( pDocSh ) != nullptr; bool bWebDShell = dynamic_cast<const SwWebDocShell*>(&rDocSh) != nullptr;
const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(bWebDShell); const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(bWebDShell);
SwViewOption aUsrPref( *pUsrPref); SwViewOption aUsrPref( *pUsrPref);
...@@ -785,19 +784,17 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -785,19 +784,17 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
} }
SAL_INFO( "sw.ui", "before create WrtShell" ); SAL_INFO( "sw.ui", "before create WrtShell" );
if(dynamic_cast<SwView*>( pExistingSh) ) if (SwView *pView = dynamic_cast<SwView*>(pExistingSh))
{ {
m_pWrtShell = new SwWrtShell( *static_cast<SwView*>(pExistingSh)->m_pWrtShell, m_pWrtShell = new SwWrtShell(*pView->m_pWrtShell, m_pEditWin, *this);
m_pEditWin, *this);
} }
else if( dynamic_cast<SwWrtShell*>( pDocSh->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() ) ) else if (SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(rDocSh.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()))
{ {
m_pWrtShell = new SwWrtShell( *static_cast<SwWrtShell*>(pDocSh->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()), m_pWrtShell = new SwWrtShell(*pWrtShell, m_pEditWin, *this);
m_pEditWin, *this);
} }
else else
{ {
SwDoc& rDoc = *static_cast<SwDocShell*>(pDocSh)->GetDoc(); SwDoc& rDoc = *static_cast<SwDocShell&>(rDocSh).GetDoc();
if( !bOldShellWasSrcView && bWebDShell && !m_bOldShellWasPagePreview ) if( !bOldShellWasSrcView && bWebDShell && !m_bOldShellWasPagePreview )
aUsrPref.setBrowseMode( true ); aUsrPref.setBrowseMode( true );
...@@ -810,7 +807,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -810,7 +807,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
aUsrPref.SetZoomType( SvxZoomType::PERCENT ); aUsrPref.SetZoomType( SvxZoomType::PERCENT );
aUsrPref.SetZoom( 100 ); aUsrPref.SetZoom( 100 );
} }
if(pDocSh->IsPreview()) if (rDocSh.IsPreview())
{ {
aUsrPref.SetZoomType( SvxZoomType::WHOLEPAGE ); aUsrPref.SetZoomType( SvxZoomType::WHOLEPAGE );
aUsrPref.SetViewLayoutBookMode( false ); aUsrPref.SetViewLayoutBookMode( false );
...@@ -859,7 +856,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -859,7 +856,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
// no margin for OLE! // no margin for OLE!
Size aBrwsBorder; Size aBrwsBorder;
if( SfxObjectCreateMode::EMBEDDED != pDocSh->GetCreateMode() ) if( SfxObjectCreateMode::EMBEDDED != rDocSh.GetCreateMode() )
aBrwsBorder = GetMargin(); aBrwsBorder = GetMargin();
m_pWrtShell->SetBrowseBorder( aBrwsBorder ); m_pWrtShell->SetBrowseBorder( aBrwsBorder );
...@@ -879,8 +876,8 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -879,8 +876,8 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
aUsrPref.SetViewVRuler(false); aUsrPref.SetViewVRuler(false);
} }
StartListening( *pViewFrame, true ); StartListening(*pViewFrame, true);
StartListening( *pDocSh, true ); StartListening(rDocSh, true);
// Set Zoom-factor from HRuler // Set Zoom-factor from HRuler
Fraction aZoomFract( aUsrPref.GetZoom(), 100 ); Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
...@@ -897,7 +894,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -897,7 +894,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
m_pVRuler->SetLineHeight( 551 ); // default line height m_pVRuler->SetLineHeight( 551 ); // default line height
// Set DocShell // Set DocShell
pDocSh->SetView( this ); rDocSh.SetView(this);
SW_MOD()->SetView( this ); SW_MOD()->SetView( this );
m_pPostItMgr = new SwPostItMgr(this); m_pPostItMgr = new SwPostItMgr(this);
...@@ -910,9 +907,9 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -910,9 +907,9 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
// Set AttrChangedNotify link // Set AttrChangedNotify link
m_pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify)); m_pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify));
if( pDocSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && if (rDocSh.GetCreateMode() == SfxObjectCreateMode::EMBEDDED &&
!pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() ) !rDocSh.GetVisArea(ASPECT_CONTENT).IsEmpty())
SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),false); SetVisArea(rDocSh.GetVisArea(ASPECT_CONTENT),false);
SAL_WARN_IF( SAL_WARN_IF(
officecfg::Office::Common::Undo::Steps::get() <= 0, officecfg::Office::Common::Undo::Steps::get() <= 0,
...@@ -960,7 +957,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -960,7 +957,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
// No ResetModified, if there is already a view to this doc. // No ResetModified, if there is already a view to this doc.
SfxViewFrame* pVFrame = GetViewFrame(); SfxViewFrame* pVFrame = GetViewFrame();
SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh); SfxViewFrame* pFirst = SfxViewFrame::GetFirst(&rDocSh);
// Currently(360) the view is registered firstly after the CTOR, // Currently(360) the view is registered firstly after the CTOR,
// the following expression is also working if this changes. // the following expression is also working if this changes.
// If the modification cannot be canceled by undo, then do NOT set // If the modification cannot be canceled by undo, then do NOT set
...@@ -977,7 +974,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -977,7 +974,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
g_bNoInterrupt = bOld; g_bNoInterrupt = bOld;
// If a new GlobalDoc will be created, the navigator will also be generated. // If a new GlobalDoc will be created, the navigator will also be generated.
if( dynamic_cast<const SwGlobalDocShell*>(pDocSh) != nullptr && if( dynamic_cast<const SwGlobalDocShell*>(&rDocSh) != nullptr &&
!pVFrame->GetChildWindow( SID_NAVIGATOR )) !pVFrame->GetChildWindow( SID_NAVIGATOR ))
{ {
SfxBoolItem aNavi(SID_NAVIGATOR, true); SfxBoolItem aNavi(SID_NAVIGATOR, true);
...@@ -1004,8 +1001,8 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) ...@@ -1004,8 +1001,8 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
m_aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl)); m_aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl));
m_bAttrChgNotified = m_bAttrChgNotifiedWithRegistrations = false; m_bAttrChgNotified = m_bAttrChgNotifiedWithRegistrations = false;
if(bOldModifyFlag) if (bOldModifyFlag)
pDocSh->EnableSetModified(); rDocSh.EnableSetModified();
InvalidateBorder(); InvalidateBorder();
if( !m_pHScrollbar->IsVisible( true ) ) if( !m_pHScrollbar->IsVisible( true ) )
......
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