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 HMWJ_PARSER
00038 # define HMWJ_PARSER
00039
00040 #include <iostream>
00041 #include <string>
00042 #include <vector>
00043
00044 #include <libwpd/libwpd.h>
00045
00046 #include "MWAWDebug.hxx"
00047
00048 #include "MWAWParser.hxx"
00049
00050 namespace HMWJParserInternal
00051 {
00052 struct State;
00053 class SubDocument;
00054 }
00055
00056 class HMWJGraph;
00057 class HMWJText;
00058
00060 struct HMWJZoneHeader {
00062 HMWJZoneHeader(bool isMain) : m_length(0), m_n(0), m_fieldSize(0), m_id(0), m_isMain(isMain) {
00063 for (int i=0; i < 4; i++) m_values[i] = 0;
00064 }
00065
00067 friend std::ostream &operator<<(std::ostream &o, HMWJZoneHeader const &h) {
00068 if (h.m_n) o << "N=" << h.m_n << ",";
00069 if (h.m_id) o << "zId=" << std::hex << h.m_id << std::dec << ",";
00070 bool toPrint[4]= {true, true, true, true};
00071 if (h.m_isMain) {
00072 if (h.m_values[0]+h.m_n == h.m_values[1])
00073 toPrint[0]=toPrint[1]=false;
00074 else if (h.m_values[0]+h.m_n == h.m_values[2])
00075 toPrint[0]=toPrint[2]=false;
00076 else
00077 o << "###N,";
00078 }
00079 for (int i=0; i < 4; i++)
00080 if (toPrint[i] && h.m_values[i]) o << "h" << i << "=" << h.m_values[i] << ",";
00081 return o;
00082 }
00084 long m_length;
00086 int m_n;
00088 int m_fieldSize;
00090 long m_id;
00092 int m_values[4];
00094 bool m_isMain;
00095 };
00096
00102 class HMWJParser : public MWAWParser
00103 {
00104 friend class HMWJGraph;
00105 friend class HMWJText;
00106 friend class HMWJParserInternal::SubDocument;
00107
00108 public:
00110 HMWJParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00112 virtual ~HMWJParser();
00113
00115 bool checkHeader(MWAWHeader *header, bool strict=false);
00116
00117
00118 void parse(WPXDocumentInterface *documentInterface);
00119
00120 protected:
00122 void init();
00123
00125 void createDocument(WPXDocumentInterface *documentInterface);
00126
00128 bool createZones();
00129
00131 Vec2f getPageLeftTop() const;
00132
00134 void newPage(int number);
00135
00136
00137
00139 bool sendText(long id, long cPos, bool asGraphic=false);
00141 bool canSendTextAsGraphic(long id, long cPos);
00142
00143
00144
00146 bool sendZone(long zId);
00148 bool getColor(int colId, int patternId, MWAWColor &color) const;
00149
00150
00151
00152
00153
00156 bool checkEntry(MWAWEntry &entry);
00157
00159 bool readZonesList();
00161 bool readZone(MWAWEntry &entry);
00162
00164 bool readClassicHeader(HMWJZoneHeader &header, long endPos=-1);
00166 bool decodeZone(MWAWEntry const &entry, WPXBinaryData &data);
00167
00169 bool readPrintInfo(MWAWEntry const &entry);
00171 bool readHeaderEnd();
00172 #ifdef DEBUG
00173
00174 bool readZoneWithHeader(MWAWEntry const &entry);
00175 #endif
00176
00177 bool readZoneA(MWAWEntry const &entry);
00179 bool readZoneB(MWAWEntry const &entry);
00180
00181 protected:
00182
00183
00184
00186 shared_ptr<HMWJParserInternal::State> m_state;
00187
00189 shared_ptr<HMWJGraph> m_graphParser;
00190
00192 shared_ptr<HMWJText> m_textParser;
00193 };
00194 #endif
00195