Warning, file /office/calligra/libs/odf/KoOdfLoadingContext.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) 2005 David Faure <faure@kde.org> 0003 Copyright (C) 2010 Inge Wallin <inge@lysator.liu.se> 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 0021 #ifndef KOODFLOADINGCONTEXT_H 0022 #define KOODFLOADINGCONTEXT_H 0023 0024 #include "koodf_export.h" 0025 #include "KoOdfStylesReader.h" 0026 0027 0028 class KoStore; 0029 class KoOdfManifestEntry; 0030 class KoStyleStack; 0031 0032 0033 /** 0034 * Used during loading of Oasis format (and discarded at the end of the loading). 0035 * 0036 * @author David Faure <faure@kde.org> 0037 */ 0038 class KOODF_EXPORT KoOdfLoadingContext 0039 { 0040 public: 0041 enum GeneratorType { Unknown, Calligra, OpenOffice, MicrosoftOffice }; 0042 /** 0043 * Stores reference to the KoOdfStylesReader and stored passed by 0044 * KoDocument. Make sure that the KoOdfStylesReader instance outlives 0045 * this KoOdfLoadingContext instance. (This is the case during 0046 * loading, when using the KoOdfStylesReader given by KoDocument) 0047 * 0048 * @param styles reference to the KoOdfStylesReader parsed by KoDocument 0049 * @param store pointer to store, if available, for e.g. loading images. 0050 * @param defaultStylesResourcePath resource path to "defaultstyles.xml", empty if none 0051 */ 0052 explicit KoOdfLoadingContext(KoOdfStylesReader &stylesReader, KoStore *store, const QString &defaultStylesResourcePath = QString()); 0053 virtual ~KoOdfLoadingContext(); 0054 0055 /** 0056 * Set different manifest 0057 * @param fileName file name of the manifest file 0058 */ 0059 void setManifestFile(const QString &fileName); 0060 0061 KoStore *store() const; 0062 0063 KoOdfStylesReader &stylesReader(); 0064 0065 /** 0066 * Get the application default styles styleReader 0067 */ 0068 KoOdfStylesReader &defaultStylesReader(); 0069 0070 KoStyleStack &styleStack() const; 0071 0072 /// Return the <meta:generator> of the document, e.g. "Calligra/1.4.0a" 0073 QString generator() const; 0074 /// Return the GeneratorType of the document, e.g. Calligra 0075 GeneratorType generatorType() const; 0076 0077 /** 0078 * Convenience method for loading the style of an object 0079 * before loading that object. 0080 * 0081 * Read attribute (nsURI,attrName) from the given dom element, 0082 * treat that attribute as a style name, and load that style 0083 * including all its parent styles. 0084 * @param element the dom element to read the attribute from 0085 * @param nsURI the namespace URI of the attribute to read 0086 * @param attrName the name of the attribute to read 0087 * @param family the style family used for this object 0088 */ 0089 void fillStyleStack(const KoXmlElement &element, const QString &nsURI, const QString &attrName, const QString &family); 0090 0091 /** 0092 * Add @p style to the stack, as well as all its parent styles 0093 * and the default style for this style family. 0094 * 0095 * @param style the dom element containing the style to add to the stack 0096 * @param family the family to use when looking up parent styles 0097 * @param usingStylesAutoStyles if true, the parent styles are looked up 0098 * in the automatic styles from styles.xml, instead of looking up 0099 * in the automatic styles from content.xml as we usually do. 0100 * This is useful for loading headers and footers for instance. 0101 * See setUseStylesAutoStyles(), which makes fillStyleStack() set this bool. 0102 * 0103 * Usually you would call fillStyleStack() instead. 0104 */ 0105 void addStyles(const KoXmlElement *style, const QString &family, bool usingStylesAutoStyles = false); 0106 0107 /// Set to true while loading headers and footers, to remember to use auto styles 0108 /// from styles.xml 0109 void setUseStylesAutoStyles(bool useStylesAutoStyles); 0110 bool useStylesAutoStyles() const; 0111 0112 0113 /** 0114 * @return the mimetype for the document in the given path using the manifest 0115 * The mimetype is defined in the manifest.xml document. 0116 * @param path The path to get the mimetpye for 0117 * @param guess If set to true it tries to guess the mimetype in case it is not provided in the manifest 0118 Note: Be sure to call this function with a closed store when guess is set to true as otherwise 0119 it will fail. 0120 */ 0121 QString mimeTypeForPath(const QString& path, bool guess = false) const; 0122 0123 /** 0124 * @return the full list of entries from the manifest file 0125 */ 0126 QList<KoOdfManifestEntry*> manifestEntries() const; 0127 0128 private: 0129 class Private; 0130 Private * const d; 0131 /// Parse and set generator and generatorType attributes from <meta:generator> attribute of meta.xml file 0132 void parseGenerator() const; 0133 bool parseManifest(const KoXmlDocument &manifestDocument); 0134 }; 0135 0136 #endif /* KOODFLOADINGCONTEXT_H */