Warning, file /office/calligra/libs/odf/KoDocumentInfo.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org> 0003 Copyright (C) 2004 David Faure <faure@kde.org> 0004 Copyright (C) 2006 Martin Pfeiffer <hubipete@gmx.net> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #ifndef KO_DOCUMENT_INFO_H 0023 #define KO_DOCUMENT_INFO_H 0024 0025 #include <QObject> 0026 #include <QMap> 0027 #include <QString> 0028 #include <QStringList> 0029 0030 #include "koodf_export.h" 0031 #include <KoXmlReader.h> 0032 0033 class QDomDocument; 0034 class QDomElement; 0035 class KoStore; 0036 class KoXmlWriter; 0037 0038 /** 0039 * @short The class containing all meta information about a document 0040 * 0041 * @author Torben Weis <weis@kde.org> 0042 * @author David Faure <faure@kde.org> 0043 * @author Martin Pfeiffer <hubipete@gmx.net> 0044 * @see KoDocumentInfoDlg 0045 * 0046 * This class contains the meta information for a document. They are 0047 * stored in two QMap and can be accessed through aboutInfo() and authorInfo(). 0048 * The about info can be changed with setAboutInfo() and setAuthorInfo() 0049 */ 0050 class KOODF_EXPORT KoDocumentInfo : public QObject 0051 { 0052 Q_OBJECT 0053 0054 public: 0055 /** 0056 * The constructor 0057 * @param parent a pointer to the parent object 0058 */ 0059 explicit KoDocumentInfo(QObject *parent = 0); 0060 0061 /** The destructor */ 0062 ~KoDocumentInfo() override; 0063 0064 /** 0065 * Load the KoDocumentInfo from an OASIS document 0066 * @param metaDoc the QDomDocument with the metaInformation 0067 * @return true if success 0068 */ 0069 bool loadOasis(const KoXmlDocument& metaDoc); 0070 0071 /** 0072 * Save the KoDocumentInfo to an OASIS document 0073 * @param store a pointer to a KoStore to save in 0074 * @return true if success 0075 */ 0076 bool saveOasis(KoStore* store); 0077 0078 /** 0079 * Load the KoDocumentInfo from an Calligra-1.3 DomDocument 0080 * @param doc the QDomDocument to load from 0081 * @return true if success 0082 */ 0083 bool load(const KoXmlDocument& doc); 0084 0085 /** 0086 * Save the KoDocumentInfo to an Calligra-1.3 DomDocument 0087 * @return the QDomDocument to which was saved 0088 */ 0089 QDomDocument save(QDomDocument &doc); 0090 0091 /** 0092 * Set information about the author. 0093 * This will override any information retrieved from the author profile 0094 * But it does not change the author profile 0095 * Note: authorInfo() will not return the new value until the document has been 0096 * saved by the user.(autosave doesn't count) 0097 * @param info the kind of information to set 0098 * @param data the data to set for this information 0099 */ 0100 void setAuthorInfo(const QString& info, const QString& data); 0101 0102 /** 0103 * Obtain information about the author 0104 * @param info the kind of information to obtain 0105 * @return a QString with the information 0106 */ 0107 QString authorInfo(const QString& info) const; 0108 0109 /** 0110 * Set information about the document 0111 * @param info the kind of information to set 0112 * @param data the data to set for this information 0113 */ 0114 void setAboutInfo(const QString& info, const QString& data); 0115 0116 /** 0117 * Obtain information about the document 0118 * @param info the kind of information to obtain 0119 * @return a QString with the information 0120 */ 0121 QString aboutInfo(const QString& info) const; 0122 0123 /** 0124 * Obtain the generator of the document, as it was loaded from the document 0125 */ 0126 QString originalGenerator() const; 0127 0128 /** 0129 * Sets the original generator of the document. This does not affect what gets 0130 * saved to a document in the meta:generator field, it only changes what 0131 * originalGenerator() will return. 0132 */ 0133 void setOriginalGenerator(const QString& generator); 0134 0135 /** Resets part of the meta data */ 0136 void resetMetaData(); 0137 0138 /** Takes care of updating the document info from configuration correctly */ 0139 void updateParameters(); 0140 0141 private: 0142 /// Bumps the editing cycles count and save date, and then calls updateParameters 0143 void updateParametersAndBumpNumCycles(); 0144 0145 /** 0146 * Set information about the author 0147 * This sets what is actually saved to file. The public method setAuthorInfo() can be used to set 0148 * values that override what is fetched from the author profile. During saveParameters() author 0149 * profile and any overrides is combined resulting in calls to this method. 0150 * @param info the kind of information to set 0151 * @param data the data to set for this information 0152 */ 0153 void setActiveAuthorInfo(const QString& info, const QString& data); 0154 0155 /** 0156 * Load the information about the document from an OASIS file 0157 * @param metaDoc a reference to the information node 0158 * @return true if success 0159 */ 0160 bool loadOasisAboutInfo(const KoXmlNode& metaDoc); 0161 0162 /** 0163 * Save the information about the document to an OASIS file 0164 * @param xmlWriter a reference to the KoXmlWriter to write in 0165 * @return true if success 0166 */ 0167 bool saveOasisAboutInfo(KoXmlWriter &xmlWriter); 0168 0169 /** 0170 * Load the information about the document from a Calligra-1.3 file 0171 * @param e the element to load from 0172 * @return true if success 0173 */ 0174 bool loadAboutInfo(const KoXmlElement& e); 0175 0176 /** 0177 * Save the information about the document to a Calligra-1.3 file 0178 * @param doc the QDomDocument to save in 0179 * @return the QDomElement to which was saved 0180 */ 0181 QDomElement saveAboutInfo(QDomDocument& doc); 0182 0183 /** 0184 * Load the information about the document from an OASIS file 0185 * @param metaDoc a reference to the information node 0186 * @return true if success 0187 */ 0188 bool loadOasisAuthorInfo(const KoXmlNode& metaDoc); 0189 0190 /** 0191 * Load the information about the document from a Calligra-1.3 file 0192 * @param e the element to load from 0193 * @return true if success 0194 */ 0195 bool loadAuthorInfo(const KoXmlElement& e); 0196 0197 /** 0198 * Save the information about the author to a Calligra-1.3 file 0199 * @param doc the QDomDocument to save in 0200 * @return the QDomElement to which was saved 0201 */ 0202 QDomElement saveAuthorInfo(QDomDocument& doc); 0203 0204 /** 0205 * Save the information about the document to an OASIS file 0206 * @param xmlWriter a reference to the KoXmlWriter to write in 0207 * @return true if success 0208 */ 0209 bool saveOasisAuthorInfo(KoXmlWriter &xmlWriter); 0210 0211 /** A QStringList containing all tags for the document information */ 0212 QStringList m_aboutTags; 0213 /** A QStringList containing all tags for the author information */ 0214 QStringList m_authorTags; 0215 /** The map containing information about the author */ 0216 QMap<QString, QString> m_authorInfo; 0217 /** The map containing information about the author set programatically*/ 0218 QMap<QString, QString> m_authorInfoOverride; 0219 /** The map containing information about the document */ 0220 QMap<QString, QString> m_aboutInfo; 0221 /** The original meta:generator of the document */ 0222 QString m_generator; 0223 const QString m_keywordSeparator = QStringLiteral(";"); 0224 0225 Q_SIGNALS: 0226 void infoUpdated(const QString &info, const QString &data); 0227 }; 0228 0229 #endif