From 53914f770f1e1dc1ab4342c64846fd995825b7e6 Mon Sep 17 00:00:00 2001 From: Stef Date: Wed, 17 Sep 2003 18:34:42 +0000 Subject: Initial Import --- src/rtfparser.h | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/rtfparser.h (limited to 'src/rtfparser.h') 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 +#include +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 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_) -- cgit v1.2.3