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 <string>
59 #include <vector>
60 
61 #include <libwpd-stream/WPXStream.h>
62 
63 #include "libwps_internal.h"
64 
65 #include "WPSDebug.h"
66 
67 class WPXBinaryData;
68 
69 namespace libwps
70 {
71 class Storage;
72 }
73 class WPSPosition;
74 namespace WPSOLEParserInternal
75 {
76 class CompObj;
77 }
78 
83 {
84 public:
87  WPSOLEParser(const std::string &mainName);
88 
90  ~WPSOLEParser();
91 
94  bool parse(shared_ptr<libwps::Storage> fileInput);
95 
97  std::vector<std::string> const &getNotParse() const
98  {
99  return m_unknownOLEs;
100  }
101 
103  std::vector<int> const &getObjectsId() const
104  {
105  return m_objectsId;
106  }
108  std::vector<WPSPosition> const &getObjectsPosition() const
109  {
110  return m_objectsPosition;
111  }
113  std::vector<WPXBinaryData> const &getObjects() const
114  {
115  return m_objects;
116  }
117 
119  bool getObject(int id, WPXBinaryData &obj, WPSPosition &pos) const;
120 
124  void setObject(int id, WPXBinaryData const &obj, WPSPosition const &pos);
125 protected:
126 
128  bool readOle(WPXInputStreamPtr &ip, std::string const &oleName,
129  libwps::DebugFile &ascii);
131  bool readMM(WPXInputStreamPtr &input, std::string const &oleName,
132  libwps::DebugFile &ascii);
134  bool readObjInfo(WPXInputStreamPtr &input, std::string const &oleName,
135  libwps::DebugFile &ascii);
137  bool readCompObj(WPXInputStreamPtr &ip, std::string const &oleName,
138  libwps::DebugFile &ascii);
139 
141  bool isOlePres(WPXInputStreamPtr &ip, std::string const &oleName);
143  bool readOlePres(WPXInputStreamPtr &ip, WPXBinaryData &data, WPSPosition &pos,
144  libwps::DebugFile &ascii);
145 
147  bool isOle10Native(WPXInputStreamPtr &ip, std::string const &oleName);
149  bool readOle10Native(WPXInputStreamPtr &ip, WPXBinaryData &data,
150  libwps::DebugFile &ascii);
151 
155  bool readContents(WPXInputStreamPtr &input, std::string const &oleName,
156  WPXBinaryData &pict, WPSPosition &pos, libwps::DebugFile &ascii);
157 
163  bool readCONTENTS(WPXInputStreamPtr &input, std::string const &oleName,
164  WPXBinaryData &pict, WPSPosition &pos, libwps::DebugFile &ascii);
165 
166 
168  std::string m_avoidOLE;
170  std::vector<std::string> m_unknownOLEs;
171 
173  std::vector<WPXBinaryData> m_objects;
175  std::vector<WPSPosition> m_objectsPosition;
177  std::vector<int> m_objectsId;
178 
180  shared_ptr<WPSOLEParserInternal::CompObj> m_compObjIdName;
181 
182 };
183 
184 #endif
185 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
std::vector< WPXBinaryData > const & getObjects() const
returns the list of data which have been read
Definition: WPSOLEParser.h:113
bool isOle10Native(WPXInputStreamPtr &ip, std::string const &oleName)
theOle10Native : basic Windows© picture, with no size
Definition: WPSOLEParser.cpp:872
std::vector< int > const & getObjectsId() const
returns the list of id for which we have find a representation
Definition: WPSOLEParser.h:103
shared_ptr< WPXInputStream > WPXInputStreamPtr
Definition: libwps_internal.h:74
Definition: WPSDebug.h:198
bool parse(shared_ptr< libwps::Storage > fileInput)
tries to parse basic OLE (excepted mainName)
Definition: WPSOLEParser.cpp:267
bool readOlePres(WPXInputStreamPtr &ip, WPXBinaryData &data, WPSPosition &pos, libwps::DebugFile &ascii)
extracts the picture of OlePres001 if it is possible
Definition: WPSOLEParser.cpp:761
bool readCONTENTS(WPXInputStreamPtr &input, std::string const &oleName, WPXBinaryData &pict, WPSPosition &pos, libwps::DebugFile &ascii)
the CONTENTS : seems to store a header size, the header and then a object in EMF (with the same heade...
Definition: WPSOLEParser.cpp:1035
a class used to parse some basic oles Tries to read the different ole parts and stores their contents...
Definition: WPSOLEParser.h:82
WPSOLEParser(const std::string &mainName)
constructor
Definition: WPSOLEParser.cpp:228
bool readMM(WPXInputStreamPtr &input, std::string const &oleName, libwps::DebugFile &ascii)
the &quot;MM&quot; small structure : seems to contain the file versions
Definition: WPSOLEParser.cpp:530
bool readObjInfo(WPXInputStreamPtr &input, std::string const &oleName, libwps::DebugFile &ascii)
the &quot;ObjInfo&quot; small structure : seems to contain 3 ints=0,3,4
Definition: WPSOLEParser.cpp:509
~WPSOLEParser()
destructor
Definition: WPSOLEParser.cpp:234
std::vector< int > m_objectsId
list of pictures id
Definition: WPSOLEParser.h:177
bool isOlePres(WPXInputStreamPtr &ip, std::string const &oleName)
the OlePres001 seems to contain standart picture file and size
Definition: WPSOLEParser.cpp:716
bool readContents(WPXInputStreamPtr &input, std::string const &oleName, WPXBinaryData &pict, WPSPosition &pos, libwps::DebugFile &ascii)
the Contents : in general a picture : a PNG, an JPEG, a basic metafile, I find also a Word art pictur...
Definition: WPSOLEParser.cpp:927
bool readOle10Native(WPXInputStreamPtr &ip, WPXBinaryData &data, libwps::DebugFile &ascii)
extracts the picture if it is possible
Definition: WPSOLEParser.cpp:888
std::vector< WPSPosition > m_objectsPosition
list of picture size ( if known)
Definition: WPSOLEParser.h:175
shared_ptr< WPSOLEParserInternal::CompObj > m_compObjIdName
a smart ptr used to stored the list of compobj id-&gt;name
Definition: WPSOLEParser.h:180
bool readCompObj(WPXInputStreamPtr &ip, std::string const &oleName, libwps::DebugFile &ascii)
the &quot;CompObj&quot; contains : UserType,ClipName,ProgIdName
Definition: WPSOLEParser.cpp:586
std::string m_avoidOLE
if filled, does not parse content with this name
Definition: WPSOLEParser.h:168
std::vector< WPSPosition > const & getObjectsPosition() const
returns the list of data positions which have been read
Definition: WPSOLEParser.h:108
std::vector< std::string > m_unknownOLEs
list of ole which can not be parsed
Definition: WPSOLEParser.h:170
std::vector< WPXBinaryData > m_objects
list of pictures read
Definition: WPSOLEParser.h:173
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: WPSPosition.h:39
bool getObject(int id, WPXBinaryData &obj, WPSPosition &pos) const
returns the picture corresponding to an id
Definition: WPSOLEParser.cpp:239
void setObject(int id, WPXBinaryData const &obj, WPSPosition const &pos)
sets an object just in case, the external parsing find another representation
Definition: WPSOLEParser.cpp:252
bool readOle(WPXInputStreamPtr &ip, std::string const &oleName, libwps::DebugFile &ascii)
the &quot;Ole&quot; small structure : unknown contain
Definition: WPSOLEParser.cpp:474
std::vector< std::string > const & getNotParse() const
returns the list of unknown ole
Definition: WPSOLEParser.h:97

Generated on Wed Jun 11 2014 02:26:01 for libwps by doxygen 1.8.5