summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2018-07-09 20:20:10 -0400
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-09-06 16:51:29 +0200
commitd322bab9ab453f5012d9760b245bf1be624f324a (patch)
treefea1fdbb9433f206cb42874f61c27efa35a73dbd /sfx2/source
parent909ebe3b90c6632d35e9069641b9afb22b814ec9 (diff)
tdf#117895: "Edit document properties before saving"...
option leaves just-saved document modified; changes are not saved Change-Id: Icad48fe1edcfb4c10c40f297326c23110144df53 Reviewed-on: https://gerrit.libreoffice.org/57211 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/59142 Reviewed-by: Henry Castro <hcastro@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/control/asyncfunc.cxx63
-rw-r--r--sfx2/source/doc/guisaveas.cxx54
-rw-r--r--sfx2/source/doc/objserv.cxx9
-rw-r--r--sfx2/source/view/frame.cxx10
4 files changed, 110 insertions, 26 deletions
diff --git a/sfx2/source/control/asyncfunc.cxx b/sfx2/source/control/asyncfunc.cxx
new file mode 100644
index 000000000000..f27931dcbf09
--- /dev/null
+++ b/sfx2/source/control/asyncfunc.cxx
@@ -0,0 +1,63 @@
+/* -*- 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 <sfx2/asyncfunc.hxx>
+#include <comphelper/servicehelper.hxx>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+namespace
+{
+class theAsyncFuncUnoTunnelId : public rtl::Static<UnoTunnelIdInit, theAsyncFuncUnoTunnelId>
+{
+};
+}
+
+AsyncFunc::AsyncFunc(const std::function<void()>& rAsyncFunc)
+ : m_pAsyncFunc(rAsyncFunc)
+{
+}
+
+AsyncFunc::~AsyncFunc() {}
+
+void AsyncFunc::Execute()
+{
+ if (m_pAsyncFunc)
+ m_pAsyncFunc();
+}
+
+const css::uno::Sequence<sal_Int8>& AsyncFunc::getUnoTunnelId()
+{
+ return theAsyncFuncUnoTunnelId::get().getSeq();
+}
+
+AsyncFunc* AsyncFunc::getImplementation(const css::uno::Reference<css::uno::XInterface>& xInterface)
+{
+ css::uno::Reference<css::lang::XUnoTunnel> xUnoTunnel(xInterface, css::uno::UNO_QUERY);
+ if (xUnoTunnel.is())
+ {
+ return reinterpret_cast<AsyncFunc*>(xUnoTunnel->getSomething(AsyncFunc::getUnoTunnelId()));
+ }
+
+ return nullptr;
+}
+
+//XUnoTunnel
+sal_Int64 SAL_CALL AsyncFunc::getSomething(const css::uno::Sequence<sal_Int8>& rId)
+{
+ if (rId.getLength() == 16
+ && 0 == memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16))
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 1f5472b3087e..42c7ec928b46 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -75,6 +75,7 @@
#include <sfx2/sfxresid.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/filedlghelper.hxx>
+#include <sfx2/asyncfunc.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/request.hxx>
@@ -334,7 +335,7 @@ public:
const css::uno::Sequence< OUString >& rBlackList
);
- bool ShowDocumentInfoDialog();
+ bool ShowDocumentInfoDialog(const std::function< void () >&);
static OUString GetRecommendedExtension( const OUString& aTypeName );
OUString GetRecommendedDir( const OUString& aSuggestedDir );
@@ -1102,7 +1103,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
}
-bool ModelData_Impl::ShowDocumentInfoDialog()
+bool ModelData_Impl::ShowDocumentInfoDialog(const std::function< void () >& aFunc)
{
bool bDialogUsed = false;
@@ -1125,7 +1126,11 @@ bool ModelData_Impl::ShowDocumentInfoDialog()
0 );
if ( xDispatch.is() )
{
- xDispatch->dispatch( aURL, uno::Sequence< beans::PropertyValue >() );
+ uno::Sequence< beans::PropertyValue > aProperties(1);
+ uno::Reference< lang::XUnoTunnel > aAsyncFunc(new AsyncFunc(aFunc));
+ aProperties[0].Name = "AsyncFunc";
+ aProperties[0].Value <<= aAsyncFunc;
+ xDispatch->dispatch( aURL, aProperties );
bDialogUsed = true;
}
}
@@ -1631,34 +1636,33 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
uno::Reference<document::XDocumentProperties> xOldDocProps(
xCloneable->createClone(), uno::UNO_QUERY_THROW);
- // use dispatch API to show document info dialog
- if ( aModelData.ShowDocumentInfoDialog() )
- bDialogUsed = true;
- else
- {
- OSL_FAIL( "Can't execute document info dialog!" );
- }
+ 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& )
+ {
+ }
- 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 )
{
- SetDocInfoState(aModelData.GetModel(), xOldDocProps, true);
+ SfxStoringHelper::SetDocInfoState(aModel.GetModel(), xOldDocProps, true);
}
- throw;
- }
+ };
- if ( nStoreMode & EXPORT_REQUESTED )
+ // use dispatch API to show document info dialog
+ if ( aModelData.ShowDocumentInfoDialog(aFunc) )
+ bDialogUsed = true;
+ else
{
- SetDocInfoState(aModelData.GetModel(), xOldDocProps, true);
+ OSL_FAIL( "Can't execute document info dialog!" );
}
}
else
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 291f59a51d8f..8267795cc6cd 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -66,6 +66,7 @@
#include <comphelper/storagehelper.hxx>
#include <tools/link.hxx>
+#include <sfx2/asyncfunc.hxx>
#include <sfx2/app.hxx>
#include <sfx2/signaturestate.hxx>
#include <sfx2/sfxresid.hxx>
@@ -496,6 +497,14 @@ 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 ) ?
+ AsyncFunc::getImplementation(xInterface) : nullptr;
+ if (pAsyncFunc)
+ pAsyncFunc->Execute();
+
pReq->Done();
}
else
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index 8441d12c0a32..82591b21c8fa 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -73,12 +73,16 @@ using namespace ::com::sun::star::util;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::container;
-SfxPoolItem* SfxUnoAnyItem::CreateDefault() { SAL_WARN( "sfx", "No SfxUnoAnyItem factory available"); return nullptr; }
+SfxPoolItem* SfxUnoAnyItem::CreateDefault()
+{
+ return new SfxUnoAnyItem();
+}
SfxPoolItem* SfxUnoFrameItem::CreateDefault()
{
return new SfxUnoFrameItem();
}
+
void SfxFrame::Construct_Impl()
{
pImpl.reset(new SfxFrame_Impl);
@@ -456,6 +460,10 @@ 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 )