Warning, file /office/calligra/libs/main/KoDocument.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 Torben Weis <weis@kde.org> 0003 Copyright (C) 2000-2005 David Faure <faure@kde.org> 0004 Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org> 0005 Copyright (C) 2010 Boudewijn Rempt <boud@kogmbh.com> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #ifndef KODOCUMENT_H 0024 #define KODOCUMENT_H 0025 0026 #include <QDateTime> 0027 #include <QList> 0028 0029 #include "komain_export.h" 0030 #include <KoXmlReaderForward.h> 0031 #include <KoDocumentBase.h> 0032 #include <kundo2stack.h> 0033 0034 class KUndo2Command; 0035 class KoPart; 0036 class KoStore; 0037 class KoDocumentInfo; 0038 class KoDocumentRdf; 0039 class KoDocumentRdfBase; 0040 class KoProgressUpdater; 0041 class KoProgressProxy; 0042 class KoDocumentInfoDlg; 0043 class KoUnit; 0044 class KoGridData; 0045 class KoGuidesData; 0046 class KoXmlWriter; 0047 0048 class QDomDocument; 0049 0050 // MSVC seems to need to know the declaration of the classes 0051 // we pass references of in, when used by external modules 0052 // e.g. 0053 // when building chartshapecore.lib, the forward-declaration 0054 // approach lead to unresolved externals warnings when it used 0055 // the pagelayout functions. 0056 // Also when building calligra_shape_formular.dll - FormulaDocument 0057 // referenced the same two pagelayout functions incorrectly. 0058 #if defined(_WIN32) || defined(_WIN64) 0059 #include <KoPageLayout.h> 0060 #else 0061 struct KoPageLayout; 0062 #endif 0063 0064 class KoVersionInfo 0065 { 0066 public: 0067 QDateTime date; 0068 QString saved_by; 0069 QString comment; 0070 QString title; 0071 0072 QByteArray data; //the content of the compressed version 0073 }; 0074 0075 /** 0076 * The %Calligra document class 0077 * 0078 * This class provides some functionality each %Calligra document should have. 0079 * 0080 * @short The %Calligra document class 0081 */ 0082 class KOMAIN_EXPORT KoDocument : public QObject, public KoDocumentBase 0083 { 0084 Q_OBJECT 0085 Q_PROPERTY(bool backupFile READ backupFile WRITE setBackupFile) 0086 Q_PROPERTY(int pageCount READ pageCount) 0087 0088 public: 0089 0090 /** 0091 * Constructor. 0092 * 0093 * @param parent The KoPart that owns the document. XXX: should be removed! 0094 * @param undoStack accepts the stack for the document. You can create any type of stack if you need. 0095 * The stack objects will become owned by the document. This is used by Krita's KisDoc2. The default value for this 0096 * parameter is a usual Qt's stack. 0097 */ 0098 explicit KoDocument(KoPart *parent, 0099 KUndo2Stack *undoStack = new KUndo2Stack()); 0100 0101 /** 0102 * Destructor. 0103 * 0104 * The destructor does not delete any attached KoView objects and it does not 0105 * delete the attached widget as returned by widget(). 0106 */ 0107 ~KoDocument() override; 0108 0109 /// XXX: Temporary! 0110 KoPart *documentPart() const; 0111 0112 /** 0113 * Reimplemented from KoParts::ReadWritePart for internal reasons 0114 * (for the autosave functionality) 0115 */ 0116 virtual bool openUrl(const QUrl &url); 0117 0118 /** 0119 * Opens the document given by @p url, without storing the URL 0120 * in the KoDocument. 0121 * Call this instead of openUrl() to implement KoMainWindow's 0122 * File --> Import feature. 0123 * 0124 * @note This will call openUrl(). To differentiate this from an ordinary 0125 * Open operation (in any reimplementation of openUrl() or openFile()) 0126 * call isImporting(). 0127 */ 0128 bool importDocument(const QUrl &url); 0129 0130 /** 0131 * Saves the document as @p url without changing the state of the 0132 * KoDocument (URL, modified flag etc.). Call this instead of 0133 * KoParts::ReadWritePart::saveAs() to implement KoMainWindow's 0134 * File --> Export feature. 0135 * 0136 * @note This will call KoDocument::saveAs(). To differentiate this 0137 * from an ordinary Save operation (in any reimplementation of 0138 * saveFile()) call isExporting(). 0139 */ 0140 bool exportDocument(const QUrl &url); 0141 0142 /** 0143 * @brief Sets whether the document can be edited or is read only. 0144 * 0145 * This recursively applied to all child documents and 0146 * KoView::updateReadWrite is called for every attached 0147 * view. 0148 */ 0149 virtual void setReadWrite(bool readwrite = true); 0150 0151 /** 0152 * To be preferred when a document exists. It is fast when calling 0153 * it multiple times since it caches the result that readNativeFormatMimeType() 0154 * delivers. 0155 * This comes from the X-KDE-NativeMimeType key in the .desktop file. 0156 */ 0157 virtual QByteArray nativeFormatMimeType() const = 0; 0158 0159 /** 0160 * Returns the OASIS OpenDocument mimetype of the document, if supported 0161 * This comes from the X-KDE-NativeOasisMimeType key in the 0162 * desktop file 0163 * 0164 * @return the oasis mimetype or, if it hasn't one, the nativeformatmimetype. 0165 */ 0166 QByteArray nativeOasisMimeType() const override = 0; 0167 0168 /// Checks whether a given mimetype can be handled natively. 0169 bool isNativeFormat(const QByteArray& mimetype) const; 0170 0171 /// Returns a list of the mimetypes considered "native", i.e. which can 0172 /// be saved by KoDocument without a filter, in *addition* to the main one 0173 virtual QStringList extraNativeMimeTypes() const = 0; 0174 0175 /** 0176 * Return the set of SupportedSpecialFormats that the application wants to 0177 * offer in the "Save" file dialog. 0178 */ 0179 int supportedSpecialFormats() const override; 0180 0181 /** 0182 * Returns the actual mimetype of the document 0183 */ 0184 QByteArray mimeType() const override; 0185 0186 /** 0187 * @brief Sets the mime type for the document. 0188 * 0189 * When choosing "save as" this is also the mime type 0190 * selected by default. 0191 */ 0192 void setMimeType(const QByteArray & mimeType) override; 0193 0194 /** 0195 * @brief Set the format in which the document should be saved. 0196 * 0197 * This is called on loading, and in "save as", so you shouldn't 0198 * have to call it. 0199 * 0200 * @param mimeType the mime type (format) to use. 0201 * @param specialOutputFlag is for "save as older version" etc. 0202 */ 0203 void setOutputMimeType(const QByteArray & mimeType, int specialOutputFlag = 0) override; 0204 QByteArray outputMimeType() const override; 0205 int specialOutputFlag() const override; 0206 0207 /** 0208 * Returns true if this document was the result of opening a foreign 0209 * file format and if the user hasn't yet saved the document (in any 0210 * format). 0211 * 0212 * Used by KoMainWindow to warn the user when s/he lazily presses 0213 * CTRL+S to save in the same foreign format, putting all his/her 0214 * formatting at risk (normally an export confirmation only comes up 0215 * with Save As). 0216 * 0217 * @param exporting specifies whether this is the setting for a 0218 * File --> Export or File --> Save/Save As operation. 0219 */ 0220 bool confirmNonNativeSave(const bool exporting) const; 0221 void setConfirmNonNativeSave(const bool exporting, const bool on); 0222 0223 0224 /** 0225 * @return true if saving/exporting should inhibit the option dialog 0226 */ 0227 bool saveInBatchMode() const; 0228 0229 /** 0230 * @param batchMode if true, do not show the option dialog when saving or exporting. 0231 */ 0232 void setSaveInBatchMode(const bool batchMode); 0233 0234 /** 0235 * Sets the error message to be shown to the user (use i18n()!) 0236 * when loading or saving fails. 0237 * If you asked the user about something and they chose "Cancel", 0238 * set the message to the magic string "USER_CANCELED", to skip the error dialog. 0239 */ 0240 void setErrorMessage(const QString& errMsg); 0241 0242 /** 0243 * Return the last error message. Usually KoDocument takes care of 0244 * showing it; this method is mostly provided for non-interactive use. 0245 */ 0246 QString errorMessage() const; 0247 0248 0249 /** 0250 * Show the last error message in a message box. 0251 * The dialog box will mention a loading problem. 0252 * openUrl/openFile takes care of doing it, but not loadNativeFormat itself, 0253 * so this is often called after loadNativeFormat returned false. 0254 */ 0255 void showLoadingErrorDialog(); 0256 0257 0258 /** 0259 * @brief Generates a preview picture of the document 0260 * @note The preview is used in the File Dialog and also to create the Thumbnail 0261 */ 0262 virtual QPixmap generatePreview(const QSize& size); 0263 0264 /** 0265 * Paints the data itself. 0266 * It's this method that %Calligra Parts have to implement. 0267 * 0268 * @param painter The painter object onto which will be drawn. 0269 * @param rect The rect that should be used in the painter object. 0270 */ 0271 virtual void paintContent(QPainter &painter, const QRect &rect) = 0; 0272 0273 /** 0274 * Tells the document that its title has been modified, either because 0275 * the modified status changes (this is done by setModified() ) or 0276 * because the URL or the document-info's title changed. 0277 */ 0278 void setTitleModified(); 0279 0280 /** 0281 * @return true if the document is empty. 0282 */ 0283 bool isEmpty() const override; 0284 0285 /** 0286 * @brief Sets the document to empty. 0287 * 0288 * Used after loading a template 0289 * (which is not empty, but not the user's input). 0290 * 0291 * @see isEmpty() 0292 */ 0293 virtual void setEmpty(); 0294 0295 /** 0296 * @brief Loads a document from a store. 0297 * 0298 * You should never have to reimplement. 0299 * 0300 * @param store The store to load from 0301 * @param url An internal url, like tar:/1/2 0302 */ 0303 virtual bool loadFromStore(KoStore *store, const QString& url); 0304 0305 /** 0306 * @brief Loads an OASIS document from a store. 0307 * This is used for both the main document and embedded objects. 0308 */ 0309 bool loadOasisFromStore(KoStore *store) override; 0310 0311 /** 0312 * @brief Saves a sub-document to a store. 0313 * 0314 * You should not have to reimplement this. 0315 */ 0316 bool saveToStore(KoStore *store, const QString& path) override; 0317 0318 /** 0319 * Reimplement this method to load the contents of your Calligra document, 0320 * from the XML document. This is for the pre-Oasis file format (maindoc.xml). 0321 */ 0322 virtual bool loadXML(const KoXmlDocument & doc, KoStore *store) = 0; 0323 0324 0325 /** 0326 * Reimplement this to save the contents of the %Calligra document into 0327 * a QDomDocument. The framework takes care of saving it to the store. 0328 */ 0329 virtual QDomDocument saveXML(); 0330 0331 /** 0332 * Return a correctly created QDomDocument for this KoDocument, 0333 * including processing instruction, complete DOCTYPE tag (with systemId and publicId), and root element. 0334 * @param tagName the name of the tag for the root element 0335 * @param version the DTD version (usually the application's version). 0336 */ 0337 QDomDocument createDomDocument(const QString& tagName, const QString& version) const; 0338 0339 /** 0340 * Return a correctly created QDomDocument for an old (1.3-style) %Calligra document, 0341 * including processing instruction, complete DOCTYPE tag (with systemId and publicId), and root element. 0342 * This static method can be used e.g. by filters. 0343 * @param appName the app's instance name, e.g. words, kspread, kpresenter etc. 0344 * @param tagName the name of the tag for the root element, e.g. DOC for words/kpresenter. 0345 * @param version the DTD version (usually the application's version). 0346 */ 0347 static QDomDocument createDomDocument(const QString& appName, const QString& tagName, const QString& version); 0348 0349 /** 0350 * The first thing to do in loadOasis is get hold of the office:body tag, then its child. 0351 * If the child isn't the expected one, the error message can indicate what it is instead. 0352 * This method returns a translated name for the type of document, 0353 * e.g. i18n("Word Processing") for office:text. 0354 */ 0355 static QString tagNameToDocumentType(const QString& localName); 0356 0357 /** 0358 * Loads a document in the native format from a given URL. 0359 * Reimplement if your native format isn't XML. 0360 * 0361 * @param file the file to load - usually KReadOnlyPart::m_file or the result of a filter 0362 */ 0363 virtual bool loadNativeFormat(const QString & file); 0364 0365 /** 0366 * Saves the document in native format, to a given file 0367 * You should never have to reimplement. 0368 * Made public for writing templates. 0369 */ 0370 virtual bool saveNativeFormat(const QString & file); 0371 0372 /** 0373 * Saves the document in native ODF format to the given store. 0374 */ 0375 bool saveNativeFormatODF(KoStore *store, const QByteArray &mimeType); 0376 0377 /** 0378 * Saves the document in the native format to the given store. 0379 */ 0380 bool saveNativeFormatCalligra(KoStore *store); 0381 0382 /** 0383 * Activate/deactivate/configure the autosave feature. 0384 * @param delay in seconds, 0 to disable 0385 */ 0386 void setAutoSave(int delay); 0387 0388 /** 0389 * Checks whether the document is currently in the process of autosaving 0390 */ 0391 bool isAutosaving() const override; 0392 0393 /** 0394 * Set whether the next openUrl call should check for an auto-saved file 0395 * and offer to open it. This is usually true, but can be turned off 0396 * (e.g. for the preview module). This only checks for names auto-saved 0397 * files, unnamed auto-saved files are only checked on KoApplication startup. 0398 */ 0399 void setCheckAutoSaveFile(bool b); 0400 0401 /** 0402 * Set whether the next openUrl call should show error message boxes in case 0403 * of errors. This is usually the case, but e.g. not when generating thumbnail 0404 * previews. 0405 */ 0406 void setAutoErrorHandlingEnabled(bool b); 0407 0408 /** 0409 * Checks whether error message boxes should be shown. 0410 */ 0411 bool isAutoErrorHandlingEnabled() const; 0412 0413 /** 0414 * Retrieve the default value for autosave in seconds. 0415 * Called by the applications to use the correct default in their config 0416 */ 0417 static int defaultAutoSave(); 0418 0419 /** 0420 * @return the information concerning this document. 0421 * @see KoDocumentInfo 0422 */ 0423 KoDocumentInfo *documentInfo() const; 0424 0425 /** 0426 * @return the Rdf metadata for this document. 0427 * This method should only be used by code that links to 0428 * the RDF system and needs full access to the KoDocumentRdf object. 0429 * @see KoDocumentRdf 0430 */ 0431 KoDocumentRdfBase *documentRdf() const; 0432 0433 /** 0434 * Replace the current rdf document with the given rdf document. The existing RDF document 0435 * will be deleted, and if RDF support is compiled out, KoDocument does not take ownership. 0436 * Otherwise, KoDocument will own the rdf document. 0437 */ 0438 void setDocumentRdf(KoDocumentRdfBase *rdfDocument); 0439 0440 /** 0441 * @return the object to report progress to. 0442 * One can add more KoUpdaters to it to make the progress reporting more 0443 * accurate. If no active progress reporter is present, 0 is returned. 0444 **/ 0445 KoProgressUpdater *progressUpdater() const; 0446 0447 /** 0448 * Set a custom progress proxy to use to report loading 0449 * progress to. 0450 */ 0451 void setProgressProxy(KoProgressProxy *progressProxy); 0452 KoProgressProxy* progressProxy() const; 0453 0454 /** 0455 * Return true if url() is a real filename, false if url() is 0456 * an internal url in the store, like "tar:/..." 0457 */ 0458 bool isStoredExtern() const override; 0459 0460 /** 0461 * @return the page layout associated with this document (margins, pageSize, etc). 0462 * Override this if you want to provide different sized pages. 0463 * 0464 * @see KoPageLayout 0465 */ 0466 virtual KoPageLayout pageLayout(int pageNumber = 0) const; 0467 virtual void setPageLayout(const KoPageLayout &pageLayout); 0468 0469 /** 0470 * Performs a cleanup of unneeded backup files 0471 */ 0472 void removeAutoSaveFiles(); 0473 0474 void setBackupFile(bool _b); 0475 0476 bool backupFile()const; 0477 0478 /** 0479 * Returns true if this document or any of its internal child documents are modified. 0480 */ 0481 Q_INVOKABLE bool isModified() const override; 0482 0483 /** 0484 * Returns true during loading (openUrl can be asynchronous) 0485 */ 0486 bool isLoading() const; 0487 0488 int queryCloseDia(); 0489 0490 /** 0491 * Sets the backup path of the document 0492 */ 0493 void setBackupPath(const QString & _path); 0494 0495 /** 0496 * @return path to the backup document 0497 */ 0498 QString backupPath()const; 0499 0500 /** 0501 * @return caption of the document 0502 * 0503 * Caption is of the form "[title] - [url]", 0504 * built out of the document info (title) and pretty-printed 0505 * document URL. 0506 * If the title is not present, only the URL it returned. 0507 */ 0508 QString caption() const; 0509 0510 /** 0511 * Sets the document URL to empty URL 0512 * KParts doesn't allow this, but %Calligra apps have e.g. templates 0513 * After using loadNativeFormat on a template, one wants 0514 * to set the url to QUrl() 0515 */ 0516 void resetURL() override; 0517 0518 bool hasExternURL() const; 0519 0520 /** 0521 * @internal (public for KoMainWindow) 0522 */ 0523 void setMimeTypeAfterLoading(const QString& mimeType); 0524 0525 /** 0526 * @return returns the number of pages in the document. 0527 */ 0528 virtual int pageCount() const; 0529 0530 /** 0531 * Returns the unit used to display all measures/distances. 0532 */ 0533 KoUnit unit() const; 0534 0535 /** 0536 * Sets the unit used to display all measures/distances. 0537 */ 0538 void setUnit(const KoUnit &unit); 0539 0540 /** 0541 * Save the unit to the settings writer 0542 * 0543 * @param settingsWriter 0544 */ 0545 void saveUnitOdf(KoXmlWriter *settingsWriter) const; 0546 0547 QList<KoVersionInfo> &versionList(); 0548 0549 bool loadNativeFormatFromStore(QByteArray &data); 0550 0551 /** 0552 * Adds a new version and then saves the whole document. 0553 * @param comment the comment for the version 0554 * @return true on success, otherwise false 0555 */ 0556 bool addVersion(const QString& comment); 0557 0558 /// return the grid data for this document. 0559 KoGridData &gridData(); 0560 0561 /// returns the guides data for this document. 0562 KoGuidesData &guidesData(); 0563 0564 void clearUndoHistory(); 0565 0566 0567 /** 0568 * Sets the modified flag on the document. This means that it has 0569 * to be saved or not before deleting it. 0570 */ 0571 Q_INVOKABLE virtual void setModified(bool _mod); 0572 0573 /** 0574 * Initialize an empty document using default values 0575 */ 0576 virtual void initEmpty(); 0577 0578 /** 0579 * Returns the global undo stack 0580 */ 0581 KUndo2Stack *undoStack(); 0582 0583 0584 /** 0585 * Set the output stream to report profile information to. 0586 */ 0587 void setProfileStream(QTextStream *profilestream); 0588 0589 /** 0590 * Set the output stream to report profile information to. 0591 */ 0592 void setProfileReferenceTime(const QTime& referenceTime); 0593 0594 /// If set, the document shall be saved even if it is not marked as modified. 0595 /// @see setAlwaysAllowSaving() 0596 bool alwaysAllowSaving() const; 0597 0598 /// Set alwaysAllowSaving to @p allow. 0599 /// Enables applications to always allow saving even when document is not modified. 0600 /// This makes it possible to save settings/context info without marking 0601 /// the document as modified. 0602 /// @see alwaysAllowSaving() 0603 void setAlwaysAllowSaving(bool allow); 0604 0605 public Q_SLOTS: 0606 0607 /** 0608 * Adds a command to the undo stack and executes it by calling the redo() function. 0609 * @param command command to add to the undo stack 0610 */ 0611 virtual void addCommand(KUndo2Command *command); 0612 0613 /** 0614 * Begins recording of a macro command. At the end endMacro needs to be called. 0615 * @param text command description 0616 */ 0617 virtual void beginMacro(const KUndo2MagicString &text); 0618 0619 /** 0620 * Ends the recording of a macro command. 0621 */ 0622 virtual void endMacro(); 0623 0624 Q_SIGNALS: 0625 0626 /** 0627 * This signal is emitted when the unit is changed by setUnit(). 0628 * It is common to connect views to it, in order to change the displayed units 0629 * (e.g. in the rulers) 0630 */ 0631 void unitChanged(const KoUnit &unit); 0632 0633 /** 0634 * Progress info while loading or saving. The value is in percents (i.e. a number between 0 and 100) 0635 * Your KoDocument-derived class should emit the signal now and then during load/save. 0636 * KoMainWindow will take care of displaying a progress bar automatically. 0637 */ 0638 void sigProgress(int value); 0639 0640 /** 0641 * Emitted e.g. at the beginning of a save operation 0642 * This is emitted by KoDocument and used by KoView to display a statusbar message 0643 */ 0644 void statusBarMessage(const QString& text); 0645 0646 /** 0647 * Emitted e.g. at the end of a save operation 0648 * This is emitted by KoDocument and used by KoView to clear the statusbar message 0649 */ 0650 void clearStatusBarMessage(); 0651 0652 /** 0653 * Emitted when the document is modified 0654 */ 0655 void modified(bool); 0656 0657 void titleModified(const QString &caption, bool isModified); 0658 0659 protected: 0660 0661 friend class KoPart; 0662 0663 /** 0664 * Generate a name for the document. 0665 */ 0666 QString newObjectName(); 0667 0668 QString autoSaveFile(const QString & path) const; 0669 void setDisregardAutosaveFailure(bool disregardFailure); 0670 0671 /** 0672 * Loads a document from KReadOnlyPart::m_file (KParts takes care of downloading 0673 * remote documents). 0674 * Applies a filter if necessary, and calls loadNativeFormat in any case 0675 * You should not have to reimplement, except for very special cases. 0676 * 0677 * NOTE: this method also creates a new KoView instance! 0678 * 0679 * This method is called from the KReadOnlyPart::openUrl method. 0680 */ 0681 virtual bool openFile(); 0682 0683 /** 0684 * This method is called by @a openFile() to allow applications to setup there 0685 * own KoProgressUpdater-subTasks which are then taken into account for the 0686 * displayed progressbar during loading. 0687 */ 0688 virtual void setupOpenFileSubProgress(); 0689 0690 /** 0691 * Saves a document to KReadOnlyPart::m_file (KParts takes care of uploading 0692 * remote documents) 0693 * Applies a filter if necessary, and calls saveNativeFormat in any case 0694 * You should not have to reimplement, except for very special cases. 0695 */ 0696 virtual bool saveFile(); 0697 0698 /** 0699 * Overload this function if you have to load additional files 0700 * from a store. This function is called after loadXML() 0701 * and after loadChildren() have been called. 0702 */ 0703 virtual bool completeLoading(KoStore *store); 0704 0705 /** 0706 * If you want to write additional files to a store, 0707 * then you must do it here. 0708 * In the implementation, you should prepend the document 0709 * url (using url().url()) before the filename, so that everything is kept relative 0710 * to this document. For instance it will produce urls such as 0711 * tar:/1/pictures/picture0.png, if the doc url is tar:/1 0712 * But do this ONLY if the document is not stored extern (see isStoredExtern() ). 0713 * If it is, then the pictures should be saved to tar:/pictures. 0714 */ 0715 virtual bool completeSaving(KoStore *store); 0716 0717 0718 /** @internal */ 0719 virtual void setModified(); 0720 0721 /** 0722 * Returns whether or not the current openUrl() or openFile() call is 0723 * actually an import operation (like File --> Import). 0724 * This is for informational purposes only. 0725 */ 0726 bool isImporting() const; 0727 0728 /** 0729 * Returns whether or not the current saveFile() call is actually an export 0730 * operation (like File --> Export). 0731 * If this function returns true during saveFile() and you are changing 0732 * some sort of state, you _must_ restore it before the end of saveFile(); 0733 * otherwise, File --> Export will not work properly. 0734 */ 0735 bool isExporting() const; 0736 0737 public: 0738 0739 QString localFilePath() const override; 0740 void setLocalFilePath( const QString &localFilePath ); 0741 0742 virtual KoDocumentInfoDlg* createDocumentInfoDialog(QWidget *parent, KoDocumentInfo *docInfo) const; 0743 0744 bool isReadWrite() const; 0745 0746 QUrl url() const override; 0747 void setUrl(const QUrl &url) override; 0748 0749 virtual bool closeUrl(bool promptToSave = true); 0750 0751 virtual bool saveAs( const QUrl &url ); 0752 0753 public Q_SLOTS: 0754 0755 virtual bool save(); 0756 bool waitSaveComplete(); 0757 0758 Q_SIGNALS: 0759 0760 void completed(); 0761 void canceled(const QString &); 0762 0763 private Q_SLOTS: 0764 0765 void slotAutoSave(); 0766 0767 /// Called by the undo stack when undo or redo is called 0768 void slotUndoStackIndexChanged(int idx); 0769 0770 protected: 0771 bool oldLoadAndParse(KoStore *store, const QString& filename, KoXmlDocument& doc); 0772 private: 0773 bool saveToStream(QIODevice *dev); 0774 0775 QString checkImageMimeTypes(const QString &mimeType, const QUrl &url) const; 0776 0777 bool loadNativeFormatFromStore(const QString& file); 0778 bool loadNativeFormatFromStoreInternal(KoStore *store); 0779 0780 bool savePreview(KoStore *store); 0781 bool saveOasisPreview(KoStore *store, KoXmlWriter *manifestWriter); 0782 0783 QString prettyPathOrUrl() const; 0784 0785 bool queryClose(); 0786 bool saveToUrl(); 0787 bool openUrlInternal(const QUrl &url); 0788 0789 void abortLoad(); 0790 0791 class Private; 0792 Private *const d; 0793 0794 Q_PRIVATE_SLOT(d, void _k_slotJobFinished( KJob * job )) 0795 Q_PRIVATE_SLOT(d, void _k_slotStatJobFinished(KJob*)) 0796 Q_PRIVATE_SLOT(d, void _k_slotGotMimeType(KIO::Job *job, const QString &mime)) 0797 Q_PRIVATE_SLOT(d, void _k_slotUploadFinished( KJob * job )) 0798 }; 0799 0800 Q_DECLARE_METATYPE(KoDocument*) 0801 0802 #endif