Debian Codegraph @

src/lib/BeagleWksText.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 * Text parser to BeagleWorks document
36 *
37 */
38 #ifndef BEAGLE_WKS_TEXT
39 # define BEAGLE_WKS_TEXT
40
41 #include "libmwaw_internal.hxx"
42 #include "MWAWDebug.hxx"
43
44 namespace BeagleWksTextInternal
45 {
46 struct Font;
47 struct Section;
48 struct State;
49
50 class SubDocument;
51 }
52
53 class BeagleWksParser;
54 class BeagleWksStructManager;
55
56 /** \brief the main class to read the text part of BeagleWorks Text file
57 *
58 *
59 *
60 */
61 class BeagleWksText
62 {
63 friend class BeagleWksParser;
64 friend class BeagleWksTextInternal::SubDocument;
65 public:
66 //! constructor
67 explicit BeagleWksText(BeagleWksParser &parser);
68 //! destructor
69 virtual ~BeagleWksText();
70
71 /** returns the file version */
72 int version() const;
73
74 /** returns the number of pages */
75 int numPages() const;
76
77 protected:
78 //! try to create the text zones
79 bool createZones(MWAWEntry const &entry);
80 //! send a main zone
81 bool sendMainText();
82 //! sends the data which have not yet been sent to the listener
83 void flushExtra();
84
85 //
86 // intermediate level
87 //
88
89 //! update the number of pages and the number of page by section
90 void countPages();
91 //! return an header subdocument
92 std::shared_ptr<MWAWSubDocument> getHeader(int page, int &numSimillar);
93 //! return a footer subdocument
94 std::shared_ptr<MWAWSubDocument> getFooter(int page, int &numSimillar);
95 /** update the page span list */
96 void updatePageSpanList(std::vector<MWAWPageSpan> &spanList);
97 //! try to send a text zone
98 bool sendText(MWAWEntry const &entry);
99 //! try to send a header/footer id
100 bool sendHF(int hfId, int sectId);
101 //! returns the font
102 MWAWFont getFont(BeagleWksTextInternal::Font const &ft) const;
103 //! try to read a font properties
104 bool readFont(BeagleWksTextInternal::Font &font, long endPos);
105 //! try to read a paragraph knowing end pos
106 bool readParagraph(MWAWParagraph &para, long endPos, bool inSection=false);
107 //! try to read a section
108 bool readSection(MWAWEntry const &entry, BeagleWksTextInternal::Section &section);
109 private:
110 BeagleWksText(BeagleWksText const &orig) = delete;
111 BeagleWksText &operator=(BeagleWksText const &orig) = delete;
112
113 protected:
114 //
115 // data
116 //
117 //! the parser state
118 MWAWParserStatePtr m_parserState;
119
120 //! the state
121 std::shared_ptr<BeagleWksTextInternal::State> m_state;
122 //! the structure manager
123 std::shared_ptr<BeagleWksStructManager> m_structureManager;
124
125 //! the main parser;
126 BeagleWksParser *m_mainParser;
127 };
128 #endif
129 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: