I have a Basic listener which has been linked to the document print event via Tools/Customize.
When I print the document the listener is called three times with an apparently identical argument, viz: EventName: “OnPrint” (which I already know), ViewController: Null, Supplement: Empty. This leaves Source, which is a reference to the current document.
What I want to know is:
- How do I get the information that was entered in the Print dialog - printer name, number of copies, etc…
- How to tell LibreOffice not to use its default printing procedure, as printing will be handled by the print listener.
- Which of the three call to the listener is currently being processed. I can probably handle this with a global variable, although it would be an unsightly bodge, but it would be interesting to know at which point in the processing of the print job each of these calls was made.
To explain why I want to do this, I have what amounts to a serial number in one of the cells of the worksheet, which should be incremented each time the sheet is printed. To do this I had planned to intercept the standard print procedure, examine the number of copies field, then print as many copies as required individually, incrementing the serial number cell each time.
If anyone can suggest an alternative approach then I would be interested but, since, apart from getting the print job parameters and inhibiting default printing, the entire job could be done in around ten lines of code, it seems unlikely that any alternative could be simpler.