/src/qtbase/src/gui/painting/qpagedpaintdevice.cpp
Line | Count | Source |
1 | | // Copyright (C) 2020 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 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #include "qpagedpaintdevice_p.h" |
6 | | #include <qpagedpaintdevice.h> |
7 | | |
8 | | QT_BEGIN_NAMESPACE |
9 | | |
10 | | |
11 | 0 | QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate() = default; |
12 | | |
13 | | /*! |
14 | | \class QPagedPaintDevice |
15 | | \inmodule QtGui |
16 | | |
17 | | \brief The QPagedPaintDevice class represents a paint device that supports |
18 | | multiple pages. |
19 | | |
20 | | \ingroup painting |
21 | | |
22 | | Paged paint devices are used to generate output for printing or for formats like PDF. |
23 | | QPdfWriter and QPrinter inherit from it. |
24 | | */ |
25 | | |
26 | | |
27 | | /*! |
28 | | \internal |
29 | | Constructs a new paged paint device with the derived private class. |
30 | | */ |
31 | | QPagedPaintDevice::QPagedPaintDevice(QPagedPaintDevicePrivate *dd) |
32 | 0 | : d(dd) |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | /*! |
37 | | Destroys the object. |
38 | | */ |
39 | | QPagedPaintDevice::~QPagedPaintDevice() |
40 | 0 | { |
41 | 0 | delete d; |
42 | 0 | } |
43 | | |
44 | | /*! |
45 | | \internal |
46 | | Returns the QPagedPaintDevicePrivate. |
47 | | */ |
48 | | QPagedPaintDevicePrivate *QPagedPaintDevice::dd() |
49 | 0 | { |
50 | 0 | return d; |
51 | 0 | } |
52 | | |
53 | | /*! |
54 | | \fn bool QPagedPaintDevice::newPage() |
55 | | |
56 | | Starts a new page. Returns \c true on success. |
57 | | */ |
58 | | |
59 | | /*! |
60 | | \enum QPagedPaintDevice::PdfVersion |
61 | | |
62 | | The PdfVersion enum describes the version of the PDF file that |
63 | | is produced by QPrinter or QPdfWriter. |
64 | | |
65 | | \value PdfVersion_1_4 A PDF 1.4 compatible document is produced. |
66 | | |
67 | | \value PdfVersion_A1b A PDF/A-1b compatible document is produced. |
68 | | |
69 | | \value PdfVersion_1_6 A PDF 1.6 compatible document is produced. |
70 | | This value was added in Qt 5.12. |
71 | | |
72 | | \value [since 6.8] PdfVersion_X4 A PDF/X-4 compatible document is |
73 | | produced. |
74 | | */ |
75 | | |
76 | | /*! |
77 | | \since 5.3 |
78 | | |
79 | | Sets the page layout to \a newPageLayout. |
80 | | |
81 | | You should call this before calling QPainter::begin(), or immediately |
82 | | before calling newPage() to apply the new page layout to a new page. |
83 | | You should not call any painting methods between a call to setPageLayout() |
84 | | and newPage() as the wrong paint metrics may be used. |
85 | | |
86 | | Returns true if the page layout was successfully set to \a newPageLayout. |
87 | | |
88 | | \sa pageLayout() |
89 | | */ |
90 | | |
91 | | bool QPagedPaintDevice::setPageLayout(const QPageLayout &newPageLayout) |
92 | 0 | { |
93 | 0 | return d->setPageLayout(newPageLayout); |
94 | 0 | } |
95 | | |
96 | | /*! |
97 | | \since 5.3 |
98 | | |
99 | | Sets the page size to \a pageSize. |
100 | | |
101 | | To get the current QPageSize use pageLayout().pageSize(). |
102 | | |
103 | | You should call this before calling QPainter::begin(), or immediately |
104 | | before calling newPage() to apply the new page size to a new page. |
105 | | You should not call any painting methods between a call to setPageSize() |
106 | | and newPage() as the wrong paint metrics may be used. |
107 | | |
108 | | Returns true if the page size was successfully set to \a pageSize. |
109 | | |
110 | | \sa pageLayout() |
111 | | */ |
112 | | |
113 | | bool QPagedPaintDevice::setPageSize(const QPageSize &pageSize) |
114 | 0 | { |
115 | 0 | return d->setPageSize(pageSize); |
116 | 0 | } |
117 | | |
118 | | /*! |
119 | | \since 5.3 |
120 | | |
121 | | Sets the page \a orientation. |
122 | | |
123 | | The page orientation is used to define the orientation of the |
124 | | page size when obtaining the page rect. |
125 | | |
126 | | You should call this before calling QPainter::begin(), or immediately |
127 | | before calling newPage() to apply the new orientation to a new page. |
128 | | You should not call any painting methods between a call to setPageOrientation() |
129 | | and newPage() as the wrong paint metrics may be used. |
130 | | |
131 | | To get the current QPageLayout::Orientation use pageLayout().orientation(). |
132 | | |
133 | | Returns true if the page orientation was successfully set to \a orientation. |
134 | | |
135 | | \sa pageLayout() |
136 | | */ |
137 | | |
138 | | bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation) |
139 | 0 | { |
140 | 0 | return d->setPageOrientation(orientation); |
141 | 0 | } |
142 | | |
143 | | /*! |
144 | | \since 5.3 |
145 | | |
146 | | Set the page \a margins defined in the given \a units. |
147 | | |
148 | | You should call this before calling QPainter::begin(), or immediately |
149 | | before calling newPage() to apply the new margins to a new page. |
150 | | You should not call any painting methods between a call to setPageMargins() |
151 | | and newPage() as the wrong paint metrics may be used. |
152 | | |
153 | | To get the current page margins use pageLayout().margins(). |
154 | | |
155 | | Returns true if the page margins were successfully set to \a margins. |
156 | | |
157 | | \sa pageLayout() |
158 | | */ |
159 | | |
160 | | bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) |
161 | 0 | { |
162 | 0 | return d->setPageMargins(margins, units); |
163 | 0 | } |
164 | | |
165 | | /*! |
166 | | \since 5.3 |
167 | | |
168 | | Returns the current page layout. Use this method to access the current |
169 | | QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect(). |
170 | | |
171 | | Note that you cannot use the setters on the returned object, you must either |
172 | | call the individual QPagedPaintDevice setters or use setPageLayout(). |
173 | | |
174 | | \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins() |
175 | | */ |
176 | | |
177 | | QPageLayout QPagedPaintDevice::pageLayout() const |
178 | 0 | { |
179 | 0 | return d->pageLayout(); |
180 | 0 | } |
181 | | |
182 | | /*! |
183 | | \since 6.0 |
184 | | |
185 | | Returns the page ranges associated with this device. |
186 | | |
187 | | \sa QPageRanges, QPrinter::fromPage(), QPrinter::toPage() |
188 | | */ |
189 | | QPageRanges QPagedPaintDevice::pageRanges() const |
190 | 0 | { |
191 | 0 | return d->pageRanges; |
192 | 0 | } |
193 | | |
194 | | /*! |
195 | | \since 6.0 |
196 | | |
197 | | Sets the page ranges for this device to \a ranges. |
198 | | */ |
199 | | void QPagedPaintDevice::setPageRanges(const QPageRanges &ranges) |
200 | 0 | { |
201 | 0 | d->pageRanges = ranges; |
202 | 0 | } |
203 | | |
204 | | QT_END_NAMESPACE |