[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jan 4 08:41:41 PST 2016


 sw/qa/extras/ooxmlexport/data/tscp.docx         |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx       |   13 +++++++------
 sw/qa/extras/ww8export/data/tscp.doc            |binary
 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(-)

New commits:
commit ce814d1a28bb1ff2e6df23e6ed8c256c948787af
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jan 4 17:39:58 2016 +0100

    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
    <http://www.tscp.org/wp-content/uploads/2013/08/TSCP_BAILSv1.pdf> that
    describes how to refer to BAF objects, so use that instead of our custom
    RDF statement / document metadata key names.
    
    Change-Id: Iac569608b05aa61547f664f2a5df7d46fe46da76

diff --git a/sw/qa/extras/ooxmlexport/data/tscp.docx b/sw/qa/extras/ooxmlexport/data/tscp.docx
index 3cda72d..bbb32b1 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 65203a6..0507fcc 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<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
-    uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, "urn:tscp:names:baf:1.1");
+    uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, "urn:bails");
     uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY);
     uno::Sequence< uno::Reference<rdf::XURI> > 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<sal_Int32>(1), aGraphNames.getLength());
     uno::Reference<rdf::XURI> xGraphName = aGraphNames[0];
     uno::Reference<rdf::XNamedGraph> 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<OUString, OUString> 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<OUString, OUString> 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<OUString, OUString> aActualStatements;
     xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>());
diff --git a/sw/qa/extras/ww8export/data/tscp.doc b/sw/qa/extras/ww8export/data/tscp.doc
index 7b710fc..9830b28 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 de10766..39c3fc8 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<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
-    uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, "urn:tscp:names:baf:1.1");
+    uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, "urn:bails");
     uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY);
     uno::Sequence< uno::Reference<rdf::XURI> > 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<sal_Int32>(1), aGraphNames.getLength());
     uno::Reference<rdf::XURI> xGraphName = aGraphNames[0];
     uno::Reference<rdf::XNamedGraph> 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<OUString, OUString> 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<OUString, OUString> 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<OUString, OUString> aActualStatements;
     xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>());
diff --git a/sw/source/core/doc/rdfhelper.cxx b/sw/source/core/doc/rdfhelper.cxx
index 83605ed..7f93813 100644
--- a/sw/source/core/doc/rdfhelper.cxx
+++ b/sw/source/core/doc/rdfhelper.cxx
@@ -9,6 +9,7 @@
 
 #include <rdfhelper.hxx>
 
+#include <com/sun/star/rdf/Literal.hpp>
 #include <com/sun/star/rdf/Statement.hpp>
 #include <com/sun/star/rdf/URI.hpp>
 #include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
@@ -68,7 +69,7 @@ void SwRDFHelper::addTextNodeStatement(const OUString& rType, const OUString& rP
     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);
+    uno::Reference<rdf::XLiteral> 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 c80eab7..de1e97c 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<OUString, OUString>& 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 2b9fded..6b4cade 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<OUString, OUString> aStatements = SwRDFHelper::getTextNodeStatements("urn:tscp:names:baf:1.1", *pTextNode);
+    std::map<OUString, OUString> 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 ae956e0..6503a68 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<OUString, OUString> aStatements = SwRDFHelper::getTextNodeStatements("urn:tscp:names:baf:1.1", rTextNode);
+    std::map<OUString, OUString> 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 dc9f094..27f4e39 100644
--- a/writerfilter/source/dmapper/SmartTagHandler.cxx
+++ b/writerfilter/source/dmapper/SmartTagHandler.cxx
@@ -9,17 +9,21 @@
 
 #include <SmartTagHandler.hxx>
 
+#include <com/sun/star/rdf/Literal.hpp>
 #include <com/sun/star/rdf/URI.hpp>
 
 #include <ooxml/resourceids.hxx>
 
 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<text::XTextRange>& xParagraph)
 
         for (const std::pair<OUString, OUString>& 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<text::XTextRange>& xParagraph)
             }
             uno::Reference<rdf::XNamedGraph> xGraph = m_xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName);
             uno::Reference<rdf::XURI> xKey = rdf::URI::create(m_xComponentContext, rAttribute.first);
-            uno::Reference<rdf::XURI> xValue = rdf::URI::create(m_xComponentContext, rAttribute.second);
+            uno::Reference<rdf::XLiteral> xValue = rdf::Literal::create(m_xComponentContext, rAttribute.second);
             xGraph->addStatement(xSubject, xKey, xValue);
         }
 


More information about the Libreoffice-commits mailing list