From ce814d1a28bb1ff2e6df23e6ed8c256c948787af Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 4 Jan 2016 17:39:58 +0100 Subject: DOC(X) filter: BAF -> BAILS in the smart tag mapping The filters map between a common subset of Word smart tags and Writer RDF annotations, and when doing so, they need to know what path to use for a smart tag namespace and also the other way around: what RDF types are interesting for smart tag purposes. It turns out there is BAILS specification at that describes how to refer to BAF objects, so use that instead of our custom RDF statement / document metadata key names. Change-Id: Iac569608b05aa61547f664f2a5df7d46fe46da76 --- sw/qa/extras/ooxmlexport/data/tscp.docx | Bin 4758 -> 4878 bytes sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 13 +++++++------ sw/qa/extras/ww8export/data/tscp.doc | Bin 23040 -> 10240 bytes sw/qa/extras/ww8export/ww8export.cxx | 13 +++++++------ sw/source/core/doc/rdfhelper.cxx | 3 ++- sw/source/filter/basflt/fltshell.cxx | 15 +++++++-------- sw/source/filter/ww8/docxattributeoutput.cxx | 2 +- sw/source/filter/ww8/wrtww8.cxx | 2 +- writerfilter/source/dmapper/SmartTagHandler.cxx | 18 +++++++++--------- 9 files changed, 34 insertions(+), 32 deletions(-) diff --git a/sw/qa/extras/ooxmlexport/data/tscp.docx b/sw/qa/extras/ooxmlexport/data/tscp.docx index 3cda72de572e..bbb32b178bd9 100644 Binary files a/sw/qa/extras/ooxmlexport/data/tscp.docx and b/sw/qa/extras/ooxmlexport/data/tscp.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 65203a6437b7..0507fcca7693 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -90,10 +90,10 @@ DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx") DECLARE_OOXMLEXPORT_TEST(testTscp, "tscp.docx") { uno::Reference xComponentContext(comphelper::getProcessComponentContext()); - uno::Reference xType = rdf::URI::create(xComponentContext, "urn:tscp:names:baf:1.1"); + uno::Reference xType = rdf::URI::create(xComponentContext, "urn:bails"); uno::Reference xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY); uno::Sequence< uno::Reference > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType); - // This failed, no graphs had the urn:tscp:names:baf:1.1 type. + // This failed, no graphs had the urn:bails type. CPPUNIT_ASSERT_EQUAL(static_cast(1), aGraphNames.getLength()); uno::Reference xGraphName = aGraphNames[0]; uno::Reference xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); @@ -105,10 +105,11 @@ DECLARE_OOXMLEXPORT_TEST(testTscp, "tscp.docx") // 3 RDF statements on the second paragraph. xParagraph.set(getParagraph(2), uno::UNO_QUERY); - std::map aExpectedStatements = { - {"urn:tscp:names:baf:1.1#BusinessAuthorization", "urn:example:tscp:1"}, - {"urn:tscp:names:baf:1.1#BusinessAuthorizationCategory", "urn:example:tscp:1:confidential"}, - {"urn:tscp:names:baf:1.1#BusinessAuthorizationDate", "2015-11-27T11:45:00"} + std::map aExpectedStatements = + { + {"urn:bails:ExportControl:BusinessAuthorization:Identifier", "urn:example:tscp:1"}, + {"urn:bails:ExportControl:BusinessAuthorizationCategory:Identifier", "urn:example:tscp:1:confidential"}, + {"urn:bails:ExportControl:Authorization:StartValidity", "2015-11-27"} }; std::map aActualStatements; xStatements = xGraph->getStatements(xParagraph, uno::Reference(), uno::Reference()); diff --git a/sw/qa/extras/ww8export/data/tscp.doc b/sw/qa/extras/ww8export/data/tscp.doc index 7b710fcab770..9830b288c1a4 100644 Binary files a/sw/qa/extras/ww8export/data/tscp.doc and b/sw/qa/extras/ww8export/data/tscp.doc differ diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index de107665d665..39c3fc80e8ea 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -103,10 +103,10 @@ DECLARE_WW8EXPORT_TEST(testN325936, "n325936.doc") DECLARE_WW8EXPORT_TEST(testTscp, "tscp.doc") { uno::Reference xComponentContext(comphelper::getProcessComponentContext()); - uno::Reference xType = rdf::URI::create(xComponentContext, "urn:tscp:names:baf:1.1"); + uno::Reference xType = rdf::URI::create(xComponentContext, "urn:bails"); uno::Reference xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY); uno::Sequence< uno::Reference > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType); - // This failed, no graphs had the urn:tscp:names:baf:1.1 type. + // This failed, no graphs had the urn:bails type. CPPUNIT_ASSERT_EQUAL(static_cast(1), aGraphNames.getLength()); uno::Reference xGraphName = aGraphNames[0]; uno::Reference xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); @@ -118,10 +118,11 @@ DECLARE_WW8EXPORT_TEST(testTscp, "tscp.doc") // 3 RDF statements on the second paragraph. xParagraph.set(getParagraph(2), uno::UNO_QUERY); - std::map aExpectedStatements = { - {"urn:tscp:names:baf:1.1#BusinessAuthorization", "urn:example:tscp:1"}, - {"urn:tscp:names:baf:1.1#BusinessAuthorizationCategory", "urn:example:tscp:1:confidential"}, - {"urn:tscp:names:baf:1.1#BusinessAuthorizationDate", "2015-11-27T11:45:00"} + std::map aExpectedStatements = + { + {"urn:bails:ExportControl:BusinessAuthorization:Identifier", "urn:example:tscp:1"}, + {"urn:bails:ExportControl:BusinessAuthorizationCategory:Identifier", "urn:example:tscp:1:confidential"}, + {"urn:bails:ExportControl:Authorization:StartValidity", "2015-11-27"} }; std::map aActualStatements; xStatements = xGraph->getStatements(xParagraph, uno::Reference(), uno::Reference()); diff --git a/sw/source/core/doc/rdfhelper.cxx b/sw/source/core/doc/rdfhelper.cxx index 83605ed4858a..7f9381329ae4 100644 --- a/sw/source/core/doc/rdfhelper.cxx +++ b/sw/source/core/doc/rdfhelper.cxx @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -68,7 +69,7 @@ void SwRDFHelper::addTextNodeStatement(const OUString& rType, const OUString& rP 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); + uno::Reference xValue = rdf::Literal::create(xComponentContext, rValue); xGraph->addStatement(xSubject, xKey, xValue); } diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index c80eab7701d0..de1e97cd4763 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -81,11 +81,14 @@ static SwContentNode* GetContentNode(SwDoc* pDoc, SwNodeIndex& rIdx, bool bNext) return pCNd; } -static OUString lcl_getTypePath(const OUString& rType) +static OUString lcl_getTypePath(OUString& rType) { OUString aRet; - if (rType == "urn:tscp:names:baf:1.1") - aRet = "tscp/baf.rdf"; + if (rType.startsWith("urn:bails")) + { + rType = "urn:bails"; + aRet = "tscp/bails.rdf"; + } return aRet; } @@ -634,11 +637,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, for (const std::pair& rAttribute : pMark->GetAttributes()) { - sal_Int32 nIndex = rAttribute.first.indexOf('#'); - if (nIndex == -1) - continue; - - OUString aTypeNS = rAttribute.first.copy(0, nIndex); + OUString aTypeNS = rAttribute.first; OUString aMetadataFilePath = lcl_getTypePath(aTypeNS); if (aMetadataFilePath.isEmpty()) continue; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 2b9fdedc9ba5..6b4cadee2331 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1038,7 +1038,7 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar // RDF metadata for this text node. SwTextNode* pTextNode = m_rExport.m_pCurPam->GetNode().GetTextNode(); - std::map aStatements = SwRDFHelper::getTextNodeStatements("urn:tscp:names:baf:1.1", *pTextNode); + std::map aStatements = SwRDFHelper::getTextNodeStatements("urn:bails", *pTextNode); if (!aStatements.empty()) { m_pSerializer->startElementNS(XML_w, XML_smartTag, diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index ae956e04be3b..6503a6886ae0 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -1501,7 +1501,7 @@ void WW8Export::AppendAnnotationMarks(const SwTextNode& rNode, sal_Int32 nAktPos void WW8Export::AppendSmartTags(const SwTextNode& rTextNode) { - std::map aStatements = SwRDFHelper::getTextNodeStatements("urn:tscp:names:baf:1.1", rTextNode); + std::map aStatements = SwRDFHelper::getTextNodeStatements("urn:bails", rTextNode); if (!aStatements.empty()) { WW8_CP nCP = Fc2Cp(Strm().Tell()); diff --git a/writerfilter/source/dmapper/SmartTagHandler.cxx b/writerfilter/source/dmapper/SmartTagHandler.cxx index dc9f094e4917..27f4e393db7d 100644 --- a/writerfilter/source/dmapper/SmartTagHandler.cxx +++ b/writerfilter/source/dmapper/SmartTagHandler.cxx @@ -9,17 +9,21 @@ #include +#include #include #include namespace { -OUString lcl_getTypePath(const OUString& rType) +OUString lcl_getTypePath(OUString& rType) { OUString aRet; - if (rType == "urn:tscp:names:baf:1.1") - aRet = "tscp/baf.rdf"; + if (rType.startsWith("urn:bails")) + { + rType = "urn:bails"; + aRet = "tscp/bails.rdf"; + } return aRet; } } @@ -91,11 +95,7 @@ void SmartTagHandler::handle(const uno::Reference& xParagraph) for (const std::pair& rAttribute : m_aAttributes) { - sal_Int32 nIndex = rAttribute.first.indexOf('#'); - if (nIndex == -1) - continue; - - OUString aTypeNS = rAttribute.first.copy(0, nIndex); + OUString aTypeNS = rAttribute.first; OUString aMetadataFilePath = lcl_getTypePath(aTypeNS); if (aMetadataFilePath.isEmpty()) continue; @@ -112,7 +112,7 @@ void SmartTagHandler::handle(const uno::Reference& xParagraph) } uno::Reference xGraph = m_xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); uno::Reference xKey = rdf::URI::create(m_xComponentContext, rAttribute.first); - uno::Reference xValue = rdf::URI::create(m_xComponentContext, rAttribute.second); + uno::Reference xValue = rdf::Literal::create(m_xComponentContext, rAttribute.second); xGraph->addStatement(xSubject, xKey, xValue); } -- cgit