hinek General User


Joined: 21 Jun 2005 Posts: 10 Location: Germany
|
Posted: Tue Jun 21, 2005 11:50 pm Post subject: OLE Automation -> Get Print Status |
|
|
Hi,
I'm trying to print an sxw document for a C# .NET application via OLE Automation an OOo 1.4 (Yes, I know it's a bad idea, but I have to do it ...).
| Code: |
public static object MyInvoke(object obj,string method, BindingFlags binding,params object[] par)
{
return obj.GetType().InvokeMember(method,binding,null,obj,par);
}
public void Print()
{
MyInvoke(this.PropertyValuePrint, "Name", BindingFlags.SetProperty, "Copies");
MyInvoke(this.PropertyValuePrint, "Value", BindingFlags.SetProperty, 1);
MyInvoke(this.PropertyValuePrint, "Name", BindingFlags.SetProperty, "Collate");
MyInvoke(this.PropertyValuePrint, "Value", BindingFlags.SetProperty, false);
MyInvoke(this.XDocument,"print",BindingFlags.InvokeMethod, this.GetPrintParams());
}
|
Printing is so far working fine. Now I need a way to get the Print Status from OOo, to 1. show the progress to the user and 2. wait until OOo has finished printing before closing the file.
Can someone help me? |
|
Danad OOo Advocate

Joined: 22 Feb 2004 Posts: 293 Location: Brasil
|
Posted: Wed Jun 22, 2005 4:29 pm Post subject: |
|
|
Steps for OOoBasic are:
1) Create a XPrintJobListener with one method printJobEvent ( a C# class ? )
2) Add XPrintJobListener to the document model ( use addPrintJobListener )
3) Print the document
4) Remove XPrintJobListener from the document model ( use removePrintJobListener )
Here's the OOoBasic code:
| Code: |
Global xPrintJobListener As Variant
Sub add_PrintListener
oDoc = thisComponent
xPrintJobListener = createUnoListener("PJL_", "com.sun.star.view.XPrintJobListener")
oDoc.addPrintJobListener(xPrintJobListener)
End Sub
Sub remove_PrintListener
oDoc = thisComponent
oDoc.removePrintJobListener(xPrintJobListener)
End Sub
Sub PJL_printJobEvent ( oEvt )
estado = oEvt.State
print estado
End Sub
Sub PJL_disposing
'
End Sub
|
Nothing is perfect, OOo 1.1.3 hasn't notified me about JOB_SPOOLED state.
Sorry, but I don't know if this works in the same way with COM or even if it's possible.
HTH |
|