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
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef HMWK_PARSER
00038 # define HMWK_PARSER
00039
00040 #include <iostream>
00041 #include <string>
00042 #include <vector>
00043
00044 #include <libwpd/libwpd.h>
00045
00046 #include "MWAWDebug.hxx"
00047 #include "MWAWInputStream.hxx"
00048
00049 #include "MWAWParser.hxx"
00050
00051 namespace HMWKParserInternal
00052 {
00053 struct State;
00054 class SubDocument;
00055 }
00056
00058 struct HMWKZone {
00060 HMWKZone(MWAWInputStreamPtr input, libmwaw::DebugFile &asciiFile);
00062 HMWKZone(shared_ptr<libmwaw::DebugFile> asciiFile);
00064 ~HMWKZone();
00065
00067 long begin() const {
00068 return m_asciiFilePtr ? 0 : m_filePos;
00069 }
00071 long end() const {
00072 return m_asciiFilePtr ? (long) m_data.size() : m_endFilePos;
00073 }
00075 long length() const {
00076 if (m_asciiFilePtr) return (long) m_data.size();
00077 return m_endFilePos-m_filePos;
00078 }
00080 bool valid() const {
00081 return length() > 0;
00082 }
00083
00084
00085
00087 long fileBeginPos() const {
00088 return m_filePos;
00089 }
00091 long fileEndPos() const {
00092 return m_endFilePos;
00093 }
00095 void setFileBeginPos(long begPos) {
00096 m_filePos = m_endFilePos = begPos;
00097 }
00099 void setFileLength(long len) {
00100 m_endFilePos = m_filePos+len;
00101 }
00103 void setFilePositions(long begPos, long endPos) {
00104 m_filePos = begPos;
00105 m_endFilePos = endPos;
00106 }
00108 WPXBinaryData &getBinaryData() {
00109 return m_data;
00110 }
00112 std::string name() const {
00113 return name(m_type);
00114 }
00116 static std::string name(int type);
00117
00119 friend std::ostream &operator<<(std::ostream &o, HMWKZone const &zone);
00120
00122 libmwaw::DebugFile &ascii() {
00123 return *m_asciiFile;
00124 }
00125
00127 int m_type;
00128
00130 long m_id;
00131
00133 long m_subId;
00134
00136 MWAWInputStreamPtr m_input;
00137
00139 std::string m_extra;
00140
00142 mutable bool m_parsed;
00143
00144 protected:
00146 long m_filePos;
00147
00149 long m_endFilePos;
00150
00152 WPXBinaryData m_data;
00153
00155 libmwaw::DebugFile *m_asciiFile;
00156
00158 shared_ptr<libmwaw::DebugFile> m_asciiFilePtr;
00159
00160 private:
00161 HMWKZone(HMWKZone const &orig);
00162 HMWKZone &operator=(HMWKZone const &orig);
00163 };
00164
00165 class HMWKGraph;
00166 class HMWKText;
00167
00173 class HMWKParser : public MWAWParser
00174 {
00175 friend class HMWKGraph;
00176 friend class HMWKText;
00177 friend class HMWKParserInternal::SubDocument;
00178
00179 public:
00181 HMWKParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00183 virtual ~HMWKParser();
00184
00186 bool checkHeader(MWAWHeader *header, bool strict=false);
00187
00188
00189 void parse(WPXDocumentInterface *documentInterface);
00190
00191 protected:
00193 void init();
00194
00196 void createDocument(WPXDocumentInterface *documentInterface);
00197
00199 bool createZones();
00200
00202 Vec2f getPageLeftTop() const;
00203
00205 void newPage(int number);
00206
00207
00208
00210 bool sendText(long id, long subId, bool asGraphic=false);
00211
00213 bool canSendTextAsGraphic(long id, long subId);
00214
00215
00216
00218 bool sendZone(long zId);
00220 bool getColor(int colId, int patternId, MWAWColor &color) const;
00221
00222
00223
00224
00225
00227 bool readZonesList();
00229 bool readZone(shared_ptr<HMWKZone> zone);
00231 shared_ptr<HMWKZone> decodeZone(shared_ptr<HMWKZone> zone);
00233 bool readFramesUnkn(shared_ptr<HMWKZone> zone);
00235 bool readPrintInfo(HMWKZone &zone);
00237 bool readZone6(shared_ptr<HMWKZone> zone);
00239 bool readZone8(shared_ptr<HMWKZone> zone);
00241 bool readZonea(shared_ptr<HMWKZone> zone);
00243 bool readZoneb(HMWKZone &zone);
00245 bool readZonec(shared_ptr<HMWKZone> zone);
00246
00247 protected:
00248
00249
00250
00252 shared_ptr<HMWKParserInternal::State> m_state;
00253
00255 shared_ptr<HMWKGraph> m_graphParser;
00256
00258 shared_ptr<HMWKText> m_textParser;
00259 };
00260 #endif
00261