cui/source/factory/dlgfact.hxx | 7 + sd/source/ui/func/futransf.cxx | 161 +++++++++++++++++++++++++---------------- sd/source/ui/view/drviews2.cxx | 3 3 files changed, 106 insertions(+), 65 deletions(-)
New commits: commit 56b4207526968098b50fe23d21e1c0f57c9c04bb Author: Jan Holesovsky <ke...@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/48117 Reviewed-by: pranavk <pran...@collabora.co.uk> Tested-by: pranavk <pran...@collabora.co.uk> diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 79f3e7cd9f36..61e018f009e4 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 d8f33c578bbd..1651ed5267bf 100644 --- a/sd/source/ui/func/futransf.cxx +++ b/sd/source/ui/func/futransf.cxx @@ -33,8 +33,7 @@ #include <memory> -namespace sd { - +using namespace sd; FuTransform::FuTransform(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq) @@ -49,74 +48,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 += " " + SD_RESSTR(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 += " " + SD_RESSTR( 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 694fa4d9767d..46d0f6eb9c11 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1025,8 +1025,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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits