filters
amiproparser.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __AMIPROPARSER_H
00021 #define __AMIPROPARSER_H
00022
00023 class QString;
00024 class QStringList;
00025 #include <qvaluelist.h>
00026 #include <qcolor.h>
00027
00028 class AmiPro
00029 {
00030 public:
00031 static const float LS_Single, LS_OneAndHalf, LS_Double;
00032 };
00033
00034 class AmiProStyle;
00035
00036 class AmiProFormat
00037 {
00038 public:
00039 int pos, len;
00040 bool bold, italic, underline;
00041 bool word_underline, double_underline;
00042 bool subscript, superscript, strikethrough;
00043 QString fontFamily;
00044 float fontSize;
00045 QColor fontColor;
00046 enum { Left, Right, Center, Justified } align;
00047 AmiProFormat();
00048 AmiProFormat( const AmiProFormat& );
00049 AmiProFormat& operator=( const AmiProFormat& );
00050 void assign( const AmiProFormat& );
00051 void applyStyle( const AmiProStyle& );
00052 };
00053
00054 typedef QValueList<AmiProFormat> AmiProFormatList;
00055
00056
00057 class AmiProLayout
00058 {
00059 public:
00060 QString name;
00061 QString fontFamily;
00062 float fontSize;
00063 QColor fontColor;
00064 bool bold, italic, underline;
00065 bool word_underline, double_underline;
00066 bool subscript, superscript, strikethrough;
00067 Qt::AlignmentFlags align;
00068 float linespace;
00069 float spaceBefore, spaceAfter;
00070 AmiProLayout();
00071 AmiProLayout( const AmiProLayout& );
00072 AmiProLayout& operator=( const AmiProLayout& );
00073 void assign( const AmiProLayout& );
00074 void applyStyle( const AmiProStyle& );
00075 };
00076
00077 class AmiProStyle
00078 {
00079 public:
00080 QString name;
00081 QString fontFamily;
00082 float fontSize;
00083 QColor fontColor;
00084 bool bold, italic, underline;
00085 bool word_underline, double_underline;
00086 bool subscript, superscript, strikethrough;
00087 Qt::AlignmentFlags align;
00088 float linespace;
00089 float spaceBefore, spaceAfter;
00090 AmiProStyle();
00091 AmiProStyle( const AmiProStyle& );
00092 AmiProStyle& operator=( const AmiProStyle& );
00093 void assign( const AmiProStyle& );
00094 };
00095
00096 typedef QValueList<AmiProStyle> AmiProStyleList;
00097
00098 class AmiProListener
00099 {
00100 public:
00101 AmiProListener();
00102 virtual ~AmiProListener();
00103 virtual bool doOpenDocument();
00104 virtual bool doCloseDocument();
00105 virtual bool doDefineStyle( const AmiProStyle& style );
00106 virtual bool doParagraph( const QString& text, AmiProFormatList formatList,
00107 AmiProLayout& layout );
00108 };
00109
00110 class AmiProParser
00111 {
00112
00113 public:
00114 AmiProParser();
00115 virtual ~AmiProParser();
00116
00117 enum { OK, UnknownError, FileError, InvalidFormat } Error;
00118
00119 bool process( const QString& filename );
00120 int result(){ return m_result; }
00121
00122 void setListener( AmiProListener * );
00123
00124 private:
00125
00126 int m_result;
00127 QString m_text;
00128 AmiProFormat m_currentFormat;
00129 AmiProFormatList m_formatList;
00130 AmiProLayout m_layout;
00131 AmiProStyleList m_styleList;
00132
00133
00134 AmiProListener *m_listener;
00135
00136 QString m_currentSection;
00137
00138 bool setResult( int );
00139 bool parseParagraph( const QStringList& lines );
00140 bool parseStyle( const QStringList& line );
00141 AmiProStyle findStyle( const QString& name );
00142
00143 bool handleTag( const QString& tag );
00144 bool processOpenDocument();
00145 bool processCloseDocument();
00146 bool processParagraph( const QString& text, AmiProFormatList formatList,
00147 AmiProLayout& layout );
00148
00149 };
00150
00151 #endif
|