Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_INC_GENERIC_PRINTERJOB_HXX
21 : #define INCLUDED_VCL_INC_GENERIC_PRINTERJOB_HXX
22 :
23 : #include "vcl/jobdata.hxx"
24 : #include "osl/file.hxx"
25 : #include "rtl/string.hxx"
26 :
27 : #include <list>
28 :
29 : namespace psp {
30 :
31 : class PrinterGfx;
32 :
33 : class PrinterJob
34 : {
35 : private:
36 : OUString maSpoolDirName;
37 : OUString maFileName; // empty: spool to command, else spool to named file
38 : OUString maJobTitle;
39 : int mnFileMode;
40 :
41 : osl::File* mpJobHeader;
42 : osl::File* mpJobTrailer;
43 :
44 : std::list< osl::File* > maPageList;
45 : std::list< osl::File* > maHeaderList;
46 :
47 : JobData m_aDocumentJobData;
48 : JobData m_aLastJobData;
49 : PrinterGfx* m_pGraphics;
50 :
51 : sal_uInt32 mnResolution;
52 :
53 : sal_uInt32 mnWidthPt;
54 : sal_uInt32 mnHeightPt;
55 : sal_uInt32 mnMaxWidthPt;
56 : sal_uInt32 mnMaxHeightPt;
57 :
58 : int mnLandscapes;
59 : int mnPortraits;
60 :
61 : sal_uInt32 mnLMarginPt;
62 : sal_uInt32 mnRMarginPt;
63 : sal_uInt32 mnTMarginPt;
64 : sal_uInt32 mnBMarginPt;
65 :
66 : double mfXScale;
67 : double mfYScale;
68 :
69 : bool m_bQuickJob;
70 :
71 : private:
72 : osl::File* CreateSpoolFile (const OUString& rName,
73 : const OUString& rExtension);
74 : void InitPaperSize (const JobData& rJobSetup);
75 :
76 : bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup );
77 : bool writeSetup( osl::File* pFile, const JobData& );
78 : bool writePageSetup( osl::File* pFile, const JobData&, bool bWriteFeatures = true );
79 : static void writeJobPatch( osl::File* File, const JobData& );
80 : static bool writeProlog (osl::File* pFile, const JobData& );
81 :
82 : public: // for usage in PrinterGfx
83 0 : sal_uInt32 GetResolution () const { return mnResolution; }
84 : void GetScale (double &rXScale, double &rYScale) const;
85 : sal_uInt16 GetDepth () const;
86 : sal_uInt16 GetPostscriptLevel (const JobData *pJobData = NULL) const;
87 : bool IsColorPrinter () const;
88 :
89 : osl::File* GetCurrentPageHeader ();
90 : osl::File* GetCurrentPageBody ();
91 :
92 0 : const OUString& GetPrinterName() const { return m_aLastJobData.m_aPrinterName; }
93 :
94 : public:
95 : PrinterJob ();
96 : ~PrinterJob ();
97 :
98 : /* rFileName: if length is greater than 0 save resulting PostScript
99 : * to named file.
100 : * nMode: only meaningful when saving to file: if nonzero, try
101 : * to impose the mode on the resulting file's inode; for nonexistant
102 : * files use open, for existent files try a chmod
103 : * rJobName: text to appear in the %%Title comment
104 : * rAppName: text to appear in the %%Creator comment
105 : * rSetupData: JobData that apply to this job
106 : * pGraphics: the graphics used to print this job;
107 : * this graphics must live until End/AbortJob has returned
108 : * bIsQuickJob: the job was started as "direct print" meaning
109 : * the quick command for spooling should be used instead
110 : * of the normal command
111 : */
112 : bool StartJob (const OUString& rFileName,
113 : int nMode,
114 : const OUString& rJobName,
115 : const OUString& rAppName,
116 : const JobData& rSetupData,
117 : PrinterGfx* pGraphics,
118 : bool bIsQuickJob
119 : );
120 : bool EndJob ();
121 :
122 : bool AbortJob ();
123 :
124 : bool StartPage (const JobData& rJobSetup);
125 : bool EndPage ();
126 : };
127 :
128 : } // namespace psp
129 :
130 : #endif // INCLUDED_VCL_INC_GENERIC_PRINTERJOB_HXX
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|