OpenCoverage

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

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