| 1 | ///////////////////////////////////////////////////////////////////////////////cxx . . $ `<file>/src/textprinter.cpp`/ |
| 2 | // textprinter.h |
| 3 | // ------------------- |
| 4 | // Copyright (c) 20072008 David Johnson <[email protected]> |
| 5 | // Please see the header file for copyright and license information. |
| 6 | /////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | #include "textprinter.h"cxx . . $ `<file>/src/textprinter.h`/ |
| 9 | |
| 10 | #include <QAbstractTextDocumentLayout> |
| 11 | #include <QDate> |
| 12 | #include <QFileDialog> |
| 13 | #include <QLocale> |
| 14 | #include <QPainter> |
| 15 | #include <QPrintDialog> |
| 16 | #include <QTextDocument> |
| 17 | #include <QTextFrame> |
| 18 | |
| 19 | #if (QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(4, 4, 0)) |
| 20 | #include <QPrintPreviewDialog> |
| 21 | #endif |
| 22 | |
| 23 | static inline double mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(double mm) { return mm * 0.039370147; } |
| 24 | |
| 25 | /////////////////////////////////////////////////////////////////////////////// |
| 26 | // TextPrinter() |
| 27 | /////////////////////////////////////////////////////////////////////////////// |
| 28 | /// Constructs a TextPrinter object. |
| 29 | /// Any related dialogs will be displayed centered over the parent, if it is |
| 30 | /// a QWidget object. |
| 31 | /////////////////////////////////////////////////////////////////////////////// |
| 32 | |
| 33 | TextPrintercxx . . $ TextPrinter#::TextPrintercxx . . $ TextPrinter#TextPrinter(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) |
| 34 | : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent), parent_cxx . . $ TextPrinter#parent_.(0), |
| 35 | printer_cxx . . $ TextPrinter#printer_.(new QPrintercxx . . $ QPrinter#(QPrintercxx . . $ QPrinter#::HighResolutioncxx . . $ QPrinter#HighResolution.)), tempdoc_cxx . . $ TextPrinter#tempdoc_.(0), |
| 36 | leftmargin_cxx . . $ TextPrinter#leftmargin_.(15.0), rightmargin_cxx . . $ TextPrinter#rightmargin_.(15.0), topmargin_cxx . . $ TextPrinter#topmargin_.(15.0), |
| 37 | bottommargin_cxx . . $ TextPrinter#bottommargin_.(15.0), spacing_cxx . . $ TextPrinter#spacing_.(5.0), |
| 38 | headersize_cxx . . $ TextPrinter#headersize_.(0.0), headerrule_cxx . . $ TextPrinter#headerrule_.(0.5), headertext_cxx . . $ TextPrinter#headertext_.(QStringcxx . . $ QString#QString(ced63f7c635d850d).()), |
| 39 | footersize_cxx . . $ TextPrinter#footersize_.(0.0), footerrule_cxx . . $ TextPrinter#footerrule_.(0.5), footertext_cxx . . $ TextPrinter#footertext_.(QStringcxx . . $ QString#QString(ced63f7c635d850d).()), |
| 40 | dateformat_cxx . . $ TextPrinter#dateformat_.() |
| 41 | { |
| 42 | if (parent) parent_cxx . . $ TextPrinter#parent_. = qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<QWidgetcxx . . $ QWidget#*>(parent); |
| 43 | |
| 44 | printer_cxx . . $ TextPrinter#printer_.->setFullPagecxx . . $ QPrinter#setFullPage(b45ddcbc8423892c).(true); |
| 45 | printer_cxx . . $ TextPrinter#printer_.->setOrientationcxx . . $ QPrinter#setOrientation(bebccd7395ab37d4).(QPrintercxx . . $ QPrinter#::Portraitcxx . . $ QPrinter#Portrait.); |
| 46 | |
| 47 | // for convenience, default to US_Letter for C/US/Canada |
| 48 | // NOTE: bug in Qt, this value is not loaded by QPrintDialog |
| 49 | switch (QLocalecxx . . $ QLocale#::systemcxx . . $ QLocale#system(7171962d3a2fd395).().countrycxx . . $ QLocale#country(7641c5ae9faf08d2).()) { |
| 50 | case QLocalecxx . . $ QLocale#::AnyCountrycxx . . $ QLocale#AnyCountry.: |
| 51 | case QLocalecxx . . $ QLocale#::Canadacxx . . $ QLocale#Canada.: |
| 52 | case QLocalecxx . . $ QLocale#::UnitedStatescxx . . $ QLocale#UnitedStates.: |
| 53 | case QLocalecxx . . $ QLocale#::UnitedStatesMinorOutlyingIslandscxx . . $ QLocale#UnitedStatesMinorOutlyingIslands.: |
| 54 | printer_cxx . . $ TextPrinter#printer_.->setPageSizecxx . . $ QPrinter#setPageSize(2d3228afb9a7f667).(QPrintercxx . . $ QPrinter#::Lettercxx . . $ QPagedPaintDevice#Letter.); break; |
| 55 | default: |
| 56 | printer_cxx . . $ TextPrinter#printer_.->setPageSizecxx . . $ QPrinter#setPageSize(2d3228afb9a7f667).(QPrintercxx . . $ QPrinter#::A4cxx . . $ QPagedPaintDevice#A4.); break; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /////////////////////////////////////////////////////////////////////////////// |
| 61 | // ~TextPrinter() |
| 62 | /////////////////////////////////////////////////////////////////////////////// |
| 63 | /// Destroys the TextPrinter object. |
| 64 | /////////////////////////////////////////////////////////////////////////////// |
| 65 | |
| 66 | TextPrintercxx . . $ TextPrinter#::~cxx . . $ TextPrinter#`~TextPrinter`(ced63f7c635d850d).TextPrintercxx . . $ TextPrinter#() |
| 67 | { |
| 68 | delete printer_cxx . . $ TextPrinter#printer_.; |
| 69 | } |
| 70 | |
| 71 | /////////////////////////////////////////////////////////////////////////////// |
| 72 | // pageSize() |
| 73 | /////////////////////////////////////////////////////////////////////////////// |
| 74 | /// Return the page size. This is defined by the QPrinter::PageSize |
| 75 | /// enumeration. |
| 76 | /////////////////////////////////////////////////////////////////////////////// |
| 77 | |
| 78 | QPrintercxx . . $ QPrinter#::PageSizecxx . . $ QPagedPaintDevice#PageSize# TextPrintercxx . . $ TextPrinter#::pageSizecxx . . $ TextPrinter#pageSize(61cb6e000139ab9e).() const |
| 79 | { |
| 80 | return printer_cxx . . $ TextPrinter#printer_.->pageSizecxx . . $ QPrinter#pageSize(61cb6e000139ab9e).(); |
| 81 | } |
| 82 | |
| 83 | /////////////////////////////////////////////////////////////////////////////// |
| 84 | // setPageSize() |
| 85 | /////////////////////////////////////////////////////////////////////////////// |
| 86 | /// Set the page size. Size is defined by the QPrinter::PageSize enumeration. |
| 87 | /// By default, this is QPrinter::Letter in US and Canada locales, and |
| 88 | /// QPrinter::A4 in other locales. |
| 89 | /////////////////////////////////////////////////////////////////////////////// |
| 90 | |
| 91 | void TextPrintercxx . . $ TextPrinter#::setPageSizecxx . . $ TextPrinter#setPageSize(2d3228afb9a7f667).(QPrintercxx . . $ QPrinter#::PageSizecxx . . $ QPagedPaintDevice#PageSize# size) |
| 92 | { |
| 93 | printer_cxx . . $ TextPrinter#printer_.->setPageSizecxx . . $ QPrinter#setPageSize(2d3228afb9a7f667).(size); |
| 94 | } |
| 95 | |
| 96 | /////////////////////////////////////////////////////////////////////////////// |
| 97 | // orientation() |
| 98 | /////////////////////////////////////////////////////////////////////////////// |
| 99 | /// Return the page orientation. This is defined by the QPrinterOrientation |
| 100 | /// enumeration. |
| 101 | /////////////////////////////////////////////////////////////////////////////// |
| 102 | |
| 103 | QPrintercxx . . $ QPrinter#::Orientationcxx . . $ QPrinter#Orientation# TextPrintercxx . . $ TextPrinter#::orientationcxx . . $ TextPrinter#orientation(a4823aa019839abf).() const |
| 104 | { |
| 105 | return printer_cxx . . $ TextPrinter#printer_.->orientationcxx . . $ QPrinter#orientation(a4823aa019839abf).(); |
| 106 | } |
| 107 | |
| 108 | /////////////////////////////////////////////////////////////////////////////// |
| 109 | // setOrientation() |
| 110 | /////////////////////////////////////////////////////////////////////////////// |
| 111 | /// Set the page orientation. Orientation is defined by the |
| 112 | /// QPrinter::Orientation enumeration, and can be QPrinter::Portrait (the |
| 113 | /// default) or QPrinter::Landscape. |
| 114 | /////////////////////////////////////////////////////////////////////////////// |
| 115 | |
| 116 | void TextPrintercxx . . $ TextPrinter#::setOrientationcxx . . $ TextPrinter#setOrientation(bebccd7395ab37d4).(QPrintercxx . . $ QPrinter#::Orientationcxx . . $ QPrinter#Orientation# orientation) |
| 117 | { |
| 118 | printer_cxx . . $ TextPrinter#printer_.->setOrientationcxx . . $ QPrinter#setOrientation(bebccd7395ab37d4).(orientation); |
| 119 | } |
| 120 | |
| 121 | /////////////////////////////////////////////////////////////////////////////// |
| 122 | // leftMargin() |
| 123 | /////////////////////////////////////////////////////////////////////////////// |
| 124 | /// Return the left page margin width in millimeters. |
| 125 | /////////////////////////////////////////////////////////////////////////////// |
| 126 | |
| 127 | double TextPrintercxx . . $ TextPrinter#::leftMargincxx . . $ TextPrinter#leftMargin(21b6c25e127938e2).() const |
| 128 | { |
| 129 | return leftmargin_cxx . . $ TextPrinter#leftmargin_.; |
| 130 | } |
| 131 | |
| 132 | /////////////////////////////////////////////////////////////////////////////// |
| 133 | // setLeftMargin() |
| 134 | /////////////////////////////////////////////////////////////////////////////// |
| 135 | /// Set the left margin width in millimeters. The default value is 15mm. |
| 136 | /////////////////////////////////////////////////////////////////////////////// |
| 137 | |
| 138 | void TextPrintercxx . . $ TextPrinter#::setLeftMargincxx . . $ TextPrinter#setLeftMargin(ba8836b59fb42830).(double margin) |
| 139 | { |
| 140 | if ((margin > 0) && (margin < printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().widthcxx . . $ QRect#width(ea6fe5115c70a13f).() / 2)) { |
| 141 | leftmargin_cxx . . $ TextPrinter#leftmargin_. = margin; |
| 142 | } else { |
| 143 | leftmargin_cxx . . $ TextPrinter#leftmargin_. = 0; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /////////////////////////////////////////////////////////////////////////////// |
| 148 | // rightMargin() |
| 149 | /////////////////////////////////////////////////////////////////////////////// |
| 150 | /// Return the right page margin width in millimeters. |
| 151 | /////////////////////////////////////////////////////////////////////////////// |
| 152 | |
| 153 | double TextPrintercxx . . $ TextPrinter#::rightMargincxx . . $ TextPrinter#rightMargin(21b6c25e127938e2).() const |
| 154 | { |
| 155 | return rightmargin_cxx . . $ TextPrinter#rightmargin_.; |
| 156 | } |
| 157 | |
| 158 | /////////////////////////////////////////////////////////////////////////////// |
| 159 | // setRightMargin() |
| 160 | /////////////////////////////////////////////////////////////////////////////// |
| 161 | /// Set the right margin width in millimeters. The default value is 15mm. |
| 162 | /////////////////////////////////////////////////////////////////////////////// |
| 163 | |
| 164 | void TextPrintercxx . . $ TextPrinter#::setRightMargincxx . . $ TextPrinter#setRightMargin(ba8836b59fb42830).(double margin) |
| 165 | { |
| 166 | if ((margin > 0) && (margin < printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().widthcxx . . $ QRect#width(ea6fe5115c70a13f).() / 2)) { |
| 167 | rightmargin_cxx . . $ TextPrinter#rightmargin_. = margin; |
| 168 | } else { |
| 169 | rightmargin_cxx . . $ TextPrinter#rightmargin_. = 0; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /////////////////////////////////////////////////////////////////////////////// |
| 174 | // topMargin() |
| 175 | /////////////////////////////////////////////////////////////////////////////// |
| 176 | /// Return the top page margin size in millimeters. |
| 177 | /////////////////////////////////////////////////////////////////////////////// |
| 178 | |
| 179 | double TextPrintercxx . . $ TextPrinter#::topMargincxx . . $ TextPrinter#topMargin(21b6c25e127938e2).() const |
| 180 | { |
| 181 | return topmargin_cxx . . $ TextPrinter#topmargin_.; |
| 182 | } |
| 183 | |
| 184 | /////////////////////////////////////////////////////////////////////////////// |
| 185 | // setTopMargin() |
| 186 | /////////////////////////////////////////////////////////////////////////////// |
| 187 | /// Set the top margin size in millimeters. The default value is 15mm. |
| 188 | /////////////////////////////////////////////////////////////////////////////// |
| 189 | |
| 190 | void TextPrintercxx . . $ TextPrinter#::setTopMargincxx . . $ TextPrinter#setTopMargin(ba8836b59fb42830).(double margin) |
| 191 | { |
| 192 | if ((margin > 0) && (margin < printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().heightcxx . . $ QRect#height(ea6fe5115c70a13f).() / 4)) { |
| 193 | topmargin_cxx . . $ TextPrinter#topmargin_. = margin; |
| 194 | } else { |
| 195 | topmargin_cxx . . $ TextPrinter#topmargin_. = 0; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | /////////////////////////////////////////////////////////////////////////////// |
| 200 | // bottomMargin() |
| 201 | /////////////////////////////////////////////////////////////////////////////// |
| 202 | /// Return the bottom page margin size in millimeters. |
| 203 | /////////////////////////////////////////////////////////////////////////////// |
| 204 | |
| 205 | double TextPrintercxx . . $ TextPrinter#::bottomMargincxx . . $ TextPrinter#bottomMargin(21b6c25e127938e2).() const |
| 206 | { |
| 207 | return bottommargin_cxx . . $ TextPrinter#bottommargin_.; |
| 208 | } |
| 209 | |
| 210 | /////////////////////////////////////////////////////////////////////////////// |
| 211 | // setBottomMargin() |
| 212 | /////////////////////////////////////////////////////////////////////////////// |
| 213 | /// Set the bottom margin size in millimeters. The default value is 15mm. |
| 214 | /////////////////////////////////////////////////////////////////////////////// |
| 215 | |
| 216 | void TextPrintercxx . . $ TextPrinter#::setBottomMargincxx . . $ TextPrinter#setBottomMargin(ba8836b59fb42830).(double margin) |
| 217 | { |
| 218 | if ((margin > 0) && (margin < printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().heightcxx . . $ QRect#height(ea6fe5115c70a13f).() / 4)) { |
| 219 | bottommargin_cxx . . $ TextPrinter#bottommargin_. = margin; |
| 220 | } else { |
| 221 | bottommargin_cxx . . $ TextPrinter#bottommargin_. = 0; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | /////////////////////////////////////////////////////////////////////////////// |
| 226 | // setMargins() |
| 227 | /////////////////////////////////////////////////////////////////////////////// |
| 228 | /// Set all margins to have the identical size. The default value is 15mm. |
| 229 | /////////////////////////////////////////////////////////////////////////////// |
| 230 | |
| 231 | void TextPrintercxx . . $ TextPrinter#::setMarginscxx . . $ TextPrinter#setMargins(ba8836b59fb42830).(double margin) |
| 232 | { |
| 233 | if ((margin > 0) |
| 234 | && (margin < printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().heightcxx . . $ QRect#height(ea6fe5115c70a13f).() / 2) |
| 235 | && (margin < printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().widthcxx . . $ QRect#width(ea6fe5115c70a13f).() / 2)) { |
| 236 | leftmargin_cxx . . $ TextPrinter#leftmargin_. = rightmargin_cxx . . $ TextPrinter#rightmargin_. = topmargin_cxx . . $ TextPrinter#topmargin_. = bottommargin_cxx . . $ TextPrinter#bottommargin_. = margin; |
| 237 | } else { |
| 238 | leftmargin_cxx . . $ TextPrinter#leftmargin_. = rightmargin_cxx . . $ TextPrinter#rightmargin_. = topmargin_cxx . . $ TextPrinter#topmargin_. = bottommargin_cxx . . $ TextPrinter#bottommargin_. = 0; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /////////////////////////////////////////////////////////////////////////////// |
| 243 | // spacing() |
| 244 | /////////////////////////////////////////////////////////////////////////////// |
| 245 | /// Return the spacing between the page content and the header and footer |
| 246 | /// blocks. This is defined in millimeters. |
| 247 | /////////////////////////////////////////////////////////////////////////////// |
| 248 | |
| 249 | double TextPrintercxx . . $ TextPrinter#::spacingcxx . . $ TextPrinter#spacing(21b6c25e127938e2).() const |
| 250 | { |
| 251 | return spacing_cxx . . $ TextPrinter#spacing_.; |
| 252 | } |
| 253 | |
| 254 | /////////////////////////////////////////////////////////////////////////////// |
| 255 | // setSpacing() |
| 256 | /////////////////////////////////////////////////////////////////////////////// |
| 257 | /// Set the spacing between the page content and the header and footer blocks. |
| 258 | /// The default value is 5mm. |
| 259 | /////////////////////////////////////////////////////////////////////////////// |
| 260 | |
| 261 | void TextPrintercxx . . $ TextPrinter#::setSpacingcxx . . $ TextPrinter#setSpacing(ba8836b59fb42830).(double spacing) |
| 262 | { |
| 263 | if ((spacing > 0) && (spacing <= printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().heightcxx . . $ QRect#height(ea6fe5115c70a13f).() / 8)) { |
| 264 | spacing_cxx . . $ TextPrinter#spacing_. = spacing; |
| 265 | } else { |
| 266 | spacing_cxx . . $ TextPrinter#spacing_. = 0; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | /////////////////////////////////////////////////////////////////////////////// |
| 271 | // headerSize() |
| 272 | /////////////////////////////////////////////////////////////////////////////// |
| 273 | /// Return the height of the header block in millimeters. |
| 274 | /////////////////////////////////////////////////////////////////////////////// |
| 275 | |
| 276 | double TextPrintercxx . . $ TextPrinter#::headerSizecxx . . $ TextPrinter#headerSize(21b6c25e127938e2).() const |
| 277 | { |
| 278 | return headersize_cxx . . $ TextPrinter#headersize_.; |
| 279 | } |
| 280 | |
| 281 | /////////////////////////////////////////////////////////////////////////////// |
| 282 | // setHeaderSize() |
| 283 | /////////////////////////////////////////////////////////////////////////////// |
| 284 | /// Set the height of the header in millimeters. The default is zero (no |
| 285 | /// header). |
| 286 | /////////////////////////////////////////////////////////////////////////////// |
| 287 | |
| 288 | void TextPrintercxx . . $ TextPrinter#::setHeaderSizecxx . . $ TextPrinter#setHeaderSize(ba8836b59fb42830).(double size) |
| 289 | { |
| 290 | if ((size > 0) && (size <= printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().heightcxx . . $ QRect#height(ea6fe5115c70a13f).() / 8)) { |
| 291 | headersize_cxx . . $ TextPrinter#headersize_. = size; |
| 292 | } else { |
| 293 | headersize_cxx . . $ TextPrinter#headersize_. = 0; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | /////////////////////////////////////////////////////////////////////////////// |
| 298 | // headerRule() |
| 299 | /////////////////////////////////////////////////////////////////////////////// |
| 300 | /// Return the size of the header rule in points. One point is 1/72 inch. |
| 301 | /////////////////////////////////////////////////////////////////////////////// |
| 302 | |
| 303 | double TextPrintercxx . . $ TextPrinter#::headerRulecxx . . $ TextPrinter#headerRule(21b6c25e127938e2).() const |
| 304 | { |
| 305 | return headerrule_cxx . . $ TextPrinter#headerrule_.; |
| 306 | } |
| 307 | |
| 308 | /////////////////////////////////////////////////////////////////////////////// |
| 309 | // setHeaderRule() |
| 310 | /////////////////////////////////////////////////////////////////////////////// |
| 311 | /// Set the header rule size in points. By default, the header rule is one half |
| 312 | /// point (1/144 inch). To turn off the rule, set the rule size to 0. The rule |
| 313 | /// will be drawn below the header area. |
| 314 | /////////////////////////////////////////////////////////////////////////////// |
| 315 | |
| 316 | void TextPrintercxx . . $ TextPrinter#::setHeaderRulecxx . . $ TextPrinter#setHeaderRule(ba8836b59fb42830).(double pointsize) |
| 317 | { |
| 318 | headerrule_cxx . . $ TextPrinter#headerrule_. = qMaxcxx . . $ qMax(2a338fce5842aa6a).(0.0, pointsize); |
| 319 | } |
| 320 | |
| 321 | /////////////////////////////////////////////////////////////////////////////// |
| 322 | // headerText() |
| 323 | /////////////////////////////////////////////////////////////////////////////// |
| 324 | /// Return the text for the header. |
| 325 | /////////////////////////////////////////////////////////////////////////////// |
| 326 | |
| 327 | const QStringcxx . . $ QString# &TextPrintercxx . . $ TextPrinter#::headerTextcxx . . $ TextPrinter#headerText(a2fb7a6ce195d51).() const |
| 328 | { |
| 329 | return headertext_cxx . . $ TextPrinter#headertext_.; |
| 330 | } |
| 331 | |
| 332 | /////////////////////////////////////////////////////////////////////////////// |
| 333 | // setHeaderText() |
| 334 | /////////////////////////////////////////////////////////////////////////////// |
| 335 | /// Set the text for the header. Rich text is supported. HTML tags may be used |
| 336 | /// to format the text and align elements. The following page variables may be |
| 337 | /// included in the text: |
| 338 | /// - \&page; - Insert current page number |
| 339 | /// - \&date; - Insert current date, using the format set with setPageFormat() |
| 340 | /////////////////////////////////////////////////////////////////////////////// |
| 341 | |
| 342 | void TextPrintercxx . . $ TextPrinter#::setHeaderTextcxx . . $ TextPrinter#setHeaderText(3520e46b33348bf6).(const QStringcxx . . $ QString# &text) |
| 343 | { |
| 344 | headertext_cxx . . $ TextPrinter#headertext_. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). text; |
| 345 | } |
| 346 | |
| 347 | /////////////////////////////////////////////////////////////////////////////// |
| 348 | // footerSize() |
| 349 | /////////////////////////////////////////////////////////////////////////////// |
| 350 | /// Return the height of the footer block in millimeters. |
| 351 | /////////////////////////////////////////////////////////////////////////////// |
| 352 | |
| 353 | double TextPrintercxx . . $ TextPrinter#::footerSizecxx . . $ TextPrinter#footerSize(21b6c25e127938e2).() const |
| 354 | { |
| 355 | return footersize_cxx . . $ TextPrinter#footersize_.; |
| 356 | } |
| 357 | |
| 358 | /////////////////////////////////////////////////////////////////////////////// |
| 359 | // setFooterSize() |
| 360 | /////////////////////////////////////////////////////////////////////////////// |
| 361 | /// Set the height of the footer in millimeters. The default is zero (no |
| 362 | /// header). |
| 363 | /////////////////////////////////////////////////////////////////////////////// |
| 364 | |
| 365 | void TextPrintercxx . . $ TextPrinter#::setFooterSizecxx . . $ TextPrinter#setFooterSize(ba8836b59fb42830).(double size) |
| 366 | { |
| 367 | if ((size > 0) && (size <= printer_cxx . . $ TextPrinter#printer_.->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).().heightcxx . . $ QRect#height(ea6fe5115c70a13f).() / 8)) { |
| 368 | footersize_cxx . . $ TextPrinter#footersize_. = size; |
| 369 | } else { |
| 370 | footersize_cxx . . $ TextPrinter#footersize_. = 0; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /////////////////////////////////////////////////////////////////////////////// |
| 375 | // footerRule() |
| 376 | /////////////////////////////////////////////////////////////////////////////// |
| 377 | /// Return the size of the footer rule in points. One point is 1/72 inch. |
| 378 | /////////////////////////////////////////////////////////////////////////////// |
| 379 | |
| 380 | double TextPrintercxx . . $ TextPrinter#::footerRulecxx . . $ TextPrinter#footerRule(21b6c25e127938e2).() const |
| 381 | { |
| 382 | return footerrule_cxx . . $ TextPrinter#footerrule_.; |
| 383 | } |
| 384 | |
| 385 | /////////////////////////////////////////////////////////////////////////////// |
| 386 | // setFooterRule() |
| 387 | /////////////////////////////////////////////////////////////////////////////// |
| 388 | /// Set the footer rule size in points. By default, the footer rule is one half |
| 389 | /// point (1/144 inch). To turn off the rule, set the rule size to 0. The rule |
| 390 | /// will be drawn just above the footer area. |
| 391 | /////////////////////////////////////////////////////////////////////////////// |
| 392 | |
| 393 | void TextPrintercxx . . $ TextPrinter#::setFooterRulecxx . . $ TextPrinter#setFooterRule(ba8836b59fb42830).(double pointsize) |
| 394 | { |
| 395 | footerrule_cxx . . $ TextPrinter#footerrule_. = qMaxcxx . . $ qMax(2a338fce5842aa6a).(0.0, pointsize); |
| 396 | } |
| 397 | |
| 398 | /////////////////////////////////////////////////////////////////////////////// |
| 399 | // footerText() |
| 400 | /////////////////////////////////////////////////////////////////////////////// |
| 401 | /// Return the text for the footer. |
| 402 | /////////////////////////////////////////////////////////////////////////////// |
| 403 | |
| 404 | const QStringcxx . . $ QString# &TextPrintercxx . . $ TextPrinter#::footerTextcxx . . $ TextPrinter#footerText(a2fb7a6ce195d51).() const |
| 405 | { |
| 406 | return footertext_cxx . . $ TextPrinter#footertext_.; |
| 407 | } |
| 408 | |
| 409 | /////////////////////////////////////////////////////////////////////////////// |
| 410 | // setFooterText() |
| 411 | /////////////////////////////////////////////////////////////////////////////// |
| 412 | /// Set the text for the footer. Rich text is supported. HTML tags may be used |
| 413 | /// to format the text and align elements. The following page variables may be |
| 414 | /// included in the text: |
| 415 | /// - \&page; - Insert current page number |
| 416 | /// - \&date; - Insert current date, using the format set with setPageFormat() |
| 417 | /////////////////////////////////////////////////////////////////////////////// |
| 418 | |
| 419 | void TextPrintercxx . . $ TextPrinter#::setFooterTextcxx . . $ TextPrinter#setFooterText(3520e46b33348bf6).(const QStringcxx . . $ QString# &text) |
| 420 | { |
| 421 | footertext_cxx . . $ TextPrinter#footertext_. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). text; |
| 422 | } |
| 423 | |
| 424 | /////////////////////////////////////////////////////////////////////////////// |
| 425 | // dateFormat() |
| 426 | /////////////////////////////////////////////////////////////////////////////// |
| 427 | /// Return the currently set date format string. |
| 428 | /////////////////////////////////////////////////////////////////////////////// |
| 429 | |
| 430 | const QStringcxx . . $ QString# &TextPrintercxx . . $ TextPrinter#::dateFormatcxx . . $ TextPrinter#dateFormat(a2fb7a6ce195d51).() const |
| 431 | { |
| 432 | return dateformat_cxx . . $ TextPrinter#dateformat_.; |
| 433 | } |
| 434 | |
| 435 | /////////////////////////////////////////////////////////////////////////////// |
| 436 | // setDateFormat() |
| 437 | /////////////////////////////////////////////////////////////////////////////// |
| 438 | /// Set the date format to be used for the \&date; page variable. The format |
| 439 | /// is the same as that used by QDate::toString(). If no format is set, the |
| 440 | /// format defaults to Qt::TextDate. |
| 441 | /////////////////////////////////////////////////////////////////////////////// |
| 442 | |
| 443 | void TextPrintercxx . . $ TextPrinter#::setDateFormatcxx . . $ TextPrinter#setDateFormat(3520e46b33348bf6).(const QStringcxx . . $ QString# &format) |
| 444 | { |
| 445 | dateformat_cxx . . $ TextPrinter#dateformat_. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). format; |
| 446 | } |
| 447 | |
| 448 | /////////////////////////////////////////////////////////////////////////////// |
| 449 | // print() |
| 450 | /////////////////////////////////////////////////////////////////////////////// |
| 451 | /// Print a document. A standard print dialog will be displayed. If a QPrinter |
| 452 | /// is not provided, a temporary printer object will be used. If the caption |
| 453 | /// parameter is not empty, it will be used as the title for the print |
| 454 | /// dialog. |
| 455 | /// |
| 456 | /// \todo add overload taking html string |
| 457 | /////////////////////////////////////////////////////////////////////////////// |
| 458 | |
| 459 | void TextPrintercxx . . $ TextPrinter#::printcxx . . $ TextPrinter#print(cbbf3cfeb0227921).(const QTextDocumentcxx . . $ QTextDocument# *document, |
| 460 | const QStringcxx . . $ QString# &caption) |
| 461 | { |
| 462 | if (!document) return; |
| 463 | |
| 464 | // setup printer |
| 465 | printer_cxx . . $ TextPrinter#printer_.->setOutputFormatcxx . . $ QPrinter#setOutputFormat(2fca30d65e351862).(QPrintercxx . . $ QPrinter#::NativeFormatcxx . . $ QPrinter#NativeFormat.); |
| 466 | printer_cxx . . $ TextPrinter#printer_.->setOutputFileNamecxx . . $ QPrinter#setOutputFileName(3520e46b33348bf6).(QStringcxx . . $ QString#QString(ced63f7c635d850d).()); |
| 467 | |
| 468 | // show print dialog |
| 469 | QPrintDialogcxx . . $ QPrintDialog# dialogcxx . . $ QPrintDialog#QPrintDialog(d9d1e5b00a59018).(printer_cxx . . $ TextPrinter#printer_., parent_cxx . . $ TextPrinter#parent_.); |
| 470 | dialog.setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(caption.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() ? "Print Document"cxx . . $ QString#QString(85c52e162fed56f9). : captioncxx . . $ QString#QString(132dd6869045752b).); |
| 471 | if (dialog.execcxx . . $ QPrintDialog#exec(b126dc7c1de90089).() == QDialogcxx . . $ QDialog#::Rejectedcxx . . $ QDialog#Rejected.) return; |
| 472 | |
| 473 | // print it |
| 474 | tempdoc_cxx . . $ TextPrinter#tempdoc_. = document->clonecxx . . $ QTextDocument#clone(483e5a87ab88b62b).(); |
| 475 | printcxx . . $ TextPrinter#print(7b1a7783bf77ba8d).(printer_cxx . . $ TextPrinter#printer_.); |
| 476 | |
| 477 | delete tempdoc_cxx . . $ TextPrinter#tempdoc_.; |
| 478 | tempdoc_cxx . . $ TextPrinter#tempdoc_. = 0; |
| 479 | } |
| 480 | |
| 481 | /////////////////////////////////////////////////////////////////////////////// |
| 482 | // exportPDF() |
| 483 | /////////////////////////////////////////////////////////////////////////////// |
| 484 | /// Export the document in PDF format. If caption is not empty, it will be used |
| 485 | /// as the title for the dialog. If filename is empty, a standard file |
| 486 | /// selection dialog will be displayed. |
| 487 | /////////////////////////////////////////////////////////////////////////////// |
| 488 | |
| 489 | void TextPrintercxx . . $ TextPrinter#::exportPdfcxx . . $ TextPrinter#exportPdf(760d0a8378c561f9).(const QTextDocumentcxx . . $ QTextDocument# *document, |
| 490 | const QStringcxx . . $ QString# &caption, |
| 491 | const QStringcxx . . $ QString# &filename) |
| 492 | { |
| 493 | if (!document) return; |
| 494 | |
| 495 | // file save dialog |
| 496 | QStringcxx . . $ QString# dialogcaption = caption.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() ? "Export PDF"cxx . . $ QString#QString(85c52e162fed56f9). : captioncxx . . $ QString#QString(132dd6869045752b).; |
| 497 | QStringcxx . . $ QString# exportnamecxx . . $ QString#QString(ced63f7c635d850d).; |
| 498 | if (!filename.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 499 | exportname =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). filename; |
| 500 | } else { |
| 501 | exportname =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QFileDialogcxx . . $ QFileDialog#::getSaveFileNamecxx . . $ QFileDialog#getSaveFileName(a6b29be4bec65236).(parent_cxx . . $ TextPrinter#parent_., dialogcaption, |
| 502 | filename, "*.pdf"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 503 | } |
| 504 | if (exportname.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) return; |
| 505 | if (QFileInfocxx . . $ QFileInfo#(exportname).suffixcxx . . $ QFileInfo#suffix(6ef7b6c27b00b43d).().isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 506 | exportname.appendcxx . . $ QString#append(d02845eef0c33901).(".pdf"); |
| 507 | |
| 508 | // setup printer |
| 509 | printer_cxx . . $ TextPrinter#printer_.->setOutputFormatcxx . . $ QPrinter#setOutputFormat(2fca30d65e351862).(QPrintercxx . . $ QPrinter#::PdfFormatcxx . . $ QPrinter#PdfFormat.); |
| 510 | printer_cxx . . $ TextPrinter#printer_.->setOutputFileNamecxx . . $ QPrinter#setOutputFileName(3520e46b33348bf6).(exportname); |
| 511 | |
| 512 | // print it |
| 513 | tempdoc_cxx . . $ TextPrinter#tempdoc_. = document->clonecxx . . $ QTextDocument#clone(483e5a87ab88b62b).(); |
| 514 | printcxx . . $ TextPrinter#print(7b1a7783bf77ba8d).(printer_cxx . . $ TextPrinter#printer_.); |
| 515 | |
| 516 | delete tempdoc_cxx . . $ TextPrinter#tempdoc_.; |
| 517 | tempdoc_cxx . . $ TextPrinter#tempdoc_. = 0; |
| 518 | } |
| 519 | |
| 520 | /////////////////////////////////////////////////////////////////////////////// |
| 521 | // preview() |
| 522 | /////////////////////////////////////////////////////////////////////////////// |
| 523 | /// Displays a print preview dialog. If caption is not empty, it will be used |
| 524 | /// as the title of the dialog. |
| 525 | /////////////////////////////////////////////////////////////////////////////// |
| 526 | |
| 527 | void TextPrintercxx . . $ TextPrinter#::previewcxx . . $ TextPrinter#preview(cbbf3cfeb0227921).(const QTextDocumentcxx . . $ QTextDocument# *document, |
| 528 | const QStringcxx . . $ QString# &caption) |
| 529 | { |
| 530 | #if (QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(4, 4, 0)) |
| 531 | if (!document) return; |
| 532 | |
| 533 | QPrintPreviewDialogcxx . . $ QPrintPreviewDialog# *dialog = new QPrintPreviewDialogcxx . . $ QPrintPreviewDialog#(printer_cxx . . $ TextPrinter#printer_., parent_cxx . . $ TextPrinter#parent_.); |
| 534 | dialog->setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(caption.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() ? "Print Preview"cxx . . $ QString#QString(85c52e162fed56f9). : captioncxx . . $ QString#QString(132dd6869045752b).); |
| 535 | |
| 536 | connectcxx . . $ QObject#connect(158df1d9a01a3410).(dialog, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(paintRequested(QPrinter*)), |
| 537 | this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(print(QPrinter*))); |
| 538 | |
| 539 | // preview it |
| 540 | tempdoc_cxx . . $ TextPrinter#tempdoc_. = document->clonecxx . . $ QTextDocument#clone(483e5a87ab88b62b).(); |
| 541 | dialog->execcxx . . $ QDialog#exec(b126dc7c1de90089).(); |
| 542 | |
| 543 | delete tempdoc_cxx . . $ TextPrinter#tempdoc_.; |
| 544 | tempdoc_cxx . . $ TextPrinter#tempdoc_. = 0; |
| 545 | |
| 546 | delete dialog; |
| 547 | #endif |
| 548 | } |
| 549 | |
| 550 | /////////////////////////////////////////////////////////////////////////////// |
| 551 | // private methods |
| 552 | /////////////////////////////////////////////////////////////////////////////// |
| 553 | |
| 554 | // paperRect() //////////////////////////////////////////////////////////////// |
| 555 | // Return the size of the paper, adjusted for DPI |
| 556 | |
| 557 | QRectFcxx . . $ QRectF# TextPrintercxx . . $ TextPrinter#::paperRectcxx . . $ TextPrinter#paperRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device) |
| 558 | { |
| 559 | // calculate size of paper |
| 560 | QRectFcxx . . $ QRectF# rect = printer_cxx . . $ QRectF#QRectF(e3d47f00c171515).->paperRectcxx . . $ QPrinter#paperRect(d857385bac04cbf7).(); |
| 561 | // adjust for DPI |
| 562 | rect.setWidthcxx . . $ QRectF#setWidth(4cbbf9c7388e6885).(rect.widthcxx . . $ QRectF#width(d8440c0a87ad7443).() * |
| 563 | device->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).() / printer_cxx . . $ TextPrinter#printer_.->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).()); |
| 564 | rect.setHeightcxx . . $ QRectF#setHeight(4cbbf9c7388e6885).(rect.heightcxx . . $ QRectF#height(d8440c0a87ad7443).() * |
| 565 | device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).() / printer_cxx . . $ TextPrinter#printer_.->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).()); |
| 566 | |
| 567 | return rect; |
| 568 | } |
| 569 | |
| 570 | // contentRect() ////////////////////////////////////////////////////////////// |
| 571 | // calculate the rect for the content block |
| 572 | |
| 573 | QRectFcxx . . $ QRectF# TextPrintercxx . . $ TextPrinter#::contentRectcxx . . $ TextPrinter#contentRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device) |
| 574 | { |
| 575 | // calculate size of content (paper - margins) |
| 576 | QRectFcxx . . $ QRectF# rect = paperRectcxx . . $ TextPrinter#paperRect(e8444818cd8ea5d7).(device); |
| 577 | |
| 578 | rect.adjustcxx . . $ QRectF#adjust(ba0360b8cbb82f7c).(mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(leftmargin_cxx . . $ TextPrinter#leftmargin_.) * device->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).(), |
| 579 | mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(topmargin_cxx . . $ TextPrinter#topmargin_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).(), |
| 580 | -mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(rightmargin_cxx . . $ TextPrinter#rightmargin_.) * device->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).(), |
| 581 | -mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(bottommargin_cxx . . $ TextPrinter#bottommargin_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).()); |
| 582 | |
| 583 | // header |
| 584 | if (headersize_cxx . . $ TextPrinter#headersize_. > 0) { |
| 585 | rect.adjustcxx . . $ QRectF#adjust(ba0360b8cbb82f7c).(0, mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(headersize_cxx . . $ TextPrinter#headersize_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).(), 0, 0); |
| 586 | rect.adjustcxx . . $ QRectF#adjust(ba0360b8cbb82f7c).(0, mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(spacing_cxx . . $ TextPrinter#spacing_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).(), 0, 0); |
| 587 | } |
| 588 | // footer |
| 589 | if (footersize_cxx . . $ TextPrinter#footersize_. > 0) { |
| 590 | rect.adjustcxx . . $ QRectF#adjust(ba0360b8cbb82f7c).(0, 0, 0, -mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(footersize_cxx . . $ TextPrinter#footersize_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).()); |
| 591 | rect.adjustcxx . . $ QRectF#adjust(ba0360b8cbb82f7c).(0, 0, 0, -mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(spacing_cxx . . $ TextPrinter#spacing_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).()); |
| 592 | } |
| 593 | |
| 594 | return rect; |
| 595 | } |
| 596 | |
| 597 | // headerRect() ////////////////////////////////////////////////////////////// |
| 598 | // calculate the rect for the header block |
| 599 | |
| 600 | QRectFcxx . . $ QRectF# TextPrintercxx . . $ TextPrinter#::headerRectcxx . . $ TextPrinter#headerRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device) |
| 601 | { |
| 602 | QRectFcxx . . $ QRectF# rect = paperRectcxx . . $ TextPrinter#paperRect(e8444818cd8ea5d7).(device); |
| 603 | rect.adjustcxx . . $ QRectF#adjust(ba0360b8cbb82f7c).(mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(leftmargin_cxx . . $ TextPrinter#leftmargin_.) * device->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).(), |
| 604 | mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(topmargin_cxx . . $ TextPrinter#topmargin_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).(), |
| 605 | -mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(rightmargin_cxx . . $ TextPrinter#rightmargin_.) * device->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).(), 0); |
| 606 | |
| 607 | (headerrule_cxx . . $ TextPrinter#headerrule_. / 144.0); |
| 608 | |
| 609 | rect.setBottomcxx . . $ QRectF#setBottom(4cbbf9c7388e6885).(rect.topcxx . . $ QRectF#top(d8440c0a87ad7443).() + |
| 610 | mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(headersize_cxx . . $ TextPrinter#headersize_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).()); |
| 611 | |
| 612 | return rect; |
| 613 | }; |
| 614 | |
| 615 | // footerRect() /////////////////////////////////////////////////////////////// |
| 616 | // calculate the rect for the footer block |
| 617 | |
| 618 | QRectFcxx . . $ QRectF# TextPrintercxx . . $ TextPrinter#::footerRectcxx . . $ TextPrinter#footerRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device) |
| 619 | { |
| 620 | QRectFcxx . . $ QRectF# rect = paperRectcxx . . $ TextPrinter#paperRect(e8444818cd8ea5d7).(device); |
| 621 | rect.adjustcxx . . $ QRectF#adjust(ba0360b8cbb82f7c).(mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(leftmargin_cxx . . $ TextPrinter#leftmargin_.) * device->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).(), 0, |
| 622 | -mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(rightmargin_cxx . . $ TextPrinter#rightmargin_.) * device->logicalDpiXcxx . . $ QPaintDevice#logicalDpiX(455f465bc33b4cdf).(), |
| 623 | -mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(bottommargin_cxx . . $ TextPrinter#bottommargin_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).()); |
| 624 | |
| 625 | rect.setTopcxx . . $ QRectF#setTop(4cbbf9c7388e6885).(rect.bottomcxx . . $ QRectF#bottom(d8440c0a87ad7443).() - |
| 626 | mmToInchescxx . . $ mmToInches(447c67c6676f75c3).(footersize_cxx . . $ TextPrinter#footersize_.) * device->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).()); |
| 627 | |
| 628 | return rect; |
| 629 | }; |
| 630 | |
| 631 | // print() //////////////////////////////////////////////////////////////////// |
| 632 | // Common printing routine. Print tempdoc_ to given printer device. |
| 633 | |
| 634 | void TextPrintercxx . . $ TextPrinter#::printcxx . . $ TextPrinter#print(7b1a7783bf77ba8d).(QPrintercxx . . $ QPrinter# *printer) |
| 635 | { |
| 636 | if (!printer || !tempdoc_cxx . . $ TextPrinter#tempdoc_.) return; |
| 637 | |
| 638 | tempdoc_cxx . . $ TextPrinter#tempdoc_.->setUseDesignMetricscxx . . $ QTextDocument#setUseDesignMetrics(b45ddcbc8423892c).(true); |
| 639 | tempdoc_cxx . . $ TextPrinter#tempdoc_.->documentLayoutcxx . . $ QTextDocument#documentLayout(135eff1e02365923).()->setPaintDevicecxx . . $ QAbstractTextDocumentLayout#setPaintDevice(dd2eedc069b0ab5f).(printer); |
| 640 | tempdoc_cxx . . $ TextPrinter#tempdoc_.->setPageSizecxx . . $ QTextDocument#setPageSize(20547220bcb692d1).(contentRectcxx . . $ TextPrinter#contentRect(e8444818cd8ea5d7).(printer).sizecxx . . $ QRectF#size(42a114e5cab6a0cd).()); |
| 641 | // dump existing margin (if any) |
| 642 | QTextFrameFormatcxx . . $ QTextFrameFormat# fmt = tempdoc_cxx . . $ TextPrinter#tempdoc_.->rootFramecxx . . $ QTextDocument#rootFrame(143c7eba696658a0).()->frameFormatcxx . . $ QTextFrame#frameFormat(8c0c203373ecea9b).(); |
| 643 | fmt.setMargincxx . . $ QTextFrameFormat#setMargin(ba8836b59fb42830).(0); |
| 644 | tempdoc_cxx . . $ TextPrinter#tempdoc_.->rootFramecxx . . $ QTextDocument#rootFrame(143c7eba696658a0).()->setFrameFormatcxx . . $ QTextFrame#setFrameFormat(ad0174e71d5f96f1).(fmt); |
| 645 | |
| 646 | // to iterate through pages we have to worry about |
| 647 | // copies, collation, page range, and print order |
| 648 | |
| 649 | // get num copies |
| 650 | int doccopies; |
| 651 | int pagecopies; |
| 652 | if (printer->collateCopiescxx . . $ QPrinter#collateCopies(50ce9a9e25b4a850).()) { |
| 653 | doccopies = 1; |
| 654 | pagecopies = printer->numCopiescxx . . $ QPrinter#numCopies(455f465bc33b4cdf).(); |
| 655 | } else { |
| 656 | doccopies = printer->numCopiescxx . . $ QPrinter#numCopies(455f465bc33b4cdf).(); |
| 657 | pagecopies = 1; |
| 658 | } |
| 659 | |
| 660 | // get page range |
| 661 | int firstpage = printer->fromPagecxx . . $ QPrinter#fromPage(455f465bc33b4cdf).(); |
| 662 | int lastpage = printer->toPagecxx . . $ QPrinter#toPage(455f465bc33b4cdf).(); |
| 663 | if (firstpage == 0 && lastpage == 0) { // all pages |
| 664 | firstpage = 1; |
| 665 | lastpage = tempdoc_cxx . . $ TextPrinter#tempdoc_.->pageCountcxx . . $ QTextDocument#pageCount(455f465bc33b4cdf).(); |
| 666 | } |
| 667 | |
| 668 | // print order |
| 669 | bool ascending = true; |
| 670 | if (printer->pageOrdercxx . . $ QPrinter#pageOrder(862025ae3c31dc6f).() == QPrintercxx . . $ QPrinter#::LastPageFirstcxx . . $ QPrinter#LastPageFirst.) { |
| 671 | int tmp = firstpage; |
| 672 | firstpage = lastpage; |
| 673 | lastpage = tmp; |
| 674 | ascending = false; |
| 675 | } |
| 676 | |
| 677 | // loop through and print pages |
| 678 | QPaintercxx . . $ QPainter# paintercxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(printer); |
| 679 | painter.setRenderHintscxx . . $ QPainter#setRenderHints(686c9363a780b925).(QPaintercxx . . $ QPainter#::Antialiasingcxx . . $ QPainter#Antialiasing. |cxx . . $ `operator|`(ffa1bf5b1cfa19b4). |
| 680 | QPaintercxx . . $ QPainter#::TextAntialiasingcxx . . $ QPainter#TextAntialiasing. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). |
| 681 | QPaintercxx . . $ QPainter#::SmoothPixmapTransformcxx . . $ QPainter#SmoothPixmapTransform., true); |
| 682 | for (int dc=0; dc<doccopies; dc++) { |
| 683 | int pagenum = firstpage; |
| 684 | while (true) { |
| 685 | for (int pc=0; pc<pagecopies; pc++) { |
| 686 | if (printer->printerStatecxx . . $ QPrinter#printerState(5a72cd63aa949853).() == QPrintercxx . . $ QPrinter#::Abortedcxx . . $ QPrinter#Aborted. || |
| 687 | printer->printerStatecxx . . $ QPrinter#printerState(5a72cd63aa949853).() == QPrintercxx . . $ QPrinter#::Errorcxx . . $ QPrinter#Error.) { |
| 688 | return; |
| 689 | } |
| 690 | // print page |
| 691 | paintPagecxx . . $ TextPrinter#paintPage(862c914bdbdf5904).(&painter, tempdoc_cxx . . $ TextPrinter#tempdoc_., pagenum); |
| 692 | if (pc < pagecopies-1) printer->newPagecxx . . $ QPrinter#newPage(c9857a73d68e59ba).(); |
| 693 | } |
| 694 | if (pagenum == lastpage) break; |
| 695 | if (ascending) pagenum++; |
| 696 | else pagenum--; |
| 697 | printer->newPagecxx . . $ QPrinter#newPage(c9857a73d68e59ba).(); |
| 698 | } |
| 699 | |
| 700 | if (dc < doccopies-1) printer->newPagecxx . . $ QPrinter#newPage(c9857a73d68e59ba).(); |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | // paintPage() //////////////////////////////////////////////////////////////// |
| 705 | // paint an individual page of the document to the painter |
| 706 | |
| 707 | void TextPrintercxx . . $ TextPrinter#::paintPagecxx . . $ TextPrinter#paintPage(862c914bdbdf5904).(QPaintercxx . . $ QPainter# *painter, |
| 708 | QTextDocumentcxx . . $ QTextDocument# *document, |
| 709 | int pagenum) |
| 710 | { |
| 711 | QRectFcxx . . $ QRectF# rectcxx . . $ QRectF#QRectF(ced63f7c635d850d).; |
| 712 | double onepoint = painter->devicecxx . . $ QPainter#device(b8933f846a69d70c).()->logicalDpiYcxx . . $ QPaintDevice#logicalDpiY(455f465bc33b4cdf).() / 72.0; |
| 713 | |
| 714 | // header |
| 715 | if (headersize_cxx . . $ TextPrinter#headersize_. > 0) { |
| 716 | rect =cxx . . $ QRectF#`operator=`(de76e1d1054206f9). headerRectcxx . . $ TextPrinter#headerRect(e8444818cd8ea5d7).(painter->devicecxx . . $ QPainter#device(b8933f846a69d70c).()); |
| 717 | if (headerrule_cxx . . $ TextPrinter#headerrule_. > 0.0) { |
| 718 | painter->savecxx . . $ QPainter#save(49f6e7a06ebc5aa8).(); |
| 719 | // allow space between rule and header |
| 720 | painter->translatecxx . . $ QPainter#translate(bc12c9ec15586e6a).(0, onepoint + (headerrule_cxx . . $ TextPrinter#headerrule_. * onepoint / 2.0)); |
| 721 | painter->setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(Qtcxx . . $ QBrush#QBrush(1975e3c608654284).::blackcxx . . $ Qt/black., headerrule_cxx . . $ TextPrinter#headerrule_. * onepoint)); |
| 722 | painter->drawLinecxx . . $ QPainter#drawLine(3628e2b324c1bb0).(rect.bottomLeftcxx . . $ QRectF#bottomLeft(6f03e34f618d40e).(), rect.bottomRightcxx . . $ QRectF#bottomRight(6f03e34f618d40e).()); |
| 723 | painter->restorecxx . . $ QPainter#restore(49f6e7a06ebc5aa8).(); |
| 724 | } |
| 725 | |
| 726 | // replace page variables |
| 727 | QStringcxx . . $ QString# header = headertext_cxx . . $ QString#QString(132dd6869045752b).; |
| 728 | header.replacecxx . . $ QString#replace(192e628656427d1c).("&page;"cxx . . $ QString#QString(85c52e162fed56f9)., QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(pagenum)); |
| 729 | if (dateformat_cxx . . $ TextPrinter#dateformat_..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 730 | header.replacecxx . . $ QString#replace(192e628656427d1c).("&date;"cxx . . $ QString#QString(85c52e162fed56f9)., QDatecxx . . $ QDate#::currentDatecxx . . $ QDate#currentDate(f1d16c240bbd73a4).().toStringcxx . . $ QDate#toString(7b7e68bded046f2f).()); |
| 731 | } else { |
| 732 | header.replacecxx . . $ QString#replace(192e628656427d1c).("&date;"cxx . . $ QString#QString(85c52e162fed56f9)., QDatecxx . . $ QDate#::currentDatecxx . . $ QDate#currentDate(f1d16c240bbd73a4).().toStringcxx . . $ QDate#toString(5555d9024dcf93fb).(dateformat_cxx . . $ TextPrinter#dateformat_.)); |
| 733 | } |
| 734 | |
| 735 | painter->savecxx . . $ QPainter#save(49f6e7a06ebc5aa8).(); |
| 736 | painter->translatecxx . . $ QPainter#translate(bc12c9ec15586e6a).(rect.leftcxx . . $ QRectF#left(d8440c0a87ad7443).(), rect.topcxx . . $ QRectF#top(d8440c0a87ad7443).()); |
| 737 | QRectFcxx . . $ QRectF# clipcxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(0, 0, rect.widthcxx . . $ QRectF#width(d8440c0a87ad7443).(), rect.heightcxx . . $ QRectF#height(d8440c0a87ad7443).()); |
| 738 | QTextDocumentcxx . . $ QTextDocument# doccxx . . $ QTextDocument#QTextDocument(749de1b6ae65bddd).; |
| 739 | doc.setUseDesignMetricscxx . . $ QTextDocument#setUseDesignMetrics(b45ddcbc8423892c).(true); |
| 740 | doc.setHtmlcxx . . $ QTextDocument#setHtml(3520e46b33348bf6).(header); |
| 741 | doc.documentLayoutcxx . . $ QTextDocument#documentLayout(135eff1e02365923).()->setPaintDevicecxx . . $ QAbstractTextDocumentLayout#setPaintDevice(dd2eedc069b0ab5f).(painter->devicecxx . . $ QPainter#device(b8933f846a69d70c).()); |
| 742 | doc.setPageSizecxx . . $ QTextDocument#setPageSize(20547220bcb692d1).(rect.sizecxx . . $ QRectF#size(42a114e5cab6a0cd).()); |
| 743 | |
| 744 | // align text to bottom |
| 745 | double newtop = clip.bottomcxx . . $ QRectF#bottom(d8440c0a87ad7443).() - doc.sizecxx . . $ QTextDocument#size(6c9504dc925659fb).().heightcxx . . $ QSizeF#height(d8440c0a87ad7443).(); |
| 746 | clip.setHeightcxx . . $ QRectF#setHeight(4cbbf9c7388e6885).(doc.sizecxx . . $ QTextDocument#size(6c9504dc925659fb).().heightcxx . . $ QSizeF#height(d8440c0a87ad7443).()); |
| 747 | painter->translatecxx . . $ QPainter#translate(bc12c9ec15586e6a).(0, newtop); |
| 748 | |
| 749 | doc.drawContentscxx . . $ QTextDocument#drawContents(72d49ac8d58e3e57).(painter, clip); |
| 750 | painter->restorecxx . . $ QPainter#restore(49f6e7a06ebc5aa8).(); |
| 751 | } |
| 752 | |
| 753 | // footer |
| 754 | if (footersize_cxx . . $ TextPrinter#footersize_. > 0) { |
| 755 | rect =cxx . . $ QRectF#`operator=`(de76e1d1054206f9). footerRectcxx . . $ TextPrinter#footerRect(e8444818cd8ea5d7).(painter->devicecxx . . $ QPainter#device(b8933f846a69d70c).()); |
| 756 | if (footerrule_cxx . . $ TextPrinter#footerrule_. > 0.0) { |
| 757 | painter->savecxx . . $ QPainter#save(49f6e7a06ebc5aa8).(); |
| 758 | // allow space between rule and footer |
| 759 | painter->translatecxx . . $ QPainter#translate(bc12c9ec15586e6a).(0, -onepoint + (-footerrule_cxx . . $ TextPrinter#footerrule_. * onepoint / 2.0)); |
| 760 | painter->setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(Qtcxx . . $ QBrush#QBrush(1975e3c608654284).::blackcxx . . $ Qt/black., footerrule_cxx . . $ TextPrinter#footerrule_. * onepoint)); |
| 761 | painter->drawLinecxx . . $ QPainter#drawLine(3628e2b324c1bb0).(rect.topLeftcxx . . $ QRectF#topLeft(6f03e34f618d40e).(), rect.topRightcxx . . $ QRectF#topRight(6f03e34f618d40e).()); |
| 762 | painter->restorecxx . . $ QPainter#restore(49f6e7a06ebc5aa8).(); |
| 763 | } |
| 764 | |
| 765 | // replace page variables |
| 766 | QStringcxx . . $ QString# footer = footertext_cxx . . $ QString#QString(132dd6869045752b).; |
| 767 | footer.replacecxx . . $ QString#replace(192e628656427d1c).("&page;"cxx . . $ QString#QString(85c52e162fed56f9)., QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(pagenum)); |
| 768 | if (dateformat_cxx . . $ TextPrinter#dateformat_..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 769 | footer.replacecxx . . $ QString#replace(192e628656427d1c).("&date;"cxx . . $ QString#QString(85c52e162fed56f9)., QDatecxx . . $ QDate#::currentDatecxx . . $ QDate#currentDate(f1d16c240bbd73a4).().toStringcxx . . $ QDate#toString(7b7e68bded046f2f).()); |
| 770 | } else { |
| 771 | footer.replacecxx . . $ QString#replace(192e628656427d1c).("&date;"cxx . . $ QString#QString(85c52e162fed56f9)., QDatecxx . . $ QDate#::currentDatecxx . . $ QDate#currentDate(f1d16c240bbd73a4).().toStringcxx . . $ QDate#toString(5555d9024dcf93fb).(dateformat_cxx . . $ TextPrinter#dateformat_.)); |
| 772 | } |
| 773 | |
| 774 | painter->savecxx . . $ QPainter#save(49f6e7a06ebc5aa8).(); |
| 775 | painter->translatecxx . . $ QPainter#translate(bc12c9ec15586e6a).(rect.leftcxx . . $ QRectF#left(d8440c0a87ad7443).(), rect.topcxx . . $ QRectF#top(d8440c0a87ad7443).()); |
| 776 | QRectFcxx . . $ QRectF# clipcxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(0, 0, rect.widthcxx . . $ QRectF#width(d8440c0a87ad7443).(), rect.heightcxx . . $ QRectF#height(d8440c0a87ad7443).()); |
| 777 | QTextDocumentcxx . . $ QTextDocument# doccxx . . $ QTextDocument#QTextDocument(749de1b6ae65bddd).; |
| 778 | doc.setUseDesignMetricscxx . . $ QTextDocument#setUseDesignMetrics(b45ddcbc8423892c).(true); |
| 779 | doc.setHtmlcxx . . $ QTextDocument#setHtml(3520e46b33348bf6).(footer); |
| 780 | doc.documentLayoutcxx . . $ QTextDocument#documentLayout(135eff1e02365923).()->setPaintDevicecxx . . $ QAbstractTextDocumentLayout#setPaintDevice(dd2eedc069b0ab5f).(painter->devicecxx . . $ QPainter#device(b8933f846a69d70c).()); |
| 781 | doc.setPageSizecxx . . $ QTextDocument#setPageSize(20547220bcb692d1).(rect.sizecxx . . $ QRectF#size(42a114e5cab6a0cd).()); |
| 782 | doc.drawContentscxx . . $ QTextDocument#drawContents(72d49ac8d58e3e57).(painter, clip); |
| 783 | painter->restorecxx . . $ QPainter#restore(49f6e7a06ebc5aa8).(); |
| 784 | } |
| 785 | |
| 786 | // content |
| 787 | painter->savecxx . . $ QPainter#save(49f6e7a06ebc5aa8).(); |
| 788 | |
| 789 | rect =cxx . . $ QRectF#`operator=`(de76e1d1054206f9). contentRectcxx . . $ TextPrinter#contentRect(e8444818cd8ea5d7).(painter->devicecxx . . $ QPainter#device(b8933f846a69d70c).()); |
| 790 | painter->translatecxx . . $ QPainter#translate(bc12c9ec15586e6a).(rect.leftcxx . . $ QRectF#left(d8440c0a87ad7443).(), rect.topcxx . . $ QRectF#top(d8440c0a87ad7443).() - (pagenum-1) * rect.heightcxx . . $ QRectF#height(d8440c0a87ad7443).()); |
| 791 | QRectFcxx . . $ QRectF# clipcxx . . $ QRectF#QRectF(ba0360b8cbb82f7c).(0, (pagenum-1) * rect.heightcxx . . $ QRectF#height(d8440c0a87ad7443).(), rect.widthcxx . . $ QRectF#width(d8440c0a87ad7443).(), rect.heightcxx . . $ QRectF#height(d8440c0a87ad7443).()); |
| 792 | |
| 793 | document->drawContentscxx . . $ QTextDocument#drawContents(72d49ac8d58e3e57).(painter, clip); |
| 794 | |
| 795 | painter->restorecxx . . $ QPainter#restore(49f6e7a06ebc5aa8).(); |
| 796 | } |