sfx2/source/doc/guisaveas.cxx |   10 +++++++++-
 sfx2/source/doc/objserv.cxx   |   27 ++++++++++++++++++++-------
 2 files changed, 29 insertions(+), 8 deletions(-)

New commits:
commit 9e52f282200dd3cd02fe3aa1b5566f16a470f7e9
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Nov 2 15:04:02 2021 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Nov 3 14:35:15 2021 +0100

    Resolves: tdf#119206 run properties sync when launched during save
    
    use (abuse?) a SynchronMode of true, which will become
    SfxRequest::IsSynchronCall of true in SfxObjectShell::ExecFile_Impl to
    request that we do not want the properties dialog to be run async. It
    looks impractical to rearrange all the post-dialog-call close code to be
    part of some callback executed when the dialog completes.
    
    Change-Id: Id2bde24986204dea3d312c0b4a91bf5c0a6f7916
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124606
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124618
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 8a110b420e9a..16f287236c79 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -59,6 +59,7 @@
 #include <tools/urlobj.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <comphelper/mimeconfighelper.hxx>
 #include <comphelper/lok.hxx>
@@ -1108,7 +1109,14 @@ bool ModelData_Impl::ShowDocumentInfoDialog()
                                                                                
 0 );
                     if ( xDispatch.is() )
                     {
-                        xDispatch->dispatch( aURL, uno::Sequence< 
beans::PropertyValue >() );
+                        // tdf#119206 use (abuse?) a SynchronMode of true,
+                        // which will become SfxRequest::IsSynchronCall of true
+                        // in SfxObjectShell::ExecFile_Impl to request that we
+                        // do not want the properties dialog to be run async
+                        uno::Sequence< beans::PropertyValue > aProperties{
+                            comphelper::makePropertyValue("SynchronMode", true)
+                        };
+                        xDispatch->dispatch(aURL, aProperties);
                         bDialogUsed = true;
                     }
                 }
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 78b686956ed0..71cb3f00e619 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -601,9 +601,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
 
                 // creating dialog is done via virtual method; application will
                 // add its own statistics page
-                std::shared_ptr<SfxRequest> pReq = 
std::make_shared<SfxRequest>(rReq);
                 std::shared_ptr<SfxDocumentInfoDialog> 
xDlg(CreateDocumentInfoDialog(rReq.GetFrameWeld(), aSet));
-                SfxTabDialogController::runAsync(xDlg, [this, xDlg, xCmisDoc, 
pReq](sal_Int32 nResult)
+                auto aFunc = [this, xDlg, xCmisDoc](sal_Int32 nResult, 
SfxRequest& rRequest)
                 {
                     if (RET_OK == nResult)
                     {
@@ -619,17 +618,31 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                             SetUseUserData( pDocInfoItem->IsUseUserData() );
                             SetUseThumbnailSave( pDocInfoItem-> 
IsUseThumbnailSave() );
                             // add data from dialog for possible recording 
purpose
-                            pReq->AppendItem( SfxDocumentInfoItem( GetTitle(),
+                            rRequest.AppendItem( SfxDocumentInfoItem( 
GetTitle(),
                                 getDocProperties(), aNewCmisProperties, 
IsUseUserData(), IsUseThumbnailSave() ) );
                         }
-                        pReq->Done();
+                        rRequest.Done();
                     }
                     else
+                    {
                         // nothing done; no recording
-                        pReq->Ignore();
-                });
+                        rRequest.Ignore();
+                    }
+                };
 
-                rReq.Ignore();
+                if (!rReq.IsSynchronCall())
+                {
+                    std::shared_ptr<SfxRequest> pReq = 
std::make_shared<SfxRequest>(rReq);
+                    SfxTabDialogController::runAsync(xDlg, [pReq, 
aFunc](sal_Int32 nResult)
+                    {
+                        aFunc(nResult, *pReq);
+                    });
+                    rReq.Ignore();
+                }
+                else
+                {
+                    aFunc(xDlg->run(), rReq);
+                }
             }
 
             return;

Reply via email to