From bdc3ec0964fd1f259c1d69907d147f7e91f56830 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 18 Jul 2007 07:11:42 +0000 Subject: [PATCH] Create a PaintContext for the KoTextDocumentLayout which holds the viewConverter. svn path=/trunk/koffice/; revision=689412 --- libs/kotext/KoTextDocumentLayout.cpp | 12 +++++++----- libs/kotext/KoTextDocumentLayout.h | 13 ++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libs/kotext/KoTextDocumentLayout.cpp b/libs/kotext/KoTextDocumentLayout.cpp index 87110f01a2..baecd2a65d 100644 --- a/libs/kotext/KoTextDocumentLayout.cpp +++ b/libs/kotext/KoTextDocumentLayout.cpp @@ -51,7 +51,7 @@ public: bool nextParag() { return false; } bool previousParag() { return false; } double documentOffsetInShape() { return 0; } - void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &, const KoViewConverter*) {} + void draw(QPainter *, const KoTextDocumentLayout::PaintContext &) {} KoStyleManager *styleManager() const { return m_styleManager; } void setStyleManager(KoStyleManager *sm) { m_styleManager = sm; } bool setFollowupShape(KoShape *) { return false; } @@ -157,12 +157,14 @@ QSizeF KoTextDocumentLayout::documentSize() const { return QSizeF(10, 10); } -void KoTextDocumentLayout::draw(QPainter *painter, const PaintContext &context) { - m_state->draw(painter, context, 0); +void KoTextDocumentLayout::draw(QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context) { + PaintContext pc; + pc.textContext = context; + m_state->draw(painter, pc); } -void KoTextDocumentLayout::draw ( QPainter * painter, const PaintContext & context, const KoViewConverter *converter ) { - m_state->draw(painter, context, converter); +void KoTextDocumentLayout::draw ( QPainter * painter, const KoTextDocumentLayout::PaintContext & context) { + m_state->draw(painter, context); } QRectF KoTextDocumentLayout::frameBoundingRect(QTextFrame *frame) const { diff --git a/libs/kotext/KoTextDocumentLayout.h b/libs/kotext/KoTextDocumentLayout.h index e3ead11f8b..9bdbea38be 100644 --- a/libs/kotext/KoTextDocumentLayout.h +++ b/libs/kotext/KoTextDocumentLayout.h @@ -42,6 +42,13 @@ class KOTEXT_EXPORT KoTextDocumentLayout : public QAbstractTextDocumentLayout { Q_OBJECT public: class LayoutState; + + struct PaintContext { + PaintContext() : viewConverter(0) { } + QAbstractTextDocumentLayout::PaintContext textContext; + const KoViewConverter *viewConverter; + }; + /// constructor explicit KoTextDocumentLayout(QTextDocument *document, KoTextDocumentLayout::LayoutState *layout = 0); virtual ~KoTextDocumentLayout(); @@ -74,9 +81,9 @@ public: */ virtual QSizeF documentSize () const; /// Draws the layout on the given painter with the given context. - virtual void draw ( QPainter * painter, const PaintContext & context ); + virtual void draw ( QPainter * painter, const QAbstractTextDocumentLayout::PaintContext & context ); /// Draws the layout on the given painter with the given context, and pass the zoom. - void draw ( QPainter * painter, const PaintContext & context, const KoViewConverter *converter ); + void draw ( QPainter * painter, const KoTextDocumentLayout::PaintContext & context); /// Returns the bounding rectacle of frame. Returns the bounding rectangle of frame. virtual QRectF frameBoundingRect ( QTextFrame * frame ) const; /** @@ -144,7 +151,7 @@ public: /// Return the y position of the offset for the current shape (See KoTextShapeData::documentOffset() ) virtual double documentOffsetInShape() = 0; /// paint the document - virtual void draw(QPainter *painter, const PaintContext & context, const KoViewConverter *converter ) = 0; + virtual void draw(QPainter *painter, const KoTextDocumentLayout::PaintContext & context) = 0; /** * After all shapes have been used and there is still text left, use the param shape to continue * layout. -- GitLab