diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-02-20 16:29:19 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-02-21 13:28:28 +0000 |
commit | 6cb076f6b08668cf2a0490fe17ce34e74969702a (patch) | |
tree | 9a3e312cadea1180b56d191a906f1d7d7109cc3e /sw/source/uibase/dbui | |
parent | b428a97d88b08fadd63039482c09c17a5fbac3be (diff) |
sw: check GetWrtShellPtr()
Change-Id: I8d99e9108f6163eafb7576603826f8d02a0ff416
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147336
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/uibase/dbui')
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 81544fe8eb2e..2f94b26b7063 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -919,49 +919,52 @@ static SfxObjectShell* lcl_CreateWorkingDocument( } SwView* pWorkView = static_cast< SwView* >( pWorkFrame->GetViewShell() ); - SwWrtShell* pWorkWrtShell = pWorkView->GetWrtShellPtr(); - pWorkWrtShell->GetViewOptions()->SetIdle( false ); - pWorkView->AttrChangedNotify(nullptr);// in order for SelectShell to be called - SwDoc* pWorkDoc = pWorkWrtShell->GetDoc(); - pWorkDoc->GetIDocumentUndoRedo().DoUndo( false ); - pWorkDoc->ReplaceDocumentProperties( *pSourceDoc ); - - // import print settings - const SwPrintData &rPrintData = pSourceDoc->getIDocumentDeviceAccess().getPrintData(); - pWorkDoc->getIDocumentDeviceAccess().setPrintData(rPrintData); - const JobSetup *pJobSetup = pSourceDoc->getIDocumentDeviceAccess().getJobsetup(); - if (pJobSetup) - pWorkDoc->getIDocumentDeviceAccess().setJobsetup(*pJobSetup); - - if( aType == WorkingDocType::TARGET ) - { - assert( !ppDBManager ); - pWorkDoc->SetInMailMerge( true ); - pWorkWrtShell->SetLabelDoc( false ); - } - else + + if (SwWrtShell* pWorkWrtShell = pWorkView->GetWrtShellPtr()) { - // We have to swap the DBmanager of the new doc, so we also need input - assert(ppDBManager && *ppDBManager); - SwDBManager *pWorkDBManager = pWorkDoc->GetDBManager(); - pWorkDoc->SetDBManager( *ppDBManager ); - *ppDBManager = pWorkDBManager; + pWorkWrtShell->GetViewOptions()->SetIdle( false ); + pWorkView->AttrChangedNotify(nullptr);// in order for SelectShell to be called + SwDoc* pWorkDoc = pWorkWrtShell->GetDoc(); + pWorkDoc->GetIDocumentUndoRedo().DoUndo( false ); + pWorkDoc->ReplaceDocumentProperties( *pSourceDoc ); + + // import print settings + const SwPrintData &rPrintData = pSourceDoc->getIDocumentDeviceAccess().getPrintData(); + pWorkDoc->getIDocumentDeviceAccess().setPrintData(rPrintData); + const JobSetup *pJobSetup = pSourceDoc->getIDocumentDeviceAccess().getJobsetup(); + if (pJobSetup) + pWorkDoc->getIDocumentDeviceAccess().setJobsetup(*pJobSetup); - if( aType == WorkingDocType::SOURCE ) + if( aType == WorkingDocType::TARGET ) { - // the GetDBData call constructs the data, if it's missing - kind of const... - pWorkWrtShell->ChgDBData( const_cast<SwDoc*>(pSourceDoc)->GetDBData() ); - // some DocumentSettings are currently not copied by SwDoc::CreateCopy - pWorkWrtShell->SetLabelDoc( rSourceWrtShell.IsLabelDoc() ); - pWorkDoc->getIDocumentState().ResetModified(); + assert( !ppDBManager ); + pWorkDoc->SetInMailMerge( true ); + pWorkWrtShell->SetLabelDoc( false ); } else - pWorkDoc->getIDocumentLinksAdministration().EmbedAllLinks(); - } + { + // We have to swap the DBmanager of the new doc, so we also need input + assert(ppDBManager && *ppDBManager); + SwDBManager *pWorkDBManager = pWorkDoc->GetDBManager(); + pWorkDoc->SetDBManager( *ppDBManager ); + *ppDBManager = pWorkDBManager; + + if( aType == WorkingDocType::SOURCE ) + { + // the GetDBData call constructs the data, if it's missing - kind of const... + pWorkWrtShell->ChgDBData( const_cast<SwDoc*>(pSourceDoc)->GetDBData() ); + // some DocumentSettings are currently not copied by SwDoc::CreateCopy + pWorkWrtShell->SetLabelDoc( rSourceWrtShell.IsLabelDoc() ); + pWorkDoc->getIDocumentState().ResetModified(); + } + else + pWorkDoc->getIDocumentLinksAdministration().EmbedAllLinks(); + } - if( pView ) *pView = pWorkView; - if( pWrtShell ) *pWrtShell = pWorkWrtShell; - if( pDoc ) *pDoc = pWorkDoc; + if( pView ) *pView = pWorkView; + if( pWrtShell ) *pWrtShell = pWorkWrtShell; + if( pDoc ) *pDoc = pWorkDoc; + } return xWorkObjectShell.get(); } @@ -1223,8 +1226,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, else if( pTargetView ) { pTargetShell = pTargetView->GetWrtShellPtr(); - pTargetDoc = pTargetShell->GetDoc(); - xTargetDocShell = pTargetView->GetDocShell(); + if (pTargetShell) + { + pTargetDoc = pTargetShell->GetDoc(); + xTargetDocShell = pTargetView->GetDocShell(); + } } if( bCreateSingleFile ) |