diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2019-04-17 17:33:10 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-03-02 10:30:52 +0100 |
commit | ed86b6250cd00ed6b7bdb81307bc66adba129cae (patch) | |
tree | 40649a37d732c53c4e951d3325724a4878c75bb1 /sw/source | |
parent | 8e323fcacebad1afe9d867b846722a6b9bf20f78 (diff) |
Make Chart Creation Wizard async
* FuInsertChart as a memeber in ScTabViewShell
stores instance is needed to react on the dialog's result
* CreationWizardUnoDlg converted to XAsynchronousExecutableDialog
added dialog close handler which notifies listeners
In the Online dialog become dead after closing, additional
PostUserEvent was needed to kill the dialog after real close
(without it user needed to select any cell to close dialog)
* Reuse in Writer
Change-Id: I9fe123d5c189d568f0edb4d36173a224a820a8a3
Reviewed-on: https://gerrit.libreoffice.org/79654
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/79571
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/inc/chartins.hxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/inc/textsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 23 | ||||
-rw-r--r-- | sw/source/uibase/table/chartins.cxx | 32 |
4 files changed, 47 insertions, 19 deletions
diff --git a/sw/source/uibase/inc/chartins.hxx b/sw/source/uibase/inc/chartins.hxx index 383e0fda1a58..d258053ae985 100644 --- a/sw/source/uibase/inc/chartins.hxx +++ b/sw/source/uibase/inc/chartins.hxx @@ -20,11 +20,17 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_CHARTINS_HXX #include <tools/gen.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> namespace vcl { class Window; } Point SwGetChartDialogPos( const vcl::Window *pParentWin, const Size& rDialogSize, const tools::Rectangle& rLogicChart ); -void SwInsertChart(); + +class SwInsertChart +{ +public: + SwInsertChart( const Link<css::ui::dialogs::DialogClosedEvent*,void>& rLink ); +}; #endif // INCLUDED_SW_SOURCE_UIBASE_INC_CHARTINS_HXX diff --git a/sw/source/uibase/inc/textsh.hxx b/sw/source/uibase/inc/textsh.hxx index 9ec521afe647..849bffcf4f2b 100644 --- a/sw/source/uibase/inc/textsh.hxx +++ b/sw/source/uibase/inc/textsh.hxx @@ -22,11 +22,13 @@ #include "basesh.hxx" #include <unotools/caserotate.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> class AbstractSvxPostItDialog; class SwFieldMgr; class SwFlyFrameAttrMgr; class SvxHyperlinkItem; +class SwInsertChart; class SW_DLLPUBLIC SwTextShell: public SwBaseShell { @@ -46,6 +48,7 @@ private: public: DECL_LINK( RedlineNextHdl, AbstractSvxPostItDialog&, void ); DECL_LINK( RedlinePrevHdl, AbstractSvxPostItDialog&, void ); + DECL_STATIC_LINK( SwTextShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); void Execute(SfxRequest &); void GetState(SfxItemSet &); diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index ef1341d078bc..c16dcf1a7cfc 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -87,9 +87,30 @@ using namespace ::com::sun::star; #include <drawdoc.hxx> #include <svtools/embedhlp.hxx> #include <sfx2/event.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <IDocumentUndoRedo.hxx> SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell) +IMPL_STATIC_LINK( SwTextShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvent, void ) +{ + SwView* pView = ::GetActiveView(); + SwWrtShell& rWrtShell = pView->GetWrtShell(); + + sal_Int16 nDialogRet = pEvent->DialogResult; + if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) + { + rWrtShell.Undo(); + rWrtShell.GetIDocumentUndoRedo().ClearRedo(); + } + else + { + OSL_ENSURE( nDialogRet == ui::dialogs::ExecutableDialogResults::OK, + "dialog execution failed" ); + } +} + void SwTextShell::InitInterface_Impl() { GetStaticInterface()->RegisterPopupMenu("text"); @@ -303,7 +324,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) break; if(!rReq.IsAPI()) { - SwInsertChart(); + SwInsertChart( LINK( this, SwTextShell, DialogClosedHdl ) ); } else { diff --git a/sw/source/uibase/table/chartins.cxx b/sw/source/uibase/table/chartins.cxx index b9e5f1e5103b..51289c19e983 100644 --- a/sw/source/uibase/table/chartins.cxx +++ b/sw/source/uibase/table/chartins.cxx @@ -41,11 +41,12 @@ #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/XWindow.hpp> +#include <svtools/dialogclosedlistener.hxx> #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> using namespace ::com::sun::star; @@ -122,7 +123,7 @@ Point SwGetChartDialogPos( const vcl::Window *pParentWin, const Size& rDialogSiz return aRet; } -void SwInsertChart() +SwInsertChart::SwInsertChart( const Link<css::ui::dialogs::DialogClosedEvent*, void>& rLink ) { SwView *pView = ::GetActiveView(); @@ -162,7 +163,7 @@ void SwInsertChart() uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); if(xMCF.is()) { - uno::Reference< ui::dialogs::XExecutableDialog > xDialog( + uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > xDialog( xMCF->createInstanceWithContext( "com.sun.star.comp.chart2.WizardDialog", xContext), uno::UNO_QUERY); @@ -208,21 +209,18 @@ void SwInsertChart() } } - sal_Int16 nDialogRet = xDialog->execute(); - if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) - { - rWrtShell.Undo(); - rWrtShell.GetIDocumentUndoRedo().ClearRedo(); - } - else - { - OSL_ENSURE( nDialogRet == ui::dialogs::ExecutableDialogResults::OK, - "dialog execution failed" ); - } + ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener(); + pListener->SetDialogClosedLink( rLink ); + css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener ); + + xDialog->startExecuteModal( xListener ); + } + else + { + uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); + if( xComponent.is()) + xComponent->dispose(); } - uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); - if( xComponent.is()) - xComponent->dispose(); } } } |