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 : // forward declarations
32 : class PrinterGfx;
33 :
34 : class PrinterJob
35 : {
36 : private: // private data
37 :
38 : OUString maSpoolDirName;
39 : OUString maFileName; // empty: spool to command, else spool to named file
40 : OUString maJobTitle;
41 : int mnFileMode;
42 :
43 : osl::File* mpJobHeader;
44 : osl::File* mpJobTrailer;
45 :
46 : std::list< osl::File* > maPageList;
47 : std::list< osl::File* > maHeaderList;
48 :
49 : JobData m_aDocumentJobData;
50 : JobData m_aLastJobData;
51 : PrinterGfx* m_pGraphics;
52 :
53 : sal_uInt32 mnResolution;
54 :
55 : sal_uInt32 mnWidthPt;
56 : sal_uInt32 mnHeightPt;
57 : sal_uInt32 mnMaxWidthPt;
58 : sal_uInt32 mnMaxHeightPt;
59 :
60 : int mnLandscapes;
61 : int mnPortraits;
62 :
63 : sal_uInt32 mnLMarginPt;
64 : sal_uInt32 mnRMarginPt;
65 : sal_uInt32 mnTMarginPt;
66 : sal_uInt32 mnBMarginPt;
67 :
68 : double mfXScale;
69 : double mfYScale;
70 :
71 : bool m_bQuickJob;
72 :
73 : private: // private methods
74 :
75 : osl::File* CreateSpoolFile (const OUString& rName,
76 : const OUString& rExtension);
77 : void InitPaperSize (const JobData& rJobSetup);
78 :
79 : bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup );
80 : bool writeSetup( osl::File* pFile, const JobData& );
81 : bool writePageSetup( osl::File* pFile, const JobData&, bool bWriteFeatures = true );
82 : void writeJobPatch( osl::File* File, const JobData& );
83 : bool writeProlog (osl::File* pFile, const JobData& );
84 :
85 : public: // for usage in PrinterGfx
86 :
87 0 : sal_uInt32 GetResolution () const { return mnResolution; }
88 : void GetScale (double &rXScale, double &rYScale) const;
89 : sal_uInt16 GetDepth () const;
90 : sal_uInt16 GetPostscriptLevel (const JobData *pJobData = NULL) const;
91 : bool IsColorPrinter () const;
92 :
93 : osl::File* GetCurrentPageHeader ();
94 : osl::File* GetCurrentPageBody ();
95 :
96 0 : const OUString& GetPrinterName() const { return m_aLastJobData.m_aPrinterName; }
97 :
98 : public:
99 : PrinterJob ();
100 : ~PrinterJob ();
101 :
102 : /* rFileName: if length is greater than 0 save resulting PostScript
103 : * to named file.
104 : * nMode: only meaningful when saving to file: if nonzero, try
105 : * to impose the mode on the resulting file's inode; for nonexistant
106 : * files use open, for existant files try a chmod
107 : * rJobName: text to appear in the %%Title comment
108 : * rAppName: text to appear in the %%Creator comment
109 : * rSetupData: JobData that apply to this job
110 : * pGraphics: the graphics used to print this job;
111 : * this graphics must live until End/AbortJob has returned
112 : * bIsQuickJob: the job was started as "direct print" meaning
113 : * the quick command for spooling should be used instead
114 : * of the normal command
115 : */
116 : bool StartJob (const OUString& rFileName,
117 : int nMode,
118 : const OUString& rJobName,
119 : const OUString& rAppName,
120 : const JobData& rSetupData,
121 : PrinterGfx* pGraphics,
122 : bool bIsQuickJob
123 : );
124 : bool EndJob ();
125 :
126 : bool AbortJob ();
127 :
128 : bool StartPage (const JobData& rJobSetup);
129 : bool EndPage ();
130 : };
131 :
132 : } /* namespace psp */
133 :
134 : #endif // INCLUDED_VCL_INC_GENERIC_PRINTERJOB_HXX
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|