WPSOLEParser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
00011  * Copyright (C) 2006, 2007 Andrew Ziem
00012  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00013  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
00014  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00015  *
00016  * For minor contributions see the git repository.
00017  *
00018  * Alternatively, the contents of this file may be used under the terms
00019  * of the GNU Lesser General Public License Version 2.1 or later
00020  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00021  * applicable instead of those above.
00022  *
00023  * For further information visit http://libwps.sourceforge.net
00024  */
00025 
00026 /*
00027  *  freely inspired from istorage :
00028  * ------------------------------------------------------------
00029  *      Generic OLE Zones furnished with a copy of the file header
00030  *
00031  * Compound Storage (32 bit version)
00032  * Storage implementation
00033  *
00034  * This file contains the compound file implementation
00035  * of the storage interface.
00036  *
00037  * Copyright 1999 Francis Beaudet
00038  * Copyright 1999 Sylvain St-Germain
00039  * Copyright 1999 Thuy Nguyen
00040  * Copyright 2005 Mike McCormack
00041  *
00042  * This library is free software; you can redistribute it and/or
00043  * modify it under the terms of the GNU Lesser General Public
00044  * License as published by the Free Software Foundation; either
00045  * version 2.1 of the License, or (at your option) any later version.
00046  *
00047  * This library is distributed in the hope that it will be useful,
00048  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00049  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00050  * Lesser General Public License for more details.
00051  *
00052  * ------------------------------------------------------------
00053  */
00054 
00055 #ifndef WPS_OLE_PARSER_H
00056 #define WPS_OLE_PARSER_H
00057 
00058 #include <string>
00059 #include <vector>
00060 
00061 #include <librevenge-stream/librevenge-stream.h>
00062 
00063 #include "libwps_internal.h"
00064 
00065 #include "WPSDebug.h"
00066 #include "WPSPosition.h"
00067 
00068 namespace libwps
00069 {
00070 class Storage;
00071 }
00072 
00073 namespace WPSOLEParserInternal
00074 {
00075 class CompObj;
00076 }
00077 
00079 struct WPSOLEParserObject
00080 {
00082         WPSOLEParserObject() : m_position(), m_data(), m_mime("image/pict")
00083         {
00084         }
00086         WPSPosition m_position;
00088         librevenge::RVNGBinaryData m_data;
00090         std::string m_mime;
00091 };
00092 
00096 class WPSOLEParser
00097 {
00098 public:
00101         WPSOLEParser(const std::string &mainName);
00102 
00104         ~WPSOLEParser();
00105 
00108         bool parse(RVNGInputStreamPtr fileInput);
00109 
00111         std::vector<std::string> const &getNotParse() const
00112         {
00113                 return m_unknownOLEs;
00114         }
00115 
00117         std::vector<int> const &getObjectsId() const
00118         {
00119                 return m_objectsId;
00120         }
00122         std::vector<WPSOLEParserObject> const &getObjects() const
00123         {
00124                 return m_objects;
00125         }
00126 protected:
00127 
00129         static bool readOle(RVNGInputStreamPtr &ip, std::string const &oleName,
00130                             libwps::DebugFile &ascii);
00132         static bool readMM(RVNGInputStreamPtr &input, std::string const &oleName,
00133                            libwps::DebugFile &ascii);
00135         static bool readObjInfo(RVNGInputStreamPtr &input, std::string const &oleName,
00136                                 libwps::DebugFile &ascii);
00138         bool readCompObj(RVNGInputStreamPtr &ip, std::string const &oleName,
00139                          libwps::DebugFile &ascii);
00140 
00142         static bool isOlePres(RVNGInputStreamPtr &ip, std::string const &oleName);
00144         static bool readOlePres(RVNGInputStreamPtr &ip, librevenge::RVNGBinaryData &data,
00145                                 WPSPosition &pos, libwps::DebugFile &ascii);
00146 
00148         static bool isOle10Native(RVNGInputStreamPtr &ip, std::string const &oleName);
00150         static bool readOle10Native(RVNGInputStreamPtr &ip, librevenge::RVNGBinaryData &data,
00151                                     libwps::DebugFile &ascii);
00152 
00156         static bool readContents(RVNGInputStreamPtr &input, std::string const &oleName,
00157                                  librevenge::RVNGBinaryData &pict, WPSPosition &pos, libwps::DebugFile &ascii);
00158 
00164         static bool readCONTENTS(RVNGInputStreamPtr &input, std::string const &oleName,
00165                                  librevenge::RVNGBinaryData &pict, WPSPosition &pos, libwps::DebugFile &ascii);
00166 
00168         static bool readMN0AndCheckWKS(RVNGInputStreamPtr &input, std::string const &oleName,
00169                                        librevenge::RVNGBinaryData &wksData,  libwps::DebugFile &ascii);
00170 
00172         std::string m_avoidOLE;
00174         std::vector<std::string> m_unknownOLEs;
00175 
00177         std::vector<WPSOLEParserObject> m_objects;
00179         std::vector<int> m_objectsId;
00180 
00182         shared_ptr<WPSOLEParserInternal::CompObj> m_compObjIdName;
00183 
00184 };
00185 
00186 #endif
00187 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */