diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-01 15:27:26 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-01 15:47:29 +0100 |
commit | 8cf2c1353cfa5f95d1aa9551035fda721d5345d8 (patch) | |
tree | ec4375325436513bad36d0c15457563a0e93d14a | |
parent | 585507a4127ff91d9360ca16938dbd36153aef0d (diff) |
DOCX import: initialize RDF metadata before importing document properties
With this, it is possible to import part of the document as RDF
statements later when parsing document.xml.
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".
Change-Id: Ia15af9bb0681cbc25fe745742c24af82cd213e5d
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 86fcb86c21fb..572f4444ea75 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -66,6 +66,8 @@ #include <comphelper/storagehelper.hxx> #include <comphelper/sequence.hxx> #include <filter/msfilter/util.hxx> +#include <sfx2/DocumentMetadataAccess.hxx> +#include <unotools/mediadescriptor.hxx> #include <TextEffectsHandler.hxx> #include <CellColorHandler.hxx> @@ -115,6 +117,22 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon // Don't load the default style definitions to avoid weird mix m_pImpl->SetDocumentSettingsProperty("StylesNoDefault", uno::makeAny(true)); + // Initialize RDF metadata, to be able to add statements during the import. + try + { + uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel, uno::UNO_QUERY_THROW); + uno::Reference<embed::XStorage> xStorage(comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xContext, bRepairStorage)); + OUString aBaseURL = rMediaDesc.getUnpackedValueOrDefault("URL", OUString()); + OUString aStreamPath; + const uno::Reference<rdf::XURI> xBaseURI(sfx2::createBaseURI(xContext, xStorage, aBaseURL, aStreamPath)); + const uno::Reference<task::XInteractionHandler> xHandler; + xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); + } + catch (const uno::Exception& rException) + { + SAL_WARN("writerfilter", "DomainMapper::DomainMapper: failed to initialize RDF metadata: " << rException.Message); + } + //import document properties try { |