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
00029 #include <libwpd/WPXString.h>
00030 #include <libwpd-stream/WPXStream.h>
00031
00032 #include "libwps_internal.h"
00033 #include "WPS.h"
00034 #include "WPSContentListener.h"
00035 #include "WPSParser.h"
00036
00037 typedef WPSContentListener WPS8ContentListener;
00038 typedef shared_ptr<WPS8ContentListener> WPS8ContentListenerPtr;
00039
00040 namespace WPS8ParserInternal
00041 {
00042 class SubDocument;
00043 }
00044
00045 class WPS8Parser : public WPSParser
00046 {
00047 friend class WPS8ParserInternal::SubDocument;
00048 public:
00049 WPS8Parser(WPXInputStreamPtr &input, WPSHeaderPtr &header);
00050 ~WPS8Parser();
00051
00052 void parse(WPXDocumentInterface *documentInterface);
00053 protected:
00054 struct Zone;
00055 typedef std::multimap<std::string, Zone> IndexMultiMap;
00056 struct Note;
00057 struct Stream;
00058 private:
00059 void readFontsTable(WPXInputStreamPtr &input);
00060 void readStreams(WPXInputStreamPtr &input);
00061 void readNotes(std::vector<Note> &dest, WPXInputStreamPtr &input, const char *key);
00062 void appendUTF16LE(WPXInputStreamPtr &input);
00063 void readTextRange(WPXInputStreamPtr &input, uint32_t startpos, uint32_t endpos, uint16_t stream);
00064 bool readFODPage(WPXInputStreamPtr &input, std::vector<WPSFOD> &FODs, uint16_t page_size);
00065 void parseHeaderIndexEntry(WPXInputStreamPtr &input);
00066 void parseHeaderIndex(WPXInputStreamPtr &input);
00067 void parsePages(std::vector<WPSPageSpan> &pageList, WPXInputStreamPtr &input);
00068 void parse(WPXInputStreamPtr &stream);
00069 void propertyChangeDelta(uint32_t newTextAttributeBits);
00070 void propertyChange(std::string rgchProp, uint16_t &specialCode, int &fieldType);
00071 void propertyChangePara(std::string rgchProp);
00072
00073 void sendNote(WPXInputStreamPtr &input, int noteId, bool is_endnote);
00074
00076 shared_ptr<WPS8ContentListener> m_listener;
00077 uint32_t m_offset_eot;
00078 uint32_t m_oldTextAttributeBits;
00079 IndexMultiMap m_headerIndexTable;
00080 std::vector<WPSFOD> m_CHFODs;
00081 std::vector<WPSFOD> m_PAFODs;
00082 std::vector<std::string> m_fontNames;
00083 std::vector<Stream> m_streams;
00084 std::vector<Note> m_footnotes;
00085 int m_actualFootnote;
00086 std::vector<Note> m_endnotes;
00087 int m_actualEndnote;
00088
00089 protected:
00092 struct Zone
00093 {
00094 Zone() : m_offset(0), m_length(0) {}
00095 virtual ~Zone() {}
00096 uint32_t const &begin() const
00097 {
00098 return m_offset;
00099 }
00100 uint32_t end() const
00101 {
00102 return m_offset+m_length;
00103 }
00104 uint32_t const &length() const
00105 {
00106 return m_length;
00107 }
00108 void setBegin(uint32_t pos)
00109 {
00110 m_offset = pos;
00111 }
00112 void setLength(uint32_t _length)
00113 {
00114 m_length = _length;
00115 }
00116 void setEnd(uint32_t _end)
00117 {
00118 m_length = _end-m_offset;
00119 }
00120
00121 bool valid() const
00122 {
00123 return m_offset && m_length;
00124 }
00125 protected:
00126 uint32_t m_offset;
00127 uint32_t m_length;
00128 };
00129
00130 struct Note : public Zone
00131 {
00132 Note() : Zone(), m_textOffset(0) {}
00133 uint32_t m_textOffset;
00134 };
00135
00136 struct Stream : public Zone
00137 {
00138 Stream() : Zone(), m_type(Z_Dummy) {}
00139
00140 enum Type {Z_Dummy=0, Z_Body=1, Z_Footnotes=2, Z_Endnotes = 3} m_type;
00141 };
00142 };
00143
00144
00145 #endif
00146