F:/KPlato/koffice/libs/kofficecore/KoDocument.h

Aller à la documentation de ce fichier.
00001 // -*- c-basic-offset: 4 -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00004    Copyright (C) 2000-2005 David Faure <faure@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef __ko_document_h__
00023 #define __ko_document_h__
00024 
00025 class KoTextDocument;
00026 #include <QDateTime>
00027 #include <QList>
00028 #include <QMatrix>
00029 //Added by qt3to4:
00030 #include <QPixmap>
00031 #include <QByteArray>
00032 #include <Q3PtrList>
00033 #include <QList>
00034 
00035 #include <kparts/part.h>
00036 #include <kurl.h>
00037 #include <kservice.h>
00038 #include <KoGlobal.h>
00039 #include <KoUnit.h>
00040 #include <KoPageLayout.h>
00041 #include <koffice_export.h>
00042 
00043 #include <KoXmlReader.h>
00044 
00045 
00046 class QDomElement;
00047 class QDomDocument;
00048 class QXmlSimpleReader;
00049 
00050 class KoStore;
00051 class KoMainWindow;
00052 
00053 class KoChild;
00054 class KoDocumentChild;
00055 class KoView;
00056 class KoDocumentInfo;
00057 // class DCOPObject;
00058 class KoOasisStyles;
00059 class KoXmlWriter;
00060 class KoOpenPane;
00061 
00062 
00063 class KoVersionInfo
00064 {
00065 public:
00066     QDateTime date;
00067     QString saved_by;
00068     QString comment;
00069     QString title;
00070 
00071     QByteArray data; //the content of the compressed version
00072 };
00073 
00081 class KOFFICECORE_EXPORT KoDocument : public KParts::ReadWritePart
00082 {
00083     Q_OBJECT
00084 //     Q_PROPERTY( QByteArray dcopObjectId READ dcopObjectId)
00085     Q_PROPERTY( bool backupFile READ backupFile WRITE setBackupFile )
00086 
00087 public:
00088 
00103     KoDocument( QWidget* parentWidget,
00104                 QObject* parent,
00105                 bool singleViewMode = false );
00106 
00113     virtual ~KoDocument();
00114 
00119     bool isSingleViewMode() const;
00120 
00124     bool isEmbedded() const;
00125 
00141     virtual KAction *action( const QDomElement &element ) const;
00142 
00147     virtual QDomDocument domDocument() const;
00148 
00152     virtual void setManager( KParts::PartManager *manager );
00153 
00158     virtual bool openURL( const KUrl & url );
00159 
00170     bool import( const KUrl &url );
00171 
00182     bool exp0rt( const KUrl &url );
00183 
00191     virtual void setReadWrite( bool readwrite = true );
00192 
00203     static QByteArray readNativeFormatMimeType( KInstance *instance = 0 );
00204 
00215     static QStringList readExtraNativeMimeTypes( KInstance *instance = 0 );
00216 
00222     static KService::Ptr readNativeService( KInstance *instance = 0 );
00223 
00227     static void setupXmlReader( QXmlSimpleReader& reader, bool namespaceProcessing = false );
00228 
00236     virtual QByteArray nativeFormatMimeType() const;
00237 
00242     QByteArray nativeOasisMimeType() const;
00243 
00245     bool isNativeFormat( const QByteArray& mimetype ) const;
00246 
00249     virtual QStringList extraNativeMimeTypes() const;
00250 
00252     enum { /*SaveAsKOffice1dot1 = 1,*/ // old and removed
00253            SaveAsDirectoryStore = 2,
00254            SaveAsFlatXML = 4
00255            // bitfield! next value is 8
00256          };
00257 
00262     virtual int supportedSpecialFormats() const;
00263 
00267     QByteArray mimeType() const;
00268 
00275     void setMimeType( const QByteArray & mimeType );
00276 
00286     void setOutputMimeType( const QByteArray & mimeType, int specialOutputFlag = 0 );
00287     QByteArray outputMimeType() const;
00288     int specialOutputFlag() const;
00289 
00303     bool confirmNonNativeSave( const bool exporting ) const;
00304     void setConfirmNonNativeSave( const bool exporting, const bool on );
00305 
00306     virtual bool wantExportConfirmation() const;
00307 
00314     void setErrorMessage( const QString& errMsg );
00315 
00321     QString errorMessage() const;
00322 
00329     void showSavingErrorDialog();
00330 
00338     void showLoadingErrorDialog();
00339 
00343     KoView *createView( QWidget *parent = 0 );
00344 
00351     virtual void addView( KoView *view );
00352 
00356     virtual void removeView( KoView *view );
00357 
00361     const QList<KoView*> & views() const;
00362 
00366     int viewCount() const;
00367 
00371     virtual KParts::Part *hitTest( QWidget *widget, const QPoint &globalPos );
00372 
00390     virtual KoDocument *hitTest( const QPoint &pos, KoView* view, const QMatrix& matrix = QMatrix() );
00391 
00402     virtual void paintEverything( QPainter &painter, const QRect &rect, bool transparent = false,
00403                                   KoView *view = 0L, double zoomX = 1.0, double zoomY = 1.0 );
00404 
00409     virtual QPixmap generatePreview( const QSize& size );
00410 
00422     virtual void paintChildren( QPainter &painter, const QRect &rect, KoView *view, double zoomX = 1.0, double zoomY = 1.0 );
00423 
00435     virtual void paintChild( KoDocumentChild *child, QPainter &painter, KoView *view,
00436                              double zoomX = 1.0, double zoomY = 1.0 );
00437 
00451     virtual void paintContent( QPainter &painter, const QRect &rect, bool transparent = false,
00452                                double zoomX = 1.0, double zoomY = 1.0 ) = 0;
00453 
00457     bool checkAutoSaveFile();
00458 
00466     enum InitDocFlags { InitDocAppStarting, InitDocFileNew, InitDocFileClose, InitDocEmbedded, InitDocEmpty };
00467 
00474     virtual void showStartUpWidget(KoMainWindow* parent, bool alwaysShow = false);
00475 
00480     virtual void setModified( bool _mod );
00481 
00487     virtual void setTitleModified();
00488 
00492     virtual bool isEmpty() const { return m_bEmpty; }
00493 
00502     virtual void setEmpty() { m_bEmpty = true; }
00503 
00512     virtual bool loadFromStore( KoStore* store, const QString& url );
00513 
00518     virtual bool loadOasisFromStore( KoStore* store );
00519 
00525     virtual bool saveToStore( KoStore* store, const QString& path );
00526 
00535     virtual bool loadXML( QIODevice *, const KoXmlDocument & doc ) = 0;
00536 
00543     virtual bool loadOasis( const KoXmlDocument & doc, KoOasisStyles& oasisStyles,
00544                             const KoXmlDocument & settings, KoStore* store ) = 0;
00545 
00550     virtual bool saveOasis( KoStore* store, KoXmlWriter* manifestWriter ) = 0;
00551 
00556     virtual QDomDocument saveXML();
00557 
00565     QDomDocument createDomDocument( const QString& tagName, const QString& version ) const;
00566 
00584     static KoXmlWriter* createOasisXmlWriter( QIODevice* dev, const char* rootElementName );
00585 
00594     static QDomDocument createDomDocument( const QString& appName, const QString& tagName, const QString& version );
00595 
00602     static QString tagNameToDocumentType( const QString& localName );
00603 
00609     virtual bool saveToStream( QIODevice * dev );
00610 
00617     virtual bool loadNativeFormat( const QString & file );
00618 
00624     virtual bool saveNativeFormat( const QString & file );
00625 
00630     void setAutoSave( int delay );
00631 
00635     bool isAutosaving() const;
00636 
00642     void setCheckAutoSaveFile( bool b );
00643 
00649     void setAutoErrorHandlingEnabled( bool b );
00650 
00655     bool isAutoErrorHandlingEnabled() const;
00656 
00661     static int defaultAutoSave() { return s_defaultAutoSave; }
00662 
00667     const Q3PtrList<KoDocumentChild>& children() const;
00668 
00676     KoDocumentChild *child( KoDocument *doc );
00677 
00682     KoDocumentInfo *documentInfo() const;
00683 
00684     void setViewBuildDocument( KoView *view, const QDomDocument &doc );
00685     QDomDocument viewBuildDocument( KoView *view );
00686 
00694     virtual void addShell( KoMainWindow *shell );
00695 
00700     virtual void removeShell( KoMainWindow *shell );
00701 
00705     const Q3PtrList<KoMainWindow>& shells() const;
00706 
00710     int shellCount() const;
00711 
00715     static Q3PtrList<KoDocument> *documentList() { return s_documentList; }
00716 
00723 //     virtual DCOPObject * dcopObject();
00724 
00728 //     QByteArray dcopObjectId() const;
00729 
00733     void emitProgress( int value ) { emit sigProgress( value ); }
00734 
00735     bool isInOperation() const;
00736     virtual void emitBeginOperation();
00737     virtual void emitEndOperation();
00738 
00743     virtual bool isStoredExtern() const;
00744 
00751     virtual KoPageLayout pageLayout(int pageNumber = 0) const;
00752 
00756     void removeAutoSaveFiles();
00757 
00758     void setBackupFile( bool _b );
00759 
00760     bool backupFile()const;
00761 
00765     bool isModified() const;
00766 
00770     bool isLoading() const;
00771 
00772     int queryCloseExternalChildren();
00773     int queryCloseDia();
00774 
00788     void setDoNotSaveExtDoc( bool on = true );
00789 
00793     void setBackupPath( const QString & _path );
00794 
00798     QString backupPath()const;
00799 
00805     void setCurrent( bool on = true );
00806 
00810     void forceCurrent( bool on );
00811     bool isCurrent() const;
00812 
00813     void setTitleModified( const QString caption, bool mod );
00814 
00821     void resetURL() { m_url = KUrl(); m_file.clear(); }
00822 
00826     void setStoreInternal( bool i );
00827 
00831     bool storeInternal() const;
00832 
00833     bool hasExternURL() const;
00834 
00839     void setURL( const KUrl& url ) { m_url = url; }
00840 
00849     QString &file() { return m_file; }
00850 
00859     void setFile( const QString &file ) { m_file = file; }
00860 
00864     void setMimeTypeAfterLoading( const QString& mimeType );
00865 
00869     virtual int pageCount() const { return 1; }
00870 
00876     virtual QList<KoTextDocument *> allTextDocuments() const;
00877 
00882     KoUnit::Unit unit() const;
00883 
00888     void setUnit( KoUnit::Unit u );
00889 
00896     QString unitName() const;
00897 
00903     void setTemplateType(const QString& _templateType);
00909     QString templateType() const;
00910 
00916     virtual bool showEmbedInitDialog(QWidget* parent);
00917 
00918 
00919     QList<KoVersionInfo> &versionList();
00920 
00921     bool loadNativeFormatFromStore( QByteArray &data );
00922 
00928     bool addVersion( const QString& comment );
00929 
00930 public slots:
00935     virtual void initEmpty();
00936 
00937 signals:
00938 
00944     void unitChanged(KoUnit::Unit);
00945 
00954     void childChanged( KoDocumentChild *child );
00955 
00961     void sigProgress( int value );
00962 
00967     void sigStatusBarMessage( const QString& text );
00968 
00973     void sigClearStatusBarMessage();
00974 
00975     void sigBeginOperation();
00976     void sigEndOperation();
00977 
00981     void modified( bool );
00982 
00983     void closeEmbedInitDialog();
00984 
00985 protected slots:
00991     virtual void openExistingFile( const KUrl& url );
00997     virtual void openTemplate( const KUrl& url );
00998 
00999     void deleteOpenPaneDelayed();
01000 
01001 protected:
01002 
01006     QString newObjectName();
01007 
01008     QString autoSaveFile( const QString & path ) const;
01009 
01010     virtual KoView *createViewInstance( QWidget *parent ) = 0;
01011 
01020     virtual bool openFile();
01021 
01028     virtual bool saveFile();
01029 
01040     virtual QWidget* createCustomDocumentWidget(QWidget *parent);
01041 
01062     virtual bool loadChildren( KoStore* );
01063 
01069     virtual bool saveChildren( KoStore* store );
01070 
01077     virtual bool saveChildrenOasis( KoStore* store, KoXmlWriter* manifestWriter );
01078 
01084     virtual bool completeLoading( KoStore* store );
01085 
01096     virtual bool completeSaving( KoStore* store );
01097 
01109     virtual void insertChild( KoDocumentChild *child );
01110 
01112     virtual void setModified() { KParts::ReadWritePart::setModified(); }
01113 
01114     KoPageLayout m_pageLayout;
01115 
01121     virtual bool saveExternalChildren();
01122 
01128     bool isImporting() const;
01129 
01137     bool isExporting() const;
01138 
01146     KoOpenPane* createOpenPane( QWidget* parent, KInstance* instance,
01147                                 const QString& templateType = QString::null);
01148 
01149 private slots:
01150     void slotChildChanged( KoChild *c );
01151     void slotChildDestroyed();
01152     void slotAutoSave();
01153     void slotStarted( KIO::Job* );
01154     void startCustomDocument();
01159     void deleteOpenPane();
01160 
01161 private:
01162     virtual void insertChild(QObject *) { Q_ASSERT( 0 ); } // avoid compiler warning, but don't call deprecated insertChild() in QObject
01163 
01164     KService::Ptr nativeService();
01165     bool oldLoadAndParse( KoStore* store, const QString& filename, KoXmlDocument& doc );
01166     bool loadNativeFormatFromStore( const QString& file );
01167     bool loadNativeFormatFromStoreInternal( KoStore * store );
01168 
01169     bool savePreview( KoStore* store );
01170     bool saveOasisPreview( KoStore* store, KoXmlWriter* manifestWriter );
01171     class Private;
01172     Private *d;
01173     KService::Ptr m_nativeService;
01174     bool m_bEmpty;
01175     static Q3PtrList<KoDocument> *s_documentList;
01176     static const int s_defaultAutoSave;
01177 };
01178 
01179 #endif

Généré le Wed Nov 22 23:41:02 2006 pour KPlato par  doxygen 1.5.1-p1