summaryrefslogtreecommitdiffstats
path: root/filters/kword/pdf/FilterPage.h
blob: 234eb6e7eaf6418f9905bc89f81dfa4506d9f517 (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) 2002-2003 Nicolas HADACEK (hadacek@kde.org)
 *
 * 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.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef FILTERPAGE_H
#define FILTERPAGE_H

#include "TextOutputDev.h"

#include <tqdatetime.h>
#include <tqptrlist.h>

#include "fstring.h"


namespace PDFImport
{

class Paragraph;
class Data;

class Page : public TextPage
{
public:
    Page(Data &data);

    TQValueVector<DRect> &rects() { return _rects; }
    bool hasHeader() const;
    bool hasFooter() const;

    void clear();

    // first pass
    void beginString(GfxState *, double x0, double y0);
    void addString(TextString *);
    void endString();
    void addLink(Link *link) { _links.append(link); }
    void endPage();

    // second pass
    void dump();

public:
    TQValueList<TQDomElement> pictures;

private:
    FontFamily checkSpecial(TQChar &, const Font &) const;
    static TextBlock *block(TextLine *, int index);
    static bool isLastParagraphLine(TextLine *, const Paragraph &);

    // first pass
    void createParagraphs();
    void checkHeader();
    void checkFooter();

    // second pass
    void initParagraph(Paragraph &) const;
    void fillParagraph(Paragraph &, double &offset) const;
    void checkSpecialChars(Paragraph &) const;
    void coalesce(Paragraph &) const;
    void prepare();
    void dump(const Paragraph &);

private:
    Data &_data;
    TQValueList<Paragraph> _pars;
    TQPtrList<Link> _links;
    String *_lastStr;
    TQTime _time; // debug
    TQValueVector<DRect> _rects;
};

} // namespace

#endif