1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // Copyright (C) 2014 John Layt <jlayt@kde.org> |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #ifndef QPRINT_P_H |
6 | #define QPRINT_P_H |
7 | |
8 | // |
9 | // W A R N I N G |
10 | // ------------- |
11 | // |
12 | // This file is not part of the Qt API. It exists purely as an |
13 | // implementation detail. This header file may change from version to |
14 | // version without notice, or even be removed. |
15 | // |
16 | // We mean it. |
17 | // |
18 | |
19 | #include <QtPrintSupport/private/qtprintsupportglobal_p.h> |
20 | #include <QtPrintSupport/qprinter.h> |
21 | |
22 | #include <QtCore/qstring.h> |
23 | #include <QtCore/qlist.h> |
24 | |
25 | #if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) |
26 | #include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module |
27 | // ### QT_DECL_METATYPE_EXTERN_TAGGED once there's a qprint.cpp TU |
28 | Q_DECLARE_METATYPE(ppd_file_t *) |
29 | #endif |
30 | |
31 | QT_BEGIN_NAMESPACE |
32 | |
33 | #ifndef QT_NO_PRINTER |
34 | |
35 | // From windgdi.h |
36 | #define DMBIN_UPPER 1 |
37 | #define DMBIN_ONLYONE 1 |
38 | #define DMBIN_LOWER 2 |
39 | #define DMBIN_MIDDLE 3 |
40 | #define DMBIN_MANUAL 4 |
41 | #define DMBIN_ENVELOPE 5 |
42 | #define DMBIN_ENVMANUAL 6 |
43 | #define DMBIN_AUTO 7 |
44 | #define DMBIN_TRACTOR 8 |
45 | #define DMBIN_SMALLFMT 9 |
46 | #define DMBIN_LARGEFMT 10 |
47 | #define DMBIN_LARGECAPACITY 11 |
48 | #define DMBIN_CASSETTE 14 |
49 | #define DMBIN_FORMSOURCE 15 |
50 | #define DMBIN_USER 256 |
51 | |
52 | namespace QPrint { |
53 | |
54 | // Note: Keep in sync with QPrinter::PrinterState for now |
55 | // Replace later with more detailed status reporting |
56 | enum DeviceState { |
57 | Idle, |
58 | Active, |
59 | Aborted, |
60 | Error |
61 | }; |
62 | |
63 | // Note: Keep in sync with QPrinter::DuplexMode |
64 | enum DuplexMode { |
65 | DuplexNone = 0, |
66 | DuplexAuto, |
67 | DuplexLongSide, |
68 | DuplexShortSide |
69 | }; |
70 | |
71 | enum ColorMode { |
72 | GrayScale, |
73 | Color |
74 | }; |
75 | |
76 | // Note: Keep in sync with QPrinter::PaperSource for now |
77 | // If/when made public, rearrange and rename |
78 | enum InputSlotId { |
79 | Upper, |
80 | Lower, |
81 | Middle, |
82 | Manual, |
83 | Envelope, |
84 | EnvelopeManual, |
85 | Auto, |
86 | Tractor, |
87 | SmallFormat, |
88 | LargeFormat, |
89 | LargeCapacity, |
90 | Cassette, |
91 | FormSource, |
92 | MaxPageSource, // Deprecated, kept for compatibility to QPrinter |
93 | CustomInputSlot, |
94 | LastInputSlot = CustomInputSlot, |
95 | OnlyOne = Upper |
96 | }; |
97 | |
98 | struct InputSlot { |
99 | QByteArray key; |
100 | QString name; |
101 | QPrint::InputSlotId id; |
102 | int windowsId; |
103 | }; |
104 | |
105 | enum OutputBinId { |
106 | AutoOutputBin, |
107 | UpperBin, |
108 | LowerBin, |
109 | RearBin, |
110 | CustomOutputBin, |
111 | LastOutputBin = CustomOutputBin |
112 | }; |
113 | |
114 | struct OutputBin { |
115 | QByteArray key; |
116 | QString name; |
117 | QPrint::OutputBinId id; |
118 | }; |
119 | |
120 | } |
121 | |
122 | struct InputSlotMap { |
123 | QPrint::InputSlotId id; |
124 | int windowsId; |
125 | const char *key; |
126 | }; |
127 | |
128 | struct OutputBinMap { |
129 | QPrint::OutputBinId id; |
130 | const char *key; |
131 | }; |
132 | |
133 | // Print utilities shared by print plugins |
134 | |
135 | namespace QPrintUtils { |
136 | |
137 | Q_PRINTSUPPORT_EXPORT QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key); |
138 | Q_PRINTSUPPORT_EXPORT QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id); |
139 | Q_PRINTSUPPORT_EXPORT int inputSlotIdToWindowsId(QPrint::InputSlotId id); |
140 | Q_PRINTSUPPORT_EXPORT QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key); |
141 | Q_PRINTSUPPORT_EXPORT QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id); |
142 | Q_PRINTSUPPORT_EXPORT QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name); |
143 | |
144 | # if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) |
145 | // PPD utilities shared by CUPS and Mac plugins requiring CUPS headers |
146 | // May turn into a proper internal QPpd class if enough shared between Mac and CUPS, |
147 | // but where would it live? Not in base module as don't want to link to CUPS. |
148 | // May have to have two copies in plugins to keep in sync. |
149 | Q_PRINTSUPPORT_EXPORT QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice); |
150 | Q_PRINTSUPPORT_EXPORT QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice); |
151 | Q_PRINTSUPPORT_EXPORT int parsePpdResolution(const QByteArray &value); |
152 | Q_PRINTSUPPORT_EXPORT QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice); |
153 | # endif // Mac and CUPS PPD Utilities |
154 | }; |
155 | |
156 | #endif // QT_NO_PRINTER |
157 | |
158 | QT_END_NAMESPACE |
159 | |
160 | #endif // QPRINT_P_H |
161 | |