[Libreoffice-commits] core.git: 2 commits - cui/source sd/source

Jan Holesovsky kendy at collabora.com
Thu Jan 18 14:18:40 UTC 2018


 cui/source/factory/dlgfact.hxx |    7 +
 sd/source/ui/func/fuline.cxx   |   40 ++++++----
 sd/source/ui/func/futransf.cxx |  161 +++++++++++++++++++++++++----------------
 sd/source/ui/view/drviews2.cxx |    5 -
 4 files changed, 132 insertions(+), 81 deletions(-)

New commits:
commit cb84fdb368ed4b09d086681fe777a0f4c0f07f76
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 17 19:17:30 2018 +0100

    lokdialog: Convert the Format -> ... -> Line... to async exec.
    
    Change-Id: Ieaf440abf819d503d388a8b060dbf7fe6548db9e
    Reviewed-on: https://gerrit.libreoffice.org/48073
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sd/source/ui/func/fuline.cxx b/sd/source/ui/func/fuline.cxx
index cb4bd715581d..67ad104ecc31 100644
--- a/sd/source/ui/func/fuline.cxx
+++ b/sd/source/ui/func/fuline.cxx
@@ -60,23 +60,34 @@ rtl::Reference<FuPoor> FuLine::Create( ViewShell* pViewSh, ::sd::Window* pWin, :
 
 void FuLine::DoExecute( SfxRequest& rReq )
 {
-    bool        bHasMarked = mpView->AreObjectsMarked();
+    rReq.Ignore();
 
     const SfxItemSet* pArgs = rReq.GetArgs();
-
-    if( !pArgs )
+    if (pArgs)
     {
-        const SdrObject* pObj = nullptr;
-        const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
-        if( rMarkList.GetMarkCount() == 1 )
-            pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+        mpViewShell->Cancel();
+        return;
+    }
+
+    const SdrObject* pObj = nullptr;
+    const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+    if( rMarkList.GetMarkCount() == 1 )
+        pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+    std::unique_ptr<SfxItemSet> pNewAttr(new SfxItemSet( mpDoc->GetPool() ));
+    mpView->GetAttributes( *pNewAttr );
 
-        std::unique_ptr<SfxItemSet> pNewAttr(new SfxItemSet( mpDoc->GetPool() ));
-        mpView->GetAttributes( *pNewAttr );
+    bool bHasMarked = mpView->AreObjectsMarked();
+    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+    VclPtr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSvxLineTabDialog(nullptr,pNewAttr.get(),mpDoc,pObj,bHasMarked) : nullptr);
+    if (!pDlg)
+    {
+        mpViewShell->Cancel();
+        return;
+    }
 
-        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-        ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSvxLineTabDialog(nullptr,pNewAttr.get(),mpDoc,pObj,bHasMarked) : nullptr);
-        if( pDlg && (pDlg->Execute() == RET_OK) )
+    pDlg->StartExecuteAsync([=](sal_Int32 nResult){
+        if (nResult == RET_OK)
         {
             mpView->SetAttributes (*(pDlg->GetOutputItemSet ()));
 
@@ -95,9 +106,8 @@ void FuLine::DoExecute( SfxRequest& rReq )
 
             mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
         }
-    }
-
-    rReq.Ignore ();
+        mpViewShell->Cancel();
+    }, pDlg);
 }
 
 void FuLine::Activate()
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 547348e22a53..4cbe90ccc623 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1367,7 +1367,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_ATTRIBUTES_LINE:  // BASIC
         {
             SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
-            Cancel();
+            // Cancel() called directly in FuTransform::Create()
         }
         break;
 
commit d3dbbdce4eb71ae848e7682374e011c4a6129b15
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 17 15:20:31 2018 +0100

    lokdialog: Convert the Format -> ... -> Position and Size... to async exec.
    
    Change-Id: Idcdbfb1366db61e247c31eab5cb27a39978b0fd9
    Reviewed-on: https://gerrit.libreoffice.org/48055
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index c3240f954532..eef4029ffcb3 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -67,12 +67,17 @@ public:                                             \
     explicit        Class( DialogClass* p)          \
                      : pDlg(p)                      \
                      {}                             \
-    virtual short   Execute() override ;
+    virtual short   Execute() override;             \
+    virtual bool    StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override;
 
 #define IMPL_ABSTDLG_BASE(Class)                    \
 short Class::Execute()                              \
 {                                                   \
     return pDlg->Execute();                         \
+}                                                   \
+bool Class::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) \
+{                                                   \
+    return pDlg->StartExecuteAsync(rCtx);           \
 }
 
 class VclAbstractDialog2_Impl : public VclAbstractDialog2
diff --git a/sd/source/ui/func/futransf.cxx b/sd/source/ui/func/futransf.cxx
index 4a811aa62a75..0d0a7788d43a 100644
--- a/sd/source/ui/func/futransf.cxx
+++ b/sd/source/ui/func/futransf.cxx
@@ -32,8 +32,7 @@
 
 #include <memory>
 
-namespace sd {
-
+using namespace sd;
 
 FuTransform::FuTransform(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
                          SdDrawDocument* pDoc, SfxRequest& rReq)
@@ -48,74 +47,112 @@ rtl::Reference<FuPoor> FuTransform::Create( ViewShell* pViewSh, ::sd::Window* pW
     return xFunc;
 }
 
-void FuTransform::DoExecute( SfxRequest& rReq )
+namespace {
+
+void setUndo(::sd::View* pView, const SfxItemSet* pArgs)
+{
+    // Undo
+    OUString aString(pView->GetDescriptionOfMarkedObjects());
+    aString += " " + SdResId(STR_TRANSFORM);
+    pView->BegUndo(aString);
+
+    pView->SetGeoAttrToMarked(*pArgs);
+    pView->SetAttributes(*pArgs);
+    pView->EndUndo();
+}
+
+class ScopeCleanup
 {
-    if( mpView->AreObjectsMarked() )
+    ViewShell* mpViewShell;
+public:
+    ScopeCleanup(ViewShell* pViewShell) : mpViewShell(pViewShell)
     {
-        const SfxItemSet* pArgs = rReq.GetArgs();
+    }
 
-        if( !pArgs )
+    ~ScopeCleanup()
+    {
+        if (mpViewShell)
         {
-            // --------- itemset for size and position --------
-            SfxItemSet aSet( mpView->GetGeoAttrFromMarked() );
-
-            const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
-            SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
-            if( rMarkList.GetMarkCount() == 1 &&
-                pObj->GetObjInventor() == SdrInventor::Default &&
-                pObj->GetObjIdentifier() == OBJ_CAPTION )
-            {
-                // --------- itemset for caption --------
-                SfxItemSet aNewAttr( mpDoc->GetPool() );
-                mpView->GetAttributes( aNewAttr );
-
-                SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-                if ( pFact )
-                {
-                    ScopedVclPtr< SfxAbstractTabDialog > pDlg( pFact->CreateCaptionDialog( nullptr, mpView ) );
-
-                    const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
-                    SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
-                    aCombSet.Put( aNewAttr );
-                    aCombSet.Put( aSet );
-                    pDlg->SetInputSet( &aCombSet );
-
-                    if( pDlg.get() && (pDlg->Execute() == RET_OK) )
-                    {
-                        rReq.Done( *( pDlg->GetOutputItemSet() ) );
-                        pArgs = rReq.GetArgs();
-                    }
-                }
-            }
-            else
-            {
-                SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-                if(pFact)
-                {
-                    ScopedVclPtr< SfxAbstractTabDialog > pDlg( pFact->CreateSvxTransformTabDialog( nullptr, &aSet, mpView ) );
-                    if( pDlg.get() && (pDlg->Execute() == RET_OK) )
-                    {
-                        rReq.Done( *( pDlg->GetOutputItemSet() ) );
-                        pArgs = rReq.GetArgs();
-                    }
-                }
-            }
+            mpViewShell->Invalidate(SID_RULER_OBJECT);
+            mpViewShell->Cancel();
         }
+    }
 
-        if( pArgs )
-        {
-            // Undo
-            OUString aString( mpView->GetDescriptionOfMarkedObjects() );
-            aString += " " + SdResId( STR_TRANSFORM );
-            mpView->BegUndo( aString );
-
-            mpView->SetGeoAttrToMarked( *pArgs );
-            mpView->SetAttributes( *pArgs );
-            mpView->EndUndo();
-        }
+    void ignore()
+    {
+        mpViewShell = nullptr;
     }
+};
+
 }
 
-} // end of namespace sd
+void FuTransform::DoExecute( SfxRequest& rReq )
+{
+    ScopeCleanup aCleanup(mpViewShell);
+
+    if (!mpView->AreObjectsMarked())
+        return;
+
+    const SfxItemSet* pArgs = rReq.GetArgs();
+
+    if (pArgs)
+    {
+        setUndo(mpView, pArgs);
+        return;
+    }
+
+    // --------- itemset for size and position --------
+    SfxItemSet aSet( mpView->GetGeoAttrFromMarked() );
+    VclPtr<SfxAbstractTabDialog> pDlg;
+
+    const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+    SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+    if( rMarkList.GetMarkCount() == 1 &&
+        pObj->GetObjInventor() == SdrInventor::Default &&
+        pObj->GetObjIdentifier() == OBJ_CAPTION )
+    {
+        // --------- itemset for caption --------
+        SfxItemSet aNewAttr( mpDoc->GetPool() );
+        mpView->GetAttributes( aNewAttr );
+
+        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+        if (!pFact)
+            return;
+
+        pDlg.reset(pFact->CreateCaptionDialog(nullptr, mpView));
+
+        const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
+        SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
+        aCombSet.Put( aNewAttr );
+        aCombSet.Put( aSet );
+        pDlg->SetInputSet( &aCombSet );
+    }
+    else
+    {
+        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+        if (!pFact)
+            return;
+
+        pDlg.reset(pFact->CreateSvxTransformTabDialog(nullptr, &aSet, mpView));
+    }
+
+    if (!pDlg)
+        return;
+
+    std::shared_ptr<SfxRequest> pRequest(new SfxRequest(rReq));
+    rReq.Ignore(); // the 'old' request is not relevant any more
+    aCleanup.ignore(); // the lambda does it
+
+    pDlg->StartExecuteAsync([=](sal_Int32 nResult){
+        if (nResult == RET_OK)
+        {
+            pRequest->Done(*(pDlg->GetOutputItemSet()));
+            setUndo(mpView, pRequest->GetArgs());
+        }
+
+        mpViewShell->Invalidate(SID_RULER_OBJECT);
+        mpViewShell->Cancel();
+    }, pDlg);
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 74e1621192e3..547348e22a53 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1381,8 +1381,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_ATTR_TRANSFORM:
         {
             SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
-            Invalidate(SID_RULER_OBJECT);
-            Cancel();
+            // Cancel() and Invalidate() called directly in FuTransform::Create()
         }
         break;
 


More information about the Libreoffice-commits mailing list