Hey,
I need some help in using a global event listener.
What I want to do:
Insert a writer-Document at a spezific position of another open writer
Document.
OK, inserting and so is not a üroblem, that works fine. But I want to
open the document, with will be inserted, by double-click in
file-explorer or via web-interface (Browser)
My idea is to store the last used writer-instance in a global variable,
check, if the new open document is one to insert (special name in
Doc-Info), and - if it matched - close the document and insert it.
So I register a GlobalEventListener and check, if the document "onFocus"
is a writer-instance. If yes, I stored it in a variable, if it is still
stored, I do nothing.
If I open a new document, this get the focus, I check the name, if it is
a matched Document, fine, then I want to insert it.
Unfortuantly this is the end of my OOo-Instance - it goes away -
everything...
I cannot really find the problem, maybe someone can give me a hint?
My code (in parts):
**********
global gel as object 'GobalEventBroadaster Service
global oListener as object
Sub StartListenerTest
gel = createUnoService("com.sun.star.frame.GlobalEventBroadcaster")
oListener = CreateUnoListener(
"DocumentListener_","com.sun.star.document.XEventListener" )
gel.addEventListener( oListener)
End Sub
Sub DocumentListener_notifyEvent( o as object )
on error goto ende
if o.EventName = "OnFocus" then
if thisComponent.supportsService("com.sun.star.text.TextDocument") then
' do something
oDoc = thisComponent
' Pos1
' bring another instane of an open Writer-Document in forground
oWriterAkt.getCurrentController().frame.ContainerWindow.setFocus()
' insert a Document in this Document on ViewCursor Position
' ...
' close actual Document
oDoc.close(true)
' Pos2
end if
end if
ende:
end sub
***********
I tried to remove the Listener at pos1 ( sel.removeEventListener(
oListener) ) and afterwards register it again at Pos2 - no effect.
The hole system is very instable - even if I remove the oDoc.close()
line. I don't know, what to do????
Thanks in advance
Thomas
--
## Marketing deutschsprachiges Projekt
## http://de.openoffice.org - www.openoffice.org
## Vorstand OpenOffice.org Deutschland e.V.
## Mitglieder willkommen: www.OOoDeV.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]