WPSOLEParser.h Source File documentation

WPSOLEParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11 * Copyright (C) 2006, 2007 Andrew Ziem
12 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15 *
16 * For minor contributions see the git repository.
17 *
18 * Alternatively, the contents of this file may be used under the terms
19 * of the GNU Lesser General Public License Version 2.1 or later
20 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21 * applicable instead of those above.
22 *
23 * For further information visit http://libwps.sourceforge.net
24 */
25
26 /*
27 * freely inspired from istorage :
28 * ------------------------------------------------------------
29 * Generic OLE Zones furnished with a copy of the file header
30 *
31 * Compound Storage (32 bit version)
32 * Storage implementation
33 *
34 * This file contains the compound file implementation
35 * of the storage interface.
36 *
37 * Copyright 1999 Francis Beaudet
38 * Copyright 1999 Sylvain St-Germain
39 * Copyright 1999 Thuy Nguyen
40 * Copyright 2005 Mike McCormack
41 *
42 * This library is free software; you can redistribute it and/or
43 * modify it under the terms of the GNU Lesser General Public
44 * License as published by the Free Software Foundation; either
45 * version 2.1 of the License, or (at your option) any later version.
46 *
47 * This library is distributed in the hope that it will be useful,
48 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50 * Lesser General Public License for more details.
51 *
52 * ------------------------------------------------------------
53 */
54
55 #ifndef WPS_OLE_PARSER_H
56 #define WPS_OLE_PARSER_H
57
58 #include <functional>
59 #include <string>
60 #include <map>
61 #include <vector>
62
63 #include <librevenge-stream/librevenge-stream.h>
64
65 #include "libwps_internal.h"
66
67 #include "WPSDebug.h"
68 #include "WPSPosition.h"
69
70 namespace libwps
71 {
72 class Storage;
73 }
74
75 namespace WPSOLEParserInternal
76 {
77 class CompObj;
78 }
79
83 class WPSOLEParser
84 {
85 public:
88 explicit WPSOLEParser(const std::string &mainName, std::function<int(std::string const &)> const &dirToIdFunc=getIdFromDirectory);
89
91 ~WPSOLEParser();
92
95 bool parse(RVNGInputStreamPtr fileInput);
96
98 std::vector<std::string> const &getNotParse() const
99 {
100 return m_unknownOLEs;
101 }
103 std::map<int,WPSEmbeddedObject> const &getObjectsMap() const
104 {
105 return m_idToObjectMap;
106 }
107 protected:
108
110 static bool readOle(RVNGInputStreamPtr &ip, std::string const &oleName,
111 libwps::DebugFile &ascii);
113 static bool readMM(RVNGInputStreamPtr &input, std::string const &oleName,
114 libwps::DebugFile &ascii);
116 static bool readObjInfo(RVNGInputStreamPtr &input, std::string const &oleName,
117 libwps::DebugFile &ascii);
119 bool readCompObj(RVNGInputStreamPtr &ip, std::string const &oleName,
120 libwps::DebugFile &ascii);
121
123 static bool isOlePres(RVNGInputStreamPtr &ip, std::string const &oleName);
125 static bool readOlePres(RVNGInputStreamPtr &ip, WPSEmbeddedObject &obj, libwps::DebugFile &ascii);
126
128 static bool isOle10Native(RVNGInputStreamPtr &ip, std::string const &oleName);
130 static bool readOle10Native(RVNGInputStreamPtr &ip, WPSEmbeddedObject &obj, libwps::DebugFile &ascii);
131
135 static bool readContents(RVNGInputStreamPtr &input, std::string const &oleName,
136 WPSEmbeddedObject &obj, libwps::DebugFile &ascii);
137
143 static bool readCONTENTS(RVNGInputStreamPtr &input, std::string const &oleName,
144 WPSEmbeddedObject &obj, libwps::DebugFile &ascii);
145
147 static bool readMN0AndCheckWKS(RVNGInputStreamPtr &input, std::string const &oleName,
148 WPSEmbeddedObject &obj, libwps::DebugFile &ascii);
149
152 static int getIdFromDirectory(std::string const &dirName);
153
155 std::function<int(std::string const &)> m_directoryToIdFunction;
157 std::string m_avoidOLE;
159 std::vector<std::string> m_unknownOLEs;
160
162 std::map<int, WPSEmbeddedObject> m_idToObjectMap;
163
165 std::shared_ptr<WPSOLEParserInternal::CompObj> m_compObjIdName;
166
167 };
168
169 #endif
170 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSOLEParser::getObjectsMap
std::map< int, WPSEmbeddedObject > const & getObjectsMap() const
returns the list of data positions which have been read
Definition: WPSOLEParser.h:103
libwps
Definition: libwps_internal.cpp:38
WPSOLEParser::getNotParse
std::vector< std::string > const & getNotParse() const
returns the list of unknown ole
Definition: WPSOLEParser.h:98
libwps::DebugFile
Definition: WPSDebug.h:207
WPSOLEParserInternal
Definition: WPSOLEParser.cpp:85
WPSOLEParser
a class used to parse some basic oles Tries to read the different ole parts and stores their contents...
Definition: WPSOLEParser.h:83
WPSOLEParser::m_compObjIdName
std::shared_ptr< WPSOLEParserInternal::CompObj > m_compObjIdName
a smart ptr used to stored the list of compobj id->name
Definition: WPSOLEParser.h:165
libwps_internal.h
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
WPSEmbeddedObject
small class use to define a embedded object
Definition: libwps_internal.h:1076
WPSOLEParser::m_avoidOLE
std::string m_avoidOLE
if filled, does not parse content with this name
Definition: WPSOLEParser.h:157
WPSPosition.h
WPSOLEParser::m_unknownOLEs
std::vector< std::string > m_unknownOLEs
list of ole which can not be parsed
Definition: WPSOLEParser.h:159
WPSOLEParser::m_directoryToIdFunction
std::function< int(std::string const &)> m_directoryToIdFunction
the function used to convert a directory name in a id
Definition: WPSOLEParser.h:155
WPSDebug.h
WPSOLEParser::m_idToObjectMap
std::map< int, WPSEmbeddedObject > m_idToObjectMap
map id to object
Definition: WPSOLEParser.h:162