Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _PSPRINT_PRINTERJOB_HXX_
30 : : #define _PSPRINT_PRINTERJOB_HXX_
31 : :
32 : : #include "vcl/jobdata.hxx"
33 : : #include "osl/file.hxx"
34 : : #include "rtl/string.hxx"
35 : :
36 : : #include <list>
37 : :
38 : : namespace psp {
39 : :
40 : : // forward declarations
41 : : class PrinterGfx;
42 : :
43 : :
44 : : class PrinterJob
45 : : {
46 : : private: // private data
47 : :
48 : : rtl::OUString maSpoolDirName;
49 : : rtl::OUString maFileName; // empty: spool to command, else spool to named file
50 : : rtl::OUString maJobTitle;
51 : : int mnFileMode;
52 : :
53 : : osl::File* mpJobHeader;
54 : : osl::File* mpJobTrailer;
55 : :
56 : : std::list< osl::File* > maPageList;
57 : : std::list< osl::File* > maHeaderList;
58 : :
59 : : JobData m_aDocumentJobData;
60 : : JobData m_aLastJobData;
61 : : PrinterGfx* m_pGraphics;
62 : :
63 : : sal_uInt32 mnResolution;
64 : :
65 : : sal_uInt32 mnWidthPt;
66 : : sal_uInt32 mnHeightPt;
67 : : sal_uInt32 mnMaxWidthPt;
68 : : sal_uInt32 mnMaxHeightPt;
69 : :
70 : : int mnLandscapes;
71 : : int mnPortraits;
72 : :
73 : : sal_uInt32 mnLMarginPt;
74 : : sal_uInt32 mnRMarginPt;
75 : : sal_uInt32 mnTMarginPt;
76 : : sal_uInt32 mnBMarginPt;
77 : :
78 : : double mfXScale;
79 : : double mfYScale;
80 : :
81 : : bool m_bQuickJob;
82 : :
83 : : private: // private methods
84 : :
85 : : osl::File* CreateSpoolFile (const rtl::OUString& rName,
86 : : const rtl::OUString& rExtension);
87 : : void InitPaperSize (const JobData& rJobSetup);
88 : :
89 : : bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup );
90 : : bool writeSetup( osl::File* pFile, const JobData& );
91 : : bool writePageSetup( osl::File* pFile, const JobData&, bool bWriteFeatures = true );
92 : : void writeJobPatch( osl::File* File, const JobData& );
93 : : bool writeProlog (osl::File* pFile, const JobData& );
94 : :
95 : : public: // for usage in PrinterGfx
96 : :
97 : 0 : sal_uInt32 GetResolution () const { return mnResolution; }
98 : : void GetScale (double &rXScale, double &rYScale) const;
99 : : sal_uInt16 GetDepth () const;
100 : : sal_uInt16 GetPostscriptLevel (const JobData *pJobData = NULL) const;
101 : : sal_Bool IsColorPrinter () const;
102 : :
103 : : osl::File* GetCurrentPageHeader ();
104 : : osl::File* GetCurrentPageBody ();
105 : :
106 : 0 : const ::rtl::OUString& GetPrinterName() const { return m_aLastJobData.m_aPrinterName; }
107 : :
108 : : public:
109 : : PrinterJob ();
110 : : ~PrinterJob ();
111 : :
112 : : /* rFileName: if length is greater than 0 save resulting PostScript
113 : : * to named file.
114 : : * nMode: only meaningful when saving to file: if nonzero, try
115 : : * to impose the mode on the resulting file's inode; for nonexistant
116 : : * files use open, for existant files try a chmod
117 : : * rJobName: text to appear in the %%Title comment
118 : : * rAppName: text to appear in the %%Creator comment
119 : : * rSetupData: JobData that apply to this job
120 : : * pGraphics: the graphics used to print this job;
121 : : * this graphics must live until End/AbortJob has returned
122 : : * bIsQuickJob: the job was started as "direct print" meaning
123 : : * the quick command for spooling should be used instead
124 : : * of the normal command
125 : : */
126 : : sal_Bool StartJob (const rtl::OUString& rFileName,
127 : : int nMode,
128 : : const rtl::OUString& rJobName,
129 : : const rtl::OUString& rAppName,
130 : : const JobData& rSetupData,
131 : : PrinterGfx* pGraphics,
132 : : bool bIsQuickJob
133 : : );
134 : : sal_Bool EndJob ();
135 : :
136 : : sal_Bool AbortJob ();
137 : :
138 : : sal_Bool StartPage (const JobData& rJobSetup);
139 : : sal_Bool EndPage ();
140 : : };
141 : :
142 : : } /* namespace psp */
143 : :
144 : : #endif /* _PSPRINT_PRINTERJOB_HXX_ */
145 : :
146 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|