diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-11-06 14:45:39 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-11-06 18:29:06 +0100 |
commit | 35925357f86e01612df28a092d71b6e216195636 (patch) | |
tree | 7086eab6098145a29d55fde5a32579871c2ac234 /sw | |
parent | 55a0fba06086436260aca1f7367da376683afdaa (diff) |
sw floattable: make Insert Frame dialog async and mark it as a jsdialog
- with this, once a LOK client dispatches .uno:InsertFrame, we don't
open two dialogs (one tunelled, one jsdialog)
- all the tabpages were already allowed as jsdialogs, the tabpages don't
open any unwanted file picker (hyperlink browse button, area -> image
-> import button)
- switching to async means we can't work with the original SfxRequest
(which is no longer there by the time the callback is invoked), but
057eca05f23d9d15465e591bd0da671735d62d50 (sc: convert optimal
width/height and normal width/height dialog to async, 2022-04-12) shows
we can re-create the SfxRequest after the fact, do the same here
- similar problem with SwFlyFrameAttrMgr, but looks like the
SwFlyFrameAttrMgr before launching the dialog doesn't share state with
the SwFlyFrameAttrMgr after the dialog is gone, so work with two
instances here
Change-Id: I97aad336b613d105f380012f8c79e92d89c583ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158978
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 76e0bc0a3511..c9e0e8a4d6f9 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -527,51 +527,56 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebDocShell*>( GetView().GetDocShell()) != nullptr ); SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateFrameTabDialog("FrameDialog", + VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateFrameTabDialog("FrameDialog", GetView().GetViewFrame(), GetView().GetFrameWeld(), aSet)); - if(pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet()) - { - //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point - SwWrtShell& rShell = GetShell(); - rShell.LockPaint(LockPaintReason::InsertFrame); - rShell.StartAllAction(); - rShell.StartUndo(SwUndoId::INSERT); + pDlg->StartExecuteAsync([pDlg, nSlot, this](sal_Int32 nResult) { + if (nResult == RET_OK && pDlg->GetOutputItemSet()) + { + SwFlyFrameAttrMgr aAttrMgr( true, GetShellPtr(), Frmmgr_Type::TEXT, nullptr ); + //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point + SwWrtShell& rShell = GetShell(); + rShell.LockPaint(LockPaintReason::InsertFrame); + rShell.StartAllAction(); + rShell.StartUndo(SwUndoId::INSERT); - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); - aMgr.SetAttrSet(*pOutSet); + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + aAttrMgr.SetAttrSet(*pOutSet); - // At first delete the selection at the ClickToEditField. - if( rShell.IsInClickToEdit() ) - rShell.DelRight(); + // At first delete the selection at the ClickToEditField. + if( rShell.IsInClickToEdit() ) + rShell.DelRight(); - aMgr.InsertFlyFrame(); + aAttrMgr.InsertFlyFrame(); - uno::Reference< frame::XDispatchRecorder > xRecorder = - GetView().GetViewFrame().GetBindings().GetRecorder(); - if ( xRecorder.is() ) - { - //FN_INSERT_FRAME - sal_uInt16 nAnchor = static_cast<sal_uInt16>(aMgr.GetAnchor()); - rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor)); - rReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos())); - rReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize())); - rReq.Done(); - } + uno::Reference< frame::XDispatchRecorder > xRecorder = + GetView().GetViewFrame().GetBindings().GetRecorder(); + if ( xRecorder.is() ) + { + //FN_INSERT_FRAME + sal_uInt16 nAnchor = static_cast<sal_uInt16>(aAttrMgr.GetAnchor()); + SfxRequest aReq(GetView().GetViewFrame(), FN_INSERT_FRAME); + aReq.AppendItem(SfxUInt16Item(nSlot, nAnchor)); + aReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos())); + aReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize())); + aReq.Done(); + } - GetView().AutoCaption(FRAME_CAP); + GetView().AutoCaption(FRAME_CAP); - { - SwRewriter aRewriter; + { + SwRewriter aRewriter; - aRewriter.AddRule(UndoArg1, SwResId(STR_FRAME)); + aRewriter.AddRule(UndoArg1, SwResId(STR_FRAME)); - rShell.EndUndo(SwUndoId::INSERT, &aRewriter); + rShell.EndUndo(SwUndoId::INSERT, &aRewriter); + } + rShell.EndAllAction(); + rShell.UnlockPaint(); } - rShell.EndAllAction(); - rShell.UnlockPaint(); - } + pDlg->disposeOnce(); + }); } break; } |