Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef INCLUDED_EPUBIMAGEMANAGER_H
00011 #define INCLUDED_EPUBIMAGEMANAGER_H
00012
00013 #include <unordered_map>
00014 #include <unordered_set>
00015
00016 #include <boost/functional/hash.hpp>
00017 #include <librevenge/librevenge.h>
00018
00019 #include "EPUBCSSProperties.h"
00020 #include "EPUBCounter.h"
00021 #include "EPUBPath.h"
00022
00023 namespace libepubgen
00024 {
00025
00026 class EPUBManifest;
00027 class EPUBPackage;
00028 class EPUBCSSSink;
00029
00030 class EPUBImageManager
00031 {
00032
00033 EPUBImageManager(const EPUBImageManager &);
00034 EPUBImageManager &operator=(const EPUBImageManager &);
00035
00036 struct BinaryDataHash
00037 {
00038 std::size_t operator()(const librevenge::RVNGBinaryData &data) const;
00039 };
00040
00041 struct BinaryDataEqual
00042 {
00043 bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const;
00044 };
00045
00046 typedef std::unordered_map<librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual> MapType_t;
00047 typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
00048
00049 public:
00050 explicit EPUBImageManager(EPUBManifest &manifest);
00051
00052 const EPUBPath &insert(const librevenge::RVNGBinaryData &data, const librevenge::RVNGString &mimetype, const librevenge::RVNGString &properties="");
00053
00054 void writeTo(EPUBPackage &package);
00055
00057 std::string getFrameClass(librevenge::RVNGPropertyList const &pList);
00059 std::string getFrameStyle(librevenge::RVNGPropertyList const &pList);
00061 static std::string getWrapStyle(librevenge::RVNGPropertyList const &pList);
00063 void send(EPUBCSSSink &out);
00064
00065 private:
00067 void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
00068
00069 EPUBManifest &m_manifest;
00070 MapType_t m_map;
00071 EPUBCounter m_number;
00073 ContentNameMap_t m_imageContentNameMap;
00074 };
00075
00077 class EPUBFontManager
00078 {
00079
00080 EPUBFontManager(const EPUBFontManager &);
00081 EPUBFontManager &operator=(const EPUBFontManager &);
00082
00083 struct BinaryDataHash
00084 {
00085 std::size_t operator()(const librevenge::RVNGBinaryData &data) const;
00086 };
00087
00088 struct BinaryDataEqual
00089 {
00090 bool operator()(const librevenge::RVNGBinaryData &left, const librevenge::RVNGBinaryData &right) const;
00091 };
00092
00093 typedef std::unordered_map<librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual> MapType_t;
00094 typedef std::unordered_set<EPUBCSSProperties, boost::hash<EPUBCSSProperties>> SetType_t;
00095
00096 public:
00097 explicit EPUBFontManager(EPUBManifest &manifest);
00098
00099 void insert(const librevenge::RVNGPropertyList &propertyList, const EPUBPath &path);
00100
00101 void writeTo(EPUBPackage &package);
00102
00104 void send(EPUBCSSSink &out);
00105
00106 private:
00108 void extractFontProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
00109
00110 EPUBManifest &m_manifest;
00112 MapType_t m_map;
00113 EPUBCounter m_number;
00115 SetType_t m_set;
00116 };
00117
00118 }
00119
00120 #endif // INCLUDED_EPUBIMAGEMANAGER
00121
00122