LRFCollector.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 LRFCOLLECTOR_H_INCLUDED
11 #define LRFCOLLECTOR_H_INCLUDED
12
13 #include <string>
14 #include <stack>
15
16 #include "LRFTypes.h"
17
18
19 namespace libebook
20 {
21
22 class LRFCollector
23 {
24 // -Weffc++
25 LRFCollector(const LRFCollector &other);
26 LRFCollector &operator=(const LRFCollector &other);
27
28 struct ImageStreamData
29 {
30 librevenge::RVNGInputStream *image;
31 LRFImageType type;
32 };
33 typedef std::map<unsigned, ImageStreamData> ImageDataMap_t;
34
35 struct ImageData
36 {
37 unsigned dataId;
38 unsigned width;
39 unsigned height;
40 };
41 typedef std::map<unsigned, ImageData> ImageMap_t;
42
43 public:
44 explicit LRFCollector(librevenge::RVNGTextInterface *document);
45 ~LRFCollector();
46
47 void startDocument();
48 void endDocument();
49
50 void openPage(unsigned pageAtrID, const LRFAttributes &attributes);
51 void closePage();
52
53 void openBlock(unsigned atrID, const LRFAttributes &attributes);
54 void closeBlock();
55
56 void openTextBlock(unsigned atrID, const LRFAttributes &attributes);
57 void closeTextBlock();
58
59 void openParagraph(unsigned atrID, const LRFAttributes &attributes);
60 void closeParagraph();
61
62 void collectText(const std::string &text, const LRFAttributes &attributes);
63 void insertLineBreak();
64
65 void insertImage(unsigned id);
66
67 void collectMetadata(const LRFMetadata &metadata);
68
69 void collectBookAttributes(const LRFAttributes &attributes);
70 void collectTextAttributes(unsigned id, const LRFAttributes &attributes);
71 void collectBlockAttributes(unsigned id, const LRFAttributes &attributes);
72 void collectPageAttributes(unsigned id, const LRFAttributes &attributes);
73 void collectParagraphAttributes(unsigned id, const LRFAttributes &attributes);
74
75 void collectImage(unsigned id, unsigned dataId, unsigned width, unsigned height);
76 void collectImageData(unsigned id, LRFImageType type, librevenge::RVNGInputStream *image);
77
78 void setDPI(double dpi);
79
80 private:
81 void collectAttributes(unsigned id, const LRFAttributes &attributes, LRFAttributeMap_t &attributeMap);
82 void openBlock(unsigned atrID, const LRFAttributes &attributes, const LRFAttributeMap_t *attributeMap);
83
84 private:
85 LRFAttributes m_bookAttributes;
86 LRFAttributeMap_t m_textAttributeMap;
87 LRFAttributeMap_t m_blockAttributeMap;
88 LRFAttributeMap_t m_pageAttributeMap;
89 LRFAttributeMap_t m_paragraphAttributeMap;
90 librevenge::RVNGTextInterface *const m_document;
91 std::stack<LRFAttributes> m_currentAttributes;
92 ImageDataMap_t m_imageDataMap;
93 ImageMap_t m_imageMap;
94 double m_dpi;
95 bool m_firstParaInBlock;
96 };
97
98 }
99
100 #endif // LRFCOLLECTOR_H_INCLUDED
101
102 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libebook::LRFCollector::m_bookAttributes
LRFAttributes m_bookAttributes
Definition: LRFCollector.h:85
libebook::LRFAttributes
Definition: LRFTypes.h:108
libebook::LRFCollector::openParagraph
void openParagraph(unsigned atrID, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:376
libebook::LRFCollector::openBlock
void openBlock(unsigned atrID, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:355
libebook::LRFCollector::m_currentAttributes
std::stack< LRFAttributes > m_currentAttributes
Definition: LRFCollector.h:91
libebook::LRFCollector::~LRFCollector
~LRFCollector()
Definition: LRFCollector.cpp:325
libebook::LRFCollector::m_textAttributeMap
LRFAttributeMap_t m_textAttributeMap
Definition: LRFCollector.h:86
libebook::LRFCollector::insertLineBreak
void insertLineBreak()
Definition: LRFCollector.cpp:408
libebook::LRFCollector::setDPI
void setDPI(double dpi)
Definition: LRFCollector.cpp:583
libebook::LRFCollector::m_imageMap
ImageMap_t m_imageMap
Definition: LRFCollector.h:93
libebook::LRFCollector::ImageData::dataId
unsigned dataId
Definition: LRFCollector.h:37
libebook::LRFCollector::closeTextBlock
void closeTextBlock()
Definition: LRFCollector.cpp:371
libebook::LRFCollector::operator=
LRFCollector & operator=(const LRFCollector &other)
libebook::LRFCollector::openTextBlock
void openTextBlock(unsigned atrID, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:365
libebook::LRFCollector::m_blockAttributeMap
LRFAttributeMap_t m_blockAttributeMap
Definition: LRFCollector.h:87
libebook::EBOOKHTMLToken::text
Definition: EBOOKHTMLToken.h:259
libebook::EBOOKHTMLToken::width
Definition: EBOOKHTMLToken.h:267
libebook::LRFImageType
LRFImageType
Definition: LRFTypes.h:22
libebook::LRFCollector::m_pageAttributeMap
LRFAttributeMap_t m_pageAttributeMap
Definition: LRFCollector.h:88
libebook::LRFCollector::m_firstParaInBlock
bool m_firstParaInBlock
Definition: LRFCollector.h:95
libebook::LRFCollector::collectPageAttributes
void collectPageAttributes(unsigned id, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:438
libebook::LRFCollector::LRFCollector
LRFCollector(const LRFCollector &other)
libebook::LRFCollector::endDocument
void endDocument()
Definition: LRFCollector.cpp:337
libebook::LRFCollector::ImageStreamData
Definition: LRFCollector.h:28
LRFTypes.h
libebook::LRFCollector::collectBookAttributes
void collectBookAttributes(const LRFAttributes &attributes)
Definition: LRFCollector.cpp:423
libebook::LRFCollector::m_paragraphAttributeMap
LRFAttributeMap_t m_paragraphAttributeMap
Definition: LRFCollector.h:89
libebook::LRFCollector
Definition: LRFCollector.h:22
libebook::LRFCollector::collectBlockAttributes
void collectBlockAttributes(unsigned id, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:433
libebook::EBOOKHTMLToken::height
Definition: EBOOKHTMLToken.h:200
metadata
RVNGPropertyList metadata
Definition: EBOOKOPFParser.cpp:63
libebook::LRFCollector::closePage
void closePage()
Definition: LRFCollector.cpp:349
libebook::LRFCollector::collectMetadata
void collectMetadata(const LRFMetadata &metadata)
Definition: LRFCollector.cpp:413
libebook::LRFCollector::collectTextAttributes
void collectTextAttributes(unsigned id, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:428
libebook::LRFCollector::m_dpi
double m_dpi
Definition: LRFCollector.h:94
libebook::LRFCollector::ImageStreamData::type
LRFImageType type
Definition: LRFCollector.h:31
libebook::LRFCollector::collectAttributes
void collectAttributes(unsigned id, const LRFAttributes &attributes, LRFAttributeMap_t &attributeMap)
Definition: LRFCollector.cpp:555
libebook::LRFCollector::collectImage
void collectImage(unsigned id, unsigned dataId, unsigned width, unsigned height)
Definition: LRFCollector.cpp:448
document
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:169
libebook::LRFCollector::ImageDataMap_t
std::map< unsigned, ImageStreamData > ImageDataMap_t
Definition: LRFCollector.h:33
libebook::LRFCollector::collectImageData
void collectImageData(unsigned id, LRFImageType type, librevenge::RVNGInputStream *image)
Definition: LRFCollector.cpp:543
libebook
Definition: CHMParser.cpp:20
libebook::LRFCollector::openPage
void openPage(unsigned pageAtrID, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:343
libebook::LRFCollector::insertImage
void insertImage(unsigned id)
Definition: LRFCollector.cpp:468
libebook::LRFCollector::closeParagraph
void closeParagraph()
Definition: LRFCollector.cpp:393
libebook::LRFMetadata
Definition: LRFTypes.h:79
libebook::LRFCollector::startDocument
void startDocument()
Definition: LRFCollector.cpp:331
libebook::LRFCollector::ImageMap_t
std::map< unsigned, ImageData > ImageMap_t
Definition: LRFCollector.h:41
libebook::LRFCollector::m_imageDataMap
ImageDataMap_t m_imageDataMap
Definition: LRFCollector.h:92
libebook::LRFCollector::closeBlock
void closeBlock()
Definition: LRFCollector.cpp:360
libebook::LRFCollector::m_document
librevenge::RVNGTextInterface *const m_document
Definition: LRFCollector.h:90
libebook::LRFCollector::ImageData
Definition: LRFCollector.h:35
libebook::LRFCollector::ImageStreamData::image
librevenge::RVNGInputStream * image
Definition: LRFCollector.h:30
libebook::LRFCollector::collectParagraphAttributes
void collectParagraphAttributes(unsigned id, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:443
libebook::LRFCollector::ImageData::width
unsigned width
Definition: LRFCollector.h:38
libebook::LRFCollector::collectText
void collectText(const std::string &text, const LRFAttributes &attributes)
Definition: LRFCollector.cpp:399
libebook::LRFCollector::ImageData::height
unsigned height
Definition: LRFCollector.h:39
libebook::LRFAttributeMap_t
std::map< unsigned, LRFAttributes > LRFAttributeMap_t
Definition: LRFTypes.h:142