| 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 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 "qpagesize.h" |
| 41 | |
| 42 | #include <QtCore/qcoreapplication.h> |
| 43 | #include <QtCore/qdebug.h> |
| 44 | #include <QtCore/qpoint.h> |
| 45 | #include <QtCore/qrect.h> |
| 46 | #include <QtCore/qsize.h> |
| 47 | #include <QtCore/qstring.h> |
| 48 | |
| 49 | QT_BEGIN_NAMESPACE |
| 50 | |
| 51 | // Define the Windows DMPAPER sizes for use in the look-up table |
| 52 | // See http://msdn.microsoft.com/en-us/library/windows/desktop/dd319099.aspx |
| 53 | |
| 54 | enum WindowsDmPaper { |
| 55 | DMPAPER_NONE = 0, // Not a DMPAPER, use for sizes without a DMPAPER value |
| 56 | DMPAPER_LETTER = 1, |
| 57 | DMPAPER_LETTERSMALL = 2, |
| 58 | DMPAPER_TABLOID = 3, |
| 59 | DMPAPER_LEDGER = 4, |
| 60 | DMPAPER_LEGAL = 5, |
| 61 | DMPAPER_STATEMENT = 6, |
| 62 | DMPAPER_EXECUTIVE = 7, |
| 63 | DMPAPER_A3 = 8, |
| 64 | DMPAPER_A4 = 9, |
| 65 | DMPAPER_A4SMALL = 10, |
| 66 | DMPAPER_A5 = 11, |
| 67 | DMPAPER_B4 = 12, |
| 68 | DMPAPER_B5 = 13, |
| 69 | DMPAPER_FOLIO = 14, |
| 70 | DMPAPER_QUARTO = 15, |
| 71 | DMPAPER_10X14 = 16, |
| 72 | DMPAPER_11X17 = 17, |
| 73 | DMPAPER_NOTE = 18, |
| 74 | DMPAPER_ENV_9 = 19, |
| 75 | DMPAPER_ENV_10 = 20, |
| 76 | DMPAPER_ENV_11 = 21, |
| 77 | DMPAPER_ENV_12 = 22, |
| 78 | DMPAPER_ENV_14 = 23, |
| 79 | DMPAPER_CSHEET = 24, |
| 80 | DMPAPER_DSHEET = 25, |
| 81 | DMPAPER_ESHEET = 26, |
| 82 | DMPAPER_ENV_DL = 27, |
| 83 | DMPAPER_ENV_C5 = 28, |
| 84 | DMPAPER_ENV_C3 = 29, |
| 85 | DMPAPER_ENV_C4 = 30, |
| 86 | DMPAPER_ENV_C6 = 31, |
| 87 | DMPAPER_ENV_C65 = 32, |
| 88 | DMPAPER_ENV_B4 = 33, |
| 89 | DMPAPER_ENV_B5 = 34, |
| 90 | DMPAPER_ENV_B6 = 35, |
| 91 | DMPAPER_ENV_ITALY = 36, |
| 92 | DMPAPER_ENV_MONARCH = 37, |
| 93 | DMPAPER_ENV_PERSONAL = 38, |
| 94 | DMPAPER_FANFOLD_US = 39, |
| 95 | DMPAPER_FANFOLD_STD_GERMAN = 40, |
| 96 | DMPAPER_FANFOLD_LGL_GERMAN = 41, |
| 97 | DMPAPER_ISO_B4 = 42, |
| 98 | DMPAPER_JAPANESE_POSTCARD = 43, |
| 99 | DMPAPER_9X11 = 44, |
| 100 | DMPAPER_10X11 = 45, |
| 101 | DMPAPER_15X11 = 46, |
| 102 | DMPAPER_ENV_INVITE = 47, |
| 103 | DMPAPER_RESERVED_48 = 48, |
| 104 | DMPAPER_RESERVED_49 = 49, |
| 105 | = 50, |
| 106 | = 51, |
| 107 | = 52, |
| 108 | = 53, |
| 109 | DMPAPER_LETTER_TRANSVERSE = 54, |
| 110 | DMPAPER_A4_TRANSVERSE = 55, |
| 111 | = 56, |
| 112 | DMPAPER_A_PLUS = 57, |
| 113 | DMPAPER_B_PLUS = 58, |
| 114 | DMPAPER_LETTER_PLUS = 59, |
| 115 | DMPAPER_A4_PLUS = 60, |
| 116 | DMPAPER_A5_TRANSVERSE = 61, |
| 117 | DMPAPER_B5_TRANSVERSE = 62, |
| 118 | = 63, |
| 119 | = 64, |
| 120 | = 65, |
| 121 | DMPAPER_A2 = 66, |
| 122 | DMPAPER_A3_TRANSVERSE = 67, |
| 123 | = 68, |
| 124 | DMPAPER_DBL_JAPANESE_POSTCARD = 69, |
| 125 | DMPAPER_A6 = 70, |
| 126 | DMPAPER_JENV_KAKU2 = 71, |
| 127 | DMPAPER_JENV_KAKU3 = 72, |
| 128 | DMPAPER_JENV_CHOU3 = 73, |
| 129 | DMPAPER_JENV_CHOU4 = 74, |
| 130 | DMPAPER_LETTER_ROTATED = 75, |
| 131 | DMPAPER_A3_ROTATED = 76, |
| 132 | DMPAPER_A4_ROTATED = 77, |
| 133 | DMPAPER_A5_ROTATED = 78, |
| 134 | DMPAPER_B4_JIS_ROTATED = 79, |
| 135 | DMPAPER_B5_JIS_ROTATED = 80, |
| 136 | DMPAPER_JAPANESE_POSTCARD_ROTATED = 81, |
| 137 | DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = 82, |
| 138 | DMPAPER_A6_ROTATED = 83, |
| 139 | DMPAPER_JENV_KAKU2_ROTATED = 84, |
| 140 | DMPAPER_JENV_KAKU3_ROTATED = 85, |
| 141 | DMPAPER_JENV_CHOU3_ROTATED = 86, |
| 142 | DMPAPER_JENV_CHOU4_ROTATED = 87, |
| 143 | DMPAPER_B6_JIS = 88, |
| 144 | DMPAPER_B6_JIS_ROTATED = 89, |
| 145 | DMPAPER_12X11 = 90, |
| 146 | DMPAPER_JENV_YOU4 = 91, |
| 147 | DMPAPER_JENV_YOU4_ROTATED = 92, |
| 148 | DMPAPER_P16K = 93, |
| 149 | DMPAPER_P32K = 94, |
| 150 | DMPAPER_P32KBIG = 95, |
| 151 | DMPAPER_PENV_1 = 96, |
| 152 | DMPAPER_PENV_2 = 97, |
| 153 | DMPAPER_PENV_3 = 98, |
| 154 | DMPAPER_PENV_4 = 99, |
| 155 | DMPAPER_PENV_5 = 100, |
| 156 | DMPAPER_PENV_6 = 101, |
| 157 | DMPAPER_PENV_7 = 102, |
| 158 | DMPAPER_PENV_8 = 103, |
| 159 | DMPAPER_PENV_9 = 104, |
| 160 | DMPAPER_PENV_10 = 105, |
| 161 | DMPAPER_P16K_ROTATED = 106, |
| 162 | DMPAPER_P32K_ROTATED = 107, |
| 163 | DMPAPER_P32KBIG_ROTATED = 108, |
| 164 | DMPAPER_PENV_1_ROTATED = 109, |
| 165 | DMPAPER_PENV_2_ROTATED = 110, |
| 166 | DMPAPER_PENV_3_ROTATED = 111, |
| 167 | DMPAPER_PENV_4_ROTATED = 112, |
| 168 | DMPAPER_PENV_5_ROTATED = 113, |
| 169 | DMPAPER_PENV_6_ROTATED = 114, |
| 170 | DMPAPER_PENV_7_ROTATED = 115, |
| 171 | DMPAPER_PENV_8_ROTATED = 116, |
| 172 | DMPAPER_PENV_9_ROTATED = 117, |
| 173 | DMPAPER_PENV_10_ROTATED = 118, |
| 174 | DMPAPER_LAST = DMPAPER_PENV_10_ROTATED, |
| 175 | DMPAPER_USER = 256 |
| 176 | }; |
| 177 | |
| 178 | // Conversion table for historic page size values that we don't support. |
| 179 | // These are deprecated in PPD and strongly discouraged from being used, |
| 180 | // so convert them to usable page sizes to support older print devices. |
| 181 | // The paper source orientation will be handled in the QPrintMedia class, |
| 182 | // we're only concerned about the standard size in QPageSize. |
| 183 | // _ROTATED = 90 degrees or QPageLayout::Landscape |
| 184 | // _TRANSVERSE = 180 degrees or QPageLayout::ReversePortrait |
| 185 | |
| 186 | static const int qt_windowsConversion[][2] = { |
| 187 | {DMPAPER_11X17, DMPAPER_TABLOID}, // = DMPAPER_LEDGER rotated |
| 188 | {DMPAPER_A3_EXTRA_TRANSVERSE, DMPAPER_A3_EXTRA}, |
| 189 | {DMPAPER_A3_ROTATED, DMPAPER_A3}, |
| 190 | {DMPAPER_A3_TRANSVERSE, DMPAPER_A3}, |
| 191 | {DMPAPER_A4_ROTATED, DMPAPER_A4}, |
| 192 | {DMPAPER_A4_TRANSVERSE, DMPAPER_A4}, |
| 193 | {DMPAPER_A5_ROTATED, DMPAPER_A5}, |
| 194 | {DMPAPER_A5_TRANSVERSE, DMPAPER_A5}, |
| 195 | {DMPAPER_A6_ROTATED, DMPAPER_A6}, |
| 196 | {DMPAPER_B4_JIS_ROTATED, DMPAPER_B4}, |
| 197 | {DMPAPER_B5_JIS_ROTATED, DMPAPER_B5}, |
| 198 | {DMPAPER_B5_TRANSVERSE, DMPAPER_B5}, |
| 199 | {DMPAPER_B6_JIS_ROTATED, DMPAPER_B6_JIS}, |
| 200 | {DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED, DMPAPER_DBL_JAPANESE_POSTCARD}, |
| 201 | {DMPAPER_JAPANESE_POSTCARD_ROTATED, DMPAPER_JAPANESE_POSTCARD}, |
| 202 | {DMPAPER_JENV_CHOU3_ROTATED, DMPAPER_JENV_CHOU3}, |
| 203 | {DMPAPER_JENV_CHOU4_ROTATED, DMPAPER_JENV_CHOU4}, |
| 204 | {DMPAPER_JENV_KAKU2_ROTATED, DMPAPER_JENV_KAKU2}, |
| 205 | {DMPAPER_JENV_KAKU3_ROTATED, DMPAPER_JENV_KAKU3}, |
| 206 | {DMPAPER_JENV_YOU4_ROTATED, DMPAPER_JENV_YOU4}, |
| 207 | {DMPAPER_LETTER_EXTRA_TRANSVERSE, DMPAPER_LETTER_EXTRA}, |
| 208 | {DMPAPER_LETTER_ROTATED, DMPAPER_LETTER}, |
| 209 | {DMPAPER_LETTER_TRANSVERSE, DMPAPER_LETTER}, |
| 210 | {DMPAPER_P16K_ROTATED, DMPAPER_P16K}, |
| 211 | {DMPAPER_P32K_ROTATED, DMPAPER_P32K}, |
| 212 | {DMPAPER_P32KBIG_ROTATED, DMPAPER_P32KBIG}, |
| 213 | {DMPAPER_PENV_1_ROTATED, DMPAPER_PENV_1}, |
| 214 | {DMPAPER_PENV_2_ROTATED, DMPAPER_PENV_2}, |
| 215 | {DMPAPER_PENV_3_ROTATED, DMPAPER_PENV_3}, |
| 216 | {DMPAPER_PENV_4_ROTATED, DMPAPER_PENV_4}, |
| 217 | {DMPAPER_PENV_5_ROTATED, DMPAPER_PENV_5}, |
| 218 | {DMPAPER_PENV_6_ROTATED, DMPAPER_PENV_6}, |
| 219 | {DMPAPER_PENV_7_ROTATED, DMPAPER_PENV_7}, |
| 220 | {DMPAPER_PENV_8_ROTATED, DMPAPER_PENV_8}, |
| 221 | {DMPAPER_PENV_9_ROTATED, DMPAPER_PENV_9}, |
| 222 | {DMPAPER_PENV_10_ROTATED, DMPAPER_PENV_10} // Is = DMPAPER_LAST, use as loop terminator |
| 223 | }; |
| 224 | |
| 225 | // Standard sizes data |
| 226 | struct StandardPageSize { |
| 227 | QPageSize::PageSizeId id; |
| 228 | int windowsId; // Windows DMPAPER value |
| 229 | QPageSize::Unit definitionUnits; // Standard definition size, e.g. ISO uses mm, ANSI uses inches |
| 230 | int widthPoints; |
| 231 | int heightPoints; |
| 232 | qreal widthMillimeters; |
| 233 | qreal heightMillimeters; |
| 234 | qreal widthInches; |
| 235 | qreal heightInches; |
| 236 | const char *mediaOption; // PPD standard mediaOption ID |
| 237 | }; |
| 238 | |
| 239 | // Standard page sizes taken from the Postscript PPD Standard v4.3 |
| 240 | // See http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf |
| 241 | // Excludes all Transverse and Rotated sizes |
| 242 | // NB! This table needs to be in sync with QPageSize::PageSizeId |
| 243 | static const StandardPageSize qt_pageSizes[] = { |
| 244 | |
| 245 | // Existing Qt sizes including ISO, US, ANSI and other standards |
| 246 | {.id: QPageSize::A4 , .windowsId: DMPAPER_A4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 595, .heightPoints: 842, .widthMillimeters: 210 , .heightMillimeters: 297 , .widthInches: 8.27, .heightInches: 11.69, .mediaOption: "A4" }, |
| 247 | {.id: QPageSize::B5 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 499, .heightPoints: 709, .widthMillimeters: 176 , .heightMillimeters: 250 , .widthInches: 6.9 , .heightInches: 9.8 , .mediaOption: "ISOB5" }, |
| 248 | {.id: QPageSize::Letter , .windowsId: DMPAPER_LETTER , .definitionUnits: QPageSize::Inch , .widthPoints: 612, .heightPoints: 792, .widthMillimeters: 215.9, .heightMillimeters: 279.4, .widthInches: 8.5 , .heightInches: 11 , .mediaOption: "Letter" }, |
| 249 | {.id: QPageSize::Legal , .windowsId: DMPAPER_LEGAL , .definitionUnits: QPageSize::Inch , .widthPoints: 612, .heightPoints: 1008, .widthMillimeters: 215.9, .heightMillimeters: 355.6, .widthInches: 8.5 , .heightInches: 14 , .mediaOption: "Legal" }, |
| 250 | {.id: QPageSize::Executive , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 540, .heightPoints: 720, .widthMillimeters: 190.5, .heightMillimeters: 254 , .widthInches: 7.5 , .heightInches: 10 , .mediaOption: "Executive.7.5x10in" }, // Qt size differs from Postscript / Windows |
| 251 | {.id: QPageSize::A0 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 2384, .heightPoints: 3370, .widthMillimeters: 841 , .heightMillimeters: 1189 , .widthInches: 33.11, .heightInches: 46.81, .mediaOption: "A0" }, |
| 252 | {.id: QPageSize::A1 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1684, .heightPoints: 2384, .widthMillimeters: 594 , .heightMillimeters: 841 , .widthInches: 23.39, .heightInches: 33.11, .mediaOption: "A1" }, |
| 253 | {.id: QPageSize::A2 , .windowsId: DMPAPER_A2 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1191, .heightPoints: 1684, .widthMillimeters: 420 , .heightMillimeters: 594 , .widthInches: 16.54, .heightInches: 23.39, .mediaOption: "A2" }, |
| 254 | {.id: QPageSize::A3 , .windowsId: DMPAPER_A3 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 842, .heightPoints: 1191, .widthMillimeters: 297 , .heightMillimeters: 420 , .widthInches: 11.69, .heightInches: 16.54, .mediaOption: "A3" }, |
| 255 | {.id: QPageSize::A5 , .windowsId: DMPAPER_A5 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 420, .heightPoints: 595, .widthMillimeters: 148 , .heightMillimeters: 210 , .widthInches: 5.83, .heightInches: 8.27, .mediaOption: "A5" }, |
| 256 | {.id: QPageSize::A6 , .windowsId: DMPAPER_A6 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 297, .heightPoints: 420, .widthMillimeters: 105 , .heightMillimeters: 148 , .widthInches: 4.13, .heightInches: 5.83, .mediaOption: "A6" }, |
| 257 | {.id: QPageSize::A7 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 210, .heightPoints: 297, .widthMillimeters: 74 , .heightMillimeters: 105 , .widthInches: 2.91, .heightInches: 4.13, .mediaOption: "A7" }, |
| 258 | {.id: QPageSize::A8 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 148, .heightPoints: 210, .widthMillimeters: 52 , .heightMillimeters: 74 , .widthInches: 2.05, .heightInches: 2.91, .mediaOption: "A8" }, |
| 259 | {.id: QPageSize::A9 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 105, .heightPoints: 148, .widthMillimeters: 37 , .heightMillimeters: 52 , .widthInches: 1.46, .heightInches: 2.05, .mediaOption: "A9" }, |
| 260 | {.id: QPageSize::B0 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 2835, .heightPoints: 4008, .widthMillimeters: 1000 , .heightMillimeters: 1414 , .widthInches: 39.37, .heightInches: 55.67, .mediaOption: "ISOB0" }, |
| 261 | {.id: QPageSize::B1 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 2004, .heightPoints: 2835, .widthMillimeters: 707 , .heightMillimeters: 1000 , .widthInches: 27.83, .heightInches: 39.37, .mediaOption: "ISOB1" }, |
| 262 | {.id: QPageSize::B10 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 88, .heightPoints: 125, .widthMillimeters: 31 , .heightMillimeters: 44 , .widthInches: 1.22, .heightInches: 1.73, .mediaOption: "ISOB10" }, |
| 263 | {.id: QPageSize::B2 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1417, .heightPoints: 2004, .widthMillimeters: 500 , .heightMillimeters: 707 , .widthInches: 19.68, .heightInches: 27.83, .mediaOption: "ISOB2" }, |
| 264 | {.id: QPageSize::B3 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1001, .heightPoints: 1417, .widthMillimeters: 353 , .heightMillimeters: 500 , .widthInches: 13.9 , .heightInches: 19.68, .mediaOption: "ISOB3" }, |
| 265 | {.id: QPageSize::B4 , .windowsId: DMPAPER_ISO_B4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 709, .heightPoints: 1001, .widthMillimeters: 250 , .heightMillimeters: 353 , .widthInches: 9.84, .heightInches: 13.9 , .mediaOption: "ISOB4" }, |
| 266 | {.id: QPageSize::B6 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 354, .heightPoints: 499, .widthMillimeters: 125 , .heightMillimeters: 176 , .widthInches: 4.92, .heightInches: 6.93, .mediaOption: "ISOB6" }, |
| 267 | {.id: QPageSize::B7 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 249, .heightPoints: 354, .widthMillimeters: 88 , .heightMillimeters: 125 , .widthInches: 3.46, .heightInches: 4.92, .mediaOption: "ISOB7" }, |
| 268 | {.id: QPageSize::B8 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 176, .heightPoints: 249, .widthMillimeters: 62 , .heightMillimeters: 88 , .widthInches: 2.44, .heightInches: 3.46, .mediaOption: "ISOB8" }, |
| 269 | {.id: QPageSize::B9 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 125, .heightPoints: 176, .widthMillimeters: 44 , .heightMillimeters: 62 , .widthInches: 1.73, .heightInches: 2.44, .mediaOption: "ISOB9" }, |
| 270 | {.id: QPageSize::C5E , .windowsId: DMPAPER_ENV_C5 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 459, .heightPoints: 649, .widthMillimeters: 162 , .heightMillimeters: 229 , .widthInches: 6.38, .heightInches: 9.02, .mediaOption: "EnvC5" }, |
| 271 | {.id: QPageSize::Comm10E , .windowsId: DMPAPER_ENV_10 , .definitionUnits: QPageSize::Inch , .widthPoints: 297, .heightPoints: 684, .widthMillimeters: 104.8, .heightMillimeters: 241.3, .widthInches: 4.12, .heightInches: 9.5 , .mediaOption: "Env10" }, |
| 272 | {.id: QPageSize::DLE , .windowsId: DMPAPER_ENV_DL , .definitionUnits: QPageSize::Millimeter, .widthPoints: 312, .heightPoints: 624, .widthMillimeters: 110 , .heightMillimeters: 220 , .widthInches: 4.33, .heightInches: 8.66, .mediaOption: "EnvDL" }, |
| 273 | {.id: QPageSize::Folio , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 595, .heightPoints: 935, .widthMillimeters: 210 , .heightMillimeters: 330 , .widthInches: 8.27, .heightInches: 13 , .mediaOption: "Folio" }, |
| 274 | {.id: QPageSize::Ledger , .windowsId: DMPAPER_LEDGER , .definitionUnits: QPageSize::Inch , .widthPoints: 1224, .heightPoints: 792, .widthMillimeters: 431.8, .heightMillimeters: 279.4, .widthInches: 17 , .heightInches: 11 , .mediaOption: "Ledger" }, |
| 275 | {.id: QPageSize::Tabloid , .windowsId: DMPAPER_TABLOID , .definitionUnits: QPageSize::Inch , .widthPoints: 792, .heightPoints: 1224, .widthMillimeters: 279.4, .heightMillimeters: 431.8, .widthInches: 11 , .heightInches: 17 , .mediaOption: "Tabloid" }, |
| 276 | {.id: QPageSize::Custom , .windowsId: DMPAPER_USER , .definitionUnits: QPageSize::Millimeter, .widthPoints: -1, .heightPoints: -1, .widthMillimeters: -1. , .heightMillimeters: -1 , .widthInches: -1 , .heightInches: -1 , .mediaOption: "Custom" }, // Special case to keep in sync with QPageSize::PageSizeId |
| 277 | |
| 278 | // ISO Standard Sizes |
| 279 | {.id: QPageSize::A10 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 73, .heightPoints: 105, .widthMillimeters: 26 , .heightMillimeters: 37 , .widthInches: 1.02, .heightInches: 1.46, .mediaOption: "A10" }, |
| 280 | {.id: QPageSize::A3Extra , .windowsId: DMPAPER_A3_EXTRA , .definitionUnits: QPageSize::Millimeter, .widthPoints: 913, .heightPoints: 1262, .widthMillimeters: 322 , .heightMillimeters: 445 , .widthInches: 12.67, .heightInches: 17.52, .mediaOption: "A3Extra" }, |
| 281 | {.id: QPageSize::A4Extra , .windowsId: DMPAPER_A4_EXTRA , .definitionUnits: QPageSize::Millimeter, .widthPoints: 667, .heightPoints: 914, .widthMillimeters: 235.5, .heightMillimeters: 322.3, .widthInches: 9.27, .heightInches: 12.69, .mediaOption: "A4Extra" }, |
| 282 | {.id: QPageSize::A4Plus , .windowsId: DMPAPER_A4_PLUS , .definitionUnits: QPageSize::Millimeter, .widthPoints: 595, .heightPoints: 936, .widthMillimeters: 210 , .heightMillimeters: 330 , .widthInches: 8.27, .heightInches: 13 , .mediaOption: "A4Plus" }, |
| 283 | {.id: QPageSize::A4Small , .windowsId: DMPAPER_A4SMALL , .definitionUnits: QPageSize::Millimeter, .widthPoints: 595, .heightPoints: 842, .widthMillimeters: 210 , .heightMillimeters: 297 , .widthInches: 8.27, .heightInches: 11.69, .mediaOption: "A4Small" }, |
| 284 | {.id: QPageSize::A5Extra , .windowsId: DMPAPER_A5_EXTRA , .definitionUnits: QPageSize::Millimeter, .widthPoints: 492, .heightPoints: 668, .widthMillimeters: 174 , .heightMillimeters: 235 , .widthInches: 6.85, .heightInches: 9.25, .mediaOption: "A5Extra" }, |
| 285 | {.id: QPageSize::B5Extra , .windowsId: DMPAPER_B5_EXTRA , .definitionUnits: QPageSize::Millimeter, .widthPoints: 570, .heightPoints: 782, .widthMillimeters: 201 , .heightMillimeters: 276 , .widthInches: 7.9 , .heightInches: 10.8 , .mediaOption: "ISOB5Extra" }, |
| 286 | |
| 287 | // JIS Standard Sizes |
| 288 | {.id: QPageSize::JisB0 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 2920, .heightPoints: 4127, .widthMillimeters: 1030 , .heightMillimeters: 1456 , .widthInches: 40.55, .heightInches: 57.32, .mediaOption: "B0" }, |
| 289 | {.id: QPageSize::JisB1 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 2064, .heightPoints: 2920, .widthMillimeters: 728 , .heightMillimeters: 1030 , .widthInches: 28.66, .heightInches: 40.55, .mediaOption: "B1" }, |
| 290 | {.id: QPageSize::JisB2 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1460, .heightPoints: 2064, .widthMillimeters: 515 , .heightMillimeters: 728 , .widthInches: 20.28, .heightInches: 28.66, .mediaOption: "B2" }, |
| 291 | {.id: QPageSize::JisB3 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1032, .heightPoints: 1460, .widthMillimeters: 364 , .heightMillimeters: 515 , .widthInches: 14.33, .heightInches: 20.28, .mediaOption: "B3" }, |
| 292 | {.id: QPageSize::JisB4 , .windowsId: DMPAPER_B4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 729, .heightPoints: 1032, .widthMillimeters: 257 , .heightMillimeters: 364 , .widthInches: 10.12, .heightInches: 14.33, .mediaOption: "B4" }, |
| 293 | {.id: QPageSize::JisB5 , .windowsId: DMPAPER_B5 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 516, .heightPoints: 729, .widthMillimeters: 182 , .heightMillimeters: 257 , .widthInches: 7.17, .heightInches: 10.12, .mediaOption: "B5" }, |
| 294 | {.id: QPageSize::JisB6 , .windowsId: DMPAPER_B6_JIS , .definitionUnits: QPageSize::Millimeter, .widthPoints: 363, .heightPoints: 516, .widthMillimeters: 128 , .heightMillimeters: 182 , .widthInches: 5.04, .heightInches: 7.17, .mediaOption: "B6" }, |
| 295 | {.id: QPageSize::JisB7 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 258, .heightPoints: 363, .widthMillimeters: 91 , .heightMillimeters: 128 , .widthInches: 3.58, .heightInches: 5.04, .mediaOption: "B7" }, |
| 296 | {.id: QPageSize::JisB8 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 181, .heightPoints: 258, .widthMillimeters: 64 , .heightMillimeters: 91 , .widthInches: 2.52, .heightInches: 3.58, .mediaOption: "B8" }, |
| 297 | {.id: QPageSize::JisB9 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 127, .heightPoints: 181, .widthMillimeters: 45 , .heightMillimeters: 64 , .widthInches: 1.77, .heightInches: 2.52, .mediaOption: "B9" }, |
| 298 | {.id: QPageSize::JisB10 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 91, .heightPoints: 127, .widthMillimeters: 32 , .heightMillimeters: 45 , .widthInches: 1.26, .heightInches: 1.77, .mediaOption: "B10" }, |
| 299 | |
| 300 | // ANSI / US Standard sizes |
| 301 | {.id: QPageSize::AnsiC , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 1224, .heightPoints: 1584, .widthMillimeters: 431.8, .heightMillimeters: 558.8, .widthInches: 17 , .heightInches: 22 , .mediaOption: "AnsiC" }, |
| 302 | {.id: QPageSize::AnsiD , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 1584, .heightPoints: 2448, .widthMillimeters: 558.8, .heightMillimeters: 863.6, .widthInches: 22 , .heightInches: 34 , .mediaOption: "AnsiD" }, |
| 303 | {.id: QPageSize::AnsiE , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 2448, .heightPoints: 3168, .widthMillimeters: 863.6, .heightMillimeters: 1118 , .widthInches: 34 , .heightInches: 44 , .mediaOption: "AnsiE" }, |
| 304 | {.id: QPageSize::LegalExtra , .windowsId: DMPAPER_LEGAL_EXTRA , .definitionUnits: QPageSize::Inch , .widthPoints: 684, .heightPoints: 1080, .widthMillimeters: 241.3, .heightMillimeters: 381 , .widthInches: 9.5 , .heightInches: 15 , .mediaOption: "LegalExtra" }, |
| 305 | {.id: QPageSize::LetterExtra , .windowsId: DMPAPER_LETTER_EXTRA , .definitionUnits: QPageSize::Inch , .widthPoints: 684, .heightPoints: 864, .widthMillimeters: 241.3, .heightMillimeters: 304.8, .widthInches: 9.5 , .heightInches: 12 , .mediaOption: "LetterExtra" }, |
| 306 | {.id: QPageSize::LetterPlus , .windowsId: DMPAPER_LETTER_PLUS , .definitionUnits: QPageSize::Inch , .widthPoints: 612, .heightPoints: 914, .widthMillimeters: 215.9, .heightMillimeters: 322.3, .widthInches: 8.5 , .heightInches: 12.69, .mediaOption: "LetterPlus" }, |
| 307 | {.id: QPageSize::LetterSmall , .windowsId: DMPAPER_LETTERSMALL , .definitionUnits: QPageSize::Inch , .widthPoints: 612, .heightPoints: 792, .widthMillimeters: 215.9, .heightMillimeters: 279.4, .widthInches: 8.5 , .heightInches: 11 , .mediaOption: "LetterSmall" }, |
| 308 | {.id: QPageSize::TabloidExtra , .windowsId: DMPAPER_TABLOID_EXTRA , .definitionUnits: QPageSize::Inch , .widthPoints: 864, .heightPoints: 1296, .widthMillimeters: 304.8, .heightMillimeters: 457.2, .widthInches: 12 , .heightInches: 18 , .mediaOption: "TabloidExtra" }, |
| 309 | |
| 310 | // Architectural sizes |
| 311 | {.id: QPageSize::ArchA , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 648, .heightPoints: 864, .widthMillimeters: 228.6, .heightMillimeters: 304.8, .widthInches: 9 , .heightInches: 12 , .mediaOption: "ARCHA" }, |
| 312 | {.id: QPageSize::ArchB , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 864, .heightPoints: 1296, .widthMillimeters: 304.8, .heightMillimeters: 457.2, .widthInches: 12 , .heightInches: 18 , .mediaOption: "ARCHB" }, |
| 313 | {.id: QPageSize::ArchC , .windowsId: DMPAPER_CSHEET , .definitionUnits: QPageSize::Inch , .widthPoints: 1296, .heightPoints: 1728, .widthMillimeters: 457.2, .heightMillimeters: 609.6, .widthInches: 18 , .heightInches: 24 , .mediaOption: "ARCHC" }, |
| 314 | {.id: QPageSize::ArchD , .windowsId: DMPAPER_DSHEET , .definitionUnits: QPageSize::Inch , .widthPoints: 1728, .heightPoints: 2592, .widthMillimeters: 609.6, .heightMillimeters: 914.4, .widthInches: 24 , .heightInches: 36 , .mediaOption: "ARCHD" }, |
| 315 | {.id: QPageSize::ArchE , .windowsId: DMPAPER_ESHEET , .definitionUnits: QPageSize::Inch , .widthPoints: 2592, .heightPoints: 3456, .widthMillimeters: 914.4, .heightMillimeters: 1219 , .widthInches: 36 , .heightInches: 48 , .mediaOption: "ARCHE" }, |
| 316 | |
| 317 | // Inch-based Sizes |
| 318 | {.id: QPageSize::Imperial7x9 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 504, .heightPoints: 648, .widthMillimeters: 177.8, .heightMillimeters: 228.6, .widthInches: 7 , .heightInches: 9 , .mediaOption: "7x9" }, |
| 319 | {.id: QPageSize::Imperial8x10 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 576, .heightPoints: 720, .widthMillimeters: 203.2, .heightMillimeters: 254 , .widthInches: 8 , .heightInches: 10 , .mediaOption: "8x10" }, |
| 320 | {.id: QPageSize::Imperial9x11 , .windowsId: DMPAPER_9X11 , .definitionUnits: QPageSize::Inch , .widthPoints: 648, .heightPoints: 792, .widthMillimeters: 228.6, .heightMillimeters: 279.4, .widthInches: 9 , .heightInches: 11 , .mediaOption: "9x11" }, |
| 321 | {.id: QPageSize::Imperial9x12 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 648, .heightPoints: 864, .widthMillimeters: 228.6, .heightMillimeters: 304.8, .widthInches: 9 , .heightInches: 12 , .mediaOption: "9x12" }, |
| 322 | {.id: QPageSize::Imperial10x11 , .windowsId: DMPAPER_10X11 , .definitionUnits: QPageSize::Inch , .widthPoints: 720, .heightPoints: 792, .widthMillimeters: 254 , .heightMillimeters: 279.4, .widthInches: 10 , .heightInches: 11 , .mediaOption: "10x11" }, |
| 323 | {.id: QPageSize::Imperial10x13 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Inch , .widthPoints: 720, .heightPoints: 936, .widthMillimeters: 254 , .heightMillimeters: 330.2, .widthInches: 10 , .heightInches: 13 , .mediaOption: "10x13" }, |
| 324 | {.id: QPageSize::Imperial10x14 , .windowsId: DMPAPER_10X14 , .definitionUnits: QPageSize::Inch , .widthPoints: 720, .heightPoints: 1008, .widthMillimeters: 254 , .heightMillimeters: 355.6, .widthInches: 10 , .heightInches: 14 , .mediaOption: "10x14" }, |
| 325 | {.id: QPageSize::Imperial12x11 , .windowsId: DMPAPER_12X11 , .definitionUnits: QPageSize::Inch , .widthPoints: 864, .heightPoints: 792, .widthMillimeters: 304.8, .heightMillimeters: 279.4, .widthInches: 12 , .heightInches: 11 , .mediaOption: "12x11" }, |
| 326 | {.id: QPageSize::Imperial15x11 , .windowsId: DMPAPER_15X11 , .definitionUnits: QPageSize::Inch , .widthPoints: 1080, .heightPoints: 792, .widthMillimeters: 381 , .heightMillimeters: 279.4, .widthInches: 15 , .heightInches: 11 , .mediaOption: "15x11" }, |
| 327 | |
| 328 | // Other Page Sizes |
| 329 | {.id: QPageSize::ExecutiveStandard , .windowsId: DMPAPER_EXECUTIVE , .definitionUnits: QPageSize::Inch , .widthPoints: 522, .heightPoints: 756, .widthMillimeters: 184.2, .heightMillimeters: 266.7, .widthInches: 7.25, .heightInches: 10.5 , .mediaOption: "Executive" }, // Qt size differs from Postscript / Windows |
| 330 | {.id: QPageSize::Note , .windowsId: DMPAPER_NOTE , .definitionUnits: QPageSize::Inch , .widthPoints: 612, .heightPoints: 792, .widthMillimeters: 215.9, .heightMillimeters: 279.4, .widthInches: 8.5 , .heightInches: 11 , .mediaOption: "Note" }, |
| 331 | {.id: QPageSize::Quarto , .windowsId: DMPAPER_QUARTO , .definitionUnits: QPageSize::Inch , .widthPoints: 610, .heightPoints: 780, .widthMillimeters: 215.9, .heightMillimeters: 275.1, .widthInches: 8.5 , .heightInches: 10.83, .mediaOption: "Quarto" }, |
| 332 | {.id: QPageSize::Statement , .windowsId: DMPAPER_STATEMENT , .definitionUnits: QPageSize::Inch , .widthPoints: 396, .heightPoints: 612, .widthMillimeters: 139.7, .heightMillimeters: 215.9, .widthInches: 5.5 , .heightInches: 8.5 , .mediaOption: "Statement" }, |
| 333 | {.id: QPageSize::SuperA , .windowsId: DMPAPER_A_PLUS , .definitionUnits: QPageSize::Millimeter, .widthPoints: 643, .heightPoints: 1009, .widthMillimeters: 227 , .heightMillimeters: 356 , .widthInches: 8.94, .heightInches: 14 , .mediaOption: "SuperA" }, |
| 334 | {.id: QPageSize::SuperB , .windowsId: DMPAPER_B_PLUS , .definitionUnits: QPageSize::Millimeter, .widthPoints: 864, .heightPoints: 1380, .widthMillimeters: 305 , .heightMillimeters: 487 , .widthInches: 12 , .heightInches: 19.17, .mediaOption: "SuperB" }, |
| 335 | {.id: QPageSize::Postcard , .windowsId: DMPAPER_JAPANESE_POSTCARD , .definitionUnits: QPageSize::Millimeter, .widthPoints: 284, .heightPoints: 419, .widthMillimeters: 100 , .heightMillimeters: 148 , .widthInches: 3.94, .heightInches: 5.83, .mediaOption: "Postcard" }, |
| 336 | {.id: QPageSize::DoublePostcard , .windowsId: DMPAPER_DBL_JAPANESE_POSTCARD, .definitionUnits: QPageSize::Millimeter, .widthPoints: 567, .heightPoints: 419, .widthMillimeters: 200 , .heightMillimeters: 148 , .widthInches: 7.87, .heightInches: 5.83, .mediaOption: "DoublePostcard" }, |
| 337 | {.id: QPageSize::Prc16K , .windowsId: DMPAPER_P16K , .definitionUnits: QPageSize::Millimeter, .widthPoints: 414, .heightPoints: 610, .widthMillimeters: 146 , .heightMillimeters: 215 , .widthInches: 5.75, .heightInches: 8.5 , .mediaOption: "PRC16K" }, |
| 338 | {.id: QPageSize::Prc32K , .windowsId: DMPAPER_P32K , .definitionUnits: QPageSize::Millimeter, .widthPoints: 275, .heightPoints: 428, .widthMillimeters: 97 , .heightMillimeters: 151 , .widthInches: 3.82, .heightInches: 5.95, .mediaOption: "PRC32K" }, |
| 339 | {.id: QPageSize::Prc32KBig , .windowsId: DMPAPER_P32KBIG , .definitionUnits: QPageSize::Millimeter, .widthPoints: 275, .heightPoints: 428, .widthMillimeters: 97 , .heightMillimeters: 151 , .widthInches: 3.82, .heightInches: 5.95, .mediaOption: "PRC32KBig" }, |
| 340 | |
| 341 | // Fan Fold Sizes |
| 342 | {.id: QPageSize::FanFoldUS , .windowsId: DMPAPER_FANFOLD_US , .definitionUnits: QPageSize::Inch , .widthPoints: 1071, .heightPoints: 792, .widthMillimeters: 377.8, .heightMillimeters: 279.4, .widthInches: 14.875, .heightInches: 11 , .mediaOption: "FanFoldUS" }, |
| 343 | {.id: QPageSize::FanFoldGerman , .windowsId: DMPAPER_FANFOLD_STD_GERMAN , .definitionUnits: QPageSize::Inch , .widthPoints: 612, .heightPoints: 864, .widthMillimeters: 215.9, .heightMillimeters: 304.8, .widthInches: 8.5 , .heightInches: 12 , .mediaOption: "FanFoldGerman" }, |
| 344 | {.id: QPageSize::FanFoldGermanLegal, .windowsId: DMPAPER_FANFOLD_LGL_GERMAN , .definitionUnits: QPageSize::Inch , .widthPoints: 612, .heightPoints: 936, .widthMillimeters: 215.9, .heightMillimeters: 330 , .widthInches: 8.5 , .heightInches: 13 , .mediaOption: "FanFoldGermanLegal" }, |
| 345 | |
| 346 | // ISO Envelopes |
| 347 | {.id: QPageSize::EnvelopeB4 , .windowsId: DMPAPER_ENV_B4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 708, .heightPoints: 1001, .widthMillimeters: 250 , .heightMillimeters: 353 , .widthInches: 9.84, .heightInches: 13.9 , .mediaOption: "EnvISOB4" }, |
| 348 | {.id: QPageSize::EnvelopeB5 , .windowsId: DMPAPER_ENV_B5 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 499, .heightPoints: 709, .widthMillimeters: 176 , .heightMillimeters: 250 , .widthInches: 6.9 , .heightInches: 9.8 , .mediaOption: "EnvISOB5" }, |
| 349 | {.id: QPageSize::EnvelopeB6 , .windowsId: DMPAPER_ENV_B6 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 499, .heightPoints: 354, .widthMillimeters: 176 , .heightMillimeters: 125 , .widthInches: 6.9 , .heightInches: 4.9 , .mediaOption: "EnvISOB6" }, |
| 350 | {.id: QPageSize::EnvelopeC0 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 2599, .heightPoints: 3676, .widthMillimeters: 917 , .heightMillimeters: 1297 , .widthInches: 36.1 , .heightInches: 51.06, .mediaOption: "EnvC0" }, |
| 351 | {.id: QPageSize::EnvelopeC1 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1837, .heightPoints: 2599, .widthMillimeters: 648 , .heightMillimeters: 917 , .widthInches: 25.51, .heightInches: 36.1 , .mediaOption: "EnvC1" }, |
| 352 | {.id: QPageSize::EnvelopeC2 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 1298, .heightPoints: 1837, .widthMillimeters: 458 , .heightMillimeters: 648 , .widthInches: 18.03, .heightInches: 25.51, .mediaOption: "EnvC2" }, |
| 353 | {.id: QPageSize::EnvelopeC3 , .windowsId: DMPAPER_ENV_C3 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 918, .heightPoints: 1296, .widthMillimeters: 324 , .heightMillimeters: 458 , .widthInches: 12.75, .heightInches: 18.03, .mediaOption: "EnvC3" }, |
| 354 | {.id: QPageSize::EnvelopeC4 , .windowsId: DMPAPER_ENV_C4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 649, .heightPoints: 918, .widthMillimeters: 229 , .heightMillimeters: 324 , .widthInches: 9.02, .heightInches: 12.75, .mediaOption: "EnvC4" }, |
| 355 | {.id: QPageSize::EnvelopeC6 , .windowsId: DMPAPER_ENV_C6 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 323, .heightPoints: 459, .widthMillimeters: 114 , .heightMillimeters: 162 , .widthInches: 4.49, .heightInches: 6.38, .mediaOption: "EnvC6" }, |
| 356 | {.id: QPageSize::EnvelopeC65 , .windowsId: DMPAPER_ENV_C65 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 324, .heightPoints: 648, .widthMillimeters: 114 , .heightMillimeters: 229 , .widthInches: 4.5 , .heightInches: 9 , .mediaOption: "EnvC65" }, |
| 357 | {.id: QPageSize::EnvelopeC7 , .windowsId: DMPAPER_NONE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 230, .heightPoints: 323, .widthMillimeters: 81 , .heightMillimeters: 114 , .widthInches: 3.19, .heightInches: 4.49, .mediaOption: "EnvC7" }, |
| 358 | |
| 359 | // US Envelopes |
| 360 | {.id: QPageSize::Envelope9 , .windowsId: DMPAPER_ENV_9 , .definitionUnits: QPageSize::Inch , .widthPoints: 279, .heightPoints: 639, .widthMillimeters: 98.4, .heightMillimeters: 225.4, .widthInches: 3.875, .heightInches: 8.875, .mediaOption: "Env9" }, |
| 361 | {.id: QPageSize::Envelope11 , .windowsId: DMPAPER_ENV_11 , .definitionUnits: QPageSize::Inch , .widthPoints: 324, .heightPoints: 747, .widthMillimeters: 114.3, .heightMillimeters: 263.5, .widthInches: 4.5 , .heightInches: 10.375, .mediaOption: "Env11" }, |
| 362 | {.id: QPageSize::Envelope12 , .windowsId: DMPAPER_ENV_12 , .definitionUnits: QPageSize::Inch , .widthPoints: 342, .heightPoints: 792, .widthMillimeters: 120.7, .heightMillimeters: 279.4, .widthInches: 4.75, .heightInches: 11 , .mediaOption: "Env12" }, |
| 363 | {.id: QPageSize::Envelope14 , .windowsId: DMPAPER_ENV_14 , .definitionUnits: QPageSize::Inch , .widthPoints: 360, .heightPoints: 828, .widthMillimeters: 127 , .heightMillimeters: 292.1, .widthInches: 5 , .heightInches: 11.5 , .mediaOption: "Env14" }, |
| 364 | {.id: QPageSize::EnvelopeMonarch , .windowsId: DMPAPER_ENV_MONARCH , .definitionUnits: QPageSize::Inch , .widthPoints: 279, .heightPoints: 540, .widthMillimeters: 98.43, .heightMillimeters: 190.5, .widthInches: 3.875, .heightInches: 7.5 , .mediaOption: "EnvMonarch" }, |
| 365 | {.id: QPageSize::EnvelopePersonal , .windowsId: DMPAPER_ENV_PERSONAL , .definitionUnits: QPageSize::Inch , .widthPoints: 261, .heightPoints: 468, .widthMillimeters: 92.08, .heightMillimeters: 165.1, .widthInches: 3.625, .heightInches: 6.5 , .mediaOption: "EnvPersonal" }, |
| 366 | |
| 367 | // Other Envelopes |
| 368 | {.id: QPageSize::EnvelopeChou3 , .windowsId: DMPAPER_JENV_CHOU3 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 340, .heightPoints: 666, .widthMillimeters: 120 , .heightMillimeters: 235 , .widthInches: 4.72, .heightInches: 9.25, .mediaOption: "EnvChou3" }, |
| 369 | {.id: QPageSize::EnvelopeChou4 , .windowsId: DMPAPER_JENV_CHOU4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 255, .heightPoints: 581, .widthMillimeters: 90 , .heightMillimeters: 205 , .widthInches: 3.54, .heightInches: 8 , .mediaOption: "EnvChou4" }, |
| 370 | {.id: QPageSize::EnvelopeInvite , .windowsId: DMPAPER_ENV_INVITE , .definitionUnits: QPageSize::Millimeter, .widthPoints: 624, .heightPoints: 624, .widthMillimeters: 220 , .heightMillimeters: 220 , .widthInches: 8.66, .heightInches: 8.66, .mediaOption: "EnvInvite" }, |
| 371 | {.id: QPageSize::EnvelopeItalian , .windowsId: DMPAPER_ENV_ITALY , .definitionUnits: QPageSize::Millimeter, .widthPoints: 312, .heightPoints: 652, .widthMillimeters: 110 , .heightMillimeters: 230 , .widthInches: 4.33, .heightInches: 9 , .mediaOption: "EnvItalian" }, |
| 372 | {.id: QPageSize::EnvelopeKaku2 , .windowsId: DMPAPER_JENV_KAKU2 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 680, .heightPoints: 941, .widthMillimeters: 240 , .heightMillimeters: 332 , .widthInches: 9.45, .heightInches: 13 , .mediaOption: "EnvKaku2" }, |
| 373 | {.id: QPageSize::EnvelopeKaku3 , .windowsId: DMPAPER_JENV_KAKU3 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 612, .heightPoints: 785, .widthMillimeters: 216 , .heightMillimeters: 277 , .widthInches: 8.5 , .heightInches: 10.9 , .mediaOption: "EnvKaku3" }, |
| 374 | {.id: QPageSize::EnvelopePrc1 , .windowsId: DMPAPER_PENV_1 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 289, .heightPoints: 468, .widthMillimeters: 102 , .heightMillimeters: 165 , .widthInches: 4 , .heightInches: 6.5 , .mediaOption: "EnvPRC1" }, |
| 375 | {.id: QPageSize::EnvelopePrc2 , .windowsId: DMPAPER_PENV_2 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 289, .heightPoints: 499, .widthMillimeters: 102 , .heightMillimeters: 176 , .widthInches: 4 , .heightInches: 6.9 , .mediaOption: "EnvPRC2" }, |
| 376 | {.id: QPageSize::EnvelopePrc3 , .windowsId: DMPAPER_PENV_3 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 354, .heightPoints: 499, .widthMillimeters: 125 , .heightMillimeters: 176 , .widthInches: 4.9 , .heightInches: 6.9 , .mediaOption: "EnvPRC3" }, |
| 377 | {.id: QPageSize::EnvelopePrc4 , .windowsId: DMPAPER_PENV_4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 312, .heightPoints: 590, .widthMillimeters: 110 , .heightMillimeters: 208 , .widthInches: 4.33, .heightInches: 8.2 , .mediaOption: "EnvPRC4" }, |
| 378 | {.id: QPageSize::EnvelopePrc5 , .windowsId: DMPAPER_PENV_5 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 312, .heightPoints: 624, .widthMillimeters: 110 , .heightMillimeters: 220 , .widthInches: 4.33, .heightInches: 8.66, .mediaOption: "EnvPRC5" }, |
| 379 | {.id: QPageSize::EnvelopePrc6 , .windowsId: DMPAPER_PENV_6 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 340, .heightPoints: 652, .widthMillimeters: 120 , .heightMillimeters: 230 , .widthInches: 4.7 , .heightInches: 9 , .mediaOption: "EnvPRC6" }, |
| 380 | {.id: QPageSize::EnvelopePrc7 , .windowsId: DMPAPER_PENV_7 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 454, .heightPoints: 652, .widthMillimeters: 160 , .heightMillimeters: 230 , .widthInches: 6.3 , .heightInches: 9 , .mediaOption: "EnvPRC7" }, |
| 381 | {.id: QPageSize::EnvelopePrc8 , .windowsId: DMPAPER_PENV_8 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 340, .heightPoints: 876, .widthMillimeters: 120 , .heightMillimeters: 309 , .widthInches: 4.7 , .heightInches: 12.2 , .mediaOption: "EnvPRC8" }, |
| 382 | {.id: QPageSize::EnvelopePrc9 , .windowsId: DMPAPER_PENV_9 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 649, .heightPoints: 918, .widthMillimeters: 229 , .heightMillimeters: 324 , .widthInches: 9 , .heightInches: 12.75, .mediaOption: "EnvPRC9" }, |
| 383 | {.id: QPageSize::EnvelopePrc10 , .windowsId: DMPAPER_PENV_10 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 918, .heightPoints: 1298, .widthMillimeters: 324 , .heightMillimeters: 458 , .widthInches: 12.75, .heightInches: 18 , .mediaOption: "EnvPRC10" }, |
| 384 | {.id: QPageSize::EnvelopeYou4 , .windowsId: DMPAPER_JENV_YOU4 , .definitionUnits: QPageSize::Millimeter, .widthPoints: 298, .heightPoints: 666, .widthMillimeters: 105 , .heightMillimeters: 235 , .widthInches: 4.13, .heightInches: 9.25, .mediaOption: "EnvYou4" } |
| 385 | }; |
| 386 | |
| 387 | static const int pageSizesCount = int(sizeof(qt_pageSizes) / sizeof(qt_pageSizes[0])); |
| 388 | Q_STATIC_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1); |
| 389 | |
| 390 | // Return key name for PageSize |
| 391 | static QString qt_keyForPageSizeId(QPageSize::PageSizeId id) |
| 392 | { |
| 393 | return QString::fromLatin1(str: qt_pageSizes[id].mediaOption); |
| 394 | } |
| 395 | |
| 396 | // Return id name for PPD Key |
| 397 | static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match = nullptr) |
| 398 | { |
| 399 | if (ppdKey.isEmpty()) |
| 400 | return QPageSize::Custom; |
| 401 | QStringRef key(&ppdKey); |
| 402 | // Remove any Rotated or Tranverse modifiers |
| 403 | if (key.endsWith(s: QLatin1String("Rotated" ))) |
| 404 | key.chop(n: 7); |
| 405 | else if (key.endsWith(s: QLatin1String(".Transverse" ))) |
| 406 | key.chop(n: 11); |
| 407 | for (int i = 0; i <= int(QPageSize::LastPageSize); ++i) { |
| 408 | if (QLatin1String(qt_pageSizes[i].mediaOption) == key) { |
| 409 | if (match) |
| 410 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 411 | return qt_pageSizes[i].id; |
| 412 | } |
| 413 | } |
| 414 | return QPageSize::Custom; |
| 415 | } |
| 416 | |
| 417 | // Return id name for Windows ID |
| 418 | static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match = nullptr) |
| 419 | { |
| 420 | // If outside known values then is Custom |
| 421 | if (windowsId <= DMPAPER_NONE || windowsId > DMPAPER_LAST) |
| 422 | return QPageSize::Custom; |
| 423 | // Check if one of the unsupported values, convert to valid value if is |
| 424 | for (const auto &it : qt_windowsConversion) { |
| 425 | if (it[0] == windowsId) { |
| 426 | windowsId = it[1]; |
| 427 | break; |
| 428 | } |
| 429 | } |
| 430 | // Look for the value in our supported size table |
| 431 | for (int i = 0; i <= int(QPageSize::LastPageSize); ++i) { |
| 432 | if (qt_pageSizes[i].windowsId == windowsId) { |
| 433 | if (match) |
| 434 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 435 | return qt_pageSizes[i].id; |
| 436 | } |
| 437 | } |
| 438 | // Otherwise is Custom |
| 439 | return QPageSize::Custom; |
| 440 | } |
| 441 | |
| 442 | // Return key name for custom size |
| 443 | static QString qt_keyForCustomSize(const QSizeF &size, QPageSize::Unit units) |
| 444 | { |
| 445 | // PPD custom format |
| 446 | QString key = QStringLiteral("Custom.%1x%2%3" ); |
| 447 | QString abbrev; |
| 448 | switch (units) { |
| 449 | case QPageSize::Millimeter: |
| 450 | abbrev = QStringLiteral("mm" ); |
| 451 | break; |
| 452 | case QPageSize::Point: |
| 453 | break; |
| 454 | case QPageSize::Inch: |
| 455 | abbrev = QStringLiteral("in" ); |
| 456 | break; |
| 457 | case QPageSize::Pica: |
| 458 | abbrev = QStringLiteral("pc" ); |
| 459 | break; |
| 460 | case QPageSize::Didot: |
| 461 | abbrev = QStringLiteral("DD" ); |
| 462 | break; |
| 463 | case QPageSize::Cicero: |
| 464 | abbrev = QStringLiteral("CC" ); |
| 465 | break; |
| 466 | } |
| 467 | // Assumes size is already max 2 decimal places |
| 468 | return key.arg(a: size.width()).arg(a: size.height()).arg(a: abbrev); |
| 469 | } |
| 470 | |
| 471 | // Return localized name for custom size |
| 472 | static QString qt_nameForCustomSize(const QSizeF &size, QPageSize::Unit units) |
| 473 | { |
| 474 | QString name; |
| 475 | switch (units) { |
| 476 | case QPageSize::Millimeter: |
| 477 | //: Custom size name in millimeters |
| 478 | name = QCoreApplication::translate(context: "QPageSize" , key: "Custom (%1mm x %2mm)" ); |
| 479 | break; |
| 480 | case QPageSize::Point: |
| 481 | //: Custom size name in points |
| 482 | name = QCoreApplication::translate(context: "QPageSize" , key: "Custom (%1pt x %2pt)" ); |
| 483 | break; |
| 484 | case QPageSize::Inch: |
| 485 | //: Custom size name in inches |
| 486 | name = QCoreApplication::translate(context: "QPageSize" , key: "Custom (%1in x %2in)" ); |
| 487 | break; |
| 488 | case QPageSize::Pica: |
| 489 | //: Custom size name in picas |
| 490 | name = QCoreApplication::translate(context: "QPageSize" , key: "Custom (%1pc x %2pc)" ); |
| 491 | break; |
| 492 | case QPageSize::Didot: |
| 493 | //: Custom size name in didots |
| 494 | name = QCoreApplication::translate(context: "QPageSize" , key: "Custom (%1DD x %2DD)" ); |
| 495 | break; |
| 496 | case QPageSize::Cicero: |
| 497 | //: Custom size name in ciceros |
| 498 | name = QCoreApplication::translate(context: "QPageSize" , key: "Custom (%1CC x %2CC)" ); |
| 499 | break; |
| 500 | } |
| 501 | // Assumes size is already max 2 decimal places |
| 502 | return name.arg(a: size.width()).arg(a: size.height()); |
| 503 | } |
| 504 | |
| 505 | // Multiplier for converting units to points. |
| 506 | static qreal qt_pointMultiplier(QPageSize::Unit unit) |
| 507 | { |
| 508 | switch (unit) { |
| 509 | case QPageSize::Millimeter: |
| 510 | return 2.83464566929; |
| 511 | case QPageSize::Point: |
| 512 | return 1.0; |
| 513 | case QPageSize::Inch: |
| 514 | return 72.0; |
| 515 | case QPageSize::Pica: |
| 516 | return 12; |
| 517 | case QPageSize::Didot: |
| 518 | return 1.065826771; |
| 519 | case QPageSize::Cicero: |
| 520 | return 12.789921252; |
| 521 | } |
| 522 | return 1.0; |
| 523 | } |
| 524 | |
| 525 | // Multiplier for converting pixels to points. |
| 526 | Q_GUI_EXPORT qreal qt_pixelMultiplier(int resolution) |
| 527 | { |
| 528 | return resolution <= 0 ? 1.0 : 72.0 / resolution; |
| 529 | } |
| 530 | |
| 531 | static QSizeF qt_definitionSize(QPageSize::PageSizeId pageSizeId) |
| 532 | { |
| 533 | QPageSize::Unit units = qt_pageSizes[pageSizeId].definitionUnits; |
| 534 | if (units == QPageSize::Millimeter) |
| 535 | return QSizeF(qt_pageSizes[pageSizeId].widthMillimeters, qt_pageSizes[pageSizeId].heightMillimeters); |
| 536 | Q_ASSERT(units == QPageSize::Inch); // We currently only support definitions in mm or inches |
| 537 | return QSizeF(qt_pageSizes[pageSizeId].widthInches, qt_pageSizes[pageSizeId].heightInches); |
| 538 | } |
| 539 | |
| 540 | static QSizeF qt_convertUnits(const QSizeF &size, QPageSize::Unit fromUnits, QPageSize::Unit toUnits) |
| 541 | { |
| 542 | if (!size.isValid()) |
| 543 | return QSizeF(); |
| 544 | |
| 545 | // If the units are the same or the size is 0, then don't need to convert |
| 546 | if (fromUnits == toUnits || (qFuzzyIsNull(d: size.width()) && qFuzzyIsNull(d: size.height()))) |
| 547 | return size; |
| 548 | |
| 549 | QSizeF newSize = size; |
| 550 | // First convert to points |
| 551 | if (fromUnits != QPageSize::Point) { |
| 552 | const qreal multiplier = qt_pointMultiplier(unit: fromUnits); |
| 553 | newSize = newSize * multiplier; |
| 554 | } |
| 555 | // Then convert from points to required units |
| 556 | const qreal multiplier = qt_pointMultiplier(unit: toUnits); |
| 557 | // Try force to 2 decimal places for consistency |
| 558 | const int width = qRound(d: newSize.width() * 100 / multiplier); |
| 559 | const int height = qRound(d: newSize.height() * 100 / multiplier); |
| 560 | return QSizeF(width / 100.0, height / 100.0); |
| 561 | } |
| 562 | |
| 563 | static QSize qt_convertUnitsToPoints(const QSizeF &size, QPageSize::Unit units) |
| 564 | { |
| 565 | if (!size.isValid()) |
| 566 | return QSize(); |
| 567 | return QSizeF(size * qt_pointMultiplier(unit: units)).toSize(); |
| 568 | } |
| 569 | |
| 570 | static QSize qt_convertPointsToPixels(const QSize &size, int resolution) |
| 571 | { |
| 572 | if (!size.isValid() || resolution <= 0) |
| 573 | return QSize(); |
| 574 | const qreal multiplier = qt_pixelMultiplier(resolution); |
| 575 | return QSize(qRound(d: size.width() / multiplier), qRound(d: size.height() / multiplier)); |
| 576 | } |
| 577 | |
| 578 | static QSizeF qt_convertPointsToUnits(const QSize &size, QPageSize::Unit units) |
| 579 | { |
| 580 | if (!size.isValid()) |
| 581 | return QSizeF(); |
| 582 | const qreal multiplier = qt_pointMultiplier(unit: units); |
| 583 | // Try force to 2 decimal places for consistency |
| 584 | const int width = qRound(d: size.width() * 100 / multiplier); |
| 585 | const int height = qRound(d: size.height() * 100 / multiplier); |
| 586 | return QSizeF(width / 100.0, height / 100.0); |
| 587 | } |
| 588 | |
| 589 | static QSizeF qt_unitSize(QPageSize::PageSizeId pageSizeId, QPageSize::Unit units) |
| 590 | { |
| 591 | switch (units) { |
| 592 | case QPageSize::Millimeter: |
| 593 | return QSizeF(qt_pageSizes[pageSizeId].widthMillimeters, qt_pageSizes[pageSizeId].heightMillimeters); |
| 594 | case QPageSize::Point: |
| 595 | return QSizeF(qt_pageSizes[pageSizeId].widthPoints, qt_pageSizes[pageSizeId].heightPoints); |
| 596 | case QPageSize::Inch: |
| 597 | return QSizeF(qt_pageSizes[pageSizeId].widthInches, qt_pageSizes[pageSizeId].heightInches); |
| 598 | case QPageSize::Pica: |
| 599 | case QPageSize::Didot: |
| 600 | case QPageSize::Cicero: |
| 601 | return qt_convertPointsToUnits(size: QSize(qt_pageSizes[pageSizeId].widthPoints, |
| 602 | qt_pageSizes[pageSizeId].heightPoints), units); |
| 603 | } |
| 604 | return QSizeF(); |
| 605 | } |
| 606 | |
| 607 | // Find matching standard page size for point size |
| 608 | static QPageSize::PageSizeId qt_idForPointSize(const QSize &size, QPageSize::SizeMatchPolicy matchPolicy, QSize *match) |
| 609 | { |
| 610 | if (!size.isValid()) |
| 611 | return QPageSize::Custom; |
| 612 | |
| 613 | // Try exact match in portrait layout |
| 614 | for (int i = 0; i <= int(QPageSize::LastPageSize); ++i) { |
| 615 | if (size.width() == qt_pageSizes[i].widthPoints && size.height() == qt_pageSizes[i].heightPoints) { |
| 616 | if (match) |
| 617 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 618 | return qt_pageSizes[i].id; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | // If no exact match only try fuzzy if asked |
| 623 | if (matchPolicy != QPageSize::ExactMatch) { |
| 624 | // Set up the fuzzy tolerance |
| 625 | // TODO Use ISO standard tolerance based on page size? |
| 626 | const int tolerance = 3; // = approx 1mm |
| 627 | const int minWidth = size.width() - tolerance; |
| 628 | const int maxWidth = size.width() + tolerance; |
| 629 | const int minHeight = size.height() - tolerance; |
| 630 | const int maxHeight = size.height() + tolerance; |
| 631 | |
| 632 | // First try fuzzy match in portrait layout |
| 633 | for (int i = 0; i <= QPageSize::LastPageSize; ++i) { |
| 634 | const int width = qt_pageSizes[i].widthPoints; |
| 635 | const int height = qt_pageSizes[i].heightPoints; |
| 636 | if (width >= minWidth && width <= maxWidth && height >= minHeight && height <= maxHeight) { |
| 637 | if (match) |
| 638 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 639 | return qt_pageSizes[i].id; |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | // If FuzzyOrientationMatch then try rotated sizes |
| 644 | if (matchPolicy == QPageSize::FuzzyOrientationMatch) { |
| 645 | // First try exact match in landscape layout |
| 646 | for (int i = 0; i <= QPageSize::LastPageSize; ++i) { |
| 647 | if (size.width() == qt_pageSizes[i].heightPoints && size.height() == qt_pageSizes[i].widthPoints) { |
| 648 | if (match) |
| 649 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 650 | return qt_pageSizes[i].id; |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | // Then try fuzzy match in landscape layout |
| 655 | for (int i = 0; i <= QPageSize::LastPageSize; ++i) { |
| 656 | const int width = qt_pageSizes[i].heightPoints; |
| 657 | const int height = qt_pageSizes[i].widthPoints; |
| 658 | if (width >= minWidth && width <= maxWidth && height >= minHeight && height <= maxHeight) { |
| 659 | if (match) |
| 660 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 661 | return qt_pageSizes[i].id; |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | if (match) |
| 668 | *match = size; |
| 669 | // Otherwise no match so Custom |
| 670 | return QPageSize::Custom; |
| 671 | } |
| 672 | |
| 673 | // Find matching standard page size for point size |
| 674 | static QPageSize::PageSizeId qt_idForSize(const QSizeF &size, QPageSize::Unit units, |
| 675 | QPageSize::SizeMatchPolicy matchPolicy, QSize *match) |
| 676 | { |
| 677 | if (!size.isValid()) |
| 678 | return QPageSize::Custom; |
| 679 | |
| 680 | // Try exact match if units are the same |
| 681 | if (units == QPageSize::Millimeter) { |
| 682 | for (int i = 0; i <= QPageSize::LastPageSize; ++i) { |
| 683 | if (size.width() == qt_pageSizes[i].widthMillimeters && size.height() == qt_pageSizes[i].heightMillimeters) { |
| 684 | if (match) |
| 685 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 686 | return qt_pageSizes[i].id; |
| 687 | } |
| 688 | } |
| 689 | } else if (units == QPageSize::Inch) { |
| 690 | for (int i = 0; i <= QPageSize::LastPageSize; ++i) { |
| 691 | if (size.width() == qt_pageSizes[i].widthInches && size.height() == qt_pageSizes[i].heightInches) { |
| 692 | if (match) |
| 693 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 694 | return qt_pageSizes[i].id; |
| 695 | } |
| 696 | } |
| 697 | } else if (units == QPageSize::Point) { |
| 698 | for (int i = 0; i <= QPageSize::LastPageSize; ++i) { |
| 699 | if (size.width() == qt_pageSizes[i].widthPoints && size.height() == qt_pageSizes[i].heightPoints) { |
| 700 | if (match) |
| 701 | *match = QSize(qt_pageSizes[i].widthPoints, qt_pageSizes[i].heightPoints); |
| 702 | return qt_pageSizes[i].id; |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | // If no exact match then convert to points and try match those |
| 708 | QSize points = qt_convertUnitsToPoints(size, units); |
| 709 | return qt_idForPointSize(size: points, matchPolicy, match); |
| 710 | } |
| 711 | |
| 712 | class QPageSizePrivate : public QSharedData |
| 713 | { |
| 714 | public: |
| 715 | QPageSizePrivate(); |
| 716 | explicit QPageSizePrivate(QPageSize::PageSizeId pageSizeId); |
| 717 | QPageSizePrivate(const QSize &pointSize, |
| 718 | const QString &name, |
| 719 | QPageSize::SizeMatchPolicy matchPolicy); |
| 720 | QPageSizePrivate(const QSizeF &size, QPageSize::Unit units, |
| 721 | const QString &name, |
| 722 | QPageSize::SizeMatchPolicy matchPolicy); |
| 723 | QPageSizePrivate(const QString &key, const QSize &size, const QString &name); |
| 724 | QPageSizePrivate(int windowsId, const QSize &pointSize, const QString &name); |
| 725 | ~QPageSizePrivate(); |
| 726 | |
| 727 | bool operator==(const QPageSizePrivate &other) const; |
| 728 | bool isEquivalentTo(const QPageSizePrivate &other) const; |
| 729 | |
| 730 | bool isValid() const; |
| 731 | |
| 732 | QSizeF size(QPageSize::Unit units) const; |
| 733 | QSize sizePixels(int resolution) const; |
| 734 | |
| 735 | private: |
| 736 | friend class QPageSize; |
| 737 | |
| 738 | void init(QPageSize::PageSizeId id, const QString &name); |
| 739 | void init(const QSize &size, const QString &name); |
| 740 | void init(const QSizeF &size, QPageSize::Unit units, const QString &name); |
| 741 | |
| 742 | QString m_key; |
| 743 | QPageSize::PageSizeId m_id; |
| 744 | QSize m_pointSize; |
| 745 | QString m_name; |
| 746 | int m_windowsId; |
| 747 | QSizeF m_size; |
| 748 | QPageSize::Unit m_units; |
| 749 | }; |
| 750 | |
| 751 | QPageSizePrivate::QPageSizePrivate() |
| 752 | : m_id(QPageSize::Custom), |
| 753 | m_windowsId(0), |
| 754 | m_units(QPageSize::Point) |
| 755 | { |
| 756 | } |
| 757 | |
| 758 | QPageSizePrivate::QPageSizePrivate(QPageSize::PageSizeId pageSizeId) |
| 759 | : m_id(QPageSize::Custom), |
| 760 | m_windowsId(0), |
| 761 | m_units(QPageSize::Point) |
| 762 | { |
| 763 | if (unsigned(pageSizeId) <= unsigned(QPageSize::LastPageSize)) |
| 764 | init(id: pageSizeId, name: QString()); |
| 765 | } |
| 766 | |
| 767 | QPageSizePrivate::QPageSizePrivate(const QSize &pointSize, const QString &name, QPageSize::SizeMatchPolicy matchPolicy) |
| 768 | : m_id(QPageSize::Custom), |
| 769 | m_windowsId(0), |
| 770 | m_units(QPageSize::Point) |
| 771 | { |
| 772 | if (pointSize.isValid()) { |
| 773 | QPageSize::PageSizeId id = qt_idForPointSize(size: pointSize, matchPolicy, match: nullptr); |
| 774 | id == QPageSize::Custom ? init(size: pointSize, name) : init(id, name); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | QPageSizePrivate::QPageSizePrivate(const QSizeF &size, QPageSize::Unit units, |
| 779 | const QString &name, QPageSize::SizeMatchPolicy matchPolicy) |
| 780 | : m_id(QPageSize::Custom), |
| 781 | m_windowsId(0), |
| 782 | m_units(QPageSize::Point) |
| 783 | { |
| 784 | if (size.isValid()) { |
| 785 | QPageSize::PageSizeId id = qt_idForSize(size, units, matchPolicy, match: nullptr); |
| 786 | id == QPageSize::Custom ? init(size, units, name) : init(id, name); |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | QPageSizePrivate::QPageSizePrivate(const QString &key, const QSize &pointSize, const QString &name) |
| 791 | : m_id(QPageSize::Custom), |
| 792 | m_windowsId(0), |
| 793 | m_units(QPageSize::Point) |
| 794 | { |
| 795 | if (!key.isEmpty() && pointSize.isValid()) { |
| 796 | QPageSize::PageSizeId id = qt_idForPpdKey(ppdKey: key, match: nullptr); |
| 797 | // If not a known PPD key, check if size is a standard PPD size |
| 798 | if (id == QPageSize::Custom) |
| 799 | id = qt_idForPointSize(size: pointSize, matchPolicy: QPageSize::FuzzyMatch, match: nullptr); |
| 800 | id == QPageSize::Custom ? init(size: pointSize, name) : init(id, name); |
| 801 | m_key = key; |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | QPageSizePrivate::QPageSizePrivate(int windowsId, const QSize &pointSize, const QString &name) |
| 806 | : m_id(QPageSize::Custom), |
| 807 | m_windowsId(0), |
| 808 | m_units(QPageSize::Point) |
| 809 | { |
| 810 | if (windowsId > 0 && pointSize.isValid()) { |
| 811 | QPageSize::PageSizeId id = qt_idForWindowsID(windowsId, match: nullptr); |
| 812 | // If not a known Windows ID, check if size is a standard PPD size |
| 813 | if (id == QPageSize::Custom) |
| 814 | id = qt_idForPointSize(size: pointSize, matchPolicy: QPageSize::FuzzyMatch, match: nullptr); |
| 815 | id == QPageSize::Custom ? init(size: pointSize, name) : init(id, name); |
| 816 | m_windowsId = windowsId; |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | QPageSizePrivate::~QPageSizePrivate() |
| 821 | { |
| 822 | } |
| 823 | |
| 824 | // Init a standard PageSizeId |
| 825 | void QPageSizePrivate::init(QPageSize::PageSizeId id, const QString &name) |
| 826 | { |
| 827 | m_id = id; |
| 828 | m_size = qt_definitionSize(pageSizeId: id); |
| 829 | m_units = qt_pageSizes[id].definitionUnits; |
| 830 | m_key = qt_keyForPageSizeId(id); |
| 831 | m_name = name.isEmpty() ? QPageSize::name(pageSizeId: id) : name; |
| 832 | m_windowsId = qt_pageSizes[id].windowsId; |
| 833 | m_pointSize = QSize(qt_pageSizes[id].widthPoints, qt_pageSizes[id].heightPoints); |
| 834 | } |
| 835 | |
| 836 | // Init a point size |
| 837 | void QPageSizePrivate::init(const QSize &size, const QString &name) |
| 838 | { |
| 839 | m_id = QPageSize::Custom; |
| 840 | m_size = size; |
| 841 | m_units = QPageSize::Point; |
| 842 | m_key = qt_keyForCustomSize(size: m_size, units: m_units); |
| 843 | m_name = name.isEmpty() ? qt_nameForCustomSize(size: m_size, units: m_units) : name; |
| 844 | m_windowsId = 0; |
| 845 | m_pointSize = size; |
| 846 | } |
| 847 | |
| 848 | // Init a unit size |
| 849 | void QPageSizePrivate::init(const QSizeF &size, QPageSize::Unit units, const QString &name) |
| 850 | { |
| 851 | m_id = QPageSize::Custom; |
| 852 | m_size = size; |
| 853 | m_units = units; |
| 854 | m_key = qt_keyForCustomSize(size: m_size, units: m_units); |
| 855 | if (name.isEmpty()) |
| 856 | m_name = qt_nameForCustomSize(size: m_size, units: m_units); |
| 857 | else |
| 858 | m_name = name; |
| 859 | m_windowsId = 0; |
| 860 | m_pointSize = qt_convertUnitsToPoints(size: m_size, units: m_units); |
| 861 | } |
| 862 | |
| 863 | bool QPageSizePrivate::operator==(const QPageSizePrivate &other) const |
| 864 | { |
| 865 | return m_size == other.m_size |
| 866 | && m_units == other.m_units |
| 867 | && m_key == other.m_key |
| 868 | && m_name == other.m_name; |
| 869 | } |
| 870 | |
| 871 | bool QPageSizePrivate::isEquivalentTo(const QPageSizePrivate &other) const |
| 872 | { |
| 873 | return m_pointSize == other.m_pointSize; |
| 874 | } |
| 875 | |
| 876 | bool QPageSizePrivate::isValid() const |
| 877 | { |
| 878 | return m_pointSize.isValid() && !m_key.isEmpty() && !m_name.isEmpty(); |
| 879 | } |
| 880 | |
| 881 | QSizeF QPageSizePrivate::size(QPageSize::Unit units) const |
| 882 | { |
| 883 | // If want units we've stored in, we already have them |
| 884 | if (units == m_units) |
| 885 | return m_size; |
| 886 | |
| 887 | // If want points we already have them |
| 888 | if (units == QPageSize::Point) |
| 889 | return QSizeF(m_pointSize.width(), m_pointSize.height()); |
| 890 | |
| 891 | // If a custom size do a conversion |
| 892 | if (m_id == QPageSize::Custom) |
| 893 | return qt_convertUnits(size: m_size, fromUnits: m_units, toUnits: units); |
| 894 | |
| 895 | // Otherwise use the standard sizes |
| 896 | return qt_unitSize(pageSizeId: m_id, units); |
| 897 | } |
| 898 | |
| 899 | QSize QPageSizePrivate::sizePixels(int resolution) const |
| 900 | { |
| 901 | return qt_convertPointsToPixels(size: m_pointSize, resolution);; |
| 902 | } |
| 903 | |
| 904 | |
| 905 | /*! |
| 906 | \class QPageSize |
| 907 | \inmodule QtGui |
| 908 | \since 5.3 |
| 909 | \brief The QPageSize class describes the size and name of a defined page size. |
| 910 | |
| 911 | This class implements support for the set of standard page sizes as defined |
| 912 | in the Adobe Postscript PPD Standard v4.3. It defines the standard set of |
| 913 | page sizes in points, millimeters and inches and ensures these sizes are |
| 914 | consistently used. Other size units can be used but will be calculated |
| 915 | results and so may not always be consistent. The defined point sizes are |
| 916 | always a integer, all other sizes can be fractions of a unit. |
| 917 | |
| 918 | The defined size is always in width x height order with no implied page |
| 919 | orientation. Note that it is possible for page sizes to be defined where the |
| 920 | width is greater than the height, such as QPageSize::Ledger, so you cannot |
| 921 | rely on comparing the width and height values to determine page orientation. |
| 922 | |
| 923 | For example, A4 is defined by the standard as 210mm x 297mm, 8.27in x 11.69in, |
| 924 | or 595pt x 842pt. |
| 925 | |
| 926 | You can also define custom page sizes with custom names in any units you want |
| 927 | and this unit size will be preserved and used as the base for all other unit |
| 928 | size calculations. |
| 929 | |
| 930 | When creating a QPageSize using a custom QSize you can choose if you want |
| 931 | QPageSize to try match the size to a standard page size. By default |
| 932 | QPaperSize uses a FuzzyMatch mode where it will match a given page size to |
| 933 | a standard page size if it falls within 3 postscript points of a defined |
| 934 | standard size. You can override this to request only an exact match but this |
| 935 | is not recommended as conversions between units can easily lose 3 points and |
| 936 | result in incorrect page sizes. |
| 937 | |
| 938 | A QPageSize instance may also be obtained by querying the supported page sizes |
| 939 | for a print device. In this case the localized name returned is that defined |
| 940 | by the printer itself. Note that the print device may not support the current |
| 941 | default locale language. |
| 942 | |
| 943 | The class also provides convenience methods for converting page size IDs to and from |
| 944 | various unit sizes. |
| 945 | |
| 946 | \sa QPagedPaintDevice, QPdfWriter |
| 947 | */ |
| 948 | |
| 949 | /*! |
| 950 | \enum QPageSize::PageSizeId |
| 951 | |
| 952 | This enum type lists the available page sizes as defined in the Postscript |
| 953 | PPD standard. These values are duplicated in QPagedPaintDevice and QPrinter. |
| 954 | |
| 955 | The defined sizes are: |
| 956 | |
| 957 | \value A0 841 x 1189 mm |
| 958 | \value A1 594 x 841 mm |
| 959 | \value A2 420 x 594 mm |
| 960 | \value A3 297 x 420 mm |
| 961 | \value A4 210 x 297 mm, 8.26 x 11.69 inches |
| 962 | \value A5 148 x 210 mm |
| 963 | \value A6 105 x 148 mm |
| 964 | \value A7 74 x 105 mm |
| 965 | \value A8 52 x 74 mm |
| 966 | \value A9 37 x 52 mm |
| 967 | \value B0 1000 x 1414 mm |
| 968 | \value B1 707 x 1000 mm |
| 969 | \value B2 500 x 707 mm |
| 970 | \value B3 353 x 500 mm |
| 971 | \value B4 250 x 353 mm |
| 972 | \value B5 176 x 250 mm, 6.93 x 9.84 inches |
| 973 | \value B6 125 x 176 mm |
| 974 | \value B7 88 x 125 mm |
| 975 | \value B8 62 x 88 mm |
| 976 | \value B9 44 x 62 mm |
| 977 | \value B10 31 x 44 mm |
| 978 | \value C5E 163 x 229 mm |
| 979 | \value Comm10E 105 x 241 mm, U.S. Common 10 Envelope |
| 980 | \value DLE 110 x 220 mm |
| 981 | \value Executive 7.5 x 10 inches, 190.5 x 254 mm |
| 982 | \value Folio 210 x 330 mm |
| 983 | \value Ledger 431.8 x 279.4 mm |
| 984 | \value Legal 8.5 x 14 inches, 215.9 x 355.6 mm |
| 985 | \value Letter 8.5 x 11 inches, 215.9 x 279.4 mm |
| 986 | \value Tabloid 279.4 x 431.8 mm |
| 987 | \value Custom Unknown, or a user defined size. |
| 988 | \value A10 |
| 989 | \value A3Extra |
| 990 | \value A4Extra |
| 991 | \value A4Plus |
| 992 | \value A4Small |
| 993 | \value A5Extra |
| 994 | \value B5Extra |
| 995 | \value JisB0 |
| 996 | \value JisB1 |
| 997 | \value JisB2 |
| 998 | \value JisB3 |
| 999 | \value JisB4 |
| 1000 | \value JisB5 |
| 1001 | \value JisB6, |
| 1002 | \value JisB7 |
| 1003 | \value JisB8 |
| 1004 | \value JisB9 |
| 1005 | \value JisB10 |
| 1006 | \value AnsiA = Letter |
| 1007 | \value AnsiB = Ledger |
| 1008 | \value AnsiC |
| 1009 | \value AnsiD |
| 1010 | \value AnsiE |
| 1011 | \value LegalExtra |
| 1012 | \value LetterExtra |
| 1013 | \value LetterPlus |
| 1014 | \value LetterSmall |
| 1015 | \value TabloidExtra |
| 1016 | \value ArchA |
| 1017 | \value ArchB |
| 1018 | \value ArchC |
| 1019 | \value ArchD |
| 1020 | \value ArchE |
| 1021 | \value Imperial7x9 |
| 1022 | \value Imperial8x10 |
| 1023 | \value Imperial9x11 |
| 1024 | \value Imperial9x12 |
| 1025 | \value Imperial10x11 |
| 1026 | \value Imperial10x13 |
| 1027 | \value Imperial10x14 |
| 1028 | \value Imperial12x11 |
| 1029 | \value Imperial15x11 |
| 1030 | \value ExecutiveStandard |
| 1031 | \value Note |
| 1032 | \value Quarto |
| 1033 | \value Statement |
| 1034 | \value SuperA |
| 1035 | \value SuperB |
| 1036 | \value Postcard |
| 1037 | \value DoublePostcard |
| 1038 | \value Prc16K |
| 1039 | \value Prc32K |
| 1040 | \value Prc32KBig |
| 1041 | \value FanFoldUS |
| 1042 | \value FanFoldGerman |
| 1043 | \value FanFoldGermanLegal |
| 1044 | \value EnvelopeB4 |
| 1045 | \value EnvelopeB5 |
| 1046 | \value EnvelopeB6 |
| 1047 | \value EnvelopeC0 |
| 1048 | \value EnvelopeC1 |
| 1049 | \value EnvelopeC2 |
| 1050 | \value EnvelopeC3 |
| 1051 | \value EnvelopeC4 |
| 1052 | \value EnvelopeC5 = C5E |
| 1053 | \value EnvelopeC6 |
| 1054 | \value EnvelopeC65 |
| 1055 | \value EnvelopeC7 |
| 1056 | \value EnvelopeDL = DLE |
| 1057 | \value Envelope9 |
| 1058 | \value Envelope10 = Comm10E |
| 1059 | \value Envelope11 |
| 1060 | \value Envelope12 |
| 1061 | \value Envelope14 |
| 1062 | \value EnvelopeMonarch |
| 1063 | \value EnvelopePersonal |
| 1064 | \value EnvelopeChou3 |
| 1065 | \value EnvelopeChou4 |
| 1066 | \value EnvelopeInvite |
| 1067 | \value EnvelopeItalian |
| 1068 | \value EnvelopeKaku2 |
| 1069 | \value EnvelopeKaku3 |
| 1070 | \value EnvelopePrc1 |
| 1071 | \value EnvelopePrc2 |
| 1072 | \value EnvelopePrc3 |
| 1073 | \value EnvelopePrc4 |
| 1074 | \value EnvelopePrc5 |
| 1075 | \value EnvelopePrc6 |
| 1076 | \value EnvelopePrc7 |
| 1077 | \value EnvelopePrc8 |
| 1078 | \value EnvelopePrc9 |
| 1079 | \value EnvelopePrc10 |
| 1080 | \value EnvelopeYou4 |
| 1081 | \value LastPageSize = EnvelopeYou4 |
| 1082 | \omitvalue NPageSize |
| 1083 | \omitvalue NPaperSize |
| 1084 | |
| 1085 | Due to historic reasons QPageSize::Executive is not the same as the standard |
| 1086 | Postscript and Windows Executive size, use QPageSize::ExecutiveStandard instead. |
| 1087 | |
| 1088 | The Postscript standard size QPageSize::Folio is different to the Windows |
| 1089 | DMPAPER_FOLIO size, use the Postscript standard size QPageSize::FanFoldGermanLegal |
| 1090 | if needed. |
| 1091 | */ |
| 1092 | |
| 1093 | /*! |
| 1094 | \enum QPageSize::Unit |
| 1095 | |
| 1096 | This enum type is used to specify the measurement unit for page sizes. |
| 1097 | |
| 1098 | \value Millimeter |
| 1099 | \value Point 1/72th of an inch |
| 1100 | \value Inch |
| 1101 | \value Pica 1/72th of a foot, 1/6th of an inch, 12 Points |
| 1102 | \value Didot 1/72th of a French inch, 0.375 mm |
| 1103 | \value Cicero 1/6th of a French inch, 12 Didot, 4.5mm |
| 1104 | */ |
| 1105 | |
| 1106 | /*! |
| 1107 | \enum QPageSize::SizeMatchPolicy |
| 1108 | |
| 1109 | \value FuzzyMatch Match to a standard page size if within the margin of tolerance. |
| 1110 | \value FuzzyOrientationMatch Match to a standard page size if within the margin of tolerance regardless of orientation. |
| 1111 | \value ExactMatch Only match to a standard page size if the sizes match exactly. |
| 1112 | */ |
| 1113 | |
| 1114 | /*! |
| 1115 | Creates a null QPageSize. |
| 1116 | */ |
| 1117 | |
| 1118 | QPageSize::QPageSize() |
| 1119 | : d(new QPageSizePrivate()) |
| 1120 | { |
| 1121 | } |
| 1122 | |
| 1123 | /*! |
| 1124 | Creates a QPageSize of the standard \a pageSize. |
| 1125 | |
| 1126 | If \a pageSize is QPageSize::Custom then the resulting QPageSize will not |
| 1127 | be valid. Use the custom size constructor instead. |
| 1128 | */ |
| 1129 | |
| 1130 | QPageSize::QPageSize(PageSizeId pageSize) |
| 1131 | : d(new QPageSizePrivate(pageSize)) |
| 1132 | { |
| 1133 | } |
| 1134 | |
| 1135 | /*! |
| 1136 | Creates a QPageSize of the given \a pointSize in Points using the matching \a matchPolicy. |
| 1137 | |
| 1138 | If the given \a pointSize matches a standard QPageSize::PageSizeId, then that page |
| 1139 | size will be used. Note that if the \a matchPolicy is FuzzyMatch this may result |
| 1140 | in the \a pointSize being adjusted to the standard size. To prevent this happening |
| 1141 | use a \a matchPolicy of ExactMatch instead. |
| 1142 | |
| 1143 | If the given \a pointSize is not a standard QPageSize::PageSizeId then a QPageSize::Custom |
| 1144 | size will be created. |
| 1145 | |
| 1146 | If \a name is null then the standard localized name will be used. If a custom page |
| 1147 | size then a custom name in the format "Custom (width x height)" will be created. |
| 1148 | |
| 1149 | The \a matchPolicy defaults to FuzzyMatch. |
| 1150 | */ |
| 1151 | |
| 1152 | QPageSize::QPageSize(const QSize &pointSize, const QString &name, SizeMatchPolicy matchPolicy) |
| 1153 | : d(new QPageSizePrivate(pointSize, name, matchPolicy)) |
| 1154 | { |
| 1155 | } |
| 1156 | |
| 1157 | /*! |
| 1158 | Creates a custom page of the given \a size in \a units. |
| 1159 | |
| 1160 | If the given \a size matches a standard QPageSize::PageSizeId, then that page |
| 1161 | size will be used. Note that if the \a matchPolicy is FuzzyMatch this may result |
| 1162 | in the \a size being adjusted to the standard size. To prevent this happening |
| 1163 | use a \a matchPolicy of ExactMatch instead. |
| 1164 | |
| 1165 | If the given \a size is not a standard QPageSize::PageSizeId then a QPageSize::Custom |
| 1166 | size will be created. The original unit size will be preserved and used as the |
| 1167 | base for all other unit size calculations. |
| 1168 | |
| 1169 | If \a name is null then a custom name will be created in the form |
| 1170 | "Custom (width x height)" where the size is expressed in units provided. |
| 1171 | */ |
| 1172 | |
| 1173 | QPageSize::QPageSize(const QSizeF &size, Unit units, |
| 1174 | const QString &name, SizeMatchPolicy matchPolicy) |
| 1175 | : d(new QPageSizePrivate(size, units, name, matchPolicy)) |
| 1176 | { |
| 1177 | } |
| 1178 | |
| 1179 | /*! |
| 1180 | \internal |
| 1181 | |
| 1182 | Create page with given key, size and name, for use by printer plugin. |
| 1183 | */ |
| 1184 | |
| 1185 | QPageSize::QPageSize(const QString &key, const QSize &pointSize, const QString &name) |
| 1186 | : d(new QPageSizePrivate(key, pointSize, name)) |
| 1187 | { |
| 1188 | } |
| 1189 | |
| 1190 | /*! |
| 1191 | \internal |
| 1192 | |
| 1193 | Create page with given windows ID, size and name, for use by printer plugin. |
| 1194 | */ |
| 1195 | |
| 1196 | QPageSize::QPageSize(int windowsId, const QSize &pointSize, const QString &name) |
| 1197 | : d(new QPageSizePrivate(windowsId, pointSize, name)) |
| 1198 | { |
| 1199 | } |
| 1200 | |
| 1201 | /*! |
| 1202 | \internal |
| 1203 | |
| 1204 | Create page with given private backend |
| 1205 | */ |
| 1206 | |
| 1207 | QPageSize::QPageSize(QPageSizePrivate &dd) |
| 1208 | : d(&dd) |
| 1209 | { |
| 1210 | } |
| 1211 | |
| 1212 | /*! |
| 1213 | Copy constructor, copies \a other to this. |
| 1214 | */ |
| 1215 | |
| 1216 | QPageSize::QPageSize(const QPageSize &other) |
| 1217 | : d(other.d) |
| 1218 | { |
| 1219 | } |
| 1220 | |
| 1221 | /*! |
| 1222 | Destroys the page. |
| 1223 | */ |
| 1224 | |
| 1225 | QPageSize::~QPageSize() |
| 1226 | { |
| 1227 | } |
| 1228 | |
| 1229 | /*! |
| 1230 | Assignment operator, assigns \a other to this. |
| 1231 | */ |
| 1232 | |
| 1233 | QPageSize &QPageSize::operator=(const QPageSize &other) |
| 1234 | { |
| 1235 | d = other.d; |
| 1236 | return *this; |
| 1237 | } |
| 1238 | |
| 1239 | /*! |
| 1240 | \fn void QPageSize::swap(QPageSize &other) |
| 1241 | |
| 1242 | Swaps this QPageSize with \a other. This function is very fast and |
| 1243 | never fails. |
| 1244 | */ |
| 1245 | |
| 1246 | /*! |
| 1247 | \fn QPageSize &QPageSize::operator=(QPageSize &&other) |
| 1248 | |
| 1249 | Move-assigns \a other to this QPageSize instance, transferring the |
| 1250 | ownership of the managed pointer to this instance. |
| 1251 | */ |
| 1252 | |
| 1253 | /*! |
| 1254 | \relates QPageSize |
| 1255 | |
| 1256 | Returns \c true if page size \a lhs is equal to page size \a rhs, |
| 1257 | i.e. if the page sizes have the same attributes. Current |
| 1258 | attributes are size and name. |
| 1259 | */ |
| 1260 | |
| 1261 | bool operator==(const QPageSize &lhs, const QPageSize &rhs) |
| 1262 | { |
| 1263 | return lhs.d == rhs.d || *lhs.d == *rhs.d; |
| 1264 | } |
| 1265 | /*! |
| 1266 | \fn bool operator!=(const QPageSize &lhs, const QPageSize &rhs) |
| 1267 | \relates QPageSize |
| 1268 | |
| 1269 | Returns \c true if page size \a lhs is unequal to page size \a |
| 1270 | rhs, i.e. if the page size has different attributes. Current |
| 1271 | attributes are size and name. |
| 1272 | */ |
| 1273 | |
| 1274 | /*! |
| 1275 | Returns \c true if this page is equivalent to the \a other page, i.e. if the |
| 1276 | page has the same size regardless of other attributes like name. |
| 1277 | */ |
| 1278 | |
| 1279 | bool QPageSize::isEquivalentTo(const QPageSize &other) const |
| 1280 | { |
| 1281 | if (d == other.d) |
| 1282 | return true; |
| 1283 | return d && other.d && d->isEquivalentTo(other: *other.d); |
| 1284 | } |
| 1285 | |
| 1286 | /*! |
| 1287 | Returns \c true if this page size is valid. |
| 1288 | |
| 1289 | The page size may be invalid if created with an invalid PageSizeId, or a |
| 1290 | negative or invalid QSize or QSizeF, or the null constructor. |
| 1291 | */ |
| 1292 | |
| 1293 | bool QPageSize::isValid() const |
| 1294 | { |
| 1295 | return d && d->isValid(); |
| 1296 | } |
| 1297 | |
| 1298 | /*! |
| 1299 | Returns the unique key of the page size. |
| 1300 | |
| 1301 | By default this is the PPD standard mediaOption keyword for the page size, |
| 1302 | or the PPD custom format key. If the QPageSize instance was obtained from |
| 1303 | a print device then this will be the key provided by the print device and |
| 1304 | may differ from the standard key. |
| 1305 | |
| 1306 | If the QPageSize is invalid then the key will be an empty string. |
| 1307 | |
| 1308 | This key should never be shown to end users, it is an internal key only. |
| 1309 | For a human-readable name use name(). |
| 1310 | |
| 1311 | \sa name() |
| 1312 | */ |
| 1313 | |
| 1314 | QString QPageSize::key() const |
| 1315 | { |
| 1316 | return isValid() ? d->m_key : QString(); |
| 1317 | } |
| 1318 | |
| 1319 | /*! |
| 1320 | Returns a localized human-readable name for the page size. |
| 1321 | |
| 1322 | If the QPageSize instance was obtained from a print device then the name |
| 1323 | used is that provided by the print device. Note that a print device may |
| 1324 | not support the current default locale language. |
| 1325 | |
| 1326 | If the QPageSize is invalid then the name will be an empty string. |
| 1327 | */ |
| 1328 | |
| 1329 | QString QPageSize::name() const |
| 1330 | { |
| 1331 | return isValid() ? d->m_name : QString(); |
| 1332 | } |
| 1333 | |
| 1334 | /*! |
| 1335 | Returns the standard QPageSize::PageSizeId of the page, or QPageSize::Custom. |
| 1336 | |
| 1337 | If the QPageSize is invalid then the ID will be QPageSize::Custom. |
| 1338 | */ |
| 1339 | |
| 1340 | QPageSize::PageSizeId QPageSize::id() const |
| 1341 | { |
| 1342 | return isValid() ? d->m_id : Custom; |
| 1343 | } |
| 1344 | |
| 1345 | /*! |
| 1346 | Returns the Windows DMPAPER enum value for the page size. |
| 1347 | |
| 1348 | Not all valid PPD page sizes have a Windows equivalent, in which case 0 |
| 1349 | will be returned. |
| 1350 | |
| 1351 | If the QPageSize is invalid then the Windows ID will be 0. |
| 1352 | |
| 1353 | \sa id() |
| 1354 | */ |
| 1355 | |
| 1356 | int QPageSize::windowsId() const |
| 1357 | { |
| 1358 | if (!isValid()) |
| 1359 | return 0; |
| 1360 | return d->m_windowsId > 0 ? d->m_windowsId : windowsId(pageSizeId: d->m_id); |
| 1361 | } |
| 1362 | |
| 1363 | /*! |
| 1364 | Returns the definition size of the page size. |
| 1365 | |
| 1366 | For a standard page size this will be the size as defined in the relevant |
| 1367 | standard, i.e. ISO A4 will be defined in millimeters while ANSI Letter will |
| 1368 | be defined in inches. |
| 1369 | |
| 1370 | For a custom page size this will be the original size used to create the |
| 1371 | page size object. |
| 1372 | |
| 1373 | If the QPageSize is invalid then the QSizeF will be invalid. |
| 1374 | |
| 1375 | \sa definitionUnits() |
| 1376 | */ |
| 1377 | |
| 1378 | QSizeF QPageSize::definitionSize() const |
| 1379 | { |
| 1380 | return isValid() ? d->m_size : QSizeF(); |
| 1381 | } |
| 1382 | |
| 1383 | /*! |
| 1384 | Returns the definition units of the page size. |
| 1385 | |
| 1386 | For a standard page size this will be the units as defined in the relevant |
| 1387 | standard, i.e. ISO A4 will be defined in millimeters while ANSI Letter will |
| 1388 | be defined in inches. |
| 1389 | |
| 1390 | For a custom page size this will be the original units used to create the |
| 1391 | page size object. |
| 1392 | |
| 1393 | If the QPageSize is invalid then the QPageSize::Unit will be invalid. |
| 1394 | |
| 1395 | \sa definitionSize() |
| 1396 | */ |
| 1397 | |
| 1398 | QPageSize::Unit QPageSize::definitionUnits() const |
| 1399 | { |
| 1400 | return isValid() ? d->m_units : Unit(-1); |
| 1401 | } |
| 1402 | |
| 1403 | /*! |
| 1404 | Returns the size of the page in the required \a units. |
| 1405 | |
| 1406 | If the QPageSize is invalid then the QSizeF will be invalid. |
| 1407 | */ |
| 1408 | |
| 1409 | QSizeF QPageSize::size(Unit units) const |
| 1410 | { |
| 1411 | return isValid() ? d->size(units) : QSize(); |
| 1412 | } |
| 1413 | |
| 1414 | /*! |
| 1415 | Returns the size of the page in Postscript Points (1/72 of an inch). |
| 1416 | |
| 1417 | If the QPageSize is invalid then the QSize will be invalid. |
| 1418 | */ |
| 1419 | |
| 1420 | QSize QPageSize::sizePoints() const |
| 1421 | { |
| 1422 | return isValid() ? d->m_pointSize : QSize(); |
| 1423 | } |
| 1424 | |
| 1425 | /*! |
| 1426 | Returns the size of the page in Device Pixels at the given \a resolution. |
| 1427 | |
| 1428 | If the QPageSize is invalid then the QSize will be invalid. |
| 1429 | */ |
| 1430 | |
| 1431 | QSize QPageSize::sizePixels(int resolution) const |
| 1432 | { |
| 1433 | return isValid() ? d->sizePixels(resolution) : QSize(); |
| 1434 | } |
| 1435 | |
| 1436 | /*! |
| 1437 | Returns the page rectangle in the required \a units. |
| 1438 | |
| 1439 | If the QPageSize is invalid then the QRect will be invalid. |
| 1440 | */ |
| 1441 | |
| 1442 | QRectF QPageSize::rect(Unit units) const |
| 1443 | { |
| 1444 | return isValid() ? QRectF(QPointF(0, 0), d->size(units)) : QRectF(); |
| 1445 | } |
| 1446 | |
| 1447 | /*! |
| 1448 | Returns the page rectangle in Postscript Points (1/72 of an inch). |
| 1449 | |
| 1450 | If the QPageSize is invalid then the QRect will be invalid. |
| 1451 | */ |
| 1452 | |
| 1453 | QRect QPageSize::rectPoints() const |
| 1454 | { |
| 1455 | return isValid() ? QRect(QPoint(0, 0), d->m_pointSize) : QRect(); |
| 1456 | } |
| 1457 | |
| 1458 | /*! |
| 1459 | Returns the page rectangle in Device Pixels at the given \a resolution. |
| 1460 | |
| 1461 | If the QPageSize is invalid then the QRect will be invalid. |
| 1462 | */ |
| 1463 | |
| 1464 | QRect QPageSize::rectPixels(int resolution) const |
| 1465 | { |
| 1466 | return isValid() ? QRect(QPoint(0, 0), d->sizePixels(resolution)) : QRect(); |
| 1467 | } |
| 1468 | |
| 1469 | // Statics |
| 1470 | |
| 1471 | /*! |
| 1472 | Returns the PPD mediaOption keyword of the standard \a pageSizeId. |
| 1473 | |
| 1474 | If the QPageSize is invalid then the key will be empty. |
| 1475 | */ |
| 1476 | |
| 1477 | QString QPageSize::key(PageSizeId pageSizeId) |
| 1478 | { |
| 1479 | if (unsigned(pageSizeId) > unsigned(LastPageSize)) |
| 1480 | return QString(); |
| 1481 | return QString::fromUtf8(str: qt_pageSizes[pageSizeId].mediaOption); |
| 1482 | } |
| 1483 | |
| 1484 | static QString msgImperialPageSizeInch(int width, int height) |
| 1485 | { |
| 1486 | //: Page size in 'Inch'. |
| 1487 | return QCoreApplication::translate(context: "QPageSize" , key: "%1 x %2 in" ).arg(a: width).arg(a: height); |
| 1488 | } |
| 1489 | |
| 1490 | /*! |
| 1491 | Returns the localized name of the standard \a pageSizeId. |
| 1492 | |
| 1493 | If the QPageSize is invalid then the name will be empty. |
| 1494 | */ |
| 1495 | |
| 1496 | QString QPageSize::name(PageSizeId pageSizeId) |
| 1497 | { |
| 1498 | if (unsigned(pageSizeId) > unsigned(LastPageSize)) |
| 1499 | return QString(); |
| 1500 | |
| 1501 | switch (pageSizeId) { |
| 1502 | case A0: |
| 1503 | return QCoreApplication::translate(context: "QPageSize" , key: "A0" ); |
| 1504 | case A1: |
| 1505 | return QCoreApplication::translate(context: "QPageSize" , key: "A1" ); |
| 1506 | case A2: |
| 1507 | return QCoreApplication::translate(context: "QPageSize" , key: "A2" ); |
| 1508 | case A3: |
| 1509 | return QCoreApplication::translate(context: "QPageSize" , key: "A3" ); |
| 1510 | case A4: |
| 1511 | return QCoreApplication::translate(context: "QPageSize" , key: "A4" ); |
| 1512 | case A5: |
| 1513 | return QCoreApplication::translate(context: "QPageSize" , key: "A5" ); |
| 1514 | case A6: |
| 1515 | return QCoreApplication::translate(context: "QPageSize" , key: "A6" ); |
| 1516 | case A7: |
| 1517 | return QCoreApplication::translate(context: "QPageSize" , key: "A7" ); |
| 1518 | case A8: |
| 1519 | return QCoreApplication::translate(context: "QPageSize" , key: "A8" ); |
| 1520 | case A9: |
| 1521 | return QCoreApplication::translate(context: "QPageSize" , key: "A9" ); |
| 1522 | case A10: |
| 1523 | return QCoreApplication::translate(context: "QPageSize" , key: "A10" ); |
| 1524 | case B0: |
| 1525 | return QCoreApplication::translate(context: "QPageSize" , key: "B0" ); |
| 1526 | case B1: |
| 1527 | return QCoreApplication::translate(context: "QPageSize" , key: "B1" ); |
| 1528 | case B2: |
| 1529 | return QCoreApplication::translate(context: "QPageSize" , key: "B2" ); |
| 1530 | case B3: |
| 1531 | return QCoreApplication::translate(context: "QPageSize" , key: "B3" ); |
| 1532 | case B4: |
| 1533 | return QCoreApplication::translate(context: "QPageSize" , key: "B4" ); |
| 1534 | case B5: |
| 1535 | return QCoreApplication::translate(context: "QPageSize" , key: "B5" ); |
| 1536 | case B6: |
| 1537 | return QCoreApplication::translate(context: "QPageSize" , key: "B6" ); |
| 1538 | case B7: |
| 1539 | return QCoreApplication::translate(context: "QPageSize" , key: "B7" ); |
| 1540 | case B8: |
| 1541 | return QCoreApplication::translate(context: "QPageSize" , key: "B8" ); |
| 1542 | case B9: |
| 1543 | return QCoreApplication::translate(context: "QPageSize" , key: "B9" ); |
| 1544 | case B10: |
| 1545 | return QCoreApplication::translate(context: "QPageSize" , key: "B10" ); |
| 1546 | case Executive: |
| 1547 | return QCoreApplication::translate(context: "QPageSize" , key: "Executive (7.5 x 10 in)" ); |
| 1548 | case ExecutiveStandard: |
| 1549 | return QCoreApplication::translate(context: "QPageSize" , key: "Executive (7.25 x 10.5 in)" ); |
| 1550 | case Folio: |
| 1551 | return QCoreApplication::translate(context: "QPageSize" , key: "Folio (8.27 x 13 in)" ); |
| 1552 | case Legal: |
| 1553 | return QCoreApplication::translate(context: "QPageSize" , key: "Legal" ); |
| 1554 | case Letter: |
| 1555 | return QCoreApplication::translate(context: "QPageSize" , key: "Letter / ANSI A" ); |
| 1556 | case Tabloid: |
| 1557 | return QCoreApplication::translate(context: "QPageSize" , key: "Tabloid / ANSI B" ); |
| 1558 | case Ledger: |
| 1559 | return QCoreApplication::translate(context: "QPageSize" , key: "Ledger / ANSI B" ); |
| 1560 | case Custom: |
| 1561 | return QCoreApplication::translate(context: "QPageSize" , key: "Custom" ); |
| 1562 | case A3Extra: |
| 1563 | return QCoreApplication::translate(context: "QPageSize" , key: "A3 Extra" ); |
| 1564 | case A4Extra: |
| 1565 | return QCoreApplication::translate(context: "QPageSize" , key: "A4 Extra" ); |
| 1566 | case A4Plus: |
| 1567 | return QCoreApplication::translate(context: "QPageSize" , key: "A4 Plus" ); |
| 1568 | case A4Small: |
| 1569 | return QCoreApplication::translate(context: "QPageSize" , key: "A4 Small" ); |
| 1570 | case A5Extra: |
| 1571 | return QCoreApplication::translate(context: "QPageSize" , key: "A5 Extra" ); |
| 1572 | case B5Extra: |
| 1573 | return QCoreApplication::translate(context: "QPageSize" , key: "B5 Extra" ); |
| 1574 | case JisB0: |
| 1575 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B0" ); |
| 1576 | case JisB1: |
| 1577 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B1" ); |
| 1578 | case JisB2: |
| 1579 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B2" ); |
| 1580 | case JisB3: |
| 1581 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B3" ); |
| 1582 | case JisB4: |
| 1583 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B4" ); |
| 1584 | case JisB5: |
| 1585 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B5" ); |
| 1586 | case JisB6: |
| 1587 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B6" ); |
| 1588 | case JisB7: |
| 1589 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B7" ); |
| 1590 | case JisB8: |
| 1591 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B8" ); |
| 1592 | case JisB9: |
| 1593 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B9" ); |
| 1594 | case JisB10: |
| 1595 | return QCoreApplication::translate(context: "QPageSize" , key: "JIS B10" ); |
| 1596 | case AnsiC: |
| 1597 | return QCoreApplication::translate(context: "QPageSize" , key: "ANSI C" ); |
| 1598 | case AnsiD: |
| 1599 | return QCoreApplication::translate(context: "QPageSize" , key: "ANSI D" ); |
| 1600 | case AnsiE: |
| 1601 | return QCoreApplication::translate(context: "QPageSize" , key: "ANSI E" ); |
| 1602 | case LegalExtra: |
| 1603 | return QCoreApplication::translate(context: "QPageSize" , key: "Legal Extra" ); |
| 1604 | case LetterExtra: |
| 1605 | return QCoreApplication::translate(context: "QPageSize" , key: "Letter Extra" ); |
| 1606 | case LetterPlus: |
| 1607 | return QCoreApplication::translate(context: "QPageSize" , key: "Letter Plus" ); |
| 1608 | case LetterSmall: |
| 1609 | return QCoreApplication::translate(context: "QPageSize" , key: "Letter Small" ); |
| 1610 | case TabloidExtra: |
| 1611 | return QCoreApplication::translate(context: "QPageSize" , key: "Tabloid Extra" ); |
| 1612 | case ArchA: |
| 1613 | return QCoreApplication::translate(context: "QPageSize" , key: "Architect A" ); |
| 1614 | case ArchB: |
| 1615 | return QCoreApplication::translate(context: "QPageSize" , key: "Architect B" ); |
| 1616 | case ArchC: |
| 1617 | return QCoreApplication::translate(context: "QPageSize" , key: "Architect C" ); |
| 1618 | case ArchD: |
| 1619 | return QCoreApplication::translate(context: "QPageSize" , key: "Architect D" ); |
| 1620 | case ArchE: |
| 1621 | return QCoreApplication::translate(context: "QPageSize" , key: "Architect E" ); |
| 1622 | case Imperial7x9: |
| 1623 | return msgImperialPageSizeInch(width: 7, height: 9); |
| 1624 | case Imperial8x10: |
| 1625 | return msgImperialPageSizeInch(width: 8, height: 10); |
| 1626 | case Imperial9x11: |
| 1627 | return msgImperialPageSizeInch(width: 9, height: 11); |
| 1628 | case Imperial9x12: |
| 1629 | return msgImperialPageSizeInch(width: 9, height: 12); |
| 1630 | case Imperial10x11: |
| 1631 | return msgImperialPageSizeInch(width: 10, height: 11); |
| 1632 | case Imperial10x13: |
| 1633 | return msgImperialPageSizeInch(width: 10, height: 13); |
| 1634 | case Imperial10x14: |
| 1635 | return msgImperialPageSizeInch(width: 10, height: 14); |
| 1636 | case Imperial12x11: |
| 1637 | return msgImperialPageSizeInch(width: 12, height: 11); |
| 1638 | case Imperial15x11: |
| 1639 | return msgImperialPageSizeInch(width: 15, height: 11); |
| 1640 | case Note: |
| 1641 | return QCoreApplication::translate(context: "QPageSize" , key: "Note" ); |
| 1642 | case Quarto: |
| 1643 | return QCoreApplication::translate(context: "QPageSize" , key: "Quarto" ); |
| 1644 | case Statement: |
| 1645 | return QCoreApplication::translate(context: "QPageSize" , key: "Statement" ); |
| 1646 | case SuperA: |
| 1647 | return QCoreApplication::translate(context: "QPageSize" , key: "Super A" ); |
| 1648 | case SuperB: |
| 1649 | return QCoreApplication::translate(context: "QPageSize" , key: "Super B" ); |
| 1650 | case Postcard: |
| 1651 | return QCoreApplication::translate(context: "QPageSize" , key: "Postcard" ); |
| 1652 | case DoublePostcard: |
| 1653 | return QCoreApplication::translate(context: "QPageSize" , key: "Double Postcard" ); |
| 1654 | case Prc16K: |
| 1655 | return QCoreApplication::translate(context: "QPageSize" , key: "PRC 16K" ); |
| 1656 | case Prc32K: |
| 1657 | return QCoreApplication::translate(context: "QPageSize" , key: "PRC 32K" ); |
| 1658 | case Prc32KBig: |
| 1659 | return QCoreApplication::translate(context: "QPageSize" , key: "PRC 32K Big" ); |
| 1660 | case FanFoldUS: |
| 1661 | return QCoreApplication::translate(context: "QPageSize" , key: "Fan-fold US (14.875 x 11 in)" ); |
| 1662 | case FanFoldGerman: |
| 1663 | return QCoreApplication::translate(context: "QPageSize" , key: "Fan-fold German (8.5 x 12 in)" ); |
| 1664 | case FanFoldGermanLegal: |
| 1665 | return QCoreApplication::translate(context: "QPageSize" , key: "Fan-fold German Legal (8.5 x 13 in)" ); |
| 1666 | case EnvelopeB4: |
| 1667 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope B4" ); |
| 1668 | case EnvelopeB5: |
| 1669 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope B5" ); |
| 1670 | case EnvelopeB6: |
| 1671 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope B6" ); |
| 1672 | case EnvelopeC0: |
| 1673 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C0" ); |
| 1674 | case EnvelopeC1: |
| 1675 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C1" ); |
| 1676 | case EnvelopeC2: |
| 1677 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C2" ); |
| 1678 | case EnvelopeC3: |
| 1679 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C3" ); |
| 1680 | case EnvelopeC4: |
| 1681 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C4" ); |
| 1682 | case EnvelopeC5: // C5E |
| 1683 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C5" ); |
| 1684 | case EnvelopeC6: |
| 1685 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C6" ); |
| 1686 | case EnvelopeC65: |
| 1687 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C65" ); |
| 1688 | case EnvelopeC7: |
| 1689 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope C7" ); |
| 1690 | case EnvelopeDL: // DLE: |
| 1691 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope DL" ); |
| 1692 | case Envelope9: |
| 1693 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope US 9" ); |
| 1694 | case Envelope10: // Comm10E |
| 1695 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope US 10" ); |
| 1696 | case Envelope11: |
| 1697 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope US 11" ); |
| 1698 | case Envelope12: |
| 1699 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope US 12" ); |
| 1700 | case Envelope14: |
| 1701 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope US 14" ); |
| 1702 | case EnvelopeMonarch: |
| 1703 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Monarch" ); |
| 1704 | case EnvelopePersonal: |
| 1705 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Personal" ); |
| 1706 | case EnvelopeChou3: |
| 1707 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Chou 3" ); |
| 1708 | case EnvelopeChou4: |
| 1709 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Chou 4" ); |
| 1710 | case EnvelopeInvite: |
| 1711 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Invite" ); |
| 1712 | case EnvelopeItalian: |
| 1713 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Italian" ); |
| 1714 | case EnvelopeKaku2: |
| 1715 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Kaku 2" ); |
| 1716 | case EnvelopeKaku3: |
| 1717 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope Kaku 3" ); |
| 1718 | case EnvelopePrc1: |
| 1719 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 1" ); |
| 1720 | case EnvelopePrc2: |
| 1721 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 2" ); |
| 1722 | case EnvelopePrc3: |
| 1723 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 3" ); |
| 1724 | case EnvelopePrc4: |
| 1725 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 4" ); |
| 1726 | case EnvelopePrc5: |
| 1727 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 5" ); |
| 1728 | case EnvelopePrc6: |
| 1729 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 6" ); |
| 1730 | case EnvelopePrc7: |
| 1731 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 7" ); |
| 1732 | case EnvelopePrc8: |
| 1733 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 8" ); |
| 1734 | case EnvelopePrc9: |
| 1735 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 9" ); |
| 1736 | case EnvelopePrc10: |
| 1737 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope PRC 10" ); |
| 1738 | case EnvelopeYou4: |
| 1739 | return QCoreApplication::translate(context: "QPageSize" , key: "Envelope You 4" ); |
| 1740 | } |
| 1741 | return QString(); |
| 1742 | } |
| 1743 | |
| 1744 | /*! |
| 1745 | Returns the standard QPageSize::PageSizeId of the given \a pointSize in |
| 1746 | points using the given \a matchPolicy. |
| 1747 | |
| 1748 | If using FuzzyMatch then the point size of the PageSizeId returned may not |
| 1749 | exactly match the \a pointSize you passed in. You should call |
| 1750 | QPageSize::sizePoints() using the returned PageSizeId to find out the actual |
| 1751 | point size of the PageSizeId before using it in any calculations. |
| 1752 | */ |
| 1753 | |
| 1754 | QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, SizeMatchPolicy matchPolicy) |
| 1755 | { |
| 1756 | return qt_idForPointSize(size: pointSize, matchPolicy, match: nullptr); |
| 1757 | } |
| 1758 | |
| 1759 | /*! |
| 1760 | Returns the standard QPageSize::PageSizeId of the given \a size in \a units |
| 1761 | using the given \a matchPolicy. |
| 1762 | |
| 1763 | If using FuzzyMatch then the unit size of the PageSizeId returned may not |
| 1764 | exactly match the \a size you passed in. You should call |
| 1765 | QPageSize::size() using the returned PageSizeId to find out the actual |
| 1766 | unit size of the PageSizeId before using it in any calculations. |
| 1767 | */ |
| 1768 | |
| 1769 | QPageSize::PageSizeId QPageSize::id(const QSizeF &size, Unit units, |
| 1770 | SizeMatchPolicy matchPolicy) |
| 1771 | { |
| 1772 | return qt_idForSize(size, units, matchPolicy, match: nullptr); |
| 1773 | } |
| 1774 | |
| 1775 | /*! |
| 1776 | Returns the PageSizeId for the given Windows DMPAPER enum value \a windowsId. |
| 1777 | |
| 1778 | If there is no matching PageSizeId then QPageSize::Custom is returned. |
| 1779 | */ |
| 1780 | |
| 1781 | QPageSize::PageSizeId QPageSize::id(int windowsId) |
| 1782 | { |
| 1783 | return qt_idForWindowsID(windowsId); |
| 1784 | } |
| 1785 | |
| 1786 | /*! |
| 1787 | Returns the Windows DMPAPER enum value of the standard \a pageSizeId. |
| 1788 | |
| 1789 | Not all valid PPD page sizes have a Windows equivalent, in which case 0 |
| 1790 | will be returned. |
| 1791 | */ |
| 1792 | |
| 1793 | int QPageSize::windowsId(PageSizeId pageSizeId) |
| 1794 | { |
| 1795 | return qt_pageSizes[pageSizeId].windowsId; |
| 1796 | } |
| 1797 | |
| 1798 | /*! |
| 1799 | Returns the definition size of the standard \a pageSizeId. |
| 1800 | |
| 1801 | To obtain the definition units, call QPageSize::definitionUnits(). |
| 1802 | */ |
| 1803 | |
| 1804 | QSizeF QPageSize::definitionSize(PageSizeId pageSizeId) |
| 1805 | { |
| 1806 | if (pageSizeId == Custom) |
| 1807 | return QSizeF(); |
| 1808 | return qt_definitionSize(pageSizeId); |
| 1809 | } |
| 1810 | |
| 1811 | /*! |
| 1812 | Returns the definition units of the standard \a pageSizeId. |
| 1813 | |
| 1814 | To obtain the definition size, call QPageSize::definitionSize(). |
| 1815 | */ |
| 1816 | |
| 1817 | QPageSize::Unit QPageSize::definitionUnits(PageSizeId pageSizeId) |
| 1818 | { |
| 1819 | if (pageSizeId == Custom) |
| 1820 | return Unit(-1); |
| 1821 | return qt_pageSizes[pageSizeId].definitionUnits; |
| 1822 | } |
| 1823 | |
| 1824 | /*! |
| 1825 | Returns the size of the standard \a pageSizeId in the requested \a units. |
| 1826 | */ |
| 1827 | |
| 1828 | QSizeF QPageSize::size(PageSizeId pageSizeId, Unit units) |
| 1829 | { |
| 1830 | if (pageSizeId == Custom) |
| 1831 | return QSizeF(); |
| 1832 | return qt_unitSize(pageSizeId, units); |
| 1833 | } |
| 1834 | |
| 1835 | /*! |
| 1836 | Returns the size of the standard \a pageSizeId in Points. |
| 1837 | */ |
| 1838 | |
| 1839 | QSize QPageSize::sizePoints(PageSizeId pageSizeId) |
| 1840 | { |
| 1841 | if (pageSizeId == Custom) |
| 1842 | return QSize(); |
| 1843 | return QSize(qt_pageSizes[pageSizeId].widthPoints, qt_pageSizes[pageSizeId].heightPoints); |
| 1844 | } |
| 1845 | |
| 1846 | /*! |
| 1847 | Returns the size of the standard \a pageSizeId in Device Pixels |
| 1848 | for the given \a resolution. |
| 1849 | */ |
| 1850 | |
| 1851 | QSize QPageSize::sizePixels(PageSizeId pageSizeId, int resolution) |
| 1852 | { |
| 1853 | if (pageSizeId == Custom) |
| 1854 | return QSize(); |
| 1855 | return qt_convertPointsToPixels(size: sizePoints(pageSizeId), resolution); |
| 1856 | } |
| 1857 | |
| 1858 | #ifndef QT_NO_DEBUG_STREAM |
| 1859 | QDebug operator<<(QDebug dbg, const QPageSize &pageSize) |
| 1860 | { |
| 1861 | QDebugStateSaver saver(dbg); |
| 1862 | dbg.nospace(); |
| 1863 | dbg.noquote(); |
| 1864 | dbg << "QPageSize(" ; |
| 1865 | if (pageSize.isValid()) { |
| 1866 | dbg << '"' << pageSize.name() << "\", key=\"" << pageSize.key() |
| 1867 | << "\", " << pageSize.sizePoints().width() << 'x' |
| 1868 | << pageSize.sizePoints().height() << "pt, id=" << pageSize.id(); |
| 1869 | } else { |
| 1870 | dbg.nospace() << "QPageSize()" ; |
| 1871 | } |
| 1872 | dbg << ')'; |
| 1873 | return dbg; |
| 1874 | } |
| 1875 | #endif |
| 1876 | |
| 1877 | QT_END_NAMESPACE |
| 1878 | |