50 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 51 #include "private/qcups_p.h" 56 #if defined (Q_WS_WIN) 57 #include <private/qprintengine_win_p.h> 58 #elif defined (Q_WS_MAC) 59 #include <private/qprintengine_mac_p.h> 60 #elif defined (QTOPIA_PRINTENGINE) 61 #include <private/qprintengine_qws_p.h> 63 #include <private/qprintengine_ps_p.h> 66 #include <private/qt_x11_p.h> 74 #include <private/qpaintengine_preview_p.h> 76 #if defined(QT3_SUPPORT) 82 #define ABORT_IF_ACTIVE(location) \ 83 if (d->printEngine->printerState() == QPrinter::Active) { \ 84 qWarning("%s: Cannot be changed while printer is active", location); \ 127 return 2.83464566929;
139 return 72.0/resolution;
151 int height_index = 1;
158 (
qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier);
164 #if !defined (QTOPIA_PRINTENGINE) 165 #if defined (Q_OS_UNIX) && ! defined (Q_WS_MAC) 172 switch (realOutputFormat) {
174 #if defined (Q_WS_WIN) 178 #elif defined (Q_WS_MAC) 182 #elif defined (QTOPIA_PRINTENGINE) 186 #elif defined (Q_OS_UNIX) 208 #ifndef QT_NO_PRINTPREVIEWWIDGET 233 #endif // QT_NO_PRINTPREVIEWWIDGET 665 #if !defined(Q_WS_X11) 670 qFatal(
"QPrinter: Must construct a QApplication before a QPaintDevice");
675 d->printerMode = mode;
677 d->createDefaultEngines();
679 #ifndef QT_NO_PRINTPREVIEWWIDGET 680 d->previewEngine = 0;
682 d->realPrintEngine = 0;
683 d->realPaintEngine = 0;
685 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 712 if (
d->use_default_engine)
713 delete d->printEngine;
717 d->use_default_engine =
false;
728 if (
d->use_default_engine)
729 delete d->printEngine;
730 #ifndef QT_NO_PRINTPREVIEWWIDGET 731 delete d->previewEngine;
770 if (
d->validPrinter &&
d->outputFormat == format)
775 const bool def_engine =
d->use_default_engine;
778 d->createDefaultEngines();
780 if (oldPrintEngine) {
781 for (
int i = 0; i <
d->manualSetList.size(); ++i) {
789 prop = oldPrintEngine->
property(key);
791 d->printEngine->setProperty(key, prop);
796 delete oldPrintEngine;
799 d->validPrinter =
true;
816 return d->outputFormat;
850 #if defined(Q_OS_UNIX) && !defined(QT_NO_CUPS) 851 if(
d->use_default_engine
866 d->validPrinter =
false;
867 for (
int i = 0; i < prnList.
size(); ++i) {
869 d->validPrinter =
true;
898 #if defined(Q_WS_X11) 903 return d->validPrinter;
1168 if (newPaperSize < 0 || newPaperSize >=
NPaperSize) {
1169 qWarning(
"QPrinter::setPaperSize: Illegal paper size %d", newPaperSize);
1174 d->hasUserSetPageSize =
true;
1229 d->hasUserSetPageSize =
true;
1249 if (paperType ==
Custom) {
1754 QRectF diRect(devRect.x()*72.0/res,
1755 devRect.y()*72.0/res,
1756 devRect.width()*72.0/res,
1757 devRect.height()*72.0/res);
1758 return QRectF(diRect.x()/multiplier, diRect.y()/multiplier,
1759 diRect.width()/multiplier, diRect.height()/multiplier);
1783 QRectF diRect(devRect.x()*72.0/res,
1784 devRect.y()*72.0/res,
1785 devRect.width()*72.0/res,
1786 devRect.height()*72.0/res);
1787 return QRectF(diRect.x()/multiplier, diRect.y()/multiplier,
1788 diRect.width()/multiplier, diRect.height()/multiplier);
1836 margins << (left * multiplier) << (top * multiplier)
1837 << (right * multiplier) << (bottom * multiplier);
1840 d->hasCustomPageMargins =
true;
1856 Q_ASSERT(left && top && right && bottom);
1859 *left = margins.
at(0).
toReal() / multiplier;
1860 *top = margins.at(1).toReal() / multiplier;
1861 *right = margins.at(2).toReal() / multiplier;
1862 *bottom = margins.at(3).toReal() / multiplier;
1876 return d->printEngine->metric(
id);
1885 return d->paintEngine;
1899 return d->printEngine;
1902 #if defined (Q_WS_WIN) 1949 for (
int i=0; i<varlist.
size(); ++i)
1950 intlist << varlist.
at(i).
toInt();
1967 return d->printEngine->newPage();
1982 return d->printEngine->abort();
1993 return d->printEngine->printerState();
2057 return d->printEngine->getPrinterDC();
2066 d->printEngine->releasePrinterDC(hdc);
2087 for (
int i=0; i<variant_list.
size(); ++i)
2226 qWarning() <<
"QPrinter::setFromTo: 'from' must be less than or equal to 'to'";
2232 if (
d->minPage == 0 &&
d->maxPage == 0) {
2271 #if defined(QT3_SUPPORT) 2273 void QPrinter::setOutputToFile(
bool f)
2287 return dlg.
exec() != 0;
2295 return psd.
exec() != 0;
2303 bool QPrinter::pageSetup(
QWidget *parent)
2305 return qt_compat_QPrinter_pageSetup(
this, parent);
2313 bool QPrinter::printSetup(
QWidget *parent)
2316 return qt_compat_QPrinter_printSetup(
this,
d, parent);
2335 return qt_compat_QPrinter_printSetup(
this,
d, parent)
2337 && qt_compat_QPrinter_pageSetup(
this, parent);
2345 int QPrinter::minPage()
const 2354 int QPrinter::maxPage()
const 2363 void QPrinter::setMinMax(
int minPage,
int maxPage )
2366 Q_ASSERT_X(minPage <= maxPage,
"QPrinter::setMinMax",
2367 "'min' must be less than or equal to 'max'");
2368 d->minPage = minPage;
2369 d->maxPage = maxPage;
2382 bool QPrinter::collateCopiesEnabled()
const 2394 void QPrinter::setCollateCopiesEnabled(
bool enable)
2407 void QPrinter::setOptionEnabled( PrinterOption option,
bool enable )
2413 d->options &= ~
QPrintDialog::PrintDialogOption(1 << option);
2419 bool QPrinter::isOptionEnabled( PrinterOption option )
const 2425 #endif // QT3_SUPPORT 2645 #endif // QT_NO_PRINTER The QVariant class acts like a union for the most common Qt data types.
DuplexMode duplex() const
Returns the current duplex mode.
void setPageOrder(PageOrder)
Sets the page order to pageOrder.
QList< const QPicture * > pages()
bool fullPage() const
Returns true if the origin of the printer's coordinate system is at the corner of the page and false ...
void setDuplex(DuplexMode duplex)
Enables double sided printing based on the duplex mode.
QList< QPrintEngine::PrintEnginePropertyKey > manualSetList
QScopedPointer< QPrinterPrivate > d_ptr
static QPrinterInfo defaultPrinter()
Returns the default printer on the system.
QString creator() const
Returns the name of the application that created the document.
PaperSize paperSize(QPrinter::PaperSize paperSize)
int toPage() const
Returns the number of the last page in a range of pages to be printed (the "to page" setting)...
QPrintEngine * printEngine
#define QT_END_NAMESPACE
This macro expands to.
PrinterState printerState() const
Returns the current state of the printer.
QRect pageRect() const
Returns the page's rectangle; this is usually smaller than the paperRect() since the page normally ha...
QPrintEngine * realPrintEngine
QString docName() const
Returns the document name.
void init(PrinterMode mode)
void setWinPageSize(int winPageSize)
Sets the page size to be used by the printer under Windows to pageSize.
qreal width() const
Returns the width.
PrinterMode
This enum describes the mode the printer should work in.
int fromPage() const
Returns the number of the first page in a range of pages to be printed (the "from page" setting)...
QPaintEngine * realPaintEngine
void setFontEmbeddingEnabled(bool enable)
Enabled or disables font embedding depending on enable.
qreal height() const
Returns the height.
void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit)
This function sets the left, top, right and bottom page margins for this printer. ...
void setProxyEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)
QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &size)
Orientation
This enum type (not to be confused with Orientation) is used to specify each page's orientation...
double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
return the multiplier of converting from the unit value to postscript-points.
void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine)
This function is used by subclasses of QPrinter to specify custom print and paint engines (printEngin...
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString printerSelectionOption() const
Returns the printer options selection string.
void setPaperSize(PaperSize)
Sets the printer paper size to newPaperSize if that size is supported.
The QString class provides a Unicode character string.
QString outputFileName() const
Returns the name of the output file.
void releaseDC(HDC hdc) const
virtual QVariant property(PrintEnginePropertyKey key) const =0
Returns the print engine's property specified by key.
bool abort()
Aborts the current print run.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
void setPaperSource(PaperSource)
Sets the paper source setting to source.
void setCollateCopies(bool collate)
Sets the default value for collation checkbox when the print dialog appears.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
PageSize pageSize() const
Returns the printer page size.
void setOrientation(Orientation)
Sets the print orientation to orientation.
QPrintEngine * printEngine() const
Returns the print engine used by the printer.
void setCopyCount(int)
Sets the number of copies to be printed to count.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Unit
This enum type is used to specify the measurement unit for page and paper sizes.
QRect paperRect() const
Returns the paper's rectangle; this is usually larger than the pageRect().
The QPrintDialog class provides a dialog for specifying the printer's configuration.
void setPrintProgram(const QString &)
Sets the name of the program that should do the print job to printProg.
PrintRange
Used to specify the print range selection option.
void append(const T &t)
Inserts value at the end of the list.
DuplexMode
This enum is used to indicate whether printing will occur on one or both sides of each sheet of paper...
int winPageSize() const
Returns the page size used by the printer under Windows.
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer...
#define QT_BEGIN_NAMESPACE
This macro expands to.
OutputFormat outputFormat() const
Returns the output format for this printer.
The QRectF class defines a rectangle in the plane using floating point precision. ...
PaperSize paperSize() const
Returns the printer paper size.
static bool isEmpty(const char *str)
Orientation orientation() const
Returns the orientation setting.
The QPrintEngine class defines an interface for how QPrinter interacts with a given printing subsyste...
void setFullPage(bool)
If fp is true, enables support for painting over the entire page; otherwise restricts painting to the...
void setPageSize(PageSize)
Sets the printer page size based on newPageSize.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
PrintDialogOption
Used to specify which parts of the print dialog should be visible.
The QPrinter class is a paint device that paints on a printer.
const T & at(int i) const
Returns the item at index position i in the list.
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
void setPrintRange(PrintRange range)
Sets the print range option in to be range.
OutputFormat
The OutputFormat enum is used to describe the format QPrinter should use for printing.
bool isValid() const
Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostSc...
Q_CORE_EXPORT void qWarning(const char *,...)
PaperSource paperSource() const
Returns the printer's paper source.
PrintRange printRange() const
Returns the page range of the QPrinter.
QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size)
void setFromTo(int fromPage, int toPage)
Sets the range of pages to be printed to cover the pages with numbers specified by from and to...
void setCreator(const QString &)
Sets the name of the application that created the document to creator.
int exec()
Reimplemented Function
ColorMode colorMode() const
Returns the current color mode.
void setColorMode(ColorMode)
Sets the printer's color mode to newColorMode, which can be either Color or GrayScale.
bool supportsMultipleCopies() const
Returns true if the printer supports printing multiple copies of the same document in one job; otherw...
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
QPrinter::PrinterMode printerMode
QList< const QPicture * > previewPages() const
bool fontEmbeddingEnabled() const
Returns true if font embedding is enabled.
void setNumCopies(int)
Sets the number of copies to be printed to numCopies.
void addToManualSetList(QPrintEngine::PrintEnginePropertyKey key)
bool newPage()
Tells the printer to eject the current page and to continue printing on a new page.
int numCopies() const
Returns the number of copies to be printed.
QSizeF qt_printerPaperSize(QPrinter::Orientation orientation, QPrinter::PaperSize paperSize, QPrinter::Unit unit, int resolution)
const char * constData() const
Returns a pointer to the data stored in the byte array.
The QPrinterInfo class gives access to information about existing printers.
QString printerName() const
Returns the name of the printer.
Q_CORE_EXPORT void qFatal(const char *,...)
#define Q_ASSERT_X(cond, where, what)
void setResolution(int)
Requests that the printer prints at dpi or as near to dpi as possible.
QPaintEngine * paintEngine() const
Returns the paint engine used by the printer.
int compare(const QString &s) const
QList< PaperSource > supportedPaperSources() const
Returns the supported paper sizes for this printer.
bool collateCopies() const
Returns true if collation is turned on when multiple copies is selected.
int actualNumCopies() const
Returns the number of copies that will be printed.
PaperSize
This enum type specifies what paper size QPrinter should use.
QPreviewPaintEngine * previewEngine
QString suffix() const
Returns the suffix of the file.
int size() const
Returns the number of items in the list.
int resolution() const
Returns the current assumed resolution of the printer, as set by setResolution() or by the printer dr...
bool doubleSidedPrinting() const
Returns true if double side printing is enabled.
ColorMode
This enum type is used to indicate whether QPrinter should print in color or not. ...
static QList< QPrinterInfo > availablePrinters()
Returns a list of available printers on the system.
The QRect class defines a rectangle in the plane using integer precision.
bool isNull() const
Returns whether this QPrinterInfo object holds a printer definition.
PageOrder
This enum type is used by QPrinter to tell the application program how to print.
QPaintEngine * paintEngine
int copyCount() const
Returns the number of copies that will be printed.
PrintRange
Used to specify the print range selection option.
int metric(PaintDeviceMetric) const
Returns the metric for the given id.
void setPrinterSelectionOption(const QString &)
Sets the printer to use option to select the printer.
void createDefaultEngines()
void setOutputFormat(OutputFormat format)
Sets the output format for this printer to format.
void setDocName(const QString &)
Sets the document name to name.
PageSize
Use QPrinter::PaperSize instead.
QList< int > supportedResolutions() const
Returns a list of the resolutions (a list of dots-per-inch integers) that the printer says it support...
static const float qt_paperSizes[][2]
The QFileInfo class provides system-independent file information.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
QString printerName() const
Returns the printer name.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
static bool printerHasPPD(const char *printerName)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
QPrinter(PrinterMode mode=ScreenResolution)
Creates a new printer object with the given mode.
PageOrder pageOrder() const
Returns the current page order.
void setDoubleSidedPrinting(bool enable)
Enables double sided printing if doubleSided is true; otherwise disables it.
~QPrinter()
Destroys the printer object and frees any allocated resources.
qreal toReal(bool *ok=0) const
Returns the variant as a qreal if the variant has type() Double , QMetaType::Float ...
void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const
Returns the page margins for this printer in left, top, right, bottom.
void setPrinterName(const QString &)
Sets the printer name to name.
#define ABORT_IF_ACTIVE(location)
void setPreviewMode(bool)
PaperSource
This enum type specifies what paper source QPrinter is to use.
The QList class is a template class that provides lists.
PrintEnginePropertyKey
This enum is used to communicate properties between the print engine and QPrinter.
QPrinter::OutputFormat outputFormat
QString printProgram() const
Returns the name of the program that sends the print output to the printer.
void setOutputFileName(const QString &)
Sets the name of the output file to fileName.