[Libreoffice-commits] core.git: writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Dec 1 06:49:16 PST 2015
writerfilter/source/dmapper/DomainMapper.cxx | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
New commits:
commit 8cf2c1353cfa5f95d1aa9551035fda721d5345d8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Dec 1 15:27:26 2015 +0100
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
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 86fcb86..572f444 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
{
More information about the Libreoffice-commits
mailing list