Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qplatformprintdevice.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | QPlatformPrintDevice::QPlatformPrintDevice() | - | ||||||||||||
9 | : m_isRemote(false), | - | ||||||||||||
10 | m_supportsMultipleCopies(false), | - | ||||||||||||
11 | m_supportsCollateCopies(false), | - | ||||||||||||
12 | m_havePageSizes(false), | - | ||||||||||||
13 | m_supportsCustomPageSizes(false), | - | ||||||||||||
14 | m_haveResolutions(false), | - | ||||||||||||
15 | m_haveInputSlots(false), | - | ||||||||||||
16 | m_haveOutputBins(false), | - | ||||||||||||
17 | m_haveDuplexModes(false), | - | ||||||||||||
18 | m_haveColorModes(false) | - | ||||||||||||
19 | - | |||||||||||||
20 | , m_haveMimeTypes(false) | - | ||||||||||||
21 | - | |||||||||||||
22 | { | - | ||||||||||||
23 | } | - | ||||||||||||
24 | - | |||||||||||||
25 | QPlatformPrintDevice::QPlatformPrintDevice(const QString &id) | - | ||||||||||||
26 | : m_id(id), | - | ||||||||||||
27 | m_isRemote(false), | - | ||||||||||||
28 | m_supportsMultipleCopies(false), | - | ||||||||||||
29 | m_supportsCollateCopies(false), | - | ||||||||||||
30 | m_havePageSizes(false), | - | ||||||||||||
31 | m_supportsCustomPageSizes(false), | - | ||||||||||||
32 | m_haveResolutions(false), | - | ||||||||||||
33 | m_haveInputSlots(false), | - | ||||||||||||
34 | m_haveOutputBins(false), | - | ||||||||||||
35 | m_haveDuplexModes(false), | - | ||||||||||||
36 | m_haveColorModes(false) | - | ||||||||||||
37 | - | |||||||||||||
38 | , m_haveMimeTypes(false) | - | ||||||||||||
39 | - | |||||||||||||
40 | { | - | ||||||||||||
41 | } | - | ||||||||||||
42 | - | |||||||||||||
43 | QPlatformPrintDevice::~QPlatformPrintDevice() | - | ||||||||||||
44 | { | - | ||||||||||||
45 | } | - | ||||||||||||
46 | - | |||||||||||||
47 | QString QPlatformPrintDevice::id() const | - | ||||||||||||
48 | { | - | ||||||||||||
49 | return m_id; | - | ||||||||||||
50 | } | - | ||||||||||||
51 | - | |||||||||||||
52 | QString QPlatformPrintDevice::name() const | - | ||||||||||||
53 | { | - | ||||||||||||
54 | return m_name; | - | ||||||||||||
55 | } | - | ||||||||||||
56 | - | |||||||||||||
57 | QString QPlatformPrintDevice::location() const | - | ||||||||||||
58 | { | - | ||||||||||||
59 | return m_location; | - | ||||||||||||
60 | } | - | ||||||||||||
61 | - | |||||||||||||
62 | QString QPlatformPrintDevice::makeAndModel() const | - | ||||||||||||
63 | { | - | ||||||||||||
64 | return m_makeAndModel; | - | ||||||||||||
65 | } | - | ||||||||||||
66 | - | |||||||||||||
67 | bool QPlatformPrintDevice::isValid() const | - | ||||||||||||
68 | { | - | ||||||||||||
69 | return false; | - | ||||||||||||
70 | } | - | ||||||||||||
71 | - | |||||||||||||
72 | bool QPlatformPrintDevice::isDefault() const | - | ||||||||||||
73 | { | - | ||||||||||||
74 | return false; | - | ||||||||||||
75 | } | - | ||||||||||||
76 | - | |||||||||||||
77 | bool QPlatformPrintDevice::isRemote() const | - | ||||||||||||
78 | { | - | ||||||||||||
79 | return m_isRemote; | - | ||||||||||||
80 | } | - | ||||||||||||
81 | - | |||||||||||||
82 | bool QPlatformPrintDevice::isValidPageLayout(const QPageLayout &layout, int resolution) const | - | ||||||||||||
83 | { | - | ||||||||||||
84 | - | |||||||||||||
85 | if (!supportedPageSize(layout.pageSize()).isValid()) | - | ||||||||||||
86 | return false; | - | ||||||||||||
87 | - | |||||||||||||
88 | - | |||||||||||||
89 | QMarginsF pointMargins = layout.margins(QPageLayout::Point); | - | ||||||||||||
90 | QMarginsF printMargins = printableMargins(layout.pageSize(), layout.orientation(), resolution); | - | ||||||||||||
91 | return pointMargins.left() >= printMargins.left() | - | ||||||||||||
92 | && pointMargins.right() >= printMargins.right() | - | ||||||||||||
93 | && pointMargins.top() >= printMargins.top() | - | ||||||||||||
94 | && pointMargins.bottom() >= printMargins.bottom(); | - | ||||||||||||
95 | } | - | ||||||||||||
96 | - | |||||||||||||
97 | QPrint::DeviceState QPlatformPrintDevice::state() const | - | ||||||||||||
98 | { | - | ||||||||||||
99 | return QPrint::Error; | - | ||||||||||||
100 | } | - | ||||||||||||
101 | - | |||||||||||||
102 | bool QPlatformPrintDevice::supportsMultipleCopies() const | - | ||||||||||||
103 | { | - | ||||||||||||
104 | return m_supportsMultipleCopies; | - | ||||||||||||
105 | } | - | ||||||||||||
106 | - | |||||||||||||
107 | bool QPlatformPrintDevice::supportsCollateCopies() const | - | ||||||||||||
108 | { | - | ||||||||||||
109 | return m_supportsCollateCopies; | - | ||||||||||||
110 | } | - | ||||||||||||
111 | - | |||||||||||||
112 | void QPlatformPrintDevice::loadPageSizes() const | - | ||||||||||||
113 | { | - | ||||||||||||
114 | } | - | ||||||||||||
115 | - | |||||||||||||
116 | QPageSize QPlatformPrintDevice::defaultPageSize() const | - | ||||||||||||
117 | { | - | ||||||||||||
118 | return QPageSize(); | - | ||||||||||||
119 | } | - | ||||||||||||
120 | - | |||||||||||||
121 | QList<QPageSize> QPlatformPrintDevice::supportedPageSizes() const | - | ||||||||||||
122 | { | - | ||||||||||||
123 | if (!m_havePageSizes) | - | ||||||||||||
124 | loadPageSizes(); | - | ||||||||||||
125 | return m_pageSizes.toList(); | - | ||||||||||||
126 | } | - | ||||||||||||
127 | - | |||||||||||||
128 | QPageSize QPlatformPrintDevice::supportedPageSize(const QPageSize &pageSize) const | - | ||||||||||||
129 | { | - | ||||||||||||
130 | if (!pageSize.isValid()
| 0 | ||||||||||||
131 | return never executed: QPageSize();return QPageSize(); never executed: return QPageSize(); | 0 | ||||||||||||
132 | - | |||||||||||||
133 | if (!m_havePageSizes
| 0 | ||||||||||||
134 | loadPageSizes(); never executed: loadPageSizes(); | 0 | ||||||||||||
135 | - | |||||||||||||
136 | - | |||||||||||||
137 | - | |||||||||||||
138 | - | |||||||||||||
139 | if (pageSize.id() != QPageSize::Custom
| 0 | ||||||||||||
140 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_pageSizes)>::type> _container_((m_pageSizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QPageSize &ps = *_container_.i; _container_.control; _container_.control = 0: m_pageSizes) { | - | ||||||||||||
141 | if (ps.id() == pageSize.id()
| 0 | ||||||||||||
142 | return never executed: ps;return ps; never executed: return ps; | 0 | ||||||||||||
143 | } never executed: end of block | 0 | ||||||||||||
144 | } never executed: end of block | 0 | ||||||||||||
145 | - | |||||||||||||
146 | - | |||||||||||||
147 | if (pageSize.id() != QPageSize::Custom
| 0 | ||||||||||||
148 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_pageSizes)>::type> _container_((m_pageSizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QPageSize &ps = *_container_.i; _container_.control; _container_.control = 0: m_pageSizes) { | - | ||||||||||||
149 | if (ps.id() == pageSize.id()
| 0 | ||||||||||||
150 | return never executed: ps;return ps; never executed: return ps; | 0 | ||||||||||||
151 | } never executed: end of block | 0 | ||||||||||||
152 | } never executed: end of block | 0 | ||||||||||||
153 | - | |||||||||||||
154 | - | |||||||||||||
155 | return never executed: supportedPageSizeMatch(pageSize);return supportedPageSizeMatch(pageSize); never executed: return supportedPageSizeMatch(pageSize); | 0 | ||||||||||||
156 | } | - | ||||||||||||
157 | - | |||||||||||||
158 | QPageSize QPlatformPrintDevice::supportedPageSize(QPageSize::PageSizeId pageSizeId) const | - | ||||||||||||
159 | { | - | ||||||||||||
160 | if (!m_havePageSizes
| 0 | ||||||||||||
161 | loadPageSizes(); never executed: loadPageSizes(); | 0 | ||||||||||||
162 | - | |||||||||||||
163 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_pageSizes)>::type> _container_((m_pageSizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QPageSize &ps = *_container_.i; _container_.control; _container_.control = 0: m_pageSizes) { | - | ||||||||||||
164 | if (ps.id() == pageSizeId
| 0 | ||||||||||||
165 | return never executed: ps;return ps; never executed: return ps; | 0 | ||||||||||||
166 | } never executed: end of block | 0 | ||||||||||||
167 | - | |||||||||||||
168 | - | |||||||||||||
169 | return never executed: supportedPageSizeMatch(QPageSize(pageSizeId));return supportedPageSizeMatch(QPageSize(pageSizeId)); never executed: return supportedPageSizeMatch(QPageSize(pageSizeId)); | 0 | ||||||||||||
170 | } | - | ||||||||||||
171 | - | |||||||||||||
172 | QPageSize QPlatformPrintDevice::supportedPageSize(const QString &pageName) const | - | ||||||||||||
173 | { | - | ||||||||||||
174 | if (!m_havePageSizes
| 0 | ||||||||||||
175 | loadPageSizes(); never executed: loadPageSizes(); | 0 | ||||||||||||
176 | - | |||||||||||||
177 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_pageSizes)>::type> _container_((m_pageSizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QPageSize &ps = *_container_.i; _container_.control; _container_.control = 0: m_pageSizes) { | - | ||||||||||||
178 | if (ps.name() == pageName
| 0 | ||||||||||||
179 | return never executed: ps;return ps; never executed: return ps; | 0 | ||||||||||||
180 | } never executed: end of block | 0 | ||||||||||||
181 | - | |||||||||||||
182 | return never executed: QPageSize();return QPageSize(); never executed: return QPageSize(); | 0 | ||||||||||||
183 | } | - | ||||||||||||
184 | - | |||||||||||||
185 | QPageSize QPlatformPrintDevice::supportedPageSize(const QSize &sizePoints) const | - | ||||||||||||
186 | { | - | ||||||||||||
187 | if (!m_havePageSizes) | - | ||||||||||||
188 | loadPageSizes(); | - | ||||||||||||
189 | - | |||||||||||||
190 | - | |||||||||||||
191 | return supportedPageSizeMatch(QPageSize(sizePoints)); | - | ||||||||||||
192 | } | - | ||||||||||||
193 | - | |||||||||||||
194 | QPageSize QPlatformPrintDevice::supportedPageSize(const QSizeF &size, QPageSize::Unit units) const | - | ||||||||||||
195 | { | - | ||||||||||||
196 | if (!m_havePageSizes) | - | ||||||||||||
197 | loadPageSizes(); | - | ||||||||||||
198 | - | |||||||||||||
199 | - | |||||||||||||
200 | return supportedPageSizeMatch(QPageSize(size, units)); | - | ||||||||||||
201 | } | - | ||||||||||||
202 | - | |||||||||||||
203 | QPageSize QPlatformPrintDevice::supportedPageSizeMatch(const QPageSize &pageSize) const | - | ||||||||||||
204 | { | - | ||||||||||||
205 | - | |||||||||||||
206 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_pageSizes)>::type> _container_((m_pageSizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QPageSize &ps = *_container_.i; _container_.control; _container_.control = 0: m_pageSizes) { | - | ||||||||||||
207 | if (ps.sizePoints() == pageSize.sizePoints()
| 0 | ||||||||||||
208 | return never executed: ps;return ps; never executed: return ps; | 0 | ||||||||||||
209 | } never executed: end of block | 0 | ||||||||||||
210 | return never executed: QPageSize();return QPageSize(); never executed: return QPageSize(); | 0 | ||||||||||||
211 | } | - | ||||||||||||
212 | - | |||||||||||||
213 | bool QPlatformPrintDevice::supportsCustomPageSizes() const | - | ||||||||||||
214 | { | - | ||||||||||||
215 | return m_supportsCustomPageSizes; | - | ||||||||||||
216 | } | - | ||||||||||||
217 | - | |||||||||||||
218 | QSize QPlatformPrintDevice::minimumPhysicalPageSize() const | - | ||||||||||||
219 | { | - | ||||||||||||
220 | return m_minimumPhysicalPageSize; | - | ||||||||||||
221 | } | - | ||||||||||||
222 | - | |||||||||||||
223 | QSize QPlatformPrintDevice::maximumPhysicalPageSize() const | - | ||||||||||||
224 | { | - | ||||||||||||
225 | return m_maximumPhysicalPageSize; | - | ||||||||||||
226 | } | - | ||||||||||||
227 | - | |||||||||||||
228 | QMarginsF QPlatformPrintDevice::printableMargins(const QPageSize &pageSize, | - | ||||||||||||
229 | QPageLayout::Orientation orientation, | - | ||||||||||||
230 | int resolution) const | - | ||||||||||||
231 | { | - | ||||||||||||
232 | (void)pageSize; | - | ||||||||||||
233 | (void)orientation; | - | ||||||||||||
234 | (void)resolution; | - | ||||||||||||
235 | return QMarginsF(0, 0, 0, 0); | - | ||||||||||||
236 | } | - | ||||||||||||
237 | - | |||||||||||||
238 | void QPlatformPrintDevice::loadResolutions() const | - | ||||||||||||
239 | { | - | ||||||||||||
240 | } | - | ||||||||||||
241 | - | |||||||||||||
242 | int QPlatformPrintDevice::defaultResolution() const | - | ||||||||||||
243 | { | - | ||||||||||||
244 | return 0; | - | ||||||||||||
245 | } | - | ||||||||||||
246 | - | |||||||||||||
247 | QList<int> QPlatformPrintDevice::supportedResolutions() const | - | ||||||||||||
248 | { | - | ||||||||||||
249 | if (!m_haveResolutions) | - | ||||||||||||
250 | loadResolutions(); | - | ||||||||||||
251 | return m_resolutions.toList(); | - | ||||||||||||
252 | } | - | ||||||||||||
253 | - | |||||||||||||
254 | void QPlatformPrintDevice::loadInputSlots() const | - | ||||||||||||
255 | { | - | ||||||||||||
256 | } | - | ||||||||||||
257 | - | |||||||||||||
258 | QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const | - | ||||||||||||
259 | { | - | ||||||||||||
260 | QPrint::InputSlot input; | - | ||||||||||||
261 | input.key = ([]() -> QByteArray { enum { Size = sizeof("Auto") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "Auto" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | - | ||||||||||||
262 | input.name = QPrintDialog::tr("Automatic"); | - | ||||||||||||
263 | input.id = QPrint::Auto; | - | ||||||||||||
264 | return input; | - | ||||||||||||
265 | } | - | ||||||||||||
266 | - | |||||||||||||
267 | QList<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const | - | ||||||||||||
268 | { | - | ||||||||||||
269 | if (!m_haveInputSlots) | - | ||||||||||||
270 | loadInputSlots(); | - | ||||||||||||
271 | return m_inputSlots.toList(); | - | ||||||||||||
272 | } | - | ||||||||||||
273 | - | |||||||||||||
274 | void QPlatformPrintDevice::loadOutputBins() const | - | ||||||||||||
275 | { | - | ||||||||||||
276 | } | - | ||||||||||||
277 | - | |||||||||||||
278 | QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const | - | ||||||||||||
279 | { | - | ||||||||||||
280 | QPrint::OutputBin output; | - | ||||||||||||
281 | output.key = ([]() -> QByteArray { enum { Size = sizeof("Auto") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "Auto" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | - | ||||||||||||
282 | output.name = QPrintDialog::tr("Automatic"); | - | ||||||||||||
283 | output.id = QPrint::AutoOutputBin; | - | ||||||||||||
284 | return output; | - | ||||||||||||
285 | } | - | ||||||||||||
286 | - | |||||||||||||
287 | QList<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const | - | ||||||||||||
288 | { | - | ||||||||||||
289 | if (!m_haveOutputBins) | - | ||||||||||||
290 | loadOutputBins(); | - | ||||||||||||
291 | return m_outputBins.toList(); | - | ||||||||||||
292 | } | - | ||||||||||||
293 | - | |||||||||||||
294 | void QPlatformPrintDevice::loadDuplexModes() const | - | ||||||||||||
295 | { | - | ||||||||||||
296 | } | - | ||||||||||||
297 | - | |||||||||||||
298 | QPrint::DuplexMode QPlatformPrintDevice::defaultDuplexMode() const | - | ||||||||||||
299 | { | - | ||||||||||||
300 | return QPrint::DuplexNone; | - | ||||||||||||
301 | } | - | ||||||||||||
302 | - | |||||||||||||
303 | QList<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const | - | ||||||||||||
304 | { | - | ||||||||||||
305 | if (!m_haveDuplexModes) | - | ||||||||||||
306 | loadDuplexModes(); | - | ||||||||||||
307 | return m_duplexModes.toList(); | - | ||||||||||||
308 | } | - | ||||||||||||
309 | - | |||||||||||||
310 | void QPlatformPrintDevice::loadColorModes() const | - | ||||||||||||
311 | { | - | ||||||||||||
312 | } | - | ||||||||||||
313 | - | |||||||||||||
314 | QPrint::ColorMode QPlatformPrintDevice::defaultColorMode() const | - | ||||||||||||
315 | { | - | ||||||||||||
316 | return QPrint::GrayScale; | - | ||||||||||||
317 | } | - | ||||||||||||
318 | - | |||||||||||||
319 | QList<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const | - | ||||||||||||
320 | { | - | ||||||||||||
321 | if (!m_haveColorModes) | - | ||||||||||||
322 | loadColorModes(); | - | ||||||||||||
323 | return m_colorModes.toList(); | - | ||||||||||||
324 | } | - | ||||||||||||
325 | - | |||||||||||||
326 | - | |||||||||||||
327 | void QPlatformPrintDevice::loadMimeTypes() const | - | ||||||||||||
328 | { | - | ||||||||||||
329 | } | - | ||||||||||||
330 | - | |||||||||||||
331 | QList<QMimeType> QPlatformPrintDevice::supportedMimeTypes() const | - | ||||||||||||
332 | { | - | ||||||||||||
333 | if (!m_haveMimeTypes) | - | ||||||||||||
334 | loadMimeTypes(); | - | ||||||||||||
335 | return m_mimeTypes.toList(); | - | ||||||||||||
336 | } | - | ||||||||||||
337 | - | |||||||||||||
338 | - | |||||||||||||
339 | QPageSize QPlatformPrintDevice::createPageSize(const QString &key, const QSize &size, const QString &localizedName) | - | ||||||||||||
340 | { | - | ||||||||||||
341 | return QPageSize(key, size, localizedName); | - | ||||||||||||
342 | } | - | ||||||||||||
343 | - | |||||||||||||
344 | QPageSize QPlatformPrintDevice::createPageSize(int windowsId, const QSize &size, const QString &localizedName) | - | ||||||||||||
345 | { | - | ||||||||||||
346 | return QPageSize(windowsId, size, localizedName); | - | ||||||||||||
347 | } | - | ||||||||||||
348 | - | |||||||||||||
349 | - | |||||||||||||
350 | - | |||||||||||||
351 | - | |||||||||||||
Switch to Source code | Preprocessed file |