Warning, file /office/calligra/libs/odf/KoOdfWriteStore.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) 2007 Thorsten Zachmann <zachmann@kde.org> 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 #ifndef KOODFWRITESTORE_H 0021 #define KOODFWRITESTORE_H 0022 0023 class QIODevice; 0024 class KoXmlWriter; 0025 class KoStore; 0026 0027 /** 0028 * Helper class around KoStore for writing out ODF files. 0029 * This class helps solving the problem that automatic styles must be before 0030 * the body, but it's easier to iterate over the application's objects only 0031 * once. So we open a KoXmlWriter into a memory buffer, write the body into it, 0032 * collect automatic styles while doing that, write out automatic styles, 0033 * and then copy the body XML from the buffer into the real KoXmlWriter. 0034 * 0035 * The typical use of this class is therefore: 0036 * - write body into bodyWriter() and collect auto styles 0037 * - write auto styles into contentWriter() 0038 * - call closeContentWriter() 0039 * - write other files into the store (styles.xml, settings.xml etc.) 0040 * 0041 * 0042 * TODO: maybe we could encapsulate a bit more things, to e.g. handle 0043 * adding manifest entries automatically. 0044 * 0045 * @author: David Faure <faure@kde.org> 0046 */ 0047 #include "koodf_export.h" 0048 0049 class KOODF_EXPORT KoOdfWriteStore 0050 { 0051 public: 0052 /// @param store recontents the property of the caller 0053 explicit KoOdfWriteStore(KoStore *store); 0054 0055 ~KoOdfWriteStore(); 0056 0057 /** 0058 * Return an XML writer for saving Oasis XML into the device @p dev, 0059 * including the XML processing instruction, 0060 * and the root element with all its namespaces. 0061 * You can add more namespaces afterwards with addAttribute. 0062 * 0063 * @param dev the device into which the XML will be written. 0064 * @param rootElementName the tag name of the root element. 0065 * This is either office:document, office:document-content, 0066 * office:document-styles, office:document-meta or office:document-settings 0067 * @return the KoXmlWriter instance. It becomes owned by the caller, which 0068 * must delete it at some point. 0069 * 0070 * Once done with writing the contents of the root element, you 0071 * will need to call endElement(); endDocument(); before destroying the KoXmlWriter. 0072 */ 0073 static KoXmlWriter *createOasisXmlWriter(QIODevice *dev, const char *rootElementName); 0074 0075 KoStore *store() const; 0076 0077 /** 0078 * Open contents.xml for writing and return the KoXmlWriter 0079 */ 0080 KoXmlWriter *contentWriter(); 0081 0082 /** 0083 * Open another KoXmlWriter for writing out the contents 0084 * into a temporary file, to collect automatic styles while doing that. 0085 */ 0086 KoXmlWriter *bodyWriter(); 0087 0088 /** 0089 * This will copy the body into the content writer, 0090 * delete the bodyWriter and the contentWriter, and then 0091 * close contents.xml. 0092 */ 0093 bool closeContentWriter(); 0094 0095 // For other files in the store, use open/addManifestEntry/KoStoreDevice/createOasisXmlWriter/close 0096 0097 /** 0098 * Create and return a manifest writer. It will write to a memory buffer. 0099 */ 0100 KoXmlWriter *manifestWriter(const char *mimeType); 0101 0102 /** 0103 * Return the manifest writer. It has to be created by manifestWriter( mimeType ) before you can use 0104 * this function. 0105 */ 0106 KoXmlWriter *manifestWriter(); 0107 0108 /** 0109 * Close the manifest writer. 0110 * @param writeMainfest If true then on closing we also write the contents to the manifest.xml else 0111 * we only close the writer and don't write the content to the manifest.xml 0112 */ 0113 bool closeManifestWriter(bool writeMainfest = true); 0114 0115 private: 0116 struct Private; 0117 Private * const d; 0118 }; 0119 0120 #endif /* KOODFWRITESTORE_H */