Warning, file /office/calligra/libs/odf/KoDocumentBase.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 
0003    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
0004    Copyright (C) 2000-2005 David Faure <faure@kde.org>
0005    Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
0006    Copyright (C) 2009 Boudewijn Rempt <boud@valdyas.org>
0007 
0008    This library is free software; you can redistribute it and/or
0009    modify it under the terms of the GNU Library General Public
0010    License as published by the Free Software Foundation; either
0011    version 2 of the License, or (at your option) any later version.
0012 
0013    This library is distributed in the hope that it will be useful,
0014    but WITHOUT ANY WARRANTY; without even the implied warranty of
0015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016    Library General Public License for more details.
0017 
0018    You should have received a copy of the GNU Library General Public License
0019    along with this library; see the file COPYING.LIB.  If not, write to
0020    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021   Boston, MA 02110-1301, USA.
0022 */
0023 #ifndef KODOCUMENTBASE_H
0024 #define KODOCUMENTBASE_H
0025 
0026 class KoStore;
0027 class KoOdfReadStore;
0028 class KoOdfWriteStore;
0029 class KoEmbeddedDocumentSaver;
0030 class KoXmlElement;
0031 class KoOdfLoadingContext;
0032 
0033 class QUrl;
0034 class QByteArray;
0035 class QString;
0036 
0037 #include "koodf_export.h"
0038 
0039 /**
0040  * Base class for documents that can load and save ODF. Most of the
0041  * implementation is still in KoDocument, though that should probably
0042  * change.
0043  */
0044 class KOODF_EXPORT KoDocumentBase
0045 {
0046 public:
0047 
0048     // context passed on saving to saveOdf
0049     struct SavingContext {
0050         SavingContext(KoOdfWriteStore &odfStore, KoEmbeddedDocumentSaver &embeddedSaver)
0051                 : odfStore(odfStore)
0052                 , embeddedSaver(embeddedSaver) {}
0053 
0054         KoOdfWriteStore &odfStore;
0055         KoEmbeddedDocumentSaver &embeddedSaver;
0056     };
0057 
0058     /**
0059      * create a new KoDocumentBase
0060      */
0061     KoDocumentBase();
0062 
0063     /**
0064      * delete this document
0065      */
0066     virtual ~KoDocumentBase();
0067 
0068     /**
0069      * Set when you want an external embedded document to be stored internally
0070      */
0071     void setStoreInternal(bool i);
0072 
0073     /**
0074      * @return true when external embedded documents are stored internally
0075      */
0076     bool storeInternal() const;
0077 
0078     /**
0079      * Return true if url() is a real filename, false if url() is
0080      * an internal url in the store, like "tar:/..."
0081      */
0082     virtual bool isStoredExtern() const = 0;
0083 
0084     /**
0085      * @return the current URL
0086      */
0087     virtual QUrl url() const = 0;
0088 
0089     virtual void setUrl(const QUrl &url) = 0;
0090 
0091     /**
0092      * Returns the OASIS OpenDocument mimetype of the document, if supported
0093      * This comes from the X-KDE-NativeOasisMimeType key in the .desktop file
0094      */
0095     virtual QByteArray nativeOasisMimeType() const = 0;
0096 
0097     /**
0098      *  @brief Saves a document to a store.
0099      */
0100     virtual bool saveToStore(KoStore *store, const QString &path) = 0;
0101 
0102     /**
0103      *  Reimplement this method to load the odf document. Take care to
0104      *  make sure styles are loaded before body text is loaded by the
0105      *  text shape.
0106      */
0107     virtual bool loadOdf(KoOdfReadStore &odfStore) = 0;
0108 
0109     /**
0110      *  Reimplement this method to save the contents of your %Calligra document,
0111      *  using the ODF format.
0112      */
0113     virtual bool saveOdf(SavingContext &documentContext) = 0;
0114 
0115     /**
0116      * Checks whether the document is currently in the process of autosaving
0117      */
0118     virtual bool isAutosaving() const = 0;
0119 
0120     /**
0121      * Returns true if this document or any of its internal child documents are modified.
0122      */
0123     virtual bool isModified() const = 0;
0124 
0125     /**
0126      *  @return true if the document is empty.
0127      */
0128     virtual bool isEmpty() const = 0;
0129 
0130     /**
0131      * Returns the actual mimetype of the document
0132      */
0133     virtual QByteArray mimeType() const = 0;
0134 
0135     /**
0136      * @brief Sets the mime type for the document.
0137      *
0138      * When choosing "save as" this is also the mime type
0139      * selected by default.
0140      */
0141     virtual void setMimeType(const QByteArray & mimeType) = 0;
0142 
0143     virtual QString localFilePath() const = 0;
0144 
0145     /**
0146      * Return the set of SupportedSpecialFormats that the application wants to
0147      * offer in the "Save" file dialog.
0148      */
0149     virtual int supportedSpecialFormats() const = 0;
0150 
0151     /// Enum values used by specialOutputFlag - note that it's a bitfield for supportedSpecialFormats
0152     enum { /*SaveAsCalligra1dot1 = 1,*/ // old and removed
0153         SaveAsDirectoryStore = 2,
0154         SaveAsFlatXML = 4,
0155         SaveEncrypted = 8
0156                         // bitfield! next value is 16
0157     };
0158     virtual int specialOutputFlag() const = 0;
0159 
0160     /**
0161      * @brief Set the format in which the document should be saved.
0162      *
0163      * This is called on loading, and in "save as", so you shouldn't
0164      * have to call it.
0165      *
0166      * @param mimeType the mime type (format) to use.
0167      * @param specialOutputFlag is for "save as older version" etc.
0168      */
0169     virtual void setOutputMimeType(const QByteArray & mimeType, int specialOutputFlag = 0) = 0;
0170 
0171     virtual QByteArray outputMimeType() const = 0;
0172 
0173     /**
0174      * Sets the document URL to empty URL
0175      * KParts doesn't allow this, but %Calligra apps have e.g. templates
0176      * After using loadNativeFormat on a template, one wants
0177      * to set the url to QUrl()
0178      */
0179     virtual void resetURL() = 0;
0180 
0181     /// Re-implement to load odf document from @p store
0182     virtual bool loadOasisFromStore(KoStore *store) = 0;
0183 
0184 private:
0185     class Private;
0186     Private *const d;
0187 };
0188 
0189 
0190 #endif