summaryrefslogtreecommitdiff
path: root/sc
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 /sc
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 'sc')
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx73
-rw-r--r--sc/source/ui/inc/fuinsert.hxx10
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx2
-rw-r--r--sc/source/ui/view/tabvwsh2.cxx2
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx1
-rw-r--r--sc/source/ui/view/tabvwshb.cxx35
6 files changed, 62 insertions, 61 deletions
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 82b1e10b0244..1c30fa935809 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -53,10 +53,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>
@@ -399,7 +401,7 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView*
}
FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP,
- SdrModel* pDoc, SfxRequest& rReq)
+ SdrModel* pDoc, SfxRequest& rReq, const Link<css::ui::dialogs::DialogClosedEvent*, void>& rLink)
: FuPoor(rViewSh, pWin, pViewP, pDoc, rReq)
{
const SfxItemSet* pReqArgs = rReq.GetArgs();
@@ -597,11 +599,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* pPage = pPV->GetPage();
+ pPage->InsertObject( pObj );
pView->UnmarkAllObj();
pView->MarkObj( pObj, pPV );
- bool bAddUndo = true; // add undo action later, unless the dialog is canceled
if (rReq.IsAPI())
{
@@ -625,7 +626,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
if(xMCF.is())
{
- uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
+ css::uno::Reference<css::ui::dialogs::XAsynchronousExecutableDialog> xDialog(
xMCF->createInstanceWithContext(
"com.sun.star.comp.chart2.WizardDialog"
, xContext), uno::UNO_QUERY);
@@ -670,62 +671,22 @@ 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
+ pView->AddUndo(std::make_unique<SdrUndoNewObj>(*pObj));
+ ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener();
+ pListener->SetDialogClosedLink( rLink );
+ css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener );
- // leave the draw shell
- rViewShell.SetDrawShell( false );
-
- // reset marked cell area
-
- rViewSh.GetViewData().GetViewShell()->SetMarkData(aMark);
- }
- else
- {
- OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK );
- //@todo maybe move chart to different table
- }
+ 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();
}
}
}
- else if( xChartModel.is() )
- xChartModel->unlockControllers();
-
- if ( bAddUndo )
- {
- // add undo action the same way as in SdrEditView::InsertObjectAtView
- // (using UndoActionHdl etc.)
- pView->AddUndo(std::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..a9c8fb5c7e38 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,10 @@ public:
class FuInsertChart : public FuPoor
{
-public:
- FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView,
- SdrModel* pDoc, SfxRequest& rReq);
+ public:
+ FuInsertChart( ScTabViewShell& pViewSh, vcl::Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq,
+ const Link<css::ui::dialogs::DialogClosedEvent*, void>& rLink);
};
class FuInsertMedia : public FuPoor
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index fad4de239c35..7975a9236508 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -32,6 +32,7 @@
#include "target.hxx"
#include <shellids.hxx>
#include <tabprotection.hxx>
+#include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
#include <memory>
#include <map>
@@ -178,6 +179,7 @@ private:
DECL_LINK( SimpleRefAborted, const OUString&, void );
DECL_LINK( SimpleRefChange, const OUString&, void );
DECL_LINK( FormControlActivated, LinkParamNone*, void );
+ DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void );
protected:
virtual void Activate(bool bMDI) override;
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index ea2fa4cdf34b..cee19352fdd8 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -87,7 +87,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
if ( nNewId == SID_DRAW_CHART )
{
// #i71254# directly insert a chart instead of drawing its output rectangle
- FuInsertChart(*this, pWin, pView, pDoc, rReq);
+ FuInsertChart(*this, pWin, pView, pDoc, rReq, LINK( this, ScTabViewShell, DialogClosedHdl ));
return;
}
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index b8aa16165e24..b00cebcdfa28 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -56,6 +56,7 @@
#include <inputwin.hxx>
#include <dbdata.hxx>
#include <reffact.hxx>
+#include <fuinsert.hxx>
#include <viewuno.hxx>
#include <dispuno.hxx>
#include <chgtrack.hxx>
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 9ebb98f8e24d..9d1c2243c7d1 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -57,6 +57,8 @@
#include <drawview.hxx>
#include <ChartRangeSelectionListener.hxx>
#include <gridwin.hxx>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <svx/svdpagv.hxx>
#include <comphelper/lok.hxx>
@@ -296,6 +298,37 @@ void ScTabViewShell::DeactivateOle()
pClient->DeactivateObject();
}
+IMPL_LINK( ScTabViewShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvent, void )
+{
+ if( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::CANCEL )
+ {
+ ScTabView* pTabView = GetViewData().GetView();
+ ScDrawView* pView = pTabView->GetScDrawView();
+ ScViewData& rData = GetViewData();
+ ScDocShell* pScDocSh = rData.GetDocShell();
+ ScDocument& rScDoc = pScDocSh->GetDocument();
+ // leave OLE inplace mode and unmark
+ OSL_ASSERT( pView );
+ DeactivateOle();
+ pView->UnMarkAll();
+
+ rScDoc.GetUndoManager()->Undo();
+ rScDoc.GetUndoManager()->ClearRedo();
+
+ // leave the draw shell
+ SetDrawShell( false );
+
+ // reset marked cell area
+ ScMarkData aMark = GetViewData().GetMarkData();
+ GetViewData().GetViewShell()->SetMarkData(aMark);
+ }
+ else
+ {
+ OSL_ASSERT( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::OK );
+ //@todo maybe move chart to different table
+ }
+}
+
void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
{
sal_uInt16 nSlot = rReq.GetSlot();
@@ -333,7 +366,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
break;
case SID_INSERT_DIAGRAM:
- FuInsertChart(*this, pWin, pView, pDrModel, rReq);
+ FuInsertChart(*this, pWin, pView, pDrModel, rReq, LINK( this, ScTabViewShell, DialogClosedHdl ));
if (comphelper::LibreOfficeKit::isActive())
pDocSh->SetModified();
break;