String documentURL = xDocumentModel.getURL();
String basename = FileAccess.getBasename(documentURL, "/");
XCloseable xCloseable = UnoRuntime.queryInterface( XCloseable.class, _xComponent );
xCloseable.close(false);
NamedValueCollection creationArgs = new NamedValueCollection();
creationArgs.put( PropertyNames.PROPERTY_NAME, basename );
creationArgs.put( PropertyNames.URL, documentURL );
creationArgs.put( "AsTemplate", i_createTemplate );
XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, _xDocNameAccess );
Object oDBDocument = xDocMSF.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", creationArgs.getPropertyValues() );
XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocNameAccess );
String sdocname = Desktop.getUniqueName(_xDocNameAccess, basename);
xHier.insertByHierarchicalName(sdocname, oDBDocument);
XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );