xref: /aoo42x/main/vcl/inc/printerjob.hxx (revision 86e1cf34)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _PSPRINT_PRINTERJOB_HXX_
25 #define _PSPRINT_PRINTERJOB_HXX_
26 
27 #include "vcl/jobdata.hxx"
28 #include "osl/file.hxx"
29 #include "rtl/string.hxx"
30 
31 #include <list>
32 
33 namespace psp {
34 
35 // forward declarations
36 class PrinterGfx;
37 
38 
39 class PrinterJob
40 {
41 private:            // private data
42 
43     rtl::OUString           maSpoolDirName;
44     rtl::OUString           maFileName; // empty: spool to command, else spool to named file
45     rtl::OUString			maJobTitle;
46     int						mnFileMode;
47 
48     osl::File*              mpJobHeader;
49     osl::File*              mpJobTrailer;
50 
51     std::list< osl::File* > maPageList;
52     std::list< osl::File* > maHeaderList;
53 
54     JobData                 m_aDocumentJobData;
55     JobData                 m_aLastJobData;
56     PrinterGfx*             m_pGraphics;
57 
58     sal_uInt32      mnResolution;
59 
60     sal_uInt32      mnWidthPt;
61     sal_uInt32      mnHeightPt;
62     sal_uInt32      mnMaxWidthPt;
63     sal_uInt32      mnMaxHeightPt;
64 
65     int mnLandscapes;
66     int mnPortraits;
67 
68     sal_uInt32      mnLMarginPt;
69     sal_uInt32      mnRMarginPt;
70     sal_uInt32      mnTMarginPt;
71     sal_uInt32      mnBMarginPt;
72 
73     double          mfXScale;
74     double          mfYScale;
75 
76     sal_Int32       mnErrorCode;
77     bool            m_bQuickJob;
78 
79 private:            // private methods
80 
81     osl::File*      CreateSpoolFile (const rtl::OUString& rName,
82                                      const rtl::OUString& rExtension);
83     void            InitPaperSize (const JobData& rJobSetup);
84 
85     bool			writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup );
86     bool            writeSetup( osl::File* pFile, const JobData& );
87     bool            writePageSetup( osl::File* pFile, const JobData&, bool bWriteFeatures = true );
88     void			writeJobPatch( osl::File* File, const JobData& );
89     bool            writeProlog (osl::File* pFile, const JobData& );
90 
91 public:             // for usage in PrinterGfx
92 
GetResolution() const93     sal_uInt32      GetResolution () const { return mnResolution; }
94     void            GetScale (double &rXScale, double &rYScale) const;
95     sal_uInt16      GetDepth () const;
96     sal_uInt16      GetPostscriptLevel (const JobData *pJobData = NULL) const;
97     sal_Bool        IsColorPrinter () const;
98 
99     osl::File*      GetDocumentHeader ();
100     osl::File*      GetDocumentTrailer ();
101     osl::File*      GetCurrentPageHeader ();
102     osl::File*      GetCurrentPageBody ();
103 
GetPrinterName() const104     const ::rtl::OUString& GetPrinterName() const { return m_aLastJobData.m_aPrinterName; }
105 
106 public:
107     PrinterJob ();
108     ~PrinterJob ();
109 
110     /*  rFileName: if length is greater than 0 save resulting PostScript
111      *  to named file.
112      *  nMode: only meaningful when saving to file: if nonzero, try
113      *  to impose the mode on the resulting file's inode; for nonexistant
114      *  files use open, for existent files try a chmod
115      *  rJobName: text to appear in the %%Title comment
116      *  rAppName: text to appear in the %%Creator comment
117      *  rSetupData: JobData that apply to this job
118      *  pGraphics: the graphics used to print this job;
119      *             this graphics must live until End/AbortJob has returned
120      *  bIsQuickJob: the job was started as "direct print" meaning
121      *               the quick command for spooling should be used instead
122      *               of the normal command
123      */
124     sal_Bool        StartJob (const rtl::OUString& rFileName,
125                               int nMode,
126                               const rtl::OUString& rJobName,
127                               const rtl::OUString& rAppName,
128                               const JobData& rSetupData,
129                               PrinterGfx* pGraphics,
130                               bool bIsQuickJob
131                               );
132     sal_Bool        EndJob ();
133 
134     sal_Bool        AbortJob ();
135 
136     sal_Bool		StartPage (const JobData& rJobSetup);
137     sal_Bool        EndPage ();
138 
139     sal_uInt32      GetErrorCode ();
140 };
141 
142 }  /* namespace psp */
143 
144 #endif /* _PSPRINT_PRINTERJOB_HXX_ */
145 
146