WPParser.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 convert some WriterPlus text document ( a french text editor )
36  *
37  */
38 #ifndef WP_PARSER
39 # define WP_PARSER
40 
41 #include <list>
42 #include <string>
43 #include <vector>
44 
45 #include "MWAWDebug.hxx"
46 #include "MWAWEntry.hxx"
47 #include "MWAWInputStream.hxx"
48 
49 #include "MWAWParser.hxx"
50 
51 namespace WPParserInternal
52 {
53 struct State;
54 struct Font;
55 struct Line;
56 struct ParagraphData;
57 struct ParagraphInfo;
58 class SubDocument;
59 }
60 
66 class WPParser : public MWAWParser
67 {
69 
70 public:
72  WPParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
74  virtual ~WPParser();
75 
77  bool checkHeader(MWAWHeader *header, bool strict=false);
78 
79  // the main parse function
80  void parse(WPXDocumentInterface *documentInterface);
81 
82 protected:
84  void init();
85 
87  void createDocument(WPXDocumentInterface *documentInterface);
88 
90  bool createZones();
91 
93  bool readPrintInfo();
94 
96  bool readWindowsInfo(int zone);
97 
99  bool sendWindow(int zone, Vec2i limits = Vec2i(-1,-1));
100 
102  bool readWindowsZone(int zone);
103 
105  bool readPageInfo(int zone);
106 
108  bool readColInfo(int zone);
109 
111  bool readParagraphInfo(int zone);
112 
114  bool findSection(int zone, Vec2i limits, MWAWSection &sec);
115 
117  bool readSection(WPParserInternal::ParagraphInfo const &info, bool mainBlock);
118 
120  bool readText(WPParserInternal::ParagraphInfo const &info);
121 
123  bool readTable(WPParserInternal::ParagraphInfo const &info);
124 
127 
130 
132  double getTextHeight() const;
133 
135  void newPage(int number);
136 
137  //
138  // low level
139  //
140 
142  bool readParagraphData(WPParserInternal::ParagraphInfo const &info, bool hasFonts,
147  bool readFonts(int nFonts, int type,
148  std::vector<WPParserInternal::Font> &fonts);
149 
152  int nLines, std::vector<WPParserInternal::Line> &lines);
153 
154 protected:
155  //
156  // data
157  //
158 
160  shared_ptr<WPParserInternal::State> m_state;
161 };
162 #endif
163 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
shared_ptr< WPParserInternal::State > m_state
the state
Definition: WPParser.hxx:160
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
bool readColInfo(int zone)
read the col info zone ?
Definition: WPParser.cxx:1310
bool readFonts(int nFonts, int type, std::vector< WPParserInternal::Font > &fonts)
reads a list of font (with position)
Definition: WPParser.cxx:1790
bool createZones()
finds the different objects zones
Definition: WPParser.cxx:703
Paragraph informations.
Definition: WPParser.cxx:125
virtual ~WPParser()
destructor
Definition: WPParser.cxx:590
MWAWParagraph getParagraph(WPParserInternal::ParagraphData const &data)
returns a paragraph corresponding to a paragraph data
Definition: WPParser.cxx:1229
bool readPrintInfo()
read the print info zone
Definition: WPParser.cxx:1891
the main class to read a Writerperfect file
Definition: WPParser.hxx:66
Vec2< int > Vec2i
Vec2 of int.
Definition: libmwaw_internal.hxx:592
bool readGraphic(WPParserInternal::ParagraphInfo const &info)
read a graphic
Definition: WPParser.cxx:1550
bool readWindowsInfo(int zone)
read the main info for zone ( 0: MAIN ZONE, 1 : HEADER, 2 : FOOTER )
Definition: WPParser.cxx:770
WPParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: WPParser.cxx:584
bool readUnknown(WPParserInternal::ParagraphInfo const &info)
read a unknown section
Definition: WPParser.cxx:1672
bool readWindowsZone(int zone)
read the page info zone
Definition: WPParser.cxx:896
void newPage(int number)
adds a new page
Definition: WPParser.cxx:616
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:354
Internal: the subdocument of a MWParser.
Definition: WPParser.cxx:522
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: WPParser.cxx:738
bool readTable(WPParserInternal::ParagraphInfo const &info)
read a table
Definition: WPParser.cxx:1481
a class which stores section properties
Definition: MWAWSection.hxx:45
double getTextHeight() const
returns the page height, ie. paper size less margin (in inches) and header/footer ...
Definition: WPParser.cxx:608
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:348
bool findSection(int zone, Vec2i limits, MWAWSection &sec)
try to find the data which correspond to a section ( mainly column )
Definition: WPParser.cxx:1123
bool sendWindow(int zone, Vec2i limits=Vec2i(-1,-1))
send a zone ( 0: MAIN ZONE, 1 : HEADER, 2 : FOOTER )
Definition: WPParser.cxx:987
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
bool readParagraphInfo(int zone)
read the paragraph info zone
Definition: WPParser.cxx:1247
bool readText(WPParserInternal::ParagraphInfo const &info)
read a text
Definition: WPParser.cxx:1345
bool readParagraphData(WPParserInternal::ParagraphInfo const &info, bool hasFonts, WPParserInternal::ParagraphData &data)
reads a paragraph data
Definition: WPParser.cxx:1713
bool readLines(WPParserInternal::ParagraphInfo const &info, int nLines, std::vector< WPParserInternal::Line > &lines)
reads a list of line (with position)
Definition: WPParser.cxx:1860
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:89
Internal: class to store the beginning of all paragraph data.
Definition: WPParser.cxx:438
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: WPParser.cxx:634
bool readPageInfo(int zone)
read the page info zone
Definition: WPParser.cxx:1179
void init()
inits all internal variables
Definition: WPParser.cxx:594
bool readSection(WPParserInternal::ParagraphInfo const &info, bool mainBlock)
read a section
Definition: WPParser.cxx:1424
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: WPParser.cxx:667

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