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 
53 namespace MSWTextInternal
54 {
55 struct State;
56 struct Table;
57 }
58 
59 struct MSWEntry;
60 class MSWParser;
61 class MSWTextStyles;
62 
64 class MSWText
65 {
66  friend class MSWParser;
67  friend class MSWTextStyles;
68 public:
70  struct PLC {
72  PLC(Type type, int id=0) : m_type(type), m_id(id), m_extra("") {
73  }
75  friend std::ostream &operator<<(std::ostream &o, PLC const &plc);
77  struct ltstr {
78  bool operator()(PLC const &s1, PLC const &s2) const {
79  if (s1.m_type != s2.m_type)
80  return int(s1.m_type) < int(s2.m_type);
81  if (s1.m_id != s2.m_id)
82  return s1.m_id < s2.m_id;
83  return false;
84  }
85  };
89  int m_id;
91  std::string m_extra;
92  };
93 public:
95  MSWText(MSWParser &parser);
97  virtual ~MSWText();
98 
100  int version() const;
101 
103  int numPages() const;
104 
106  MWAWEntry getHeader() const;
107 
109  MWAWEntry getFooter() const;
110 protected:
112  shared_ptr<MWAWParserState> &getParserState() {
113  return m_parserState;
114  }
115 
117  bool sendMainText();
118 
120  bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false);
122  bool sendSection(int sectionId);
124  bool readHeaderTextLength();
125 
127  bool createZones(long bot);
128 
130  bool readTextStruct(MSWEntry &entry);
131 
133  bool readPageBreak(MSWEntry &entry);
134 
136  bool readParagraphInfo(MSWEntry entry);
137 
139  bool readFields(MSWEntry &entry, std::vector<long> const &fieldPos);
140 
142  bool sendFieldComment(int id);
143 
145  bool readFootnotesPos(MSWEntry &entry, std::vector<long> const &noteDef);
146 
148  bool readFootnotesData(MSWEntry &entry);
149 
151  bool sendFootnote(int id);
152 
154  bool readFontNames(MSWEntry &entry);
155 
157  void flushExtra();
158 
160  bool sendTable(MSWTextInternal::Table const &table);
161 
162  // interface with MSWTextStyles
163 
165  long getMainTextLength() const;
167  std::multimap<long, MSWText::PLC> &getTextPLCMap();
169  std::multimap<long, MSWText::PLC> &getFilePLCMap();
170 
171  //
172  // low level
173  //
174 
176  void prepareData();
177 
179  void prepareLines();
181  void convertFilePLCPos();
185  void prepareFontProperties();
186 
188  void prepareTableLimits();
190  bool updateTableBeginnningAt(long cPos, long &nextCPos);
191 
193  bool readLongZone(MSWEntry &entry, int sz, std::vector<long> &list);
194 
195 private:
196  MSWText(MSWText const &orig);
197  MSWText &operator=(MSWText const &orig);
198 
199 protected:
200  //
201  // data
202  //
205 
207  shared_ptr<MSWTextInternal::State> m_state;
208 
210  shared_ptr<MSWTextStyles> m_stylesManager;
211 
214 };
215 #endif
216 // 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:213
void convertFilePLCPos()
convert the file position in character position and compute the paragraph limit
Definition: MSWText.cxx:1208
a comparaison structure
Definition: MSWText.hxx:77
bool readFields(MSWEntry &entry, std::vector< long > const &fieldPos)
read the field data
Definition: MSWText.cxx:1043
Definition: MSWText.hxx:71
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:66
bool sendMainText()
send a main zone
Definition: MSWText.cxx:2065
bool readParagraphInfo(MSWEntry entry)
read the paragraph height info
Definition: MSWText.cxx:808
MWAWEntry getFooter() const
returns the footer entry
Definition: MSWText.cxx:428
shared_ptr< MSWTextInternal::State > m_state
the state
Definition: MSWText.hxx:207
Definition: MSWText.hxx:71
void prepareParagraphProperties()
retrieve the paragraph properties
Definition: MSWText.cxx:1326
bool operator()(PLC const &s1, PLC const &s2) const
Definition: MSWText.hxx:78
the main class to read a Microsoft Word file
Definition: MSWParser.hxx:88
Definition: MSWText.hxx:71
bool readTextStruct(MSWEntry &entry)
read the text structure(some paragraph style+some text position?)
Definition: MSWText.cxx:649
the entry of MSWParser
Definition: MSWParser.hxx:63
void prepareLines()
cut the text in line/cell pos
Definition: MSWText.cxx:1168
int m_id
the identificator
Definition: MSWText.hxx:89
Definition: MSWText.hxx:71
bool readFontNames(MSWEntry &entry)
read the font names
Definition: MSWText.cxx:747
bool readPageBreak(MSWEntry &entry)
read the page limit ?
Definition: MSWText.cxx:873
long getMainTextLength() const
returns the main text length
Definition: MSWText.cxx:400
bool updateTableBeginnningAt(long cPos, long &nextCPos)
try to find a table which begin at position cPos, if so, update its data...
Definition: MSWText.cxx:1605
void prepareTableLimits()
find the table end position knowing the end cell/pos delimiter
Definition: MSWText.cxx:1503
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:64
bool sendFieldComment(int id)
send a field note to a listener
Definition: MSWText.cxx:2092
bool readFootnotesData(MSWEntry &entry)
read the footnote data
Definition: MSWText.cxx:995
void prepareFontProperties()
retrieve the font properties
Definition: MSWText.cxx:1420
bool sendTable(MSWTextInternal::Table const &table)
try to send a table.
Definition: MSWText.cxx:2000
std::multimap< long, MSWText::PLC > & getFilePLCMap()
returns the file correspondance zone ( filepos, plc )
Definition: MSWText.cxx:456
Definition: MSWText.hxx:71
Internal and low level: a structure to store a table of a MSWText.
Definition: MSWText.cxx:256
int version() const
returns the file version
Definition: MSWText.cxx:387
bool readFootnotesPos(MSWEntry &entry, std::vector< long > const &noteDef)
read the footnote pos in text + val
Definition: MSWText.cxx:935
PLC(Type type, int id=0)
Definition: MSWText.hxx:72
void prepareData()
prepare the data to be send
Definition: MSWText.cxx:1628
std::string m_extra
some extra data
Definition: MSWText.hxx:91
MSWText(MSWParser &parser)
constructor
Definition: MSWText.cxx:377
bool readHeaderTextLength()
reads the three different zone size
Definition: MSWText.cxx:510
Definition: MSWText.hxx:71
friend std::ostream & operator<<(std::ostream &o, PLC const &plc)
operator&lt;&lt;
Definition: MSWText.cxx:465
int numPages() const
returns the number of pages
Definition: MSWText.cxx:394
bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false)
send a text zone
Definition: MSWText.cxx:1776
Type m_type
the plc type
Definition: MSWText.hxx:87
Definition: MSWText.hxx:71
bool readLongZone(MSWEntry &entry, int sz, std::vector< long > &list)
read a zone which consists in a list of int
Definition: MSWText.cxx:1131
bool sendFootnote(int id)
send a note to a listener
Definition: MSWText.cxx:2074
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: MSWText.cxx:2112
bool sendSection(int sectionId)
try to open a section
Definition: MSWText.cxx:1984
Internal: the plc.
Definition: MSWText.hxx:70
shared_ptr< MSWTextStyles > m_stylesManager
the style manager
Definition: MSWText.hxx:210
Type
Definition: MSWText.hxx:71
std::multimap< long, MSWText::PLC > & getTextPLCMap()
returns the text correspondance zone ( textpos, plc )
Definition: MSWText.cxx:451
Definition: MSWText.hxx:71
shared_ptr< MWAWParserState > & getParserState()
returns the parser state
Definition: MSWText.hxx:112
Definition: MSWText.hxx:71
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:356
bool createZones(long bot)
finds the different zones
Definition: MSWText.cxx:537
Definition: MSWText.hxx:71
Definition: MSWText.hxx:71
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:405
MWAWParserStatePtr m_parserState
the parser state
Definition: MSWText.hxx:204
virtual ~MSWText()
destructor
Definition: MSWText.cxx:384

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