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