summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-01-25 10:19:00 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-01-25 10:33:21 +0100
commite5d6133283bacb6bced8cdbedaeae6b3bd2f179e (patch)
treee0676dc2bceeb47fd78fe5154e4644ec3d812e0d
parent2aa773c9bdb8fc89225d251ca2662a328a0d5e6f (diff)
make insert row dialog async
Change-Id: Icb6c2fafe2b47989ff2692956890c87780b117e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162552 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--cui/source/dialogs/insrc.cxx19
-rw-r--r--cui/source/factory/dlgfact.cxx2
-rw-r--r--cui/source/inc/insrc.hxx17
-rw-r--r--sd/source/ui/table/tableobjectbar.cxx62
-rw-r--r--sw/source/uibase/shells/tabsh.cxx33
5 files changed, 90 insertions, 43 deletions
diff --git a/cui/source/dialogs/insrc.cxx b/cui/source/dialogs/insrc.cxx
index 1ff1a14411cb..6c09c8ce4560 100644
--- a/cui/source/dialogs/insrc.cxx
+++ b/cui/source/dialogs/insrc.cxx
@@ -51,9 +51,24 @@ SvxInsRowColDlg::SvxInsRowColDlg(weld::Window* pParent, bool bColumn, const OUSt
m_xDialog->set_help_id(rHelpId);
}
-short SvxInsRowColDlg::Execute()
+short SvxAbstractInsRowColDlg_Impl::Execute()
{
- return run();
+ return m_xDlg->run();
+}
+
+bool SvxAbstractInsRowColDlg_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+ return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
+bool SvxAbstractInsRowColDlg_Impl::isInsertBefore() const
+{
+ return m_xDlg->isInsertBefore();
+}
+
+sal_uInt16 SvxAbstractInsRowColDlg_Impl::getInsertCount() const
+{
+ return m_xDlg->getInsertCount();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 6979167de569..2392fa46edc6 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1475,7 +1475,7 @@ VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateOptionsDialog(weld::
VclPtr<SvxAbstractInsRowColDlg> AbstractDialogFactory_Impl::CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OUString& rHelpId)
{
- return VclPtr<SvxInsRowColDlg>::Create(pParent, bCol, rHelpId);
+ return VclPtr<SvxAbstractInsRowColDlg_Impl>::Create(std::make_shared<SvxInsRowColDlg>(pParent, bCol, rHelpId));
}
VclPtr<AbstractPasswordToOpenModifyDialog> AbstractDialogFactory_Impl::CreatePasswordToOpenModifyDialog(
diff --git a/cui/source/inc/insrc.hxx b/cui/source/inc/insrc.hxx
index 597ef172c3e9..9ab7f0fed466 100644
--- a/cui/source/inc/insrc.hxx
+++ b/cui/source/inc/insrc.hxx
@@ -22,7 +22,7 @@
#include <svx/svxdlg.hxx>
#include <vcl/weld.hxx>
-class SvxInsRowColDlg : public SvxAbstractInsRowColDlg, public weld::GenericDialogController
+class SvxInsRowColDlg : public weld::GenericDialogController
{
private:
std::unique_ptr<weld::SpinButton> m_xCountEdit;
@@ -32,8 +32,21 @@ private:
public:
SvxInsRowColDlg(weld::Window* pParent, bool bCol, const OUString& rHelpId);
- virtual short Execute() override;
+ bool isInsertBefore() const;
+ sal_uInt16 getInsertCount() const;
+};
+
+class SvxAbstractInsRowColDlg_Impl final : public SvxAbstractInsRowColDlg
+{
+ std::shared_ptr<SvxInsRowColDlg> m_xDlg;
+public:
+ explicit SvxAbstractInsRowColDlg_Impl(std::shared_ptr<SvxInsRowColDlg> p)
+ : m_xDlg(std::move(p))
+ {
+ }
+ virtual short Execute() override;
+ virtual bool StartExecuteAsync(AsyncContext& rCtx) override;
virtual bool isInsertBefore() const override;
virtual sal_uInt16 getInsertCount() const override;
};
diff --git a/sd/source/ui/table/tableobjectbar.cxx b/sd/source/ui/table/tableobjectbar.cxx
index 6dfd86928530..bd19915692e8 100644
--- a/sd/source/ui/table/tableobjectbar.cxx
+++ b/sd/source/ui/table/tableobjectbar.cxx
@@ -122,40 +122,50 @@ void TableObjectBar::Execute( SfxRequest& rReq )
switch( nSlotId )
{
case SID_TABLE_INSERT_ROW_DLG:
+ case SID_TABLE_INSERT_COL_DLG:
+ {
+ auto xRequest = std::make_shared<SfxRequest>(rReq);
+ rReq.Ignore(); // the 'old' request is not relevant any more
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ vcl::Window* pWin = mpView->GetViewShell()->GetParentWindow();
+ VclPtr<SvxAbstractInsRowColDlg> pDlg( pFact->CreateSvxInsRowColDlg(pWin ? pWin->GetFrameWeld() : nullptr,
+ nSlotId == SID_TABLE_INSERT_COL_DLG,
+ SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) );
+ pDlg->StartExecuteAsync(
+ [pDlg, xRequest, nSlotId, xController, pBindings] (sal_Int32 nResult) mutable ->void
+ {
+ if (nResult == RET_OK)
+ {
+ sal_uInt16 nCount = pDlg->getInsertCount();
+ bool bInsertAfter = !pDlg->isInsertBefore();
+
+ if (nSlotId == SID_TABLE_INSERT_ROW_DLG)
+ nSlotId = SID_TABLE_INSERT_ROW;
+ else
+ nSlotId = SID_TABLE_INSERT_COL;
+
+ xRequest->AppendItem(SfxInt16Item(nSlotId, nCount));
+ xRequest->AppendItem(SfxBoolItem(SID_TABLE_PARAM_INSERT_AFTER, bInsertAfter));
+
+ xRequest->SetSlot( nSlotId );
+ }
+ pDlg->disposeOnce();
+ xController->Execute( *xRequest );
+ pBindings->Invalidate( SID_UNDO );
+ pBindings->Invalidate( SID_REDO );
+ }
+ );
+ return;
+ }
case SID_TABLE_INSERT_ROW_BEFORE:
case SID_TABLE_INSERT_ROW_AFTER:
- case SID_TABLE_INSERT_COL_DLG:
case SID_TABLE_INSERT_COL_BEFORE:
case SID_TABLE_INSERT_COL_AFTER:
{
- ScopedVclPtr<SvxAbstractInsRowColDlg> pDlg;
- if (nSlotId == SID_TABLE_INSERT_ROW_DLG || nSlotId == SID_TABLE_INSERT_COL_DLG)
- {
- SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- vcl::Window* pWin = mpView->GetViewShell()->GetParentWindow();
- pDlg.disposeAndReset( pFact->CreateSvxInsRowColDlg(pWin ? pWin->GetFrameWeld() : nullptr,
- nSlotId == SID_TABLE_INSERT_COL_DLG,
- SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) );
-
- if (pDlg->Execute() != 1)
- break;
- }
-
sal_uInt16 nCount = 1;
bool bInsertAfter = (nSlotId == SID_TABLE_INSERT_ROW_AFTER) || (nSlotId == SID_TABLE_INSERT_COL_AFTER);
- if (nSlotId == SID_TABLE_INSERT_ROW_DLG)
- {
- nCount = pDlg->getInsertCount();
- bInsertAfter = !pDlg->isInsertBefore();
- }
- else if (nSlotId == SID_TABLE_INSERT_COL_DLG)
- {
- nCount = pDlg->getInsertCount();
- bInsertAfter = !pDlg->isInsertBefore();
- }
-
- if (nSlotId == SID_TABLE_INSERT_ROW_DLG || nSlotId == SID_TABLE_INSERT_ROW_BEFORE || nSlotId == SID_TABLE_INSERT_ROW_AFTER)
+ if ( nSlotId == SID_TABLE_INSERT_ROW_BEFORE || nSlotId == SID_TABLE_INSERT_ROW_AFTER)
nSlotId = SID_TABLE_INSERT_ROW;
else
nSlotId = SID_TABLE_INSERT_COL;
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 736c70f20d79..4e17153d166f 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -990,20 +990,29 @@ void SwTableShell::Execute(SfxRequest &rReq)
const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
{
+ auto xRequest = std::make_shared<SfxRequest>(rReq);
+ rReq.Ignore(); // the 'old' request is not relevant any more
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr<SvxAbstractInsRowColDlg> pDlg(pFact->CreateSvxInsRowColDlg(GetView().GetFrameWeld(),
+ VclPtr<SvxAbstractInsRowColDlg> pDlg(pFact->CreateSvxInsRowColDlg(GetView().GetFrameWeld(),
nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand()));
- if( pDlg->Execute() == 1 )
- {
- const TypedWhichId<SfxUInt16Item> nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG)
- ? FN_TABLE_INSERT_COL_AFTER : FN_TABLE_INSERT_ROW_AFTER;
- SfxUInt16Item aCountItem( nDispatchSlot, pDlg->getInsertCount() );
- SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
- SfxViewFrame& rVFrame = GetView().GetViewFrame();
- rVFrame.GetDispatcher()->ExecuteList(nDispatchSlot,
- SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
- { &aCountItem, &aAfter });
- }
+ pDlg->StartExecuteAsync(
+ [this, pDlg, xRequest, nSlot] (sal_Int32 nResult)->void
+ {
+ if (nResult == RET_OK)
+ {
+ const TypedWhichId<SfxUInt16Item> nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG)
+ ? FN_TABLE_INSERT_COL_AFTER : FN_TABLE_INSERT_ROW_AFTER;
+ SfxUInt16Item aCountItem( nDispatchSlot, pDlg->getInsertCount() );
+ SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
+ SfxViewFrame& rVFrame = GetView().GetViewFrame();
+ rVFrame.GetDispatcher()->ExecuteList(nDispatchSlot,
+ SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
+ { &aCountItem, &aAfter });
+ }
+ pDlg->disposeOnce();
+ xRequest->Done();
+ }
+ );
}
break;
}