summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qprinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qprinter.cpp')
-rw-r--r--src/gui/painting/qprinter.cpp225
1 files changed, 23 insertions, 202 deletions
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 74a8f6a9d8..bfd2c44b9f 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -44,8 +44,7 @@
#include "qprintengine.h"
#include "qprinterinfo.h"
#include "qlist.h"
-#include <qpagesetupdialog.h>
-#include <qapplication.h>
+#include <qcoreapplication.h>
#include <qfileinfo.h>
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
#include "private/qcups_p.h"
@@ -60,7 +59,6 @@
#elif defined (QTOPIA_PRINTENGINE)
#include <private/qprintengine_qws_p.h>
#endif
-#include <private/qprintengine_ps_p.h>
#if defined(Q_WS_X11)
#include <private/qt_x11_p.h>
@@ -73,10 +71,6 @@
#include <qpicture.h>
#include <private/qpaintengine_preview_p.h>
-#if defined(QT3_SUPPORT)
-# include "qprintdialog.h"
-#endif // QT3_SUPPORT
-
QT_BEGIN_NAMESPACE
#define ABORT_IF_ACTIVE(location) \
@@ -120,7 +114,7 @@ static const float qt_paperSizes[][2] = {
};
/// return the multiplier of converting from the unit value to postscript-points.
-double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
+Q_GUI_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
{
switch(unit) {
case QPrinter::Millimeter:
@@ -142,7 +136,7 @@ double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
}
// not static: it's needed in qpagesetupdialog_unix.cpp
-QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
+Q_GUI_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
QPrinter::PaperSize paperSize,
QPrinter::Unit unit,
int resolution)
@@ -164,7 +158,7 @@ void QPrinterPrivate::createDefaultEngines()
#if !defined (QTOPIA_PRINTENGINE)
#if defined (Q_OS_UNIX) && ! defined (Q_WS_MAC)
if(outputFormat == QPrinter::NativeFormat) {
- realOutputFormat = QPrinter::PostScriptFormat;
+ realOutputFormat = QPrinter::PdfFormat;
}
#endif
#endif
@@ -194,12 +188,6 @@ void QPrinterPrivate::createDefaultEngines()
printEngine = pdfEngine;
}
break;
- case QPrinter::PostScriptFormat: {
- QPSPrintEngine *psEngine = new QPSPrintEngine(printerMode);
- paintEngine = psEngine;
- printEngine = psEngine;
- }
- break;
}
use_default_engine = true;
had_default_engines = true;
@@ -260,7 +248,7 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
When printing directly to a printer on Windows or Mac OS X, QPrinter uses
the built-in printer drivers. On X11, QPrinter uses the
\l{Common Unix Printing System (CUPS)} or the standard Unix \l lpr utility
- to send PostScript or PDF output to the printer. As an alternative,
+ to send PDF output to the printer. As an alternative,
the printProgram() function can be used to specify the command or utility
to use instead of the system default.
@@ -347,8 +335,8 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
printer code.
\value HighResolution On Windows, sets the printer resolution to that
- defined for the printer in use. For PostScript printing, sets the
- resolution of the PostScript driver to 1200 dpi.
+ defined for the printer in use. For PDF printing, sets the
+ resolution of the PDF driver to 1200 dpi.
\note When rendering text on a QPrinter device, it is important
to realize that the size of text, when specified in points, is
@@ -627,9 +615,9 @@ QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode)
void QPrinter::init(PrinterMode mode)
{
#if !defined(Q_WS_X11)
- if (!qApp) {
+ if (!QCoreApplication::instance()) {
#else
- if (!qApp || !X11) {
+ if (!QCoreApplication::instance() || !X11) {
#endif
qFatal("QPrinter: Must construct a QApplication before a QPaintDevice");
return;
@@ -709,9 +697,6 @@ QPrinter::~QPrinter()
\value PdfFormat QPrinter will generate its output as a searchable PDF file.
This mode is the default when printing to a file.
- \value PostScriptFormat QPrinter will generate its output as in the PostScript format.
- (This feature was introduced in Qt 4.2.)
-
\sa outputFormat(), setOutputFormat(), setOutputFileName()
*/
@@ -753,7 +738,7 @@ void QPrinter::setOutputFormat(OutputFormat format)
if (def_engine)
delete oldPrintEngine;
- if (d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat)
+ if (d->outputFormat == QPrinter::PdfFormat)
d->validPrinter = true;
#else
Q_UNUSED(format);
@@ -803,20 +788,15 @@ void QPrinter::setPrinterName(const QString &name)
ABORT_IF_ACTIVE("QPrinter::setPrinterName");
#if defined(Q_OS_UNIX) && !defined(QT_NO_CUPS)
- if(d->use_default_engine
- && d->outputFormat == QPrinter::NativeFormat) {
- if (QCUPSSupport::cupsVersion() >= 10200
- && QCUPSSupport::printerHasPPD(name.toLocal8Bit().constData()))
- setOutputFormat(QPrinter::PdfFormat);
- else
- setOutputFormat(QPrinter::PostScriptFormat);
+ if(d->use_default_engine && d->outputFormat == QPrinter::NativeFormat) {
+ setOutputFormat(QPrinter::PdfFormat);
d->outputFormat = QPrinter::NativeFormat;
}
#endif
QList<QPrinterInfo> prnList = QPrinterInfo::availablePrinters();
if (name.isEmpty()) {
- d->validPrinter = d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat;
+ d->validPrinter = d->outputFormat == QPrinter::PdfFormat;
} else {
d->validPrinter = false;
for (int i = 0; i < prnList.size(); ++i) {
@@ -836,7 +816,7 @@ void QPrinter::setPrinterName(const QString &name)
\since 4.4
Returns true if the printer currently selected is a valid printer
- in the system, or a pure PDF/PostScript printer; otherwise returns false.
+ in the system, or a pure PDF printer; otherwise returns false.
To detect other failures check the output of QPainter::begin() or QPrinter::newPage().
@@ -902,13 +882,12 @@ QString QPrinter::outputFileName() const
Setting a null or empty name (0 or "") disables printing to a file.
Setting a non-empty name enables printing to a file.
- This can change the value of outputFormat(). If the file name has the
- suffix ".ps" then PostScript is automatically selected as output format.
+ This can change the value of outputFormat().
If the file name has the ".pdf" suffix PDF is generated. If the file name
- has a suffix other than ".ps" and ".pdf", the output format used is the
+ has a suffix other than ".pdf", the output format used is the
one set with setOutputFormat().
- QPrinter uses Qt's cross-platform PostScript or PDF print engines
+ QPrinter uses Qt's cross-platform PDF print engines
respectively. If you can produce this format natively, for example
Mac OS X can generate PDF's from its print engine, set the output format
back to NativeFormat.
@@ -922,9 +901,7 @@ void QPrinter::setOutputFileName(const QString &fileName)
ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
QFileInfo fi(fileName);
- if (!fi.suffix().compare(QLatin1String("ps"), Qt::CaseInsensitive))
- setOutputFormat(QPrinter::PostScriptFormat);
- else if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
+ if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
setOutputFormat(QPrinter::PdfFormat);
else if (fileName.isEmpty())
setOutputFormat(QPrinter::NativeFormat);
@@ -956,7 +933,7 @@ QString QPrinter::printProgram() const
Sets the name of the program that should do the print job to \a
printProg.
- On X11, this function sets the program to call with the PostScript
+ On X11, this function sets the program to call with the PDF
output. On other platforms, it has no effect.
\sa printProgram()
@@ -1798,9 +1775,9 @@ int QPrinter::winPageSize() const
Returns a list of the resolutions (a list of dots-per-inch
integers) that the printer says it supports.
- For X11 where all printing is directly to postscript, this
+ For X11 where all printing is directly to PDF, this
function will always return a one item list containing only the
- postscript resolution, i.e., 72 (72 dpi -- but see PrinterMode).
+ PDF resolution, i.e., 72 (72 dpi -- but see PrinterMode).
*/
QList<int> QPrinter::supportedResolutions() const
{
@@ -2073,7 +2050,6 @@ void QPrinter::setFromTo(int from, int to)
if (d->minPage == 0 && d->maxPage == 0) {
d->minPage = 1;
d->maxPage = to;
- d->options |= QAbstractPrintDialog::PrintPageRange;
}
}
@@ -2085,7 +2061,7 @@ void QPrinter::setFromTo(int from, int to)
void QPrinter::setPrintRange( PrintRange range )
{
Q_D(QPrinter);
- d->printRange = QAbstractPrintDialog::PrintRange(range);
+ d->printRange = range;
}
/*!
@@ -2100,164 +2076,9 @@ void QPrinter::setPrintRange( PrintRange range )
QPrinter::PrintRange QPrinter::printRange() const
{
Q_D(const QPrinter);
- return PrintRange(d->printRange);
-}
-
-#if defined(QT3_SUPPORT)
-
-void QPrinter::setOutputToFile(bool f)
-{
- if (f) {
- if (outputFileName().isEmpty())
- setOutputFileName(QLatin1String("untitled_printer_document"));
- } else {
- setOutputFileName(QString());
- }
-}
-
-bool qt_compat_QPrinter_printSetup(QPrinter *printer, QPrinterPrivate *pd, QWidget *parent)
-{
- Q_UNUSED(pd);
- QPrintDialog dlg(printer, parent);
- return dlg.exec() != 0;
-}
-
-
-#ifdef Q_WS_MAC
-bool qt_compat_QPrinter_pageSetup(QPrinter *p, QWidget *parent)
-{
- QPageSetupDialog psd(p, parent);
- return psd.exec() != 0;
-}
-
-/*!
- Executes a page setup dialog so that the user can configure the type of
- page used for printing. Returns true if the contents of the dialog are
- accepted; returns false if the dialog is canceled.
-*/
-bool QPrinter::pageSetup(QWidget *parent)
-{
- return qt_compat_QPrinter_pageSetup(this, parent);
-}
-
-/*!
- Executes a print setup dialog so that the user can configure the printing
- process. Returns true if the contents of the dialog are accepted; returns
- false if the dialog is canceled.
-*/
-bool QPrinter::printSetup(QWidget *parent)
-{
- Q_D(QPrinter);
- return qt_compat_QPrinter_printSetup(this, d, parent);
-}
-#endif // Q_WS_MAC
-
-/*!
- Use QPrintDialog instead.
-
- \oldcode
- if (printer->setup(parent))
- ...
- \newcode
- QPrintDialog dialog(printer, parent);
- if (dialog.exec())
- ...
- \endcode
-*/
-bool QPrinter::setup(QWidget *parent)
-{
- Q_D(QPrinter);
- return qt_compat_QPrinter_printSetup(this, d, parent)
-#ifdef Q_WS_MAC
- && qt_compat_QPrinter_pageSetup(this, parent);
-#endif
- ;
-}
-
-/*!
- Use QPrintDialog::minPage() instead.
-*/
-int QPrinter::minPage() const
-{
- Q_D(const QPrinter);
- return d->minPage;
-}
-
-/*!
- Use QPrintDialog::maxPage() instead.
-*/
-int QPrinter::maxPage() const
-{
- Q_D(const QPrinter);
- return d->maxPage;
-}
-
-/*!
- Use QPrintDialog::setMinMax() instead.
-*/
-void QPrinter::setMinMax( int minPage, int maxPage )
-{
- Q_D(QPrinter);
- Q_ASSERT_X(minPage <= maxPage, "QPrinter::setMinMax",
- "'min' must be less than or equal to 'max'");
- d->minPage = minPage;
- d->maxPage = maxPage;
- d->options |= QPrintDialog::PrintPageRange;
-}
-
-/*!
- Returns true if the printer is set up to collate copies of printed documents;
- otherwise returns false.
-
- Use QPrintDialog::isOptionEnabled(QPrintDialog::PrintCollateCopies)
- instead.
-
- \sa collateCopies()
-*/
-bool QPrinter::collateCopiesEnabled() const
-{
- Q_D(const QPrinter);
- return (d->options & QPrintDialog::PrintCollateCopies);
-}
-
-/*!
- Use QPrintDialog::setOption(QPrintDialog::PrintCollateCopies)
- or QPrintDialog::setOptions(QPrintDialog::options()
- & ~QPrintDialog::PrintCollateCopies) instead, depending on \a
- enable.
-*/
-void QPrinter::setCollateCopiesEnabled(bool enable)
-{
- Q_D(QPrinter);
-
- if (enable)
- d->options |= QPrintDialog::PrintCollateCopies;
- else
- d->options &= ~QPrintDialog::PrintCollateCopies;
-}
-
-/*!
- Use QPrintDialog instead.
-*/
-void QPrinter::setOptionEnabled( PrinterOption option, bool enable )
-{
- Q_D(QPrinter);
- if (enable)
- d->options |= QPrintDialog::PrintDialogOption(1 << option);
- else
- d->options &= ~QPrintDialog::PrintDialogOption(1 << option);
-}
-
-/*!
- Use QPrintDialog instead.
-*/
-bool QPrinter::isOptionEnabled( PrinterOption option ) const
-{
- Q_D(const QPrinter);
- return (d->options & QPrintDialog::PrintDialogOption(option));
+ return d->printRange;
}
-#endif // QT3_SUPPORT
/*!
\class QPrintEngine