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