Tobias Krais schrieb:
Hi together,

I wrote a little cute java program that is converting documents via OOo.
This conversion machine is running hidden. It will fail, even crash down
if someone uses OOo in foreground and closes the last opened window. For
this reason I registered a TerminateListener that throws a
TerminateVetoException, which prevents my lovely program from crashing.
But this exception even prevents the user to close his visible document(s).

So I search for a better solution and thought a CloseListener throwing a
CloseVetoException could be one. But it works only half. Here is the
code I use:
-----%<----
    public void addCloseListener() {
        // initial close listener
        xCloseListener = new XCloseListener() {
            public void queryClosing(EventObject arg0, boolean arg1)
                    throws CloseVetoException {
                throw new CloseVetoException();
            }

            public void notifyClosing(EventObject arg0) {}

            public void disposing(EventObject arg0) {}
        };
        this.xComponent.addEventListener(xCloseListener);
    }
-----%<-----
The result is, that I again cannot close the visible OOo Desktop - but I
can close my document!

Is there a solution, to use the CloseListener (or any other Listener)
that allows the user to close the visible OOo desktop, but prevents my
hidden document and OOo to close?

No ... currently not (not realy).

You can listen for closing events on every document opened by YOUR code
and prevent them from closing. Then the desktop should close all documents not throwing an exception (which should be the UI opened documents only) and ignore your documents ... which will result into a failed terminate operation.

But there is a "small time frame", where you cant control the situation ... the time between loadComponentFromURL() returned a document and you will be registered as close listener. OK - the chance that an UI office terminates during these 200 ms is very small ... but this possibility exists .-)

Fact is: the office isnt prepared for such "concurrent uses cases".
There exists two simple uses cases only:
a) UI Office (as normaly used on the desktop
b) API Office (as you use it)

There is another solution for you ...
If you start the office with an own user layer, you will get an own office instance independed from the normal UI desktop office.
"soffice -env:<path>".
Problem here: all settings made inside the desktop office has to be done twice. There is no synchronization .-)


Greetings, Tobias

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


Regards
Andreas

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

Reply via email to