Debian Codegraph @

src/lib/ClarisWksText.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 Claris Works text document
36 *
37 */
38 #ifndef CLARIS_WKS_TEXT
39 # define CLARIS_WKS_TEXT
40
41 #include <list>
42 #include <string>
43 #include <vector>
44
45 #include "libmwaw_internal.hxx"
46
47 #include "MWAWEntry.hxx"
48 #include "MWAWSubDocument.hxx"
49
50 #include "MWAWDebug.hxx"
51 #include "MWAWInputStream.hxx"
52
53 #include "MWAWParser.hxx"
54
55 #include "ClarisWksStruct.hxx"
56
57 namespace ClarisWksTextInternal
58 {
59 class SubDocument;
60
61 struct Paragraph;
62 struct Zone;
63 struct State;
64 }
65
66 class ClarisWksDocument;
67 class ClarisWksParser;
68 class ClarisWksStyleManager;
69
70 /** \brief the main class to read the text part of Claris Works file
71 *
72 *
73 *
74 */
75 class ClarisWksText
76 {
77 friend class ClarisWksTextInternal::SubDocument;
78 friend class ClarisWksDocument;
79 friend class ClarisWksParser;
80 friend class ClarisWksStyleManager;
81
82 public:
83 //! constructor
84 explicit ClarisWksText(ClarisWksDocument &document);
85 //! destructor
86 virtual ~ClarisWksText();
87
88 /** returns the file version */
89 int version() const;
90
91 /** returns the number of pages */
92 int numPages() const;
93 /** updates the page span list and returns true if this is possible */
94 bool updatePageSpanList(MWAWPageSpan const &page, std::vector<MWAWPageSpan> &spanList);
95
96 //! reads the zone Text DSET
97 std::shared_ptr<ClarisWksStruct::DSET> readDSETZone(ClarisWksStruct::DSET const &zone, MWAWEntry const &entry, bool &complete);
98
99 protected:
100 /** sends a paragraph property to the listener */
101 void setProperty(MWAWListener &listener, ClarisWksTextInternal::Paragraph const &ruler, int listId=-1);
102
103 //! sends the zone data to the listener (if it exists )
104 bool sendZone(int number, MWAWListenerPtr const &listener=MWAWListenerPtr());
105 //! check if we can send a textzone as graphic
106 bool canSendTextAsGraphic(int number) const;
107
108 //! sends the data which have not yet been sent to the listener
109 void flushExtra();
110
111 //
112 // low level
113 //
114
115 //! try to read the paragraph
116 bool readParagraphs(MWAWEntry const &entry, ClarisWksTextInternal::Zone &zone);
117
118 //! try to read a font sequence
119 bool readFonts(MWAWEntry const &entry, ClarisWksTextInternal::Zone &zone);
120
121 //! try to the token zone)
122 bool readTokens(MWAWEntry const &entry, ClarisWksTextInternal::Zone &zone);
123
124 //! try to read the text zone size
125 bool readTextZoneSize(MWAWEntry const &entry, ClarisWksTextInternal::Zone &zone);
126
127 //! try to read the section
128 bool readTextSection(ClarisWksTextInternal::Zone &zone);
129
130 //! send the text zone to the listener
131 bool sendText(ClarisWksTextInternal::Zone const &zone, MWAWListenerPtr listener);
132 //! check if we can send a textzone has graphic
133 bool canSendTextAsGraphic(ClarisWksTextInternal::Zone const &zone) const;
134
135 //! try to find a list id which corresponds to the list beginning in actPos
136 int findListId(ClarisWksTextInternal::Zone const &zone, int actListId, long cPos, long &lastPos);
137
138 /** read the rulers block which is present at the beginning of the text in the first version of Claris Works : v1-2 */
139 bool readParagraphs();
140
141 /** the definition of ruler :
142 present at the beginning of the text in the first version of Claris Works : v1-2,
143 present in the STYL entries in v4-v6 files */
144 bool readParagraph(int id=-1);
145
146 // THE NAMED ENTRY
147
148 /** read a STYL Paragraph sequence */
149 bool readSTYL_RULR(int N, int fSz);
150
151 private:
152 ClarisWksText(ClarisWksText const &orig) = delete;
153 ClarisWksText &operator=(ClarisWksText const &orig) = delete;
154
155 protected:
156 //
157 // data
158 //
159
160 //! the document
161 ClarisWksDocument &m_document;
162
163 //! the parser state
164 MWAWParserStatePtr m_parserState;
165
166 //! the state
167 std::shared_ptr<ClarisWksTextInternal::State> m_state;
168
169 //! the main parser;
170 MWAWParser *m_mainParser;
171 };
172 #endif
173 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: