Warning, file /office/calligra/filters/libmsooxml/VmlDrawingReader.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * This file is part of Office 2007 Filters for Calligra 0003 * 0004 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 0005 * 0006 * Contact: Suresh Chande suresh.chande@nokia.com 0007 * 0008 * This library is free software; you can redistribute it and/or 0009 * modify it under the terms of the GNU Lesser General Public License 0010 * version 2.1 as published by the Free Software Foundation. 0011 * 0012 * This library is distributed in the hope that it will be useful, but 0013 * WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library; if not, write to the Free Software 0019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 0020 * 02110-1301 USA 0021 * 0022 */ 0023 0024 #include "VmlDrawingReader.h" 0025 #include <MsooXmlSchemas.h> 0026 #include <MsooXmlUtils.h> 0027 #include <MsooXmlRelationships.h> 0028 #include <MsooXmlUnits.h> 0029 #include <KoXmlWriter.h> 0030 #include <KoGenStyles.h> 0031 #include <KoOdfGraphicStyles.h> 0032 #include <limits.h> 0033 0034 #define MSOOXML_CURRENT_NS empty // Without this, the vml methods won't have ns identifier in them 0035 #define MSOOXML_CURRENT_CLASS VmlDrawingReader 0036 #define BIND_READ_CLASS MSOOXML_CURRENT_CLASS 0037 0038 #include <MsooXmlReader_p.h> 0039 0040 VmlDrawingReaderContext::VmlDrawingReaderContext(MSOOXML::MsooXmlImport& _import, const QString& _path, 0041 const QString& _file, MSOOXML::MsooXmlRelationships& _relationships) : 0042 MSOOXML::MsooXmlReaderContext(&_relationships), import(&_import), path(_path), file(_file) 0043 { 0044 } 0045 0046 class Q_DECL_HIDDEN VmlDrawingReader::Private 0047 { 0048 public: 0049 Private() { 0050 } 0051 ~Private() { 0052 } 0053 }; 0054 0055 VmlDrawingReader::VmlDrawingReader(KoOdfWriters *writers) 0056 : MSOOXML::MsooXmlCommonReader(writers) 0057 , d(new Private) 0058 { 0059 init(); 0060 } 0061 0062 VmlDrawingReader::~VmlDrawingReader() 0063 { 0064 delete d; 0065 } 0066 0067 void VmlDrawingReader::init() 0068 { 0069 m_currentVMLProperties.insideGroup = false; 0070 m_outputFrames = false; 0071 } 0072 0073 QMap<QString, QString> VmlDrawingReader::content() 0074 { 0075 return m_content; 0076 } 0077 0078 QMap<QString, QString> VmlDrawingReader::frames() 0079 { 0080 return m_frames; 0081 } 0082 0083 KoFilter::ConversionStatus VmlDrawingReader::read(MSOOXML::MsooXmlReaderContext* context) 0084 { 0085 m_context = static_cast<VmlDrawingReaderContext*>(context); 0086 0087 readNext(); 0088 if (!isStartDocument()) { 0089 return KoFilter::WrongFormat; 0090 } 0091 readNext(); 0092 0093 debugMsooXml << *this << namespaceUri(); 0094 if (!expectEl(QList<QByteArray>() << "xml")) { 0095 return KoFilter::WrongFormat; 0096 } 0097 0098 const QString qn(qualifiedName().toString()); 0099 0100 RETURN_IF_ERROR(read_xml()) 0101 0102 if (!expectElEnd(qn)) { 0103 return KoFilter::WrongFormat; 0104 } 0105 debugMsooXml << "===========finished============"; 0106 0107 return KoFilter::OK; 0108 } 0109 0110 KoFilter::ConversionStatus VmlDrawingReader::read_xml() 0111 { 0112 unsigned index = 0; 0113 KoXmlWriter *oldBody = 0; 0114 0115 while (!atEnd()) { 0116 readNext(); 0117 if (isEndElement() && qualifiedName() == "xml") { 0118 break; 0119 } 0120 if (isStartElement()) { 0121 if (name() == "shapetype") { 0122 TRY_READ(shapetype) 0123 } 0124 else if (name() == "shape") { 0125 oldBody = body; // Body protection starts 0126 QBuffer frameBuf; 0127 KoXmlWriter frameWriter(&frameBuf); 0128 body = &frameWriter; 0129 TRY_READ(shape) //from vml 0130 m_content[m_currentVMLProperties.currentShapeId] = m_currentVMLProperties.imagedataPath; 0131 pushCurrentDrawStyle(new KoGenStyle(KoGenStyle::GraphicAutoStyle, "graphic")); 0132 createFrameStart(); 0133 popCurrentDrawStyle(); 0134 m_frames[m_currentVMLProperties.currentShapeId] = QString::fromUtf8(frameBuf.buffer(), frameBuf.buffer().size()).append(">"); 0135 body = oldBody; // Body protection ends 0136 ++index; 0137 } 0138 } 0139 } 0140 return KoFilter::OK; 0141 } 0142 0143 #include <MsooXmlVmlReaderImpl.h>