sfx2: port checkRDFa from Java to CppUnittest
TESTRDFA.odt is still used by checkTdf123293. (To be ported in a follow-up commit) while at it, move existing 'hello.odt' file from misc to data, this is the normal folder name for files everywhere Change-Id: I3ab12550e1d2e7654cb59c55c6da40b6c28b7e46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169888 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
@@ -91,7 +91,6 @@ public class DocumentMetadataAccess
|
||||
|
||||
XURI foo;
|
||||
XURI bar;
|
||||
XURI baz;
|
||||
|
||||
static XURI rdf_type;
|
||||
static XURI rdfs_label;
|
||||
@@ -100,11 +99,6 @@ public class DocumentMetadataAccess
|
||||
static XURI pkg_MetadataFile;
|
||||
static XURI odf_ContentFile;
|
||||
static XURI odf_StylesFile;
|
||||
static XURI odf_Element;
|
||||
static XBlankNode blank1;
|
||||
static XBlankNode blank2;
|
||||
static XBlankNode blank3;
|
||||
static XBlankNode blank4;
|
||||
static String manifestPath = "manifest.rdf";
|
||||
static String contentPath = "content.xml";
|
||||
static String stylesPath = "styles.xml";
|
||||
@@ -139,17 +133,7 @@ public class DocumentMetadataAccess
|
||||
assertNotNull("foo", foo);
|
||||
bar = URI.create(xContext, "uri:bar");
|
||||
assertNotNull("bar", bar);
|
||||
baz = URI.create(xContext, "uri:baz");
|
||||
assertNotNull("baz", baz);
|
||||
|
||||
blank1 = BlankNode.create(xContext, "_:1");
|
||||
assertNotNull("blank1", blank1);
|
||||
blank2 = BlankNode.create(xContext, "_:2");
|
||||
assertNotNull("blank2", blank2);
|
||||
blank3 = BlankNode.create(xContext, "_:3");
|
||||
assertNotNull("blank3", blank3);
|
||||
blank4 = BlankNode.create(xContext, "_:4");
|
||||
assertNotNull("blank4", blank4);
|
||||
rdf_type = URI.createKnown(xContext, URIs.RDF_TYPE);
|
||||
assertNotNull("rdf_type", rdf_type);
|
||||
rdfs_label = URI.createKnown(xContext, URIs.RDFS_LABEL);
|
||||
@@ -164,8 +148,6 @@ public class DocumentMetadataAccess
|
||||
assertNotNull("odf_ContentFile", odf_ContentFile);
|
||||
odf_StylesFile = URI.createKnown(xContext, URIs.ODF_STYLESFILE);
|
||||
assertNotNull("odf_StylesFile", odf_StylesFile);
|
||||
odf_Element = URI.createKnown(xContext, URIs.ODF_ELEMENT);
|
||||
assertNotNull("odf_Element", odf_Element);
|
||||
}
|
||||
|
||||
@After public void after()
|
||||
@@ -596,25 +578,6 @@ public class DocumentMetadataAccess
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void checkRDFa() throws Exception
|
||||
{
|
||||
XComponent xComp = null;
|
||||
try {
|
||||
final String file = TestDocument.getUrl("TESTRDFA.odt");
|
||||
xComp = loadRDFa(file);
|
||||
if (xComp != null)
|
||||
{
|
||||
final String sNewFile = tempDir + "TESTRDFA.odt";
|
||||
storeRDFa(xComp, sNewFile);
|
||||
close(xComp);
|
||||
|
||||
xComp = loadRDFa(sNewFile);
|
||||
}
|
||||
} finally {
|
||||
close(xComp);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkTdf123293() throws Exception
|
||||
{
|
||||
@@ -630,232 +593,6 @@ public class DocumentMetadataAccess
|
||||
}
|
||||
}
|
||||
|
||||
private void storeRDFa(XComponent xComp, String file) throws com.sun.star.io.IOException
|
||||
{
|
||||
System.out.println("Storing test document...");
|
||||
|
||||
XStorable xStor = UnoRuntime.queryInterface(XStorable.class, xComp);
|
||||
|
||||
xStor.storeToURL(file, new PropertyValue[0]);
|
||||
|
||||
System.out.println("...done");
|
||||
}
|
||||
|
||||
private XComponent loadRDFa(String file) throws Exception
|
||||
{
|
||||
XComponent xComp = null;
|
||||
|
||||
System.out.println("Loading test document...");
|
||||
|
||||
PropertyValue[] loadProps = new PropertyValue[1];
|
||||
loadProps[0] = new PropertyValue();
|
||||
loadProps[0].Name = "Hidden";
|
||||
loadProps[0].Value = true;
|
||||
|
||||
|
||||
|
||||
xComp = util.DesktopTools.loadDoc(xMSF, file, loadProps);
|
||||
|
||||
XRepositorySupplier xRepoSupplier = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp);
|
||||
assertTrue("xRS null", null != xRepoSupplier);
|
||||
|
||||
XDocumentRepository xDocRepository = UnoRuntime.queryInterface(XDocumentRepository.class, xRepoSupplier.getRDFRepository());
|
||||
assertTrue("xRep null", null != xDocRepository);
|
||||
|
||||
XTextDocument xTextDoc = UnoRuntime.queryInterface(XTextDocument.class, xComp);
|
||||
|
||||
XText xText = xTextDoc.getText();
|
||||
|
||||
XEnumerationAccess xEA = UnoRuntime.queryInterface(XEnumerationAccess.class, xText);
|
||||
XEnumeration xEnum = xEA.createEnumeration();
|
||||
|
||||
System.out.println("...done");
|
||||
|
||||
System.out.println("Checking RDFa in loaded test document...");
|
||||
|
||||
XMetadatable xPara;
|
||||
Pair<Statement[], Boolean> result;
|
||||
|
||||
Statement x_FooBarLit1 = new Statement(foo, bar, mkLit("1"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 1",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit1
|
||||
}));
|
||||
|
||||
Statement x_FooBarLit2 = new Statement(foo, bar, mkLit("2"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 2",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit2
|
||||
}));
|
||||
|
||||
Statement x_BlankBarLit3 =
|
||||
new Statement(blank1, bar, mkLit("3"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 3",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_BlankBarLit3
|
||||
}));
|
||||
XBlankNode b3 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);
|
||||
|
||||
Statement x_BlankBarLit4 =
|
||||
new Statement(blank2, bar, mkLit("4"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 4",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_BlankBarLit4
|
||||
}));
|
||||
XBlankNode b4 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);
|
||||
|
||||
Statement x_BlankBarLit5 =
|
||||
new Statement(blank1, bar, mkLit("5"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 5",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_BlankBarLit5
|
||||
}));
|
||||
XBlankNode b5 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);
|
||||
|
||||
assertTrue("RDFa: 3 != 4",
|
||||
!b3.getStringValue().equals(b4.getStringValue()));
|
||||
assertTrue("RDFa: 3 == 5",
|
||||
b3.getStringValue().equals(b5.getStringValue()));
|
||||
|
||||
Statement x_FooBarLit6 = new Statement(foo, bar, mkLit("6"), null);
|
||||
Statement x_FooBazLit6 = new Statement(foo, baz, mkLit("6"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 6",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit6, x_FooBazLit6
|
||||
}));
|
||||
|
||||
Statement x_FooBarLit7 = new Statement(foo, bar, mkLit("7"), null);
|
||||
Statement x_FooBazLit7 = new Statement(foo, baz, mkLit("7"), null);
|
||||
Statement x_FooFooLit7 = new Statement(foo, foo, mkLit("7"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 7",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit7, x_FooBazLit7, x_FooFooLit7
|
||||
}));
|
||||
|
||||
XNode lit = mkLit("a fooish bar");
|
||||
XNode lit_type= mkLit("a fooish bar", bar);
|
||||
Statement x_FooBarLit = new Statement(foo, bar, lit, null);
|
||||
Statement x_FooBarLittype = new Statement(foo, bar, lit_type, null);
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 8",
|
||||
result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit
|
||||
}));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 9",
|
||||
result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit
|
||||
}));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 10",
|
||||
result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLittype
|
||||
}));
|
||||
|
||||
Statement x_FooBarLit11
|
||||
= new Statement(foo, bar, mkLit("11", bar), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 11",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit11
|
||||
}));
|
||||
|
||||
XURI xFile = URI.createNS(xContext, file, "/" + contentPath);
|
||||
Statement x_FileBarLit12 =
|
||||
new Statement(xFile, bar, mkLit("12"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 12",
|
||||
!result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FileBarLit12
|
||||
}));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 13",
|
||||
result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
x_FooBarLit
|
||||
}));
|
||||
|
||||
new Statement(foo, rdfs_label, mkLit("14"), null);
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 14",
|
||||
result.Second &&
|
||||
eq(result.First, new Statement[] {
|
||||
/* x_FooLabelLit14 */ x_FooBarLit
|
||||
}));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 15", eq(result.First, new Statement[] { } ));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 16", eq(result.First, new Statement[] { } ));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 17", eq(result.First, new Statement[] { } ));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 18", eq(result.First, new Statement[] { } ));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 19", eq(result.First, new Statement[] { } ));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(
|
||||
XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 20", eq(result.First, new Statement[] { } ));
|
||||
|
||||
xPara = UnoRuntime.queryInterface(
|
||||
XMetadatable.class, xEnum.nextElement());
|
||||
result = xDocRepository.getStatementRDFa(xPara);
|
||||
assertTrue("RDFa: 21", eq(result.First, new Statement[] { } ));
|
||||
|
||||
System.out.println("...done");
|
||||
|
||||
return xComp;
|
||||
}
|
||||
|
||||
|
||||
// utilities -------------------------------------------------------------
|
||||
|
||||
static void close(XComponent i_comp)
|
||||
|
||||
Binary file not shown.
@@ -19,12 +19,19 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/plugin/TestPlugIn.h>
|
||||
|
||||
#include <com/sun/star/beans/Pair.hpp>
|
||||
#include <com/sun/star/beans/PropertyState.hpp>
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
#include <com/sun/star/document/DocumentProperties.hpp>
|
||||
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
|
||||
#include <com/sun/star/frame/Desktop.hpp>
|
||||
#include <com/sun/star/frame/XStorable.hpp>
|
||||
#include <com/sun/star/rdf/Statement.hpp>
|
||||
#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
|
||||
#include <com/sun/star/rdf/XDocumentRepository.hpp>
|
||||
#include <com/sun/star/rdf/XRepository.hpp>
|
||||
#include <com/sun/star/text/XTextDocument.hpp>
|
||||
#include <comphelper/sequence.hxx>
|
||||
|
||||
#include <test/unoapixml_test.hxx>
|
||||
|
||||
@@ -45,10 +52,11 @@ class MiscTest
|
||||
{
|
||||
public:
|
||||
MiscTest()
|
||||
: UnoApiXmlTest(u"/sfx2/qa/cppunit/misc/"_ustr)
|
||||
: UnoApiXmlTest(u"/sfx2/qa/cppunit/data/"_ustr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override
|
||||
{
|
||||
// ODF
|
||||
@@ -194,6 +202,255 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testOverwrite)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<rdf::Statement>
|
||||
sortStatementsByPredicate(const uno::Sequence<rdf::Statement>& rStatements)
|
||||
{
|
||||
std::vector<rdf::Statement> aStatements
|
||||
= comphelper::sequenceToContainer<std::vector<rdf::Statement>>(rStatements);
|
||||
std::sort(aStatements.begin(), aStatements.end(),
|
||||
[](const rdf::Statement& a, const rdf::Statement& b) {
|
||||
return a.Predicate->getStringValue() < b.Predicate->getStringValue();
|
||||
});
|
||||
return aStatements;
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(MiscTest, testRDFa)
|
||||
{
|
||||
auto verify = [this](bool bIsExport) {
|
||||
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
|
||||
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
|
||||
uno::UNO_QUERY);
|
||||
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
|
||||
|
||||
uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(mxComponent,
|
||||
uno::UNO_QUERY);
|
||||
uno::Reference<rdf::XRepository> xRepo = xDocumentMetadataAccess->getRDFRepository();
|
||||
uno::Reference<rdf::XDocumentRepository> xDocRepo(xRepo, uno::UNO_QUERY);
|
||||
CPPUNIT_ASSERT(xDocRepo);
|
||||
|
||||
{
|
||||
// RDFa: 1
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("1"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 2
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("2"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
|
||||
OUString aSubject3;
|
||||
OUString aSubject4;
|
||||
OUString aSubject5;
|
||||
{
|
||||
// RDFa: 3
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
aSubject3 = aStatements[0].Subject->getStringValue();
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("3"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 4
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
aSubject4 = aStatements[0].Subject->getStringValue();
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("4"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 5
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
aSubject5 = aStatements[0].Subject->getStringValue();
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("5"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(aSubject3 != aSubject4);
|
||||
CPPUNIT_ASSERT_EQUAL(aSubject3, aSubject5);
|
||||
|
||||
{
|
||||
// RDFa: 6
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
|
||||
std::vector<rdf::Statement> aStatements = sortStatementsByPredicate(xResult.First);
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aStatements.size());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("6"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[1].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:baz"), aStatements[1].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("6"), aStatements[1].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 7
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
std::vector<rdf::Statement> aStatements = sortStatementsByPredicate(xResult.First);
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(3), aStatements.size());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("7"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[1].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:baz"), aStatements[1].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("7"), aStatements[1].Object->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[2].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[2].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("7"), aStatements[2].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 8
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("a fooish bar"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 9
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("a fooish bar"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 10
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("a fooish bar^^uri:bar"),
|
||||
aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 11
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("11^^uri:bar"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 12
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
OUString aSubject;
|
||||
if (bIsExport)
|
||||
aSubject = maTempFile.GetURL() + "/content.xml";
|
||||
else
|
||||
aSubject = createFileURL(u"TESTRDFA.odt") + "/content.xml";
|
||||
CPPUNIT_ASSERT_EQUAL(aSubject, aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("12"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(!xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 13
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("a fooish bar"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(xResult.Second);
|
||||
}
|
||||
{
|
||||
// RDFa: 14
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aStatements.getLength());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:foo"), aStatements[0].Subject->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("uri:bar"), aStatements[0].Predicate->getStringValue());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("a fooish bar"), aStatements[0].Object->getStringValue());
|
||||
CPPUNIT_ASSERT(xResult.Second);
|
||||
}
|
||||
|
||||
// Remaning rdfs should be empty
|
||||
do
|
||||
{
|
||||
uno::Reference<rdf::XMetadatable> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
::beans::Pair<uno::Sequence<rdf::Statement>, sal_Bool> xResult
|
||||
= xDocRepo->getStatementRDFa(xPara);
|
||||
uno::Sequence<rdf::Statement> aStatements = xResult.First;
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aStatements.getLength());
|
||||
} while (xParaEnum->hasMoreElements());
|
||||
};
|
||||
|
||||
loadFromFile(u"TESTRDFA.odt");
|
||||
verify(/*bIsExport*/ false);
|
||||
saveAndReload(u"writer8"_ustr);
|
||||
verify(/*bIsExport*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
Reference in New Issue
Block a user