filters

htmlimport.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003    Copyright (C) 2001 Frank Dekervel <Frank.Dekervel@student.kuleuven.ac.be>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <htmlimport.h>
00022 #include <htmlimport.moc>
00023 
00024 #include <kdebug.h>
00025 #include <kgenericfactory.h>
00026 #include <KoFilterChain.h>
00027 
00028 #include <KoStore.h>
00029 
00030 #include <khtmlreader.h>
00031 #include <kwdwriter.h>
00032 
00033 typedef KGenericFactory<HTMLImport, KoFilter> HTMLImportFactory;
00034 K_EXPORT_COMPONENT_FACTORY( libhtmlimport, HTMLImportFactory( "kofficefilters" ) )
00035 
00036 
00037 HTMLImport::HTMLImport(KoFilter *, const char*, const QStringList &) :
00038                      KoFilter() {
00039 // 123
00040 }
00041 
00042 KoFilter::ConversionStatus HTMLImport::convert( const QCString& from, const QCString& to )
00043 {
00044     if(to!="application/x-kword" || from!="text/html")
00045         return KoFilter::NotImplemented;
00046 
00047     KoStore *k= KoStore::createStore(m_chain->outputFile(), KoStore::Write, "application/x-kword");
00048     KWDWriter *w= new KWDWriter(k);
00049     KHTMLReader h(w);
00050     KURL url;
00051     url.setPath(m_chain->inputFile());
00052     bool b= h.filter(url);
00053     delete(w);
00054     delete(k);
00055 
00056         if ( b )
00057             return KoFilter::OK;
00058         else
00059             return KoFilter::StupidError;
00060 }
KDE Home | KDE Accessibility Home | Description of Access Keys