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