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
23namespace libepubgen
24{
25
26class EPUBManifest;
27class EPUBPackage;
28class EPUBCSSSink;
29
31{
32 // disable copying
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
49public:
51
52 const EPUBPath &insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="");
53
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
65private:
67 void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
68
74};
75
78{
79 // disable copying
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
96public:
98
99 void insert(const librevenge::RVNGPropertyList &propertyList, const EPUBPath &path);
100
102
104 void send(EPUBCSSSink &out);
105
106private:
108 void extractFontProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
109
116};
117
118}
119
120#endif // INCLUDED_EPUBIMAGEMANAGER
121
122/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition EPUBCSSSink.h:24
Definition EPUBCounter.h:17
Manages embedded fonts.
Definition EPUBImageManager.h:78
void send(EPUBCSSSink &out)
send the data to the sink
Definition EPUBImageManager.cpp:312
EPUBCounter m_number
Definition EPUBImageManager.h:113
EPUBFontManager & operator=(const EPUBFontManager &)
EPUBManifest & m_manifest
Definition EPUBImageManager.h:110
void writeTo(EPUBPackage &package)
Definition EPUBImageManager.cpp:302
void insert(const librevenge::RVNGPropertyList &propertyList, const EPUBPath &path)
Definition EPUBImageManager.cpp:244
MapType_t m_map
Font filename -> content map.
Definition EPUBImageManager.h:112
EPUBFontManager(const EPUBFontManager &)
SetType_t m_set
Set of font properties.
Definition EPUBImageManager.h:115
std::unordered_set< EPUBCSSProperties, boost::hash< EPUBCSSProperties > > SetType_t
Definition EPUBImageManager.h:94
void extractFontProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition EPUBImageManager.cpp:286
std::unordered_map< librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual > MapType_t
Definition EPUBImageManager.h:93
Definition EPUBImageManager.h:31
void send(EPUBCSSSink &out)
send the data to the sink
Definition EPUBImageManager.cpp:205
ContentNameMap_t m_imageContentNameMap
a map image content -> name
Definition EPUBImageManager.h:73
std::string getFrameClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition EPUBImageManager.cpp:121
void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition EPUBImageManager.cpp:145
MapType_t m_map
Definition EPUBImageManager.h:70
const EPUBPath & insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="")
Definition EPUBImageManager.cpp:87
EPUBImageManager & operator=(const EPUBImageManager &)
EPUBImageManager(const EPUBImageManager &)
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition EPUBImageManager.h:47
void writeTo(EPUBPackage &package)
Definition EPUBImageManager.cpp:111
EPUBCounter m_number
Definition EPUBImageManager.h:71
std::unordered_map< librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual > MapType_t
Definition EPUBImageManager.h:46
EPUBManifest & m_manifest
Definition EPUBImageManager.h:69
static std::string getWrapStyle(librevenge::RVNGPropertyList const &pList)
returns the style for a follow-up element, based on wrapping properties.
Definition EPUBImageManager.cpp:176
std::string getFrameStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition EPUBImageManager.cpp:134
Definition EPUBManifest.h:24
Representation of a path in the package.
Definition EPUBPath.h:22
Definition EPUBBinarySink.cpp:13
std::map< std::string, std::string > EPUBCSSProperties
Definition EPUBCSSProperties.h:21
std::unique_ptr< T > make_unique(Args &&... args)
Definition libepubgen_utils.h:60
Definition EPUBImageManager.h:89
bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const
Definition EPUBImageManager.cpp:226
Definition EPUBImageManager.h:84
std::size_t operator()(const librevenge::RVNGBinaryData &data) const
Definition EPUBImageManager.cpp:215
Definition EPUBImageManager.h:42
bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const
Definition EPUBImageManager.cpp:69
Definition EPUBImageManager.h:37
std::size_t operator()(const librevenge::RVNGBinaryData &data) const
Definition EPUBImageManager.cpp:58

Generated for libepubgen by doxygen 1.9.8