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
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #ifndef STOFF_OLE_PARSER_H
00064 #define STOFF_OLE_PARSER_H
00065
00066 #include <string>
00067 #include <vector>
00068
00069 #include <librevenge-stream/librevenge-stream.h>
00070
00071 #include <libstaroffice/STOFFDocument.hxx>
00072
00073 #include "libstaroffice_internal.hxx"
00074 #include "STOFFPosition.hxx"
00075
00076 #include "STOFFDebug.hxx"
00077
00078 namespace STOFFOLEParserInternal
00079 {
00080 struct State;
00081 }
00082
00086 class STOFFOLEParser
00087 {
00088 public:
00089 struct OleDirectory;
00090
00092 STOFFOLEParser();
00093
00095 ~STOFFOLEParser();
00096
00099 bool parse(STOFFInputStreamPtr fileInput);
00100
00102 std::vector<shared_ptr<OleDirectory> > &getDirectoryList();
00104 shared_ptr<OleDirectory> getDirectory(std::string const &dir);
00105
00107 struct OleContent {
00109 OleContent(std::string const &dir, std::string const &base) :
00110 m_dir(dir), m_base(base), m_isParsed(false), m_position(), m_imageData(), m_imageType("")
00111 {
00112 }
00114 std::string getBaseName()
00115 {
00116 return m_base;
00117 }
00119 std::string getOleName() const
00120 {
00121 if (m_dir.empty()) return m_base;
00122 return m_dir+"/"+m_base;
00123 }
00125 bool isParsed() const
00126 {
00127 return m_isParsed;
00128 }
00130 void setParsed(bool flag=true)
00131 {
00132 m_isParsed=flag;
00133 }
00135 STOFFPosition const &getPosition() const
00136 {
00137 return m_position;
00138 }
00140 void setPosition(STOFFPosition const &pos)
00141 {
00142 m_position=pos;
00143 }
00145 bool getImageData(librevenge::RVNGBinaryData &data, std::string &type) const
00146 {
00147 if (m_imageData.empty()) {
00148 data.clear();
00149 type="";
00150 return false;
00151 }
00152 data=m_imageData;
00153 type=m_imageType;
00154 return true;
00155 }
00157 void setImageData(librevenge::RVNGBinaryData const &data, std::string const &type)
00158 {
00159 m_imageData=data;
00160 m_imageType=type;
00161 }
00162 protected:
00164 std::string m_dir;
00166 std::string m_base;
00168 bool m_isParsed;
00170 STOFFPosition m_position;
00172 librevenge::RVNGBinaryData m_imageData;
00174 std::string m_imageType;
00175 };
00176
00178 struct OleDirectory {
00180 OleDirectory(STOFFInputStreamPtr input, std::string const &dir) : m_input(input), m_dir(dir), m_contentList(), m_kind(STOFFDocument::STOFF_K_UNKNOWN),
00181 m_hasCompObj(false), m_clsName(""), m_clipName(""), m_parsed(false), m_inUse(false) { }
00183 void addNewBase(std::string const &base)
00184 {
00185 if (base=="CompObj")
00186 m_hasCompObj=true;
00187 else
00188 m_contentList.push_back(OleContent(m_dir,base));
00189 }
00191 std::vector<std::string> getUnparsedOles() const
00192 {
00193 std::vector<std::string> res;
00194 for (size_t i=0; i<m_contentList.size(); ++i) {
00195 if (m_contentList[i].isParsed()) continue;
00196 res.push_back(m_contentList[i].getOleName());
00197 }
00198 return res;
00199 }
00201 STOFFInputStreamPtr m_input;
00203 std::string m_dir;
00205 std::vector<OleContent> m_contentList;
00207 STOFFDocument::Kind m_kind;
00209 bool m_hasCompObj;
00211 std::string m_clsName;
00213 std::string m_clipName;
00215 bool m_parsed;
00217 mutable bool m_inUse;
00218 };
00219
00220 protected:
00222 static bool readSummaryInformation(STOFFInputStreamPtr input, std::string const &oleName,
00223 libstoff::DebugFile &ascii);
00224
00226 static bool readOle(STOFFInputStreamPtr ip, std::string const &oleName,
00227 libstoff::DebugFile &ascii);
00229 static bool readObjInfo(STOFFInputStreamPtr input, std::string const &oleName,
00230 libstoff::DebugFile &ascii);
00232 bool readCompObj(STOFFInputStreamPtr ip, OleDirectory &directory);
00233
00235 static bool isOlePres(STOFFInputStreamPtr ip, std::string const &oleName);
00239 static bool readOlePres(STOFFInputStreamPtr ip, OleContent &content);
00240
00242 static bool isOle10Native(STOFFInputStreamPtr ip, std::string const &oleName);
00246 static bool readOle10Native(STOFFInputStreamPtr ip, OleContent &content);
00247
00251 bool readContents(STOFFInputStreamPtr input, OleContent &content);
00252
00258 bool readCONTENTS(STOFFInputStreamPtr input, OleContent &content);
00259
00260 protected:
00261
00262
00263
00264
00266 shared_ptr<STOFFOLEParserInternal::State> m_state;
00267 };
00268
00269 #endif
00270