summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2014-03-28 10:58:25 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-05 21:47:46 +0200
commitbc46b591b2cb81a5cb0c513aa4139b7e88fa8b06 (patch)
treef419a9eb6c623cd24d57f316edcaec1d4f6c5cd2
parentd84da399649d01ac689e87295f8decc024a4f8e8 (diff)
QPagedPaintDevice - Move QPageLayout methods
The new QPageLayout methods weren't originally added to QPagePaintDevice as no new virtuals can be added, instead static polymorphism was used to add the methods directly in the derived classes QPdfWriter and QPrinter. This however means that classes like QTextDocument with print() methods that take a QPagedPaintDevice are unable to access the QPageLayout methods. To fix this, instead make the QPagedPaintDevicePrivate a virtual class and have QPdfWriter and QPrinter implement derived private classes that are called by the non-virtual QPagedPaintDevice base methods. Change-Id: Ieb6e513b1fa05f5ae76ea1f9156b0b1a053089eb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/gui/painting/qpagedpaintdevice.cpp146
-rw-r--r--src/gui/painting/qpagedpaintdevice.h12
-rw-r--r--src/gui/painting/qpagedpaintdevice_p.h42
-rw-r--r--src/gui/painting/qpdfwriter.cpp129
-rw-r--r--src/gui/painting/qpdfwriter.h5
-rw-r--r--src/printsupport/kernel/qprinter.cpp160
-rw-r--r--src/printsupport/kernel/qprinter.h6
7 files changed, 374 insertions, 126 deletions
diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp
index 18ba964a26..e102b7fae3 100644
--- a/src/gui/painting/qpagedpaintdevice.cpp
+++ b/src/gui/painting/qpagedpaintdevice.cpp
@@ -66,6 +66,15 @@ QPagedPaintDevice::QPagedPaintDevice()
}
/*!
+ \internal
+ Constructs a new paged paint device with the derived private class.
+*/
+QPagedPaintDevice::QPagedPaintDevice(QPagedPaintDevicePrivate *dd)
+ : d(dd)
+{
+}
+
+/*!
Destroys the object.
*/
QPagedPaintDevice::~QPagedPaintDevice()
@@ -74,6 +83,15 @@ QPagedPaintDevice::~QPagedPaintDevice()
}
/*!
+ \internal
+ Returns the QPagedPaintDevicePrivate.
+*/
+QPagedPaintDevicePrivate *QPagedPaintDevice::dd()
+{
+ return d;
+}
+
+/*!
\enum QPagedPaintDevice::PageSize
This enum type lists the available page sizes as defined in the Postscript
@@ -296,6 +314,134 @@ QPagedPaintDevice::Margins QPagedPaintDevice::margins() const
}
/*!
+ \since 5.3
+
+ Sets the page layout to \a newPageLayout.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new page layout to a new page.
+ You should not call any painting methods between a call to setPageLayout()
+ and newPage() as the wrong paint metrics may be used.
+
+ Returns true if the page layout was successfully set to \a newPageLayout.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageLayout(const QPageLayout &newPageLayout)
+{
+ return d->setPageLayout(newPageLayout);
+}
+
+/*!
+ \since 5.3
+
+ Sets the page size to \a pageSize.
+
+ To get the current QPageSize use pageLayout().pageSize().
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new page size to a new page.
+ You should not call any painting methods between a call to setPageSize()
+ and newPage() as the wrong paint metrics may be used.
+
+ Returns true if the page size was successfully set to \a pageSize.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageSize(const QPageSize &pageSize)
+{
+ return d->setPageSize(pageSize);
+}
+
+/*!
+ \since 5.3
+
+ Sets the page \a orientation.
+
+ The page orientation is used to define the orientation of the
+ page size when obtaining the page rect.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new orientation to a new page.
+ You should not call any painting methods between a call to setPageOrientation()
+ and newPage() as the wrong paint metrics may be used.
+
+ To get the current QPageLayout::Orientation use pageLayout().pageOrientation().
+
+ Returns true if the page orientation was successfully set to \a orientation.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation)
+{
+ return d->setPageOrientation(orientation);
+}
+
+/*!
+ \since 5.3
+
+ Set the page \a margins in the current page layout units.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new margins to a new page.
+ You should not call any painting methods between a call to setPageMargins()
+ and newPage() as the wrong paint metrics may be used.
+
+ To get the current page margins use pageLayout().pageMargins().
+
+ Returns true if the page margins were successfully set to \a margins.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins)
+{
+ return d->setPageMargins(margins);
+}
+
+/*!
+ \since 5.3
+
+ Set the page \a margins defined in the given \a units.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new margins to a new page.
+ You should not call any painting methods between a call to setPageMargins()
+ and newPage() as the wrong paint metrics may be used.
+
+ To get the current page margins use pageLayout().pageMargins().
+
+ Returns true if the page margins were successfully set to \a margins.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
+{
+ return d->setPageMargins(margins, units);
+}
+
+/*!
+ \since 5.3
+
+ Returns the current page layout. Use this method to access the current
+ QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect().
+
+ Note that you cannot use the setters on the returned object, you must either
+ call the individual QPagedPaintDevice setters or use setPageLayout().
+
+ \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
+*/
+
+QPageLayout QPagedPaintDevice::pageLayout() const
+{
+ return d->pageLayout();
+}
+
+/*!
\internal
Returns the internal device page layout.
diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h
index 6d4c422a95..dec56f9ce8 100644
--- a/src/gui/painting/qpagedpaintdevice.h
+++ b/src/gui/painting/qpagedpaintdevice.h
@@ -43,6 +43,7 @@
#define QPAGEDPAINTDEVICE_H
#include <QtGui/qpaintdevice.h>
+#include <QtGui/qpagelayout.h>
QT_BEGIN_NAMESPACE
@@ -51,7 +52,6 @@ QT_BEGIN_NAMESPACE
#endif
class QPagedPaintDevicePrivate;
-class QPageLayout;
class Q_GUI_EXPORT QPagedPaintDevice : public QPaintDevice
{
@@ -214,6 +214,14 @@ public:
Envelope10 = Comm10E
};
+ // ### Qt6 Make these virtual
+ bool setPageLayout(const QPageLayout &pageLayout);
+ bool setPageSize(const QPageSize &pageSize);
+ bool setPageOrientation(QPageLayout::Orientation orientation);
+ bool setPageMargins(const QMarginsF &margins);
+ bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
+ QPageLayout pageLayout() const;
+
virtual void setPageSize(PageSize size);
PageSize pageSize() const;
@@ -232,6 +240,8 @@ public:
Margins margins() const;
protected:
+ QPagedPaintDevice(QPagedPaintDevicePrivate *dd);
+ QPagedPaintDevicePrivate *dd();
QPageLayout devicePageLayout() const;
QPageLayout &devicePageLayout();
friend class QPagedPaintDevicePrivate;
diff --git a/src/gui/painting/qpagedpaintdevice_p.h b/src/gui/painting/qpagedpaintdevice_p.h
index da58951dc7..2321494779 100644
--- a/src/gui/painting/qpagedpaintdevice_p.h
+++ b/src/gui/painting/qpagedpaintdevice_p.h
@@ -55,8 +55,6 @@
#include <qpagedpaintdevice.h>
-#include "qpagelayout.h"
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPagedPaintDevicePrivate
@@ -71,6 +69,46 @@ public:
{
}
+ virtual ~QPagedPaintDevicePrivate()
+ {
+ }
+
+ // ### Qt6 Remove these and make public class methods virtual
+ virtual bool setPageLayout(const QPageLayout &newPageLayout)
+ {
+ m_pageLayout = newPageLayout;
+ return m_pageLayout.isEquivalentTo(newPageLayout);;
+ }
+
+ virtual bool setPageSize(const QPageSize &pageSize)
+ {
+ m_pageLayout.setPageSize(pageSize);
+ return m_pageLayout.pageSize().isEquivalentTo(pageSize);
+ }
+
+ virtual bool setPageOrientation(QPageLayout::Orientation orientation)
+ {
+ m_pageLayout.setOrientation(orientation);
+ return m_pageLayout.orientation() == orientation;
+ }
+
+ virtual bool setPageMargins(const QMarginsF &margins)
+ {
+ return setPageMargins(margins, m_pageLayout.units());
+ }
+
+ virtual bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
+ {
+ m_pageLayout.setUnits(units);
+ m_pageLayout.setMargins(margins);
+ return m_pageLayout.margins() == margins && m_pageLayout.units() == units;
+ }
+
+ virtual QPageLayout pageLayout() const
+ {
+ return m_pageLayout;
+ }
+
static inline QPagedPaintDevicePrivate *get(QPagedPaintDevice *pd) { return pd->d; }
QPageLayout m_pageLayout;
diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp
index 08c8f42fd9..b856d6625c 100644
--- a/src/gui/painting/qpdfwriter.cpp
+++ b/src/gui/painting/qpdfwriter.cpp
@@ -43,6 +43,7 @@
#ifndef QT_NO_PDF
+#include "qpagedpaintdevice_p.h"
#include <QtCore/private/qobject_p.h>
#include "private/qpdf_p.h"
#include <QtCore/qfile.h>
@@ -68,6 +69,64 @@ public:
QFile *output;
};
+class QPdfPagedPaintDevicePrivate : public QPagedPaintDevicePrivate
+{
+public:
+ QPdfPagedPaintDevicePrivate(QPdfWriterPrivate *d)
+ : QPagedPaintDevicePrivate(), pd(d)
+ {}
+
+ virtual ~QPdfPagedPaintDevicePrivate()
+ {}
+
+ bool setPageLayout(const QPageLayout &newPageLayout) Q_DECL_OVERRIDE
+ {
+ // Try to set the paint engine page layout
+ pd->engine->setPageLayout(newPageLayout);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.isEquivalentTo(newPageLayout);
+ }
+
+ bool setPageSize(const QPageSize &pageSize) Q_DECL_OVERRIDE
+ {
+ // Try to set the paint engine page size
+ pd->engine->setPageSize(pageSize);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.pageSize().isEquivalentTo(pageSize);
+ }
+
+ bool setPageOrientation(QPageLayout::Orientation orientation) Q_DECL_OVERRIDE
+ {
+ // Set the print engine value
+ pd->engine->setPageOrientation(orientation);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.orientation() == orientation;
+ }
+
+ bool setPageMargins(const QMarginsF &margins) Q_DECL_OVERRIDE
+ {
+ return setPageMargins(margins, pageLayout().units());
+ }
+
+ bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) Q_DECL_OVERRIDE
+ {
+ // Try to set engine margins
+ pd->engine->setPageMargins(margins, units);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.margins() == margins && m_pageLayout.units() == units;
+ }
+
+ QPageLayout pageLayout() const Q_DECL_OVERRIDE
+ {
+ return pd->engine->pageLayout();
+ }
+
+ QPdfWriterPrivate *pd;
+};
/*! \class QPdfWriter
\inmodule QtGui
@@ -85,7 +144,8 @@ public:
Constructs a PDF writer that will write the pdf to \a filename.
*/
QPdfWriter::QPdfWriter(const QString &filename)
- : QObject(*new QPdfWriterPrivate)
+ : QObject(*new QPdfWriterPrivate),
+ QPagedPaintDevice(new QPdfPagedPaintDevicePrivate(d_func()))
{
Q_D(QPdfWriter);
@@ -195,7 +255,10 @@ int QPdfWriter::resolution() const
return d->engine->resolution();
}
+// Defined in QPagedPaintDevice but non-virtual, add QPdfWriter specific doc here
+#ifdef Q_QDOC
/*!
+ \fn bool QPdfWriter::setPageLayout(const QPageLayout &newPageLayout)
\since 5.3
Sets the PDF page layout to \a newPageLayout.
@@ -210,17 +273,8 @@ int QPdfWriter::resolution() const
\sa pageLayout()
*/
-bool QPdfWriter::setPageLayout(const QPageLayout &newPageLayout)
-{
- Q_D(const QPdfWriter);
- // Try to set the paint engine page layout
- d->engine->setPageLayout(newPageLayout);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().isEquivalentTo(newPageLayout);
-}
-
/*!
+ \fn bool QPdfWriter::setPageSize(const QPageSize &pageSize)
\since 5.3
Sets the PDF page size to \a pageSize.
@@ -237,17 +291,8 @@ bool QPdfWriter::setPageLayout(const QPageLayout &newPageLayout)
\sa pageLayout()
*/
-bool QPdfWriter::setPageSize(const QPageSize &pageSize)
-{
- Q_D(const QPdfWriter);
- // Try to set the paint engine page size
- d->engine->setPageSize(pageSize);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().pageSize().isEquivalentTo(pageSize);
-}
-
/*!
+ \fn bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)
\since 5.3
Sets the PDF page \a orientation.
@@ -267,17 +312,8 @@ bool QPdfWriter::setPageSize(const QPageSize &pageSize)
\sa pageLayout()
*/
-bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)
-{
- Q_D(const QPdfWriter);
- // Set the print engine value
- d->engine->setPageOrientation(orientation);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().orientation() == orientation;
-}
-
/*!
+ \fn bool QPdfWriter::setPageMargins(const QMarginsF &margins)
\since 5.3
Set the PDF page \a margins in the current page layout units.
@@ -294,17 +330,8 @@ bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)
\sa pageLayout()
*/
-bool QPdfWriter::setPageMargins(const QMarginsF &margins)
-{
- Q_D(const QPdfWriter);
- // Try to set engine margins
- d->engine->setPageMargins(margins, pageLayout().units());
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().margins() == margins;
-}
-
/*!
+ \fn bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
\since 5.3
Set the PDF page \a margins defined in the given \a units.
@@ -321,17 +348,10 @@ bool QPdfWriter::setPageMargins(const QMarginsF &margins)
\sa pageLayout()
*/
-bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
-{
- Q_D(const QPdfWriter);
- // Try to set engine margins
- d->engine->setPageMargins(margins, units);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().margins() == margins && pageLayout().units() == units;
-}
-
/*!
+ \fn QPageLayout QPdfWriter::pageLayout() const
+ \since 5.3
+
Returns the current page layout. Use this method to access the current
QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect().
@@ -340,12 +360,7 @@ bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit unit
\sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
*/
-
-QPageLayout QPdfWriter::pageLayout() const
-{
- Q_D(const QPdfWriter);
- return d->engine->pageLayout();
-}
+#endif
/*!
\reimp
diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h
index fce0b88ea8..747ce380e7 100644
--- a/src/gui/painting/qpdfwriter.h
+++ b/src/gui/painting/qpdfwriter.h
@@ -74,13 +74,16 @@ public:
void setResolution(int resolution);
int resolution() const;
+#ifdef Q_QDOC
bool setPageLayout(const QPageLayout &pageLayout);
bool setPageSize(const QPageSize &pageSize);
bool setPageOrientation(QPageLayout::Orientation orientation);
bool setPageMargins(const QMarginsF &margins);
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
-
QPageLayout pageLayout() const;
+#else
+ using QPagedPaintDevice::setPageSize;
+#endif
void setPageSize(PageSize size);
void setPageSizeMM(const QSizeF &size);
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 153fb23d36..bdc9a98f2e 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -220,6 +220,87 @@ void QPrinterPrivate::setProperty(QPrintEngine::PrintEnginePropertyKey key, cons
}
+class QPrinterPagedPaintDevicePrivate : public QPagedPaintDevicePrivate
+{
+public:
+ QPrinterPagedPaintDevicePrivate(QPrinterPrivate *d)
+ : QPagedPaintDevicePrivate(), pd(d)
+ {}
+
+ virtual ~QPrinterPagedPaintDevicePrivate()
+ {}
+
+ bool setPageLayout(const QPageLayout &newPageLayout) Q_DECL_OVERRIDE
+ {
+ if (pd->paintEngine->type() != QPaintEngine::Pdf
+ && pd->printEngine->printerState() == QPrinter::Active) {
+ qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
+ return false;
+ }
+
+ // Try to set the print engine page layout
+ pd->setProperty(QPrintEngine::PPK_QPageLayout, QVariant::fromValue(newPageLayout));
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().isEquivalentTo(newPageLayout);
+ }
+
+ bool setPageSize(const QPageSize &pageSize) Q_DECL_OVERRIDE
+ {
+ if (pd->paintEngine->type() != QPaintEngine::Pdf
+ && pd->printEngine->printerState() == QPrinter::Active) {
+ qWarning("QPrinter::setPageLayout: Cannot be changed while printer is active");
+ return false;
+ }
+
+
+ // Try to set the print engine page size
+ pd->setProperty(QPrintEngine::PPK_QPageSize, QVariant::fromValue(pageSize));
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().pageSize().isEquivalentTo(pageSize);
+ }
+
+ bool setPageOrientation(QPageLayout::Orientation orientation) Q_DECL_OVERRIDE
+ {
+ // Set the print engine value
+ pd->setProperty(QPrintEngine::PPK_Orientation, orientation);
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().orientation() == orientation;
+ }
+
+ bool setPageMargins(const QMarginsF &margins) Q_DECL_OVERRIDE
+ {
+ return setPageMargins(margins, pageLayout().units());
+ }
+
+ bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) Q_DECL_OVERRIDE
+ {
+ // Try to set print engine margins
+ QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units);
+ pd->setProperty(QPrintEngine::PPK_QPageMargins, QVariant::fromValue(pair));
+
+ // Set QPagedPaintDevice layout to match the current print engine value
+ m_pageLayout = pageLayout();
+
+ return pageLayout().margins() == margins && pageLayout().units() == units;
+ }
+
+ QPageLayout pageLayout() const Q_DECL_OVERRIDE
+ {
+ return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
+ }
+
+ QPrinterPrivate *pd;
+};
+
/*!
\class QPrinter
@@ -601,6 +682,8 @@ QPrinter::QPrinter(PrinterMode mode)
: QPagedPaintDevice(),
d_ptr(new QPrinterPrivate(this))
{
+ delete d;
+ d = new QPrinterPagedPaintDevicePrivate(d_func());
d_ptr->init(QPrinterInfo(), mode);
}
@@ -613,6 +696,8 @@ QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode)
: QPagedPaintDevice(),
d_ptr(new QPrinterPrivate(this))
{
+ delete d;
+ d = new QPrinterPagedPaintDevicePrivate(d_func());
d_ptr->init(printer, mode);
}
@@ -947,7 +1032,10 @@ void QPrinter::setCreator(const QString &creator)
d->setProperty(QPrintEngine::PPK_Creator, creator);
}
+// Defined in QPagedPaintDevice but non-virtual, add QPrinter specific doc here
+#ifdef Q_QDOC
/*!
+ \fn bool QPrinter::setPageLayout(const QPageLayout &newLayout)
\since 5.3
Sets the page layout to \a newLayout.
@@ -961,23 +1049,8 @@ void QPrinter::setCreator(const QString &creator)
\sa pageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
*/
-bool QPrinter::setPageLayout(const QPageLayout &newLayout)
-{
- Q_D(QPrinter);
-
- if (d->paintEngine->type() != QPaintEngine::Pdf)
- ABORT_IF_ACTIVE_RETURN("QPrinter::setPageLayout", false);
-
- // Try to set the print engine page layout
- d->setProperty(QPrintEngine::PPK_QPageLayout, QVariant::fromValue(newLayout));
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().isEquivalentTo(newLayout);
-}
-
/*!
+ \fn bool QPrinter::setPageSize(const QPageSize &pageSize)
\since 5.3
Sets the page size to \a pageSize.
@@ -995,23 +1068,8 @@ bool QPrinter::setPageLayout(const QPageLayout &newLayout)
\sa pageLayout(), setPageLayout()
*/
-bool QPrinter::setPageSize(const QPageSize &pageSize)
-{
- Q_D(QPrinter);
-
- if (d->paintEngine->type() != QPaintEngine::Pdf)
- ABORT_IF_ACTIVE_RETURN("QPrinter::setPageSize", false);
-
- // Try to set the print engine page size
- d->setProperty(QPrintEngine::PPK_QPageSize, QVariant::fromValue(pageSize));
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().pageSize().isEquivalentTo(pageSize);
-}
-
/*!
+ \fn bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
\since 5.3
Sets the page \a orientation to QPageLayout::Portrait or QPageLayout::Landscape.
@@ -1029,20 +1087,8 @@ bool QPrinter::setPageSize(const QPageSize &pageSize)
\sa pageLayout(), setPageLayout()
*/
-bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
-{
- Q_D(QPrinter);
-
- // Set the print engine value
- d->setProperty(QPrintEngine::PPK_Orientation, orientation);
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().orientation() == orientation;
-}
-
/*!
+ \fn bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
\since 5.3
Set the page margins to \a margins in the given \a units. If \a units are
@@ -1059,21 +1105,10 @@ bool QPrinter::setPageOrientation(QPageLayout::Orientation orientation)
\sa pageLayout(), setPageLayout()
*/
-bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
-{
- Q_D(QPrinter);
-
- // Try to set print engine margins
- QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units);
- d->setProperty(QPrintEngine::PPK_QPageMargins, QVariant::fromValue(pair));
-
- // Set QPagedPaintDevice layout to match the current print engine value
- devicePageLayout() = pageLayout();
-
- return pageLayout().margins() == margins && pageLayout().units() == units;
-}
-
/*!
+ \fn QPageLayout QPrinter::pageLayout() const
+ \since 5.3
+
Returns the current page layout. Use this method to access the current
QPageSize, QPageLayout::Orientation, QMarginsF, fullPageRect() and paintRect().
@@ -1082,12 +1117,7 @@ bool QPrinter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
\sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
*/
-
-QPageLayout QPrinter::pageLayout() const
-{
- Q_D(const QPrinter);
- return d->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>();
-}
+#endif
/*!
\obsolete Use pageLayout().pageOrientation() instead.
diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h
index 1f0639d81f..fa102d0fe3 100644
--- a/src/printsupport/kernel/qprinter.h
+++ b/src/printsupport/kernel/qprinter.h
@@ -307,11 +307,17 @@ public:
void setCreator(const QString &);
QString creator() const;
+#ifdef Q_QDOC
bool setPageLayout(const QPageLayout &pageLayout);
bool setPageSize(const QPageSize &pageSize);
bool setPageOrientation(QPageLayout::Orientation orientation);
+ bool setPageMargins(const QMarginsF &margins);
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
QPageLayout pageLayout() const;
+#else
+ using QPagedPaintDevice::setPageSize;
+ using QPagedPaintDevice::setPageMargins;
+#endif
void setOrientation(Orientation);
Orientation orientation() const;