summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-01-17 15:20:31 +0100
committerJan Holesovsky <kendy@collabora.com>2018-01-18 15:18:16 +0100
commitd3dbbdce4eb71ae848e7682374e011c4a6129b15 (patch)
treec27c21e950212b14fa441d0b3bc8280047907305
parente6e125946358865990ea999c8a4845ec84eb7088 (diff)
lokdialog: Convert the Format -> ... -> Position and Size... to async exec.
Change-Id: Idcdbfb1366db61e247c31eab5cb27a39978b0fd9 Reviewed-on: https://gerrit.libreoffice.org/48055 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--cui/source/factory/dlgfact.hxx7
-rw-r--r--sd/source/ui/func/futransf.cxx161
-rw-r--r--sd/source/ui/view/drviews2.cxx3
3 files changed, 106 insertions, 65 deletions
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;