filters

xcfexport.cpp

00001 /*
00002  *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 #include <xcfexport.h>
00020 
00021 #include <kurl.h>
00022 #include <kgenericfactory.h>
00023 
00024 #include <KoDocument.h>
00025 #include <KoFilterChain.h>
00026 
00027 #include <kis_doc.h>
00028 #include <kis_image.h>
00029 #include <kis_annotation.h>
00030 #include <kis_types.h>
00031 #include <kis_xcf_converter.h>
00032 
00033 typedef KGenericFactory<XCFExport, KoFilter> XCFExportFactory;
00034 K_EXPORT_COMPONENT_FACTORY(libkritaxcfexport, XCFExportFactory("kofficefilters"))
00035 
00036 XCFExport::XCFExport(KoFilter *, const char *, const QStringList&) : KoFilter()
00037 {
00038 }
00039 
00040 XCFExport::~XCFExport()
00041 {
00042 }
00043 
00044 KoFilter::ConversionStatus XCFExport::convert(const QCString& from, const QCString& to)
00045 {
00046     kdDebug(41008) << "xcf export! From: " << from << ", To: " << to << "\n";
00047     
00048     if (from != "application/x-krita")
00049         return KoFilter::NotImplemented;
00050 
00051     KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument());
00052     QString filename = m_chain->outputFile();
00053     
00054     if (!output)
00055         return KoFilter::CreationError;
00056     
00057     
00058     if (filename.isEmpty()) return KoFilter::FileNotFound;
00059 
00060     KURL url(filename);
00061 
00062     KisImageSP img = output->currentImage();
00063     if (!img) return KoFilter::ParsingError;
00064 
00065     KisXCFConverter ib(output, output->undoAdapter());
00066 
00067     vKisAnnotationSP_it beginIt = img->beginAnnotations();
00068     vKisAnnotationSP_it endIt = img->endAnnotations();
00069     
00070     if (ib.buildFile(url, img, beginIt, endIt) == KisImageBuilder_RESULT_OK) {
00071         return KoFilter::OK;
00072     }
00073 
00074     return KoFilter::InternalError;
00075 }
00076 
00077 #include <xcfexport.moc>
00078 
KDE Home | KDE Accessibility Home | Description of Access Keys