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();
180  bool findParaPosAndStyles(std::map<long, int> &posStyleMap);
181 
183  void prepareTables();
184 
186  bool readLongZone(MSWEntry &entry, int sz, std::vector<long> &list);
187 
188 private:
189  MSWText(MSWText const &orig);
190  MSWText &operator=(MSWText const &orig);
191 
192 protected:
193  //
194  // data
195  //
198 
200  shared_ptr<MSWTextInternal::State> m_state;
201 
203  shared_ptr<MSWTextStyles> m_stylesManager;
204 
207 };
208 #endif
209 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MSWText & operator=(MSWText const &orig)
MSWParser * m_mainParser
the main parser;
Definition: MSWText.hxx:206
a comparaison structure
Definition: MSWText.hxx:80
bool readFields(MSWEntry &entry, std::vector< long > const &fieldPos)
read the field data
Definition: MSWText.cxx:932
Definition: MSWText.hxx:74
shared_ptr< MWAWParserState > MWAWParserStatePtr
Definition: ACText.hxx:49
bool sendTable(MSWTextInternal::Property const &prop)
try to send a table.
Definition: MSWText.cxx:1723
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:69
bool sendMainText()
send a main zone
Definition: MSWText.cxx:1805
bool readParagraphInfo(MSWEntry entry)
read the paragraph height info
Definition: MSWText.cxx:705
MWAWEntry getFooter() const
returns the footer entry
Definition: MSWText.cxx:347
shared_ptr< MSWTextInternal::State > m_state
the state
Definition: MSWText.hxx:200
Definition: MSWText.hxx:74
bool operator()(PLC const &s1, PLC const &s2) const
Definition: MSWText.hxx:81
the main class to read a Microsoft Word file
Definition: MSWParser.hxx:88
Definition: MSWText.hxx:74
void prepareTables()
prepare the table to be send
Definition: MSWText.cxx:1444
bool readTextStruct(MSWEntry &entry)
read the text structure(some paragraph style+some text position?)
Definition: MSWText.cxx:551
the entry of MSWParser
Definition: MSWParser.hxx:63
Internal: a list of plc.
Definition: MSWText.cxx:215
int m_id
the identificator
Definition: MSWText.hxx:92
Definition: MSWText.hxx:74
bool readFontNames(MSWEntry &entry)
read the font names
Definition: MSWText.cxx:644
bool readPageBreak(MSWEntry &entry)
read the page limit ?
Definition: MSWText.cxx:770
long getMainTextLength() const
returns the main text length
Definition: MSWText.cxx:335
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:67
bool sendFieldComment(int id)
send a field note to a listener
Definition: MSWText.cxx:1832
bool readFootnotesData(MSWEntry &entry)
read the footnote data
Definition: MSWText.cxx:884
std::multimap< long, MSWText::PLC > & getFilePLCMap()
returns the file correspondance zone ( filepos, plc )
Definition: MSWText.cxx:359
Definition: MSWText.hxx:74
int version() const
returns the file version
Definition: MSWText.cxx:322
bool readFootnotesPos(MSWEntry &entry, std::vector< long > const &noteDef)
read the footnote pos in text + val
Definition: MSWText.cxx:824
PLC(Type type, int id=0)
Definition: MSWText.hxx:75
void prepareData()
prepare the data to be send
Definition: MSWText.cxx:1129
std::string m_extra
some extra data
Definition: MSWText.hxx:94
MSWText(MSWParser &parser)
constructor
Definition: MSWText.cxx:312
bool readHeaderTextLength()
reads the three different zone size
Definition: MSWText.cxx:413
Definition: MSWText.hxx:74
a class to define the parser state
Definition: MWAWParser.hxx:60
friend std::ostream & operator<<(std::ostream &o, PLC const &plc)
operator&lt;&lt;
Definition: MSWText.cxx:368
int numPages() const
returns the number of pages
Definition: MSWText.cxx:329
bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false)
send a text zone
Definition: MSWText.cxx:1513
Type m_type
the plc type
Definition: MSWText.hxx:90
Definition: MSWText.hxx:74
bool readLongZone(MSWEntry &entry, int sz, std::vector< long > &list)
read a zone which consists in a list of int
Definition: MSWText.cxx:1020
bool sendFootnote(int id)
send a note to a listener
Definition: MSWText.cxx:1814
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: MSWText.cxx:1852
Internal: the plc.
Definition: MSWText.hxx:73
shared_ptr< MSWTextStyles > m_stylesManager
the style manager
Definition: MSWText.hxx:203
Type
Definition: MSWText.hxx:74
std::multimap< long, MSWText::PLC > & getTextPLCMap()
returns the text correspondance zone ( textpos, plc )
Definition: MSWText.cxx:354
Definition: MSWText.hxx:74
shared_ptr< MWAWParserState > & getParserState()
returns the parser state
Definition: MSWText.hxx:115
Definition: MSWText.hxx:74
bool createZones(long bot)
finds the different zones
Definition: MSWText.cxx:440
Definition: MSWText.hxx:74
Definition: MSWText.hxx:74
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWEntry getHeader() const
returns the header entry
Definition: MSWText.cxx:340
MWAWParserStatePtr m_parserState
the parser state
Definition: MSWText.hxx:197
virtual ~MSWText()
destructor
Definition: MSWText.cxx:319
bool findParaPosAndStyles(std::map< long, int > &posStyleMap)
update the list of beginning cPos of each paragraph, cell, and each id...
Definition: MSWText.cxx:1057

Generated for libmwaw by doxygen 1.8.5