Hi Andreas,

> You shouldnt post "a complete application" as code snippet.
> It's better to show some parts of you approach only.

yes and no. For one part I agree. If you are an expert, it is useful for
you to see only the relevant part of an application.
But I disagree because I am a newbie. And I waste 90% of my time with
finding out the conditions for code snippets and how to get them to
work. And you can imagine, this work is really discouraging.

I suggest a solution: I post the relevant part of the code as a snippet
and add a link to my homepage where you can find a sample application
for the snippet. Is this useful?

> Trying all possible PDF export filters and catching occuring exceptions
> isnt realy "good style" .-)
> The better approach:
> 
>     com.sun.star.frame.XModuleManager xMM =
> (com.sun.star.frame.XModuleManager)UnoRuntime.queryInterface(
>     com.sun.star.frame.XModuleManager.class,
>     xSMGR.createInstance("com.sun.star.frame.ModuleManager"));

Here I have my first problems. Please give me a hint: what is the type
of xSMGR? How can I creat xSMGR? (I'm sure it is a very simple answer,
but I already searched about 4 hours for the solution...).

>     String sOOoApp = null;
>     try{
>         sOOoApp = xMM.identify(openDocument);
>     }catch(com.sun.star.frame.UnknownModuleException)
>     {
>         ...
>     }
> 
>     // Now you know the application name of this document
>     // e.g. "com.sun.star.text.TextDocument" for writer
>     // And you can select the right filter:
>     String sPDFExportFilter = null;
>     if (sOOoApp.equals("com.sun.star.text.TextDocument"))
>         sPDFExportFilter = "writer_pdf_Export";
>     else
>         ...


This is very good! Thank you, I will do it this way as soon as I find
the xSMGR.

>>         try
>>         {
>>             openedDocument = xComponentLoader.loadComponentFromURL(
>>                     "file://" + source_File,        // File folder and
>> name
>>                     "_blank",                       // New windos
>>                     Integer.parseInt(ooport),       // Port OO listens on
>>                     documentProperties);            // Special properties

> a)
> The third parameter of loadComponentFromURL() isnt the port number where
> OOo listens on. It's a flag, which regulate search for the right target
> frame in case the second parameter of loadComponentFromURL() isnt a
> special one.
> 
> If you use "_blank", "_default", "_self", "_top" or "" (which is simlar
> to "_self") the third parameter will be ignored !
> Otherwise the third parameter must be from type
> css.frame.FrameSearchFlag. And then a frame supporting the name you
> specified as second parameter is searched.
> 
> Examples:
> 
> loadComponentFromURL(url, "_blank", 0, args)
> => creates a new frame every time
> 
> loadComponentFromURL(url, "_blank", 87658, args)
> => does the same, because the third parameter is ignored
> 
> loadComponentFromURL(url, "anynameyoulike", GLOBAL | CREATE, args)
> => search for a frame named "anynameyoulike" or create a new one if no
> frame supporting this name could be found

Very good. Now I understand. Thanks!

> b)
> Construction of URL's isnt realy platform independend here. You should
> the JAVA classes File/URL/URI to create real URL's.
> But be aware of a bug inside these JAVA classes. They construct file
> URL's like "file:/test/file.txt", which does not represent valid file
> URLs. You have to establish a workaround for that and convert "file:/"
> hardly to "file:///".
> 
> On the other side I currently dont know, if OOo accepts such "wrong
> formated" URL's too and convert it internaly .-)

Well its working -> I think OO will accept it. But I will use following
code for the snippet:
-----%<-----
public String createUNOFileURL(String filelocation)
{
    String myUNOFileURL = null;

    java.io.File newfile = new java.io.File(filelocation);
    try {
        myUNOFileURL
             = newfile.toURL().toString().replace("file:/", "file:///");
    }
    catch (MalformedURLException e) {
        System.out.println(e.getLocalizedMessage());
    }

    return myUNOFileURL;
}
-----%<-----

>>         }
>>         catch(Exception e)
>>         {
>>             System.out.println("OpenOffice runs, but error opening
>> document:");
>>             System.out.println(e.getLocalizedMessage());
>>         }
>>
>>         if (openedDocument == null) {
>>             System.err.println("I found the document but cannot open
>> it...");
>>             System.exit(-4);
> 
> 
> System.exit() isnt realy an option, if you work remote with OOo using
> UNO. Your JAVA process will be killed hardly - fine . But the OOo
> instance will stay alive inside memory ... Furhtermore it might contain
> dead UNO objects (forgotten JAVA listener etcpp). And if you use this
> office instance from it's normal UI it can happen that it crashes by
> using these dead objects.
> 
> Solution:
> 
> Terminate the office from JAVA before you call exit()

If I understand right, this will exit all my offices or just this
instance. I even have no xDesktop -> I think I cannot add a
terminateListener. Am I right?

> ... or
> make sure that all your registered listener was deregistered before.

For I did not register any listeners, I think there is no need to
deregister them. Am I right?

Thank you for your help.

Greetings, Tobias

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

Reply via email to