kspread/latex/export/latexexport.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 <latexexport.h>
21#include <latexexport.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 "kspreadlatexexportdiaImpl.h"
29
30typedef KGenericFactory<LATEXExport, KoFilter> LATEXExportFactory;
31K_EXPORT_COMPONENT_FACTORY( libkspreadlatexexport, LATEXExportFactory( "kofficefilters" ) )
32
33
34LATEXExport::LATEXExport(KoFilter *, const char *, const TQStringList&) :
35 KoFilter() {
36}
37
38KoFilter::ConversionStatus LATEXExport::convert( const TQCString& from, const TQCString& to )
39{
40 TQString config;
41
42 if(to != "text/x-tex" || from != "application/x-kspread")
43 return KoFilter::NotImplemented;
44
45 KoStore* in = KoStore::createStore(m_chain->inputFile(), KoStore::Read);
46 if(!in || !in->open("root")) {
47 kdError(30503) << "Unable to open input file!" << endl;
48 delete in;
49 return KoFilter::FileNotFound;
50 }
51 kdDebug(30522) << "In the kspread latex export filter..." << endl;
52 /* input file Reading */
53 in->close();
54
55 KSpreadLatexExportDiaImpl* dialog = new KSpreadLatexExportDiaImpl(in);
56 dialog->setOutputFile(m_chain->outputFile());
57
58 dialog->exec();
59 delete dialog;
60 delete in;
61
62 return KoFilter::OK;
63}