summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-02-15 17:50:38 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-02-20 07:54:42 +0100
commit0a5ca5768f56db481dd3b947b3dddaab7ed96450 (patch)
tree59eb8e570e98485aaf0d3587a1876f0fe9add6e9 /ucb
parentb95fa8525d42574ecce2c04f92b602c022adbd92 (diff)
tdf#123293 sfx2: fix metadata loss when loading from stream
The problem is that when loading from a stream, there is no BaseURL and also no storage for the document. Due to the lack of BaseURL, the sfx2::createBaseURI() throws and loading RDF metadata fails, which also pops up an annoying warning dialog. Try to handle this in a similar way than a newly created document (see GetDMA()), by using the vnd.sun.star.tdoc scheme URL for the document; this however currently requires that the document has a XStorage, which is also not the case here. So add another UNO method to tdoc UCP's tdoc_ucp::ContentProvider, to split out the creation of the tdoc schema URL from the creation of the ucb Content, to get rid of the XStorage requirement. Change-Id: Ica62743f9d21db0b1464b70db1a62ebc61989ef8 Reviewed-on: https://gerrit.libreoffice.org/67882 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/tdoc/tdoc_provider.cxx27
-rw-r--r--ucb/source/ucp/tdoc/tdoc_provider.hxx13
2 files changed, 29 insertions, 11 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx
index fef2f3145f5e..fdcfd241502c 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx
@@ -88,6 +88,7 @@ css::uno::Any SAL_CALL ContentProvider::queryInterface( const css::uno::Type & r
static_cast< lang::XTypeProvider* >(this),
static_cast< lang::XServiceInfo* >(this),
static_cast< ucb::XContentProvider* >(this),
+ static_cast< frame::XTransientDocumentsDocumentContentIdentifierFactory* >(this),
static_cast< frame::XTransientDocumentsDocumentContentFactory* >(this)
);
return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
@@ -96,10 +97,11 @@ css::uno::Any SAL_CALL ContentProvider::queryInterface( const css::uno::Type & r
// XTypeProvider methods.
-XTYPEPROVIDER_IMPL_4( ContentProvider,
+XTYPEPROVIDER_IMPL_5( ContentProvider,
lang::XTypeProvider,
lang::XServiceInfo,
ucb::XContentProvider,
+ frame::XTransientDocumentsDocumentContentIdentifierFactory,
frame::XTransientDocumentsDocumentContentFactory );
@@ -164,13 +166,11 @@ ContentProvider::queryContent(
}
-// XTransientDocumentsDocumentContentFactory methods.
-
+// XTransientDocumentsDocumentContentIdentifierFactory methods.
-// virtual
-uno::Reference< ucb::XContent > SAL_CALL
-ContentProvider::createDocumentContent(
- const uno::Reference< frame::XModel >& Model )
+uno::Reference<ucb::XContentIdentifier> SAL_CALL
+ContentProvider::createDocumentContentIdentifier(
+ uno::Reference<frame::XModel> const& xModel)
{
// model -> id -> content identifier -> queryContent
if ( !m_xDocsMgr.is() )
@@ -181,7 +181,7 @@ ContentProvider::createDocumentContent(
1 );
}
- OUString aDocId = tdoc_ucp::OfficeDocumentsManager::queryDocumentId( Model );
+ OUString aDocId = tdoc_ucp::OfficeDocumentsManager::queryDocumentId(xModel);
if ( aDocId.isEmpty() )
{
throw lang::IllegalArgumentException(
@@ -196,6 +196,17 @@ ContentProvider::createDocumentContent(
uno::Reference< ucb::XContentIdentifier > xId
= new ::ucbhelper::ContentIdentifier( aBuffer.makeStringAndClear() );
+ return xId;
+}
+
+// XTransientDocumentsDocumentContentFactory methods.
+
+uno::Reference< ucb::XContent > SAL_CALL
+ContentProvider::createDocumentContent(
+ uno::Reference<frame::XModel> const& xModel)
+{
+ uno::Reference<ucb::XContentIdentifier> const xId(
+ createDocumentContentIdentifier(xModel));
osl::MutexGuard aGuard( m_aMutex );
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.hxx b/ucb/source/ucp/tdoc/tdoc_provider.hxx
index 2f308bf3ff5c..f1dc515b1b84 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.hxx
@@ -22,6 +22,7 @@
#include <rtl/ref.hxx>
#include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
+#include <com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.hpp>
#include <com/sun/star/packages/WrongPasswordException.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -53,9 +54,10 @@ namespace tdoc_ucp {
class StorageElementFactory;
-class ContentProvider :
- public ::ucbhelper::ContentProviderImplHelper,
- public css::frame::XTransientDocumentsDocumentContentFactory
+class ContentProvider
+ : public ::ucbhelper::ContentProviderImplHelper
+ , public css::frame::XTransientDocumentsDocumentContentIdentifierFactory
+ , public css::frame::XTransientDocumentsDocumentContentFactory
{
public:
explicit ContentProvider( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
@@ -88,6 +90,11 @@ public:
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override;
+ // XTransientDocumentsDocumentContentIdentifierFactory
+ virtual css::uno::Reference<css::ucb::XContentIdentifier> SAL_CALL
+ createDocumentContentIdentifier(
+ css::uno::Reference<css::frame::XModel> const& xModel) override;
+
// XTransientDocumentsDocumentContentFactory
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
createDocumentContent( const css::uno::Reference<