filters

chalk/xcf/xcfexport.cpp
1/*
2 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19#include <xcfexport.h>
20
21#include <kurl.h>
22#include <kgenericfactory.h>
23
24#include <KoDocument.h>
25#include <KoFilterChain.h>
26
27#include <kis_doc.h>
28#include <kis_image.h>
29#include <kis_annotation.h>
30#include <kis_types.h>
31#include <kis_xcf_converter.h>
32
33typedef KGenericFactory<XCFExport, KoFilter> XCFExportFactory;
34K_EXPORT_COMPONENT_FACTORY(libchalkxcfexport, XCFExportFactory("kofficefilters"))
35
36XCFExport::XCFExport(KoFilter *, const char *, const TQStringList&) : KoFilter()
37{
38}
39
40XCFExport::~XCFExport()
41{
42}
43
44KoFilter::ConversionStatus XCFExport::convert(const TQCString& from, const TQCString& to)
45{
46 kdDebug(41008) << "xcf export! From: " << from << ", To: " << to << "\n";
47
48 if (from != "application/x-chalk")
49 return KoFilter::NotImplemented;
50
51 KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument());
52 TQString filename = m_chain->outputFile();
53
54 if (!output)
55 return KoFilter::CreationError;
56
57
58 if (filename.isEmpty()) return KoFilter::FileNotFound;
59
60 KURL url(filename);
61
62 KisImageSP img = output->currentImage();
63 if (!img) return KoFilter::ParsingError;
64
65 KisXCFConverter ib(output, output->undoAdapter());
66
67 vKisAnnotationSP_it beginIt = img->beginAnnotations();
68 vKisAnnotationSP_it endIt = img->endAnnotations();
69
70 if (ib.buildFile(url, img, beginIt, endIt) == KisImageBuilder_RESULT_OK) {
71 return KoFilter::OK;
72 }
73
74 return KoFilter::InternalError;
75}
76
77#include <xcfexport.moc>
78