EBOOKHTMLParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libe-book project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef EBOOKHTMLPARSER_H_INCLUDED
11 #define EBOOKHTMLPARSER_H_INCLUDED
12 
13 #include <boost/shared_ptr.hpp>
14 
15 #include <librevenge/librevenge.h>
16 #include <librevenge-stream/librevenge-stream.h>
17 
18 #include "XMLTreeNode.h"
19 
20 namespace libebook
21 {
22 
23 class XMLCollector;
24 struct EBOOKHTMLMetadata;
25 class EBOOKHTMLParagraphAttributes;
26 class EBOOKHTMLSpanAttributes;
27 class EBOOKHTMLTableCellAttributes;
28 class EBOOKOutputElements;
29 class XMLTreeWalker;
30 
32 {
33  struct State;
34 
35 public:
36  enum Dialect
37  {
41  };
42 
43 public:
44  EBOOKHTMLParser(librevenge::RVNGInputStream *input, Dialect dialect, librevenge::RVNGTextInterface *document);
45  virtual ~EBOOKHTMLParser();
46 
47  void parse();
48  const XMLTreeNodePtr_t readTree();
49 
50  virtual librevenge::RVNGInputStream *getImage(const char *path) = 0;
51  virtual librevenge::RVNGInputStream *getObject(const char *path) = 0;
52  virtual librevenge::RVNGInputStream *getStylesheet(const char *path) = 0;
53 
54 private:
55  const XMLTreeNodePtr_t readTreeImpl(std::string &encoding, bool &encodingChange);
56  void processNode(const XMLTreeWalker &node);
57 
58  void startElement(const XMLTreeWalker &node);
59  void endElement(const XMLTreeWalker &node);
60  void text(const XMLTreeWalker &node);
61 
62  void startExternalElement(const XMLTreeWalker &node);
63  void endExternalElement(const XMLTreeWalker &node);
64 
65  void sendParagraph(const XMLTreeWalker &node);
66  void sendSpan(const XMLTreeWalker &node);
67  void sendTableCell(const XMLTreeWalker &node);
68  void sendPreformattedText(const char *ch, int len);
69  void sendHeading(const XMLTreeWalker &node, int level);
70 
71 private:
72  boost::shared_ptr<XMLCollector> m_collector;
73  boost::shared_ptr<State> m_state;
74  boost::shared_ptr<librevenge::RVNGInputStream> m_input;
75  // const Dialect m_dialect;
76  boost::shared_ptr<librevenge::RVNGInputStream> m_workingInput;
77 };
78 
79 }
80 
81 #endif // EBOOKHTMLPARSER_H_INCLUDED
82 
83 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
boost::intrusive_ptr< XMLTreeNode > XMLTreeNodePtr_t
Definition: XMLTreeNode.h:24
Definition: EBOOKHTMLToken.h:91
virtual ~EBOOKHTMLParser()
Definition: EBOOKHTMLParser.cpp:935
virtual librevenge::RVNGInputStream * getStylesheet(const char *path)=0
Definition: EBOOKHTMLParser.h:31
boost::shared_ptr< State > m_state
Definition: EBOOKHTMLParser.h:73
void text(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1434
void endElement(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1266
void parse()
Definition: EBOOKHTMLParser.cpp:939
boost::shared_ptr< librevenge::RVNGInputStream > m_input
Definition: EBOOKHTMLParser.h:74
EBOOKHTMLParser(librevenge::RVNGInputStream *input, Dialect dialect, librevenge::RVNGTextInterface *document)
Definition: EBOOKHTMLParser.cpp:926
void sendTableCell(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1489
void sendSpan(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1483
Definition: EBOOKHTMLParser.h:40
boost::shared_ptr< XMLCollector > m_collector
Definition: EBOOKHTMLParser.h:72
void endExternalElement(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1471
void processNode(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1002
string path
Definition: EBOOKOPFParser.cpp:49
void sendPreformattedText(const char *ch, int len)
Definition: EBOOKHTMLParser.cpp:1495
void sendParagraph(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1477
const XMLTreeNodePtr_t readTree()
Definition: EBOOKHTMLParser.cpp:952
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:169
virtual librevenge::RVNGInputStream * getObject(const char *path)=0
Definition: EBOOKHTMLParser.h:38
void startExternalElement(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1465
size_t len
Definition: EBOOKHTMLParser.cpp:53
Dialect
Definition: EBOOKHTMLParser.h:36
Definition: CHMParser.cpp:20
Definition: EBOOKHTMLParser.cpp:908
void startElement(const XMLTreeWalker &node)
Definition: EBOOKHTMLParser.cpp:1016
boost::shared_ptr< librevenge::RVNGInputStream > m_workingInput
Definition: EBOOKHTMLParser.h:76
void sendHeading(const XMLTreeWalker &node, int level)
Definition: EBOOKHTMLParser.cpp:1539
Definition: EBOOKHTMLParser.h:39
virtual librevenge::RVNGInputStream * getImage(const char *path)=0
const XMLTreeNodePtr_t readTreeImpl(std::string &encoding, bool &encodingChange)
Definition: EBOOKHTMLParser.cpp:970
const char * encoding
Definition: EBOOKHTMLParser.cpp:172
Definition: XMLTreeWalker.h:27

Generated for libe-book by doxygen 1.8.8