summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-12-09 15:43:34 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-09 16:25:23 +0100
commitb7c2e9ae95ff41570f752ca43c361b249a65da77 (patch)
treecc0b064b91894d67a775313977af431c36b44ad9 /sw/source
parent6e132dea8c33d106793a9e43c2c57406ae221a30 (diff)
DOC import: initialize RDF metadata before importing document properties
With this, it is possible to import part of the document as RDF statements later when SwFltControlStack::SetAttrInDoc() gets an SwFltRDFMark. Previously SfxBaseModel member functions like getMetadataGraphsWithType() and addMetadataFile() failed, as they tried to find the already imported document in UCB, which failed, as the import was still in progress. To prevent that, do the same as the ODT import in XMLReader::Read(), part "RDF metadata". One trick here is the call to comphelper::OStorageHelper::GetTemporaryStorage(), which gives an empty storage. Ideally a wrapper class would be needed that works on a SotStorage, but implements embed::XStorage, but that would be only used to find that the real storage doesn't provide a manifest.rdf stream, which is always the case. So instead of writing such a wrapper, just give loadMetadataFromStorage() an empty storage, which will have the same result without writing lots of dead code. Change-Id: Id1897838b1477eee0489b706d51cb6f59898877b
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/ww8par.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 85557ceb344c..56a819b24973 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -144,6 +144,8 @@ using namespace nsHdFtFlags;
#include <comphelper/sequenceashashmap.hxx>
#include <oox/ole/vbaproject.hxx>
#include <oox/ole/olestorage.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <sfx2/DocumentMetadataAccess.hxx>
//#define VT_EMPTY 0
//#define VT_I4 3
@@ -4904,7 +4906,23 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
m_rDoc.SetDocumentType( SwDoc::DOCTYPE_MSWORD );
if (m_bNewDoc && m_pStg && !pGloss)
+ {
+ // Initialize RDF metadata, to be able to add statements during the import.
+ try
+ {
+ uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
+ uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+ const uno::Reference<rdf::XURI> xBaseURI(sfx2::createBaseURI(xComponentContext, xStorage, m_sBaseURL));
+ uno::Reference<task::XInteractionHandler> xHandler;
+ xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler);
+ }
+ catch (const uno::Exception& rException)
+ {
+ SAL_WARN("sw.ww8", "SwWW8ImplReader::CoreLoad: failed to initialize RDF metadata: " << rException.Message);
+ }
ReadDocInfo();
+ }
::ww8::WW8FibData * pFibData = new ::ww8::WW8FibData();