OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

OLE Automation -> Get Print Status

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
hinek
General User
General User


Joined: 21 Jun 2005
Posts: 10
Location: Germany

PostPosted: Tue Jun 21, 2005 11:50 pm    Post subject: OLE Automation -> Get Print Status Reply with quote

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?
Back to top
View user's profile Send private message
Danad
OOo Advocate
OOo Advocate


Joined: 22 Feb 2004
Posts: 293
Location: Brasil

PostPosted: Wed Jun 22, 2005 4:29 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group