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 <string>
14#include <unordered_map>
15#include <unordered_set>
16
17#include <boost/functional/hash.hpp>
18
19#include <librevenge/librevenge.h>
20
21#include "EPUBCSSProperties.h"
22#include "EPUBCounter.h"
23#include "EPUBPath.h"
24
25namespace libepubgen
26{
27
28class EPUBManifest;
29class EPUBPackage;
30class EPUBCSSContent;
31
32 class EPUBImageManager
33{
34 // disable copying
35 EPUBImageManager(const EPUBImageManager &);
36 EPUBImageManager &operator=(const EPUBImageManager &);
37
38 struct BinaryDataHash // : public std::unary_function<librevenge::RVNGBinaryData, std::size_t>
39 {
40 std::size_t operator()(const librevenge::RVNGBinaryData &data) const;
41 };
42
43 struct BinaryDataEqual // : public std::binary_function<librevenge::RVNGBinaryData, librevenge::RVNGBinaryData, bool>
44 {
45 bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const;
46 };
47
48 typedef std::unordered_map<librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual> MapType_t;
49 typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
50
51public:
52 explicit EPUBImageManager(EPUBManifest &manifest);
53
54 const EPUBPath &insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="");
55
56 void writeTo(EPUBPackage &package);
57
59 std::string getFrameClass(librevenge::RVNGPropertyList const &pList);
61 std::string getFrameStyle(librevenge::RVNGPropertyList const &pList);
63 static std::string getWrapStyle(librevenge::RVNGPropertyList const &pList);
65 void send(EPUBCSSContent &out);
66
67private:
69 void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
70
71 EPUBManifest &m_manifest;
72 MapType_t m_map;
73 EPUBCounter m_number;
75 ContentNameMap_t m_imageContentNameMap;
76};
77
78}
79
80#endif // INCLUDED_EPUBIMAGEMANAGER
81
82/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
EPUBCSSProperties.h
EPUBCounter.h
EPUBPath.h
libepubgen::EPUBCSSContent
Definition: EPUBCSSContent.h:24
libepubgen::EPUBCounter
Definition: EPUBCounter.h:17
libepubgen::EPUBImageManager
Definition: EPUBImageManager.h:33
libepubgen::EPUBImageManager::m_imageContentNameMap
ContentNameMap_t m_imageContentNameMap
a map image content -> name
Definition: EPUBImageManager.h:75
libepubgen::EPUBImageManager::getFrameClass
std::string getFrameClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBImageManager.cpp:113
libepubgen::EPUBImageManager::extractImageProperties
void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBImageManager.cpp:137
libepubgen::EPUBImageManager::m_map
MapType_t m_map
Definition: EPUBImageManager.h:72
libepubgen::EPUBImageManager::insert
const EPUBPath & insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="")
Definition: EPUBImageManager.cpp:79
libepubgen::EPUBImageManager::operator=
EPUBImageManager & operator=(const EPUBImageManager &)
libepubgen::EPUBImageManager::EPUBImageManager
EPUBImageManager(const EPUBImageManager &)
libepubgen::EPUBImageManager::send
void send(EPUBCSSContent &out)
send the data to the sink
Definition: EPUBImageManager.cpp:203
libepubgen::EPUBImageManager::ContentNameMap_t
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition: EPUBImageManager.h:49
libepubgen::EPUBImageManager::writeTo
void writeTo(EPUBPackage &package)
Definition: EPUBImageManager.cpp:103
libepubgen::EPUBImageManager::m_number
EPUBCounter m_number
Definition: EPUBImageManager.h:73
libepubgen::EPUBImageManager::MapType_t
std::unordered_map< librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual > MapType_t
Definition: EPUBImageManager.h:48
libepubgen::EPUBImageManager::m_manifest
EPUBManifest & m_manifest
Definition: EPUBImageManager.h:71
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:174
libepubgen::EPUBImageManager::getFrameStyle
std::string getFrameStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBImageManager.cpp:126
libepubgen::EPUBManifest
Definition: EPUBManifest.h:24
libepubgen::EPUBPath
Representation of a path in the package.
Definition: EPUBPath.h:22
libepubgen
Definition: EPUBBinaryContent.cpp:15
libepubgen::EPUBCSSProperties
std::map< std::string, std::string > EPUBCSSProperties
Definition: EPUBCSSProperties.h:21
libepubgen::EPUBImageManager::BinaryDataEqual
Definition: EPUBImageManager.h:44
libepubgen::EPUBImageManager::BinaryDataEqual::operator()
bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const
Definition: EPUBImageManager.cpp:61
libepubgen::EPUBImageManager::BinaryDataHash
Definition: EPUBImageManager.h:39
libepubgen::EPUBImageManager::BinaryDataHash::operator()
std::size_t operator()(const librevenge::RVNGBinaryData &data) const
Definition: EPUBImageManager.cpp:50