00001 /* AbiSource 00002 * 00003 * Copyright (C) 2011 Volodymyr Rudyj <vladimir.rudoy@gmail.com> 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00018 * 02110-1301 USA. 00019 */ 00020 #ifndef IE_EXP_EPUB_H_ 00021 #define IE_EXP_EPUB_H_ 00022 00023 #include "ie_exp_EPUB_EPUB3Writer.h" 00024 #include "ap_Dialog_EpubExportOptions.h" 00025 00026 #include <string> 00027 #include <vector> 00028 #include <algorithm> 00029 // External includes 00030 #include <gsf/gsf-output-stdio.h> 00031 #include <gsf/gsf-outfile.h> 00032 #include <gsf/gsf-outfile-zip.h> 00033 #include <gsf/gsf-output.h> 00034 #include <gsf/gsf-libxml.h> 00035 #include <gsf/gsf-infile-stdio.h> 00036 #include <gsf/gsf-infile.h> 00037 // Abiword includes 00038 #include <ie_exp.h> 00039 #include <ie_exp_HTML.h> 00040 #include <pd_Document.h> 00041 #include <ut_go_file.h> 00042 #include <ut_path.h> 00043 #include <ie_TOC.h> 00044 00045 #define EPUB_MIMETYPE "application/epub+zip" 00046 #define OPF_MIMETYPE "application/oebps-package+xml" 00047 #define OCF201_NAMESPACE "urn:oasis:names:tc:opendocument:xmlns:container" 00048 #define OPF201_NAMESPACE "http://www.idpf.org/2007/opf" 00049 #define OPS201_NAMESPACE "http://www.idpf.org/2007/ops" 00050 #define EPUB3_PACKAGE_PROFILE "http://www.idpf.org/epub/30/profile/package/" 00051 #define DC_NAMESPACE "http://purl.org/dc/elements/1.1/" 00052 #define NCX_NAMESPACE "http://www.daisy.org/z3986/2005/ncx/" 00053 class IE_Exp_EPUB: public IE_Exp 00054 { 00055 00056 public: 00057 IE_Exp_EPUB(PD_Document * pDocument); 00058 virtual ~IE_Exp_EPUB(); 00059 00060 protected: 00061 virtual UT_Error _writeDocument(); 00062 00063 private: 00064 UT_Error writeStructure(); 00065 UT_Error writeNavigation(); 00066 UT_Error writeContainer(); 00067 UT_Error package(); 00068 UT_Error compress(); 00069 00070 // Methods for EPUB 2.0.1 document generation 00071 UT_Error EPUB2_writeStructure(); 00072 UT_Error EPUB2_writeNavigation(); 00073 00074 // Methods for EPUB 3 document generation 00075 UT_Error EPUB3_writeStructure(); 00076 UT_Error EPUB3_writeNavigation(); 00077 00078 00079 std::string getAuthor() const; 00080 std::string getTitle() const; 00081 std::string getLanguage() const; 00082 00083 UT_Error doOptions(); 00084 void registerDialogs(); 00085 00086 static std::vector<std::string> getFileList(const std::string &directory); 00087 static void closeNTags(GsfXMLOut* xml, int n); 00088 static std::string escapeForId(const std::string & src); 00089 static std::string getMimeType(const std::string &uri); 00090 00091 std::string m_baseTempDir; 00092 std::string m_oebpsDir; 00093 GsfOutfile* m_root; 00094 GsfOutput* m_oebps; 00095 IE_Exp_HTML *m_pHmtlExporter; 00096 // Array with file id`s in linear reading order 00097 std::vector<std::string> m_opsId; 00098 00099 XAP_Dialog_Id m_iDialogExport; 00100 XAP_Exp_EpubExportOptions m_exp_opt; 00101 }; 00102 00103 #endif /* IE_EXP_EPUB_H_ */