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-05-18 20:45:26 +0200
commit77445e201c45e5593761e8399c32f80eea2178a4 (patch)
treedb0010bc4842b224382e6cdca5b18aa89185068b /chart2
parent835bced249e95ccbf0a88266f8c1ba166cf5efcb (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: Ib09b5d83af9e1aa67218e093aa161419e8ddb922 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90380 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx56
-rw-r--r--chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx17
2 files changed, 48 insertions, 25 deletions
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
index 40ab5f3d90ce..5411277f8f0b 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
{
@@ -81,9 +83,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 +120,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 +146,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()
@@ -169,24 +170,41 @@ 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;
+ 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();
+
+ CreationWizardUnoDlg* xThat = this;
+ weld::DialogController::runAsync(m_xDialog, [xListener, xThat](sal_Int32 nResult){
+ if( xListener.is() )
+ {
+ ::css::uno::Reference< ::css::uno::XInterface > xSource;
+ // Notify UNO listener to perform correct action depending on the result
+ css::ui::dialogs::DialogClosedEvent aEvent( xSource, nResult );
+ xListener->dialogClosed( aEvent );
+ }
+ xThat->m_xDialog.reset();
+ });
}
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 33d1dfbf1a69..2e27418de27d 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::sun::star::awt { class XWindow; }
namespace com::sun::star::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,14 @@ 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;
- std::unique_ptr<CreationWizard> m_xDialog;
+ std::shared_ptr<CreationWizard> m_xDialog;
bool m_bUnlockControllersOnExecute;
};