Okular

fileprinter.h
1/*
2 SPDX-FileCopyrightText: 2007, 2010 John Layt <john@layt.net>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7// This Class is a temporary addition to Okular for the duration of KDE 4.0.
8// In KDE 4.1 this class will either be moved to kdelibs if still required,
9// or replaced with a Qt 4.4 based solution.
10
11#ifndef FILEPRINTER_H
12#define FILEPRINTER_H
13
14#include <QList>
15#include <QPrinter>
16#include <QString>
17
18#include "document.h"
19#include "okularcore_export.h"
20
21class QSize;
22
23namespace Okular
24{
25class OKULARCORE_EXPORT FilePrinter
26{
27public:
28 /** Whether file(s) get deleted by the application or by the print system.
29 *
30 * You may need to chose system deletion if your temp file clean-up
31 * deletes the file before the print system is finished with it.
32 */
33 enum FileDeletePolicy { ApplicationDeletesFiles, SystemDeletesFiles };
34
35 /** Whether pages to be printed are selected by the application or the print system.
36 *
37 * If application side, then the generated file will only contain those pages
38 * selected by the user, so FilePrinter will print all the pages in the file.
39 *
40 * If system side, then the file will contain all the pages in the document, and
41 * the print system will print the users selected print range from out of the file.
42 *
43 * Note system side only works in CUPS, not LPR.
44 */
45 enum PageSelectPolicy { ApplicationSelectsPages, SystemSelectsPages };
46
47 /** Whether to apply scaling when printing.
48 *
49 * 'NoScaling' indicates that no scaling should be applied.
50 * 'FitToPrintArea' indicates that the document should be scaled to the
51 * area that is available for printing. Whether or not this includes the printer's
52 * hardware margins depends on the value of 'QPrinter::fullPage()' for the given printer.
53 *
54 * @since 1.8
55 */
56 enum ScaleMode { NoScaling = 0, FitToPrintArea = 1 };
57
58 /** Print a file using the settings in QPrinter
59 *
60 * Only supports CUPS and LPR on *NIX. Page Range only supported in CUPS.
61 * Most settings unsupported by LPR, some settings unsupported by CUPS.
62 *
63 * The documentOrientation parameter was added in version 0.14.
64 *
65 * @param printer the print settings to use
66 * @param file the file to print
67 * @param documentOrientation the orientation stored in the document itself
68 * @param scaleMode scale mode to use
69 * @param fileDeletePolicy if the application or system deletes the file
70 * @param pageSelectPolicy if the application or system selects the pages to print
71 * @param pageRange page range to print if SystemSelectsPages and user chooses Selection in Print Dialog
72 *
73 * @returns Returns exit code:
74 * -9 if lpr not found
75 * -8 if empty file name
76 * -7 if unable to find file
77 * -6 if invalid printer state
78 * -5 if print to file copy failed
79 * -2 if the KProcess could not be started
80 * -1 if the KProcess crashed
81 * otherwise the KProcess exit code
82 *
83 * @since 1.8
84 */
85 static Document::PrintError printFile(QPrinter &printer,
86 const QString &file,
87 QPageLayout::Orientation documentOrientation,
88 FileDeletePolicy fileDeletePolicy = FilePrinter::ApplicationDeletesFiles,
89 PageSelectPolicy pageSelectPolicy = FilePrinter::ApplicationSelectsPages,
90 const QString &pageRange = QString(),
91 ScaleMode scaleMode = ScaleMode::FitToPrintArea);
92
93 /** Return the list of pages selected by the user in the Print Dialog
94 *
95 * @param printer the print settings to use
96 * @param lastPage the last page number, needed if AllPages option is selected
97 * @param currentPage the current page number, needed if CurrentPage option is selected
98 * @param selectedPageList list of pages to use if Selection option is selected
99 * @returns Returns list of pages to print
100 */
101 static QList<int> pageList(QPrinter &printer, int lastPage, int currentPage, const QList<int> &selectedPageList);
102
103 /** Return if Ghostscript ps2pdf is available on this system
104 *
105 * @returns Returns true if Ghostscript ps2pdf available
106 */
107 static bool ps2pdfAvailable();
108
109 /** Return if Ghostscript pdf2ps is available on this system
110 *
111 * @returns Returns true if Ghostscript pdf2ps available
112 */
113 static bool pdf2psAvailable();
114
115private:
116 /** Return if CUPS Print System is available on this system
117 *
118 * @returns Returns true if CUPS available
119 */
120 static bool cupsAvailable();
121
122 Document::PrintError
123 doPrintFiles(QPrinter &printer, const QStringList &fileList, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, QPageLayout::Orientation documentOrientation, ScaleMode scaleMode);
124
125 /// @since 1.8
126 QStringList printArguments(QPrinter &printer,
127 FileDeletePolicy fileDeletePolicy,
128 PageSelectPolicy pageSelectPolicy,
129 bool useCupsOptions,
130 const QString &pageRange,
131 const QString &version,
132 QPageLayout::Orientation documentOrientation,
133 ScaleMode scaleMode);
134
135 QStringList destination(QPrinter &printer, const QString &version);
136 QStringList copies(QPrinter &printer, const QString &version);
137 QStringList jobname(QPrinter &printer, const QString &version);
138 QStringList deleteFile(QPrinter &printer, FileDeletePolicy fileDeletePolicy, const QString &version);
139 QStringList pages(QPrinter &printer, PageSelectPolicy pageSelectPolicy, const QString &pageRange, bool useCupsOptions, const QString &version);
140
141 /// @since 1.8
142 QStringList cupsOptions(QPrinter &printer, QPageLayout::Orientation documentOrientation, ScaleMode scaleMode);
143 QStringList optionMedia(QPrinter &printer);
144 QString mediaPageSize(QPrinter &printer);
145 QString mediaPaperSource(QPrinter &printer);
146 QStringList optionOrientation(QPrinter &printer, QPageLayout::Orientation documentOrientation);
147 QStringList optionDoubleSidedPrinting(QPrinter &printer);
148 QStringList optionPageOrder(QPrinter &printer);
149 QStringList optionCollateCopies(QPrinter &printer);
150 /// @since 1.8
151 QStringList optionPageMargins(QPrinter &printer, ScaleMode scaleMode);
152 QStringList optionCupsProperties(QPrinter &printer);
153};
154
155}
156
157#endif // FILEPRINTER_H
const QList< QKeySequence > & deleteFile()
global.h
Definition action.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.