Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef IE_IMP_EPUB_H_
00022 #define IE_IMP_EPUB_H_
00023
00024 #include <gsf/gsf-infile-zip.h>
00025 #include <gsf/gsf-infile.h>
00026 #include <gsf/gsf-libxml.h>
00027 #include <gsf/gsf-input-memory.h>
00028 #include <ut_go_file.h>
00029 #include <stdexcept>
00030 #include <vector>
00031 #include <map>
00032 #include <string>
00033
00034
00035 #include <ie_imp.h>
00036 #include <ie_imp_XHTML.h>
00037 #include <ut_xml.h>
00038 #include <ie_imp_PasteListener.h>
00039 #include <xap_Prefs.h>
00040 #include <xap_App.h>
00041
00042
00043
00044 #define EPUB_MIMETYPE "application/epub+zip"
00045
00046 typedef std::pair<std::string, std::string> string_pair;
00050 class IE_Imp_EPUB: public IE_Imp
00051 {
00052 public:
00053 IE_Imp_EPUB(PD_Document * pDocument);
00054 virtual ~IE_Imp_EPUB();
00055 virtual bool pasteFromBuffer(PD_DocumentRange * pDocRange,
00056 const unsigned char * pData, UT_uint32 lenData,
00057 const char * szEncoding = 0);
00058 protected:
00059 virtual UT_Error _loadFile(GsfInput * input);
00060
00061 private:
00062 GsfInfile* m_epub;
00063 std::string m_rootfilePath;
00064 std::string m_tmpDir;
00065 std::string m_opsDir;
00066 std::vector<std::string> m_spine;
00067 std::map<std::string, std::string> m_manifestItems;
00068
00069 UT_Error readMetadata();
00070 UT_Error readPackage();
00071 UT_Error uncompress();
00072 UT_Error readStructure();
00073 static GsfOutput* createFileByPath(const char* path);
00074 };
00075
00076
00077
00078
00079 class ContainerListener: public UT_XML::Listener
00080 {
00081 public:
00082 void startElement(const gchar * name, const gchar ** atts);
00083 void endElement(const gchar * name);
00084 void charData(const gchar * buffer, int length);
00085
00086 const std::string & getRootFilePath() const;
00087
00088 private:
00089 std::string m_rootFilePath;
00090 };
00091
00092
00093
00094
00095 class OpfListener: public UT_XML::Listener
00096 {
00097 public:
00098 void startElement(const gchar * name, const gchar ** atts);
00099 void endElement(const gchar * name);
00100 void charData(const gchar * buffer, int length);
00101
00102 const std::map<std::string, std::string> & getManifestItems() const
00103 {
00104 return m_manifestItems;
00105 }
00106 const std::vector<std::string> & getSpine() const
00107 {
00108 return m_spine;
00109 }
00110
00111 OpfListener();
00112
00113 private:
00114
00115
00116
00117 std::vector<std::string> m_spine;
00118
00119
00120 std::map<std::string, std::string> m_manifestItems;
00121
00122 bool m_inManifest;
00123 bool m_inSpine;
00124 };
00125
00126
00127
00128
00129 class NavigationListener: public UT_XML::Listener
00130 {
00131 public:
00132 void startElement(const gchar * name, const gchar ** atts);
00133 void endElement(const gchar * name);
00134 void charData(const gchar * buffer, int length);
00135 };
00136
00137 #endif
00138