QPrinter::Orientation QPrinterProto::orientation() const { QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject()); if (item) return item->orientation(); return QPrinter::Portrait; }
QStringList FilePrinter::optionOrientation( QPrinter &printer, QPrinter::Orientation documentOrientation ) { // portrait and landscape options rotate the document according to the document orientation // If we want to print a landscape document as one would expect it, we have to pass the // portrait option so that the document is not rotated additionaly if ( printer.orientation() == documentOrientation ) { // the user wants the document printed as is return QStringList("-o") << "portrait"; } else { // the user expects the document being rotated by 90 degrees return QStringList("-o") << "landscape"; } }
QStringList FilePrinter::optionDoubleSidedPrinting( QPrinter &printer ) { switch ( printer.duplex() ) { case QPrinter::DuplexNone: return QStringList(QStringLiteral("-o")) << QStringLiteral("sides=one-sided"); case QPrinter::DuplexAuto: if ( printer.orientation() == QPrinter::Landscape ) { return QStringList(QStringLiteral("-o")) << QStringLiteral("sides=two-sided-short-edge"); } else { return QStringList(QStringLiteral("-o")) << QStringLiteral("sides=two-sided-long-edge"); } case QPrinter::DuplexLongSide: return QStringList(QStringLiteral("-o")) << QStringLiteral("sides=two-sided-long-edge"); case QPrinter::DuplexShortSide: return QStringList(QStringLiteral("-o")) << QStringLiteral("sides=two-sided-short-edge"); default: return QStringList(); //Use printer default } }
QSize FilePrinter::psPaperSize( QPrinter &printer ) { QSize size; switch ( printer.pageSize() ) { case QPrinter::A0: size = QSize( 2384, 3370 ); break; case QPrinter::A1: size = QSize( 1684, 2384 ); break; case QPrinter::A2: size = QSize( 1191, 1684 ); break; case QPrinter::A3: size = QSize( 842, 1191 ); break; case QPrinter::A4: size = QSize( 595, 842 ); break; case QPrinter::A5: size = QSize( 420, 595 ); break; case QPrinter::A6: size = QSize( 298, 420 ); break; case QPrinter::A7: size = QSize( 210, 298 ); break; case QPrinter::A8: size = QSize( 147, 210 ); break; case QPrinter::A9: size = QSize( 105, 147 ); break; case QPrinter::B0: size = QSize( 2835, 4008 ); break; case QPrinter::B1: size = QSize( 2004, 2835 ); break; case QPrinter::B2: size = QSize( 1417, 2004 ); break; case QPrinter::B3: size = QSize( 1001, 1417 ); break; case QPrinter::B4: size = QSize( 709, 1001 ); break; case QPrinter::B5: size = QSize( 499, 709 ); break; case QPrinter::B6: size = QSize( 354, 499 ); break; case QPrinter::B7: size = QSize( 249, 354 ); break; case QPrinter::B8: size = QSize( 176, 249 ); break; case QPrinter::B9: size = QSize( 125, 176 ); break; case QPrinter::B10: size = QSize( 88, 125 ); break; case QPrinter::C5E: size = QSize( 459, 649 ); break; case QPrinter::Comm10E: size = QSize( 297, 684 ); break; case QPrinter::DLE: size = QSize( 312, 624 ); break; case QPrinter::Executive: size = QSize( 522, 756 ); break; case QPrinter::Folio: size = QSize( 595, 935 ); break; case QPrinter::Ledger: size = QSize( 1224, 792 ); break; case QPrinter::Legal: size = QSize( 612, 1008 ); break; case QPrinter::Letter: size = QSize( 612, 792 ); break; case QPrinter::Tabloid: size = QSize( 792, 1224 ); break; case QPrinter::Custom: return QSize( (int) printer.widthMM() * ( 25.4 / 72 ), (int) printer.heightMM() * ( 25.4 / 72 ) ); default: return QSize(); } if ( printer.orientation() == QPrinter::Landscape ) { size.transpose(); } return size; }
int Printer::orientation(lua_State * L) // const : Orientation { QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 ); Util::push( L, lhs->orientation() ); return 1; }