summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/docsh4.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-10-21 10:23:39 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2018-10-22 14:38:04 +0200
commitc99732d59bc649ff9e79d880c7f328076864f64e (patch)
tree6cefee0123997d09f6c50de68373deb2ac17e0a0 /sc/source/ui/docshell/docsh4.cxx
parentc0a6a4c3ae0116ada31971f80bf383c5bc6c28e8 (diff)
tdf#120703 (PVS): redundant nullptr check
V668 There is no sense in testing the 'pMed' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. Change-Id: Ia630fd30d86e9b8f9ce85077edbd949274bbee70 Reviewed-on: https://gerrit.libreoffice.org/62125 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/ui/docshell/docsh4.cxx')
-rw-r--r--sc/source/ui/docshell/docsh4.cxx122
1 files changed, 60 insertions, 62 deletions
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index b09254aeb764..480b8d44e8e5 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -776,84 +776,82 @@ void ScDocShell::Execute( SfxRequest& rReq )
return ;
}
- if ( pMed ) // now execute in earnest...
+ // now execute in earnest...
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
+
+ // pOtherDocSh->DoClose() will be called explicitly later, but it is still more safe to use SfxObjectShellLock here
+ ScDocShell* pOtherDocSh = new ScDocShell;
+ SfxObjectShellLock aDocShTablesRef = pOtherDocSh;
+ pOtherDocSh->DoLoad( pMed );
+ ErrCode nErr = pOtherDocSh->GetErrorCode();
+ if (nErr)
+ ErrorHandler::HandleError( nErr ); // also warnings
+
+ if ( !pOtherDocSh->GetError() ) // only errors
{
- SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
-
- // pOtherDocSh->DoClose() will be called explicitly later, but it is still more safe to use SfxObjectShellLock here
- ScDocShell* pOtherDocSh = new ScDocShell;
- SfxObjectShellLock aDocShTablesRef = pOtherDocSh;
- pOtherDocSh->DoLoad( pMed );
- ErrCode nErr = pOtherDocSh->GetErrorCode();
- if (nErr)
- ErrorHandler::HandleError( nErr ); // also warnings
+ bool bHadTrack = ( m_aDocument.GetChangeTrack() != nullptr );
+#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
+ sal_uLong nStart = 0;
+ if ( nSlot == SID_DOCUMENT_MERGE && pChangeTrack )
+ {
+ nStart = pChangeTrack->GetActionMax() + 1;
+ }
+#endif
+ if ( nSlot == SID_DOCUMENT_COMPARE )
+ CompareDocument( pOtherDocSh->GetDocument() );
+ else
+ MergeDocument( pOtherDocSh->GetDocument() );
- if ( !pOtherDocSh->GetError() ) // only errors
+ // show "accept changes" dialog
+ //! get view for this document!
+ if ( !IsDocShared() )
{
- bool bHadTrack = ( m_aDocument.GetChangeTrack() != nullptr );
-#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
- sal_uLong nStart = 0;
- if ( nSlot == SID_DOCUMENT_MERGE && pChangeTrack )
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm )
{
- nStart = pChangeTrack->GetActionMax() + 1;
+ pViewFrm->ShowChildWindow( ScAcceptChgDlgWrapper::GetChildWindowId() ); //@51669
}
-#endif
- if ( nSlot == SID_DOCUMENT_COMPARE )
- CompareDocument( pOtherDocSh->GetDocument() );
- else
- MergeDocument( pOtherDocSh->GetDocument() );
-
- // show "accept changes" dialog
- //! get view for this document!
- if ( !IsDocShared() )
+ if ( pBindings )
{
- SfxViewFrame* pViewFrm = SfxViewFrame::Current();
- if ( pViewFrm )
- {
- pViewFrm->ShowChildWindow( ScAcceptChgDlgWrapper::GetChildWindowId() ); //@51669
- }
- if ( pBindings )
- {
- pBindings->Invalidate( FID_CHG_ACCEPT );
- }
+ pBindings->Invalidate( FID_CHG_ACCEPT );
}
+ }
- rReq.SetReturnValue( SfxInt32Item( nSlot, 0 ) ); //! ???????
- rReq.Done();
+ rReq.SetReturnValue( SfxInt32Item( nSlot, 0 ) ); //! ???????
+ rReq.Done();
- if (!bHadTrack) // newly turned on -> show as well
+ if (!bHadTrack) // newly turned on -> show as well
+ {
+ ScChangeViewSettings* pOldSet = m_aDocument.GetChangeViewSettings();
+ if ( !pOldSet || !pOldSet->ShowChanges() )
{
- ScChangeViewSettings* pOldSet = m_aDocument.GetChangeViewSettings();
- if ( !pOldSet || !pOldSet->ShowChanges() )
- {
- ScChangeViewSettings aChangeViewSet;
- aChangeViewSet.SetShowChanges(true);
- m_aDocument.SetChangeViewSettings(aChangeViewSet);
- }
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges(true);
+ m_aDocument.SetChangeViewSettings(aChangeViewSet);
}
+ }
#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
- else if ( nSlot == SID_DOCUMENT_MERGE && IsDocShared() && pChangeTrack )
+ else if ( nSlot == SID_DOCUMENT_MERGE && IsDocShared() && pChangeTrack )
+ {
+ sal_uLong nEnd = pChangeTrack->GetActionMax();
+ if ( nEnd >= nStart )
{
- sal_uLong nEnd = pChangeTrack->GetActionMax();
- if ( nEnd >= nStart )
- {
- // only show changes from merged document
- ScChangeViewSettings aChangeViewSet;
- aChangeViewSet.SetShowChanges( true );
- aChangeViewSet.SetShowAccepted( true );
- aChangeViewSet.SetHasActionRange();
- aChangeViewSet.SetTheActionRange( nStart, nEnd );
- m_aDocument.SetChangeViewSettings( aChangeViewSet );
-
- // update view
- PostPaintExtras();
- PostPaintGridAll();
- }
+ // only show changes from merged document
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges( true );
+ aChangeViewSet.SetShowAccepted( true );
+ aChangeViewSet.SetHasActionRange();
+ aChangeViewSet.SetTheActionRange( nStart, nEnd );
+ m_aDocument.SetChangeViewSettings( aChangeViewSet );
+
+ // update view
+ PostPaintExtras();
+ PostPaintGridAll();
}
-#endif
}
- pOtherDocSh->DoClose(); // delete happens with the Ref
+#endif
}
+ pOtherDocSh->DoClose(); // delete happens with the Ref
}
break;