summaryrefslogtreecommitdiff
path: root/sfx2/qa
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-07-07 16:37:59 +0200
committerNoel Grandin <noel@peralex.com>2015-07-08 08:33:48 +0200
commit3c4da0f6fda6d6cf376cae77417d813e1d21d740 (patch)
tree340413f1358d8c3a81b7d199c2b243240857a7c8 /sfx2/qa
parentaf4121416c8f4c88385765ec16a7569104ed2714 (diff)
java: let the unit-test framework catch exceptions
and report them for us, instead of inventing our own mechanisms Change-Id: Id9186a2b01dad33c377e4785e1ca07bccea48b07
Diffstat (limited to 'sfx2/qa')
-rw-r--r--sfx2/qa/complex/sfx2/DocumentMetadataAccess.java622
-rw-r--r--sfx2/qa/complex/sfx2/DocumentProperties.java657
-rw-r--r--sfx2/qa/complex/sfx2/UndoManager.java58
-rw-r--r--sfx2/qa/complex/sfx2/tools/WriterHelper.java22
-rw-r--r--sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java23
5 files changed, 665 insertions, 717 deletions
diff --git a/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java
index 5b6bc0cadf44..b871a1c3f36a 100644
--- a/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java
+++ b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java
@@ -18,55 +18,58 @@
package complex.sfx2;
-import com.sun.star.beans.Pair;
-import com.sun.star.rdf.Literal;
-import com.sun.star.rdf.XLiteral;
-import com.sun.star.rdf.XNamedGraph;
-import com.sun.star.rdf.BlankNode;
-import com.sun.star.rdf.XQuerySelectResult;
-import com.sun.star.rdf.XNode;
-import com.sun.star.rdf.XDocumentRepository;
-import com.sun.star.rdf.XMetadatable;
-import com.sun.star.rdf.Statement;
-import com.sun.star.rdf.FileFormat;
-import com.sun.star.rdf.URIs;
-import com.sun.star.rdf.URI;
-import com.sun.star.rdf.XDocumentMetadataAccess;
-import com.sun.star.rdf.XRepositorySupplier;
-import com.sun.star.rdf.XRepository;
-import com.sun.star.rdf.XBlankNode;
-import com.sun.star.rdf.XURI;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import helper.StreamSimulator;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XComponent;
+import java.io.IOException;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.lang.IllegalArgumentException;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.beans.StringPair;
-import com.sun.star.container.XEnumerationAccess;
-import com.sun.star.container.XEnumeration;
-import com.sun.star.io.XInputStream;
-import com.sun.star.util.XCloseable;
-import com.sun.star.frame.XStorable;
-import com.sun.star.text.XTextDocument;
-import com.sun.star.text.XTextRange;
-import com.sun.star.text.XText;
-import complex.sfx2.tools.TestDocument;
import lib.TestParameters;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openoffice.test.OfficeConnection;
-import static org.junit.Assert.*;
+
+import com.sun.star.beans.Pair;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.StringPair;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.XInputStream;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.rdf.BlankNode;
+import com.sun.star.rdf.FileFormat;
+import com.sun.star.rdf.Literal;
+import com.sun.star.rdf.Statement;
+import com.sun.star.rdf.URI;
+import com.sun.star.rdf.URIs;
+import com.sun.star.rdf.XBlankNode;
+import com.sun.star.rdf.XDocumentMetadataAccess;
+import com.sun.star.rdf.XDocumentRepository;
+import com.sun.star.rdf.XLiteral;
+import com.sun.star.rdf.XMetadatable;
+import com.sun.star.rdf.XNamedGraph;
+import com.sun.star.rdf.XNode;
+import com.sun.star.rdf.XQuerySelectResult;
+import com.sun.star.rdf.XRepository;
+import com.sun.star.rdf.XRepositorySupplier;
+import com.sun.star.rdf.XURI;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextRange;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XCloseable;
+import complex.sfx2.tools.TestDocument;
/**
* Test case for interface com.sun.star.rdf.XDocumentMetadataAccess
@@ -119,58 +122,52 @@ public class DocumentMetadataAccess
*/
private static TestParameters param = null;
- @Before public void before()
+ @Before public void before() throws Exception
{
- try {
-
- xMSF = getMSF();
- param = new TestParameters();
- param.put("ServiceFactory", xMSF); // important for param.getMSF()
-
- assertNotNull("could not create MultiServiceFactory.", xMSF);
- XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xMSF);
- Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext");
- xContext = UnoRuntime.queryInterface(XComponentContext.class, defaultCtx);
- assertNotNull("could not get component context.", xContext);
-
- tempDir = util.utils.getOfficeTemp/*Dir*/(xMSF);
- System.out.println("tempdir: " + tempDir);
-
- foo = URI.create(xContext, "uri:foo");
- 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);
- assertNotNull("rdfs_label", rdfs_label);
- pkg_Document = URI.createKnown(xContext, URIs.PKG_DOCUMENT);
- assertNotNull("pkg_Document", pkg_Document);
- pkg_hasPart = URI.createKnown(xContext, URIs.PKG_HASPART);
- assertNotNull("pkg_hasPart", pkg_hasPart);
- pkg_MetadataFile = URI.createKnown(xContext, URIs.PKG_METADATAFILE);
- assertNotNull("pkg_MetadataFile", pkg_MetadataFile);
- odf_ContentFile = URI.createKnown(xContext, URIs.ODF_CONTENTFILE);
- 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);
-
- } catch (Exception e) {
- report(e);
- }
+ xMSF = getMSF();
+ param = new TestParameters();
+ param.put("ServiceFactory", xMSF); // important for param.getMSF()
+
+ assertNotNull("could not create MultiServiceFactory.", xMSF);
+ XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xMSF);
+ Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext");
+ xContext = UnoRuntime.queryInterface(XComponentContext.class, defaultCtx);
+ assertNotNull("could not get component context.", xContext);
+
+ tempDir = util.utils.getOfficeTemp/*Dir*/(xMSF);
+ System.out.println("tempdir: " + tempDir);
+
+ foo = URI.create(xContext, "uri:foo");
+ 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);
+ assertNotNull("rdfs_label", rdfs_label);
+ pkg_Document = URI.createKnown(xContext, URIs.PKG_DOCUMENT);
+ assertNotNull("pkg_Document", pkg_Document);
+ pkg_hasPart = URI.createKnown(xContext, URIs.PKG_HASPART);
+ assertNotNull("pkg_hasPart", pkg_hasPart);
+ pkg_MetadataFile = URI.createKnown(xContext, URIs.PKG_METADATAFILE);
+ assertNotNull("pkg_MetadataFile", pkg_MetadataFile);
+ odf_ContentFile = URI.createKnown(xContext, URIs.ODF_CONTENTFILE);
+ 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()
@@ -180,7 +177,7 @@ public class DocumentMetadataAccess
xDMA = null;
}
- @Test public void check()
+ @Test public void check() throws Exception
{
XComponent xComp = null;
XComponent xComp2 = null;
@@ -595,15 +592,13 @@ public class DocumentMetadataAccess
System.out.println("...done");
- } catch (Exception e) {
- report(e);
} finally {
close(xComp);
close(xComp2);
}
}
- @Test public void checkRDFa()
+ @Test public void checkRDFa() throws Exception
{
XComponent xComp = null;
try {
@@ -622,251 +617,234 @@ public class DocumentMetadataAccess
}
}
- private void storeRDFa(XComponent xComp, String file)
+ private void storeRDFa(XComponent xComp, String file) throws com.sun.star.io.IOException
{
- try {
+ System.out.println("Storing test document...");
- System.out.println("Storing test document...");
+ XStorable xStor = UnoRuntime.queryInterface(XStorable.class, xComp);
- XStorable xStor = UnoRuntime.queryInterface(XStorable.class, xComp);
+ xStor.storeToURL(file, new PropertyValue[0]);
- xStor.storeToURL(file, new PropertyValue[0]);
-
- System.out.println("...done");
-
- } catch (Exception e) {
- report(e);
- }
+ System.out.println("...done");
}
- private XComponent loadRDFa(String file)
+ private XComponent loadRDFa(String file) throws Exception
{
XComponent xComp = null;
- try {
-
- 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
- }));
+ 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");
- 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");
-
- } catch (Exception e) {
- report(e);
- close(xComp);
- }
return xComp;
}
// utilities -------------------------------------------------------------
- public void report(Exception e) {
- System.out.println("Exception occurred:");
- e.printStackTrace(System.err);
- fail();
- }
-
static void close(XComponent i_comp)
{
try {
diff --git a/sfx2/qa/complex/sfx2/DocumentProperties.java b/sfx2/qa/complex/sfx2/DocumentProperties.java
index 8edda78be1ce..0d21cdb15e35 100644
--- a/sfx2/qa/complex/sfx2/DocumentProperties.java
+++ b/sfx2/qa/complex/sfx2/DocumentProperties.java
@@ -84,76 +84,76 @@ public class DocumentProperties
}
}
- @Test public void check() {
- try {
- XMultiServiceFactory xMSF = getMSF();
- assertNotNull("could not create MultiServiceFactory.", xMSF);
- XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xMSF);
- Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext");
- XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, defaultCtx);
- assertNotNull("could not get component context.", xContext);
+ @Test public void check() throws Exception
+ {
+ XMultiServiceFactory xMSF = getMSF();
+ assertNotNull("could not create MultiServiceFactory.", xMSF);
+ XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xMSF);
+ Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext");
+ XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, defaultCtx);
+ assertNotNull("could not get component context.", xContext);
- // TODO: Path to temp
- String temp = util.utils.getOfficeTemp/*Dir*/(xMSF);
- System.out.println("tempdir: " + temp);
+ // TODO: Path to temp
+ String temp = util.utils.getOfficeTemp/*Dir*/(xMSF);
+ System.out.println("tempdir: " + temp);
- PropertyValue[] noArgs = { };
- PropertyValue mimetype = new PropertyValue();
- mimetype.Name = "MediaType";
- mimetype.Value = "application/vnd.oasis.opendocument.text";
- PropertyValue[] mimeArgs = { mimetype };
- PropertyValue cfile = new PropertyValue();
- cfile.Name = "URL";
- cfile.Value = temp + "EMPTY.odt";
- PropertyValue[] mimeEmptyArgs = { mimetype, cfile };
+ PropertyValue[] noArgs = { };
+ PropertyValue mimetype = new PropertyValue();
+ mimetype.Name = "MediaType";
+ mimetype.Value = "application/vnd.oasis.opendocument.text";
+ PropertyValue[] mimeArgs = { mimetype };
+ PropertyValue cfile = new PropertyValue();
+ cfile.Name = "URL";
+ cfile.Value = temp + "EMPTY.odt";
+ PropertyValue[] mimeEmptyArgs = { mimetype, cfile };
- System.out.println("Creating service DocumentProperties...");
+ System.out.println("Creating service DocumentProperties...");
- Object oDP =
- xMSF.createInstance("com.sun.star.document.DocumentProperties");
- XDocumentProperties xDP = UnoRuntime.queryInterface(XDocumentProperties.class, oDP);
+ Object oDP =
+ xMSF.createInstance("com.sun.star.document.DocumentProperties");
+ XDocumentProperties xDP = UnoRuntime.queryInterface(XDocumentProperties.class, oDP);
- System.out.println("...done");
+ System.out.println("...done");
- System.out.println("Checking initialize ...");
+ System.out.println("Checking initialize ...");
- XDocumentProperties xDP2 = UnoRuntime.queryInterface(XDocumentProperties.class, xMSF.createInstance("com.sun.star.document.DocumentProperties"));
- XInitialization xInit = UnoRuntime.queryInterface(XInitialization.class, xDP2);
- xInit.initialize(new Object[] { });
+ XDocumentProperties xDP2 = UnoRuntime.queryInterface(XDocumentProperties.class, xMSF.createInstance("com.sun.star.document.DocumentProperties"));
+ XInitialization xInit = UnoRuntime.queryInterface(XInitialization.class, xDP2);
+ xInit.initialize(new Object[] { });
- System.out.println("...done");
+ System.out.println("...done");
- System.out.println("Checking storing default-initialized meta data ...");
+ System.out.println("Checking storing default-initialized meta data ...");
- xDP2.storeToMedium("", mimeEmptyArgs);
+ xDP2.storeToMedium("", mimeEmptyArgs);
- System.out.println("...done");
+ System.out.println("...done");
- System.out.println("Checking loading default-initialized meta data ...");
+ System.out.println("Checking loading default-initialized meta data ...");
- xDP2.loadFromMedium("", mimeEmptyArgs);
- assertEquals("Author", "", xDP2.getAuthor());
+ xDP2.loadFromMedium("", mimeEmptyArgs);
+ assertEquals("Author", "", xDP2.getAuthor());
- System.out.println("...done");
+ System.out.println("...done");
- System.out.println("(Not) Checking preservation of custom meta data ...");
+ System.out.println("(Not) Checking preservation of custom meta data ...");
- xDP2.loadFromMedium(TestDocument.getUrl("CUSTOM.odt"),
- noArgs);
- assertEquals("Author", "", xDP2.getAuthor());
- xDP2.storeToMedium(temp + "CUSTOM.odt", mimeArgs);
+ xDP2.loadFromMedium(TestDocument.getUrl("CUSTOM.odt"),
+ noArgs);
+ assertEquals("Author", "", xDP2.getAuthor());
+ xDP2.storeToMedium(temp + "CUSTOM.odt", mimeArgs);
- //FIXME: now what? comparing for binary equality seems useless
- // we could unzip the written file and grep for the custom stuff
- // but would that work on windows...
+ //FIXME: now what? comparing for binary equality seems useless
+ // we could unzip the written file and grep for the custom stuff
+ // but would that work on windows...
- System.out.println("...done");
+ System.out.println("...done");
- System.out.println("Checking loading from test document...");
+ System.out.println("Checking loading from test document...");
- String file = TestDocument.getUrl("TEST.odt");
- xDP.loadFromMedium(file, noArgs);
+ String file = TestDocument.getUrl("TEST.odt");
+ xDP.loadFromMedium(file, noArgs);
/* XInputStream xStream =
new StreamSimulator("./testdocuments/TEST.odt", true, param);
Object oSF =
@@ -166,298 +166,294 @@ public class DocumentProperties
XStorage.class, oStor);
xDP.loadFromStorage(xStor);*/
- System.out.println("...done");
-
- System.out.println("Checking meta-data import...");
-
- assertEquals("Author", "Karl-Heinz Mustermann", xDP.getAuthor());
- assertEquals(
- "Generator",
- "StarOffice/8$Solaris_x86 OpenOffice.org_project/680m232$Build-9227",
- xDP.getGenerator());
- assertEquals("CreationDate", 2007, xDP.getCreationDate().Year);
- assertEquals("Title", "Urgent Memo", xDP.getTitle());
- assertEquals("Subject", "Wichtige Mitteilung", xDP.getSubject());
- assertEquals(
- "Description",
- "Modern internal company memorandum in full-blocked style",
- xDP.getDescription());
- assertEquals(
- "ModifiedBy", "Karl-Heinz Mustermann", xDP.getModifiedBy());
- assertEquals(
- "ModificationDate", 10, xDP.getModificationDate().Month);
- assertEquals(
- "PrintedBy", "Karl-Heinz Mustermann", xDP.getPrintedBy());
- assertEquals("PrintDate", 29, xDP.getPrintDate().Day);
- assertEquals("TemplateName", "Modern Memo", xDP.getTemplateName());
- assertTrue("TemplateURL",
- xDP.getTemplateURL().endsWith("memmodern.ott"));
- assertEquals("TemplateDate", 17, xDP.getTemplateDate().Hours);
- assertTrue(
- "AutoloadURL", xDP.getAutoloadURL().endsWith("/TEST.odt"));
- assertEquals("AutoloadSecs", 0, xDP.getAutoloadSecs());
- assertEquals("DefaultTarget", "_blank", xDP.getDefaultTarget());
- assertEquals("EditingCycles", 3, xDP.getEditingCycles());
- assertEquals("EditingDuration", 320, xDP.getEditingDuration());
-
- String[] kws = xDP.getKeywords();
- assertTrue("Keywords", fromArray(kws).containsAll(
- fromArray(new Object[] { "Asien", "Memo", "Reis" })));
-
- NamedValue[] ds = xDP.getDocumentStatistics();
- assertTrue("DocumentStatistics:WordCount", containsNV(ds,
- new NamedValue("WordCount", Integer.valueOf(23))));
- assertTrue("DocumentStatistics:PageCount", containsNV(ds,
- new NamedValue("PageCount", Integer.valueOf(1))));
-
- XPropertyContainer udpc = xDP.getUserDefinedProperties();
- XPropertySet udps = UnoRuntime.queryInterface( XPropertySet.class, udpc );
- assertEquals(
- "UserDefined 1", "Dies ist ein wichtiger Hinweis",
- udps.getPropertyValue("Hinweis"));
- assertEquals(
- "UserDefined 2", "Kann Spuren von N\u00FCssen enthalten",
- udps.getPropertyValue("Warnung"));
-
- System.out.println("...done");
-
- System.out.println("Checking meta-data updates...");
-
- String str;
- DateTime dt = new DateTime();
- Locale l = new Locale();
- int i;
-
- str = "me";
- xDP.setAuthor(str);
- assertEquals("setAuthor", str, xDP.getAuthor());
- str = "the computa";
- xDP.setGenerator(str);
- assertEquals("setGenerator", str, xDP.getGenerator());
- dt.Year = 2038;
- dt.Month = 1;
- dt.Day = 1;
- xDP.setCreationDate(dt);
- assertEquals(
- "setCreationDate", dt.Year, xDP.getCreationDate().Year);
- str = "El t'itulo";
- xDP.setTitle(str);
- assertEquals("setTitle", str, xDP.getTitle());
- str = "Ein verkommenes Subjekt";
- xDP.setSubject(str);
- assertEquals("setSubject", str, xDP.getSubject());
- str = "Este descripci'on no es importante";
- xDP.setDescription(str);
- assertEquals("setDescription", str, xDP.getDescription());
- l.Language = "en";
- l.Country = "GB";
- xDP.setLanguage(l);
- Locale l2 = xDP.getLanguage();
- assertEquals("setLanguage Lang", l.Language, l2.Language);
- assertEquals("setLanguage Cty", l.Country, l2.Country);
- str = "myself";
- xDP.setModifiedBy(str);
- assertEquals("setModifiedBy", str, xDP.getModifiedBy());
- dt.Year = 2042;
- xDP.setModificationDate(dt);
- assertEquals(
- "setModificationDate", dt.Year, xDP.getModificationDate().Year);
- str = "i did not do it";
- xDP.setPrintedBy(str);
- assertEquals("setPrintedBy", str, xDP.getPrintedBy());
- dt.Year = 2024;
- xDP.setPrintDate(dt);
- assertEquals("setPrintDate", dt.Year, xDP.getPrintDate().Year);
- str = "blah";
- xDP.setTemplateName(str);
- assertEquals("setTemplateName", str, xDP.getTemplateName());
- str = "gopher://some-hole-in-the-ground/";
- xDP.setTemplateURL(str);
- assertEquals("setTemplateURL", str, xDP.getTemplateURL());
- dt.Year = 2043;
- xDP.setTemplateDate(dt);
- assertEquals(
- "setTemplateDate", dt.Year, xDP.getTemplateDate().Year);
- str = "http://nowhere/";
- xDP.setAutoloadURL(str);
- assertEquals("setAutoloadURL", str, xDP.getAutoloadURL());
- i = 3661; // this might not work (due to conversion via double...)
- xDP.setAutoloadSecs(i);
- assertEquals("setAutoloadSecs", i, xDP.getAutoloadSecs());
- str = "_blank";
- xDP.setDefaultTarget(str);
- assertEquals("setDefaultTarget", str, xDP.getDefaultTarget());
- i = 42;
- xDP.setEditingCycles((short) i);
- assertEquals("setEditingCycles", i, xDP.getEditingCycles());
- i = 84;
- xDP.setEditingDuration(i);
- assertEquals("setEditingDuration", i, xDP.getEditingDuration());
- str = "";
-
- String[] kws2 = new String[] {
- "keywordly", "keywordlike", "keywordalicious" };
- xDP.setKeywords(kws2);
- kws = xDP.getKeywords();
- assertTrue("setKeywords", fromArray(kws).containsAll(fromArray(kws2)));
-
- NamedValue[] ds2 = new NamedValue[] {
- new NamedValue("SyllableCount", Integer.valueOf(9)),
- new NamedValue("FrameCount", Integer.valueOf(2)),
- new NamedValue("SentenceCount", Integer.valueOf(7)) };
- xDP.setDocumentStatistics(ds2);
- ds = xDP.getDocumentStatistics();
- assertTrue("setDocumentStatistics:SyllableCount", containsNV(ds,
- new NamedValue("SyllableCount", Integer.valueOf(9))));
- assertTrue("setDocumentStatistics:FrameCount", containsNV(ds,
- new NamedValue("FrameCount", Integer.valueOf(2))));
- assertTrue("setDocumentStatistics:SentenceCount", containsNV(ds,
- new NamedValue("SentenceCount", Integer.valueOf(7))));
-
- System.out.println("...done");
-
- System.out.println("Checking user-defined meta-data updates...");
-
- // actually, this tests the PropertyBag service
- // but maybe the DocumentProperties service will be implemented
- // differently some day...
- boolean b = true;
- double d = 3.1415;
- // note that Time is only supported for backward compatibility!
- Time t = new Time();
- t.Hours = 1;
- t.Minutes = 16;
- Date date = new Date();
- date.Year = 2071;
- date.Month = 2;
- date.Day = 3;
- dt.Year = 2065;
- Duration dur = new Duration();
- dur.Negative = true;
- dur.Years = 1001;
- dur.Months = 999;
- dur.Days = 888;
- dur.Hours = 777;
- dur.Minutes = 666;
- dur.Seconds = 555;
- dur.NanoSeconds = 444444444;
-
- udpc.addProperty("Frobnicate", PropertyAttribute.REMOVABLE, b);
- udpc.addProperty("FrobDuration", PropertyAttribute.REMOVABLE, dur);
- udpc.addProperty("FrobDuration2", PropertyAttribute.REMOVABLE, t);
- udpc.addProperty("FrobEndDate", PropertyAttribute.REMOVABLE, date);
- udpc.addProperty("FrobStartTime", PropertyAttribute.REMOVABLE, dt);
- udpc.addProperty("Pi", PropertyAttribute.REMOVABLE, new Double(d));
- udpc.addProperty("Foo", PropertyAttribute.REMOVABLE, "bar");
- udpc.addProperty("Removed", PropertyAttribute.REMOVABLE, "bar");
- // #i94175#: empty property name is valid ODF 1.1
- udpc.addProperty("", PropertyAttribute.REMOVABLE, "eeeeek");
- try {
- udpc.removeProperty("Info 1");
- udpc.removeProperty("Removed");
- } catch (UnknownPropertyException e) {
- fail("removeProperty failed");
- }
+ System.out.println("...done");
+
+ System.out.println("Checking meta-data import...");
+
+ assertEquals("Author", "Karl-Heinz Mustermann", xDP.getAuthor());
+ assertEquals(
+ "Generator",
+ "StarOffice/8$Solaris_x86 OpenOffice.org_project/680m232$Build-9227",
+ xDP.getGenerator());
+ assertEquals("CreationDate", 2007, xDP.getCreationDate().Year);
+ assertEquals("Title", "Urgent Memo", xDP.getTitle());
+ assertEquals("Subject", "Wichtige Mitteilung", xDP.getSubject());
+ assertEquals(
+ "Description",
+ "Modern internal company memorandum in full-blocked style",
+ xDP.getDescription());
+ assertEquals(
+ "ModifiedBy", "Karl-Heinz Mustermann", xDP.getModifiedBy());
+ assertEquals(
+ "ModificationDate", 10, xDP.getModificationDate().Month);
+ assertEquals(
+ "PrintedBy", "Karl-Heinz Mustermann", xDP.getPrintedBy());
+ assertEquals("PrintDate", 29, xDP.getPrintDate().Day);
+ assertEquals("TemplateName", "Modern Memo", xDP.getTemplateName());
+ assertTrue("TemplateURL",
+ xDP.getTemplateURL().endsWith("memmodern.ott"));
+ assertEquals("TemplateDate", 17, xDP.getTemplateDate().Hours);
+ assertTrue(
+ "AutoloadURL", xDP.getAutoloadURL().endsWith("/TEST.odt"));
+ assertEquals("AutoloadSecs", 0, xDP.getAutoloadSecs());
+ assertEquals("DefaultTarget", "_blank", xDP.getDefaultTarget());
+ assertEquals("EditingCycles", 3, xDP.getEditingCycles());
+ assertEquals("EditingDuration", 320, xDP.getEditingDuration());
+
+ String[] kws = xDP.getKeywords();
+ assertTrue("Keywords", fromArray(kws).containsAll(
+ fromArray(new Object[] { "Asien", "Memo", "Reis" })));
+
+ NamedValue[] ds = xDP.getDocumentStatistics();
+ assertTrue("DocumentStatistics:WordCount", containsNV(ds,
+ new NamedValue("WordCount", Integer.valueOf(23))));
+ assertTrue("DocumentStatistics:PageCount", containsNV(ds,
+ new NamedValue("PageCount", Integer.valueOf(1))));
+
+ XPropertyContainer udpc = xDP.getUserDefinedProperties();
+ XPropertySet udps = UnoRuntime.queryInterface( XPropertySet.class, udpc );
+ assertEquals(
+ "UserDefined 1", "Dies ist ein wichtiger Hinweis",
+ udps.getPropertyValue("Hinweis"));
+ assertEquals(
+ "UserDefined 2", "Kann Spuren von N\u00FCssen enthalten",
+ udps.getPropertyValue("Warnung"));
+
+ System.out.println("...done");
+
+ System.out.println("Checking meta-data updates...");
+
+ String str;
+ DateTime dt = new DateTime();
+ Locale l = new Locale();
+ int i;
+
+ str = "me";
+ xDP.setAuthor(str);
+ assertEquals("setAuthor", str, xDP.getAuthor());
+ str = "the computa";
+ xDP.setGenerator(str);
+ assertEquals("setGenerator", str, xDP.getGenerator());
+ dt.Year = 2038;
+ dt.Month = 1;
+ dt.Day = 1;
+ xDP.setCreationDate(dt);
+ assertEquals(
+ "setCreationDate", dt.Year, xDP.getCreationDate().Year);
+ str = "El t'itulo";
+ xDP.setTitle(str);
+ assertEquals("setTitle", str, xDP.getTitle());
+ str = "Ein verkommenes Subjekt";
+ xDP.setSubject(str);
+ assertEquals("setSubject", str, xDP.getSubject());
+ str = "Este descripci'on no es importante";
+ xDP.setDescription(str);
+ assertEquals("setDescription", str, xDP.getDescription());
+ l.Language = "en";
+ l.Country = "GB";
+ xDP.setLanguage(l);
+ Locale l2 = xDP.getLanguage();
+ assertEquals("setLanguage Lang", l.Language, l2.Language);
+ assertEquals("setLanguage Cty", l.Country, l2.Country);
+ str = "myself";
+ xDP.setModifiedBy(str);
+ assertEquals("setModifiedBy", str, xDP.getModifiedBy());
+ dt.Year = 2042;
+ xDP.setModificationDate(dt);
+ assertEquals(
+ "setModificationDate", dt.Year, xDP.getModificationDate().Year);
+ str = "i did not do it";
+ xDP.setPrintedBy(str);
+ assertEquals("setPrintedBy", str, xDP.getPrintedBy());
+ dt.Year = 2024;
+ xDP.setPrintDate(dt);
+ assertEquals("setPrintDate", dt.Year, xDP.getPrintDate().Year);
+ str = "blah";
+ xDP.setTemplateName(str);
+ assertEquals("setTemplateName", str, xDP.getTemplateName());
+ str = "gopher://some-hole-in-the-ground/";
+ xDP.setTemplateURL(str);
+ assertEquals("setTemplateURL", str, xDP.getTemplateURL());
+ dt.Year = 2043;
+ xDP.setTemplateDate(dt);
+ assertEquals(
+ "setTemplateDate", dt.Year, xDP.getTemplateDate().Year);
+ str = "http://nowhere/";
+ xDP.setAutoloadURL(str);
+ assertEquals("setAutoloadURL", str, xDP.getAutoloadURL());
+ i = 3661; // this might not work (due to conversion via double...)
+ xDP.setAutoloadSecs(i);
+ assertEquals("setAutoloadSecs", i, xDP.getAutoloadSecs());
+ str = "_blank";
+ xDP.setDefaultTarget(str);
+ assertEquals("setDefaultTarget", str, xDP.getDefaultTarget());
+ i = 42;
+ xDP.setEditingCycles((short) i);
+ assertEquals("setEditingCycles", i, xDP.getEditingCycles());
+ i = 84;
+ xDP.setEditingDuration(i);
+ assertEquals("setEditingDuration", i, xDP.getEditingDuration());
+ str = "";
+
+ String[] kws2 = new String[] {
+ "keywordly", "keywordlike", "keywordalicious" };
+ xDP.setKeywords(kws2);
+ kws = xDP.getKeywords();
+ assertTrue("setKeywords", fromArray(kws).containsAll(fromArray(kws2)));
+
+ NamedValue[] ds2 = new NamedValue[] {
+ new NamedValue("SyllableCount", Integer.valueOf(9)),
+ new NamedValue("FrameCount", Integer.valueOf(2)),
+ new NamedValue("SentenceCount", Integer.valueOf(7)) };
+ xDP.setDocumentStatistics(ds2);
+ ds = xDP.getDocumentStatistics();
+ assertTrue("setDocumentStatistics:SyllableCount", containsNV(ds,
+ new NamedValue("SyllableCount", Integer.valueOf(9))));
+ assertTrue("setDocumentStatistics:FrameCount", containsNV(ds,
+ new NamedValue("FrameCount", Integer.valueOf(2))));
+ assertTrue("setDocumentStatistics:SentenceCount", containsNV(ds,
+ new NamedValue("SentenceCount", Integer.valueOf(7))));
+
+ System.out.println("...done");
+
+ System.out.println("Checking user-defined meta-data updates...");
+
+ // actually, this tests the PropertyBag service
+ // but maybe the DocumentProperties service will be implemented
+ // differently some day...
+ boolean b = true;
+ double d = 3.1415;
+ // note that Time is only supported for backward compatibility!
+ Time t = new Time();
+ t.Hours = 1;
+ t.Minutes = 16;
+ Date date = new Date();
+ date.Year = 2071;
+ date.Month = 2;
+ date.Day = 3;
+ dt.Year = 2065;
+ Duration dur = new Duration();
+ dur.Negative = true;
+ dur.Years = 1001;
+ dur.Months = 999;
+ dur.Days = 888;
+ dur.Hours = 777;
+ dur.Minutes = 666;
+ dur.Seconds = 555;
+ dur.NanoSeconds = 444444444;
+
+ udpc.addProperty("Frobnicate", PropertyAttribute.REMOVABLE, b);
+ udpc.addProperty("FrobDuration", PropertyAttribute.REMOVABLE, dur);
+ udpc.addProperty("FrobDuration2", PropertyAttribute.REMOVABLE, t);
+ udpc.addProperty("FrobEndDate", PropertyAttribute.REMOVABLE, date);
+ udpc.addProperty("FrobStartTime", PropertyAttribute.REMOVABLE, dt);
+ udpc.addProperty("Pi", PropertyAttribute.REMOVABLE, new Double(d));
+ udpc.addProperty("Foo", PropertyAttribute.REMOVABLE, "bar");
+ udpc.addProperty("Removed", PropertyAttribute.REMOVABLE, "bar");
+ // #i94175#: empty property name is valid ODF 1.1
+ udpc.addProperty("", PropertyAttribute.REMOVABLE, "eeeeek");
+ try {
+ udpc.removeProperty("Info 1");
+ udpc.removeProperty("Removed");
+ } catch (UnknownPropertyException e) {
+ fail("removeProperty failed");
+ }
- try {
- udpc.addProperty("Forbidden", PropertyAttribute.REMOVABLE,
- new String[] { "foo", "bar" });
- fail("inserting value of non-supported type did not fail");
- } catch (IllegalTypeException e) {
- // ignore
- }
+ try {
+ udpc.addProperty("Forbidden", PropertyAttribute.REMOVABLE,
+ new String[] { "foo", "bar" });
+ fail("inserting value of non-supported type did not fail");
+ } catch (IllegalTypeException e) {
+ // ignore
+ }
- assertEquals(
- "UserDefined bool", b, udps.getPropertyValue("Frobnicate"));
- assertTrue("UserDefined duration", eqDuration(dur, (Duration)
- udps.getPropertyValue("FrobDuration")));
- assertTrue("UserDefined time", eqTime(t, (Time)
- udps.getPropertyValue("FrobDuration2")));
- assertTrue("UserDefined date", eqDate(date, (Date)
- udps.getPropertyValue("FrobEndDate")));
- assertTrue("UserDefined datetime", eqDateTime(dt, (DateTime)
- udps.getPropertyValue("FrobStartTime")));
- assertEquals("UserDefined float", d, udps.getPropertyValue("Pi"));
- assertEquals(
- "UserDefined string", "bar", udps.getPropertyValue("Foo"));
- assertEquals(
- "UserDefined empty name", "eeeeek", udps.getPropertyValue(""));
-
- try {
- udps.getPropertyValue("Removed");
- fail("UserDefined remove didn't");
- } catch (UnknownPropertyException e) {
- // ok
- }
+ assertEquals(
+ "UserDefined bool", b, udps.getPropertyValue("Frobnicate"));
+ assertTrue("UserDefined duration", eqDuration(dur, (Duration)
+ udps.getPropertyValue("FrobDuration")));
+ assertTrue("UserDefined time", eqTime(t, (Time)
+ udps.getPropertyValue("FrobDuration2")));
+ assertTrue("UserDefined date", eqDate(date, (Date)
+ udps.getPropertyValue("FrobEndDate")));
+ assertTrue("UserDefined datetime", eqDateTime(dt, (DateTime)
+ udps.getPropertyValue("FrobStartTime")));
+ assertEquals("UserDefined float", d, udps.getPropertyValue("Pi"));
+ assertEquals(
+ "UserDefined string", "bar", udps.getPropertyValue("Foo"));
+ assertEquals(
+ "UserDefined empty name", "eeeeek", udps.getPropertyValue(""));
- System.out.println("...done");
+ try {
+ udps.getPropertyValue("Removed");
+ fail("UserDefined remove didn't");
+ } catch (UnknownPropertyException e) {
+ // ok
+ }
- System.out.println("Checking storing meta-data to file...");
+ System.out.println("...done");
- xDP.storeToMedium(temp + "TEST.odt", mimeArgs);
+ System.out.println("Checking storing meta-data to file...");
- System.out.println("...done");
+ xDP.storeToMedium(temp + "TEST.odt", mimeArgs);
- System.out.println("Checking loading meta-data from stored file...");
+ System.out.println("...done");
- xDP.loadFromMedium(temp + "TEST.odt", noArgs);
+ System.out.println("Checking loading meta-data from stored file...");
- System.out.println("...done");
+ xDP.loadFromMedium(temp + "TEST.odt", noArgs);
- System.out.println("Checking user-defined meta-data from stored file...");
+ System.out.println("...done");
- udpc = xDP.getUserDefinedProperties();
- udps = UnoRuntime.queryInterface( XPropertySet.class, udpc );
+ System.out.println("Checking user-defined meta-data from stored file...");
- assertEquals(
- "UserDefined bool", b, udps.getPropertyValue("Frobnicate"));
- assertTrue("UserDefined duration", eqDuration(dur, (Duration)
- udps.getPropertyValue("FrobDuration")));
- // this is now a Duration!
- Duration t_dur = new Duration(false, (short)0, (short)0, (short)0,
- t.Hours, t.Minutes, t.Seconds,
- t.NanoSeconds);
- assertTrue("UserDefined time", eqDuration(t_dur, (Duration)
- udps.getPropertyValue("FrobDuration2")));
- assertTrue("UserDefined date", eqDate(date, (Date)
- udps.getPropertyValue("FrobEndDate")));
- assertTrue("UserDefined datetime", eqDateTime(dt, (DateTime)
- udps.getPropertyValue("FrobStartTime")));
- assertEquals("UserDefined float", d, udps.getPropertyValue("Pi"));
- assertEquals(
- "UserDefined string", "bar", udps.getPropertyValue("Foo"));
+ udpc = xDP.getUserDefinedProperties();
+ udps = UnoRuntime.queryInterface( XPropertySet.class, udpc );
- try {
- udps.getPropertyValue("Removed");
- fail("UserDefined remove didn't");
- } catch (UnknownPropertyException e) {
- // ok
- }
+ assertEquals(
+ "UserDefined bool", b, udps.getPropertyValue("Frobnicate"));
+ assertTrue("UserDefined duration", eqDuration(dur, (Duration)
+ udps.getPropertyValue("FrobDuration")));
+ // this is now a Duration!
+ Duration t_dur = new Duration(false, (short)0, (short)0, (short)0,
+ t.Hours, t.Minutes, t.Seconds,
+ t.NanoSeconds);
+ assertTrue("UserDefined time", eqDuration(t_dur, (Duration)
+ udps.getPropertyValue("FrobDuration2")));
+ assertTrue("UserDefined date", eqDate(date, (Date)
+ udps.getPropertyValue("FrobEndDate")));
+ assertTrue("UserDefined datetime", eqDateTime(dt, (DateTime)
+ udps.getPropertyValue("FrobStartTime")));
+ assertEquals("UserDefined float", d, udps.getPropertyValue("Pi"));
+ assertEquals(
+ "UserDefined string", "bar", udps.getPropertyValue("Foo"));
- System.out.println("...done");
-
- System.out.println("Checking notification listener interface...");
-
- Listener listener = new Listener();
- XModifyBroadcaster xMB = UnoRuntime.queryInterface( XModifyBroadcaster.class, xDP );
- xMB.addModifyListener(listener);
- xDP.setAuthor("not me");
- assertTrue("Listener Author", listener.reset());
- udpc.addProperty("Listener", PropertyAttribute.REMOVABLE, "foo");
- assertTrue("Listener UserDefined Add", listener.reset());
- udps.setPropertyValue("Listener", "bar");
- assertTrue("Listener UserDefined Set", listener.reset());
- udpc.removeProperty("Listener");
- assertTrue("Listener UserDefined Remove", listener.reset());
- xMB.removeModifyListener(listener);
- udpc.addProperty("Listener2", PropertyAttribute.REMOVABLE, "foo");
- assertTrue("Removed Listener UserDefined Add", !listener.reset());
-
- System.out.println("...done");
-
- } catch (Exception e) {
- report(e);
+ try {
+ udps.getPropertyValue("Removed");
+ fail("UserDefined remove didn't");
+ } catch (UnknownPropertyException e) {
+ // ok
}
+
+ System.out.println("...done");
+
+ System.out.println("Checking notification listener interface...");
+
+ Listener listener = new Listener();
+ XModifyBroadcaster xMB = UnoRuntime.queryInterface( XModifyBroadcaster.class, xDP );
+ xMB.addModifyListener(listener);
+ xDP.setAuthor("not me");
+ assertTrue("Listener Author", listener.reset());
+ udpc.addProperty("Listener", PropertyAttribute.REMOVABLE, "foo");
+ assertTrue("Listener UserDefined Add", listener.reset());
+ udps.setPropertyValue("Listener", "bar");
+ assertTrue("Listener UserDefined Set", listener.reset());
+ udpc.removeProperty("Listener");
+ assertTrue("Listener UserDefined Remove", listener.reset());
+ xMB.removeModifyListener(listener);
+ udpc.addProperty("Listener2", PropertyAttribute.REMOVABLE, "foo");
+ assertTrue("Removed Listener UserDefined Add", !listener.reset());
+
+ System.out.println("...done");
}
// grrr...
@@ -504,14 +500,7 @@ public class DocumentProperties
return false;
}
- public void report(Exception e) {
- System.out.println("Exception occurred:");
- e.printStackTrace();
- fail();
- }
-
-
- private XMultiServiceFactory getMSF()
+ private XMultiServiceFactory getMSF()
{
final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface( XMultiServiceFactory.class, connection.getComponentContext().getServiceManager() );
return xMSF1;
diff --git a/sfx2/qa/complex/sfx2/UndoManager.java b/sfx2/qa/complex/sfx2/UndoManager.java
index 45f99fd9d441..ad82ca4c9db8 100644
--- a/sfx2/qa/complex/sfx2/UndoManager.java
+++ b/sfx2/qa/complex/sfx2/UndoManager.java
@@ -42,8 +42,11 @@ import com.sun.star.document.XUndoAction;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.IndexOutOfBoundsException;
import com.sun.star.lang.XEventListener;
+
import java.lang.reflect.InvocationTargetException;
+
import org.openoffice.test.tools.OfficeDocument;
+
import com.sun.star.document.XUndoManagerSupplier;
import com.sun.star.document.XUndoManager;
import com.sun.star.document.XUndoManagerListener;
@@ -60,28 +63,34 @@ import com.sun.star.script.ScriptEventDescriptor;
import com.sun.star.script.XEventAttacherManager;
import com.sun.star.script.XLibraryContainer;
import com.sun.star.task.XJob;
+import com.sun.star.uno.Exception;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.InvalidStateException;
import com.sun.star.util.NotLockedException;
import com.sun.star.view.XControlAccess;
+
import complex.sfx2.undo.CalcDocumentTest;
import complex.sfx2.undo.ChartDocumentTest;
import complex.sfx2.undo.DocumentTest;
import complex.sfx2.undo.DrawDocumentTest;
import complex.sfx2.undo.ImpressDocumentTest;
import complex.sfx2.undo.WriterDocumentTest;
+
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Stack;
+
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+
import static org.junit.Assert.*;
+
import org.openoffice.test.OfficeConnection;
import org.openoffice.test.tools.DocumentType;
import org.openoffice.test.tools.SpreadsheetDocument;
@@ -118,7 +127,7 @@ public class UndoManager
//FIXME fails fdo#35663 @Test
- public void checkCalcUndo() throws Exception
+ public void checkCalcUndo() throws java.lang.Exception
{
m_currentTestCase = new CalcDocumentTest( getORB() );
impl_checkUndo();
@@ -385,38 +394,31 @@ public class UndoManager
private void impl_assignScript( final XPropertySet i_controlModel, final String i_interfaceName,
- final String i_interfaceMethod, final String i_scriptURI )
+ final String i_interfaceMethod, final String i_scriptURI ) throws Exception
{
- try
- {
- final XChild modelAsChild = UnoRuntime.queryInterface( XChild.class, i_controlModel );
- final XIndexContainer parentForm = UnoRuntime.queryInterface( XIndexContainer.class, modelAsChild.getParent() );
+ final XChild modelAsChild = UnoRuntime.queryInterface( XChild.class, i_controlModel );
+ final XIndexContainer parentForm = UnoRuntime.queryInterface( XIndexContainer.class, modelAsChild.getParent() );
- final XEventAttacherManager manager = UnoRuntime.queryInterface( XEventAttacherManager.class, parentForm );
+ final XEventAttacherManager manager = UnoRuntime.queryInterface( XEventAttacherManager.class, parentForm );
- int containerPosition = -1;
- for ( int i = 0; i < parentForm.getCount(); ++i )
+ int containerPosition = -1;
+ for ( int i = 0; i < parentForm.getCount(); ++i )
+ {
+ final XPropertySet child = UnoRuntime.queryInterface( XPropertySet.class, parentForm.getByIndex( i ) );
+ if ( UnoRuntime.areSame( child, i_controlModel ) )
{
- final XPropertySet child = UnoRuntime.queryInterface( XPropertySet.class, parentForm.getByIndex( i ) );
- if ( UnoRuntime.areSame( child, i_controlModel ) )
- {
- containerPosition = i;
- break;
- }
+ containerPosition = i;
+ break;
}
- assertFalse( "could not find the given control model within its parent", containerPosition == -1 );
- manager.registerScriptEvent( containerPosition, new ScriptEventDescriptor(
- i_interfaceName,
- i_interfaceMethod,
- "",
- "Script",
- i_scriptURI
- ) );
- }
- catch( com.sun.star.uno.Exception e )
- {
- fail( "caught an exception while assigning the script event to the button: " + e.toString() );
}
+ assertFalse( "could not find the given control model within its parent", containerPosition == -1 );
+ manager.registerScriptEvent( containerPosition, new ScriptEventDescriptor(
+ i_interfaceName,
+ i_interfaceMethod,
+ "",
+ "Script",
+ i_scriptURI
+ ) );
}
@@ -1195,7 +1197,7 @@ public class UndoManager
@BeforeClass
- public static void setUpConnection() throws Exception
+ public static void setUpConnection() throws java.lang.Exception
{
System.out.println( "--------------------------------------------------------------------------------" );
System.out.println( "starting class: " + UndoManager.class.getName() );
diff --git a/sfx2/qa/complex/sfx2/tools/WriterHelper.java b/sfx2/qa/complex/sfx2/tools/WriterHelper.java
index 382aebca5449..3180d3607115 100644
--- a/sfx2/qa/complex/sfx2/tools/WriterHelper.java
+++ b/sfx2/qa/complex/sfx2/tools/WriterHelper.java
@@ -185,15 +185,8 @@ public class WriterHelper {
*
* @return returns the gained XExtendedToolkit Interface
*/
- public XExtendedToolkit getToolkit() {
- Object toolkit = null;
-
- try {
- toolkit = m_xMSF.createInstance("com.sun.star.awt.Toolkit");
- } catch (com.sun.star.uno.Exception e) {
- System.out.println("Couldn't get toolkit");
- e.printStackTrace(System.err);
- }
+ public XExtendedToolkit getToolkit() throws com.sun.star.uno.Exception {
+ Object toolkit = m_xMSF.createInstance("com.sun.star.awt.Toolkit");
XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class,
toolkit);
@@ -207,15 +200,8 @@ public class WriterHelper {
*
* @return returns the gained XDesktop interface
*/
- private XDesktop getDesktop() {
- Object desk = null;
-
- try {
- desk = m_xMSF.createInstance("com.sun.star.frame.Desktop");
- } catch (com.sun.star.uno.Exception e) {
- System.out.println("Couldn't get desktop");
- e.printStackTrace(System.err);
- }
+ private XDesktop getDesktop() throws com.sun.star.uno.Exception {
+ Object desk = m_xMSF.createInstance("com.sun.star.frame.Desktop");
XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, desk);
diff --git a/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java b/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java
index 7d2b22975671..8ccbe6b6c5b7 100644
--- a/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java
+++ b/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java
@@ -115,23 +115,16 @@ public class ChartDocumentTest implements DocumentTest
return wallProperties;
}
- private XPropertySet impl_getYAxisProperties()
+ private XPropertySet impl_getYAxisProperties() throws IndexOutOfBoundsException
{
XPropertySet axisProperties = null;
- try
- {
- final XChartDocument chartDoc = UnoRuntime.queryInterface( XChartDocument.class, m_chartDocument.getDocument() );
- final XDiagram diagram = chartDoc.getFirstDiagram();
- final XCoordinateSystemContainer coordContainer = UnoRuntime.queryInterface( XCoordinateSystemContainer.class, diagram );
- final XCoordinateSystem[] coordSystems = coordContainer.getCoordinateSystems();
- final XCoordinateSystem coordSystem = coordSystems[0];
- final XAxis primaryYAxis = coordSystem.getAxisByDimension( 1, 0 );
- axisProperties = UnoRuntime.queryInterface( XPropertySet.class, primaryYAxis );
- }
- catch ( Exception ex )
- {
- fail( "internal error: could not retrieve primary Y axis properties" );
- }
+ final XChartDocument chartDoc = UnoRuntime.queryInterface( XChartDocument.class, m_chartDocument.getDocument() );
+ final XDiagram diagram = chartDoc.getFirstDiagram();
+ final XCoordinateSystemContainer coordContainer = UnoRuntime.queryInterface( XCoordinateSystemContainer.class, diagram );
+ final XCoordinateSystem[] coordSystems = coordContainer.getCoordinateSystems();
+ final XCoordinateSystem coordSystem = coordSystems[0];
+ final XAxis primaryYAxis = coordSystem.getAxisByDimension( 1, 0 );
+ axisProperties = UnoRuntime.queryInterface( XPropertySet.class, primaryYAxis );
return axisProperties;
}