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 #ifndef MAC_WRT_PRO_PARSER
00036 # define MAC_WRT_PRO_PARSER
00037
00038 #include <list>
00039 #include <string>
00040 #include <vector>
00041
00042 #include "MWAWDebug.hxx"
00043 #include "MWAWEntry.hxx"
00044 #include "MWAWGraphicStyle.hxx"
00045 #include "MWAWInputStream.hxx"
00046
00047 #include "MWAWParser.hxx"
00048
00049 namespace MacWrtProParserInternal
00050 {
00051 struct State;
00052 struct TextZoneData;
00053 struct TextZone;
00054 struct Token;
00055 struct Zone;
00056 class SubDocument;
00057 }
00058
00059 class MacWrtProStructures;
00060 class MacWrtProStructuresListenerState;
00061
00067 class MacWrtProParser : public MWAWTextParser
00068 {
00069 friend class MacWrtProStructures;
00070 friend class MacWrtProStructuresListenerState;
00071 friend class MacWrtProParserInternal::SubDocument;
00072
00073 public:
00075 MacWrtProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00077 virtual ~MacWrtProParser();
00078
00080 bool checkHeader(MWAWHeader *header, bool strict=false);
00081
00082
00083 void parse(librevenge::RVNGTextInterface *documentInterface);
00084
00085 protected:
00087 void init();
00088
00090 void createDocument(librevenge::RVNGTextInterface *documentInterface);
00091
00093 bool createZones();
00094
00096 bool getZoneData(librevenge::RVNGBinaryData &data, int blockId);
00097
00099 bool getFreeZoneList(int blockId, std::vector<int> &blockLists);
00100
00105 bool parseDataZone(int blockId, int type);
00106
00108 bool parseTextZone(shared_ptr<MacWrtProParserInternal::Zone> zone);
00109
00111 bool readTextEntries(shared_ptr<MacWrtProParserInternal::Zone> zone,
00112 std::vector<MWAWEntry> &res, int textLength);
00114 bool readTextIds(shared_ptr<MacWrtProParserInternal::Zone> zone,
00115 std::vector<MacWrtProParserInternal::TextZoneData> &res,
00116 int textLength, int type);
00118 bool readTextTokens(shared_ptr<MacWrtProParserInternal::Zone> zone,
00119 std::vector<MacWrtProParserInternal::Token> &res,
00120 int textLength);
00121
00124 std::vector<int> const &getBlocksCalledByToken() const;
00125
00127 float pageHeight() const;
00129 int numColumns() const;
00130
00132 void newPage(int number, bool softBreak=false);
00133
00134
00135
00136
00137
00139 bool sendTextZone(int blockId, bool mainZone = false);
00140
00142 int findNumHardBreaks(int blockId);
00143
00145 bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00146
00148 bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00150 bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style);
00151
00152
00153
00154
00155
00157 bool readPrintInfo();
00158
00160 bool readDocHeader();
00161
00162 #ifdef DEBUG
00163
00164 void saveOriginal(MWAWInputStreamPtr input);
00165 #endif
00166
00168 bool sendPicture(shared_ptr<MacWrtProParserInternal::Zone> zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
00169
00171 bool sendText(shared_ptr<MacWrtProParserInternal::TextZone> zone, bool mainZone = false);
00172
00174 int findNumHardBreaks(shared_ptr<MacWrtProParserInternal::TextZone> zone);
00175
00177 void checkUnparsed();
00178
00179 protected:
00180
00181
00182
00184 shared_ptr<MacWrtProParserInternal::State> m_state;
00185
00187 shared_ptr<MacWrtProStructures> m_structures;
00188 };
00189 #endif
00190