File indexing completed on 2024-06-23 03:45:57
0001 /**************************************************************************** 0002 ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me> 0003 ** All right reserved. 0004 ** 0005 ** Permission is hereby granted, free of charge, to any person obtaining 0006 ** a copy of this software and associated documentation files (the 0007 ** "Software"), to deal in the Software without restriction, including 0008 ** without limitation the rights to use, copy, modify, merge, publish, 0009 ** distribute, sublicense, and/or sell copies of the Software, and to 0010 ** permit persons to whom the Software is furnished to do so, subject to 0011 ** the following conditions: 0012 ** 0013 ** The above copyright notice and this permission notice shall be 0014 ** included in all copies or substantial portions of the Software. 0015 ** 0016 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0017 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 0018 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 0019 ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 0020 ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 0021 ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 0022 ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 0023 ** 0024 ****************************************************************************/ 0025 #ifndef XLSXRELATIONSHIPS_H 0026 #define XLSXRELATIONSHIPS_H 0027 0028 // 0029 // W A R N I N G 0030 // ------------- 0031 // 0032 // This file is not part of the Qt Xlsx API. It exists for the convenience 0033 // of the Qt Xlsx. This header file may change from 0034 // version to version without notice, or even be removed. 0035 // 0036 // We mean it. 0037 // 0038 0039 #include "xlsxglobal.h" 0040 0041 #include <QList> 0042 #include <QString> 0043 #include <QIODevice> 0044 0045 QT_BEGIN_NAMESPACE_XLSX 0046 0047 struct XlsxRelationship 0048 { 0049 QString id; 0050 QString type; 0051 QString target; 0052 QString targetMode; 0053 }; 0054 0055 class Relationships 0056 { 0057 public: 0058 Relationships(); 0059 0060 QList<XlsxRelationship> documentRelationships(const QString &relativeType) const; 0061 QList<XlsxRelationship> packageRelationships(const QString &relativeType) const; 0062 QList<XlsxRelationship> msPackageRelationships(const QString &relativeType) const; 0063 QList<XlsxRelationship> worksheetRelationships(const QString &relativeType) const; 0064 0065 void addDocumentRelationship(const QString &relativeType, const QString &target); 0066 void addPackageRelationship(const QString &relativeType, const QString &target); 0067 void addMsPackageRelationship(const QString &relativeType, const QString &target); 0068 void addWorksheetRelationship(const QString &relativeType, const QString &target, const QString &targetMode=QString()); 0069 0070 void saveToXmlFile(QIODevice *device) const; 0071 QByteArray saveToXmlData() const; 0072 bool loadFromXmlFile(QIODevice *device); 0073 bool loadFromXmlData(const QByteArray &data); 0074 XlsxRelationship getRelationshipById(const QString &id) const; 0075 0076 void clear(); 0077 int count() const; 0078 bool isEmpty() const; 0079 0080 private: 0081 QList<XlsxRelationship> relationships(const QString &type) const; 0082 void addRelationship(const QString &type, const QString &target, const QString &targetMode=QString()); 0083 0084 QList<XlsxRelationship> m_relationships; 0085 }; 0086 0087 QT_END_NAMESPACE_XLSX 0088 0089 #endif // XLSXRELATIONSHIPS_H