MWAWOLEParser.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 /*
35  * freely inspired from istorage :
36  * ------------------------------------------------------------
37  * Generic OLE Zones furnished with a copy of the file header
38  *
39  * Compound Storage (32 bit version)
40  * Storage implementation
41  *
42  * This file contains the compound file implementation
43  * of the storage interface.
44  *
45  * Copyright 1999 Francis Beaudet
46  * Copyright 1999 Sylvain St-Germain
47  * Copyright 1999 Thuy Nguyen
48  * Copyright 2005 Mike McCormack
49  *
50  * This library is free software; you can redistribute it and/or
51  * modify it under the terms of the GNU Lesser General Public
52  * License as published by the Free Software Foundation; either
53  * version 2.1 of the License, or (at your option) any later version.
54  *
55  * This library is distributed in the hope that it will be useful,
56  * but WITHOUT ANY WARRANTY; without even the implied warranty of
57  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58  * Lesser General Public License for more details.
59  *
60  * ------------------------------------------------------------
61  */
62 
63 #ifndef MWAW_OLE_PARSER_H
64 #define MWAW_OLE_PARSER_H
65 
66 #include <string>
67 #include <vector>
68 
69 #include <librevenge-stream/librevenge-stream.h>
70 
71 #include "libmwaw_internal.hxx"
72 #include "MWAWInputStream.hxx"
73 
74 #include "MWAWDebug.hxx"
75 
76 namespace MWAWOLEParserInternal
77 {
78 class CompObj;
79 struct State;
80 }
81 
86 {
87 public:
93  explicit MWAWOLEParser(std::string const &mainName, MWAWFontConverterPtr const &fontConverter, int fontId);
94 
97 
100  bool parse(MWAWInputStreamPtr fileInput);
102  void updateMetaData(librevenge::RVNGPropertyList &metaData) const;
104  int getFontEncoding() const;
106  std::vector<std::string> const &getNotParse() const;
108  std::vector<int> const &getObjectsId() const;
110  std::vector<MWAWPosition> const &getObjectsPosition() const;
112  std::vector<librevenge::RVNGBinaryData> const &getObjects() const;
114  std::vector<std::string> const &getObjectsType() const;
115 
117  bool getObject(int id, librevenge::RVNGBinaryData &obj, MWAWPosition &pos, std::string &type) const;
118 
122  void setObject(int id, librevenge::RVNGBinaryData const &obj, MWAWPosition const &pos,
123  std::string const &type);
124 
125 protected:
127  bool readSummaryInformation(MWAWInputStreamPtr input, std::string const &oleName,
128  int &encoding, librevenge::RVNGPropertyList &pList,
129  libmwaw::DebugFile &ascii) const;
131  bool readSummaryProperty(MWAWInputStreamPtr input, long endPos, int type,
132  libmwaw::DebugFile &ascii, libmwaw::DebugStream &f) const;
134  bool readSummaryPropertyString(MWAWInputStreamPtr input, long endPos, int type, librevenge::RVNGString &string,
135  libmwaw::DebugStream &f) const;
137  bool readSummaryPropertyLong(MWAWInputStreamPtr input, long endPos, int type, long &value,
138  libmwaw::DebugStream &f) const;
139 
141  static bool readOle(MWAWInputStreamPtr ip, std::string const &oleName,
142  libmwaw::DebugFile &ascii);
144  static bool readMM(MWAWInputStreamPtr input, std::string const &oleName,
145  libmwaw::DebugFile &ascii);
147  static bool readObjInfo(MWAWInputStreamPtr input, std::string const &oleName,
148  libmwaw::DebugFile &ascii);
150  bool readCompObj(MWAWInputStreamPtr ip, std::string const &oleName,
151  libmwaw::DebugFile &ascii);
152 
154  static bool isOlePres(MWAWInputStreamPtr ip, std::string const &oleName);
156  static bool readOlePres(MWAWInputStreamPtr ip, librevenge::RVNGBinaryData &data, MWAWPosition &pos,
157  libmwaw::DebugFile &ascii);
158 
160  static bool isOle10Native(MWAWInputStreamPtr ip, std::string const &oleName);
162  static bool readOle10Native(MWAWInputStreamPtr ip, librevenge::RVNGBinaryData &data,
163  libmwaw::DebugFile &ascii);
164 
168  bool readContents(MWAWInputStreamPtr input, std::string const &oleName,
169  librevenge::RVNGBinaryData &pict, MWAWPosition &pos, libmwaw::DebugFile &ascii);
170 
176  bool readCONTENTS(MWAWInputStreamPtr input, std::string const &oleName,
177  librevenge::RVNGBinaryData &pict, MWAWPosition &pos, libmwaw::DebugFile &ascii);
178 
179 
181  std::string m_avoidOLE;
183  std::shared_ptr<MWAWOLEParserInternal::State> m_state;
184 };
185 
186 #endif
187 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
MWAWOLEParserInternal::State::m_objectsPosition
std::vector< MWAWPosition > m_objectsPosition
list of picture size ( if known)
Definition: MWAWOLEParser.cxx:232
MWAWOLEParser::getObject
bool getObject(int id, librevenge::RVNGBinaryData &obj, MWAWPosition &pos, std::string &type) const
returns the picture corresponding to an id
Definition: MWAWOLEParser.cxx:293
MWAWOLEParser::readMM
static bool readMM(MWAWInputStreamPtr input, std::string const &oleName, libmwaw::DebugFile &ascii)
the "MM" small structure : seems to contain the file versions
Definition: MWAWOLEParser.cxx:596
MWAWInputStream::get
static std::shared_ptr< MWAWInputStream > get(librevenge::RVNGBinaryData const &data, bool inverted)
returns a new input stream corresponding to a librevenge::RVNGBinaryData
Definition: MWAWInputStream.cxx:102
MWAWPosition::naturalSize
MWAWVec2f const & naturalSize() const
returns the natural size (if known)
Definition: MWAWPosition.hxx:140
MWAWOLEParser::readSummaryPropertyString
bool readSummaryPropertyString(MWAWInputStreamPtr input, long endPos, int type, librevenge::RVNGString &string, libmwaw::DebugStream &f) const
try to read a summary property: type 1e
Definition: MWAWOLEParser.cxx:911
MWAWPosition::getInvUnitScale
float getInvUnitScale(librevenge::RVNGUnit fromUnit) const
returns a float which can be used to scale some data in object unit
Definition: MWAWPosition.hxx:199
MWAWFontConverterPtr
std::shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition: libmwaw_internal.hxx:543
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MWAWOLEParser::getNotParse
std::vector< std::string > const & getNotParse() const
returns the list of unknown ole
Definition: MWAWOLEParser.cxx:268
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
MWAWOLEParserInternal::State::m_compObjIdName
std::shared_ptr< MWAWOLEParserInternal::CompObj > m_compObjIdName
a smart ptr used to stored the list of compobj id->name
Definition: MWAWOLEParser.cxx:239
MWAWOLEParser::readOlePres
static bool readOlePres(MWAWInputStreamPtr ip, librevenge::RVNGBinaryData &data, MWAWPosition &pos, libmwaw::DebugFile &ascii)
extracts the picture of OlePres001 if it is possible
Definition: MWAWOLEParser.cxx:1132
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
MWAWOLEParser::readSummaryPropertyLong
bool readSummaryPropertyLong(MWAWInputStreamPtr input, long endPos, int type, long &value, libmwaw::DebugStream &f) const
try to read a summary property: type 2,3,9,12,
Definition: MWAWOLEParser.cxx:943
MWAWFontConverter.hxx
libmwaw::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string
Definition: libmwaw_internal.cxx:63
MWAWOLEParser::isOlePres
static bool isOlePres(MWAWInputStreamPtr ip, std::string const &oleName)
the OlePres001 seems to contain standart picture file and size
Definition: MWAWOLEParser.cxx:1087
MWAWPosition::setUnit
void setUnit(librevenge::RVNGUnit newUnit)
sets the dimension unit
Definition: MWAWPosition.hxx:225
MWAWOLEParserInternal::CompObj::CompObj
CompObj()
the constructor
Definition: MWAWOLEParser.cxx:59
MWAWOLEParserInternal::State::m_objects
std::vector< librevenge::RVNGBinaryData > m_objects
list of pictures read
Definition: MWAWOLEParser.cxx:230
MWAWOLEParser::getObjectsPosition
std::vector< MWAWPosition > const & getObjectsPosition() const
returns the list of data positions which have been read
Definition: MWAWOLEParser.cxx:278
MWAWOLEParser::setObject
void setObject(int id, librevenge::RVNGBinaryData const &obj, MWAWPosition const &pos, std::string const &type)
sets an object just in case, the external parsing find another representation
Definition: MWAWOLEParser.cxx:306
MWAWOLEParser
a class used to parse some basic oles Tries to read the different ole parts and stores their contents...
Definition: MWAWOLEParser.hxx:86
MWAWOLEParser::readCONTENTS
bool readCONTENTS(MWAWInputStreamPtr input, std::string const &oleName, librevenge::RVNGBinaryData &pict, MWAWPosition &pos, libmwaw::DebugFile &ascii)
the CONTENTS : seems to store a header size, the header and then a object in EMF (with the same heade...
Definition: MWAWOLEParser.cxx:1384
MWAWOLEParserInternal::OleDef::m_dir
std::string m_dir
the directory
Definition: MWAWOLEParser.cxx:199
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
MWAWPosition::setNaturalSize
void setNaturalSize(MWAWVec2f const &naturalSz)
sets the natural size (if known)
Definition: MWAWPosition.hxx:220
MWAWOLEParser::m_avoidOLE
std::string m_avoidOLE
if filled, does not parse content with this name
Definition: MWAWOLEParser.hxx:181
MWAWOLEParser::readSummaryInformation
bool readSummaryInformation(MWAWInputStreamPtr input, std::string const &oleName, int &encoding, librevenge::RVNGPropertyList &pList, libmwaw::DebugFile &ascii) const
the summary information and the doc summary information
Definition: MWAWOLEParser.cxx:772
MWAWOLEParserInternal::CompObj
Internal: internal method to compobj definition.
Definition: MWAWOLEParser.cxx:56
MWAWOLEParserInternal::State::m_encoding
int m_encoding
the font encoding
Definition: MWAWOLEParser.cxx:223
MWAWOLEParserInternal::State::m_objectsType
std::vector< std::string > m_objectsType
list of picture type
Definition: MWAWOLEParser.cxx:236
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
MWAWOLEParser::isOle10Native
static bool isOle10Native(MWAWInputStreamPtr ip, std::string const &oleName)
theOle10Native : basic Windows© picture, with no size
Definition: MWAWOLEParser.cxx:1233
libmwaw::DebugFile::skipZone
void skipZone(long beginPos, long endPos)
skips the file zone defined by beginPos-endPos
Definition: MWAWDebug.hxx:113
MWAWVec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:673
libmwaw::Debug::dumpFile
bool dumpFile(librevenge::RVNGBinaryData &data, char const *fileName)
a debug function to store in a datafile in the current directory WARNING: this function erase the fil...
Definition: MWAWDebug.cxx:193
MWAWOLEParser::getObjectsId
std::vector< int > const & getObjectsId() const
returns the list of id for which we have find a representation
Definition: MWAWOLEParser.cxx:273
libmwaw_internal.hxx
MWAWPosition.hxx
MWAWPosition::setSize
void setSize(MWAWVec2f const &sz)
sets the frame size
Definition: MWAWPosition.hxx:215
MWAWOLEParserInternal::State::State
State(MWAWFontConverterPtr const &fontConverter, int fId)
constructor
Definition: MWAWOLEParser.cxx:205
MWAWOLEParser::readContents
bool readContents(MWAWInputStreamPtr input, std::string const &oleName, librevenge::RVNGBinaryData &pict, MWAWPosition &pos, libmwaw::DebugFile &ascii)
the Contents : in general a picture : a PNG, an JPEG, a basic metafile, I find also a Word art pictur...
Definition: MWAWOLEParser.cxx:1287
MWAWVec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:668
MWAWOLEParser::updateMetaData
void updateMetaData(librevenge::RVNGPropertyList &metaData) const
update the meta data, using information find in SummaryInformation
Definition: MWAWOLEParser.cxx:259
MWAWOLEParserInternal::CompObj::getCLSName
char const * getCLSName(unsigned long v)
return the CLS Name corresponding to an identifier
Definition: MWAWOLEParser.cxx:66
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
MWAWOLEParser::getObjects
std::vector< librevenge::RVNGBinaryData > const & getObjects() const
returns the list of data which have been read
Definition: MWAWOLEParser.cxx:283
MWAWOLEParserInternal::CompObj::m_mapCls
std::map< unsigned long, char const * > m_mapCls
map CLSId <-> name
Definition: MWAWOLEParser.cxx:74
MWAWOLEParserInternal::State::m_fontId
int m_fontId
the font id used to decode string
Definition: MWAWOLEParser.cxx:221
MWAWOLEParser.hxx
MWAWPict::MWAW_R_BAD
@ MWAW_R_BAD
Definition: MWAWPict.hxx:73
MWAWVec2< float >
MWAWOLEParser::getObjectsType
std::vector< std::string > const & getObjectsType() const
returns the list of data type
Definition: MWAWOLEParser.cxx:288
MWAWPictMac.hxx
MWAWDebug.hxx
MWAWOLEParserInternal::CompObj::initCLSMap
void initCLSMap()
initialise a map CLSId <-> name
Definition: MWAWOLEParser.cxx:77
MWAWOLEParser::~MWAWOLEParser
~MWAWOLEParser()
destructor
Definition: MWAWOLEParser.cxx:250
MWAWOLEParser::readCompObj
bool readCompObj(MWAWInputStreamPtr ip, std::string const &oleName, libmwaw::DebugFile &ascii)
the "CompObj" contains : UserType,ClipName,ProgIdName
Definition: MWAWOLEParser.cxx:652
MWAWOLEParser::readSummaryProperty
bool readSummaryProperty(MWAWInputStreamPtr input, long endPos, int type, libmwaw::DebugFile &ascii, libmwaw::DebugStream &f) const
try to read a summary property
Definition: MWAWOLEParser.cxx:968
MWAWOLEParser::getFontEncoding
int getFontEncoding() const
returns the font encoding find in SummaryInformation or -1
Definition: MWAWOLEParser.cxx:254
MWAWPosition::Char
@ Char
Definition: MWAWPosition.hxx:51
MWAWOLEParserInternal::State::m_unknownOLEs
std::vector< std::string > m_unknownOLEs
list of ole which can not be parsed
Definition: MWAWOLEParser.cxx:227
MWAWOLEParser::readObjInfo
static bool readObjInfo(MWAWInputStreamPtr input, std::string const &oleName, libmwaw::DebugFile &ascii)
the "ObjInfo" small structure : seems to contain 3 ints=0,3,4
Definition: MWAWOLEParser.cxx:575
MWAWOLEParserInternal
Low level: namespace used to define/store the data used by MWAWOLEParser.
Definition: MWAWOLEParser.cxx:53
MWAWPictData::check
static ReadResult check(MWAWInputStreamPtr const &input, int size, MWAWBox2f &box)
checks if the data pointed by input is known
Definition: MWAWPictData.hxx:100
MWAWOLEParser::readOle10Native
static bool readOle10Native(MWAWInputStreamPtr ip, librevenge::RVNGBinaryData &data, libmwaw::DebugFile &ascii)
extracts the picture if it is possible
Definition: MWAWOLEParser.cxx:1249
MWAWOLEParserInternal::OleDef::m_subId
int m_subId
subsversion id
Definition: MWAWOLEParser.cxx:198
MWAWOLEParserInternal::State
Internal: internal state of a MWAWOLEParser.
Definition: MWAWOLEParser.cxx:203
MWAWOLEParserInternal::State::m_fontConverter
MWAWFontConverterPtr m_fontConverter
the font converter
Definition: MWAWOLEParser.cxx:219
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWOLEParserInternal::OleDef::m_name
std::string m_name
the complete name
Definition: MWAWOLEParser.cxx:199
MWAWOLEParser::MWAWOLEParser
MWAWOLEParser(std::string const &mainName, MWAWFontConverterPtr const &fontConverter, int fontId)
constructor
Definition: MWAWOLEParser.cxx:244
MWAWPosition::unit
librevenge::RVNGUnit unit() const
returns the unit
Definition: MWAWPosition.hxx:155
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
MWAWOLEParserInternal::State::m_metaData
librevenge::RVNGPropertyList m_metaData
the meta data
Definition: MWAWOLEParser.cxx:225
MWAWOLEParserInternal::OleDef::m_base
std::string m_base
the base
Definition: MWAWOLEParser.cxx:199
MWAWInputStream.hxx
MWAWOLEParserInternal::OleDef
Internal: internal method to keep ole definition.
Definition: MWAWOLEParser.cxx:189
MWAWOLEParser::readOle
static bool readOle(MWAWInputStreamPtr ip, std::string const &oleName, libmwaw::DebugFile &ascii)
the "Ole" small structure : unknown contain
Definition: MWAWOLEParser.cxx:542
MWAWOLEParserInternal::State::m_objectsId
std::vector< int > m_objectsId
list of pictures id
Definition: MWAWOLEParser.cxx:234
MWAWBox2< float >
MWAWOLEParser::m_state
std::shared_ptr< MWAWOLEParserInternal::State > m_state
the main state
Definition: MWAWOLEParser.hxx:183
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWOLEParserInternal::OleDef::m_id
int m_id
main id
Definition: MWAWOLEParser.cxx:198
MWAWOLEParserInternal::OleDef::OleDef
OleDef()
Definition: MWAWOLEParser.cxx:190
MWAWOLEParser::parse
bool parse(MWAWInputStreamPtr fileInput)
tries to parse basic OLE (excepted mainName)
Definition: MWAWOLEParser.cxx:323

Generated on Fri Sep 18 2020 18:14:52 for libmwaw by doxygen 1.8.20