summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2019-04-17 17:33:10 +0200
committerMichael Meeks <michael.meeks@collabora.com>2019-09-28 11:00:00 +0200
commitcb01bb34713f39b55b5994c7a756d95db4a81231 (patch)
tree3dbc2eec4f64fb88e84bdc5386e574b7101e8bda /sw/source
parentf5308a09498cde2fc6ab039e17649c5b3ea33e54 (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>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/uibase/inc/chartins.hxx8
-rw-r--r--sw/source/uibase/inc/textsh.hxx3
-rw-r--r--sw/source/uibase/shells/textsh.cxx23
-rw-r--r--sw/source/uibase/table/chartins.cxx32
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 af865e56ed63..2a6cd78c6149 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_LINK( 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 2b59a321b650..156175db4ad7 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -108,9 +108,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_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");
@@ -322,7 +343,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 1c071806a0fd..868b76f11d6f 100644
--- a/sw/source/uibase/table/chartins.cxx
+++ b/sw/source/uibase/table/chartins.cxx
@@ -47,9 +47,10 @@
#include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/component_context.hxx>
#include <comphelper/propertysequence.hxx>
+#include <svtools/dialogclosedlistener.hxx>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/lang/XInitialization.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;
@@ -126,7 +127,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();
@@ -166,7 +167,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);
@@ -212,21 +213,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();
}
}
}