Debian Codegraph @

src/lib/MindWrtParser.hxx

raw
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 ([email protected])
18 * Copyright (C) 2002,2004 Marc Maurer ([email protected])
19 * Copyright (C) 2004-2006 Fridrich Strba ([email protected])
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent ([email protected])
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 MindWrite document
36 */
37 #ifndef MIND_WRT_PARSER
38 # define MIND_WRT_PARSER
39
40 #include <string>
41 #include <vector>
42
43 #include "MWAWDebug.hxx"
44 #include "MWAWInputStream.hxx"
45
46 #include "MWAWParser.hxx"
47
48 namespace MindWrtParserInternal
49 {
50 struct LineInfo;
51 struct State;
52 class SubDocument;
53 }
54
55 /** \brief the main class to read a MindWrite file
56 *
57 *
58 *
59 */
60 class MindWrtParser final : public MWAWTextParser
61 {
62 friend class MindWrtParserInternal::SubDocument;
63
64 public:
65 //! constructor
66 MindWrtParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
67 //! destructor
68 ~MindWrtParser() final;
69
70 //! checks if the document header is correct (or not)
71 bool checkHeader(MWAWHeader *header, bool strict=false) final;
72
73 // the main parse function
74 void parse(librevenge::RVNGTextInterface *documentInterface) final;
75
76 protected:
77 //! inits all internal variables
78 void init();
79
80 //! creates the listener which will be associated to the document
81 void createDocument(librevenge::RVNGTextInterface *documentInterface);
82
83 //! finds the different objects zones
84 bool createZones();
85
86 //! try to send a zone
87 bool sendZone(int i);
88
89 //! try to read a graphic
90 bool readGraphic(MindWrtParserInternal::LineInfo const &line);
91
92 //! try to read a ruler
93 bool readRuler(MindWrtParserInternal::LineInfo &line);
94
95 //! try to read a compressed text zone
96 bool readCompressedText(MindWrtParserInternal::LineInfo const &line);
97
98 //! try to read a non compressed text zone
99 bool readText(MindWrtParserInternal::LineInfo const &line);
100
101 //! try to send the text
102 void sendText(std::string const &text, std::vector<MWAWFont> const &fonts, std::vector<int> const &textPos);
103 //! try to send the header/footer zone
104 void sendHeaderFooter(bool header);
105 //! try to send the header/footer fields as text (in a textbox)
106 void sendHeaderFooterFields(bool header);
107 //! try to read the fonts
108 bool readFonts(MWAWEntry const &entry, std::vector<MWAWFont> &fonts, std::vector<int> &textPos);
109
110 //! read the print info zone
111 bool readPrintInfo(MWAWEntry const &entry);
112
113 //! read the lines information zone
114 bool readLinesInfo(MWAWEntry &entry);
115
116 //! read the last zone ( pos + 7fffffff )
117 bool readLastZone(MWAWEntry const &entry);
118
119 //! read the 8th zone ( unknown zone)
120 bool readZone8(MWAWEntry &entry);
121 //! read the heading state
122 bool readHeadingStates(MWAWEntry &entry);
123 //! read the heading field zone ( zone 12 )
124 bool readHeadingFields(MWAWEntry &entry);
125 //! read the heading property zone
126 bool readHeadingProperties(MWAWEntry &entry);
127 //! read the heading custom zone
128 bool readHeadingCustom(MWAWEntry &entry);
129
130 /** sends a paragraph property to the listener */
131 void setProperty(MWAWParagraph const &para);
132
133 //! adds a new page
134 void newPage(int number);
135
136 //
137 // low level
138 //
139
140 //! read a file entry
141 MWAWEntry readEntry();
142
143 protected:
144 //
145 // data
146 //
147 //! the state
148 std::shared_ptr<MindWrtParserInternal::State> m_state;
149 };
150 #endif
151 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: