EPUBImageManager.h Source File documentation

EPUBImageManager.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 libepubgen 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 INCLUDED_EPUBIMAGEMANAGER_H
11 #define INCLUDED_EPUBIMAGEMANAGER_H
12
13 #include <unordered_map>
14 #include <unordered_set>
15
16 #include <boost/functional/hash.hpp>
17 #include <librevenge/librevenge.h>
18
19 #include "EPUBCSSProperties.h"
20 #include "EPUBCounter.h"
21 #include "EPUBPath.h"
22
23 namespace libepubgen
24 {
25
26 class EPUBManifest;
27 class EPUBPackage;
28 class EPUBCSSSink;
29
30 class EPUBImageManager
31 {
32 // disable copying
33 EPUBImageManager(const EPUBImageManager &);
34 EPUBImageManager &operator=(const EPUBImageManager &);
35
36 struct BinaryDataHash // : public std::unary_function<librevenge::RVNGBinaryData, std::size_t>
37 {
38 std::size_t operator()(const librevenge::RVNGBinaryData &data) const;
39 };
40
41 struct BinaryDataEqual // : public std::binary_function<librevenge::RVNGBinaryData, librevenge::RVNGBinaryData, bool>
42 {
43 bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const;
44 };
45
46 typedef std::unordered_map<librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual> MapType_t;
47 typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
48
49 public:
50 explicit EPUBImageManager(EPUBManifest &manifest);
51
52 const EPUBPath &insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="");
53
54 void writeTo(EPUBPackage &package);
55
57 std::string getFrameClass(librevenge::RVNGPropertyList const &pList);
59 std::string getFrameStyle(librevenge::RVNGPropertyList const &pList);
61 static std::string getWrapStyle(librevenge::RVNGPropertyList const &pList);
63 void send(EPUBCSSSink &out);
64
65 private:
67 void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
68
69 EPUBManifest &m_manifest;
70 MapType_t m_map;
71 EPUBCounter m_number;
73 ContentNameMap_t m_imageContentNameMap;
74 };
75
77 class EPUBFontManager
78 {
79 // disable copying
80 EPUBFontManager(const EPUBFontManager &);
81 EPUBFontManager &operator=(const EPUBFontManager &);
82
83 struct BinaryDataHash // : public std::unary_function<librevenge::RVNGBinaryData, std::size_t>
84 {
85 std::size_t operator()(const librevenge::RVNGBinaryData &data) const;
86 };
87
88 struct BinaryDataEqual // : public std::binary_function<librevenge::RVNGBinaryData, librevenge::RVNGBinaryData, bool>
89 {
90 bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const;
91 };
92
93 typedef std::unordered_map<librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual> MapType_t;
94 typedef std::unordered_set<EPUBCSSProperties, boost::hash<EPUBCSSProperties>> SetType_t;
95
96 public:
97 explicit EPUBFontManager(EPUBManifest &manifest);
98
99 void insert(const librevenge::RVNGPropertyList &propertyList, const EPUBPath &path);
100
101 void writeTo(EPUBPackage &package);
102
104 void send(EPUBCSSSink &out);
105
106 private:
108 void extractFontProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
109
110 EPUBManifest &m_manifest;
112 MapType_t m_map;
113 EPUBCounter m_number;
115 SetType_t m_set;
116 };
117
118 }
119
120 #endif // INCLUDED_EPUBIMAGEMANAGER
121
122 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
EPUBCounter.h
libepubgen::EPUBCSSSink
Definition: EPUBCSSSink.h:23
libepubgen::EPUBImageManager::m_map
MapType_t m_map
Definition: EPUBImageManager.h:70
libepubgen::EPUBFontManager::m_number
EPUBCounter m_number
Definition: EPUBImageManager.h:113
libepubgen
Definition: EPUBBinarySink.cpp:12
libepubgen::EPUBFontManager::extractFontProperties
void extractFontProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBImageManager.cpp:286
libepubgen::EPUBImageManager::send
void send(EPUBCSSSink &out)
send the data to the sink
Definition: EPUBImageManager.cpp:205
libepubgen::EPUBImageManager::MapType_t
std::unordered_map< librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual > MapType_t
Definition: EPUBImageManager.h:46
libepubgen::EPUBFontManager::writeTo
void writeTo(EPUBPackage &package)
Definition: EPUBImageManager.cpp:302
libepubgen::EPUBImageManager::writeTo
void writeTo(EPUBPackage &package)
Definition: EPUBImageManager.cpp:111
libepubgen::EPUBFontManager::operator=
EPUBFontManager & operator=(const EPUBFontManager &)
libepubgen::EPUBImageManager::getFrameClass
std::string getFrameClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBImageManager.cpp:121
libepubgen::EPUBFontManager::insert
void insert(const librevenge::RVNGPropertyList &propertyList, const EPUBPath &path)
Definition: EPUBImageManager.cpp:244
libepubgen::EPUBImageManager::BinaryDataEqual::operator()
bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const
Definition: EPUBImageManager.cpp:69
libepubgen::EPUBImageManager::BinaryDataEqual
Definition: EPUBImageManager.h:41
libepubgen::EPUBFontManager::m_manifest
EPUBManifest & m_manifest
Definition: EPUBImageManager.h:110
libepubgen::EPUBFontManager::SetType_t
std::unordered_set< EPUBCSSProperties, boost::hash< EPUBCSSProperties > > SetType_t
Definition: EPUBImageManager.h:94
EPUBCSSProperties.h
libepubgen::EPUBFontManager::BinaryDataEqual::operator()
bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const
Definition: EPUBImageManager.cpp:226
libepubgen::EPUBFontManager
Manages embedded fonts.
Definition: EPUBImageManager.h:77
libepubgen::EPUBManifest
Definition: EPUBManifest.h:23
libepubgen::EPUBImageManager::ContentNameMap_t
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition: EPUBImageManager.h:47
libepubgen::EPUBImageManager::EPUBImageManager
EPUBImageManager(const EPUBImageManager &)
libepubgen::EPUBFontManager::BinaryDataEqual
Definition: EPUBImageManager.h:88
libepubgen::EPUBFontManager::EPUBFontManager
EPUBFontManager(const EPUBFontManager &)
EPUBPath.h
libepubgen::EPUBCSSProperties
std::map< std::string, std::string > EPUBCSSProperties
Definition: EPUBCSSProperties.h:21
libepubgen::EPUBFontManager::send
void send(EPUBCSSSink &out)
send the data to the sink
Definition: EPUBImageManager.cpp:312
libepubgen::EPUBPath
Representation of a path in the package.
Definition: EPUBPath.h:21
libepubgen::EPUBFontManager::MapType_t
std::unordered_map< librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual > MapType_t
Definition: EPUBImageManager.h:93
libepubgen::EPUBImageManager::getWrapStyle
static std::string getWrapStyle(librevenge::RVNGPropertyList const &pList)
returns the style for a follow-up element, based on wrapping properties.
Definition: EPUBImageManager.cpp:176
libepubgen::EPUBImageManager::insert
const EPUBPath & insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="")
Definition: EPUBImageManager.cpp:87
libepubgen::EPUBImageManager::getFrameStyle
std::string getFrameStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBImageManager.cpp:134
libepubgen::EPUBImageManager::m_imageContentNameMap
ContentNameMap_t m_imageContentNameMap
a map image content -> name
Definition: EPUBImageManager.h:73
libepubgen::EPUBImageManager::extractImageProperties
void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBImageManager.cpp:145
libepubgen::EPUBFontManager::BinaryDataHash::operator()
std::size_t operator()(const librevenge::RVNGBinaryData &data) const
Definition: EPUBImageManager.cpp:215
libepubgen::EPUBFontManager::m_set
SetType_t m_set
Set of font properties.
Definition: EPUBImageManager.h:115
libepubgen::EPUBImageManager::m_manifest
EPUBManifest & m_manifest
Definition: EPUBImageManager.h:69
libepubgen::EPUBImageManager::m_number
EPUBCounter m_number
Definition: EPUBImageManager.h:71
libepubgen::EPUBCounter
Definition: EPUBCounter.h:16
libepubgen::EPUBImageManager::operator=
EPUBImageManager & operator=(const EPUBImageManager &)
libepubgen::EPUBFontManager::m_map
MapType_t m_map
Font filename -> content map.
Definition: EPUBImageManager.h:112
libepubgen::EPUBFontManager::BinaryDataHash
Definition: EPUBImageManager.h:83
libepubgen::EPUBImageManager::BinaryDataHash
Definition: EPUBImageManager.h:36
libepubgen::EPUBImageManager::BinaryDataHash::operator()
std::size_t operator()(const librevenge::RVNGBinaryData &data) const
Definition: EPUBImageManager.cpp:58
libepubgen::EPUBImageManager
Definition: EPUBImageManager.h:30