| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QPRINTER_P_H |
| 5 | #define QPRINTER_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | |
| 19 | #include <QtPrintSupport/private/qtprintsupportglobal_p.h> |
| 20 | |
| 21 | #ifndef QT_NO_PRINTER |
| 22 | |
| 23 | #include "QtPrintSupport/qprinter.h" |
| 24 | #include "QtPrintSupport/qprinterinfo.h" |
| 25 | #include "QtPrintSupport/qprintengine.h" |
| 26 | #include "QtCore/qpointer.h" |
| 27 | #include "QtCore/qset.h" |
| 28 | |
| 29 | #include <limits.h> |
| 30 | |
| 31 | QT_BEGIN_NAMESPACE |
| 32 | |
| 33 | class QPrintEngine; |
| 34 | class QPreviewPaintEngine; |
| 35 | class QPicture; |
| 36 | |
| 37 | class Q_PRINTSUPPORT_EXPORT QPrinterPrivate |
| 38 | { |
| 39 | Q_DECLARE_PUBLIC(QPrinter) |
| 40 | public: |
| 41 | QPrinterPrivate(QPrinter *printer) |
| 42 | : pdfVersion(QPrinter::PdfVersion_1_4), |
| 43 | printEngine(nullptr), |
| 44 | paintEngine(nullptr), |
| 45 | realPrintEngine(nullptr), |
| 46 | realPaintEngine(nullptr), |
| 47 | #if QT_CONFIG(printpreviewwidget) |
| 48 | previewEngine(nullptr), |
| 49 | #endif |
| 50 | q_ptr(printer), |
| 51 | printRange(QPrinter::AllPages), |
| 52 | use_default_engine(true), |
| 53 | validPrinter(false) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | ~QPrinterPrivate() { |
| 58 | |
| 59 | } |
| 60 | |
| 61 | static QPrinterPrivate *get(QPrinter *printer) { |
| 62 | return printer->d_ptr.get(); |
| 63 | } |
| 64 | |
| 65 | void init(const QPrinterInfo &printer, QPrinter::PrinterMode mode); |
| 66 | |
| 67 | QPrinterInfo findValidPrinter(const QPrinterInfo &printer = QPrinterInfo()); |
| 68 | void initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer); |
| 69 | void changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer); |
| 70 | #if QT_CONFIG(printpreviewwidget) |
| 71 | QList<const QPicture *> previewPages() const; |
| 72 | void setPreviewMode(bool); |
| 73 | bool previewMode() const; |
| 74 | #endif |
| 75 | |
| 76 | void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value); |
| 77 | |
| 78 | QPrinter::PrinterMode printerMode; |
| 79 | QPrinter::OutputFormat outputFormat; |
| 80 | QPrinter::PdfVersion pdfVersion; |
| 81 | QPrintEngine *printEngine; |
| 82 | QPaintEngine *paintEngine; |
| 83 | |
| 84 | QPrintEngine *realPrintEngine; |
| 85 | QPaintEngine *realPaintEngine; |
| 86 | #if QT_CONFIG(printpreviewwidget) |
| 87 | QPreviewPaintEngine *previewEngine; |
| 88 | #endif |
| 89 | |
| 90 | QPrinter *q_ptr; |
| 91 | |
| 92 | QPrinter::PrintRange printRange; |
| 93 | |
| 94 | uint use_default_engine : 1; |
| 95 | uint had_default_engines : 1; |
| 96 | |
| 97 | uint validPrinter : 1; |
| 98 | uint hasCustomPageMargins : 1; |
| 99 | |
| 100 | // Used to remember which properties have been manually set by the user. |
| 101 | QSet<QPrintEngine::PrintEnginePropertyKey> m_properties; |
| 102 | }; |
| 103 | |
| 104 | QT_END_NAMESPACE |
| 105 | |
| 106 | #endif // QT_NO_PRINTER |
| 107 | |
| 108 | #endif // QPRINTER_P_H |
| 109 | |