Commit bdc3ec09 authored by Thomas Zander's avatar Thomas Zander

Create a PaintContext for the KoTextDocumentLayout which holds the viewConverter.

svn path=/trunk/koffice/; revision=689412
parent 8f557148
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
bool nextParag() { return false; } bool nextParag() { return false; }
bool previousParag() { return false; } bool previousParag() { return false; }
double documentOffsetInShape() { return 0; } double documentOffsetInShape() { return 0; }
void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &, const KoViewConverter*) {} void draw(QPainter *, const KoTextDocumentLayout::PaintContext &) {}
KoStyleManager *styleManager() const { return m_styleManager; } KoStyleManager *styleManager() const { return m_styleManager; }
void setStyleManager(KoStyleManager *sm) { m_styleManager = sm; } void setStyleManager(KoStyleManager *sm) { m_styleManager = sm; }
bool setFollowupShape(KoShape *) { return false; } bool setFollowupShape(KoShape *) { return false; }
...@@ -157,12 +157,14 @@ QSizeF KoTextDocumentLayout::documentSize() const { ...@@ -157,12 +157,14 @@ QSizeF KoTextDocumentLayout::documentSize() const {
return QSizeF(10, 10); return QSizeF(10, 10);
} }
void KoTextDocumentLayout::draw(QPainter *painter, const PaintContext &context) { void KoTextDocumentLayout::draw(QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context) {
m_state->draw(painter, context, 0); PaintContext pc;
pc.textContext = context;
m_state->draw(painter, pc);
} }
void KoTextDocumentLayout::draw ( QPainter * painter, const PaintContext & context, const KoViewConverter *converter ) { void KoTextDocumentLayout::draw ( QPainter * painter, const KoTextDocumentLayout::PaintContext & context) {
m_state->draw(painter, context, converter); m_state->draw(painter, context);
} }
QRectF KoTextDocumentLayout::frameBoundingRect(QTextFrame *frame) const { QRectF KoTextDocumentLayout::frameBoundingRect(QTextFrame *frame) const {
......
...@@ -42,6 +42,13 @@ class KOTEXT_EXPORT KoTextDocumentLayout : public QAbstractTextDocumentLayout { ...@@ -42,6 +42,13 @@ class KOTEXT_EXPORT KoTextDocumentLayout : public QAbstractTextDocumentLayout {
Q_OBJECT Q_OBJECT
public: public:
class LayoutState; class LayoutState;
struct PaintContext {
PaintContext() : viewConverter(0) { }
QAbstractTextDocumentLayout::PaintContext textContext;
const KoViewConverter *viewConverter;
};
/// constructor /// constructor
explicit KoTextDocumentLayout(QTextDocument *document, KoTextDocumentLayout::LayoutState *layout = 0); explicit KoTextDocumentLayout(QTextDocument *document, KoTextDocumentLayout::LayoutState *layout = 0);
virtual ~KoTextDocumentLayout(); virtual ~KoTextDocumentLayout();
...@@ -74,9 +81,9 @@ public: ...@@ -74,9 +81,9 @@ public:
*/ */
virtual QSizeF documentSize () const; virtual QSizeF documentSize () const;
/// Draws the layout on the given painter with the given context. /// 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. /// 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. /// Returns the bounding rectacle of frame. Returns the bounding rectangle of frame.
virtual QRectF frameBoundingRect ( QTextFrame * frame ) const; virtual QRectF frameBoundingRect ( QTextFrame * frame ) const;
/** /**
...@@ -144,7 +151,7 @@ public: ...@@ -144,7 +151,7 @@ public:
/// Return the y position of the offset for the current shape (See KoTextShapeData::documentOffset() ) /// Return the y position of the offset for the current shape (See KoTextShapeData::documentOffset() )
virtual double documentOffsetInShape() = 0; virtual double documentOffsetInShape() = 0;
/// paint the document /// 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 * After all shapes have been used and there is still text left, use the param shape to continue
* layout. * layout.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment