1
I try to learn some event reflex extensions of LibreOffice. Catching events(like Save, SaveAs etc.) and after that getting some information about caught event(like flags, member variables etc.) and blocking event routine that I filtered is what I want to do. For example, the function has been caught SaveAs event and if the function want to prevent SaveAs routine, it has to set related flag or member variable of caught event. I have found some example python scripts from libreofficehelp.
The example used XDocumentEventListener
from com.sun.star.document
. And the example used following 2 functions for catching,
def listen(self, *args): # OnLoad/OnNew at the earliest
""" Start doc. events monitoring """
self.doc.addDocumentEventListener(self)
Console.log("INFO", "Document events are being logged", True)
def documentEventOccured(self, event: DocumentEvent):
""" Intercepts all doc. events """
#self.setCell(event.Source, event.EventName) # only for Calc docs
Console.log("DEBUG",
event.EventName+" in "+self.Filename,
False)
I tried to find documents about XDocumentEventListener
. Unfortunately, I could not find an explanatory and detailed document.
In addition, similar process can be done on the Microsoft Office side below:
private void Application_DocumentBeforeSave(Word.Document doc, ref bool SaveAsUI, ref bool Cancel)
{
...
Cancel = true;
return;
}
How can I find related document and where from ? Or may someone give me some information ?