qplatformprintdevice.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qplatformprintdevice.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2014 John Layt <jlayt@kde.org>-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtPrintSupport module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qplatformprintdevice.h"-
35-
36#include "qprintdevice_p.h"-
37#include "qprintdialog.h"-
38-
39#include <QtGui/qpagelayout.h>-
40-
41QT_BEGIN_NAMESPACE-
42-
43#ifndef QT_NO_PRINTER-
44-
45QPlatformPrintDevice::QPlatformPrintDevice()-
46 : m_isRemote(false),-
47 m_supportsMultipleCopies(false),-
48 m_supportsCollateCopies(false),-
49 m_havePageSizes(false),-
50 m_supportsCustomPageSizes(false),-
51 m_haveResolutions(false),-
52 m_haveInputSlots(false),-
53 m_haveOutputBins(false),-
54 m_haveDuplexModes(false),-
55 m_haveColorModes(false)-
56#ifndef QT_NO_MIMETYPES-
57 , m_haveMimeTypes(false)-
58#endif-
59{-
60}
executed 144 times by 3 tests: end of block
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
  • tst_QPrinterInfo
144
61-
62QPlatformPrintDevice::QPlatformPrintDevice(const QString &id)-
63 : m_id(id),-
64 m_isRemote(false),-
65 m_supportsMultipleCopies(false),-
66 m_supportsCollateCopies(false),-
67 m_havePageSizes(false),-
68 m_supportsCustomPageSizes(false),-
69 m_haveResolutions(false),-
70 m_haveInputSlots(false),-
71 m_haveOutputBins(false),-
72 m_haveDuplexModes(false),-
73 m_haveColorModes(false)-
74#ifndef QT_NO_MIMETYPES-
75 , m_haveMimeTypes(false)-
76#endif-
77{-
78}
executed 5 times by 1 test: end of block
Executed by:
  • tst_QPrinter
5
79-
80QPlatformPrintDevice::~QPlatformPrintDevice()-
81{-
82}-
83-
84QString QPlatformPrintDevice::id() const-
85{-
86 return m_id;
never executed: return m_id;
0
87}-
88-
89QString QPlatformPrintDevice::name() const-
90{-
91 return m_name;
never executed: return m_name;
0
92}-
93-
94QString QPlatformPrintDevice::location() const-
95{-
96 return m_location;
never executed: return m_location;
0
97}-
98-
99QString QPlatformPrintDevice::makeAndModel() const-
100{-
101 return m_makeAndModel;
never executed: return m_makeAndModel;
0
102}-
103-
104bool QPlatformPrintDevice::isValid() const-
105{-
106 return false;
executed 272 times by 3 tests: return false;
Executed by:
  • tst_QAbstractPrintDialog
  • tst_QPrinter
  • tst_QPrinterInfo
272
107}-
108-
109bool QPlatformPrintDevice::isDefault() const-
110{-
111 return false;
never executed: return false;
0
112}-
113-
114bool QPlatformPrintDevice::isRemote() const-
115{-
116 return m_isRemote;
never executed: return m_isRemote;
0
117}-
118-
119bool QPlatformPrintDevice::isValidPageLayout(const QPageLayout &layout, int resolution) const-
120{-
121 // Check the page size is supported-
122 if (!supportedPageSize(layout.pageSize()).isValid())
!supportedPage...e()).isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
123 return false;
never executed: return false;
0
124-
125 // Check the margins are valid-
126 QMarginsF pointMargins = layout.margins(QPageLayout::Point);-
127 QMarginsF printMargins = printableMargins(layout.pageSize(), layout.orientation(), resolution);-
128 return pointMargins.left() >= printMargins.left()
never executed: return pointMargins.left() >= printMargins.left() && pointMargins.right() >= printMargins.right() && pointMargins.top() >= printMargins.top() && pointMargins.bottom() >= printMargins.bottom();
pointMargins.l...Margins.left()Description
TRUEnever evaluated
FALSEnever evaluated
0
129 && pointMargins.right() >= printMargins.right()
never executed: return pointMargins.left() >= printMargins.left() && pointMargins.right() >= printMargins.right() && pointMargins.top() >= printMargins.top() && pointMargins.bottom() >= printMargins.bottom();
pointMargins.r...argins.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
130 && pointMargins.top() >= printMargins.top()
never executed: return pointMargins.left() >= printMargins.left() && pointMargins.right() >= printMargins.right() && pointMargins.top() >= printMargins.top() && pointMargins.bottom() >= printMargins.bottom();
pointMargins.t...tMargins.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
131 && pointMargins.bottom() >= printMargins.bottom();
never executed: return pointMargins.left() >= printMargins.left() && pointMargins.right() >= printMargins.right() && pointMargins.top() >= printMargins.top() && pointMargins.bottom() >= printMargins.bottom();
pointMargins.b...rgins.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
132}-
133-
134QPrint::DeviceState QPlatformPrintDevice::state() const-
135{-
136 return QPrint::Error;
never executed: return QPrint::Error;
0
137}-
138-
139bool QPlatformPrintDevice::supportsMultipleCopies() const-
140{-
141 return m_supportsMultipleCopies;
never executed: return m_supportsMultipleCopies;
0
142}-
143-
144bool QPlatformPrintDevice::supportsCollateCopies() const-
145{-
146 return m_supportsCollateCopies;
never executed: return m_supportsCollateCopies;
0
147}-
148-
149void QPlatformPrintDevice::loadPageSizes() const-
150{-
151}-
152-
153QPageSize QPlatformPrintDevice::defaultPageSize() const-
154{-
155 return QPageSize();
never executed: return QPageSize();
0
156}-
157-
158QList<QPageSize> QPlatformPrintDevice::supportedPageSizes() const-
159{-
160 if (!m_havePageSizes)
!m_havePageSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
161 loadPageSizes();
never executed: loadPageSizes();
0
162 return m_pageSizes.toList();
never executed: return m_pageSizes.toList();
0
163}-
164-
165QPageSize QPlatformPrintDevice::supportedPageSize(const QPageSize &pageSize) const-
166{-
167 if (!pageSize.isValid())
!pageSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
168 return QPageSize();
never executed: return QPageSize();
0
169-
170 if (!m_havePageSizes)
!m_havePageSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
171 loadPageSizes();
never executed: loadPageSizes();
0
172-
173 // First try match on name and id for case where printer defines same size twice with different names-
174 // e.g. Windows defines DMPAPER_11X17 and DMPAPER_TABLOID with names "11x17" and "Tabloid", but both-
175 // map to QPageSize::Tabloid / PPD Key "Tabloid" / ANSI B Tabloid-
176 if (pageSize.id() != QPageSize::Custom) {
pageSize.id() ...geSize::CustomDescription
TRUEnever evaluated
FALSEnever evaluated
0
177 foreach (const QPageSize &ps, m_pageSizes) {-
178 if (ps.id() == pageSize.id() && ps.name() == pageSize.name())
ps.id() == pageSize.id()Description
TRUEnever evaluated
FALSEnever evaluated
ps.name() == pageSize.name()Description
TRUEnever evaluated
FALSEnever evaluated
0
179 return ps;
never executed: return ps;
0
180 }
never executed: end of block
0
181 }
never executed: end of block
0
182-
183 // Next try match on id only if not custom-
184 if (pageSize.id() != QPageSize::Custom) {
pageSize.id() ...geSize::CustomDescription
TRUEnever evaluated
FALSEnever evaluated
0
185 foreach (const QPageSize &ps, m_pageSizes) {-
186 if (ps.id() == pageSize.id())
ps.id() == pageSize.id()Description
TRUEnever evaluated
FALSEnever evaluated
0
187 return ps;
never executed: return ps;
0
188 }
never executed: end of block
0
189 }
never executed: end of block
0
190-
191 // Next try a match on size, in case it's a custom with a different name-
192 return supportedPageSizeMatch(pageSize);
never executed: return supportedPageSizeMatch(pageSize);
0
193}-
194-
195QPageSize QPlatformPrintDevice::supportedPageSize(QPageSize::PageSizeId pageSizeId) const-
196{-
197 if (!m_havePageSizes)
!m_havePageSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
198 loadPageSizes();
never executed: loadPageSizes();
0
199-
200 foreach (const QPageSize &ps, m_pageSizes) {-
201 if (ps.id() == pageSizeId)
ps.id() == pageSizeIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
202 return ps;
never executed: return ps;
0
203 }
never executed: end of block
0
204-
205 // If no supported page size found, try use a custom size instead if supported-
206 return supportedPageSizeMatch(QPageSize(pageSizeId));
never executed: return supportedPageSizeMatch(QPageSize(pageSizeId));
0
207}-
208-
209QPageSize QPlatformPrintDevice::supportedPageSize(const QString &pageName) const-
210{-
211 if (!m_havePageSizes)
!m_havePageSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
212 loadPageSizes();
never executed: loadPageSizes();
0
213-
214 foreach (const QPageSize &ps, m_pageSizes) {-
215 if (ps.name() == pageName)
ps.name() == pageNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
216 return ps;
never executed: return ps;
0
217 }
never executed: end of block
0
218-
219 return QPageSize();
never executed: return QPageSize();
0
220}-
221-
222QPageSize QPlatformPrintDevice::supportedPageSize(const QSize &sizePoints) const-
223{-
224 if (!m_havePageSizes)
!m_havePageSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
225 loadPageSizes();
never executed: loadPageSizes();
0
226-
227 // Try to find a supported page size based on fuzzy-matched point size-
228 return supportedPageSizeMatch(QPageSize(sizePoints));
never executed: return supportedPageSizeMatch(QPageSize(sizePoints));
0
229}-
230-
231QPageSize QPlatformPrintDevice::supportedPageSize(const QSizeF &size, QPageSize::Unit units) const-
232{-
233 if (!m_havePageSizes)
!m_havePageSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
234 loadPageSizes();
never executed: loadPageSizes();
0
235-
236 // Try to find a supported page size based on fuzzy-matched unit size-
237 return supportedPageSizeMatch(QPageSize(size, units));
never executed: return supportedPageSizeMatch(QPageSize(size, units));
0
238}-
239-
240QPageSize QPlatformPrintDevice::supportedPageSizeMatch(const QPageSize &pageSize) const-
241{-
242 // Try to find a supported page size based on point size-
243 foreach (const QPageSize &ps, m_pageSizes) {-
244 if (ps.sizePoints() == pageSize.sizePoints())
ps.sizePoints(...e.sizePoints()Description
TRUEnever evaluated
FALSEnever evaluated
0
245 return ps;
never executed: return ps;
0
246 }
never executed: end of block
0
247 return QPageSize();
never executed: return QPageSize();
0
248}-
249-
250bool QPlatformPrintDevice::supportsCustomPageSizes() const-
251{-
252 return m_supportsCustomPageSizes;
never executed: return m_supportsCustomPageSizes;
0
253}-
254-
255QSize QPlatformPrintDevice::minimumPhysicalPageSize() const-
256{-
257 return m_minimumPhysicalPageSize;
never executed: return m_minimumPhysicalPageSize;
0
258}-
259-
260QSize QPlatformPrintDevice::maximumPhysicalPageSize() const-
261{-
262 return m_maximumPhysicalPageSize;
never executed: return m_maximumPhysicalPageSize;
0
263}-
264-
265QMarginsF QPlatformPrintDevice::printableMargins(const QPageSize &pageSize,-
266 QPageLayout::Orientation orientation,-
267 int resolution) const-
268{-
269 Q_UNUSED(pageSize)-
270 Q_UNUSED(orientation)-
271 Q_UNUSED(resolution)-
272 return QMarginsF(0, 0, 0, 0);
never executed: return QMarginsF(0, 0, 0, 0);
0
273}-
274-
275void QPlatformPrintDevice::loadResolutions() const-
276{-
277}-
278-
279int QPlatformPrintDevice::defaultResolution() const-
280{-
281 return 0;
never executed: return 0;
0
282}-
283-
284QList<int> QPlatformPrintDevice::supportedResolutions() const-
285{-
286 if (!m_haveResolutions)
!m_haveResolutionsDescription
TRUEnever evaluated
FALSEnever evaluated
0
287 loadResolutions();
never executed: loadResolutions();
0
288 return m_resolutions.toList();
never executed: return m_resolutions.toList();
0
289}-
290-
291void QPlatformPrintDevice::loadInputSlots() const-
292{-
293}-
294-
295QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const-
296{-
297 QPrint::InputSlot input;-
298 input.key = QByteArrayLiteral("Auto");
never executed: return ba;
0
299 input.name = QPrintDialog::tr("Automatic");-
300 input.id = QPrint::Auto;-
301 return input;
never executed: return input;
0
302}-
303-
304QList<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const-
305{-
306 if (!m_haveInputSlots)
!m_haveInputSlotsDescription
TRUEnever evaluated
FALSEnever evaluated
0
307 loadInputSlots();
never executed: loadInputSlots();
0
308 return m_inputSlots.toList();
never executed: return m_inputSlots.toList();
0
309}-
310-
311void QPlatformPrintDevice::loadOutputBins() const-
312{-
313}-
314-
315QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const-
316{-
317 QPrint::OutputBin output;-
318 output.key = QByteArrayLiteral("Auto");
never executed: return ba;
0
319 output.name = QPrintDialog::tr("Automatic");-
320 output.id = QPrint::AutoOutputBin;-
321 return output;
never executed: return output;
0
322}-
323-
324QList<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const-
325{-
326 if (!m_haveOutputBins)
!m_haveOutputBinsDescription
TRUEnever evaluated
FALSEnever evaluated
0
327 loadOutputBins();
never executed: loadOutputBins();
0
328 return m_outputBins.toList();
never executed: return m_outputBins.toList();
0
329}-
330-
331void QPlatformPrintDevice::loadDuplexModes() const-
332{-
333}-
334-
335QPrint::DuplexMode QPlatformPrintDevice::defaultDuplexMode() const-
336{-
337 return QPrint::DuplexNone;
never executed: return QPrint::DuplexNone;
0
338}-
339-
340QList<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const-
341{-
342 if (!m_haveDuplexModes)
!m_haveDuplexModesDescription
TRUEnever evaluated
FALSEnever evaluated
0
343 loadDuplexModes();
never executed: loadDuplexModes();
0
344 return m_duplexModes.toList();
never executed: return m_duplexModes.toList();
0
345}-
346-
347void QPlatformPrintDevice::loadColorModes() const-
348{-
349}-
350-
351QPrint::ColorMode QPlatformPrintDevice::defaultColorMode() const-
352{-
353 return QPrint::GrayScale;
never executed: return QPrint::GrayScale;
0
354}-
355-
356QList<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const-
357{-
358 if (!m_haveColorModes)
!m_haveColorModesDescription
TRUEnever evaluated
FALSEnever evaluated
0
359 loadColorModes();
never executed: loadColorModes();
0
360 return m_colorModes.toList();
never executed: return m_colorModes.toList();
0
361}-
362-
363#ifndef QT_NO_MIMETYPE-
364void QPlatformPrintDevice::loadMimeTypes() const-
365{-
366}-
367-
368QList<QMimeType> QPlatformPrintDevice::supportedMimeTypes() const-
369{-
370 if (!m_haveMimeTypes)
!m_haveMimeTypesDescription
TRUEnever evaluated
FALSEnever evaluated
0
371 loadMimeTypes();
never executed: loadMimeTypes();
0
372 return m_mimeTypes.toList();
never executed: return m_mimeTypes.toList();
0
373}-
374#endif // QT_NO_MIMETYPE-
375-
376QPageSize QPlatformPrintDevice::createPageSize(const QString &key, const QSize &size, const QString &localizedName)-
377{-
378 return QPageSize(key, size, localizedName);
never executed: return QPageSize(key, size, localizedName);
0
379}-
380-
381QPageSize QPlatformPrintDevice::createPageSize(int windowsId, const QSize &size, const QString &localizedName)-
382{-
383 return QPageSize(windowsId, size, localizedName);
never executed: return QPageSize(windowsId, size, localizedName);
0
384}-
385-
386#endif // QT_NO_PRINTER-
387-
388QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9