BBeBParser.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 BBEBPARSER_H_INCLUDED
11 #define BBEBPARSER_H_INCLUDED
12 
13 #include <vector>
14 #include <map>
15 #include <memory>
16 
17 #include "BBeBCollector.h"
18 
19 
20 namespace libebook
21 {
22 
23 struct BBeBHeader;
24 
26 {
27  // disable copying
28  BBeBParser(const BBeBParser &other);
29  BBeBParser &operator=(const BBeBParser &other);
30 
32  {
60  };
61 
63  {
64  unsigned offset;
65  unsigned size;
66  bool reading;
67  bool read;
68  };
69 
70  typedef std::map<unsigned, BBeBIndexEntry> ObjectIndex_t;
71  typedef std::vector<unsigned> ToC_t;
72 
73 public:
74  BBeBParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document);
75  ~BBeBParser();
76 
77  bool parse();
78 
79  static bool isSupported(librevenge::RVNGInputStream *input);
80 
81 private:
82  void readHeader();
83  void readMetadata();
84  void readThumbnail();
85  void readObjectIndex();
86 
87  void readObject(unsigned id, unsigned type = OBJECT_TYPE_UNSPECIFIED);
88 
89  void readPageTreeObject(librevenge::RVNGInputStream *object);
90  void readPageObject(librevenge::RVNGInputStream *object);
91  void readFooterObject(librevenge::RVNGInputStream *object);
92  void readHeaderObject(librevenge::RVNGInputStream *object);
93  void readPageAtrObject(librevenge::RVNGInputStream *object, unsigned id);
94  void readBlockObject(librevenge::RVNGInputStream *object, unsigned id);
95  void readBlockAtrObject(librevenge::RVNGInputStream *object, unsigned id);
96  void readMiniPageObject(librevenge::RVNGInputStream *object);
97  void readBlockListObject(librevenge::RVNGInputStream *object);
98  void readTextObject(librevenge::RVNGInputStream *object);
99  void readTextAtrObject(librevenge::RVNGInputStream *object, unsigned id);
100  void readImageObject(librevenge::RVNGInputStream *object, unsigned id);
101  void readCanvasObject(librevenge::RVNGInputStream *object);
102  void readParagraphAtrObject(librevenge::RVNGInputStream *object, unsigned id);
103  void readImageStreamObject(librevenge::RVNGInputStream *object, unsigned id);
104  void readImportObject(librevenge::RVNGInputStream *object);
105  void readButtonObject(librevenge::RVNGInputStream *object);
106  void readWindowObject(librevenge::RVNGInputStream *object);
107  void readPopUpWinObject(librevenge::RVNGInputStream *object);
108  void readSoundObject(librevenge::RVNGInputStream *object);
109  void readPlaneStreamObject(librevenge::RVNGInputStream *object);
110  void readFontObject(librevenge::RVNGInputStream *object);
111  void readObjectInfoObject(librevenge::RVNGInputStream *object);
112  void readBookAtrObject(librevenge::RVNGInputStream *object);
113  void readSimpleTextObject(librevenge::RVNGInputStream *object);
114  void readTOCObject(librevenge::RVNGInputStream *object);
115 
116  void readToCStream(librevenge::RVNGInputStream *input);
117 
118  bool readAttribute(unsigned tag, librevenge::RVNGInputStream *input, BBeBAttributes &attributes);
119 
120  void skipUnhandledTag(unsigned tag, librevenge::RVNGInputStream *input, const char *objectType);
121 
122  bool isObjectRead(unsigned id) const;
123 
124  double toInches(unsigned px) const;
125 
126 private:
128  librevenge::RVNGInputStream *m_input;
129  std::unique_ptr<BBeBHeader> m_header;
131  unsigned m_pageTree;
133 };
134 
135 } // namespace libebook
136 
137 #endif // BBEBPARSER_H_INCLUDED
138 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
unsigned m_pageTree
Definition: BBeBParser.h:131
Definition: EBOOKHTMLToken.h:89
bool parse()
Definition: BBeBParser.cpp:282
bool readAttribute(unsigned tag, librevenge::RVNGInputStream *input, BBeBAttributes &attributes)
Definition: BBeBParser.cpp:1205
Definition: BBeBParser.h:37
void readPageTreeObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:533
void readBookAtrObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1090
Definition: BBeBParser.h:59
bool read
Definition: BBeBParser.h:67
void readObject(unsigned id, unsigned type=OBJECT_TYPE_UNSPECIFIED)
Definition: BBeBParser.cpp:382
Definition: BBeBParser.h:53
void readTOCObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1126
void readPlaneStreamObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1069
void readImageObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: BBeBParser.cpp:920
void readWindowObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1048
void readImageStreamObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: BBeBParser.cpp:976
void readObjectInfoObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1083
qi::rule< Iterator, std::pair< int, Attributes_t >, qi::space_type > tag
Definition: TealDocParser.cpp:229
BBeBParser(const BBeBParser &other)
~BBeBParser()
Definition: BBeBParser.cpp:278
std::vector< unsigned > ToC_t
Definition: BBeBParser.h:71
Definition: BBeBParser.h:51
Definition: BBeBParser.h:43
void readToCStream(librevenge::RVNGInputStream *input)
Definition: BBeBParser.cpp:1175
void readParagraphAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: BBeBParser.cpp:962
void readImportObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1034
void readFooterObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:631
Definition: BBeBParser.h:36
void readMetadata()
Definition: BBeBParser.cpp:348
void readHeader()
Definition: BBeBParser.cpp:307
void readObjectIndex()
Definition: BBeBParser.cpp:366
void readSoundObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1062
EBOOKDocument::Type type
Definition: EBOOKDocument.cpp:325
Definition: BBeBParser.h:25
void readPopUpWinObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1055
Definition: BBeBParser.h:35
BBeBParser & operator=(const BBeBParser &other)
static bool isSupported(librevenge::RVNGInputStream *input)
Definition: BBeBParser.cpp:299
Definition: BBeBTypes.h:108
Definition: BBeBParser.h:46
ObjectIndex_t m_objectIndex
Definition: BBeBParser.h:130
Definition: BBeBParser.h:50
Definition: BBeBParser.h:62
unsigned size
Definition: BBeBParser.h:65
Definition: BBeBParser.h:55
unsigned offset
Definition: BBeBParser.h:64
ToC_t m_toc
Definition: BBeBParser.h:132
void readTextObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:763
void readSimpleTextObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1119
BBeBCollector m_collector
Definition: BBeBParser.h:127
Definition: BBeBCollector.h:22
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:163
void readBlockListObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:756
double toInches(unsigned px) const
void readMiniPageObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:749
void readBlockAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: BBeBParser.cpp:735
std::unique_ptr< BBeBHeader > m_header
Definition: BBeBParser.h:129
void readBlockObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: BBeBParser.cpp:659
Definition: BBeBCollector.cpp:18
void readCanvasObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:955
void readHeaderObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:638
librevenge::RVNGInputStream * m_input
Definition: BBeBParser.h:128
void readFontObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1076
void readTextAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: BBeBParser.cpp:906
bool isObjectRead(unsigned id) const
Definition: BBeBParser.cpp:1613
void readPageAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: BBeBParser.cpp:645
void skipUnhandledTag(unsigned tag, librevenge::RVNGInputStream *input, const char *objectType)
Definition: BBeBParser.cpp:1392
void readThumbnail()
Definition: BBeBParser.cpp:361
Definition: BBeBParser.h:39
Definition: BBeBParser.h:45
bool reading
Definition: BBeBParser.h:66
void readButtonObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:1041
ObjectType
Definition: BBeBParser.h:31
std::map< unsigned, BBeBIndexEntry > ObjectIndex_t
Definition: BBeBParser.h:70
void readPageObject(librevenge::RVNGInputStream *object)
Definition: BBeBParser.cpp:553

Generated for libe-book by doxygen 1.8.14