1*ebfcd9afSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ebfcd9afSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ebfcd9afSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ebfcd9afSAndrew Rist * distributed with this work for additional information 6*ebfcd9afSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ebfcd9afSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ebfcd9afSAndrew Rist * "License"); you may not use this file except in compliance 9*ebfcd9afSAndrew Rist * with the License. You may obtain a copy of the License at 10*ebfcd9afSAndrew Rist * 11*ebfcd9afSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ebfcd9afSAndrew Rist * 13*ebfcd9afSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ebfcd9afSAndrew Rist * software distributed under the License is distributed on an 15*ebfcd9afSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ebfcd9afSAndrew Rist * KIND, either express or implied. See the License for the 17*ebfcd9afSAndrew Rist * specific language governing permissions and limitations 18*ebfcd9afSAndrew Rist * under the License. 19*ebfcd9afSAndrew Rist * 20*ebfcd9afSAndrew Rist *************************************************************/ 21*ebfcd9afSAndrew Rist 22*ebfcd9afSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _PSPRINT_PRINTERJOB_HXX_ 25cdf0e10cSrcweir #define _PSPRINT_PRINTERJOB_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "vcl/jobdata.hxx" 28cdf0e10cSrcweir #include "osl/file.hxx" 29cdf0e10cSrcweir #include "rtl/string.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <list> 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace psp { 34cdf0e10cSrcweir 35cdf0e10cSrcweir // forward declarations 36cdf0e10cSrcweir class PrinterGfx; 37cdf0e10cSrcweir 38cdf0e10cSrcweir 39cdf0e10cSrcweir class PrinterJob 40cdf0e10cSrcweir { 41cdf0e10cSrcweir private: // private data 42cdf0e10cSrcweir 43cdf0e10cSrcweir rtl::OUString maSpoolDirName; 44cdf0e10cSrcweir rtl::OUString maFileName; // empty: spool to command, else spool to named file 45cdf0e10cSrcweir rtl::OUString maJobTitle; 46cdf0e10cSrcweir int mnFileMode; 47cdf0e10cSrcweir 48cdf0e10cSrcweir osl::File* mpJobHeader; 49cdf0e10cSrcweir osl::File* mpJobTrailer; 50cdf0e10cSrcweir 51cdf0e10cSrcweir std::list< osl::File* > maPageList; 52cdf0e10cSrcweir std::list< osl::File* > maHeaderList; 53cdf0e10cSrcweir 54cdf0e10cSrcweir JobData m_aDocumentJobData; 55cdf0e10cSrcweir JobData m_aLastJobData; 56cdf0e10cSrcweir PrinterGfx* m_pGraphics; 57cdf0e10cSrcweir 58cdf0e10cSrcweir sal_uInt32 mnResolution; 59cdf0e10cSrcweir 60cdf0e10cSrcweir sal_uInt32 mnWidthPt; 61cdf0e10cSrcweir sal_uInt32 mnHeightPt; 62cdf0e10cSrcweir sal_uInt32 mnMaxWidthPt; 63cdf0e10cSrcweir sal_uInt32 mnMaxHeightPt; 64cdf0e10cSrcweir 65cdf0e10cSrcweir int mnLandscapes; 66cdf0e10cSrcweir int mnPortraits; 67cdf0e10cSrcweir 68cdf0e10cSrcweir sal_uInt32 mnLMarginPt; 69cdf0e10cSrcweir sal_uInt32 mnRMarginPt; 70cdf0e10cSrcweir sal_uInt32 mnTMarginPt; 71cdf0e10cSrcweir sal_uInt32 mnBMarginPt; 72cdf0e10cSrcweir 73cdf0e10cSrcweir double mfXScale; 74cdf0e10cSrcweir double mfYScale; 75cdf0e10cSrcweir 76cdf0e10cSrcweir sal_Int32 mnErrorCode; 77cdf0e10cSrcweir bool m_bQuickJob; 78cdf0e10cSrcweir 79cdf0e10cSrcweir private: // private methods 80cdf0e10cSrcweir 81cdf0e10cSrcweir osl::File* CreateSpoolFile (const rtl::OUString& rName, 82cdf0e10cSrcweir const rtl::OUString& rExtension); 83cdf0e10cSrcweir void InitPaperSize (const JobData& rJobSetup); 84cdf0e10cSrcweir 85cdf0e10cSrcweir bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup ); 86cdf0e10cSrcweir bool writeSetup( osl::File* pFile, const JobData& ); 87cdf0e10cSrcweir bool writePageSetup( osl::File* pFile, const JobData&, bool bWriteFeatures = true ); 88cdf0e10cSrcweir void writeJobPatch( osl::File* File, const JobData& ); 89cdf0e10cSrcweir bool writeProlog (osl::File* pFile, const JobData& ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir public: // for usage in PrinterGfx 92cdf0e10cSrcweir 93cdf0e10cSrcweir sal_uInt32 GetResolution () const { return mnResolution; } 94cdf0e10cSrcweir void GetScale (double &rXScale, double &rYScale) const; 95cdf0e10cSrcweir sal_uInt16 GetDepth () const; 96cdf0e10cSrcweir sal_uInt16 GetPostscriptLevel (const JobData *pJobData = NULL) const; 97cdf0e10cSrcweir sal_Bool IsColorPrinter () const; 98cdf0e10cSrcweir 99cdf0e10cSrcweir osl::File* GetDocumentHeader (); 100cdf0e10cSrcweir osl::File* GetDocumentTrailer (); 101cdf0e10cSrcweir osl::File* GetCurrentPageHeader (); 102cdf0e10cSrcweir osl::File* GetCurrentPageBody (); 103cdf0e10cSrcweir 104cdf0e10cSrcweir const ::rtl::OUString& GetPrinterName() const { return m_aLastJobData.m_aPrinterName; } 105cdf0e10cSrcweir 106cdf0e10cSrcweir public: 107cdf0e10cSrcweir PrinterJob (); 108cdf0e10cSrcweir ~PrinterJob (); 109cdf0e10cSrcweir 110cdf0e10cSrcweir /* rFileName: if length is greater than 0 save resulting PostScript 111cdf0e10cSrcweir * to named file. 112cdf0e10cSrcweir * nMode: only meaningful when saving to file: if nonzero, try 113cdf0e10cSrcweir * to impose the mode on the resulting file's inode; for nonexistant 114cdf0e10cSrcweir * files use open, for existant files try a chmod 115cdf0e10cSrcweir * rJobName: text to appear in the %%Title comment 116cdf0e10cSrcweir * rAppName: text to appear in the %%Creator comment 117cdf0e10cSrcweir * rSetupData: JobData that apply to this job 118cdf0e10cSrcweir * pGraphics: the graphics used to print this job; 119cdf0e10cSrcweir * this graphics must live until End/AbortJob has returned 120cdf0e10cSrcweir * bIsQuickJob: the job was started as "direct print" meaning 121cdf0e10cSrcweir * the quick command for spooling should be used instead 122cdf0e10cSrcweir * of the normal command 123cdf0e10cSrcweir */ 124cdf0e10cSrcweir sal_Bool StartJob (const rtl::OUString& rFileName, 125cdf0e10cSrcweir int nMode, 126cdf0e10cSrcweir const rtl::OUString& rJobName, 127cdf0e10cSrcweir const rtl::OUString& rAppName, 128cdf0e10cSrcweir const JobData& rSetupData, 129cdf0e10cSrcweir PrinterGfx* pGraphics, 130cdf0e10cSrcweir bool bIsQuickJob 131cdf0e10cSrcweir ); 132cdf0e10cSrcweir sal_Bool EndJob (); 133cdf0e10cSrcweir 134cdf0e10cSrcweir sal_Bool AbortJob (); 135cdf0e10cSrcweir 136cdf0e10cSrcweir sal_Bool StartPage (const JobData& rJobSetup); 137cdf0e10cSrcweir sal_Bool EndPage (); 138cdf0e10cSrcweir 139cdf0e10cSrcweir sal_uInt32 GetErrorCode (); 140cdf0e10cSrcweir }; 141cdf0e10cSrcweir 142cdf0e10cSrcweir } /* namespace psp */ 143cdf0e10cSrcweir 144cdf0e10cSrcweir #endif /* _PSPRINT_PRINTERJOB_HXX_ */ 145cdf0e10cSrcweir 146