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 : public MWAWEntry {
65 MsWrdEntry() : MWAWEntry(), m_pictType(-1)
66 {
67 }
69 ~MsWrdEntry();
74 int pictType() const
75 {
76 return m_pictType;
77 }
79 void setPictType(int newId)
80 {
81 m_pictType = newId;
82 }
84 friend std::ostream &operator<<(std::ostream &o, MsWrdEntry const &entry);
86 int m_pictType;
87 };
88
94 class MsWrdParser : public MWAWTextParser
95 {
96 friend class MsWrdText;
97 friend class MsWrdTextStyles;
98 friend class MsWrdParserInternal::SubDocument;
99
100 public:
102 MsWrdParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
104 virtual ~MsWrdParser();
105
107 bool checkHeader(MWAWHeader *header, bool strict=false);
108
110 void parse(librevenge::RVNGTextInterface *documentInterface);
111
112 protected:
114 void init();
115
117 void createDocument(librevenge::RVNGTextInterface *documentInterface);
118
120 bool createZones();
121
123 bool readHeaderEndV3();
124
126 bool readZoneList();
127
129 bool readPrintInfo(MsWrdEntry &entry);
130
132 bool readPrinter(MsWrdEntry &entry);
133
135 bool readDocSum(MsWrdEntry &entry);
136
138 bool readStringsZone(MsWrdEntry &entry, std::vector<std::string> &list);
139
141 bool readObjects();
142
144 bool readObjectList(MsWrdEntry &entry);
145
147 bool readObjectFlags(MsWrdEntry &entry);
148
150 bool readObject(MsWrdParserInternal::Object &obj);
151
153 bool readDocumentInfo(MsWrdEntry &entry);
154
156 bool readZone17(MsWrdEntry &entry);
157
159 bool checkPicturePos(long pos, int type);
160
162 bool readPicture(MsWrdEntry &entry);
164 void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char);
165
167 bool getColor(int id, MWAWColor &col) const;
168
170 void newPage(int number);
171
172 /*
173 * interface with subdocument
174 */
176 void sendFootnote(int id);
177
179 void sendFieldComment(int id);
180
182 void send(int id, libmwaw::SubDocumentType type);
184 void send(MWAWEntry const &entry);
185
186 //
187 // low level
188 //
189
191 MsWrdEntry readEntry(std::string type, int id=-1);
192
193 protected:
194 //
195 // data
196 //
198 shared_ptr<MsWrdParserInternal::State> m_state;
199
201 std::multimap<std::string, MsWrdEntry> m_entryMap;
202
204 shared_ptr<MsWrdText> m_textParser;
205 };
206 #endif
207 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MsWrdParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type)
the parser function
Definition: MsWrdParser.cxx:246
MWAWParser.hxx
MWAWPosition::Char
Definition: MWAWPosition.hxx:51
BeagleWksDRParserInternal::operator<<
std::ostream & operator<<(std::ostream &o, Shape const &shape)
Definition: BeagleWksDRParser.cxx:98
MWAWEntry.hxx
MsWrdEntry::pictType
int pictType() const
returns the text id
Definition: MsWrdParser.hxx:74
MsWrdEntry
the entry of MsWrdParser
Definition: MsWrdParser.hxx:63
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:192
MsWrdEntry::setPictType
void setPictType(int newId)
sets the picture id
Definition: MsWrdParser.hxx:79
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:196
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:527
MWAWPosition::AnchorTo
AnchorTo
a list of enum used to defined the anchor
Definition: MWAWPosition.hxx:51
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:295
MsWrdParser
the main class to read a Microsoft Word file
Definition: MsWrdParser.hxx:94
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:517
MWAWInputStream.hxx
MWAWDebug.hxx
MsWrdParserInternal::SubDocument
Internal: the subdocument of a MsWrdParser.
Definition: MsWrdParser.cxx:208
MsWrdParserInternal::Object
Internal: the object of MsWrdParser.
Definition: MsWrdParser.cxx:61
FullWrtStruct::getColor
bool getColor(int color, MWAWColor &col)
try to convert a file data to a color
Definition: FullWrtStruct.cxx:45
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:86
MsWrdParser::m_textParser
shared_ptr< MsWrdText > m_textParser
the text parser
Definition: MsWrdParser.hxx:204
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:57
MWAWPosition.hxx
MsWrdParser::m_state
shared_ptr< MsWrdParserInternal::State > m_state
the state
Definition: MsWrdParser.hxx:198
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MsWrdEntry::MsWrdEntry
MsWrdEntry()
constructor
Definition: MsWrdParser.hxx:65
MsWrdParser::m_entryMap
std::multimap< std::string, MsWrdEntry > m_entryMap
the list of entries
Definition: MsWrdParser.hxx:201