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 MARINER_WRT_PARSER
00038 # define MARINER_WRT_PARSER
00039
00040 #include <iostream>
00041 #include <string>
00042 #include <vector>
00043
00044 #include <librevenge/librevenge.h>
00045
00046 #include "MWAWDebug.hxx"
00047 #include "MWAWEntry.hxx"
00048 #include "MWAWInputStream.hxx"
00049
00050 #include "MWAWParser.hxx"
00051
00052 namespace MarinerWrtParserInternal
00053 {
00054 struct State;
00055 class SubDocument;
00056 }
00057
00058 class MarinerWrtGraph;
00059 class MarinerWrtText;
00060
00062 struct MarinerWrtEntry : public MWAWEntry {
00064 MarinerWrtEntry() : MWAWEntry(), m_fileType(0), m_N(0), m_value(0)
00065 {
00066 }
00068 std::string name() const;
00070 friend std::ostream &operator<< (std::ostream &o, MarinerWrtEntry const &ent)
00071 {
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 MarinerWrtStruct {
00092 MarinerWrtStruct() : m_filePos(-1), m_pos(), m_type(-1), m_data()
00093 {
00094 }
00096 friend std::ostream &operator<<(std::ostream &o, MarinerWrtStruct const &dt);
00098 int numValues() const
00099 {
00100 return int(m_data.size());
00101 }
00103 bool isBasic() const
00104 {
00105 return (m_type==1 || m_type==2) && m_data.size()<=1;
00106 }
00108 long value(int i) const;
00110 long m_filePos;
00112 MWAWEntry m_pos;
00114 int m_type;
00116 std::vector<long> m_data;
00117 };
00118
00124 class MarinerWrtParser : public MWAWTextParser
00125 {
00126 friend class MarinerWrtGraph;
00127 friend class MarinerWrtText;
00128 friend class MarinerWrtParserInternal::SubDocument;
00129
00130 public:
00132 MarinerWrtParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00134 virtual ~MarinerWrtParser();
00135
00137 bool checkHeader(MWAWHeader *header, bool strict=false);
00138
00139
00140 void parse(librevenge::RVNGTextInterface *documentInterface);
00141
00142 protected:
00144 void init();
00145
00147 void createDocument(librevenge::RVNGTextInterface *documentInterface);
00148
00150 bool createZones();
00152 bool readZone(int &actZone, bool onlyTest=false);
00153
00155 MWAWVec2f getPageLeftTop() const;
00157 MWAWSection getSection(int zoneId) const;
00158
00160 void newPage(int number);
00161
00162
00163
00165 int getZoneId(uint32_t fileId, bool &endNote);
00167 void sendText(int zoneId);
00168
00169
00171 float getPatternPercent(int id) const;
00173 void sendToken(int zoneId, long tokenId);
00174
00175
00176
00177
00178
00180 bool readEntryHeader(MarinerWrtEntry &entry);
00182 bool decodeZone(std::vector<MarinerWrtStruct> &dataList, long numData=999999);
00183
00185 bool readSeparator(MarinerWrtEntry const &entry);
00187 bool readZoneDim(MarinerWrtEntry const &entry, int zoneId);
00189 bool readZoneHeader(MarinerWrtEntry const &entry, int zoneId, bool onlyTest);
00191 bool readZoneb(MarinerWrtEntry const &entry, int zoneId);
00193 bool readZonec(MarinerWrtEntry const &entry, int zoneId);
00195 bool readZone13(MarinerWrtEntry const &entry, int zoneId);
00197 bool readDocInfo(MarinerWrtEntry const &entry, int zoneId);
00199 bool readPrintInfo(MarinerWrtEntry const &entry);
00201 bool readCPRT(MarinerWrtEntry const &entry);
00202
00204 bool readNumbersString(int num, std::vector<long> &res);
00205
00206 protected:
00207
00208
00209
00211 shared_ptr<MarinerWrtParserInternal::State> m_state;
00212
00214 bool m_pageMarginsSpanSet;
00215
00217 shared_ptr<MarinerWrtGraph> m_graphParser;
00218
00220 shared_ptr<MarinerWrtText> m_textParser;
00221 };
00222 #endif
00223