Debian Codegraph @

src/lib/DocMkrText.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 Nisus text document
36 *
37 */
38 #ifndef DOC_MKR_TEXT
39 # define DOC_MKR_TEXT
40
41 #include "libmwaw_internal.hxx"
42 #include "MWAWDebug.hxx"
43
44 namespace DocMkrTextInternal
45 {
46 struct Zone;
47
48 class SubDocument;
49 struct State;
50 }
51
52 class DocMkrParser;
53
54 /** \brief the main class to read the text part of DocMaker file
55 *
56 *
57 *
58 */
59 class DocMkrText
60 {
61 friend class DocMkrTextInternal::SubDocument;
62 friend class DocMkrParser;
63 public:
64 //! constructor
65 explicit DocMkrText(DocMkrParser &parser);
66 //! destructor
67 virtual ~DocMkrText();
68
69 /** returns the file version */
70 int version() const;
71
72 /** returns the number of pages */
73 int numPages() const;
74
75 /** returns the number of chapter */
76 int numChapters() const;
77
78 //! send a string as comment
79 void sendComment(std::string const &str);
80
81 protected:
82
83 //! finds the different text zones
84 bool createZones();
85
86 //! send a main zone
87 bool sendMainText();
88
89 //! sends the data which have not yet been sent to the listener
90 void flushExtra();
91
92 //
93 // intermediate level
94 //
95
96 /** compute the number of page of a zone*/
97 void computeNumPages(DocMkrTextInternal::Zone const &zone) const;
98
99 /** update the page span list */
100 void updatePageSpanList(std::vector<MWAWPageSpan> &spanList);
101
102 /** try to send the text corresponding to a zone */
103 bool sendText(DocMkrTextInternal::Zone const &zone);
104
105 //! try to read the font name ( resource rQDF )
106 bool readFontNames(MWAWEntry const &entry);
107
108 //! try to read the styles ( resource styl )
109 bool readStyles(MWAWEntry const &entry);
110
111 //! try to read a TOC zone? ( resource cnt# )
112 bool readTOC(MWAWEntry const &entry);
113
114 //! try to send a TOC zone
115 bool sendTOC();
116
117 //! try to read the windows information zone? ( resource Wndo )
118 bool readWindows(MWAWEntry const &entry);
119
120 //! try to read the footer zone ( resource foot )
121 bool readFooter(MWAWEntry const &entry);
122
123 //! try to send a footer corresponding to a zone id
124 bool sendFooter(int zId);
125
126 //
127 // low level
128 //
129
130 //! send a string to the listener
131 void sendString(std::string const &str) const;
132 private:
133 DocMkrText(DocMkrText const &orig) = delete;
134 DocMkrText &operator=(DocMkrText const &orig) = delete;
135
136 protected:
137 //
138 // data
139 //
140 //! the parser state
141 MWAWParserStatePtr m_parserState;
142
143 //! the state
144 std::shared_ptr<DocMkrTextInternal::State> m_state;
145
146 //! the main parser;
147 DocMkrParser *m_mainParser;
148
149 };
150 #endif
151 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: