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_J_PARSER
00038 # define HAN_MAC_WRD_J_PARSER
00039
00040 #include <iostream>
00041 #include <string>
00042 #include <vector>
00043
00044 #include <librevenge/librevenge.h>
00045
00046 #include "MWAWDebug.hxx"
00047
00048 #include "MWAWParser.hxx"
00049
00050 namespace HanMacWrdJParserInternal
00051 {
00052 struct State;
00053 class SubDocument;
00054 }
00055
00056 class HanMacWrdJGraph;
00057 class HanMacWrdJText;
00058
00060 struct HanMacWrdJZoneHeader {
00062 HanMacWrdJZoneHeader(bool isMain) : m_length(0), m_n(0), m_fieldSize(0), m_id(0), m_isMain(isMain)
00063 {
00064 for (int i=0; i < 4; i++) m_values[i] = 0;
00065 }
00066
00068 friend std::ostream &operator<<(std::ostream &o, HanMacWrdJZoneHeader const &h)
00069 {
00070 if (h.m_n) o << "N=" << h.m_n << ",";
00071 if (h.m_id) o << "zId=" << std::hex << h.m_id << std::dec << ",";
00072 bool toPrint[4]= {true, true, true, true};
00073 if (h.m_isMain) {
00074 if (h.m_values[0]+h.m_n == h.m_values[1])
00075 toPrint[0]=toPrint[1]=false;
00076 else if (h.m_values[0]+h.m_n == h.m_values[2])
00077 toPrint[0]=toPrint[2]=false;
00078 else
00079 o << "###N,";
00080 }
00081 for (int i=0; i < 4; i++)
00082 if (toPrint[i] && h.m_values[i]) o << "h" << i << "=" << h.m_values[i] << ",";
00083 return o;
00084 }
00086 long m_length;
00088 int m_n;
00090 int m_fieldSize;
00092 long m_id;
00094 int m_values[4];
00096 bool m_isMain;
00097 };
00098
00104 class HanMacWrdJParser : public MWAWTextParser
00105 {
00106 friend class HanMacWrdJGraph;
00107 friend class HanMacWrdJText;
00108 friend class HanMacWrdJParserInternal::SubDocument;
00109
00110 public:
00112 HanMacWrdJParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00114 virtual ~HanMacWrdJParser();
00115
00117 bool checkHeader(MWAWHeader *header, bool strict=false);
00118
00119
00120 void parse(librevenge::RVNGTextInterface *documentInterface);
00121
00122 protected:
00124 void init();
00125
00127 void createDocument(librevenge::RVNGTextInterface *documentInterface);
00128
00130 bool createZones();
00131
00133 MWAWVec2f getPageLeftTop() const;
00134
00136 void newPage(int number);
00137
00138
00139
00141 bool sendText(long id, long cPos, MWAWListenerPtr listener=MWAWListenerPtr());
00143 bool canSendTextAsGraphic(long id, long cPos);
00144
00145
00146
00148 bool sendZone(long zId);
00150 bool getColor(int colId, int patternId, MWAWColor &color) const;
00151
00152
00153
00154
00155
00158 bool checkEntry(MWAWEntry &entry);
00159
00161 bool readZonesList();
00163 bool readZone(MWAWEntry &entry);
00164
00166 bool readClassicHeader(HanMacWrdJZoneHeader &header, long endPos=-1);
00168 bool decodeZone(MWAWEntry const &entry, librevenge::RVNGBinaryData &data);
00169
00171 bool readPrintInfo(MWAWEntry const &entry);
00173 bool readHeaderEnd();
00174 #ifdef DEBUG
00175
00176 bool readZoneWithHeader(MWAWEntry const &entry);
00177 #endif
00178
00179 bool readZoneA(MWAWEntry const &entry);
00181 bool readZoneB(MWAWEntry const &entry);
00182
00183 protected:
00184
00185
00186
00188 shared_ptr<HanMacWrdJParserInternal::State> m_state;
00189
00191 shared_ptr<HanMacWrdJGraph> m_graphParser;
00192
00194 shared_ptr<HanMacWrdJText> m_textParser;
00195 };
00196 #endif
00197