include/sfx2/frame.hxx            |    1 
 sfx2/Library_sfx.mk               |    1 
 sfx2/sdi/sfx.sdi                  |    2 -
 sfx2/source/control/asyncfunc.cxx |   28 -------------------
 sfx2/source/doc/guisaveas.cxx     |   54 +++++++++++++++++---------------------
 sfx2/source/doc/objserv.cxx       |   10 -------
 sfx2/source/view/frame.cxx        |   10 -------
 7 files changed, 28 insertions(+), 78 deletions(-)

New commits:
commit 688489959e69994d455f36f3e9bb4c0ba3ee87aa
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Nov 2 14:25:24 2021 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Nov 2 18:29:13 2021 +0100

    Revert "tdf#117895: "Edit document properties before saving"..."
    
    This reverts commit 3add3e5b70ad991c8351a54b0da62d05e977458f to try
    and alternative approach
    
    Change-Id: Ieb36b78246586cc7f1977c67eab130d2ae025988
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124605
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/sfx2/frame.hxx b/include/sfx2/frame.hxx
index 26560b3db1f6..d8a0b9d90501 100644
--- a/include/sfx2/frame.hxx
+++ b/include/sfx2/frame.hxx
@@ -171,7 +171,6 @@ class SFX2_DLLPUBLIC SfxUnoAnyItem final : public 
SfxPoolItem
     css::uno::Any  aValue;
 public:
                                 static SfxPoolItem* CreateDefault();
-                                SfxUnoAnyItem();
                                 SfxUnoAnyItem( sal_uInt16 nWhich, const 
css::uno::Any& rAny );
     const css::uno::Any&        GetValue() const
                                 { return aValue; }
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index a47d57138d94..d5f1c28ed436 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -133,7 +133,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/bastyp/sfxresid \
     sfx2/source/commandpopup/CommandPopup \
     sfx2/source/config/evntconf \
-    sfx2/source/control/asyncfunc \
     sfx2/source/control/bindings \
     sfx2/source/control/ctrlitem \
        sfx2/source/control/dispatch \
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 85570cdbb08c..0a9b40b7f7a5 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3325,7 +3325,7 @@ SfxBoolItem PrintPreview SID_PRINTPREVIEW
 
 
 SfxVoidItem SetDocumentProperties SID_DOCINFO
-(SfxDocumentInfoItem Properties SID_DOCINFO,SfxUnoAnyItem AsyncFunc FN_PARAM_2)
+(SfxDocumentInfoItem Properties SID_DOCINFO)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/control/asyncfunc.cxx 
b/sfx2/source/control/asyncfunc.cxx
deleted file mode 100644
index b81639af5646..000000000000
--- a/sfx2/source/control/asyncfunc.cxx
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <asyncfunc.hxx>
-
-AsyncFunc::AsyncFunc(const std::function<void()>& rAsyncFunc)
-    : m_pAsyncFunc(rAsyncFunc)
-{
-}
-
-AsyncFunc::~AsyncFunc() {}
-
-void AsyncFunc::Execute()
-{
-    if (m_pAsyncFunc)
-        m_pAsyncFunc();
-}
-
-//XUnoTunnel
-UNO3_GETIMPLEMENTATION_IMPL(AsyncFunc)
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index d5eb3369d735..ee059c790619 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -71,7 +71,6 @@
 #include <sfx2/strings.hrc>
 #include <sfx2/sfxresid.hxx>
 #include <sfx2/filedlghelper.hxx>
-#include <asyncfunc.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/sfxuno.hxx>
 #include <alienwarn.hxx>
@@ -318,7 +317,7 @@ public:
                                 const css::uno::Sequence< OUString >& rDenyList
                                 );
 
-    bool ShowDocumentInfoDialog(const std::function< void () >&);
+    bool ShowDocumentInfoDialog();
 
     static OUString GetRecommendedExtension( const OUString& aTypeName );
     OUString GetRecommendedDir( const OUString& aSuggestedDir );
@@ -1102,7 +1101,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 
nStoreMode,
 }
 
 
-bool ModelData_Impl::ShowDocumentInfoDialog(const std::function< void () >& 
aFunc)
+bool ModelData_Impl::ShowDocumentInfoDialog()
 {
     bool bDialogUsed = false;
 
@@ -1125,11 +1124,7 @@ bool ModelData_Impl::ShowDocumentInfoDialog(const 
std::function< void () >& aFun
                                                                                
 0 );
                     if ( xDispatch.is() )
                     {
-                        uno::Reference< lang::XUnoTunnel > aAsyncFunc(new 
AsyncFunc(aFunc));
-                        uno::Sequence< beans::PropertyValue > aProperties{
-                            comphelper::makePropertyValue("AsyncFunc", 
aAsyncFunc)
-                        };
-                        xDispatch->dispatch( aURL, aProperties );
+                        xDispatch->dispatch( aURL, uno::Sequence< 
beans::PropertyValue >() );
                         bDialogUsed = true;
                     }
                 }
@@ -1637,33 +1632,34 @@ bool SfxStoringHelper::GUIStoreModel( const 
uno::Reference< frame::XModel >& xMo
         uno::Reference<document::XDocumentProperties> xOldDocProps(
             xCloneable->createClone(), uno::UNO_QUERY_THROW);
 
-        std::function< void () > aFunc = [xModel, xOldDocProps, nStoreMode, 
aURL, aArgsSequence]() {
-            SfxStoringHelper aStoringHelper;
-            ModelData_Impl aModel(aStoringHelper, xModel, aArgsSequence );
-
-            try
-            {
-                if ( nStoreMode & EXPORT_REQUESTED )
-                    aModel.GetStorable()->storeToURL( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
-                else
-                    aModel.GetStorable()->storeAsURL( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
-            }
-            catch( const uno::Exception& )
-            {
-            }
+        // use dispatch API to show document info dialog
+        if ( aModelData.ShowDocumentInfoDialog() )
+            bDialogUsed = true;
+        else
+        {
+            OSL_FAIL( "Can't execute document info dialog!" );
+        }
 
+        try {
+            // Document properties can contain streams that should be freed 
before storing
+            aModelData.FreeDocumentProps();
+            if ( nStoreMode & EXPORT_REQUESTED )
+                aModelData.GetStorable()->storeToURL( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
+            else
+                aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
+        }
+        catch( const uno::Exception& )
+        {
             if ( nStoreMode & EXPORT_REQUESTED )
             {
-                SfxStoringHelper::SetDocInfoState(aModel.GetModel(), 
xOldDocProps);
+                SetDocInfoState(aModelData.GetModel(), xOldDocProps);
             }
-        };
+            throw;
+        }
 
-        // use dispatch API to show document info dialog
-        if ( aModelData.ShowDocumentInfoDialog(aFunc) )
-            bDialogUsed = true;
-        else
+        if ( nStoreMode & EXPORT_REQUESTED )
         {
-            OSL_FAIL( "Can't execute document info dialog!" );
+            SetDocInfoState(aModelData.GetModel(), xOldDocProps);
         }
     }
     else
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 67de2f96a547..3fb676dc4b0a 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <com/sun/star/drawing/XDrawView.hpp>
 
 #include <com/sun/star/security/DocumentSignatureInformation.hpp>
@@ -63,7 +64,6 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <tools/link.hxx>
 
-#include <asyncfunc.hxx>
 #include <sfx2/signaturestate.hxx>
 #include <sfx2/sfxresid.hxx>
 #include <sfx2/request.hxx>
@@ -623,14 +623,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                             pReq->AppendItem( SfxDocumentInfoItem( GetTitle(),
                                 getDocProperties(), aNewCmisProperties, 
IsUseUserData(), IsUseThumbnailSave() ) );
                         }
-
-                        css::uno::Reference< css::uno::XInterface > xInterface;
-                        const SfxUnoAnyItem* pUnoAny = 
pReq->GetArg<SfxUnoAnyItem>(FN_PARAM_2);
-                        AsyncFunc* pAsyncFunc = pUnoAny && 
(pUnoAny->GetValue() >>= xInterface ) ?
-                            
comphelper::getFromUnoTunnel<AsyncFunc>(xInterface) : nullptr;
-                        if (pAsyncFunc)
-                            pAsyncFunc->Execute();
-
                         pReq->Done();
                     }
                     else
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index 5f5aed2d208f..91bea023858e 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -58,16 +58,12 @@ using namespace ::com::sun::star::util;
 using namespace ::com::sun::star::frame;
 using namespace ::com::sun::star::container;
 
-SfxPoolItem* SfxUnoAnyItem::CreateDefault()
-{
-    return new SfxUnoAnyItem();
-}
+SfxPoolItem* SfxUnoAnyItem::CreateDefault() { SAL_WARN( "sfx", "No 
SfxUnoAnyItem factory available"); return nullptr; }
 
 SfxPoolItem* SfxUnoFrameItem::CreateDefault()
 {
     return new SfxUnoFrameItem();
 }
-
 void SfxFrame::Construct_Impl()
 {
     pImpl.reset(new SfxFrame_Impl);
@@ -443,10 +439,6 @@ bool SfxFrameItem::PutValue( const css::uno::Any& rVal, 
sal_uInt8 )
     return false;
 }
 
-SfxUnoAnyItem::SfxUnoAnyItem()
-    : SfxPoolItem( 0 )
-{
-}
 
 SfxUnoAnyItem::SfxUnoAnyItem( sal_uInt16 nWhichId, const css::uno::Any& rAny )
     : SfxPoolItem( nWhichId )

Reply via email to