File indexing completed on 2025-11-30 14:29:58
0001 /* This file is part of the KDE project 0002 Copyright (C) 2000, S.R.Haque <shaheedhaque@hotmail.com>. 0003 Copyright (c) 2007 Jan Hambrecht <jaham@gmx.net> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 0020 DESCRIPTION 0021 */ 0022 0023 #include "WmfImport.h" 0024 #include "WmfImportParser.h" 0025 0026 #include <KoFilterChain.h> 0027 #include <KoXmlWriter.h> 0028 0029 #include <kpluginfactory.h> 0030 0031 #include <QFile> 0032 0033 K_PLUGIN_FACTORY_WITH_JSON(WMFImportFactory, "calligra_filter_wmf2svg.json", 0034 registerPlugin<WMFImport>();) 0035 0036 0037 WMFImport::WMFImport(QObject *parent, const QVariantList&) : 0038 KoFilter(parent) 0039 { 0040 } 0041 0042 WMFImport::~WMFImport() 0043 { 0044 } 0045 0046 KoFilter::ConversionStatus WMFImport::convert(const QByteArray& from, const QByteArray& to) 0047 { 0048 if (to != "image/svg+xml" || from != "image/x-wmf") 0049 return KoFilter::NotImplemented; 0050 0051 QFile svgFile(m_chain->outputFile()); 0052 if (!svgFile.open(QIODevice::WriteOnly)) { 0053 return KoFilter::CreationError; 0054 } 0055 0056 KoXmlWriter svgWriter(&svgFile); 0057 0058 WMFImportParser wmfParser(svgWriter); 0059 if (!wmfParser.load(QString(m_chain->inputFile()))) { 0060 return KoFilter::WrongFormat; 0061 } 0062 0063 // Do the conversion! 0064 if (!wmfParser.play()) { 0065 return KoFilter::WrongFormat; 0066 } 0067 0068 svgFile.close(); 0069 0070 return KoFilter::OK; 0071 } 0072 0073 #include <WmfImport.moc>