LRFParser.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 LRFPARSER_H_INCLUDED
11 #define LRFPARSER_H_INCLUDED
12 
13 #include <vector>
14 #include <map>
15 
16 #include "LRFCollector.h"
17 
18 
19 namespace libebook
20 {
21 
22 struct LRFHeader;
23 
24 class LRFParser
25 {
26  // disable copying
27  LRFParser(const LRFParser &other);
28  LRFParser &operator=(const LRFParser &other);
29 
31  {
59  };
60 
62  {
63  unsigned offset;
64  unsigned size;
65  bool reading;
66  bool read;
67  };
68 
69  typedef std::map<unsigned, LRFIndexEntry> ObjectIndex_t;
70  typedef std::vector<unsigned> ToC_t;
71 
72 public:
73  LRFParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document);
74  ~LRFParser();
75 
76  bool parse();
77 
78  static bool isSupported(librevenge::RVNGInputStream *input);
79 
80 private:
81  void readHeader();
82  void readMetadata();
83  void readThumbnail();
84  void readObjectIndex();
85 
86  void readObject(unsigned id, unsigned type = OBJECT_TYPE_UNSPECIFIED);
87 
88  void readPageTreeObject(librevenge::RVNGInputStream *object);
89  void readPageObject(librevenge::RVNGInputStream *object);
90  void readFooterObject(librevenge::RVNGInputStream *object);
91  void readHeaderObject(librevenge::RVNGInputStream *object);
92  void readPageAtrObject(librevenge::RVNGInputStream *object, unsigned id);
93  void readBlockObject(librevenge::RVNGInputStream *object, unsigned id);
94  void readBlockAtrObject(librevenge::RVNGInputStream *object, unsigned id);
95  void readMiniPageObject(librevenge::RVNGInputStream *object);
96  void readBlockListObject(librevenge::RVNGInputStream *object);
97  void readTextObject(librevenge::RVNGInputStream *object);
98  void readTextAtrObject(librevenge::RVNGInputStream *object, unsigned id);
99  void readImageObject(librevenge::RVNGInputStream *object, unsigned id);
100  void readCanvasObject(librevenge::RVNGInputStream *object);
101  void readParagraphAtrObject(librevenge::RVNGInputStream *object, unsigned id);
102  void readImageStreamObject(librevenge::RVNGInputStream *object, unsigned id);
103  void readImportObject(librevenge::RVNGInputStream *object);
104  void readButtonObject(librevenge::RVNGInputStream *object);
105  void readWindowObject(librevenge::RVNGInputStream *object);
106  void readPopUpWinObject(librevenge::RVNGInputStream *object);
107  void readSoundObject(librevenge::RVNGInputStream *object);
108  void readPlaneStreamObject(librevenge::RVNGInputStream *object);
109  void readFontObject(librevenge::RVNGInputStream *object);
110  void readObjectInfoObject(librevenge::RVNGInputStream *object);
111  void readBookAtrObject(librevenge::RVNGInputStream *object);
112  void readSimpleTextObject(librevenge::RVNGInputStream *object);
113  void readTOCObject(librevenge::RVNGInputStream *object);
114 
115  void readToCStream(librevenge::RVNGInputStream *input);
116 
117  bool readAttribute(unsigned tag, librevenge::RVNGInputStream *input, LRFAttributes &attributes);
118 
119  void skipUnhandledTag(unsigned tag, librevenge::RVNGInputStream *input, const char *objectType);
120 
121  bool isObjectRead(unsigned id) const;
122 
123  double toInches(unsigned px) const;
124 
125 private:
127  librevenge::RVNGInputStream *m_input;
129  ObjectIndex_t m_objectIndex;
130  unsigned m_pageTree;
131  ToC_t m_toc;
132 };
133 
134 } // namespace libebook
135 
136 #endif // LRFPARSER_H_INCLUDED
137 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition: LRFParser.h:42
Definition: LRFTypes.h:108
LRFParser(const LRFParser &other)
Definition: EBOOKHTMLToken.h:91
void readObject(unsigned id, unsigned type=OBJECT_TYPE_UNSPECIFIED)
Definition: LRFParser.cpp:383
void readPageObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:553
void readObjectIndex()
Definition: LRFParser.cpp:367
Definition: LRFParser.h:44
LRFParser & operator=(const LRFParser &other)
void readThumbnail()
Definition: LRFParser.cpp:362
ObjectType
Definition: LRFParser.h:30
bool parse()
Definition: LRFParser.cpp:283
void readObjectInfoObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1069
librevenge::RVNGInputStream * m_input
Definition: LRFParser.h:127
~LRFParser()
Definition: LRFParser.cpp:278
void readTextAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: LRFParser.cpp:894
void readFooterObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:630
Definition: LRFParser.h:58
Definition: LRFParser.h:48
void readHeader()
Definition: LRFParser.cpp:308
bool readAttribute(unsigned tag, librevenge::RVNGInputStream *input, LRFAttributes &attributes)
Definition: LRFParser.cpp:1189
EBOOKDocument::Type type
Definition: EBOOKDocument.cpp:328
std::map< unsigned, LRFIndexEntry > ObjectIndex_t
Definition: LRFParser.h:69
void readBlockAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: LRFParser.cpp:729
Definition: LRFCollector.h:22
bool isObjectRead(unsigned id) const
Definition: LRFParser.cpp:1597
void readBlockListObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:750
Definition: LRFParser.h:52
void readParagraphAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: LRFParser.cpp:950
void readHeaderObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:637
void readButtonObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1027
Definition: LRFParser.h:49
bool read
Definition: LRFParser.h:66
LRFCollector m_collector
Definition: LRFParser.h:126
unsigned m_pageTree
Definition: LRFParser.h:130
void readTextObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:757
Definition: LRFParser.h:35
void readSimpleTextObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1105
void readSoundObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1048
Definition: LRFParser.h:38
double toInches(unsigned px) const
bool reading
Definition: LRFParser.h:65
ToC_t m_toc
Definition: LRFParser.h:131
void readMetadata()
Definition: LRFParser.cpp:349
Definition: LRFParser.h:54
void readCanvasObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:943
void readWindowObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1034
Definition: LRFParser.h:50
ObjectIndex_t m_objectIndex
Definition: LRFParser.h:129
void readMiniPageObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:743
unsigned size
Definition: LRFParser.h:64
Definition: LRFParser.h:36
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:169
void readPopUpWinObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1041
std::vector< unsigned > ToC_t
Definition: LRFParser.h:70
Definition: LRFParser.h:45
void readPlaneStreamObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1055
void readPageTreeObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:535
static bool isSupported(librevenge::RVNGInputStream *input)
Definition: LRFParser.cpp:300
Definition: CHMParser.cpp:20
void readTOCObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1112
LRFHeader * m_header
Definition: LRFParser.h:128
Definition: LRFParser.h:24
Definition: LRFParser.cpp:236
void skipUnhandledTag(unsigned tag, librevenge::RVNGInputStream *input, const char *objectType)
Definition: LRFParser.cpp:1376
void readPageAtrObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: LRFParser.cpp:644
void readBookAtrObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1076
void readToCStream(librevenge::RVNGInputStream *input)
Definition: LRFParser.cpp:1161
void readImportObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1020
void readFontObject(librevenge::RVNGInputStream *object)
Definition: LRFParser.cpp:1062
unsigned offset
Definition: LRFParser.h:63
Definition: LRFParser.h:61
void readImageObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: LRFParser.cpp:908
void readImageStreamObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: LRFParser.cpp:964
Definition: LRFParser.h:34
void readBlockObject(librevenge::RVNGInputStream *object, unsigned id)
Definition: LRFParser.cpp:658

Generated for libe-book by doxygen 1.8.8