xsltimport.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library 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 GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <xsltimport.h>
21#include <xsltimport.moc>
22#include <kdebug.h>
23#include <KoFilterChain.h>
24#include <kgenericfactory.h>
25#include <tdeglobal.h>
26#include <tdelocale.h>
27#include <tqtextcodec.h>
28#include "xsltimportdia.h"
29
30
31typedef KGenericFactory<XSLTImport, KoFilter> XSLTImportFactory;
32K_EXPORT_COMPONENT_FACTORY( libxsltimport, XSLTImportFactory( "kofficefilters" ) )
33
34
35XSLTImport::XSLTImport(KoFilter *, const char *, const TQStringList&) :
36 KoFilter() {
37}
38
39KoFilter::ConversionStatus XSLTImport::convert( const TQCString&, const TQCString& to )
40{
41 TQString config;
42
43 if(to != "application/x-kword" &&
44 to != "application/x-kontour" && to != "application/x-kspread" &&
45 to != "application/x-kivio" && to != "application/x-kchart" &&
46 to != "application/x-kpresenter")
47 return KoFilter::NotImplemented;
48
49 // ## missing appIdentification
50 KoStore* out = KoStore::createStore(TQString(m_chain->outputFile()), KoStore::Write);
51 if(!out || !out->open("root"))
52 {
53 kdError() << "Unable to create output file!" << endl;
54 delete out;
55 return KoFilter::FileNotFound;
56 }
57 /* input file Reading */
58 out->close();
59 kdDebug() << "here" << endl;
60 XSLTImportDia* dialog = new XSLTImportDia(out, to, 0, "Importation", true);
61 dialog->setInputFile(m_chain->inputFile());
62
63 dialog->exec();
64 delete dialog;
65 delete out;
66
67 return KoFilter::OK;
68}