Hi Ocke & all other dba-dev subscribers!

At first thanks for the response and sorry that my reply comes so late.
Since I'm not good in C++, someone translated the code for me, you posted.

Unfortunately I couldn't solve the problem.

The task is to store an existing Writer-form document in a db file.

You told me, the difference to my snippet is, that yours uses the document
container as servicefactory. I created the
"com.sun.star.sdb.DocumentDefinition" as service. I guess that’s the same
you did? 

However I don't understand which properties need to be used for the
DocumentDefinition. Unfortunately there is no real documentation for this.
http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/DocumentDefinitio
n.html says "unpublished" and I guess the 2 properties which can be found
there are not right..

You used the properties:
Name - m_sBookmarkName (where can I get this object - or is it only the
name, which should be used to store the form?)

Parent - xNames (What is xNames - is this property optional? Does it only
allow to build a hierarchy of forms inside the db-file?)

PROPERTY_URL - m_sDocumentLocation (Whats the real name of this property
because in this case PROPERTY_URL is the name of a C++ constant? And what's
its value? Is it only the Url to the form file? Eg.:
"file:///c:/odbfiles/test.odt")


I know that’s a lot of questions but I would be glad if someone could help
to get this example work.

Greets Stefan







-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 23. November 2006 15:03
An: [email protected]
Betreff: Re: [dba-dev] store form in OOo db-file

Hi Stefan,

I copied some C++ code from 
dbaccess/source/filter/migration/cfgimport.cxx The difference is that it 
uses the document container as servicefactory

I hope this helps a little bit.

Best regards,

Ocke


Stefan Schmid wrote:::rtl::OUString 
sServiceName(SERVICE_SDB_DOCUMENTDEFINITION);
Sequence< Any > aArguments(3);
PropertyValue aValue;
// set as folder
aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
aValue.Value <<= m_sBookmarkName;
aArguments[0] <<= aValue;
//parent
aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
aValue.Value <<= xNames;
aArguments[1] <<= aValue;

aValue.Name = PROPERTY_URL;
aValue.Value <<= m_sDocumentLocation;
aArguments[2] <<= aValue;

Reference<XMultiServiceFactory> xORB(xNames,UNO_QUERY);
if ( xORB.is() )
{
Reference<XInterface> xComponent = 
xORB->createInstanceWithArguments(SERVICE_SDB_DOCUMENTDEFINITION,aArguments)
;
Reference<XNameContainer> xNameContainer(xNames,UNO_QUERY);
if ( xNameContainer.is() )
xNameContainer->insertByName(m_sBookmarkName,makeAny(xComponent));
}


> 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.DocumentDefinit
ion", props, xContext)
>
> xFormDocs~insertByName("formtest", oDocDef)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>   

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



-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.14/547 - Release Date: 22.11.2006


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

Reply via email to