00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __CDRPARSER_H__
00011 #define __CDRPARSER_H__
00012
00013 #include <stdio.h>
00014 #include <iostream>
00015 #include <vector>
00016 #include <map>
00017 #include <stack>
00018 #include <librevenge-stream/librevenge-stream.h>
00019 #include "CDRTypes.h"
00020 #include "CommonParser.h"
00021
00022 namespace libcdr
00023 {
00024
00025 class CDRCollector;
00026
00027 class CDRParser : protected CommonParser
00028 {
00029 public:
00030 explicit CDRParser(const std::vector<librevenge::RVNGInputStream *> &externalStreams, CDRCollector *collector);
00031 virtual ~CDRParser();
00032 bool parseRecords(librevenge::RVNGInputStream *input, const std::vector<unsigned> &blockLengths = std::vector<unsigned>(), unsigned level = 0);
00033 bool parseWaldo(librevenge::RVNGInputStream *input);
00034
00035 private:
00036 CDRParser();
00037 CDRParser(const CDRParser &);
00038 CDRParser &operator=(const CDRParser &);
00039 bool parseWaldoStructure(librevenge::RVNGInputStream *input, std::stack<WaldoRecordType1> &waldoStack,
00040 const std::map<unsigned, WaldoRecordType1> &records1,
00041 std::map<unsigned, WaldoRecordInfo> &records2);
00042 bool gatherWaldoInformation(librevenge::RVNGInputStream *input, std::vector<WaldoRecordInfo> &records, std::map<unsigned, WaldoRecordInfo> &records2,
00043 std::map<unsigned, WaldoRecordInfo> &records3, std::map<unsigned, WaldoRecordInfo> &records4,
00044 std::map<unsigned, WaldoRecordInfo> &records6, std::map<unsigned, WaldoRecordInfo> &records7,
00045 std::map<unsigned, WaldoRecordInfo> &records8, std::map<unsigned, WaldoRecordInfo> recordsOther);
00046 void readWaldoRecord(librevenge::RVNGInputStream *input, const WaldoRecordInfo &info);
00047 bool parseRecord(librevenge::RVNGInputStream *input, const std::vector<unsigned> &blockLengths = std::vector<unsigned>(), unsigned level = 0);
00048 void readRecord(unsigned fourCC, unsigned length, librevenge::RVNGInputStream *input);
00049 double readRectCoord(librevenge::RVNGInputStream *input);
00050 CDRColor readColor(librevenge::RVNGInputStream *input);
00051
00052 void readRectangle(librevenge::RVNGInputStream *input);
00053 void readEllipse(librevenge::RVNGInputStream *input);
00054 void readLineAndCurve(librevenge::RVNGInputStream *input);
00055 void readBitmap(librevenge::RVNGInputStream *input);
00056 void readPageSize(librevenge::RVNGInputStream *input);
00057 void readWaldoBmp(librevenge::RVNGInputStream *input, unsigned length, unsigned id);
00058 void readWaldoBmpf(librevenge::RVNGInputStream *input, unsigned id);
00059 void readWaldoTrfd(librevenge::RVNGInputStream *input);
00060 void readWaldoOutl(librevenge::RVNGInputStream *input);
00061 void readWaldoFill(librevenge::RVNGInputStream *input);
00062 void readWaldoLoda(librevenge::RVNGInputStream *input, unsigned length);
00063 void readOpacity(librevenge::RVNGInputStream *input, unsigned length);
00064 void readTrfd(librevenge::RVNGInputStream *input, unsigned length);
00065 void readFild(librevenge::RVNGInputStream *input, unsigned length);
00066 void readOutl(librevenge::RVNGInputStream *input, unsigned length);
00067 void readLoda(librevenge::RVNGInputStream *input, unsigned length);
00068 void readFlags(librevenge::RVNGInputStream *input, unsigned length);
00069 void readMcfg(librevenge::RVNGInputStream *input, unsigned length);
00070 void readPath(librevenge::RVNGInputStream *input);
00071 void readArrw(librevenge::RVNGInputStream *input, unsigned length);
00072 void readPolygonCoords(librevenge::RVNGInputStream *input);
00073 void readPolygonTransform(librevenge::RVNGInputStream *input);
00074 void readBmp(librevenge::RVNGInputStream *input, unsigned length);
00075 void readBmpf(librevenge::RVNGInputStream *input, unsigned length);
00076 void readPpdt(librevenge::RVNGInputStream *input, unsigned length);
00077 void readFtil(librevenge::RVNGInputStream *input, unsigned length);
00078 void readDisp(librevenge::RVNGInputStream *input, unsigned length);
00079 void readVersion(librevenge::RVNGInputStream *input, unsigned length);
00080 void readIccd(librevenge::RVNGInputStream *input, unsigned length);
00081 void readBBox(librevenge::RVNGInputStream *input, unsigned length);
00082 void readSpnd(librevenge::RVNGInputStream *input, unsigned length);
00083 void readVpat(librevenge::RVNGInputStream *input, unsigned length);
00084 void readUidr(librevenge::RVNGInputStream *input, unsigned length);
00085 void readFont(librevenge::RVNGInputStream *input, unsigned length);
00086 void readStlt(librevenge::RVNGInputStream *input, unsigned length);
00087 void readStyd(librevenge::RVNGInputStream *input);
00088 void readTxsm(librevenge::RVNGInputStream *input, unsigned length);
00089 void readTxsm16(librevenge::RVNGInputStream *input);
00090 void readTxsm6(librevenge::RVNGInputStream *input);
00091 void readTxsm5(librevenge::RVNGInputStream *input);
00092 void readUdta(librevenge::RVNGInputStream *input);
00093 void readArtisticText(librevenge::RVNGInputStream *input);
00094 void readParagraphText(librevenge::RVNGInputStream *input);
00095
00096 bool _redirectX6Chunk(librevenge::RVNGInputStream **input, unsigned &length);
00097 void _readX6StyleString(librevenge::RVNGInputStream *input, unsigned length, CDRCharacterStyle &style);
00098
00099 std::vector<librevenge::RVNGInputStream *> m_externalStreams;
00100
00101 std::map<unsigned, CDRFont> m_fonts;
00102 std::map<unsigned, CDRFillStyle> m_fillStyles;
00103 std::map<unsigned, CDRLineStyle> m_lineStyles;
00104 std::map<unsigned, CDRPath> m_arrows;
00105
00106 unsigned m_version;
00107
00108 };
00109
00110 }
00111
00112 #endif // __CDRPARSER_H__
00113