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
20 #ifndef __HTMLBOOKREADER_H__
21 #define __HTMLBOOKREADER_H__
25 #include <shared_ptr.h>
27 #include "HtmlReader.h"
28 #include "../../bookmodel/BookReader.h"
29 #include "StyleSheetTable.h"
32 class PlainTextFormat
;
33 class StyleSheetParser
;
37 class HtmlBookReader
: public HtmlReader
{
40 HtmlBookReader(const std::string
&baseDirectoryPath
, BookModel
&model
, const PlainTextFormat
&format
, const std::string
&encoding
);
42 void setFileName(const std::string fileName
);
45 virtual shared_ptr
<HtmlTagAction
> createAction(const std::string
&tag
);
46 void setBuildTableOfContent(bool build
);
47 void setProcessPreTag(bool process
);
50 void startDocumentHandler();
51 void endDocumentHandler();
52 bool tagHandler(const HtmlTag
&tag
);
53 bool characterDataHandler(const char *text
, int len
, bool convert
);
56 void preformattedCharacterDataHandler(const char *text
, int len
, bool convert
);
57 void addConvertedDataToBuffer(const char *text
, int len
, bool convert
);
60 BookReader myBookReader
;
61 std::string myBaseDirPath
;
64 const PlainTextFormat
&myFormat
;
65 int myIgnoreDataCounter
;
66 bool myIsPreformatted
;
67 bool myDontBreakParagraph
;
70 bool myBuildTableOfContent
;
73 std::stack
<int> myListNumStack
;
75 StyleSheetTable myStyleSheetTable
;
76 shared_ptr
<StyleSheetParser
> myStyleSheetParser
;
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__ */