summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2019-04-17 17:33:10 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2020-03-02 10:30:52 +0100
commited86b6250cd00ed6b7bdb81307bc66adba129cae (patch)
tree40649a37d732c53c4e951d3325724a4878c75bb1 /chart2
parent8e323fcacebad1afe9d867b846722a6b9bf20f78 (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 'chart2')
-rw-r--r--chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx57
-rw-r--r--chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx18
2 files changed, 50 insertions, 25 deletions
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
index 7735c1757e1f..4d959b335252 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
@@ -29,6 +29,8 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <tools/diagnose_ex.h>
+#include <comphelper/lok.hxx>
+#include <sfx2/viewsh.hxx>
namespace chart
{
@@ -47,6 +49,7 @@ CreationWizardUnoDlg::CreationWizardUnoDlg(const uno::Reference<uno::XComponentC
CreationWizardUnoDlg::~CreationWizardUnoDlg()
{
SolarMutexGuard aSolarGuard;
+ m_xDlgClosedListener.clear();
m_xDialog.reset();
}
@@ -81,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())
@@ -118,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;
}
@@ -145,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()
@@ -168,25 +170,42 @@ void CreationWizardUnoDlg::createDialogOnDemand()
uno::Reference< XComponent > xKeepAlive( this );
if( m_xChartModel.is() )
{
- m_xDialog = std::make_unique<CreationWizard>(Application::GetFrameWeld(m_xParentWindow), m_xChartModel, m_xCC);
+ m_xDialog = std::make_shared<CreationWizard>(Application::GetFrameWeld(m_xParentWindow), m_xChartModel, m_xCC);
}
}
}
-sal_Int16 SAL_CALL CreationWizardUnoDlg::execute( )
+IMPL_STATIC_LINK_NOARG(CreationWizardUnoDlg, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*)
{
- sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
- {
- SolarMutexGuard aSolarGuard;
- createDialogOnDemand();
- if (!m_xDialog)
- return nRet;
- TimerTriggeredControllerLock aTimerTriggeredControllerLock( m_xChartModel );
- if( m_bUnlockControllersOnExecute && m_xChartModel.is() )
- m_xChartModel->unlockControllers();
- nRet = m_xDialog->run();
- }
- return nRet;
+ return SfxViewShell::Current();
+}
+
+void SAL_CALL CreationWizardUnoDlg::startExecuteModal( const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& xListener )
+{
+ SolarMutexGuard aSolarGuard;
+ m_xDlgClosedListener = xListener;
+ createDialogOnDemand();
+
+ if( !m_xDialog )
+ return;
+
+ m_xDialog->getDialog()->SetInstallLOKNotifierHdl(
+ LINK(this, CreationWizardUnoDlg, InstallLOKNotifierHdl));
+
+ TimerTriggeredControllerLock aTimerTriggeredControllerLock( m_xChartModel );
+ if( m_bUnlockControllersOnExecute && m_xChartModel.is() )
+ m_xChartModel->unlockControllers();
+
+ rtl::Reference<CreationWizardUnoDlg> xThat(this);
+ weld::DialogController::runAsync(m_xDialog, [xThat](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, 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 c3ebb615db32..a7e67519d678 100644
--- a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx
+++ b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx
@@ -26,9 +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 "dlg_CreationWizard.hxx"
+#include <tools/link.hxx>
+#include <vcl/vclptr.hxx>
+#include <vcl/vclevent.hxx>
namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } }
@@ -41,7 +45,7 @@ namespace chart
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
@@ -68,9 +72,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;
@@ -97,13 +101,15 @@ protected:
private:
void createDialogOnDemand();
+ DECL_STATIC_LINK(CreationWizardUnoDlg, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*);
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;
- std::unique_ptr<CreationWizard> m_xDialog;
+ std::shared_ptr<CreationWizard> m_xDialog;
bool m_bUnlockControllersOnExecute;
};