gui
[lbook_fbreader.git] / fbreader / src / formats / rtf / RtfBookReader.h
blob7d6d7f5977a5df57ba2c67babbf87d032a77394a
1 /*
2 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
20 #ifndef __RTFBOOKREADER_H__
21 #define __RTFBOOKREADER_H__
23 #include <vector>
25 #include "RtfReader.h"
26 #include "../../bookmodel/BookReader.h"
28 class BookModel;
29 class RtfImage;
32 class RtfBookReader : public RtfReader {
34 public:
35 RtfBookReader(BookModel &model, const std::string &encoding);
36 ~RtfBookReader();
38 bool readDocument(const std::string &fileName);
40 bool characterDataHandler(std::string &str);
41 void flushBuffer();
43 void setEncoding(int code);
44 void setAlignment();
45 void switchDestination(DestinationType destination, bool on);
46 void addCharData(const char *data, size_t len, bool convert);
47 void insertImage(const std::string &mimeType, const std::string &fileName, size_t startOffset, size_t size);
49 void setFontProperty(FontProperty property);
50 void newParagraph();
52 private:
53 BookReader myBookReader;
55 std::string myOutputBuffer;
57 int myImageIndex;
58 int myFootnoteIndex;
60 struct RtfBookReaderState {
61 std::string Id;
62 bool ReadText;
65 RtfBookReaderState myCurrentState;
66 std::stack<RtfBookReaderState> myStateStack;
69 inline RtfBookReader::~RtfBookReader() {}
71 #endif /* __RTFBOOKREADER_H__ */