rtfexport.cpp
1// $Header$
2
3/*
4 This file is part of the KDE project
5 Copyright 2001, 2002 Nicolas GOUTTE <goutte@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21*/
22
23/*
24 This file is based on the old file:
25 /home/kde/koffice/filters/kword/ascii/asciiexport.cpp
26
27 The old file was copyrighted by
28 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
29 Copyright (c) 2000 ID-PRO Deutschland GmbH. All rights reserved.
30 Contact: Wolf-Michael Bolle <Bolle@ID-PRO.de>
31
32 The old file was licensed under the terms of the GNU Library General Public
33 License version 2.
34*/
35
36#include <kdebug.h>
37#include <kgenericfactory.h>
38#include <kimageio.h>
39#include <KoFilterChain.h>
40
41#include <KWEFBaseWorker.h>
42#include <KWEFKWordLeader.h>
43
44#include "ExportFilter.h"
45
46#include <rtfexport.h>
47#include <rtfexport.moc>
48
49typedef KGenericFactory<RTFExport, KoFilter> RTFExportFactory;
50K_EXPORT_COMPONENT_FACTORY( librtfexport, RTFExportFactory( "kofficefilters" ) )
51
52//
53// RTFExport
54//
55
56RTFExport::RTFExport(KoFilter *, const char *, const TQStringList &) :
57 KoFilter() {
58}
59
60KoFilter::ConversionStatus RTFExport::convert( const TQCString& from, const TQCString& to )
61{
62 if ((from != "application/x-kword") || (to != "text/rtf" && to != "application/msword" ))
63 {
64 return KoFilter::NotImplemented;
65 }
66
67 KImageIO::registerFormats();
68
69 RTFWorker* worker=new RTFWorker();
70
71 KWEFKWordLeader* leader=new KWEFKWordLeader(worker);
72
73 if (!leader)
74 {
75 kdError(30515) << "Cannot create Worker! Aborting!" << endl;
76 delete worker;
77 return KoFilter::StupidError;
78 }
79
80 KoFilter::ConversionStatus result=leader->convert(m_chain, from,to );
81
82 delete leader;
83 delete worker;
84
85 return result;
86}
87