[Libreoffice-commits] core.git: sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Oct 22 12:38:27 UTC 2018
sc/source/ui/docshell/docsh4.cxx | 122 +++++++++++++++++++--------------------
1 file changed, 60 insertions(+), 62 deletions(-)
New commits:
commit c99732d59bc649ff9e79d880c7f328076864f64e
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Oct 21 10:23:39 2018 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Oct 22 14:38:04 2018 +0200
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 at collabora.com>
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
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;
More information about the Libreoffice-commits
mailing list