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 MRW_PARSER
00038 # define MRW_PARSER
00039
00040 #include <iostream>
00041 #include <string>
00042 #include <vector>
00043
00044 #include <libwpd/libwpd.h>
00045
00046 class WPXBinaryData;
00047
00048 #include "MWAWDebug.hxx"
00049 #include "MWAWEntry.hxx"
00050 #include "MWAWInputStream.hxx"
00051
00052 #include "MWAWParser.hxx"
00053
00054 namespace MRWParserInternal
00055 {
00056 struct State;
00057 class SubDocument;
00058 }
00059
00060 class MRWGraph;
00061 class MRWText;
00062
00064 struct MRWEntry : public MWAWEntry {
00066 MRWEntry() : MWAWEntry(), m_fileType(0), m_N(0), m_value(0) {
00067 }
00069 std::string name() const;
00071 friend std::ostream &operator<< (std::ostream &o, MRWEntry const &ent) {
00072 if (ent.m_N || ent.m_value || ent.m_extra.length()) {
00073 o << "[";
00074 if (ent.m_N) o << "N=" << ent.m_N << ",";
00075 if (ent.m_value) o << "unkn=" << ent.m_value << ",";
00076 if (ent.m_extra.length()) o << ent.m_extra;
00077 o << "],";
00078 }
00079 return o;
00080 }
00082 int m_fileType;
00084 int m_N;
00086 int m_value;
00087 };
00088
00090 struct MRWStruct {
00092 MRWStruct() : m_filePos(-1), m_pos(), m_type(-1), m_data() {
00093 }
00095 friend std::ostream &operator<<(std::ostream &o, MRWStruct const &dt);
00097 int numValues() const {
00098 return int(m_data.size());
00099 }
00101 bool isBasic() const {
00102 return (m_type==1 || m_type==2) && m_data.size()<=1;
00103 }
00105 long value(int i) const;
00107 long m_filePos;
00109 MWAWEntry m_pos;
00111 int m_type;
00113 std::vector<long> m_data;
00114 };
00115
00121 class MRWParser : public MWAWParser
00122 {
00123 friend class MRWGraph;
00124 friend class MRWText;
00125 friend class MRWParserInternal::SubDocument;
00126
00127 public:
00129 MRWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00131 virtual ~MRWParser();
00132
00134 bool checkHeader(MWAWHeader *header, bool strict=false);
00135
00136
00137 void parse(WPXDocumentInterface *documentInterface);
00138
00139 protected:
00141 void init();
00142
00144 void createDocument(WPXDocumentInterface *documentInterface);
00145
00147 bool createZones();
00149 bool readZone(int &actZone, bool onlyTest=false);
00150
00152 Vec2f getPageLeftTop() const;
00154 MWAWSection getSection(int zoneId) const;
00155
00157 void newPage(int number);
00158
00159
00160
00162 int getZoneId(uint32_t fileId, bool &endNote);
00164 void sendText(int zoneId);
00165
00166
00168 float getPatternPercent(int id) const;
00170 void sendToken(int zoneId, long tokenId);
00171
00172
00173
00174
00175
00177 bool readEntryHeader(MRWEntry &entry);
00179 bool decodeZone(std::vector<MRWStruct> &dataList, long numData=999999);
00180
00182 bool readSeparator(MRWEntry const &entry);
00184 bool readZoneDim(MRWEntry const &entry, int zoneId);
00186 bool readZoneHeader(MRWEntry const &entry, int zoneId, bool onlyTest);
00188 bool readZoneb(MRWEntry const &entry, int zoneId);
00190 bool readZonec(MRWEntry const &entry, int zoneId);
00192 bool readZone13(MRWEntry const &entry, int zoneId);
00194 bool readDocInfo(MRWEntry const &entry, int zoneId);
00196 bool readPrintInfo(MRWEntry const &entry);
00198 bool readCPRT(MRWEntry const &entry);
00199
00201 bool readNumbersString(int num, std::vector<long> &res);
00202
00203 protected:
00204
00205
00206
00208 shared_ptr<MRWParserInternal::State> m_state;
00209
00211 bool m_pageMarginsSpanSet;
00212
00214 shared_ptr<MRWGraph> m_graphParser;
00215
00217 shared_ptr<MRWText> m_textParser;
00218 };
00219 #endif
00220