diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-01-31 13:12:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-02-01 07:00:17 +0100 |
commit | d2101ec9402d067ec6fce1017c9ff6adbaf2808c (patch) | |
tree | d900ca0a847ae3d2a93a8cdb7bdd912c4e4b05f5 /sw | |
parent | 137df7cd67e5bb34cb75f716700d3c765a3efad2 (diff) |
make insert-new-doc dialog async
Change-Id: I4977fc6ef2c6da356051ac5573ed088707d3b311
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162834
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/app/docsh2.cxx | 103 |
3 files changed, 64 insertions, 52 deletions
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index d4d35f0d0dc0..7333b4ebefcd 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -104,7 +104,13 @@ short AbstractSwWordCountFloatDlg_Impl::Execute() short AbstractSwInsertAbstractDlg_Impl::Execute() { - return m_xDlg->run(); + assert(false); + return -1; +} + +bool AbstractSwInsertAbstractDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); } short SwAbstractSfxController_Impl::Execute() diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index b0283b603172..100833f79f67 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -104,13 +104,14 @@ public: class AbstractSwInsertAbstractDlg_Impl : public AbstractSwInsertAbstractDlg { - std::unique_ptr<SwInsertAbstractDlg> m_xDlg; + std::shared_ptr<SwInsertAbstractDlg> m_xDlg; public: - explicit AbstractSwInsertAbstractDlg_Impl(std::unique_ptr<SwInsertAbstractDlg> p) + explicit AbstractSwInsertAbstractDlg_Impl(std::shared_ptr<SwInsertAbstractDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; virtual sal_uInt8 GetLevel() const override ; virtual sal_uInt8 GetPara() const override ; }; diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 7079c40a3b99..87344ccedd43 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -750,62 +750,67 @@ void SwDocShell::Execute(SfxRequest& rReq) case FN_ABSTRACT_NEWDOC: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSwInsertAbstractDlg> pDlg(pFact->CreateSwInsertAbstractDlg(GetView()->GetFrameWeld())); - if(RET_OK == pDlg->Execute()) - { - sal_uInt8 nLevel = pDlg->GetLevel(); - sal_uInt8 nPara = pDlg->GetPara(); - SwDoc* pSmryDoc = new SwDoc(); - SfxObjectShellLock xDocSh(new SwDocShell(*pSmryDoc, SfxObjectCreateMode::STANDARD)); - xDocSh->DoInitNew(); - - bool bImpress = FN_ABSTRACT_STARIMPRESS == nWhich; - m_xDoc->Summary(*pSmryDoc, nLevel, nPara, bImpress); - if( bImpress ) + VclPtr<AbstractSwInsertAbstractDlg> pDlg(pFact->CreateSwInsertAbstractDlg(GetView()->GetFrameWeld())); + pDlg->StartExecuteAsync( + [this, pDlg, nWhich] (sal_Int32 nResult)->void { - WriterRef xWrt; - // mba: looks as if relative URLs don't make sense here - ::GetRTFWriter(std::u16string_view(), OUString(), xWrt); - SvMemoryStream *pStrm = new SvMemoryStream(); - pStrm->SetBufferSize( 16348 ); - SwWriter aWrt( *pStrm, *pSmryDoc ); - ErrCodeMsg eErr = aWrt.Write( xWrt ); - if( !eErr.IgnoreWarning() ) + if (nResult == RET_OK) { - uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext ); + sal_uInt8 nLevel = pDlg->GetLevel(); + sal_uInt8 nPara = pDlg->GetPara(); + SwDoc* pSmryDoc = new SwDoc(); + SfxObjectShellLock xDocSh(new SwDocShell(*pSmryDoc, SfxObjectCreateMode::STANDARD)); + xDocSh->DoInitNew(); + + bool bImpress = FN_ABSTRACT_STARIMPRESS == nWhich; + m_xDoc->Summary(*pSmryDoc, nLevel, nPara, bImpress); + if( bImpress ) + { + WriterRef xWrt; + // mba: looks as if relative URLs don't make sense here + ::GetRTFWriter(std::u16string_view(), OUString(), xWrt); + SvMemoryStream *pStrm = new SvMemoryStream(); + pStrm->SetBufferSize( 16348 ); + SwWriter aWrt( *pStrm, *pSmryDoc ); + ErrCodeMsg eErr = aWrt.Write( xWrt ); + if( !eErr.IgnoreWarning() ) + { + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext ); - uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); - pStrm->Seek( STREAM_SEEK_TO_END ); - pStrm->WriteChar( '\0' ); - pStrm->Seek( STREAM_SEEK_TO_BEGIN ); + uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) ); + pStrm->Seek( STREAM_SEEK_TO_END ); + pStrm->WriteChar( '\0' ); + pStrm->Seek( STREAM_SEEK_TO_BEGIN ); - uno::Sequence< sal_Int8 > aSeq( pStrm->TellEnd() ); - pStrm->ReadBytes( aSeq.getArray(), aSeq.getLength() ); + uno::Sequence< sal_Int8 > aSeq( pStrm->TellEnd() ); + pStrm->ReadBytes( aSeq.getArray(), aSeq.getLength() ); - uno::Sequence< beans::PropertyValue > aArgs{ - comphelper::makePropertyValue("RtfOutline", aSeq) - }; - xHelper->executeDispatch( xProv, "SendOutlineToImpress", OUString(), 0, aArgs ); + uno::Sequence< beans::PropertyValue > aArgs{ + comphelper::makePropertyValue("RtfOutline", aSeq) + }; + xHelper->executeDispatch( xProv, "SendOutlineToImpress", OUString(), 0, aArgs ); + } + else + ErrorHandler::HandleError( eErr ); + } + else + { + // Create new document + SfxViewFrame *pFrame = SfxViewFrame::LoadDocument( *xDocSh, SFX_INTERFACE_NONE ); + SwView *pCurrView = static_cast<SwView*>( pFrame->GetViewShell()); + + // Set document's title + OUString aTmp = SwResId(STR_ABSTRACT_TITLE) + GetTitle(); + xDocSh->SetTitle( aTmp ); + pCurrView->GetWrtShell().SetNewDoc(); + pFrame->Show(); + pSmryDoc->getIDocumentState().SetModified(); + } } - else - ErrorHandler::HandleError( eErr ); - } - else - { - // Create new document - SfxViewFrame *pFrame = SfxViewFrame::LoadDocument( *xDocSh, SFX_INTERFACE_NONE ); - SwView *pCurrView = static_cast<SwView*>( pFrame->GetViewShell()); - - // Set document's title - OUString aTmp = SwResId(STR_ABSTRACT_TITLE) + GetTitle(); - xDocSh->SetTitle( aTmp ); - pCurrView->GetWrtShell().SetNewDoc(); - pFrame->Show(); - pSmryDoc->getIDocumentState().SetModified(); + pDlg->disposeOnce(); } - - } + ); } break; case FN_OUTLINE_TO_CLIPBOARD: |