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 HAN_MAC_WRD_K_PARSER
00038 # define HAN_MAC_WRD_K_PARSER
00039
00040 #include <iostream>
00041 #include <string>
00042 #include <vector>
00043
00044 #include <librevenge/librevenge.h>
00045
00046 #include "MWAWDebug.hxx"
00047 #include "MWAWInputStream.hxx"
00048
00049 #include "MWAWParser.hxx"
00050
00051 namespace HanMacWrdKParserInternal
00052 {
00053 struct State;
00054 class SubDocument;
00055 }
00056
00058 struct HanMacWrdKZone {
00060 HanMacWrdKZone(MWAWInputStreamPtr input, libmwaw::DebugFile &asciiFile);
00062 HanMacWrdKZone(shared_ptr<libmwaw::DebugFile> asciiFile);
00064 ~HanMacWrdKZone();
00065
00067 long begin() const
00068 {
00069 return m_asciiFilePtr ? 0 : m_filePos;
00070 }
00072 long end() const
00073 {
00074 return m_asciiFilePtr ? (long) m_data.size() : m_endFilePos;
00075 }
00077 long length() const
00078 {
00079 if (m_asciiFilePtr) return (long) m_data.size();
00080 return m_endFilePos-m_filePos;
00081 }
00083 bool valid() const
00084 {
00085 return length() > 0;
00086 }
00087
00088
00089
00091 long fileBeginPos() const
00092 {
00093 return m_filePos;
00094 }
00096 long fileEndPos() const
00097 {
00098 return m_endFilePos;
00099 }
00101 void setFileBeginPos(long begPos)
00102 {
00103 m_filePos = m_endFilePos = begPos;
00104 }
00106 void setFileLength(long len)
00107 {
00108 m_endFilePos = m_filePos+len;
00109 }
00111 void setFilePositions(long begPos, long endPos)
00112 {
00113 m_filePos = begPos;
00114 m_endFilePos = endPos;
00115 }
00117 librevenge::RVNGBinaryData &getBinaryData()
00118 {
00119 return m_data;
00120 }
00122 std::string name() const
00123 {
00124 return name(m_type);
00125 }
00127 static std::string name(int type);
00128
00130 friend std::ostream &operator<<(std::ostream &o, HanMacWrdKZone const &zone);
00131
00133 libmwaw::DebugFile &ascii() const
00134 {
00135 return *m_asciiFile;
00136 }
00137
00139 int m_type;
00140
00142 long m_id;
00143
00145 long m_subId;
00146
00148 MWAWInputStreamPtr m_input;
00149
00151 std::string m_extra;
00152
00154 mutable bool m_parsed;
00155
00156 protected:
00158 long m_filePos;
00159
00161 long m_endFilePos;
00162
00164 librevenge::RVNGBinaryData m_data;
00165
00167 libmwaw::DebugFile *m_asciiFile;
00168
00170 shared_ptr<libmwaw::DebugFile> m_asciiFilePtr;
00171
00172 private:
00173 HanMacWrdKZone(HanMacWrdKZone const &orig);
00174 HanMacWrdKZone &operator=(HanMacWrdKZone const &orig);
00175 };
00176
00177 class HanMacWrdKGraph;
00178 class HanMacWrdKText;
00179
00185 class HanMacWrdKParser : public MWAWTextParser
00186 {
00187 friend class HanMacWrdKGraph;
00188 friend class HanMacWrdKText;
00189 friend class HanMacWrdKParserInternal::SubDocument;
00190
00191 public:
00193 HanMacWrdKParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00195 virtual ~HanMacWrdKParser();
00196
00198 bool checkHeader(MWAWHeader *header, bool strict=false);
00199
00200
00201 void parse(librevenge::RVNGTextInterface *documentInterface);
00202
00203 protected:
00205 void init();
00206
00208 void createDocument(librevenge::RVNGTextInterface *documentInterface);
00209
00211 bool createZones();
00212
00214 MWAWVec2f getPageLeftTop() const;
00215
00217 void newPage(int number);
00218
00219
00220
00222 bool sendText(long id, long subId, MWAWListenerPtr listener=MWAWListenerPtr());
00223
00225 bool canSendTextAsGraphic(long id, long subId);
00226
00227
00228
00230 bool sendZone(long zId);
00232 bool getColor(int colId, int patternId, MWAWColor &color) const;
00233
00234
00235
00236
00237
00239 bool readZonesList();
00241 bool readZone(shared_ptr<HanMacWrdKZone> zone);
00243 shared_ptr<HanMacWrdKZone> decodeZone(shared_ptr<HanMacWrdKZone> zone);
00245 bool readFramesUnkn(shared_ptr<HanMacWrdKZone> zone);
00247 bool readPrintInfo(HanMacWrdKZone &zone);
00249 bool readZone6(shared_ptr<HanMacWrdKZone> zone);
00251 bool readZone8(shared_ptr<HanMacWrdKZone> zone);
00253 bool readZonea(shared_ptr<HanMacWrdKZone> zone);
00255 bool readZoneb(HanMacWrdKZone &zone);
00257 bool readZonec(shared_ptr<HanMacWrdKZone> zone);
00258
00259 protected:
00260
00261
00262
00264 shared_ptr<HanMacWrdKParserInternal::State> m_state;
00265
00267 shared_ptr<HanMacWrdKGraph> m_graphParser;
00268
00270 shared_ptr<HanMacWrdKText> m_textParser;
00271 };
00272 #endif
00273