2004-08-26 21:17:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* 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) 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. *
|
|
|
|
***************************************************************************/
|
2003-04-15 12:14:00 +00:00
|
|
|
|
2004-09-15 20:45:00 +00:00
|
|
|
#ifndef KPDFOUTPUTDEV_H
|
|
|
|
#define KPDFOUTPUTDEV_H
|
2003-04-15 12:14:00 +00:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
#include <qvaluelist.h>
|
|
|
|
#include "xpdf/PDFDoc.h" // for 'Object'
|
|
|
|
#include "xpdf/SplashOutputDev.h"
|
2003-04-15 12:14:00 +00:00
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
class QPixmap;
|
2003-04-15 12:14:00 +00:00
|
|
|
class TextPage;
|
2004-12-21 12:38:52 +00:00
|
|
|
class PDFGenerator;
|
2004-10-02 14:30:30 +00:00
|
|
|
class KPDFLink;
|
2004-12-10 16:04:45 +00:00
|
|
|
class KPDFPageRect;
|
2003-04-15 12:14:00 +00:00
|
|
|
|
2004-09-15 20:45:00 +00:00
|
|
|
/**
|
2004-09-16 21:04:49 +00:00
|
|
|
* @short A SplashOutputDev renderer that grabs text and links.
|
2004-12-10 16:04:45 +00:00
|
|
|
* ### MERGE: rename definition/impl to generator_pdf_outputdev.h/.cpp
|
2004-09-15 20:45:00 +00:00
|
|
|
*
|
2004-11-07 14:07:08 +00:00
|
|
|
* This output device:
|
2004-09-15 20:45:00 +00:00
|
|
|
* - renders the page using SplashOutputDev (its parent)
|
|
|
|
* - harvests text into a textPage (for searching text)
|
2004-12-10 16:04:45 +00:00
|
|
|
* - harvests links and collects them
|
|
|
|
* - collects images and collects them
|
2004-09-15 20:45:00 +00:00
|
|
|
*/
|
|
|
|
class KPDFOutputDev : public SplashOutputDev
|
2004-08-25 16:27:34 +00:00
|
|
|
{
|
2004-11-07 14:07:08 +00:00
|
|
|
public:
|
2004-12-21 12:38:52 +00:00
|
|
|
KPDFOutputDev( PDFGenerator * parent, SplashColor paperColor );
|
2004-11-07 14:07:08 +00:00
|
|
|
virtual ~KPDFOutputDev();
|
|
|
|
|
|
|
|
// to be called before PDFDoc->displayPage( thisclass, .. )
|
|
|
|
void setParams( int pixmapWidth, int pixmapHeight, bool generateTextpage,
|
2004-12-11 17:25:03 +00:00
|
|
|
bool decodeLinks, bool decodeImages );
|
2004-12-10 16:04:45 +00:00
|
|
|
|
|
|
|
// generate a valid KPDFLink subclass (or null) from a xpdf's LinkAction
|
|
|
|
KPDFLink * generateLink( LinkAction * );
|
2004-11-07 14:07:08 +00:00
|
|
|
|
|
|
|
// takes pointers out of the class (so deletion it's up to others)
|
|
|
|
QPixmap * takePixmap();
|
|
|
|
TextPage * takeTextPage();
|
2004-12-10 16:04:45 +00:00
|
|
|
QValueList< KPDFPageRect * > takeRects();
|
2004-11-07 14:07:08 +00:00
|
|
|
|
|
|
|
/** inherited from OutputDev */
|
|
|
|
// 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);
|
|
|
|
//----- update text state
|
|
|
|
virtual void updateFont(GfxState *state);
|
|
|
|
//----- text drawing
|
|
|
|
virtual void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, Unicode *u, int uLen);
|
|
|
|
virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
|
|
|
|
//----- image drawing
|
|
|
|
virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height,
|
|
|
|
GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// delete all interal objects and data
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
// generator switches and parameters
|
|
|
|
bool m_generateText;
|
|
|
|
bool m_generateLinks;
|
2004-12-10 16:04:45 +00:00
|
|
|
bool m_generateImages;
|
2004-11-07 14:07:08 +00:00
|
|
|
int m_pixmapWidth;
|
|
|
|
int m_pixmapHeight;
|
|
|
|
QPixmap * m_pixmap;
|
2004-12-21 12:38:52 +00:00
|
|
|
PDFGenerator * m_generator;
|
2004-11-07 14:07:08 +00:00
|
|
|
|
|
|
|
// text page generated on demand
|
|
|
|
TextPage * m_text;
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
// rectangles on page (associated to links/images)
|
|
|
|
QValueList< KPDFPageRect * > m_rects;
|
2003-04-15 12:14:00 +00:00
|
|
|
};
|
|
|
|
|
2004-09-16 21:04:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Collect text into a takeable TextPage.
|
|
|
|
*
|
|
|
|
* This is the simplest OutputDev. It harvests text from currently
|
|
|
|
* rendered page and provides a method for getting the TextPage.
|
2004-10-02 14:30:30 +00:00
|
|
|
* Xpdf's textOutputDev can't return a textpage, unfortunately, and
|
|
|
|
* KPDFOutputDev is too heavy for sucha a simple task.
|
2004-09-16 21:04:49 +00:00
|
|
|
*/
|
|
|
|
class KPDFTextDev : public OutputDev
|
|
|
|
{
|
2004-11-07 14:07:08 +00:00
|
|
|
public:
|
|
|
|
KPDFTextDev();
|
|
|
|
virtual ~KPDFTextDev();
|
|
|
|
|
|
|
|
// takes pointers out of the class (so deletion it's up to others)
|
|
|
|
TextPage * takeTextPage();
|
|
|
|
|
|
|
|
/** inherited from OutputDev */
|
|
|
|
// top left corner is (0,0)
|
|
|
|
virtual GBool upsideDown() { return gTrue; }
|
|
|
|
// use draw char to get text data
|
|
|
|
virtual GBool useDrawChar() { return gTrue; }
|
|
|
|
// use drawChar even for Type3 chars
|
|
|
|
virtual GBool interpretType3Chars() { return gFalse; }
|
|
|
|
// do not pass non-text to this device
|
|
|
|
virtual GBool needNonText() { return gFalse; }
|
|
|
|
|
|
|
|
// Start a page.
|
|
|
|
virtual void startPage(int, GfxState *state);
|
|
|
|
// End a page.
|
|
|
|
virtual void endPage();
|
|
|
|
//----- update text state
|
|
|
|
virtual void updateFont(GfxState *state);
|
|
|
|
//----- text drawing
|
|
|
|
virtual void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, Unicode *u, int uLen);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// text page generated by execution
|
|
|
|
TextPage * m_text;
|
2004-09-16 21:04:49 +00:00
|
|
|
};
|
|
|
|
|
2003-04-15 12:14:00 +00:00
|
|
|
#endif
|