log.println("Opening a Writer document");
xTextDoc = WriterTools.createTextDoc(m_xMSF);
log.println("... done");
XDocumentInfoSupplier xDocInfoSup =
(XDocumentInfoSupplier) UnoRuntime.queryInterface(XDocumentInfoSupplier.class,
xTextDoc);
XDocumentInfo xDocInfo = xDocInfoSup.getDocumentInfo();
XPropertyContainer xPropContainer =
(XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class,
xDocInfo);
log.println("Trying to add a existing property");
boolean worked =
addProperty(xPropContainer, "Author", (short) 0, "");
assure("Could set an existing property", !worked);
log.println("...done");
log.println("Trying to add a integer property");
worked =
addProperty(xPropContainer, "intValue", com.sun.star.beans.PropertyAttribute.READONLY,
new Integer(17));
assure("Couldn't set an integer property", worked);
log.println("...done");
log.println("Trying to add a double property");
worked =
addProperty(xPropContainer, "doubleValue", com.sun.star.beans.PropertyAttribute.REMOVEABLE ,
new Double(17.7));
assure("Couldn't set an double property", worked);
log.println("...done");
log.println("Trying to add a boolean property");
worked =
addProperty(xPropContainer, "booleanValue", com.sun.star.beans.PropertyAttribute.REMOVEABLE,
Boolean.TRUE);
assure("Couldn't set an boolean property", worked);
log.println("...done");
log.println("Trying to add a date property");
worked =
addProperty(xPropContainer, "dateValue", com.sun.star.beans.PropertyAttribute.REMOVEABLE,
new Date());
assure("Couldn't set an date property", worked);
log.println("...done");
log.println("trying to remove a read only Property");
try {
xPropContainer.removeProperty ("intValue");
assure("Could remove read only property", false);
} catch (Exception e) {
log.println("\tException was thrown "+e);
log.println("\t...OK");
}
log.println("...done");
String tempdir = System.getProperty("java.io.tmpdir");
String fs = System.getProperty("file.separator");
if (!tempdir.endsWith(fs)) {
tempdir += fs;
}
tempdir = util.utils.getFullURL(tempdir);
log.println("Storing the document");
try {
XStorable store =
(XStorable) UnoRuntime.queryInterface(XStorable.class,
xTextDoc);
store.storeToURL(tempdir + "DocInfo.oot",
new PropertyValue[] {});
DesktopTools.closeDoc(xTextDoc);
} catch (Exception e) {
assure("Couldn't store document", false);
}
log.println("...done");
log.println("loading the document");
try {
XComponentLoader xCL =
(XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
m_xMSF.createInstance(
"com.sun.star.frame.Desktop"));
XComponent xComp =
xCL.loadComponentFromURL(tempdir + "DocInfo.oot",
"_blank", 0, new PropertyValue[] {});
xTextDoc =
(XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,
xComp);
} catch (Exception e) {
assure("Couldn't load document", false);
}
log.println("...done");
xDocInfoSup =
(XDocumentInfoSupplier) UnoRuntime.queryInterface(XDocumentInfoSupplier.class,
xTextDoc);
xDocInfo = xDocInfoSup.getDocumentInfo();
XPropertySet xProps =
(XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
xDocInfo);