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
19namespace 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
45public:
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
82private:
83 void collectAttributes(unsigned id, const BBeBAttributes &attributes, BBeBAttributeMap_t &attributeMap);
84 void openBlock(unsigned atrID, const BBeBAttributes &attributes, const BBeBAttributeMap_t *attributeMap);
85
86private:
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: */
BBeBTypes.h
libebook::BBeBCollector::setDPI
void setDPI(double dpi)
Definition BBeBCollector.cpp:591
libebook::BBeBCollector::openPage
void openPage(unsigned pageAtrID, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:351
libebook::BBeBCollector::m_bookAttributes
BBeBAttributes m_bookAttributes
Definition BBeBCollector.h:87
libebook::BBeBCollector::collectParagraphAttributes
void collectParagraphAttributes(unsigned id, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:451
libebook::BBeBCollector::~BBeBCollector
~BBeBCollector()
Definition BBeBCollector.cpp:335
libebook::BBeBCollector::ImageMap_t
std::map< unsigned, ImageData > ImageMap_t
Definition BBeBCollector.h:43
libebook::BBeBCollector::collectMetadata
void collectMetadata(const BBeBMetadata &metadata)
Definition BBeBCollector.cpp:421
libebook::BBeBCollector::m_pageAttributeMap
BBeBAttributeMap_t m_pageAttributeMap
Definition BBeBCollector.h:90
libebook::BBeBCollector::m_firstParaInBlock
bool m_firstParaInBlock
Definition BBeBCollector.h:97
libebook::BBeBCollector::operator=
BBeBCollector & operator=(const BBeBCollector &other)
libebook::BBeBCollector::openTextBlock
void openTextBlock(unsigned atrID, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:373
libebook::BBeBCollector::m_currentAttributes
std::stack< BBeBAttributes > m_currentAttributes
Definition BBeBCollector.h:93
libebook::BBeBCollector::closeBlock
void closeBlock()
Definition BBeBCollector.cpp:368
libebook::BBeBCollector::collectPageAttributes
void collectPageAttributes(unsigned id, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:446
libebook::BBeBCollector::endDocument
void endDocument()
Definition BBeBCollector.cpp:345
libebook::BBeBCollector::startDocument
void startDocument()
Definition BBeBCollector.cpp:339
libebook::BBeBCollector::m_paragraphAttributeMap
BBeBAttributeMap_t m_paragraphAttributeMap
Definition BBeBCollector.h:91
libebook::BBeBCollector::collectTextAttributes
void collectTextAttributes(unsigned id, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:436
libebook::BBeBCollector::insertImage
void insertImage(unsigned id)
Definition BBeBCollector.cpp:476
libebook::BBeBCollector::collectBookAttributes
void collectBookAttributes(const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:431
libebook::BBeBCollector::m_textAttributeMap
BBeBAttributeMap_t m_textAttributeMap
Definition BBeBCollector.h:88
libebook::BBeBCollector::collectImageData
void collectImageData(unsigned id, BBeBImageType type, const RVNGInputStreamPtr_t &image)
Definition BBeBCollector.cpp:551
libebook::BBeBCollector::closeParagraph
void closeParagraph()
Definition BBeBCollector.cpp:401
libebook::BBeBCollector::m_imageDataMap
ImageDataMap_t m_imageDataMap
Definition BBeBCollector.h:94
libebook::BBeBCollector::insertLineBreak
void insertLineBreak()
Definition BBeBCollector.cpp:416
libebook::BBeBCollector::collectText
void collectText(const std::string &text, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:407
libebook::BBeBCollector::collectBlockAttributes
void collectBlockAttributes(unsigned id, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:441
libebook::BBeBCollector::m_dpi
double m_dpi
Definition BBeBCollector.h:96
libebook::BBeBCollector::collectAttributes
void collectAttributes(unsigned id, const BBeBAttributes &attributes, BBeBAttributeMap_t &attributeMap)
Definition BBeBCollector.cpp:563
libebook::BBeBCollector::m_document
librevenge::RVNGTextInterface *const m_document
Definition BBeBCollector.h:92
libebook::BBeBCollector::m_imageMap
ImageMap_t m_imageMap
Definition BBeBCollector.h:95
libebook::BBeBCollector::openBlock
void openBlock(unsigned atrID, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:363
libebook::BBeBCollector::collectImage
void collectImage(unsigned id, unsigned dataId, unsigned width, unsigned height)
Definition BBeBCollector.cpp:456
libebook::BBeBCollector::BBeBCollector
BBeBCollector(const BBeBCollector &other)
libebook::BBeBCollector::closeTextBlock
void closeTextBlock()
Definition BBeBCollector.cpp:379
libebook::BBeBCollector::ImageDataMap_t
std::map< unsigned, ImageStreamData > ImageDataMap_t
Definition BBeBCollector.h:35
libebook::BBeBCollector::openParagraph
void openParagraph(unsigned atrID, const BBeBAttributes &attributes)
Definition BBeBCollector.cpp:384
libebook::BBeBCollector::m_blockAttributeMap
BBeBAttributeMap_t m_blockAttributeMap
Definition BBeBCollector.h:89
libebook::BBeBCollector::closePage
void closePage()
Definition BBeBCollector.cpp:357
libebook_utils.h
libebook::EBOOKHTMLToken::type
@ type
Definition EBOOKHTMLToken.h:258
libebook::EBOOKHTMLToken::width
@ width
Definition EBOOKHTMLToken.h:265
libebook::EBOOKHTMLToken::text
@ text
Definition EBOOKHTMLToken.h:257
libebook::EBOOKHTMLToken::height
@ height
Definition EBOOKHTMLToken.h:198
libebook::EBOOKOPFToken::metadata
@ metadata
Definition EBOOKOPFToken.h:62
libebook::FictionBook2Token::image
@ image
Definition FictionBook2Token.h:60
libebook
Definition BBeBCollector.cpp:20
libebook::BBeBImageType
BBeBImageType
Definition BBeBTypes.h:23
libebook::BBeBAttributeMap_t
std::map< unsigned, BBeBAttributes > BBeBAttributeMap_t
Definition BBeBTypes.h:142
libebook::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libebook_utils.h:54
libebook::BBeBAttributes
Definition BBeBTypes.h:109
libebook::BBeBCollector::ImageData
Definition BBeBCollector.h:38
libebook::BBeBCollector::ImageData::height
unsigned height
Definition BBeBCollector.h:41
libebook::BBeBCollector::ImageData::dataId
unsigned dataId
Definition BBeBCollector.h:39
libebook::BBeBCollector::ImageData::width
unsigned width
Definition BBeBCollector.h:40
libebook::BBeBCollector::ImageStreamData::ImageStreamData
ImageStreamData()
Definition BBeBCollector.cpp:314
libebook::BBeBCollector::ImageStreamData::image
RVNGInputStreamPtr_t image
Definition BBeBCollector.h:32
libebook::BBeBCollector::ImageStreamData::type
BBeBImageType type
Definition BBeBCollector.h:33
libebook::BBeBMetadata
Definition BBeBTypes.h:80