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
28Q_DECLARE_METATYPE(ppd_file_t *)
29#endif
30
31QT_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
52namespace 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 // Note: Keep in sync with QPrinter::ColorMode
72 enum ColorMode {
73 GrayScale,
74 Color
75 };
76
77 // Note: Keep in sync with QPrinter::PaperSource for now
78 // If/when made public, rearrange and rename
79 enum InputSlotId {
80 Upper,
81 Lower,
82 Middle,
83 Manual,
84 Envelope,
85 EnvelopeManual,
86 Auto,
87 Tractor,
88 SmallFormat,
89 LargeFormat,
90 LargeCapacity,
91 Cassette,
92 FormSource,
93 MaxPageSource, // Deprecated, kept for compatibility to QPrinter
94 CustomInputSlot,
95 LastInputSlot = CustomInputSlot,
96 OnlyOne = Upper
97 };
98
99 struct InputSlot {
100 QByteArray key;
101 QString name;
102 QPrint::InputSlotId id;
103 int windowsId;
104 };
105
106 enum OutputBinId {
107 AutoOutputBin,
108 UpperBin,
109 LowerBin,
110 RearBin,
111 CustomOutputBin,
112 LastOutputBin = CustomOutputBin
113 };
114
115 struct OutputBin {
116 QByteArray key;
117 QString name;
118 QPrint::OutputBinId id;
119 };
120
121}
122
123struct InputSlotMap {
124 QPrint::InputSlotId id;
125 int windowsId;
126 const char *key;
127};
128
129struct OutputBinMap {
130 QPrint::OutputBinId id;
131 const char *key;
132};
133
134// Print utilities shared by print plugins
135
136namespace QPrintUtils {
137
138Q_PRINTSUPPORT_EXPORT QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key);
139Q_PRINTSUPPORT_EXPORT QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id);
140Q_PRINTSUPPORT_EXPORT int inputSlotIdToWindowsId(QPrint::InputSlotId id);
141Q_PRINTSUPPORT_EXPORT QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key);
142Q_PRINTSUPPORT_EXPORT QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id);
143Q_PRINTSUPPORT_EXPORT QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name);
144
145# if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups))
146// PPD utilities shared by CUPS and Mac plugins requiring CUPS headers
147// May turn into a proper internal QPpd class if enough shared between Mac and CUPS,
148// but where would it live? Not in base module as don't want to link to CUPS.
149// May have to have two copies in plugins to keep in sync.
150Q_PRINTSUPPORT_EXPORT QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice);
151Q_PRINTSUPPORT_EXPORT QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice);
152Q_PRINTSUPPORT_EXPORT int parsePpdResolution(const QByteArray &value);
153Q_PRINTSUPPORT_EXPORT QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice);
154# endif // Mac and CUPS PPD Utilities
155};
156
157#endif // QT_NO_PRINTER
158
159QT_END_NAMESPACE
160
161#endif // QPRINT_P_H
162

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtbase/src/printsupport/kernel/qprint_p.h