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 {
66  : MWAWEntry()
67  , m_pictType(-1)
68  {
69  }
70  MsWrdEntry(MsWrdEntry const &)=default;
72  ~MsWrdEntry() final;
77  int pictType() const
78  {
79  return m_pictType;
80  }
82  void setPictType(int newId)
83  {
84  m_pictType = newId;
85  }
87  friend std::ostream &operator<<(std::ostream &o, MsWrdEntry const &entry);
90 };
91 
97 class MsWrdParser final : public MWAWTextParser
98 {
99  friend class MsWrdText;
100  friend class MsWrdTextStyles;
102 
103 public:
105  MsWrdParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
107  ~MsWrdParser() final;
108 
110  bool checkHeader(MWAWHeader *header, bool strict=false) final;
111 
113  void parse(librevenge::RVNGTextInterface *documentInterface) final;
114 
115 protected:
117  void init();
118 
120  void createDocument(librevenge::RVNGTextInterface *documentInterface);
121 
123  bool createZones();
124 
126  bool readHeaderEndV3();
127 
129  bool readZoneList();
130 
132  bool readPrintInfo(MsWrdEntry &entry);
133 
135  bool readPrinter(MsWrdEntry &entry);
136 
138  bool readDocSum(MsWrdEntry &entry);
139 
141  bool readStringsZone(MsWrdEntry &entry, std::vector<std::string> &list);
142 
144  bool readObjects();
145 
147  bool readObjectList(MsWrdEntry &entry);
148 
150  bool readObjectFlags(MsWrdEntry &entry);
151 
153  bool readObject(MsWrdParserInternal::Object &obj);
154 
156  bool readDocumentInfo(MsWrdEntry &entry);
157 
159  bool readZone17(MsWrdEntry &entry);
160 
162  bool checkPicturePos(long pos, int type);
163 
165  bool readPicture(MsWrdEntry &entry);
167  void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char);
168 
170  bool getColor(int id, MWAWColor &col) const;
171 
173  void newPage(int number);
174 
175  /*
176  * interface with subdocument
177  */
179  void sendFootnote(int id);
180 
182  void sendFieldComment(int id);
183 
185  void send(int id, libmwaw::SubDocumentType type);
187  void send(MWAWEntry const &entry);
189  void sendSimpleTextZone(MWAWListenerPtr &listener, MWAWEntry const &entry);
190 
191  //
192  // low level
193  //
194 
196  MsWrdEntry readEntry(std::string type, int id=-1);
197 
198 protected:
199  //
200  // data
201  //
203  std::shared_ptr<MsWrdParserInternal::State> m_state;
204 
206  std::multimap<std::string, MsWrdEntry> m_entryMap;
207 
209  std::shared_ptr<MsWrdText> m_textParser;
210 };
211 #endif
212 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool readHeaderEndV3()
finish reading the header (v3)
Definition: MsWrdParser.cxx:898
~MsWrdEntry() final
destructor
Definition: MsWrdParser.cxx:321
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
bool readPicture(MsWrdEntry &entry)
read a picture data
Definition: MsWrdParser.cxx:1795
Definition: MWAWDocument.hxx:56
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MsWrdParser.cxx:514
int pictType() const
returns the text id
Definition: MsWrdParser.hxx:77
bool readZone17(MsWrdEntry &entry)
read the zone 17( some bdbox + text position ?)
Definition: MsWrdParser.cxx:1151
the entry of MsWrdParser
Definition: MsWrdParser.hxx:63
SubDocumentType
Definition: libmwaw_internal.hxx:188
MsWrdParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: MsWrdParser.cxx:338
void setPictType(int newId)
sets the picture id
Definition: MsWrdParser.hxx:82
bool readDocSum(MsWrdEntry &entry)
read the document sumary
Definition: MsWrdParser.cxx:1275
void sendFootnote(int id)
try to send a footnote id
Definition: MsWrdParser.cxx:443
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:50
the class to store a color
Definition: libmwaw_internal.hxx:192
bool readObjectFlags(MsWrdEntry &entry)
read the object flags
Definition: MsWrdParser.cxx:1527
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
std::shared_ptr< MsWrdText > m_textParser
the text parser
Definition: MsWrdParser.hxx:209
bool readZoneList()
read the list of zones
Definition: MsWrdParser.cxx:627
MsWrdEntry readEntry(std::string type, int id=-1)
read a file entry
Definition: MsWrdParser.cxx:1039
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:298
~MsWrdParser() final
destructor
Definition: MsWrdParser.cxx:347
void send(int id, libmwaw::SubDocumentType type)
try to send a footnote, a field to the textParser
Definition: MsWrdParser.cxx:465
void sendSimpleTextZone(MWAWListenerPtr &listener, MWAWEntry const &entry)
try to send a simple text zone(ie. a comment)
Definition: MsWrdParser.cxx:414
the main class to read a Microsoft Word file
Definition: MsWrdParser.hxx:97
bool readPrinter(MsWrdEntry &entry)
read the printer name
Definition: MsWrdParser.cxx:1228
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
bool readObjects()
read the objects
Definition: MsWrdParser.cxx:1403
std::shared_ptr< MsWrdParserInternal::State > m_state
the state
Definition: MsWrdParser.hxx:203
Internal: the subdocument of a MsWrdParser.
Definition: MsWrdParser.cxx:230
the main class to read the text part of Microsoft Word file
Definition: MsWrdText.hxx:64
int m_pictType
the picture identificator
Definition: MsWrdParser.hxx:89
bool checkPicturePos(long pos, int type)
check if a position corresponds or not to a picture entry
Definition: MsWrdParser.cxx:1760
the main class to read/store the text font, paragraph, section stylesread
Definition: MsWrdTextStyles.hxx:66
Internal: the structures of a MsWrdParser.
Definition: MsWrdParser.cxx:58
bool getColor(int id, MWAWColor &col) const
returns the color corresponding to an id
Definition: MsWrdParser.cxx:380
bool readPrintInfo(MsWrdEntry &entry)
read the print info zone
Definition: MsWrdParser.cxx:1939
bool createZones()
finds the different zones
Definition: MsWrdParser.cxx:566
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: MsWrdParser.cxx:757
bool readObject(MsWrdParserInternal::Object &obj)
read an object
Definition: MsWrdParser.cxx:1584
void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char)
send a picture
Definition: MsWrdParser.cxx:1871
void init()
inits all internal variables
Definition: MsWrdParser.cxx:351
void parse(librevenge::RVNGTextInterface *documentInterface) final
the main parse function
Definition: MsWrdParser.cxx:479
void newPage(int number)
adds a new page
Definition: MsWrdParser.cxx:367
friend std::ostream & operator<<(std::ostream &o, MsWrdEntry const &entry)
operator<<
Definition: MsWrdParser.cxx:325
bool readDocumentInfo(MsWrdEntry &entry)
read the page dimensions + ?
Definition: MsWrdParser.cxx:1080
bool readObjectList(MsWrdEntry &entry)
read the object list
Definition: MsWrdParser.cxx:1454
MsWrdEntry()
constructor
Definition: MsWrdParser.hxx:65
void sendFieldComment(int id)
try to send a bookmark field id
Definition: MsWrdParser.cxx:452
bool readStringsZone(MsWrdEntry &entry, std::vector< std::string > &list)
read a zone which consists in a list of string
Definition: MsWrdParser.cxx:1346
std::multimap< std::string, MsWrdEntry > m_entryMap
the list of entries
Definition: MsWrdParser.hxx:206

Generated for libmwaw by doxygen 1.8.14