filters
fstring.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef FSTRING_H
00021 #define FSTRING_H
00022
00023 #include "TextOutputDev.h"
00024
00025 #include <qvaluevector.h>
00026
00027 #include "misc.h"
00028
00029
00030 namespace PDFImport
00031 {
00032
00033 class Data;
00034
00035
00036 class Tabulator
00037 {
00038 public:
00039 enum Alignment { Left = 0, Center, Right, Character };
00040 enum Filling { Blank = 0, Dots, Line, Dash, DashDot, DashDotDot };
00041
00042 Tabulator() : alignment(Left) {}
00043
00044 QDomElement createElement(Data &data) const;
00045
00046 public:
00047 double pos;
00048 Alignment alignment;
00049 Filling filling;
00050 QChar alignmentChar;
00051 };
00052
00053 inline bool operator <(const Tabulator &t1, const Tabulator &t2)
00054 { return t1.pos<t2.pos; }
00055
00056
00057 class Block
00058 {
00059 public:
00060 Block() : link(0) {}
00061
00062 public:
00063 Font font;
00064 const Link *link;
00065 QString text;
00066 };
00067
00068
00069 enum Align { AlignLeft, AlignRight, AlignCenter, AlignBlock };
00070
00071 class Paragraph
00072 {
00073 public:
00074 Paragraph();
00075 Paragraph(TextLine *first, uint nbLines);
00076
00077 const DRect &rect() const { return _rect; }
00078
00079 bool hasOneLine() const { return _lines.count()==1; }
00080 const QValueList<TextLine *> lines() const { return _lines; }
00081 bool isFirst(const TextLine *line) const { return line==_lines.first();}
00082 bool isSecond(const TextLine* line) const
00083 { return (_lines.count()>1 && line==_lines.first()->next); }
00084 bool isLast(const TextLine *line) const { return line==_lines.last(); }
00085
00086 int findTab(double xMin, const TextLine *) const;
00087 uint findNbTabs(uint i, double prevXMax) const;
00088 int charFromEnd(uint dec, uint &blockIndex) const;
00089
00090 public:
00091 ParagraphType type;
00092 uint frameIndex;
00093 double firstIndent, leftIndent, offset;
00094 Align align;
00095 QValueVector<Tabulator> tabs;
00096 QValueList<Block> blocks;
00097
00098 private:
00099 QValueList<TextLine *> _lines;
00100 DRect _rect;
00101 };
00102
00103
00104 class String : public TextString
00105 {
00106 public:
00107 String(GfxState *state, double x0, double y0,
00108 double fontSize, uint frameIndex);
00109
00110 uint frameIndex() const { return _frameIndex; }
00111 const Font &font() const { return _font; }
00112 DRect rect() const { return DRect(xMin, xMax, yMin, yMax); }
00113 bool checkCombination(TextString *s);
00114
00115 public:
00116 const Link *link;
00117
00118 private:
00119 void addChar(GfxState *state, double x, double y,
00120 double dx, double dy, Unicode u);
00121
00122 private:
00123 Font _font;
00124 uint _frameIndex;
00125 };
00126
00127 }
00128
00129 #endif
|