gui
[lbook_fbreader.git] / fbreader / src / formats / html / HtmlBookReader.h
blobfae124b593aac7e5647647669808a8dd222c6c4f
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 __HTMLBOOKREADER_H__
21 #define __HTMLBOOKREADER_H__
23 #include <stack>
25 #include <shared_ptr.h>
27 #include "HtmlReader.h"
28 #include "../../bookmodel/BookReader.h"
29 #include "StyleSheetTable.h"
31 class BookModel;
32 class PlainTextFormat;
33 class StyleSheetParser;
35 class HtmlTagAction;
37 class HtmlBookReader : public HtmlReader {
39 public:
40 HtmlBookReader(const std::string &baseDirectoryPath, BookModel &model, const PlainTextFormat &format, const std::string &encoding);
41 ~HtmlBookReader();
42 void setFileName(const std::string fileName);
44 protected:
45 virtual shared_ptr<HtmlTagAction> createAction(const std::string &tag);
46 void setBuildTableOfContent(bool build);
47 void setProcessPreTag(bool process);
49 protected:
50 void startDocumentHandler();
51 void endDocumentHandler();
52 bool tagHandler(const HtmlTag &tag);
53 bool characterDataHandler(const char *text, int len, bool convert);
55 private:
56 void preformattedCharacterDataHandler(const char *text, int len, bool convert);
57 void addConvertedDataToBuffer(const char *text, int len, bool convert);
59 protected:
60 BookReader myBookReader;
61 std::string myBaseDirPath;
63 private:
64 const PlainTextFormat &myFormat;
65 int myIgnoreDataCounter;
66 bool myIsPreformatted;
67 bool myDontBreakParagraph;
69 bool myIsStarted;
70 bool myBuildTableOfContent;
71 bool myProcessPreTag;
72 bool myIgnoreTitles;
73 std::stack<int> myListNumStack;
75 StyleSheetTable myStyleSheetTable;
76 shared_ptr<StyleSheetParser> myStyleSheetParser;
78 int mySpaceCounter;
79 int myBreakCounter;
80 std::string myConverterBuffer;
82 std::map<std::string,shared_ptr<HtmlTagAction> > myActionMap;
83 std::vector<FBTextKind> myKindList;
85 std::string myFileName;
87 friend class HtmlTagAction;
88 friend class HtmlControlTagAction;
89 friend class HtmlHeaderTagAction;
90 friend class HtmlIgnoreTagAction;
91 friend class HtmlHrefTagAction;
92 friend class HtmlImageTagAction;
93 friend class HtmlBreakTagAction;
94 friend class HtmlPreTagAction;
95 friend class HtmlListTagAction;
96 friend class HtmlListItemTagAction;
97 friend class HtmlTableTagAction;
98 friend class HtmlStyleTagAction;
101 #endif /* __HTMLBOOKREADER_H__ */