XContent xContent = xTransientDocumentsDocumentContentFactory.createDocumentContent(xModel);
// actual test: execute some commands
XCommandProcessor xCommandProcessor = (XCommandProcessor)UnoRuntime.queryInterface(XCommandProcessor.class, xContent);
// create the command and arguments
Command command = new Command();
OpenCommandArgument2 cmargs2 = new OpenCommandArgument2();
Property[]props = new Property[1];
props[0] = new Property();
props[0].Name = "Title";
props[0].Handle = -1;
cmargs2.Mode = OpenMode.ALL;
cmargs2.Properties = props;
command.Name = "open";
command.Argument = cmargs2;
Object result = xCommandProcessor.execute(command, 0, null);
XDynamicResultSet xDynamicResultSet = (XDynamicResultSet)UnoRuntime.queryInterface(XDynamicResultSet.class, result);
XResultSet xResultSet = xDynamicResultSet.getStaticResultSet();
XRow xRow = (XRow)UnoRuntime.queryInterface(XRow.class, xResultSet);
// create the new folder 'folderName': first, check if it's already there
while(xResultSet.next()) {
String existingFolderName = xRow.getString(1);
log.println("Found existing folder: '" + existingFolderName + "'");
if (folderName.equals(existingFolderName)) {
failed("Cannot create a new folder: folder already exists: adapt test or choose a different document.");
}
}
// create a folder
log.println("Create new folder "+ folderName);
ContentInfo contentInfo = new ContentInfo();
contentInfo.Type = "application/vnd.sun.star.tdoc-folder";
command.Name = "createNewContent";
command.Argument = contentInfo;
result = xCommandProcessor.execute(command, 0, null);
XContent xNewFolder = (XContent)UnoRuntime.queryInterface(XContent.class, result);
XCommandProcessor xFolderCommandProcessor = (XCommandProcessor)UnoRuntime.queryInterface(XCommandProcessor.class, xNewFolder);
log.println("Got the new folder: " + utils.getImplName(xNewFolder));
// name the new folder
PropertyValue[] titleProp = new PropertyValue[1];
titleProp[0] = new PropertyValue();
titleProp[0].Name = "Title";
titleProp[0].Handle = -1;
titleProp[0].Value = folderName;
Command titleSetCommand = new Command();
titleSetCommand.Name = "setPropertyValues";
titleSetCommand.Argument = titleProp;
xFolderCommandProcessor.execute(titleSetCommand, 0, null);
// 2do: check all this stuff!