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 
25 namespace libepubgen
26 {
27 
28 class EPUBManifest;
29 class EPUBPackage;
30 class EPUBCSSContent;
31 
33 {
34  // disable copying
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 
51 public:
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 
67 private:
69  void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
70 
76 };
77 
78 }
79 
80 #endif // INCLUDED_EPUBIMAGEMANAGER
81 
82 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
MapType_t m_map
Definition: EPUBImageManager.h:72
Definition: EPUBCSSContent.h:23
void send(EPUBCSSContent &out)
send the data to the sink
Definition: EPUBImageManager.cpp:203
Definition: EPUBBinaryContent.cpp:14
std::unordered_map< librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual > MapType_t
Definition: EPUBImageManager.h:48
void writeTo(EPUBPackage &package)
Definition: EPUBImageManager.cpp:103
std::string getFrameClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBImageManager.cpp:113
bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const
Definition: EPUBImageManager.cpp:61
Definition: EPUBImageManager.h:43
Definition: EPUBManifest.h:23
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition: EPUBImageManager.h:49
EPUBImageManager(const EPUBImageManager &)
std::map< std::string, std::string > EPUBCSSProperties
Definition: EPUBCSSProperties.h:21
Representation of a path in the package.
Definition: EPUBPath.h:21
static std::string getWrapStyle(librevenge::RVNGPropertyList const &pList)
returns the style for a follow-up element, based on wrapping properties.
Definition: EPUBImageManager.cpp:174
const EPUBPath & insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="")
Definition: EPUBImageManager.cpp:79
std::string getFrameStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBImageManager.cpp:126
ContentNameMap_t m_imageContentNameMap
a map image content -> name
Definition: EPUBImageManager.h:75
void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBImageManager.cpp:137
EPUBManifest & m_manifest
Definition: EPUBImageManager.h:71
EPUBCounter m_number
Definition: EPUBImageManager.h:73
Definition: EPUBCounter.h:16
EPUBImageManager & operator=(const EPUBImageManager &)
Definition: EPUBImageManager.h:38
std::size_t operator()(const librevenge::RVNGBinaryData &data) const
Definition: EPUBImageManager.cpp:50
Definition: EPUBImageManager.h:32

Generated for libepubgen by doxygen 1.8.14