MsWrdParser.hxx Source File documentation

MsWrdParser.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 * parser for Microsoft Word ( version 3.0-5.1 )
36 */
37 #ifndef MS_WRD_MWAW_PARSER
38 # define MS_WRD_MWAW_PARSER
39
40 #include <list>
41 #include <map>
42 #include <string>
43 #include <vector>
44
45 #include "MWAWDebug.hxx"
46 #include "MWAWEntry.hxx"
47 #include "MWAWInputStream.hxx"
48 #include "MWAWPosition.hxx"
49
50 #include "MWAWParser.hxx"
51
52 namespace MsWrdParserInternal
53 {
54 struct Object;
55 struct State;
56 class SubDocument;
57 }
58
59 class MsWrdText;
60 class MsWrdTextStyles;
61
63 struct MsWrdEntry final : public MWAWEntry {
65 MsWrdEntry()
66 : MWAWEntry()
67 , m_pictType(-1)
68 {
69 }
71 ~MsWrdEntry() final;
76 int pictType() const
77 {
78 return m_pictType;
79 }
81 void setPictType(int newId)
82 {
83 m_pictType = newId;
84 }
86 friend std::ostream &operator<<(std::ostream &o, MsWrdEntry const &entry);
88 int m_pictType;
89 };
90
96 class MsWrdParser final : public MWAWTextParser
97 {
98 friend class MsWrdText;
99 friend class MsWrdTextStyles;
100 friend class MsWrdParserInternal::SubDocument;
101
102 public:
104 MsWrdParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
106 ~MsWrdParser() final;
107
109 bool checkHeader(MWAWHeader *header, bool strict=false) final;
110
112 void parse(librevenge::RVNGTextInterface *documentInterface) final;
113
114 protected:
116 void init();
117
119 void createDocument(librevenge::RVNGTextInterface *documentInterface);
120
122 bool createZones();
123
125 bool readHeaderEndV3();
126
128 bool readZoneList();
129
131 bool readPrintInfo(MsWrdEntry &entry);
132
134 bool readPrinter(MsWrdEntry &entry);
135
137 bool readDocSum(MsWrdEntry &entry);
138
140 bool readStringsZone(MsWrdEntry &entry, std::vector<std::string> &list);
141
143 bool readObjects();
144
146 bool readObjectList(MsWrdEntry &entry);
147
149 bool readObjectFlags(MsWrdEntry &entry);
150
152 bool readObject(MsWrdParserInternal::Object &obj);
153
155 bool readDocumentInfo(MsWrdEntry &entry);
156
158 bool readZone17(MsWrdEntry &entry);
159
161 bool checkPicturePos(long pos, int type);
162
164 bool readPicture(MsWrdEntry &entry);
166 void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char);
167
169 bool getColor(int id, MWAWColor &col) const;
170
172 void newPage(int number);
173
174 /*
175 * interface with subdocument
176 */
178 void sendFootnote(int id);
179
181 void sendFieldComment(int id);
182
184 void send(int id, libmwaw::SubDocumentType type);
186 void send(MWAWEntry const &entry);
187
188 //
189 // low level
190 //
191
193 MsWrdEntry readEntry(std::string type, int id=-1);
194
195 protected:
196 //
197 // data
198 //
200 std::shared_ptr<MsWrdParserInternal::State> m_state;
201
203 std::multimap<std::string, MsWrdEntry> m_entryMap;
204
206 std::shared_ptr<MsWrdText> m_textParser;
207 };
208 #endif
209 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MsWrdParser::readHeaderEndV3
bool readHeaderEndV3()
finish reading the header (v3)
Definition: MsWrdParser.cxx:860
MsWrdEntry::~MsWrdEntry
~MsWrdEntry() final
destructor
Definition: MsWrdParser.cxx:312
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MsWrdParser::readPicture
bool readPicture(MsWrdEntry &entry)
read a picture data
Definition: MsWrdParser.cxx:1753
MWAWParser.hxx
librevenge
Definition: MWAWDocument.hxx:56
MWAWEntry.hxx
MsWrdParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MsWrdParser.cxx:476
MsWrdEntry::pictType
int pictType() const
returns the text id
Definition: MsWrdParser.hxx:76
MsWrdParser::readZone17
bool readZone17(MsWrdEntry &entry)
read the zone 17( some bdbox + text position ?)
Definition: MsWrdParser.cxx:1113
MsWrdEntry
the entry of MsWrdParser
Definition: MsWrdParser.hxx:63
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
MsWrdParser::MsWrdParser
MsWrdParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: MsWrdParser.cxx:329
MsWrdEntry::setPictType
void setPictType(int newId)
sets the picture id
Definition: MsWrdParser.hxx:81
MsWrdParser::readDocSum
bool readDocSum(MsWrdEntry &entry)
read the document sumary
Definition: MsWrdParser.cxx:1237
MsWrdParser::sendFootnote
void sendFootnote(int id)
try to send a footnote id
Definition: MsWrdParser.cxx:405
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:50
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
MsWrdParser::readObjectFlags
bool readObjectFlags(MsWrdEntry &entry)
read the object flags
Definition: MsWrdParser.cxx:1484
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:557
MsWrdParser::m_textParser
std::shared_ptr< MsWrdText > m_textParser
the text parser
Definition: MsWrdParser.hxx:206
MsWrdParser::readZoneList
bool readZoneList()
read the list of zones
Definition: MsWrdParser.cxx:589
MsWrdParser::readEntry
MsWrdEntry readEntry(std::string type, int id=-1)
read a file entry
Definition: MsWrdParser.cxx:1001
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:298
MsWrdParser::~MsWrdParser
~MsWrdParser() final
destructor
Definition: MsWrdParser.cxx:338
MsWrdParser::send
void send(int id, libmwaw::SubDocumentType type)
try to send a footnote, a field to the textParser
Definition: MsWrdParser.cxx:427
MsWrdParser
the main class to read a Microsoft Word file
Definition: MsWrdParser.hxx:96
MsWrdParser::readPrinter
bool readPrinter(MsWrdEntry &entry)
read the printer name
Definition: MsWrdParser.cxx:1190
MWAWInputStream.hxx
MWAWDebug.hxx
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:547
MsWrdParser::readObjects
bool readObjects()
read the objects
Definition: MsWrdParser.cxx:1365
MsWrdParser::m_state
std::shared_ptr< MsWrdParserInternal::State > m_state
the state
Definition: MsWrdParser.hxx:200
MsWrdParserInternal::SubDocument
Internal: the subdocument of a MsWrdParser.
Definition: MsWrdParser.cxx:223
MsWrdText
the main class to read the text part of Microsoft Word file
Definition: MsWrdText.hxx:64
MsWrdEntry::m_pictType
int m_pictType
the picture identificator
Definition: MsWrdParser.hxx:88
MsWrdParser::checkPicturePos
bool checkPicturePos(long pos, int type)
check if a position corresponds or not to a picture entry
Definition: MsWrdParser.cxx:1718
MsWrdTextStyles
the main class to read/store the text font, paragraph, section stylesread
Definition: MsWrdTextStyles.hxx:66
MsWrdParserInternal
Internal: the structures of a MsWrdParser.
Definition: MsWrdParser.cxx:58
MsWrdParser::getColor
bool getColor(int id, MWAWColor &col) const
returns the color corresponding to an id
Definition: MsWrdParser.cxx:371
MWAWPosition.hxx
MsWrdParser::readPrintInfo
bool readPrintInfo(MsWrdEntry &entry)
read the print info zone
Definition: MsWrdParser.cxx:1890
MsWrdParser::createZones
bool createZones()
finds the different zones
Definition: MsWrdParser.cxx:528
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MsWrdParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: MsWrdParser.cxx:719
MsWrdParser::readObject
bool readObject(MsWrdParserInternal::Object &obj)
read an object
Definition: MsWrdParser.cxx:1541
MsWrdParser::sendPicture
void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char)
send a picture
Definition: MsWrdParser.cxx:1829
MsWrdParser::init
void init()
inits all internal variables
Definition: MsWrdParser.cxx:342
MsWrdParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
the main parse function
Definition: MsWrdParser.cxx:441
MsWrdParser::newPage
void newPage(int number)
adds a new page
Definition: MsWrdParser.cxx:358
MsWrdEntry::operator<<
friend std::ostream & operator<<(std::ostream &o, MsWrdEntry const &entry)
operator<<
Definition: MsWrdParser.cxx:316
MsWrdParser::readDocumentInfo
bool readDocumentInfo(MsWrdEntry &entry)
read the page dimensions + ?
Definition: MsWrdParser.cxx:1042
MsWrdParser::readObjectList
bool readObjectList(MsWrdEntry &entry)
read the object list
Definition: MsWrdParser.cxx:1411
MsWrdEntry::MsWrdEntry
MsWrdEntry()
constructor
Definition: MsWrdParser.hxx:65
MsWrdParser::sendFieldComment
void sendFieldComment(int id)
try to send a bookmark field id
Definition: MsWrdParser.cxx:414
MsWrdParser::readStringsZone
bool readStringsZone(MsWrdEntry &entry, std::vector< std::string > &list)
read a zone which consists in a list of string
Definition: MsWrdParser.cxx:1308
MsWrdParser::m_entryMap
std::multimap< std::string, MsWrdEntry > m_entryMap
the list of entries
Definition: MsWrdParser.hxx:203