MsWrdText.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 MS_WRD_MWAW_TEXT
39 # define MS_WRD_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 "MsWrdTextStyles.hxx"
52 
53 namespace MsWrdTextInternal
54 {
55 struct State;
56 struct Table;
57 }
58 
59 struct MsWrdEntry;
60 class MsWrdParser;
61 class MsWrdTextStyles;
62 
64 class MsWrdText
65 {
66  friend class MsWrdParser;
67  friend class MsWrdTextStyles;
68 public:
70  struct PLC {
72  PLC(Type type, int id=0) : m_type(type), m_id(id), m_extra("")
73  {
74  }
76  friend std::ostream &operator<<(std::ostream &o, PLC const &plc);
78  struct ltstr {
79  bool operator()(PLC const &s1, PLC const &s2) const
80  {
81  if (s1.m_type != s2.m_type)
82  return int(s1.m_type) < int(s2.m_type);
83  if (s1.m_id != s2.m_id)
84  return s1.m_id < s2.m_id;
85  return false;
86  }
87  };
91  int m_id;
93  std::string m_extra;
94  };
95 public:
97  MsWrdText(MsWrdParser &parser);
99  virtual ~MsWrdText();
100 
102  int version() const;
103 
105  int numPages() const;
106 
108  MWAWEntry getHeader() const;
109 
111  MWAWEntry getFooter() const;
112 protected:
114  shared_ptr<MWAWParserState> &getParserState()
115  {
116  return m_parserState;
117  }
118 
120  bool sendMainText();
121 
123  bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false);
125  bool sendSection(int sectionId);
127  bool readHeaderTextLength();
128 
130  bool createZones(long bot);
131 
133  bool readTextStruct(MsWrdEntry &entry);
134 
136  bool readPageBreak(MsWrdEntry &entry);
137 
139  bool readParagraphInfo(MsWrdEntry entry);
140 
142  bool readFields(MsWrdEntry &entry, std::vector<long> const &fieldPos);
143 
145  bool sendFieldComment(int id);
146 
148  bool readFootnotesPos(MsWrdEntry &entry, std::vector<long> const &noteDef);
149 
151  bool readFootnotesData(MsWrdEntry &entry);
152 
154  bool sendFootnote(int id);
155 
157  bool readFontNames(MsWrdEntry &entry);
158 
160  void flushExtra();
161 
163  bool sendTable(MsWrdTextInternal::Table const &table);
164 
165  // interface with MsWrdTextStyles
166 
168  long getMainTextLength() const;
170  std::multimap<long, MsWrdText::PLC> &getTextPLCMap();
172  std::multimap<long, MsWrdText::PLC> &getFilePLCMap();
173 
174  //
175  // low level
176  //
177 
179  void prepareData();
180 
182  void prepareLines();
184  void convertFilePLCPos();
188  void prepareFontProperties();
189 
191  void prepareTableLimits();
193  bool updateTableBeginnningAt(long cPos, long &nextCPos);
194 
196  bool readLongZone(MsWrdEntry &entry, int sz, std::vector<long> &list);
197 
198 private:
199  MsWrdText(MsWrdText const &orig);
200  MsWrdText &operator=(MsWrdText const &orig);
201 
202 protected:
203  //
204  // data
205  //
208 
210  shared_ptr<MsWrdTextInternal::State> m_state;
211 
213  shared_ptr<MsWrdTextStyles> m_stylesManager;
214 
217 };
218 #endif
219 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool readTextStruct(MsWrdEntry &entry)
read the text structure(some paragraph style+some text position?)
Definition: MsWrdText.cxx:664
std::string m_extra
some extra data
Definition: MsWrdText.hxx:93
Definition: MsWrdText.hxx:71
void prepareLines()
cut the text in line/cell pos
Definition: MsWrdText.cxx:1193
bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false)
send a text zone
Definition: MsWrdText.cxx:1811
Definition: MsWrdText.hxx:71
MWAWEntry getFooter() const
returns the footer entry
Definition: MsWrdText.cxx:443
shared_ptr< MWAWParserState > & getParserState()
returns the parser state
Definition: MsWrdText.hxx:114
void prepareFontProperties()
retrieve the font properties
Definition: MsWrdText.cxx:1449
Definition: MsWrdText.hxx:71
bool sendSection(int sectionId)
try to open a section
Definition: MsWrdText.cxx:2019
std::multimap< long, MsWrdText::PLC > & getTextPLCMap()
returns the text correspondance zone ( textpos, plc )
Definition: MsWrdText.cxx:466
bool sendFootnote(int id)
send a note to a listener
Definition: MsWrdText.cxx:2110
Definition: MsWrdText.hxx:71
the entry of MsWrdParser
Definition: MsWrdParser.hxx:63
bool sendFieldComment(int id)
send a field note to a listener
Definition: MsWrdText.cxx:2128
bool readParagraphInfo(MsWrdEntry entry)
read the paragraph height info
Definition: MsWrdText.cxx:825
bool readHeaderTextLength()
reads the three different zone size
Definition: MsWrdText.cxx:525
Definition: MsWrdText.hxx:71
void prepareParagraphProperties()
retrieve the paragraph properties
Definition: MsWrdText.cxx:1354
bool readFields(MsWrdEntry &entry, std::vector< long > const &fieldPos)
read the field data
Definition: MsWrdText.cxx:1064
bool readLongZone(MsWrdEntry &entry, int sz, std::vector< long > &list)
read a zone which consists in a list of int
Definition: MsWrdText.cxx:1156
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: MsWrdText.cxx:2148
void convertFilePLCPos()
convert the file position in character position and compute the paragraph limit
Definition: MsWrdText.cxx:1233
Internal: the plc.
Definition: MsWrdText.hxx:70
Definition: MsWrdText.hxx:71
int version() const
returns the file version
Definition: MsWrdText.cxx:402
Definition: MsWrdText.hxx:71
bool sendTable(MsWrdTextInternal::Table const &table)
try to send a table.
Definition: MsWrdText.cxx:2035
MsWrdText & operator=(MsWrdText const &orig)
Definition: MsWrdText.hxx:71
Internal and low level: a structure to store a table of a MsWrdText.
Definition: MsWrdText.cxx:265
Type
Definition: MsWrdText.hxx:71
bool createZones(long bot)
finds the different zones
Definition: MsWrdText.cxx:552
Definition: MsWrdText.hxx:71
shared_ptr< MsWrdTextInternal::State > m_state
the state
Definition: MsWrdText.hxx:210
bool readFootnotesData(MsWrdEntry &entry)
read the footnote data
Definition: MsWrdText.cxx:1016
int m_id
the identificator
Definition: MsWrdText.hxx:91
MWAWParserStatePtr m_parserState
the parser state
Definition: MsWrdText.hxx:207
std::multimap< long, MsWrdText::PLC > & getFilePLCMap()
returns the file correspondance zone ( filepos, plc )
Definition: MsWrdText.cxx:471
void prepareData()
prepare the data to be send
Definition: MsWrdText.cxx:1658
virtual ~MsWrdText()
destructor
Definition: MsWrdText.cxx:399
bool operator()(PLC const &s1, PLC const &s2) const
Definition: MsWrdText.hxx:79
MWAWEntry getHeader() const
returns the header entry
Definition: MsWrdText.cxx:420
bool readFootnotesPos(MsWrdEntry &entry, std::vector< long > const &noteDef)
read the footnote pos in text + val
Definition: MsWrdText.cxx:954
MsWrdText(MsWrdParser &parser)
constructor
Definition: MsWrdText.cxx:392
the main class to read a Microsoft Word file
Definition: MsWrdParser.hxx:91
long getMainTextLength() const
returns the main text length
Definition: MsWrdText.cxx:415
Type m_type
the plc type
Definition: MsWrdText.hxx:89
bool sendMainText()
send a main zone
Definition: MsWrdText.cxx:2101
Definition: MsWrdText.hxx:71
void prepareTableLimits()
find the table end position knowing the end cell/pos delimiter
Definition: MsWrdText.cxx:1533
Internal: the structures of a MsWrdText.
Definition: MsWrdText.cxx:69
Definition: MsWrdText.hxx:71
the main class to read the text part of Microsoft Word file
Definition: MsWrdText.hxx:64
the main class to read/store the text font, paragraph, section stylesread
Definition: MsWrdTextStyles.hxx:66
MsWrdParser * m_mainParser
the main parser;
Definition: MsWrdText.hxx:216
a comparaison structure
Definition: MsWrdText.hxx:78
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:445
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
int numPages() const
returns the number of pages
Definition: MsWrdText.cxx:409
friend std::ostream & operator<<(std::ostream &o, PLC const &plc)
operator<<
Definition: MsWrdText.cxx:480
bool readFontNames(MsWrdEntry &entry)
read the font names
Definition: MsWrdText.cxx:764
bool updateTableBeginnningAt(long cPos, long &nextCPos)
try to find a table which begin at position cPos, if so, update its data...
Definition: MsWrdText.cxx:1635
shared_ptr< MsWrdTextStyles > m_stylesManager
the style manager
Definition: MsWrdText.hxx:213
PLC(Type type, int id=0)
Definition: MsWrdText.hxx:72
bool readPageBreak(MsWrdEntry &entry)
read the page limit ?
Definition: MsWrdText.cxx:891

Generated on Thu Jul 9 2015 20:26:36 for libmwaw by doxygen 1.8.8