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