filters

htmlimport.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2001 Frank Dekervel <Frank.Dekervel@student.kuleuven.ac.be>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include <htmlimport.h>
22#include <htmlimport.moc>
23
24#include <kdebug.h>
25#include <kgenericfactory.h>
26#include <KoFilterChain.h>
27
28#include <KoStore.h>
29
30#include <tdehtmlreader.h>
31#include <kwdwriter.h>
32
33typedef KGenericFactory<HTMLImport, KoFilter> HTMLImportFactory;
34K_EXPORT_COMPONENT_FACTORY( libhtmlimport, HTMLImportFactory( "kofficefilters" ) )
35
36
37HTMLImport::HTMLImport(KoFilter *, const char*, const TQStringList &) :
38 KoFilter() {
39// 123
40}
41
42KoFilter::ConversionStatus HTMLImport::convert( const TQCString& from, const TQCString& to )
43{
44 if(to!="application/x-kword" || from!="text/html")
45 return KoFilter::NotImplemented;
46
47 KoStore *k= KoStore::createStore(m_chain->outputFile(), KoStore::Write, "application/x-kword");
48 KWDWriter *w= new KWDWriter(k);
49 TDEHTMLReader h(w);
50 KURL url;
51 url.setPath(m_chain->inputFile());
52 bool b= h.filter(url);
53 delete(w);
54 delete(k);
55
56 if ( b )
57 return KoFilter::OK;
58 else
59 return KoFilter::StupidError;
60}