From 6e132dea8c33d106793a9e43c2c57406ae221a30 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 9 Dec 2015 15:01:46 +0100 Subject: sw: implement addition of statements in SwRDFHelper With this, the only thing that blocks the DOC import to handle smart tags is the lack of RDF metadata initialization in the filter. Change-Id: I33ab74c7d6ceaac42cc94fdf0b1dfcb0eaf61ab4 --- sw/source/core/doc/rdfhelper.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sw/source') diff --git a/sw/source/core/doc/rdfhelper.cxx b/sw/source/core/doc/rdfhelper.cxx index 25acac9720eb..70a885c0d46a 100644 --- a/sw/source/core/doc/rdfhelper.cxx +++ b/sw/source/core/doc/rdfhelper.cxx @@ -48,8 +48,25 @@ std::map SwRDFHelper::getTextNodeStatements(const OUString& return aRet; } -void SwRDFHelper::addTextNodeStatement(const OUString& /*rType*/, const OUString& /*rPath*/, SwTextNode& /*rTextNode*/, const OUString& /*rKey*/, const OUString& /*rValue*/) +void SwRDFHelper::addTextNodeStatement(const OUString& rType, const OUString& rPath, SwTextNode& rTextNode, const OUString& rKey, const OUString& rValue) { + uno::Reference xComponentContext(comphelper::getProcessComponentContext()); + uno::Reference xType = rdf::URI::create(xComponentContext, rType); + uno::Reference xDocumentMetadataAccess(rTextNode.GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY); + uno::Sequence< uno::Reference > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType); + uno::Reference xGraphName; + if (aGraphNames.hasElements()) + xGraphName = aGraphNames[0]; + else + { + uno::Sequence< uno::Reference > xTypes = { xType }; + xGraphName = xDocumentMetadataAccess->addMetadataFile(rPath, xTypes); + } + uno::Reference xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); + uno::Reference xSubject(SwXParagraph::CreateXParagraph(*rTextNode.GetDoc(), &rTextNode), uno::UNO_QUERY); + uno::Reference xKey = rdf::URI::create(xComponentContext, rKey); + uno::Reference xValue = rdf::URI::create(xComponentContext, rValue); + xGraph->addStatement(xSubject, xKey, xValue); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3