How can a previously created form be added to the database document?
oDesktop = UNO.createDesktop() -- get the UNO Desktop service object
/* get the database document */
xComponentLoader = oDesktop~XDesktop~XComponentLoader
url = uno.ConvertToURL("c:\odbfiles\mysql1.odb")
xComponent = xComponentLoader~loadComponentFromURL(-
url, "_blank", 0, .UNO~noProps)
/* get the form container */
xFormDocumentsSupplier = xComponent~XModel~XFormDocumentsSupplier
xHierarchicalNameAccess = xFormDocumentsSupplier~getFormDocuments
/* create a new DocumentDefinition containing the form */
props = bsf.createArray(.UNO~propertyValue,4)
props[1] = .UNO~PropertyValue~new
props[1]~Name = "Name"
props[1]~Value = "test"
props[2] = .UNO~PropertyValue~new
props[2]~Name = "Parent"
props[2]~Value = xHierarchicalNameAccess
props[3] = .UNO~PropertyValue~new
props[3]~Name = "URL"
props[3]~Value = uno.ConvertToURL("c:\odbfiles\shop_form.odt")
props[4] = .UNO~PropertyValue~new
props[4]~Name = "DocumentTitle"
props[4]~Value = "test"
xDocMSF = xHierarchicalNameAccess~XMultiServiceFactory
oDBDocument = xDocMSF~createInstanceWithArguments(-
"com.sun.star.sdb.DocumentDefinition", props)
/* add the DocumentDefinition to the database document */
xHierarchicalNameContainer = xHierarchicalNameAccess~XHierarchicalNameContainer
xHierarchicalNameContainer~insertByHierarchicalName("shop_form",oDBDocument)
::requires UNO.cls -- get UNO support