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