BBeBCollector.h Source File documentation

BBeBCollector.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 BBEBCOLLECTOR_H_INCLUDED
11 #define BBEBCOLLECTOR_H_INCLUDED
12
13 #include <string>
14 #include <stack>
15
16 #include "BBeBTypes.h"
17 #include "libebook_utils.h"
18
19 namespace libebook
20 {
21
22 class BBeBCollector
23 {
24 // -Weffc++
25 BBeBCollector(const BBeBCollector &other);
26 BBeBCollector &operator=(const BBeBCollector &other);
27
28 struct ImageStreamData
29 {
30 ImageStreamData();
31
32 RVNGInputStreamPtr_t image;
33 BBeBImageType type;
34 };
35 typedef std::map<unsigned, ImageStreamData> ImageDataMap_t;
36
37 struct ImageData
38 {
39 unsigned dataId;
40 unsigned width;
41 unsigned height;
42 };
43 typedef std::map<unsigned, ImageData> ImageMap_t;
44
45 public:
46 explicit BBeBCollector(librevenge::RVNGTextInterface *document);
47 ~BBeBCollector();
48
49 void startDocument();
50 void endDocument();
51
52 void openPage(unsigned pageAtrID, const BBeBAttributes &attributes);
53 void closePage();
54
55 void openBlock(unsigned atrID, const BBeBAttributes &attributes);
56 void closeBlock();
57
58 void openTextBlock(unsigned atrID, const BBeBAttributes &attributes);
59 void closeTextBlock();
60
61 void openParagraph(unsigned atrID, const BBeBAttributes &attributes);
62 void closeParagraph();
63
64 void collectText(const std::string &text, const BBeBAttributes &attributes);
65 void insertLineBreak();
66
67 void insertImage(unsigned id);
68
69 void collectMetadata(const BBeBMetadata &metadata);
70
71 void collectBookAttributes(const BBeBAttributes &attributes);
72 void collectTextAttributes(unsigned id, const BBeBAttributes &attributes);
73 void collectBlockAttributes(unsigned id, const BBeBAttributes &attributes);
74 void collectPageAttributes(unsigned id, const BBeBAttributes &attributes);
75 void collectParagraphAttributes(unsigned id, const BBeBAttributes &attributes);
76
77 void collectImage(unsigned id, unsigned dataId, unsigned width, unsigned height);
78 void collectImageData(unsigned id, BBeBImageType type, const RVNGInputStreamPtr_t &image);
79
80 void setDPI(double dpi);
81
82 private:
83 void collectAttributes(unsigned id, const BBeBAttributes &attributes, BBeBAttributeMap_t &attributeMap);
84 void openBlock(unsigned atrID, const BBeBAttributes &attributes, const BBeBAttributeMap_t *attributeMap);
85
86 private:
87 BBeBAttributes m_bookAttributes;
88 BBeBAttributeMap_t m_textAttributeMap;
89 BBeBAttributeMap_t m_blockAttributeMap;
90 BBeBAttributeMap_t m_pageAttributeMap;
91 BBeBAttributeMap_t m_paragraphAttributeMap;
92 librevenge::RVNGTextInterface *const m_document;
93 std::stack<BBeBAttributes> m_currentAttributes;
94 ImageDataMap_t m_imageDataMap;
95 ImageMap_t m_imageMap;
96 double m_dpi;
97 bool m_firstParaInBlock;
98 };
99
100 }
101
102 #endif // BBEBCOLLECTOR_H_INCLUDED
103
104 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libebook::BBeBCollector::collectParagraphAttributes
void collectParagraphAttributes(unsigned id, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:450
libebook::BBeBCollector::collectBookAttributes
void collectBookAttributes(const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:430
libebook::BBeBCollector::m_currentAttributes
std::stack< BBeBAttributes > m_currentAttributes
Definition: BBeBCollector.h:93
libebook::BBeBCollector::collectAttributes
void collectAttributes(unsigned id, const BBeBAttributes &attributes, BBeBAttributeMap_t &attributeMap)
Definition: BBeBCollector.cpp:562
libebook::BBeBCollector::collectImageData
void collectImageData(unsigned id, BBeBImageType type, const RVNGInputStreamPtr_t &image)
Definition: BBeBCollector.cpp:550
libebook::BBeBCollector::ImageStreamData::type
BBeBImageType type
Definition: BBeBCollector.h:33
libebook::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition: libebook_utils.h:54
libebook::BBeBCollector::collectText
void collectText(const std::string &text, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:406
libebook::BBeBImageType
BBeBImageType
Definition: BBeBTypes.h:22
libebook::EBOOKHTMLToken::width
Definition: EBOOKHTMLToken.h:265
libebook::BBeBCollector::m_firstParaInBlock
bool m_firstParaInBlock
Definition: BBeBCollector.h:97
libebook::BBeBCollector::ImageStreamData::ImageStreamData
ImageStreamData()
Definition: BBeBCollector.cpp:313
libebook::BBeBCollector::openPage
void openPage(unsigned pageAtrID, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:350
libebook::BBeBCollector::m_imageDataMap
ImageDataMap_t m_imageDataMap
Definition: BBeBCollector.h:94
libebook::BBeBCollector::closeBlock
void closeBlock()
Definition: BBeBCollector.cpp:367
libebook::BBeBCollector::ImageStreamData::image
RVNGInputStreamPtr_t image
Definition: BBeBCollector.h:32
libebook::BBeBCollector::endDocument
void endDocument()
Definition: BBeBCollector.cpp:344
libebook::BBeBCollector::openParagraph
void openParagraph(unsigned atrID, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:383
libebook::BBeBCollector::operator=
BBeBCollector & operator=(const BBeBCollector &other)
libebook::BBeBCollector::m_imageMap
ImageMap_t m_imageMap
Definition: BBeBCollector.h:95
libebook::BBeBCollector::insertImage
void insertImage(unsigned id)
Definition: BBeBCollector.cpp:475
libebook::BBeBCollector::m_document
librevenge::RVNGTextInterface *const m_document
Definition: BBeBCollector.h:92
libebook_utils.h
libebook::BBeBCollector::m_pageAttributeMap
BBeBAttributeMap_t m_pageAttributeMap
Definition: BBeBCollector.h:90
libebook::BBeBCollector::m_paragraphAttributeMap
BBeBAttributeMap_t m_paragraphAttributeMap
Definition: BBeBCollector.h:91
libebook::BBeBCollector::ImageData::width
unsigned width
Definition: BBeBCollector.h:40
libebook::BBeBAttributeMap_t
std::map< unsigned, BBeBAttributes > BBeBAttributeMap_t
Definition: BBeBTypes.h:142
libebook::BBeBCollector::openTextBlock
void openTextBlock(unsigned atrID, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:372
libebook::BBeBCollector::m_blockAttributeMap
BBeBAttributeMap_t m_blockAttributeMap
Definition: BBeBCollector.h:89
libebook::BBeBCollector::m_dpi
double m_dpi
Definition: BBeBCollector.h:96
libebook::BBeBCollector::m_bookAttributes
BBeBAttributes m_bookAttributes
Definition: BBeBCollector.h:87
libebook::BBeBCollector::closeParagraph
void closeParagraph()
Definition: BBeBCollector.cpp:400
BBeBTypes.h
libebook::BBeBCollector::collectMetadata
void collectMetadata(const BBeBMetadata &metadata)
Definition: BBeBCollector.cpp:420
libebook::BBeBCollector::m_textAttributeMap
BBeBAttributeMap_t m_textAttributeMap
Definition: BBeBCollector.h:88
libebook::BBeBCollector::startDocument
void startDocument()
Definition: BBeBCollector.cpp:338
libebook::EBOOKHTMLToken::height
Definition: EBOOKHTMLToken.h:198
libebook::BBeBAttributes
Definition: BBeBTypes.h:108
metadata
RVNGPropertyList metadata
Definition: EBOOKOPFParser.cpp:63
libebook::BBeBCollector::ImageData::dataId
unsigned dataId
Definition: BBeBCollector.h:39
libebook::BBeBCollector::collectImage
void collectImage(unsigned id, unsigned dataId, unsigned width, unsigned height)
Definition: BBeBCollector.cpp:455
libebook::BBeBCollector::collectTextAttributes
void collectTextAttributes(unsigned id, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:435
libebook::BBeBCollector::setDPI
void setDPI(double dpi)
Definition: BBeBCollector.cpp:590
libebook::BBeBCollector::ImageData
Definition: BBeBCollector.h:37
libebook::BBeBCollector::ImageData::height
unsigned height
Definition: BBeBCollector.h:41
libebook::BBeBCollector::closeTextBlock
void closeTextBlock()
Definition: BBeBCollector.cpp:378
libebook::BBeBCollector::ImageMap_t
std::map< unsigned, ImageData > ImageMap_t
Definition: BBeBCollector.h:43
libebook::BBeBCollector
Definition: BBeBCollector.h:22
libebook::BBeBCollector::ImageDataMap_t
std::map< unsigned, ImageStreamData > ImageDataMap_t
Definition: BBeBCollector.h:35
document
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:163
libebook::BBeBCollector::insertLineBreak
void insertLineBreak()
Definition: BBeBCollector.cpp:415
libebook::BBeBMetadata
Definition: BBeBTypes.h:79
libebook::BBeBCollector::closePage
void closePage()
Definition: BBeBCollector.cpp:356
libebook::BBeBCollector::openBlock
void openBlock(unsigned atrID, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:362
libebook::BBeBCollector::ImageStreamData
Definition: BBeBCollector.h:28
libebook
Definition: BBeBCollector.cpp:18
libebook::BBeBCollector::BBeBCollector
BBeBCollector(const BBeBCollector &other)
text
qi::rule< Iterator, AttrValue_t, qi::space_type > text
Definition: TealDocParser.cpp:232
libebook::BBeBCollector::~BBeBCollector
~BBeBCollector()
Definition: BBeBCollector.cpp:334
libebook::BBeBCollector::collectBlockAttributes
void collectBlockAttributes(unsigned id, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:440
libebook::BBeBCollector::collectPageAttributes
void collectPageAttributes(unsigned id, const BBeBAttributes &attributes)
Definition: BBeBCollector.cpp:445