MSWText.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 to Microsoft Word text document
36  *
37  */
38 #ifndef MSW_MWAW_TEXT
39 # define MSW_MWAW_TEXT
40 
41 #include <map>
42 #include <string>
43 #include <vector>
44 
45 #include "libmwaw_internal.hxx"
46 
47 #include "MWAWEntry.hxx"
48 
49 #include "MWAWDebug.hxx"
50 
51 #include "MSWTextStyles.hxx"
52 
54 typedef shared_ptr<MWAWParserState> MWAWParserStatePtr;
55 
56 namespace MSWTextInternal
57 {
58 struct Property;
59 struct State;
60 }
61 
62 struct MSWEntry;
63 class MSWParser;
64 class MSWTextStyles;
65 
67 class MSWText
68 {
69  friend class MSWParser;
70  friend class MSWTextStyles;
71 public:
73  struct PLC {
75  PLC(Type type, int id=0) : m_type(type), m_id(id), m_extra("") {
76  }
78  friend std::ostream &operator<<(std::ostream &o, PLC const &plc);
80  struct ltstr {
81  bool operator()(PLC const &s1, PLC const &s2) const {
82  if (s1.m_type != s2.m_type)
83  return int(s1.m_type) < int(s2.m_type);
84  if (s1.m_id != s2.m_id)
85  return s1.m_id < s2.m_id;
86  return false;
87  }
88  };
92  int m_id;
94  std::string m_extra;
95  };
96 public:
98  MSWText(MSWParser &parser);
100  virtual ~MSWText();
101 
103  int version() const;
104 
106  int numPages() const;
107 
109  MWAWEntry getHeader() const;
110 
112  MWAWEntry getFooter() const;
113 protected:
115  shared_ptr<MWAWParserState> &getParserState() {
116  return m_parserState;
117  }
118 
120  bool sendMainText();
121 
123  bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false);
124 
126  bool readHeaderTextLength();
127 
129  bool createZones(long bot);
130 
132  bool readTextStruct(MSWEntry &entry);
133 
135  bool readPageBreak(MSWEntry &entry);
136 
138  bool readParagraphInfo(MSWEntry entry);
139 
141  bool readFields(MSWEntry &entry, std::vector<long> const &fieldPos);
142 
144  bool sendFieldComment(int id);
145 
147  bool readFootnotesPos(MSWEntry &entry, std::vector<long> const &noteDef);
148 
150  bool readFootnotesData(MSWEntry &entry);
151 
153  bool sendFootnote(int id);
154 
156  bool readFontNames(MSWEntry &entry);
157 
159  void flushExtra();
160 
162  bool sendTable(MSWTextInternal::Property const &prop);
163 
164  // interface with MSWTextStyles
165 
167  long getMainTextLength() const;
169  std::multimap<long, MSWText::PLC> &getTextPLCMap();
171  std::multimap<long, MSWText::PLC> &getFilePLCMap();
172 
173  //
174  // low level
175  //
176 
178  void prepareData();
179 
181  void prepareTables();
182 
184  bool readLongZone(MSWEntry &entry, int sz, std::vector<long> &list);
185 
186 private:
187  MSWText(MSWText const &orig);
188  MSWText &operator=(MSWText const &orig);
189 
190 protected:
191  //
192  // data
193  //
196 
198  shared_ptr<MSWTextInternal::State> m_state;
199 
201  shared_ptr<MSWTextStyles> m_stylesManager;
202 
205 };
206 #endif
207 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Tue Apr 30 2013 06:31:12 for libmwaw by doxygen 1.8.3.1