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