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 <eszkadev@gmail.com>2020-05-13 16:30:06 +0200
commit00b14b433a13808ea4c42eb4cbf1cc8bacfee237 (patch)
tree908ab8d2a119c0c10e895564de33e0fa6e73cb21 /chart2
parent6a34b5361804d1a5b61eea1a9cd159fbef2fd149 (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
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.hxx17
2 files changed, 46 insertions, 25 deletions
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
index ceca92791678..cd6bbe0557e2 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx
@@ -30,6 +30,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
{
@@ -82,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())
@@ -119,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;
}
@@ -146,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()
@@ -169,25 +170,40 @@ void CreationWizardUnoDlg::createDialogOnDemand()
uno::Reference< XComponent > xComp( 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();
+
+ weld::DialogController::runAsync(m_xDialog, [xListener](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 );
+ }
+ });
}
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 230cac85816d..c6eb3a7cf2a6 100644
--- a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx
+++ b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx
@@ -26,11 +26,15 @@
#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 "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; } } } }
@@ -43,7 +47,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
@@ -70,9 +74,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;
@@ -99,13 +103,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;
};