diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-02 17:00:17 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-02 17:16:17 +0100 |
commit | 08e5fc257fa8c106be34bb034ebe5e00b6fcf711 (patch) | |
tree | edcc122c1591380c63957436837818e5d94a97e5 /sw/qa/extras/ooxmlexport | |
parent | 5402ac4e006b9aac6944f7fb9f1a9f256a754472 (diff) |
DOCX export: handle <w:smartTag>
A Writer document can have multiple arbitrary RDF graphs, handle the following
subset:
- instead of handling all graphs, have a whitelist, look at the TSCP graph the
DOCX importer creates
- look for (paragraph, key, value) statements and export those
Change-Id: I142c24fb4c8140bde5fc1efad2932886de167b90
Diffstat (limited to 'sw/qa/extras/ooxmlexport')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tscp.docx | bin | 0 -> 4758 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 40 |
2 files changed, 40 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tscp.docx b/sw/qa/extras/ooxmlexport/data/tscp.docx Binary files differnew file mode 100644 index 000000000000..3cda72de572e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tscp.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index b4b8896ea57f..c0979dbff9df 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -49,6 +49,8 @@ #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/Hatch.hpp> +#include <com/sun/star/rdf/URI.hpp> +#include <com/sun/star/rdf/Statement.hpp> #include <string> @@ -85,6 +87,44 @@ DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx") assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0); } +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::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. + 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); + + // No RDF statement on the first paragraph. + uno::Reference<rdf::XResource> xParagraph(getParagraph(1), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); + CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements())); + + // 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> aActualStatements; + xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); + while (xStatements->hasMoreElements()) + { + rdf::Statement aStatement = xStatements->nextElement().get<rdf::Statement>(); + aActualStatements[aStatement.Predicate->getNamespace() + aStatement.Predicate->getLocalName()] = aStatement.Object->getStringValue(); + } + CPPUNIT_ASSERT(aExpectedStatements == aActualStatements); + + // No RDF statement on the third paragraph. + xParagraph.set(getParagraph(3), uno::UNO_QUERY); + xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); + CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements())); +} + DECLARE_OOXMLEXPORT_TEST(testfdo76589 , "fdo76589.docx") { /* Numbered list was not preserve after RT. |