Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef WPS8_H
00024 #define WPS8_H
00025
00026 #include <vector>
00027 #include <map>
00028 #include <libwpd/WPXString.h>
00029
00030 #include "libwps_internal.h"
00031 #include "WPS.h"
00032 #include "WPSContentListener.h"
00033 #include <libwpd-stream/WPXStream.h>
00034 #include "WPSParser.h"
00035
00036 typedef WPSContentListener WPS8ContentListener;
00037
00038 class WPS8Parser : public WPSParser
00039 {
00040 public:
00041 WPS8Parser(WPXInputStreamPtr &input, WPSHeaderPtr &header);
00042 ~WPS8Parser();
00043
00044 void parse(WPXDocumentInterface *documentInterface);
00045 protected:
00046 struct Zone;
00047 typedef std::multimap<std::string, Zone> IndexMultiMap;
00048 struct Note;
00049 struct Stream;
00050 private:
00051 void readFontsTable(WPXInputStreamPtr &input);
00052 void readStreams(WPXInputStreamPtr &input);
00053 void readNotes(std::vector<Note> &dest, WPXInputStreamPtr &input, const char *key);
00054 void appendUTF16LE(WPXInputStreamPtr &input);
00055 void readTextRange(WPXInputStreamPtr &input, uint32_t startpos, uint32_t endpos, uint16_t stream);
00056 void readNote(WPXInputStreamPtr &input, bool is_endnote);
00057 bool readFODPage(WPXInputStreamPtr &input, std::vector<WPSFOD> &FODs, uint16_t page_size);
00058 void parseHeaderIndexEntry(WPXInputStreamPtr &input);
00059 void parseHeaderIndex(WPXInputStreamPtr &input);
00060 void parsePages(std::vector<WPSPageSpan> &pageList, WPXInputStreamPtr &input);
00061 void parse(WPXInputStreamPtr &stream);
00062 void propertyChangeDelta(uint32_t newTextAttributeBits);
00063 void propertyChange(std::string rgchProp, uint16_t &specialCode);
00064 void propertyChangePara(std::string rgchProp);
00066 shared_ptr<WPS8ContentListener> m_listener;
00067 uint32_t m_offset_eot;
00068 uint32_t m_oldTextAttributeBits;
00069 IndexMultiMap m_headerIndexTable;
00070 std::vector<WPSFOD> m_CHFODs;
00071 std::vector<WPSFOD> m_PAFODs;
00072 std::vector<std::string> m_fontNames;
00073 std::vector<Stream> m_streams;
00074 std::vector<Note> m_footnotes;
00075 int m_actualFootnote;
00076 std::vector<Note> m_endnotes;
00077 int m_actualEndnote;
00078
00079 protected:
00082 struct Zone
00083 {
00084 Zone() : m_offset(0), m_length(0) {}
00085 virtual ~Zone() {}
00086 uint32_t const &begin() const
00087 {
00088 return m_offset;
00089 }
00090 uint32_t end() const
00091 {
00092 return m_offset+m_length;
00093 }
00094 uint32_t const &length() const
00095 {
00096 return m_length;
00097 }
00098 void setBegin(uint32_t pos)
00099 {
00100 m_offset = pos;
00101 }
00102 void setLength(uint32_t _length)
00103 {
00104 m_length = _length;
00105 }
00106 void setEnd(uint32_t _end)
00107 {
00108 m_length = _end-m_offset;
00109 }
00110
00111 bool valid() const
00112 {
00113 return m_offset && m_length;
00114 }
00115 protected:
00116 uint32_t m_offset;
00117 uint32_t m_length;
00118 };
00119
00120 struct Note : public Zone
00121 {
00122 Note() : Zone(), m_textOffset(0) {}
00123 uint32_t m_textOffset;
00124 };
00125
00126 struct Stream : public Zone
00127 {
00128 Stream() : Zone(), m_type(Z_Dummy) {}
00129
00130 enum Type {Z_Dummy=0, Z_Body=1, Z_Footnotes=2, Z_Endnotes = 3} m_type;
00131 };
00132 };
00133
00134
00135 #endif
00136