filters

fstring.h
1/*
2 * Copyright (c) 2002-2003 Nicolas HADACEK (hadacek@kde.org)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef FSTRING_H
21#define FSTRING_H
22
23#include "TextOutputDev.h"
24
25#include <tqvaluevector.h>
26
27#include "misc.h"
28
29
30namespace PDFImport
31{
32
33class Data;
34
35//-----------------------------------------------------------------------------
36class Tabulator
37{
38public:
39 enum Alignment { Left = 0, Center, Right, Character };
40 enum Filling { Blank = 0, Dots, Line, Dash, DashDot, DashDotDot };
41
42 Tabulator() : alignment(Left) {}
43
44 TQDomElement createElement(Data &data) const;
45
46public:
47 double pos;
48 Alignment alignment;
49 Filling filling;
50 TQChar alignmentChar;
51};
52
53inline bool operator <(const Tabulator &t1, const Tabulator &t2)
54{ return t1.pos<t2.pos; }
55
56//-----------------------------------------------------------------------------
57class Block
58{
59public:
60 Block() : link(0) {}
61
62public:
63 Font font;
64 const Link *link;
65 TQString text;
66};
67
68//-----------------------------------------------------------------------------
69enum Align { AlignLeft, AlignRight, AlignCenter, AlignBlock };
70
71class Paragraph
72{
73public:
74 Paragraph();
75 Paragraph(TextLine *first, uint nbLines);
76
77 const DRect &rect() const { return _rect; }
78
79 bool hasOneLine() const { return _lines.count()==1; }
80 const TQValueList<TextLine *> lines() const { return _lines; }
81 bool isFirst(const TextLine *line) const { return line==_lines.first();}
82 bool isSecond(const TextLine* line) const
83 { return (_lines.count()>1 && line==_lines.first()->next); }
84 bool isLast(const TextLine *line) const { return line==_lines.last(); }
85
86 int findTab(double xMin, const TextLine *) const;
87 uint findNbTabs(uint i, double prevXMax) const;
88 int charFromEnd(uint dec, uint &blockIndex) const;
89
90public:
91 ParagraphType type;
92 uint frameIndex;
93 double firstIndent, leftIndent, offset;
94 Align align;
95 TQValueVector<Tabulator> tabs;
96 TQValueList<Block> blocks;
97
98private:
99 TQValueList<TextLine *> _lines;
100 DRect _rect;
101};
102
103//-----------------------------------------------------------------------------
104class String : public TextString
105{
106public:
107 String(GfxState *state, double x0, double y0,
108 double fontSize, uint frameIndex);
109
110 uint frameIndex() const { return _frameIndex; }
111 const Font &font() const { return _font; }
112 DRect rect() const { return DRect(xMin, xMax, yMin, yMax); }
113 bool checkCombination(TextString *s);
114
115public:
116 const Link *link;
117
118private:
119 void addChar(GfxState *state, double x, double y,
120 double dx, double dy, Unicode u);
121
122private:
123 Font _font;
124 uint _frameIndex;
125};
126
127} // namespace
128
129#endif