summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx54
-rw-r--r--chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx16
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx130
-rw-r--r--sc/source/ui/inc/fuinsert.hxx14
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx3
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx1
-rw-r--r--sc/source/ui/view/tabvwshb.cxx2
-rw-r--r--svtools/source/dialogs/wizardmachine.cxx9
-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
12 files changed, 176 insertions, 119 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;
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index dc01065c8942..5a34fc7a6917 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -56,10 +56,12 @@
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <cppuhelper/bootstrap.hxx>
+#include <svtools/dialogclosedlistener.hxx>
#include <PivotTableDataProvider.hxx>
#include <chart2uno.hxx>
@@ -405,8 +407,58 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView*
rReq.Ignore();
}
+IMPL_LINK( FuInsertChart, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvent, void )
+{
+ bool bAddUndo = true;
+
+ if( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::CANCEL )
+ {
+ // leave OLE inplace mode and unmark
+ OSL_ASSERT( pView );
+ rViewShell.DeactivateOle();
+ pView->UnMarkAll();
+
+ // old page view pointer is invalid after switching sheets
+ SdrPageView* pPV = pView->GetSdrPageView();
+
+ // remove the chart
+ OSL_ASSERT( pPV );
+ SdrPage * pPage( pPV->GetPage());
+ OSL_ASSERT( pPage );
+ OSL_ASSERT( m_pInsertedObject );
+ if( pPage )
+ {
+ // Remove the OLE2 object from the sdr page.
+ SdrObject* pRemoved = pPage->RemoveObject( m_pInsertedObject->GetOrdNum() );
+ OSL_ASSERT( pRemoved == m_pInsertedObject );
+ SdrObject::Free( pRemoved );
+ }
+
+ bAddUndo = false;
+
+ // leave the draw shell
+ rViewShell.SetDrawShell( false );
+
+ // reset marked cell area
+ ScMarkData aMark = rViewShell.GetViewData().GetMarkData();
+ rViewShell.GetViewData().GetViewShell()->SetMarkData(aMark);
+ }
+ else
+ {
+ OSL_ASSERT( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::OK );
+ //@todo maybe move chart to different table
+ }
+
+ if ( bAddUndo )
+ {
+ // add undo action the same way as in SdrEditView::InsertObjectAtView
+ // (using UndoActionHdl etc.)
+ pView->AddUndo(o3tl::make_unique<SdrUndoNewObj>(*m_pInsertedObject));
+ }
+}
+
FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP,
- SdrModel* pDoc, SfxRequest& rReq)
+ SdrModel* pDoc, SfxRequest& rReq)
: FuPoor(rViewSh, pWin, pViewP, pDoc, rReq)
{
const SfxItemSet* pReqArgs = rReq.GetArgs();
@@ -591,7 +643,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
Point aStart = rViewSh.GetChartInsertPos( aSize, aPositionRange );
tools::Rectangle aRect (aStart, aSize);
- SdrOle2Obj* pObj = new SdrOle2Obj(
+ m_pInsertedObject = new SdrOle2Obj(
*pDoc, // TTTT should be reference
svt::EmbeddedObjectRef(xObj, nAspect),
aName,
@@ -605,11 +657,10 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
// pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immediate redraw and asks the chart for a visual representation
// use the page instead of the view to insert, so no undo action is created yet
- SdrPage* pInsPage = pPV->GetPage();
- pInsPage->InsertObject( pObj );
+ SdrPage* m_pPage = pPV->GetPage();
+ m_pPage->InsertObject( m_pInsertedObject );
pView->UnmarkAllObj();
- pView->MarkObj( pObj, pPV );
- bool bAddUndo = true; // add undo action later, unless the dialog is canceled
+ pView->MarkObj( m_pInsertedObject, pPV );
if (rReq.IsAPI())
{
@@ -621,7 +672,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
//the controller will be unlocked by the dialog when the dialog is told to do so
// only activate object if not called via API (e.g. macro)
- rViewShell.ActivateObject(pObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
+ rViewShell.ActivateObject( m_pInsertedObject, embed::EmbedVerbs::MS_OLEVERB_SHOW );
//open wizard
//@todo get context from calc if that has one
@@ -632,11 +683,11 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
if(xMCF.is())
{
- uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
+ m_xDialog = uno::Reference< ui::dialogs::XAsynchronousExecutableDialog >(
xMCF->createInstanceWithContext(
"com.sun.star.comp.chart2.WizardDialog"
, xContext), uno::UNO_QUERY);
- uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY );
+ uno::Reference< lang::XInitialization > xInit( m_xDialog, uno::UNO_QUERY );
if( xChartModel.is() && xInit.is() )
{
uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
@@ -647,7 +698,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
xInit->initialize( aSeq );
// try to set the dialog's position so it doesn't hide the chart
- uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xDialogProps( m_xDialog, uno::UNO_QUERY );
if ( xDialogProps.is() )
{
try
@@ -677,60 +728,21 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
}
}
- sal_Int16 nDialogRet = xDialog->execute();
- if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
- {
- // leave OLE inplace mode and unmark
- OSL_ASSERT( pView );
- rViewShell.DeactivateOle();
- pView->UnmarkAll();
-
- // old page view pointer is invalid after switching sheets
- pPV = pView->GetSdrPageView();
-
- // remove the chart
- OSL_ASSERT( pPV );
- SdrPage * pPage( pPV->GetPage());
- OSL_ASSERT( pPage );
- OSL_ASSERT( pObj );
- if( pPage )
- {
- // Remove the OLE2 object from the sdr page.
- SdrObject* pRemoved = pPage->RemoveObject(pObj->GetOrdNum());
- OSL_ASSERT(pRemoved == pObj);
- SdrObject::Free(pRemoved); // Don't forget to free it.
- }
-
- bAddUndo = false; // don't create the undo action for inserting
-
- // leave the draw shell
- rViewShell.SetDrawShell( false );
+ ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener();
+ pListener->SetDialogClosedLink( LINK( this, FuInsertChart, DialogClosedHdl ) );
+ css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener );
- // reset marked cell area
-
- rViewSh.GetViewData().GetViewShell()->SetMarkData(aMark);
- }
- else
- {
- OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK );
- //@todo maybe move chart to different table
- }
+ m_xDialog->startExecuteModal( xListener );
+ }
+ else
+ {
+ uno::Reference< lang::XComponent > xComponent( m_xDialog, uno::UNO_QUERY );
+ if( xComponent.is())
+ xComponent->dispose();
}
- uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY );
- if( xComponent.is())
- xComponent->dispose();
}
}
}
-
- if ( bAddUndo )
- {
- // add undo action the same way as in SdrEditView::InsertObjectAtView
- // (using UndoActionHdl etc.)
- pView->AddUndo(o3tl::make_unique<SdrUndoNewObj>(*pObj));
- }
-
- // BM/IHA --
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuinsert.hxx b/sc/source/ui/inc/fuinsert.hxx
index 863aa6d88cb1..cfad23933836 100644
--- a/sc/source/ui/inc/fuinsert.hxx
+++ b/sc/source/ui/inc/fuinsert.hxx
@@ -22,6 +22,9 @@
#include "fupoor.hxx"
#include <scdllapi.h>
+#include <svx/svdoole2.hxx>
+#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp>
+#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
class FuInsertGraphic : public FuPoor
{
@@ -40,9 +43,14 @@ public:
class FuInsertChart : public FuPoor
{
-public:
- FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView,
- SdrModel* pDoc, SfxRequest& rReq);
+ css::uno::Reference<css::ui::dialogs::XAsynchronousExecutableDialog> m_xDialog;
+ SdrOle2Obj* m_pInsertedObject;
+
+ DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void );
+
+ public:
+ FuInsertChart( ScTabViewShell& pViewSh, vcl::Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
};
class FuInsertMedia : public FuPoor
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 2f17319efeaf..8191d629b381 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -57,6 +57,7 @@ class ScPageBreakShell;
class ScDPObject;
class ScNavigatorSettings;
class ScRangeName;
+class FuInsertChart;
struct ScHeaderFieldData;
@@ -97,6 +98,7 @@ private:
sal_uInt16 nDrawSfxId;
sal_uInt16 nFormSfxId;
OUString sDrawCustom; // current custom shape type
+
std::unique_ptr<ScDrawShell> pDrawShell;
std::unique_ptr<ScDrawTextObjectBar> pDrawTextShell;
std::unique_ptr<ScEditShell> pEditShell;
@@ -111,6 +113,7 @@ private:
std::unique_ptr<ScPageBreakShell> pPageBreakShell;
std::unique_ptr<svx::ExtrusionBar> pExtrusionBarShell;
std::unique_ptr<svx::FontworkBar> pFontworkBarShell;
+ std::unique_ptr<FuInsertChart> pFuInsertChart;
std::unique_ptr<FmFormShell> pFormShell;
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 30e9def2e4a2..ec912c115848 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -64,6 +64,7 @@
#include <inputwin.hxx>
#include <dbdata.hxx>
#include <reffact.hxx>
+#include <fuinsert.hxx>
#include <viewuno.hxx>
#include <dispuno.hxx>
#include <anyrefdg.hxx>
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 5ea064f7fdd3..7ac16fa1a0dc 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -336,7 +336,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
break;
case SID_INSERT_DIAGRAM:
- FuInsertChart(*this, pWin, pView, pDrModel, rReq);
+ pFuInsertChart.reset(new FuInsertChart(*this, pWin, pView, pDrModel, rReq));
break;
case SID_INSERT_OBJECT:
diff --git a/svtools/source/dialogs/wizardmachine.cxx b/svtools/source/dialogs/wizardmachine.cxx
index bf14a0dae2e0..0ec3e014aba3 100644
--- a/svtools/source/dialogs/wizardmachine.cxx
+++ b/svtools/source/dialogs/wizardmachine.cxx
@@ -669,17 +669,18 @@ namespace svt
void OWizardMachine::suspendTraveling( AccessGuard )
{
DBG_ASSERT( !m_pImpl->m_bTravelingSuspended, "OWizardMachine::suspendTraveling: already suspended!" );
- m_pImpl->m_bTravelingSuspended = true;
+ m_pImpl->m_bTravelingSuspended = true;
}
-
void OWizardMachine::resumeTraveling( AccessGuard )
{
+ if (!m_pImpl)
+ return;
+
DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "OWizardMachine::resumeTraveling: nothing to resume!" );
- m_pImpl->m_bTravelingSuspended = false;
+ m_pImpl->m_bTravelingSuspended = false;
}
-
} // namespace svt
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();
}
}
}