sw/source/uibase/shells/textsh.cxx |   71 +++++++++++++++++++------------------
 vcl/jsdialog/enabled.cxx           |    1 
 2 files changed, 39 insertions(+), 33 deletions(-)

New commits:
commit 355681eead2411d70caf4f52f1b802cf8c61a981
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Nov 6 14:45:39 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Nov 7 12:58:37 2023 +0100

    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
    
    (cherry picked from commit 35925357f86e01612df28a092d71b6e216195636)
    
    Change-Id: I97aad336b613d105f380012f8c79e92d89c583ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159053
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index 807ee76859e9..a8d24351cdbf 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -526,51 +526,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;
     }
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 14627b3a6424..993a6f45685e 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -184,6 +184,7 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
         || rUIFile == u"modules/swriter/ui/footnotesendnotestabpage.ui"
         || rUIFile == u"modules/swriter/ui/formatsectiondialog.ui"
         || rUIFile == u"modules/swriter/ui/formattablepage.ui"
+        || rUIFile == u"modules/swriter/ui/framedialog.ui"
         || rUIFile == u"modules/swriter/ui/frmaddpage.ui"
         || rUIFile == u"modules/swriter/ui/frmurlpage.ui"
         || rUIFile == u"modules/swriter/ui/frmtypepage.ui"

Reply via email to