MSWParser.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 MSW_MWAW_PARSER
38 # define MSW_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 MSWParserInternal
53 {
54 struct Object;
55 struct State;
56 class SubDocument;
57 }
58 
59 class MSWText;
60 class MSWTextStyles;
61 
63 struct MSWEntry : public MWAWEntry {
65  }
70  int pictType() const {
71  return m_pictType;
72  }
74  void setPictType(int newId) {
75  m_pictType = newId;
76  }
78  friend std::ostream &operator<<(std::ostream &o, MSWEntry const &entry);
81 };
82 
88 class MSWParser : public MWAWParser
89 {
90  friend class MSWText;
91  friend class MSWTextStyles;
93 
94 public:
96  MSWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
98  virtual ~MSWParser();
99 
101  bool checkHeader(MWAWHeader *header, bool strict=false);
102 
104  void parse(WPXDocumentInterface *documentInterface);
105 
106 protected:
108  void init();
109 
111  void createDocument(WPXDocumentInterface *documentInterface);
112 
114  bool createZones();
115 
117  bool readHeaderEndV3();
118 
120  bool readZoneList();
121 
123  bool readPrintInfo(MSWEntry &entry);
124 
126  bool readPrinter(MSWEntry &entry);
127 
129  bool readDocSum(MSWEntry &entry);
130 
132  bool readStringsZone(MSWEntry &entry, std::vector<std::string> &list);
133 
135  bool readObjects();
136 
138  bool readObjectList(MSWEntry &entry);
139 
141  bool readObjectFlags(MSWEntry &entry);
142 
145 
147  bool readDocumentInfo(MSWEntry &entry);
148 
150  bool readZone17(MSWEntry &entry);
151 
153  bool checkPicturePos(long pos, int type);
154 
156  bool readPicture(MSWEntry &entry);
158  void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char);
159 
161  bool getColor(int id, MWAWColor &col) const;
162 
164  void newPage(int number);
165 
166  /*
167  * interface with subdocument
168  */
170  void sendFootnote(int id);
171 
173  void sendFieldComment(int id);
174 
176  void send(int id, libmwaw::SubDocumentType type);
178  void send(MWAWEntry const &entry);
179 
180  //
181  // low level
182  //
183 
185  MSWEntry readEntry(std::string type, int id=-1);
186 
187 protected:
188  //
189  // data
190  //
192  shared_ptr<MSWParserInternal::State> m_state;
193 
195  std::multimap<std::string, MSWEntry> m_entryMap;
196 
198  shared_ptr<MSWText> m_textParser;
199 };
200 #endif
201 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void send(int id, libmwaw::SubDocumentType type)
try to send a footnote, a field to the textParser
Definition: MSWParser.cxx:379
MSWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: MSWParser.cxx:284
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
bool readZone17(MSWEntry &entry)
read the zone 17( some bdbox + text position ?)
Definition: MSWParser.cxx:1061
shared_ptr< MSWText > m_textParser
the text parser
Definition: MSWParser.hxx:198
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:66
Definition: MWAWPosition.hxx:51
bool readDocSum(MSWEntry &entry)
read the document sumary
Definition: MSWParser.cxx:1185
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: MSWParser.cxx:671
bool readObjects()
read the objects
Definition: MSWParser.cxx:1297
int pictType() const
returns the text id
Definition: MSWParser.hxx:70
the main class to read a Microsoft Word file
Definition: MSWParser.hxx:88
the entry of MSWParser
Definition: MSWParser.hxx:63
SubDocumentType
Definition: libmwaw_internal.hxx:162
bool readObjectFlags(MSWEntry &entry)
read the object flags
Definition: MSWParser.cxx:1420
bool readPrinter(MSWEntry &entry)
read the printer name
Definition: MSWParser.cxx:1138
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:64
bool readStringsZone(MSWEntry &entry, std::vector< std::string > &list)
read a zone which consists in a list of string
Definition: MSWParser.cxx:1240
MSWEntry()
Definition: MSWParser.hxx:64
friend std::ostream & operator<<(std::ostream &o, MSWEntry const &entry)
operator&lt;&lt;
Definition: MSWParser.cxx:271
the class to store a color
Definition: libmwaw_internal.hxx:166
bool readObjectList(MSWEntry &entry)
read the object list
Definition: MSWParser.cxx:1347
Internal: the object of MSWParser.
Definition: MSWParser.cxx:61
void sendFieldComment(int id)
try to send a bookmark field id
Definition: MSWParser.cxx:366
bool readHeaderEndV3()
finish reading the header (v3)
Definition: MSWParser.cxx:811
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MSWParser.cxx:429
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:354
AnchorTo
a list of enum used to defined the anchor
Definition: MWAWPosition.hxx:51
bool createZones()
finds the different zones
Definition: MSWParser.cxx:479
void newPage(int number)
adds a new page
Definition: MSWParser.cxx:310
MSWEntry readEntry(std::string type, int id=-1)
read a file entry
Definition: MSWParser.cxx:950
bool getColor(int id, MWAWColor &col) const
returns the color corresponding to an id
Definition: MSWParser.cxx:323
shared_ptr< MSWParserInternal::State > m_state
the state
Definition: MSWParser.hxx:192
bool readPrintInfo(MSWEntry &entry)
read the print info zone
Definition: MSWParser.cxx:1824
void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char)
send a picture
Definition: MSWParser.cxx:1763
bool readPicture(MSWEntry &entry)
read a picture data
Definition: MSWParser.cxx:1684
bool readObject(MSWParserInternal::Object &obj)
read an object
Definition: MSWParser.cxx:1477
void init()
inits all internal variables
Definition: MSWParser.cxx:294
virtual ~MSWParser()
destructor
Definition: MSWParser.cxx:290
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:348
bool checkPicturePos(long pos, int type)
check if a position corresponds or not to a picture entry
Definition: MSWParser.cxx:1649
std::multimap< std::string, MSWEntry > m_entryMap
the list of entries
Definition: MSWParser.hxx:195
void parse(WPXDocumentInterface *documentInterface)
the main parse function
Definition: MSWParser.cxx:393
void sendFootnote(int id)
try to send a footnote id
Definition: MSWParser.cxx:357
bool readDocumentInfo(MSWEntry &entry)
read the page dimensions + ?
Definition: MSWParser.cxx:991
bool readZoneList()
read the list of zones
Definition: MSWParser.cxx:541
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:89
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
void setPictType(int newId)
sets the picture id
Definition: MSWParser.hxx:74
int m_pictType
the picture identificator
Definition: MSWParser.hxx:80
Internal: the subdocument of a MSWParser.
Definition: MSWParser.cxx:200

Generated on Tue Mar 10 2015 17:32:08 for libmwaw by doxygen 1.8.5