diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-01-17 12:42:42 +0100 |
---|---|---|
committer | pranavk <pranavk@collabora.co.uk> | 2018-01-18 14:00:04 +0100 |
commit | 4ca3356cedf32c6cc4ff142cbb8b76bfba40d2d4 (patch) | |
tree | 507c9cd4f2509a067ce6737ce02a059b47ddf74b /sw | |
parent | bf1e0f8ee19e1f0a499d8a85ffaf552ccd419811 (diff) |
lokdialog: Convert the Format -> Page... dialog to async exec.
This actually also converts the Style -> Edit Style... at the same time.
Change-Id: I4c09fcdfd7a543cce613eaa3620d0b623540d7e8
Reviewed-on: https://gerrit.libreoffice.org/48116
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/docsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/app/docst.cxx | 75 | ||||
-rw-r--r-- | sw/source/uibase/shells/basesh.cxx | 2 |
3 files changed, 46 insertions, 34 deletions
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index aed3fa37dc27..d71e1fe989a9 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -126,7 +126,8 @@ class SW_DLLPUBLIC SwDocShell const bool bNew, const OString& sPageId, SwWrtShell* pActShell = nullptr, - SfxRequest* pRequest = nullptr); + SfxRequest* pRequest = nullptr, + sal_uInt16 nSlot = 0); SAL_DLLPRIVATE void Delete(const OUString &rName, SfxStyleFamily nFamily); SAL_DLLPRIVATE void Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden); diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index 58e8c59130ef..41a21853194a 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -319,15 +319,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) if (sName.isEmpty() && m_xBasePool.get()) sName = SfxStyleDialog::GenerateUnusedName(*m_xBasePool); - Edit(sName, sParent, nFamily, nMask, true, OString(), nullptr, &rReq); - - // Update Watermark if new page style was created - if( nFamily == SfxStyleFamily::Page ) - { - SwWrtShell* pShell = GetWrtShell(); - const SfxWatermarkItem aWatermark = pShell->GetWatermark(); - pShell->SetWatermark( aWatermark ); - } + Edit(sName, sParent, nFamily, nMask, true, OString(), nullptr, &rReq, nSlot); } break; @@ -655,10 +647,11 @@ void SwDocShell::Edit( const bool bNew, const OString& sPage, SwWrtShell* pActShell, - SfxRequest* pRequest) + SfxRequest* pReq, + sal_uInt16 nSlot) { assert( GetWrtShell() ); - const bool bBasic = pRequest && pRequest->IsAPI(); + const bool bBasic = pReq && pReq->IsAPI(); SfxStyleSheetBase *pStyle = nullptr; bool bModified = m_pDoc->getIDocumentState().IsModified(); @@ -828,36 +821,52 @@ void SwDocShell::Edit( *(xTmp.get()), nFamily, sPage, pActShell ? pActShell : m_pWrtShell, bNew)); assert( pDlg ); - ApplyStyle aApplyStyleHelper(*this, bNew, xTmp, nFamily, pDlg.get(), m_xBasePool, bModified); - pDlg->SetApplyHdl(LINK(&aApplyStyleHelper, ApplyStyle, ApplyHdl)); + std::shared_ptr<ApplyStyle> pApplyStyleHelper(new ApplyStyle(*this, bNew, xTmp, nFamily, pDlg.get(), m_xBasePool, bModified)); + pDlg->SetApplyHdl(LINK(pApplyStyleHelper.get(), ApplyStyle, ApplyHdl)); - short nDlgRet = pDlg->Execute(); - - if (RET_OK == nDlgRet) + std::shared_ptr<SfxRequest> pRequest; + if (pReq) { - aApplyStyleHelper.apply(); + pRequest.reset(new SfxRequest(*pReq)); + pReq->Ignore(); // the 'old' request is not relevant any more } - if (bNew) - { - SwRewriter aRewriter; - aRewriter.AddRule(UndoArg1, xTmp->GetName()); - //Group the create style and change style operations together under the - //one "create style" comment - m_pWrtShell->EndUndo(nNewStyleUndoId, &aRewriter); - } + pDlg->StartExecuteAsync([=](sal_Int32 nResult){ + if (RET_OK == nResult) + pApplyStyleHelper->apply(); - if (RET_OK != nDlgRet) - { - if( bNew ) + if (bNew) { - GetWrtShell()->Undo(); - m_pDoc->GetIDocumentUndoRedo().ClearRedo(); + SwRewriter aRewriter; + aRewriter.AddRule(UndoArg1, xTmp->GetName()); + //Group the create style and change style operations together under the + //one "create style" comment + m_pWrtShell->EndUndo(nNewStyleUndoId, &aRewriter); } - if( !bModified ) - m_pDoc->getIDocumentState().ResetModified(); - } + if (RET_OK != nResult) + { + if (bNew) + { + GetWrtShell()->Undo(); + m_pDoc->GetIDocumentUndoRedo().ClearRedo(); + } + + if (!bModified) + m_pDoc->getIDocumentState().ResetModified(); + } + + // Update Watermark if new page style was created + if (nSlot == SID_STYLE_NEW && nFamily == SfxStyleFamily::Page) + { + SwWrtShell* pShell = GetWrtShell(); + const SfxWatermarkItem aWatermark = pShell->GetWatermark(); + pShell->SetWatermark(aWatermark); + } + + if (pRequest) + pRequest->Done(); + }, pDlg); } else { diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 746450ba2484..d30b079c6214 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -2452,6 +2452,8 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) rTempView.GetDocShell()->FormatPage(rPageDesc.GetName(), sPageId, rSh, &rReq); rTempView.InvalidateRulerPos(); + + bDone = true; // FormatPage() takes care of calling Done() } } break; |