summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-12-09 15:01:46 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-09 16:25:22 +0100
commit6e132dea8c33d106793a9e43c2c57406ae221a30 (patch)
treeac0ece2d6438a880920642795ca0afb0f066a72d /sw
parentda5e8ba393b8522a8f7501ebeb1e9a98d544a7ba (diff)
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
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/rdfhelper.cxx19
1 files changed, 18 insertions, 1 deletions
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<OUString, OUString> 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<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
+ uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, rType);
+ uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(rTextNode.GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
+ uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType);
+ uno::Reference<rdf::XURI> xGraphName;
+ if (aGraphNames.hasElements())
+ xGraphName = aGraphNames[0];
+ else
+ {
+ uno::Sequence< uno::Reference<rdf::XURI> > xTypes = { xType };
+ xGraphName = xDocumentMetadataAccess->addMetadataFile(rPath, xTypes);
+ }
+ uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName);
+ uno::Reference<rdf::XResource> xSubject(SwXParagraph::CreateXParagraph(*rTextNode.GetDoc(), &rTextNode), uno::UNO_QUERY);
+ uno::Reference<rdf::XURI> xKey = rdf::URI::create(xComponentContext, rKey);
+ uno::Reference<rdf::XURI> xValue = rdf::URI::create(xComponentContext, rValue);
+ xGraph->addStatement(xSubject, xKey, xValue);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */