summaryrefslogtreecommitdiff
path: root/chart2
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 /chart2
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 'chart2')
-rw-r--r--chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx54
-rw-r--r--chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx16
2 files changed, 37 insertions, 33 deletions
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
index 9606ae805c6f..ba08b5b7ed55 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/sequence.hxx>
#include <tools/diagnose_ex.h>
+#include <comphelper/lok.hxx>
namespace chart
{
@@ -83,9 +84,9 @@ void SAL_CALL CreationWizardUnoDlg::release() throw ()
}
uno::Any SAL_CALL CreationWizardUnoDlg::queryAggregation( uno::Type const & rType )
{
- if (rType == cppu::UnoType<ui::dialogs::XExecutableDialog>::get())
+ if (rType == cppu::UnoType<ui::dialogs::XAsynchronousExecutableDialog>::get())
{
- void * p = static_cast< ui::dialogs::XExecutableDialog * >( this );
+ void * p = static_cast< ui::dialogs::XAsynchronousExecutableDialog * >( this );
return uno::Any( &p, rType );
}
else if (rType == cppu::UnoType<lang::XServiceInfo>::get())
@@ -120,9 +121,8 @@ uno::Sequence< uno::Type > CreationWizardUnoDlg::getTypes()
cppu::UnoType<lang::XServiceInfo>::get(),
cppu::UnoType<lang::XInitialization>::get(),
cppu::UnoType<frame::XTerminateListener>::get(),
- cppu::UnoType<ui::dialogs::XExecutableDialog>::get(),
+ cppu::UnoType<ui::dialogs::XAsynchronousExecutableDialog>::get(),
cppu::UnoType<beans::XPropertySet>::get() };
-
return aTypeList;
}
@@ -147,7 +147,7 @@ void SAL_CALL CreationWizardUnoDlg::disposing( const lang::EventObject& /*Source
//Listener should deregister himself and release all references to the closing object.
}
-void SAL_CALL CreationWizardUnoDlg::setTitle( const OUString& /*rTitle*/ )
+void SAL_CALL CreationWizardUnoDlg::setDialogTitle( const OUString& /*rTitle*/ )
{
}
void CreationWizardUnoDlg::createDialogOnDemand()
@@ -176,32 +176,34 @@ void CreationWizardUnoDlg::createDialogOnDemand()
}
uno::Reference< XComponent > xComp( this );
if( m_xChartModel.is() )
- {
m_pDialog = VclPtr<CreationWizard>::Create( pParent, m_xChartModel, m_xCC );
- m_pDialog->AddEventListener( LINK( this, CreationWizardUnoDlg, DialogEventHdl ) );
- }
}
}
-IMPL_LINK( CreationWizardUnoDlg, DialogEventHdl, VclWindowEvent&, rEvent, void )
-{
- if(rEvent.GetId() == VclEventId::ObjectDying)
- m_pDialog = nullptr;//avoid duplicate destruction of m_pDialog
-}
-sal_Int16 SAL_CALL CreationWizardUnoDlg::execute( )
+void SAL_CALL CreationWizardUnoDlg::startExecuteModal( const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& xListener )
{
- sal_Int16 nRet = RET_CANCEL;
- {
- SolarMutexGuard aSolarGuard;
- createDialogOnDemand();
- if( !m_pDialog )
- return nRet;
- TimerTriggeredControllerLock aTimerTriggeredControllerLock( m_xChartModel );
- if( m_bUnlockControllersOnExecute && m_xChartModel.is() )
- m_xChartModel->unlockControllers();
- nRet = m_pDialog->Execute();
- }
- return nRet;
+ SolarMutexGuard aSolarGuard;
+ m_xDlgClosedListener = xListener;
+ createDialogOnDemand();
+
+ if( !m_pDialog )
+ return;
+
+ TimerTriggeredControllerLock aTimerTriggeredControllerLock( m_xChartModel );
+ if( m_bUnlockControllersOnExecute && m_xChartModel.is() )
+ m_xChartModel->unlockControllers();
+
+ VclPtr<CreationWizard> xWizard(m_pDialog);
+ rtl::Reference<CreationWizardUnoDlg> xThat(this);
+ m_pDialog->StartExecuteAsync([xThat, xWizard](sal_Int32 nResult){
+ if( xThat->m_xDlgClosedListener.is() )
+ {
+ // Notify UNO listener to perform correct action depending on the result
+ css::ui::dialogs::DialogClosedEvent aEvent( *xThat.get(), nResult );
+ xThat->m_xDlgClosedListener->dialogClosed( aEvent );
+ xThat->m_xDlgClosedListener.clear();
+ }
+ });
}
void SAL_CALL CreationWizardUnoDlg::initialize( const uno::Sequence< uno::Any >& aArguments )
diff --git a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx
index 2eed39a2a19d..77738fab845d 100644
--- a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx
+++ b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx
@@ -26,10 +26,13 @@
#include <com/sun/star/frame/XTerminateListener.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
#include <tools/link.hxx>
#include <vcl/vclptr.hxx>
+#include <vcl/vclevent.hxx>
+#include <vcl/dialog.hxx>
namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } }
@@ -43,7 +46,7 @@ namespace chart
class CreationWizard;
class CreationWizardUnoDlg : public MutexContainer
, public ::cppu::OComponentHelper
- , public css::ui::dialogs::XExecutableDialog
+ , public css::ui::dialogs::XAsynchronousExecutableDialog
, public css::lang::XServiceInfo
, public css::lang::XInitialization
, public css::frame::XTerminateListener
@@ -70,9 +73,9 @@ public:
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- // XExecutableDialog
- virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
- virtual sal_Int16 SAL_CALL execute( ) override;
+ // XAsynchronousExecutableDialog
+ virtual void SAL_CALL setDialogTitle( const OUString& aTitle ) override;
+ virtual void SAL_CALL startExecuteModal( const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& xListener ) override;
// XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
@@ -92,8 +95,6 @@ public:
virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
- DECL_LINK( DialogEventHdl, VclWindowEvent&, void );
-
protected:
// ____ OComponentHelper ____
/// Called in dispose method after the listeners were notified.
@@ -106,6 +107,7 @@ private:
css::uno::Reference< css::frame::XModel > m_xChartModel;
css::uno::Reference< css::uno::XComponentContext> m_xCC;
css::uno::Reference< css::awt::XWindow > m_xParentWindow;
+ css::uno::Reference< css::ui::dialogs::XDialogClosedListener > m_xDlgClosedListener;
VclPtr<CreationWizard> m_pDialog;
bool m_bUnlockControllersOnExecute;