00001 /* -*- c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ 00002 00003 /* AbiWord Graphic importer employing GdkPixbuf 00004 * Copyright (C) 2001 Martin Sevior 00005 * Copyright (C) 2002 Dom Lachowicz 00006 * Copyright (C) 2005 Marc Maurer 00007 * Copyright (C) 2009 Hubert Figuiere 00008 * 00009 * Portions from GdkPixBuf Library 00010 * Copyright (C) 1999 The Free Software Foundation 00011 * 00012 * This program is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU General Public License 00014 * as published by the Free Software Foundation; either version 2 00015 * of the License, or (at your option) any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU General Public License 00023 * along with this program; if not, write to the Free Software 00024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00025 * 02110-1301 USA. 00026 */ 00027 00028 #include <string.h> 00029 00030 #include <string> 00031 00032 #include <glib.h> 00033 #include "ut_compiler.h" 00034 ABI_W_NO_CONST_QUAL 00035 #include <gdk-pixbuf/gdk-pixbuf.h> 00036 #include <gdk-pixbuf/gdk-pixbuf-loader.h> 00037 #include <gdk-pixbuf/gdk-pixbuf-io.h> 00038 ABI_W_POP 00039 00040 #include "ut_debugmsg.h" 00041 #include "ut_types.h" 00042 #include "ut_bytebuf.h" 00043 #include "ut_vector.h" 00044 #include "ut_string.h" 00045 #include "xap_Module.h" 00046 #include "ie_impGraphic.h" 00047 #include "fg_GraphicRaster.h" 00048 #include <png.h> 00049 00050 #ifndef IE_IMPGRAPHIC_GDKPIXBUF_H 00051 #define IE_IMPGRAPHIC_GDKPIXBUF_H 00052 00053 class ABI_EXPORT IE_ImpGraphic_GdkPixbuf : public IE_ImpGraphic 00054 { 00055 public: 00056 00057 IE_ImpGraphic_GdkPixbuf(); 00058 virtual ~IE_ImpGraphic_GdkPixbuf(); 00059 00060 virtual UT_Error importGraphic(const UT_ConstByteBufPtr & pBB, FG_ConstGraphicPtr & pfg); 00061 00062 private: 00063 00064 GdkPixbuf * pixbufForByteBuf(const UT_ConstByteBufPtr & pBB, std::string & mimetype); 00065 void _createPNGFromPixbuf(GdkPixbuf * pixbuf); 00066 UT_Error _png_write(GdkPixbuf * pixbuf); 00067 00068 GdkPixbuf * _loadXPM(const UT_ConstByteBufPtr & pBB); 00069 UT_Error Initialize_PNG(void); 00070 00071 // PNG structures used 00072 png_structp m_pPNG; // libpng structure for the PNG Object 00073 png_infop m_pPNGInfo; // libpng structure for info on the PNG Object 00074 UT_ConstByteBufPtr m_pPngBB; // pBB Converted to PNG File 00075 }; 00076 00077 class ABI_EXPORT IE_ImpGraphicGdkPixbuf_Sniffer : public IE_ImpGraphicSniffer 00078 { 00079 public: 00080 IE_ImpGraphicGdkPixbuf_Sniffer(); 00081 virtual ~IE_ImpGraphicGdkPixbuf_Sniffer(); 00082 00083 virtual const IE_SuffixConfidence * getSuffixConfidence (); 00084 virtual const IE_MimeConfidence * getMimeConfidence (); 00085 virtual UT_Confidence_t recognizeContents(const char * szBuf, UT_uint32 iNum); 00086 virtual bool getDlgLabels(const char ** pszDesc, 00087 const char ** pszSuffixList, 00088 IEGraphicFileType * ft); 00089 virtual UT_Error constructImporter(IE_ImpGraphic **ppieg); 00090 }; 00091 00092 #endif // IE_IMPGRAPHIC_GDKPIXBUF_H 00093