summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-11-11 15:38:00 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-11-11 15:44:51 (GMT)
commit06baf7f173b0331a5192616b8ecf9611130f278b (patch)
treecef1740eabeb5213a82290ad80144954d29cf908 /src/gui
parent223b5de63e56c6c3dfbc5000b460baa653ab3f75 (diff)
downloadQt-06baf7f173b0331a5192616b8ecf9611130f278b.zip
Qt-06baf7f173b0331a5192616b8ecf9611130f278b.tar.gz
Qt-06baf7f173b0331a5192616b8ecf9611130f278b.tar.bz2
Printing QTextDocument doesn't include custom objects.
We need to copy the abstract text layout's custom object handlers as well when we temporarily use a different QTextDocument. Task-number: QTBUG-5397 Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h1
-rw-r--r--src/gui/text/qtextcontrol.cpp4
-rw-r--r--src/gui/text/qtextdocument.cpp4
3 files changed, 9 insertions, 0 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 2f8a746..438b291 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -122,6 +122,7 @@ protected:
QTextCharFormat format(int pos);
private:
+ friend class QTextControl;
friend class QTextDocument;
friend class QTextDocumentPrivate;
friend class QTextEngine;
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 9497b6f..62039f3 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -55,6 +55,7 @@
#include <qstyle.h>
#include <qtimer.h>
#include "private/qtextdocumentlayout_p.h"
+#include "private/qabstracttextdocumentlayout_p.h"
#include "private/qtextedit_p.h"
#include "qtextdocument.h"
#include "private/qtextdocument_p.h"
@@ -2313,6 +2314,9 @@ void QTextControl::print(QPrinter *printer) const
tempDoc->setUseDesignMetrics(doc->useDesignMetrics());
QTextCursor(tempDoc).insertFragment(d->cursor.selection());
doc = tempDoc;
+
+ // copy the custom object handlers
+ doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers;
}
doc->print(printer);
delete tempDoc;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 1aad385..048325c 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -64,6 +64,7 @@
#include "qtextdocument_p.h"
#include <private/qprinter_p.h>
+#include <private/qabstracttextdocumentlayout_p.h>
#include <limits.h>
@@ -1722,6 +1723,9 @@ void QTextDocument::print(QPrinter *printer) const
QAbstractTextDocumentLayout *layout = doc->documentLayout();
layout->setPaintDevice(p.device());
+ // copy the custom object handlers
+ layout->d_func()->handlers = documentLayout()->d_func()->handlers;
+
int dpiy = p.device()->logicalDpiY();
int margin = 0;
if (printer->fullPage() && !printer->d_func()->hasCustomPageMargins) {