File indexing completed on 2024-05-12 16:29:10

0001 /*
0002  * This file is part of Office 2007 Filters for Calligra
0003  *
0004  * Copyright (C) 2009 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 #ifndef MSOOXMLRELATIONSHIPSREADER_H
0025 #define MSOOXMLRELATIONSHIPSREADER_H
0026 
0027 #include "MsooXmlReader.h"
0028 #include <QMap>
0029 
0030 namespace MSOOXML
0031 {
0032 
0033 //! A context structure for MsooXmlRelationshipsReader
0034 class MsooXmlRelationshipsReaderContext : public MSOOXML::MsooXmlReaderContext
0035 {
0036 public:
0037     MsooXmlRelationshipsReaderContext(const QString& _path, const QString& _file, QMap<QString, QString>& _rels,
0038                                       QMap<QString, QString>& _targetsForTypes);
0039     const QString path;
0040     const QString file;
0041     QMap<QString, QString> *rels;
0042     QMap<QString, QString> *targetsForTypes;
0043 };
0044 
0045 //! A class reading MSOOXML rels markup - *.xml.rels part.
0046 class MsooXmlRelationshipsReader : public MSOOXML::MsooXmlReader
0047 {
0048 public:
0049     explicit MsooXmlRelationshipsReader(KoOdfWriters *writers);
0050 
0051     ~MsooXmlRelationshipsReader() override;
0052 
0053     //! Reads/parses the file of format *.xml.rels.
0054     //! The output goes to MsooXmlRelationships structure.
0055     KoFilter::ConversionStatus read(MSOOXML::MsooXmlReaderContext* context = 0) override;
0056 
0057     //! @return key for use in MsooXmlRelationships::target()
0058     static inline QString relKey(const QString& path, const QString& file, const QString& id) {
0059         return path + '\n' + file + '\n' + id;
0060     }
0061 
0062 //! @return key for use in MsooXmlRelationships::targetForType()
0063         static inline QString targetKey(const QString& pathAndFile, const QString& relType) {
0064         return pathAndFile + '\n' + relType;
0065     }
0066 
0067 protected:
0068     KoFilter::ConversionStatus readInternal();
0069     KoFilter::ConversionStatus read_Relationships();
0070     KoFilter::ConversionStatus read_Relationship();
0071 
0072     MsooXmlRelationshipsReaderContext* m_context;
0073 private:
0074     void init();
0075 
0076     class Private;
0077     Private* const d;
0078 };
0079 
0080 }
0081 
0082 #endif //MSOOXMLRELATIONSHIPSREADER_H