Back to index

lightning-sunbird  0.9+nobinonly
nsPrintJobPS.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Ken Herron <kherron@fastmail.us>.
00020  * Portions created by the Initial Developer are Copyright (C) 2004
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsPrintJobPS_h__
00040 #define nsPrintJobPS_h__
00041 
00042 #include "nsCUPSShim.h"
00043 #include "nsDebug.h"
00044 #include "nsIDeviceContext.h"   // for NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED
00045 #include "nsILocalFile.h"
00046 #include "nsIPrintJobPS.h"
00047 #include "nsString.h"
00048 #include "nsTempfilePS.h"
00049 
00050 
00051 /* Print job class for print preview operations. */
00052 
00053 class nsPrintJobPreviewPS : public nsIPrintJobPS {
00054     public:
00055         /* see nsIPrintJobPS.h. Print preview doesn't actually
00056          * implement printing.
00057          */
00058         nsresult StartSubmission(FILE **aHandle)
00059             { return NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED; }
00060 
00061         nsresult FinishSubmission()
00062             { return NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED; }
00063 
00064         nsresult SetNumCopies(int aNumCopies)
00065             { return NS_ERROR_NOT_IMPLEMENTED; }
00066 
00067     protected:
00068         /* See nsIPrintJobPS.h. */
00069         nsresult Init(nsIDeviceContextSpecPS *);
00070 };
00071 
00072 
00073 /* Print job class for print-to-file. */
00074 class nsPrintJobFilePS : public nsIPrintJobPS {
00075     public:
00076         nsPrintJobFilePS();
00077         ~nsPrintJobFilePS();
00078 
00079         /* see nsIPrintJobPS.h */
00080         nsresult StartSubmission(FILE **aHandle);
00081         nsresult FinishSubmission();
00082 
00083         nsresult SetNumCopies(int aNumCopies)
00084             { return NS_ERROR_NOT_IMPLEMENTED; }
00085 
00086     protected:
00087         /* see nsIPrintJobPS.h */
00088         nsresult Init(nsIDeviceContextSpecPS *);
00089 
00094         void SetDestHandle(FILE *aHandle) { mDestHandle = aHandle; }
00095 
00100         FILE *GetDestHandle() { return mDestHandle; }
00101 
00108         void SetDestination(const char *aDest) { mDestination = aDest; }
00109 
00114         nsCString& GetDestination() { return mDestination; }
00115 
00116 
00117     private:
00118         FILE *mDestHandle;                  // Destination file handle
00119         nsCString mDestination;
00120 };
00121 
00122 #ifdef VMS
00123 
00124 /* This is the class for printing by launching a command on VMS. The
00125  * string for GetDestination() and SetDestination() is a command to be
00126  * executed, rather than a filename.
00127  */
00128 class nsPrintJobVMSCmdPS : public nsPrintJobFilePS {
00129     public:
00130         /* see nsIPrintJobPS.h */
00131         nsresult StartSubmission(FILE **aHandle);
00132         nsresult FinishSubmission();
00133 
00134     protected:
00135         nsresult Init(nsIDeviceContextSpecPS *);
00136 
00137     private:
00138         nsCString mPrinterName;
00139         nsTempfilePS mTempFactory;
00140         nsCOMPtr<nsILocalFile> mTempFile;
00141 };
00142 
00143 #else   /* Not VMS */
00144 
00145 /* This is the class for printing to a pipe. The destination for
00146  * GetDestination() and SetDestination() is a command to be executed,
00147  * rather than a filename.
00148  */
00149 class nsPrintJobPipePS : public nsPrintJobFilePS {
00150     public:
00151         /* see nsIPrintJobPS.h */
00152         ~nsPrintJobPipePS();
00153         nsresult StartSubmission(FILE **aHandle);
00154         nsresult FinishSubmission();
00155 
00156     protected:
00157         nsresult Init(nsIDeviceContextSpecPS *);
00158 
00159     private:
00160         nsCString mPrinterName;
00161 };
00162 
00163 
00164 /* This class submits print jobs through CUPS. mDestHandle and
00165  * mDestination point to a temporary file used to assemble the
00166  * final print job.
00167  */
00168 class nsPrintJobCUPS : public nsPrintJobFilePS {
00169     public:
00170         nsresult StartSubmission(FILE **aHandle);
00171         nsresult FinishSubmission();
00172         nsresult SetNumCopies(int aNumCopies);
00173         void SetJobTitle(const PRUnichar *aTitle);
00174 
00175     protected:
00176         nsresult Init(nsIDeviceContextSpecPS *);
00177 
00178     private:
00179         nsCUPSShim mCups;
00180         nsCString mPrinterName;
00181         nsCString mNumCopies;
00182         nsCString mJobTitle;        // IsVoid() if no title
00183 };
00184 #endif  /* VMS */
00185 
00186 #endif /* nsPrintJobPS_h__ */