diff options
author | Stef Walter <stef@memberwebs.com> | 2003-09-17 18:34:42 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2003-09-17 18:34:42 +0000 |
commit | 69aa93c828303dcc44253fe88ff3d6024d10817b (patch) | |
tree | 63d14dacbd3d81363fcbea1036c47a0210b0f397 /src/rtfparser.h | |
parent | 15f3015d2e8305b729d7996faad410b3378497da (diff) |
Initial Import
Diffstat (limited to 'src/rtfparser.h')
-rw-r--r-- | src/rtfparser.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/rtfparser.h b/src/rtfparser.h new file mode 100644 index 0000000..f28150e --- /dev/null +++ b/src/rtfparser.h @@ -0,0 +1,80 @@ +// RtfReader.h: interface for the RtfReader class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_RTFREADER_H__2C77784F_5333_4E16_B0E0_B56E211C2D82__INCLUDED_) +#define AFX_RTFREADER_H__2C77784F_5333_4E16_B0E0_B56E211C2D82__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include <mystring.h> +#include <stack> +class RtfReader; + +class RtfHandler +{ +public: + virtual void startDocument(RtfReader* reader) = 0; + virtual void endDocument() = 0; + virtual void controlWord(const string& cw, int flags, int param) = 0; + virtual void groupStart() = 0; + virtual void groupEnd() = 0; + virtual void charData(wstring data) = 0; + + static const int kAsterisk; + static const int kHasParam; + static const int kIsEncoded; +}; + +class RtfReader +{ +public: + RtfReader(); + virtual ~RtfReader(); + + + bool parse(string fileName); + bool parse(FILE* file); + + void setHandler(RtfHandler* handler) + { m_handler = handler; } + string getParseErrors() const + { return m_parseErrors; } + int getDepth() const + { return m_depth; } + void setHexParse(bool parse) + { m_parseHex = parse; } + void setUnicode(bool unicode); + +protected: + RtfHandler* m_handler; + int m_depth; + bool m_parseHex; + string m_parseErrors; + + // Unicode handling + bool m_parseUnicode; + typedef std::stack<int> StackInt; + StackInt m_uniEatStack; + int m_uniEat; + +private: + + struct RtfContext + { + FILE* file; + bool isData; + wstring data; + }; + + bool parseControlWord(RtfContext& cx); + bool parseHexChar(RtfContext& cx, int num); + void sendControlWord(RtfContext& cx, string cw, int flags, int param); + void sendData(RtfContext& cx, wchar_t ch); + void sendData(RtfContext& cx, wstring data); + void emptyData(RtfContext& cx); +}; + +#endif // !defined(AFX_RTFREADER_H__2C77784F_5333_4E16_B0E0_B56E211C2D82__INCLUDED_) |