diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-01-17 12:42:42 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-22 16:18:51 +0100 |
commit | ff25702c53157935e32858df919e9051767032a2 (patch) | |
tree | 13085d89021cb37b3baa99d40e7f495b5e3f47f9 | |
parent | adabda5056d99a1efade39a47bceafa9a467d149 (diff) |
lokdialog: Convert the Format -> Page... dialog to async exec.
This actually also converts the Style -> Edit Style... at the same time.
Reviewed-on: https://gerrit.libreoffice.org/48043
Tested-by: Jan Holesovsky <kendy@collabora.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
(cherry picked from commit e6e125946358865990ea999c8a4845ec84eb7088)
Change-Id: I4c09fcdfd7a543cce613eaa3620d0b623540d7e8
-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 9ab55372c184..8b2c064403b3 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -127,7 +127,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 bfbe6438110c..4361dd18068c 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -322,15 +322,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; @@ -657,10 +649,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_xDoc->getIDocumentState().IsModified(); @@ -830,36 +823,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_xDoc->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_xDoc->getIDocumentState().ResetModified(); - } + if (RET_OK != nResult) + { + if (bNew) + { + GetWrtShell()->Undo(); + m_xDoc->GetIDocumentUndoRedo().ClearRedo(); + } + + if (!bModified) + m_xDoc->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 a8e7ff358020..2d38db9fdea0 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -2450,6 +2450,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; |