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 <memory>
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
31 class EBOOKHTMLParser
32{
33 struct State;
34
35 public:
36 enum Dialect
37 {
38 DIALECT_UNKNOWN,
39 DIALECT_HTML,
40 DIALECT_XHTML
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 std::shared_ptr<XMLCollector> m_collector;
73 std::shared_ptr<State> m_state;
74 std::shared_ptr<librevenge::RVNGInputStream> m_input;
75 // const Dialect m_dialect;
76 std::shared_ptr<librevenge::RVNGInputStream> m_workingInput;
77};
78
79}
80
81#endif // EBOOKHTMLPARSER_H_INCLUDED
82
83/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
document
XMLTreeNodePtr_t document
Definition EBOOKHTMLParser.cpp:163
len
size_t len
Definition EBOOKHTMLParser.cpp:47
encoding
const char * encoding
Definition EBOOKHTMLParser.cpp:166
path
string path
Definition EBOOKOPFParser.cpp:49
text
qi::rule< Iterator, AttrValue_t, qi::space_type > text
Definition TealDocParser.cpp:232
XMLTreeNode.h
libebook::EBOOKHTMLParser
Definition EBOOKHTMLParser.h:32
libebook::EBOOKHTMLParser::getImage
virtual librevenge::RVNGInputStream * getImage(const char *path)=0
libebook::EBOOKHTMLParser::m_collector
std::shared_ptr< XMLCollector > m_collector
Definition EBOOKHTMLParser.h:72
libebook::EBOOKHTMLParser::~EBOOKHTMLParser
virtual ~EBOOKHTMLParser()
Definition EBOOKHTMLParser.cpp:928
libebook::EBOOKHTMLParser::m_input
std::shared_ptr< librevenge::RVNGInputStream > m_input
Definition EBOOKHTMLParser.h:74
libebook::EBOOKHTMLParser::readTreeImpl
const XMLTreeNodePtr_t readTreeImpl(std::string &encoding, bool &encodingChange)
Definition EBOOKHTMLParser.cpp:964
libebook::EBOOKHTMLParser::sendSpan
void sendSpan(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:1478
libebook::EBOOKHTMLParser::parse
void parse()
Definition EBOOKHTMLParser.cpp:932
libebook::EBOOKHTMLParser::endExternalElement
void endExternalElement(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:1466
libebook::EBOOKHTMLParser::processNode
void processNode(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:996
libebook::EBOOKHTMLParser::getObject
virtual librevenge::RVNGInputStream * getObject(const char *path)=0
libebook::EBOOKHTMLParser::m_workingInput
std::shared_ptr< librevenge::RVNGInputStream > m_workingInput
Definition EBOOKHTMLParser.h:76
libebook::EBOOKHTMLParser::startElement
void startElement(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:1011
libebook::EBOOKHTMLParser::sendHeading
void sendHeading(const XMLTreeWalker &node, int level)
Definition EBOOKHTMLParser.cpp:1534
libebook::EBOOKHTMLParser::readTree
const XMLTreeNodePtr_t readTree()
Definition EBOOKHTMLParser.cpp:946
libebook::EBOOKHTMLParser::Dialect
Dialect
Definition EBOOKHTMLParser.h:37
libebook::EBOOKHTMLParser::DIALECT_HTML
@ DIALECT_HTML
Definition EBOOKHTMLParser.h:39
libebook::EBOOKHTMLParser::DIALECT_UNKNOWN
@ DIALECT_UNKNOWN
Definition EBOOKHTMLParser.h:38
libebook::EBOOKHTMLParser::DIALECT_XHTML
@ DIALECT_XHTML
Definition EBOOKHTMLParser.h:40
libebook::EBOOKHTMLParser::startExternalElement
void startExternalElement(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:1460
libebook::EBOOKHTMLParser::m_state
std::shared_ptr< State > m_state
Definition EBOOKHTMLParser.h:73
libebook::EBOOKHTMLParser::getStylesheet
virtual librevenge::RVNGInputStream * getStylesheet(const char *path)=0
libebook::EBOOKHTMLParser::endElement
void endElement(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:1261
libebook::EBOOKHTMLParser::sendParagraph
void sendParagraph(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:1472
libebook::EBOOKHTMLParser::sendPreformattedText
void sendPreformattedText(const char *ch, int len)
Definition EBOOKHTMLParser.cpp:1490
libebook::EBOOKHTMLParser::sendTableCell
void sendTableCell(const XMLTreeWalker &node)
Definition EBOOKHTMLParser.cpp:1484
libebook::XMLTreeWalker
Definition XMLTreeWalker.h:28
libebook
Definition BBeBCollector.cpp:19
libebook::XMLTreeNodePtr_t
boost::intrusive_ptr< XMLTreeNode > XMLTreeNodePtr_t
Definition XMLTreeNode.h:25
libebook::EBOOKHTMLParser::State
Definition EBOOKHTMLParser.cpp:903