Commit b8c2ee05 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

QOutputDevKPrinter does not need to inherit from QOutputDev

Bye bye QOutputDevPixmap

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=344825
parent edf38cc6
# set the include path for X, qt and KDE
INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../splash -I$(srcdir)/../goo -I$(srcdir)/../xpdf $(all_includes) $(FREETYPE_CFLAGS)
# these are the headers for your project
noinst_HEADERS = kpdf_shell.h kpdf_part.h kpdf_pagewidget.h QOutputDevPixmap.h QOutputDev.h
# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO
......@@ -42,7 +39,7 @@ shellrc_DATA = kpdf_shell.rc
kde_module_LTLIBRARIES = libkpdfpart.la
# the Part's source, library search path, and link libraries
libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevPixmap.cpp QOutputDevKPrinter.cpp kpdf_part.cpp kpdf_pagewidget.cc part.cpp thumbnail.cpp thumbnaillist.cpp kpdf_error.cpp xpdf_errors.cpp thumbnailgenerator.cpp
libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevKPrinter.cpp kpdf_part.cpp kpdf_pagewidget.cc part.cpp thumbnail.cpp thumbnaillist.cpp kpdf_error.cpp xpdf_errors.cpp thumbnailgenerator.cpp
libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) $(LIB_KUTILS) -lm
......
......@@ -19,6 +19,7 @@
#pragma implementation
#endif
#include "SplashBitmap.h"
#include "TextOutputDev.h"
#include "QOutputDev.h"
......@@ -28,7 +29,7 @@
//------------------------------------------------------------------------
QOutputDev::QOutputDev(SplashColor paperColor)
: SplashOutputDev(splashModeRGB8, false, paperColor)
: SplashOutputDev(splashModeRGB8, false, paperColor), m_image(0)
{
// create text object
m_text = new TextPage ( gFalse );
......@@ -65,8 +66,15 @@ void QOutputDev::startPage(int pageNum, GfxState *state)
void QOutputDev::endPage()
{
SplashColorPtr dataPtr;
int bh, bw;
SplashOutputDev::endPage();
m_text->coalesce(gTrue);
bh = getBitmap()->getHeight();
bw = getBitmap()->getWidth();
dataPtr = getBitmap()->getDataPtr();
m_image = QImage((uchar*)dataPtr.rgb8, bw, bh, 32, 0, 0, QImage::IgnoreEndian);
}
void QOutputDev::updateFont(GfxState *state)
......@@ -79,3 +87,8 @@ bool QOutputDev::find(Unicode *s, int len, GBool startAtTop, GBool stopAtBottom,
{
return m_text -> findText(s, len, startAtTop, stopAtBottom, startAtLast, stopAtLast, xMin, yMin, xMax, yMax);
}
const QImage &QOutputDev::getImage() const
{
return m_image;
}
......@@ -19,15 +19,13 @@
#pragma interface
#endif
#include <qimage.h>
#include "XRef.h"
#include "SplashOutputDev.h"
class TextPage;
//------------------------------------------------------------------------
// QOutputDev
//------------------------------------------------------------------------
class QOutputDev : public SplashOutputDev
{
public:
......@@ -54,10 +52,12 @@ class QOutputDev : public SplashOutputDev
void clear();
bool find(Unicode *s, int len, GBool startAtTop, GBool stopAtBottom, GBool startAtLast, GBool stopAtLast, double *xMin, double *yMin, double *xMax, double *yMax);
const QImage &getImage() const;
private:
TextPage *m_text; // text from the current page
TextPage *m_text; // text from the current page
QImage m_image; // the image where the page is drawn
};
#endif
......@@ -20,7 +20,7 @@
#include <qimage.h>
QOutputDevKPrinter::QOutputDevKPrinter(QPainter& painter, SplashColor paperColor, KPrinter& printer )
: QOutputDev(paperColor), m_printer( printer ), m_painter( painter )
: SplashOutputDev(splashModeRGB8, false, paperColor), m_printer( printer ), m_painter( painter )
{
}
......@@ -30,18 +30,18 @@ QOutputDevKPrinter::~QOutputDevKPrinter()
void QOutputDevKPrinter::startPage(int page, GfxState *state)
{
// TODO: page size ?
QOutputDev::startPage( page, state);
// TODO: page size ?
SplashOutputDev::startPage( page, state);
}
void QOutputDevKPrinter::endPage()
{
SplashColorPtr dataPtr;
int bh, bw;
QOutputDev::endPage();
bh = getBitmap()->getHeight();
bw = getBitmap()->getWidth();
dataPtr = getBitmap()->getDataPtr();
m_painter.drawPixmap(0, 0, QImage((uchar*)dataPtr.rgb8, bw, bh, 32, 0, 0, QImage::IgnoreEndian));
SplashColorPtr dataPtr;
int bh, bw;
SplashOutputDev::endPage();
bh = getBitmap()->getHeight();
bw = getBitmap()->getWidth();
dataPtr = getBitmap()->getDataPtr();
m_painter.drawPixmap(0, 0, QImage((uchar*)dataPtr.rgb8, bw, bh, 32, 0, 0, QImage::IgnoreEndian));
}
......@@ -13,31 +13,27 @@
#ifndef QOUTPUTDEVKPRINTER_H
#define QOUTPUTDEVKPRINTER_H
#include "QOutputDev.h"
#include "XRef.h"
#include "SplashOutputDev.h"
class KPrinter;
class QPainter;
class QOutputDevKPrinter : public QOutputDev
class QOutputDevKPrinter : public SplashOutputDev
{
public:
QOutputDevKPrinter(QPainter& painter, SplashColor paperColor, KPrinter& printer);
virtual ~QOutputDevKPrinter();
//----- initialization and control
// Start a page.
virtual void startPage(int pageNum, GfxState *state);
// End a page
virtual void endPage();
protected:
void draw();
private:
KPrinter& m_printer; // the printer that we're drawing to
QPainter& m_painter; // the painter that we're drawing to
public:
QOutputDevKPrinter(QPainter& painter, SplashColor paperColor, KPrinter& printer);
virtual ~QOutputDevKPrinter();
// Start a page.
virtual void startPage(int pageNum, GfxState *state);
// End a page
virtual void endPage();
private:
KPrinter& m_printer; // the printer that we're drawing to
QPainter& m_painter; // the painter that we're drawing to
};
#endif
/***************************************************************************
* Copyright (C) 2003-2004 by Christophe Devriese *
* <Christophe.Devriese@student.kuleuven.ac.be> *
* Copyright (C) 2003 by Helio Chissini de Castro *
* <helio@conectiva.com.br> *
* Copyright (C) 2003 by Dirk Mueller <mueller@kde.org> *
* Copyright (C) 2003 by Scott Wheeler <wheeler@kde.org> *
* Copyright (C) 2003 by Ingo Klcker <kloecker@kde.org> *
* Copyright (C) 2003 by Andy Goossens <andygoossens@telenet.be> *
* Copyright (C) 2004 by Dominique Devriese <devriese@kde.org> *
* Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifdef __GNUC__
#pragma implementation
#endif
#include <GfxState.h>
#include <kdebug.h>
#include "SplashBitmap.h"
#include "SplashTypes.h"
#include "QOutputDevPixmap.h"
//------------------------------------------------------------------------
// QOutputDevPixmap
//------------------------------------------------------------------------
QOutputDevPixmap::QOutputDevPixmap(SplashColor paperColor) : QOutputDev(paperColor), m_image(0)
{
}
QOutputDevPixmap::~QOutputDevPixmap( )
{
}
void QOutputDevPixmap::endPage ( )
{
SplashColorPtr dataPtr;
int bh, bw;
QOutputDev::endPage();
bh = getBitmap()->getHeight();
bw = getBitmap()->getWidth();
dataPtr = getBitmap()->getDataPtr();
m_image = QImage((uchar*)dataPtr.rgb8, bw, bh, 32, 0, 0, QImage::IgnoreEndian);
}
const QImage &QOutputDevPixmap::getImage() const
{
return m_image;
}
/***************************************************************************
* Copyright (C) 2003-2004 by Christophe Devriese *
* <Christophe.Devriese@student.kuleuven.ac.be> *
* Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
* Copyright (C) 2003 by Helio Chissini de Castro *
* <helio@conectiva.com.br> *
* Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef QOUTPUTDEVPIXMAP_H
#define QOUTPUTDEVPIXMAP_H
#ifdef __GNUC__
#pragma interface
#endif
#include "QOutputDev.h"
#include <qimage.h>
class QOutputDevPixmap : public QOutputDev {
public:
// Constructor.
QOutputDevPixmap(SplashColor paperColor);
// Destructor.
virtual ~QOutputDevPixmap();
// End a page
virtual void endPage();
const QImage &getImage() const;
private:
QImage m_image;
};
#endif // QOUTPUTDEVPIXMAP
......@@ -24,7 +24,7 @@
#include "kpdf_pagewidget.h"
#include "kpdf_pagewidget.moc"
#include "QOutputDevPixmap.h"
#include "QOutputDev.h"
#include <qpushbutton.h>
#include <kiconloader.h>
......@@ -41,7 +41,7 @@ namespace KPDF
{
SplashColor paperColor;
paperColor.rgb8 = splashMakeRGB8(0xff, 0xff, 0xff);
m_outputdev = new QOutputDevPixmap(paperColor);
m_outputdev = new QOutputDev(paperColor);
setFocusPolicy( QWidget::StrongFocus );
viewport()->setFocusPolicy( QWidget::WheelFocus );
......
......@@ -27,7 +27,7 @@ class QWidget;
class LinkAction;
class PDFDoc;
class QOutputDevPixmap;
class QOutputDev;
namespace KPDF
{
......@@ -91,7 +91,7 @@ namespace KPDF
virtual void dropEvent( QDropEvent* );
private:
QOutputDevPixmap * m_outputdev;
QOutputDev *m_outputdev;
PDFDoc* m_doc;
QMutex* m_docMutex;
float m_ppp; // Pixels per point
......
......@@ -48,14 +48,12 @@
#include "kpdf_error.h"
#include "part.h"
#include "GString.h"
#include "GlobalParams.h"
#include "PDFDoc.h"
#include "TextOutputDev.h"
#include "QOutputDevKPrinter.h"
#include "QOutputDevPixmap.h"
#include "kpdf_pagewidget.h"
......
......@@ -17,7 +17,6 @@
#define _KPDF_PART_H_
#include <qmutex.h>
#include <qwidget.h>
#include <kparts/browserextension.h>
#include <kparts/part.h>
......
......@@ -14,6 +14,7 @@
#include "PDFDoc.h"
#include "QOutputDev.h"
#include "thumbnailgenerator.h"
ThumbnailGenerator::ThumbnailGenerator(PDFDoc *doc, QMutex *docMutex, int page, double ppp, QObject *o) : m_doc(doc), m_docMutex(docMutex), m_page(page), m_o(o), m_ppp(ppp)
......@@ -32,7 +33,7 @@ void ThumbnailGenerator::run()
SplashColor paperColor;
paperColor.rgb8 = splashMakeRGB8(0xff, 0xff, 0xff);
QOutputDevPixmap odev(paperColor);
QOutputDev odev(paperColor);
odev.startDoc(m_doc->getXRef());
m_docMutex->lock();
m_doc -> displayPage(&odev, m_page, m_ppp, m_ppp, 0, true, false);
......
......@@ -12,8 +12,6 @@
#include <qthread.h>
#include "QOutputDevPixmap.h"
class QMutex;
class PDFDoc;
......
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