Commit 0edb09e9 authored by Christophe Devriese's avatar Christophe Devriese

imported code from qpdf, now it works again !

svn path=/trunk/kdegraphics/kpdf/; revision=220285
parent 98ae1fcf
......@@ -6,7 +6,7 @@ SUBDIRS = .
INCLUDES = -I.. -I$(top_srcdir)/kpdf/goo -I$(top_srcdir)/kpdf/xpdf $(all_includes)
# these are the headers for your project
noinst_HEADERS = kpdf_shell.h kpdf_part.h kpdf_canvas.h kpdf_pagewidget.h
noinst_HEADERS = kpdf_shell.h kpdf_part.h kpdf_canvas.h kpdf_pagewidget.h QOutputDev.h
# let automoc handle all of the meta source files (moc)
......@@ -43,7 +43,7 @@ shellrc_DATA = kpdf_shell.rc
kde_module_LTLIBRARIES =
# the Part's source, library search path, and link libraries
libkpdfpart_la_SOURCES = kpdf_canvas.cpp kpdf_part.cpp
libkpdfpart_la_SOURCES = kpdf_canvas.cpp kpdf_part.cpp QOutputDev.cpp
libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkpdfpart_la_LIBADD = ../xpdf/ $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT)
This diff is collapsed.
// XOutputDev.h
// Copyright 1996 Derek B. Noonburg
#ifdef __GNUC__
#pragma interface
#include "aconf.h"
#include <stddef.h>
#include <qscrollview.h>
class Object;
#include "config.h"
#include "CharTypes.h"
#include "GlobalParams.h"
#include "OutputDev.h"
class GString;
class GList;
struct GfxRGB;
class GfxFont;
class GfxSubpath;
class TextPage;
class XOutputFontCache;
class Link;
class Catalog;
class DisplayFontParam;
class UnicodeMap;
class CharCodeToUnicode;
class QPainter;
class QPixmap;
class QPointArray;
typedef double fp_t;
// Constants
// Misc types
// XOutputDev
class QOutputDev : public QScrollView, public OutputDev {
// Constructor.
QOutputDev( QWidget *parent = 0, const char *name = 0, int flags = 0 );
// Destructor.
virtual ~QOutputDev();
//---- get info about output device
// Does this device use upside-down coordinates?
// (Upside-down means (0,0) is the top left corner of the page.)
virtual GBool upsideDown() { return gTrue; }
// Does this device use drawChar() or drawString()?
virtual GBool useDrawChar() { return gTrue; }
// Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString.
virtual GBool interpretType3Chars() { return gFalse; }
// Does this device need non-text content?
virtual GBool needNonText() { return gFalse; }
//----- initialization and control
// Start a page.
virtual void startPage(int pageNum, GfxState *state);
// End a page.
virtual void endPage();
//----- link borders
virtual void drawLink(Link *link, Catalog *catalog);
//----- save/restore graphics state
virtual void saveState(GfxState *state);
virtual void restoreState(GfxState *state);
//----- update graphics state
virtual void updateAll(GfxState *state);
virtual void updateCTM(GfxState *state, fp_t m11, fp_t m12,
fp_t m21, fp_t m22, fp_t m31, fp_t m32);
virtual void updateLineDash(GfxState *state);
virtual void updateFlatness(GfxState *state);
virtual void updateLineJoin(GfxState *state);
virtual void updateLineCap(GfxState *state);
virtual void updateMiterLimit(GfxState *state);
virtual void updateLineWidth(GfxState *state);
virtual void updateFillColor(GfxState *state);
virtual void updateStrokeColor(GfxState *state);
//----- update text state
virtual void updateFont(GfxState *state);
//----- path painting
virtual void stroke(GfxState *state);
virtual void fill(GfxState *state);
virtual void eoFill(GfxState *state);
//----- path clipping
virtual void clip(GfxState *state);
virtual void eoClip(GfxState *state);
//----- text drawing
virtual void beginString(GfxState *state, GString *s);
virtual void endString(GfxState *state);
virtual void drawChar(GfxState *state, fp_t x, fp_t y,
fp_t dx, fp_t dy,
fp_t originX, fp_t originY,
CharCode code, Unicode *u, int uLen);
//----- image drawing
virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
int width, int height, GBool invert,
GBool inlineImg);
virtual void drawImage(GfxState *state, Object *ref, Stream *str,
int width, int height, GfxImageColorMap *colorMap,
int *maskColors, GBool inlineImg);
// Find a string. If <top> is true, starts looking at <l>,<t>;
// otherwise starts looking at top of page. If <bottom> is true,
// stops looking at <l+w-1>,<t+h-1>; otherwise stops looking at bottom
// of page. If found, sets the text bounding rectange and returns
// true; otherwise returns false.
GBool findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax );
//----- special QT access
bool findText ( const QString &str, int &l, int &t, int &w, int &h, bool top = 0, bool bottom = 0 );
bool findText ( const QString &str, QRect &r, bool top = 0, bool bottom = 0 );
// Get the text which is inside the specified rectangle.
QString getText ( int left, int top, int width, int height );
QString getText ( const QRect &r );
virtual void drawContents ( QPainter *p, int, int, int, int );
QPixmap *m_pixmap; // pixmap to draw into
QPainter *m_painter;
TextPage *m_text; // text from the current page
QFont matchFont ( GfxFont *, fp_t m11, fp_t m12, fp_t m21, fp_t m22 );
void updateLineAttrs ( GfxState *state, GBool updateDash );
void doFill ( GfxState *state, bool winding );
void doClip ( GfxState *state, bool winding );
int convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths );
int convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points );
......@@ -29,7 +29,6 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name,
const QStringList & /*args*/ )
: KParts::ReadOnlyPart(parent, name),
m_pagePixmap(1, 1),
......@@ -42,22 +41,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
// we need an instance
m_canvas = new Canvas(parentWidget, widgetName);
m_pageWidget = new PageWidget(m_canvas->viewport());
connect(m_pageWidget, SIGNAL(linkClicked(LinkAction*)),
Pixmap pixmap = m_pagePixmap.handle();
Display* display = m_pagePixmap.x11Display();
Colormap colormap = m_pagePixmap.x11Colormap();
int screen = m_pagePixmap.x11Screen();
m_outputDev = new XOutputDev(display, pixmap, 0, colormap, false,
WhitePixel(display, screen), false, 5);
m_outputDev = new QOutputDev(parentWidget, widgetName);
// create our actions
KStdAction::find (this, SLOT(find()),
......@@ -88,7 +73,6 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
delete m_outputDev;
......@@ -129,8 +113,7 @@ Part::openFile()
// just for fun, set the status bar
// emit setStatusBarText( QString::number( m_doc->getNumPages() ) );
m_doc->displayPage( m_outputDev , 1, 72, 0, false );
return true;
......@@ -154,9 +137,9 @@ Part::displayPage(int pageNumber, float /*zoomFactor*/)
const double pageAR = pageWidth/pageHeight; // Aspect ratio
const int canvasWidth = m_canvas->contentsRect().width();
const int canvasHeight = m_canvas->contentsRect().height();
const int scrollBarWidth = m_canvas->verticalScrollBar()->width();
const int canvasWidth = m_outputDev->contentsRect().width();
const int canvasHeight = m_outputDev->contentsRect().height();
const int scrollBarWidth = m_outputDev->verticalScrollBar()->width();
// Calculate the height so that the page fits the viewport width
// assuming that we need a vertical scrollbar.
......@@ -186,17 +169,9 @@ Part::displayPage(int pageNumber, float /*zoomFactor*/)
const float ppp = basePpp * m_zoomFactor; // pixels per point
m_pagePixmap.resize(ceil(pageWidth*ppp), ceil(pageHeight*ppp));
m_pagePixmap.width(), m_pagePixmap.height());
m_doc->displayPage(m_outputDev, pageNumber, int(ppp*72.0), 0, true);
m_currentPage = pageNumber;
......@@ -8,6 +8,8 @@
#include <kparts/browserextension.h>
#include <kparts/part.h>
#include <QOutputDev.h>
class QPainter;
class QPixmap;
class QWidget;
......@@ -85,11 +87,8 @@ namespace KPDF
void executeAction(LinkAction*);
Canvas* m_canvas;
QPixmap m_pagePixmap;
PageWidget* m_pageWidget;
PDFDoc* m_doc;
XOutputDev* m_outputDev;
QOutputDev* m_outputDev;
KToggleAction* m_fitToWidth;
......@@ -77,7 +77,7 @@ Shell::setupActions()
KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
KStdAction::quit(kapp, SLOT(quit()), actionCollection());
KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
......@@ -21,6 +21,5 @@ noinst_HEADERS = Annot.h Array.h BuiltinFont.h BuiltinFontTables.h \
OutputDev.h PBMOutputDev.h PDFDoc.h PSOutputDev.h \
PSTokenizer.h Page.h Parser.h SFont.h Stream-CCITT.h Stream.h \
TextOutputDev.h UTF8.h UnicodeMap.h UnicodeMapTables.h \
XOutputDev.h XPDFApp.h XPDFCore.h XPDFTree.h XPDFTreeP.h XPDFViewer.h \
XPixmapOutputDev.h XRef.h config.h xpdf-ltk.h
XOutputDev.h XRef.h config.h xpdf-ltk.h
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