summaryrefslogtreecommitdiffstats
path: root/kpdf/core/generator_pdf/gp_outputdev.h
blob: a4d33b04f2cba3ab224416dac6eeb5619d4c5c27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/***************************************************************************
 *   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.                                   *
 ***************************************************************************/

#ifndef KPDFOUTPUTDEV_H
#define KPDFOUTPUTDEV_H

#ifdef __GNUC__
#pragma interface
#endif

#include <tqvaluelist.h>
#include "xpdf/PDFDoc.h" // for 'Object'
#include "xpdf/SplashOutputDev.h"

class TQPixmap;
class KPDFLink;
class ObjectRect;
class DocumentViewport;

/**
 * @short A SplashOutputDev renderer that grabs text and links.
 *
 * This output device:
 * - renders the page using SplashOutputDev (its tqparent)
 * - harvests text into a textPage (for searching text)
 * - harvests links and collects them
 * - collects images and collects them
 */
class KPDFOutputDev : public SplashOutputDev
{
    public:
        KPDFOutputDev( SplashColor paperColor );
        virtual ~KPDFOutputDev();

        // initialize device -> attach device to PDFDoc
        void initDevice( class PDFDoc * pdfDoc );

        // set parameters before rendering *each* page
        // @param qtThreadSafety: duplicate memory buffer (slow but safe)
        void setParams( int pixmapWidth, int pixmapHeight, 
                        bool decodeLinks, bool decodeImages, bool qtThreadSafety = false );

        // takes pointers out of the class (so deletion it's up to others)
        TQPixmap * takePixmap();
        TQImage * takeImage();
        TQValueList< ObjectRect * > takeObjectRects();

        /** inherited from OutputDev */
        // End a page.
        virtual void endPage();
        //----- link borders
        virtual void processLink(Link *link, Catalog *catalog);
        //----- image drawing
        virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height,
                             GfxImageColorMap *colorMap, int *tqmaskColors, GBool inlineImg);

    private:
        // delete all interal objects and data
        void clear();
        // generate a valid KPDFLink subclass (or null) from a xpdf's LinkAction
        KPDFLink * generateLink( LinkAction * a );
        // fills up a Viewport structure out of a given LinkGoto link
        DocumentViewport decodeViewport( GString *, class LinkDest * );

        // generator switches and parameters
        bool m_qtThreadSafety;
        bool m_generateLinks;
        bool m_generateImages;
        int m_pixmapWidth;
        int m_pixmapHeight;

        // Internal objects
        PDFDoc * m_doc;
        TQPixmap * m_pixmap;
        TQImage * m_image;
        TQValueList< ObjectRect * > m_rects; // objectRects (links/images)
};

#endif