[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/inc sw/source

Jan Holesovsky kendy at collabora.com
Thu Jan 18 13:00:27 UTC 2018


 sw/inc/docsh.hxx                   |    3 -
 sw/source/uibase/app/docst.cxx     |   75 ++++++++++++++++++++-----------------
 sw/source/uibase/shells/basesh.cxx |    2 
 3 files changed, 46 insertions(+), 34 deletions(-)

New commits:
commit 4ca3356cedf32c6cc4ff142cbb8b76bfba40d2d4
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 17 12:42:42 2018 +0100

    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 at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

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;


More information about the Libreoffice-commits mailing list