Hello!! 

I have a problem with storing an existing Writer-form document in a db file. 
There is a small chapter in the Developers Guide about this issue (Forms and 
Reports p.842). But I couldn’t get my program work with the information 
provided there and the API idl …

The following program fails to create the DocumentDefinition, which should be 
filled with the form document to store. Afterwards it should be inserted into 
DocumentContainer of the db-file where the forms are stored.

Although I provide exactly the properties shown in the Developers Guide, the 
DocumentDefinition is not created.

I would be glad, if someone could help me.

Greets Stefan


CODE (ooRexx):

/* get the service manager */
xContext = UNO.connect()
XMcf = xContext~getServiceManager

/* retrieve the DatabaseContext and get its XNameAccess interface */
xNameAccess = xMcf~createInstanceWithContext(-
        "com.sun.star.sdb.DatabaseContext", xContext)~XNameAccess

/* we use the mysql-test data sorce */
dataSource = xNameAccess~getByName("mysql-test")

/* retrieve the XDocumentDataSource interface of the data source */
xDocumentDataSource = dataSource~XDocumentDataSource
/* get the attribute 'DatabaseDocument' */
xOfficeDatabaseDocument = xDocumentDataSource~getDatabaseDocument


xFormDocumentsSupplier = xOfficeDatabaseDocument~XFormDocumentsSupplier
formDocuments = xFormDocumentsSupplier~getFormDocuments

say formDocuments~TOSTRING

/* show stored forms */ 
DO n OVER formDocuments~getElementNames
        say n
END

/* get the connection */

/* get the service manager */
xContext = UNO.connect()
XMcf = xContext~getServiceManager
/* retrieve the DatabaseContext and get its XNameAccess interface */
xNameAccess = xMcf~createInstanceWithContext(-
        "com.sun.star.sdb.DatabaseContext", xContext)~XNameAccess
/* we use the mysql-test data sorce */
dataSource = xNameAccess~getByName("mysql-test")
/* query for the XDataSource interface of the data source */
xDataSource = dataSource~XDataSource
/* simple way to connect - hard code (usr,pw) */
xConnection = xDataSource~getConnection("stefan","apple");



xFormDocs = xFormDocumentsSupplier~getFormDocuments

props = bsf.createArray(.UNO~propertyValue,3)
props[1] = .UNO~PropertyValue~new
props[1]~Name = "Name"
props[1]~Value = "formtest"
props[1]~Name = "ActiveConnection"
props[1]~Value = xConnection
props[1]~Name = "URL"
props[1]~Value = "file:///c:/odbfiles/test.odt"

oDocDef = 
XMcf~createInstanceWithArgumentsAndContext("com.sun.star.sdb.DocumentDefinition",
 props, xContext)

xFormDocs~insertByName("formtest", oDocDef)


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to