From 98b99ef61c6d725962cdbaa05ff90c9d1aa72d57 Mon Sep 17 00:00:00 2001
From: Michael Stahl <Michael.Stahl@cib.de>
Date: Fri, 15 Feb 2019 17:50:38 +0100
Subject: 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>
(cherry picked from commit 0a5ca5768f56db481dd3b947b3dddaab7ed96450)
Reviewed-on: https://gerrit.libreoffice.org/69101
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
---
 offapi/UnoApi_offapi.mk                            |  1 +
 ...ntDocumentsDocumentContentIdentifierFactory.idl | 59 ++++++++++++++++++++++
 2 files changed, 60 insertions(+)
 create mode 100644 offapi/com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.idl

(limited to 'offapi')

diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 9934fff83b8c..13a00192bd8c 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2656,6 +2656,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/frame,\
 	XToolbarController \
 	XToolbarControllerListener \
 	XTransientDocumentsDocumentContentFactory \
+	XTransientDocumentsDocumentContentIdentifierFactory \
 	XUIControllerFactory \
 	XUIControllerRegistration \
 	XUntitledNumbers \
diff --git a/offapi/com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.idl b/offapi/com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.idl
new file mode 100644
index 000000000000..26359db3eec5
--- /dev/null
+++ b/offapi/com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.idl
@@ -0,0 +1,59 @@
+/* -*- 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/.
+ *
+ */
+#ifndef __com_sun_star_frame_XTransientDocumentsDocumentContentIdentifierFactory_idl__
+#define __com_sun_star_frame_XTransientDocumentsDocumentContentIdentifierFactory_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/ucb/XContentIdentifier.idl>
+#include <com/sun/star/frame/XModel.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+
+
+module com { module sun { module star { module frame {
+
+/** a factory for identifiers of
+    com::sun::star::ucb::TransientDocumentsDocumentContents.
+
+    @see com::sun::star::document::OfficeDocument
+    @see com::sun::star::ucb::XContentIdentifier
+
+    @since LibreOffice 6.3
+*/
+interface XTransientDocumentsDocumentContentIdentifierFactory
+    : com::sun::star::uno::XInterface
+{
+    /** creates a com::sun::star::ucb::XContentIdentifier
+        based on a given com::sun::star::document::OfficeDocument.
+
+        @param Model
+            the document model for which a
+            com::sun::star::ucb::XContentIdentifier
+            is requested. The model must be an implementation of service
+            com::sun::star::document::OfficeDocument.
+
+        @returns
+            a content identifier based on the given document model.
+
+        @throws com::sun::star::lang::IllegalArgumentException
+            if the document model cannot be associated with content for any reason.
+    */
+    com::sun::star::ucb::XContentIdentifier
+    createDocumentContentIdentifier(
+            [in] com::sun::star::frame::XModel Model )
+        raises ( com::sun::star::lang::IllegalArgumentException );
+
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
cgit