G. Roderick Singleton wrote:

> On Fri, 2006-06-02 at 11:46 +0200, Christoph Wunder wrote:
>> Hallo ,
>> I want to use OpenOffice in an area where data should be kept confidential.
>> Therfore i wrote an own File Dialog that permits users to access and work
>> only in a predefinded directory.
>> I could easyly integrate my File Dialog using macros in basic.
>> 
>> My Problem:
>> 
>> How can i load and store documents in the formats used provided by
>> OpenOffice on the level of macros, because
>> i only found apis to write Documets line by line.
>> Is there an easy/abstract way to load and store documents independent of
>> their format that i can use from the level
>> of macros using only the path of a file ??  How can i do this ??
>> 
>> If this is not possible:  How do i load and store a document of a certain
>> type ( the types provided by OpenOffice)
>> (and how do i get the type of the document)
> 
> Hmm, a programming question.  You may or may not get an answer on this
> list but do monitor it.  Better you should ask those that use the api
> for developing in the same manner you are trying to do. The project you
> want is http://api.openoffice.org/ and I will let you subscribe to the
> list of your choice. You could also try [email protected] which I have
> cc'd for you as this is a general list for programming type problems.
> 
> Hope this helps you get your programming problem solved.

Loading documents by URL can be done by using the desktop service:

(1)

dim arg(2) as new com.sun.star.beans.PropertyValue
args(0).Name = "UpdateDocMode"
args(0).Value = com.sun.star.document.UpdateDocMode.ACCORDING_TO_CONFIG
args(1).Name = "MacroExecutionMode"
args(1).Value = com.sun.star.document.MacroExecMode.USE_CONFIG
args(2).Name = "InteractionHandler"
args(2).Value = CreateUnoService("com.sun.star.task.InteractionHandler")
StarDesktop.loadComponentFromURL( sURL, "_default", 0, args() )

or by using the Dispatch Framework:

(2)

frame = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "URL"
args(0).Value = "sURL"
dispatcher.executeDispatch(frame, ".uno:Open", "_default", 0, args())

The arguments in the first case are necessary because without them you
don't get any necessary updates or update queries when you open the
document (styles,links etc.) and your program will break in case of an
error (e.g. file corruption) and also macros in the document will be
disabled completely.

In the second case they will be automatically added by the code that
executes the dispatch and you will also stay "compatible" to the
behaviour of the OOo file dialog even if we will add more parameters of
this kind in future versions.

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project Lead
Please reply to the list only, [EMAIL PROTECTED] is a spam sink.

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

Reply via email to