lib Library API Documentation

koDocument.h

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, 2001 David Faure <david@mandrakesoft.com>
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., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef __ko_document_h__
00023 #define __ko_document_h__
00024 
00025 namespace std { }
00026 using namespace std;
00027 #include <qwmatrix.h>
00028 
00029 #include <kparts/part.h>
00030 #include <kurl.h>
00031 #include <kservice.h>
00032 #include <koGlobal.h>
00033 
00034 class QDomElement;
00035 class QDomDocument;
00036 
00037 class KoStore;
00038 class KoMainWindow;
00039 
00040 class KoChild;
00041 class KoDocumentChild;
00042 class KoView;
00043 class KoDocumentInfo;
00044 class DCOPObject;
00045 
00046 
00054 class KoDocument : public KParts::ReadWritePart
00055 {
00056     Q_OBJECT
00057     Q_PROPERTY( QCString dcopObjectId READ dcopObjectId)
00058     Q_PROPERTY( bool backupFile READ backupFile WRITE setBackupFile )
00059 
00060 public:
00061 
00078     KoDocument( QWidget* parentWidget,
00079                 const char* widgetName,
00080                 QObject* parent,
00081                 const char* name,
00082                 bool singleViewMode = false );
00083 
00090     virtual ~KoDocument();
00091 
00096     bool isSingleViewMode() const;
00097 
00101     bool isEmbedded() const;
00102 
00118     virtual KAction *action( const QDomElement &element ) const;
00119 
00124     virtual QDomDocument domDocument() const;
00125 
00129     virtual void setManager( KParts::PartManager *manager );
00130 
00135     virtual bool openURL( const KURL & url );
00136 
00147     bool import( const KURL &url );
00148 
00159     bool exp0rt( const KURL &url );
00160 
00167     virtual void setReadWrite( bool readwrite = true );
00168 
00179     static QCString readNativeFormatMimeType( KInstance *instance = 0L );
00180 
00181     static KService::Ptr readNativeService( KInstance *instance = 0L );
00182 
00189     virtual QCString nativeFormatMimeType() const;
00190 
00191     KService::Ptr nativeService();
00192 
00193     enum { SaveAsKOffice1dot1 = 1, SaveAsDirectoryStore = 2 };
00194 
00198     QCString mimeType() const;
00199     
00205     void setMimeType( const QCString & mimeType );
00206 
00213     void setOutputMimeType( const QCString & mimeType, int specialOutputFlag = 0 );
00214     QCString outputMimeType() const;
00215     int specialOutputFlag() const;
00216 
00230     bool confirmNonNativeSave( const bool exporting ) const;
00231     void setConfirmNonNativeSave( const bool exporting, const bool on );
00232 
00239     void setErrorMessage( const QString& errMsg );
00240 
00244     KoView *createView( QWidget *parent = 0, const char *name = 0 );
00245 
00252     virtual void addView( KoView *view );
00253 
00257     virtual void removeView( KoView *view );
00258 
00262     const QPtrList<KoView> & views() const;
00263 
00267     int viewCount() const;
00268 
00272     virtual KParts::Part *hitTest( QWidget *widget, const QPoint &globalPos );
00273 
00290     virtual KoDocument *hitTest( const QPoint &pos, const QWMatrix &matrix = QWMatrix() );
00291 
00302     virtual void paintEverything( QPainter &painter, const QRect &rect, bool transparent = false,
00303                                   KoView *view = 0L, double zoomX = 1.0, double zoomY = 1.0 );
00304 
00309     virtual QPixmap generatePreview( const QSize& size );
00310 
00322     virtual void paintChildren( QPainter &painter, const QRect &rect, KoView *view, double zoomX = 1.0, double zoomY = 1.0 );
00323 
00335     virtual void paintChild( KoDocumentChild *child, QPainter &painter, KoView *view,
00336                              double zoomX = 1.0, double zoomY = 1.0 );
00337 
00351     virtual void paintContent( QPainter &painter, const QRect &rect, bool transparent = false,
00352                                double zoomX = 1.0, double zoomY = 1.0 ) = 0;
00353 
00357     bool checkAutoSaveFile();
00358 
00363     virtual bool initDoc() = 0; // BCI: pass a QWidget* parentWidget, to pass to KoTemplateChooseDia
00364 
00365     // Who calls initDoc?
00366     enum InitDocFlags { InitDocAppStarting, InitDocFileNew, InitDocFileClose, InitDocEmbedded };
00373     InitDocFlags initDocFlags() const;
00377     void setInitDocFlags( InitDocFlags flags );
00378 
00383     virtual void setModified( bool _mod );
00384 
00390     virtual void setTitleModified();
00391 
00395     virtual bool isEmpty() const { return m_bEmpty; }
00396 
00403     virtual void setEmpty() { m_bEmpty = true; }
00404 
00410     virtual bool loadFromStore( KoStore* store, const QString& url );
00411 
00416     virtual bool saveToStore( KoStore* store, const QString& path );
00417 
00426     virtual bool loadXML( QIODevice *, const QDomDocument & doc ) = 0;
00427 
00432     virtual QDomDocument saveXML();
00433 
00440     QDomDocument createDomDocument( const QString& tagName, const QString& version ) const;
00441 
00450     static QDomDocument createDomDocument( const QString& appName, const QString& tagName, const QString& version );
00451 
00457     virtual bool saveToStream( QIODevice * dev );
00458 
00465     virtual bool loadNativeFormat( const QString & file );
00466 
00472     virtual bool saveNativeFormat( const QString & file );
00473 
00478     void setAutoSave( int delay );
00479 
00483     bool isAutosaving();
00484 
00490     void setCheckAutoSaveFile( bool b );
00491 
00497     void setAutoErrorHandlingEnabled( bool b );
00498 
00503     bool isAutoErrorHandlingEnabled();
00504 
00509     static int defaultAutoSave() { return s_defaultAutoSave; }
00510 
00515     const QPtrList<KoDocumentChild>& children() const;
00516 
00524     KoDocumentChild *child( KoDocument *doc );
00525 
00530     KoDocumentInfo *documentInfo() const;
00531 
00532     void setViewBuildDocument( KoView *view, const QDomDocument &doc );
00533     QDomDocument viewBuildDocument( KoView *view );
00534 
00542     virtual void addShell( KoMainWindow *shell );
00543 
00548     virtual void removeShell( KoMainWindow *shell );
00549 
00553     const QPtrList<KoMainWindow>& shells() const;
00554 
00558     int shellCount() const;
00559 
00563     static QPtrList<KoDocument> *documentList() { return s_documentList; }
00564 
00570     virtual DCOPObject * dcopObject();
00571 
00575     QCString dcopObjectId() const;
00576 
00580     void emitProgress( int value ) { emit sigProgress( value ); }
00581 
00582     bool isInOperation();
00583     virtual void emitBeginOperation();
00584     virtual void emitEndOperation();
00585 
00590     virtual bool isStoredExtern();
00591 
00597     KoPageLayout pageLayout() const { return m_pageLayout; }
00598 
00602     void removeAutoSaveFiles();
00603 
00604     void setBackupFile( bool _b );
00605 
00606     bool backupFile()const;
00607 
00611     bool isModified();
00612 
00613     int queryCloseExternalChildren();
00614     int queryCloseDia();
00615 
00627     void setDoNotSaveExtDoc( bool on = true );
00628 
00632     void setBackupPath( const QString & _path );
00633 
00637     QString backupPath()const;
00638 
00644     void setCurrent( bool on = true );
00645 
00649     void forceCurrent( bool on );
00650     bool isCurrent() const;
00651 
00652     void setTitleModified( const QString caption, bool mod );
00653 
00660     void resetURL() { m_url = KURL(); m_file = QString::null; }
00661 
00665     void setStoreInternal( bool i );
00666 
00670     bool storeInternal() const;
00671 
00672     bool hasExternURL();
00673 
00678     void setURL( const KURL& url ) { m_url = url; }
00679 
00688     QString &file() { return m_file; }
00689 
00693     void setFile( const QString &file ) { m_file = file; }
00694 
00695 signals:
00704     void childChanged( KoDocumentChild *child );
00705 
00711     void sigProgress( int value );
00712 
00717     void sigStatusBarMessage( const QString& text );
00718 
00723     void sigClearStatusBarMessage();
00724 
00725     void sigBeginOperation();
00726     void sigEndOperation();
00727 
00728 protected:
00729 
00730     QString autoSaveFile( const QString & path ) const;
00731 
00732     virtual KoView *createViewInstance( QWidget *parent, const char *name ) = 0;
00733 
00742     virtual bool openFile();
00743 
00750     virtual bool saveFile();
00751 
00757     bool isImporting() const;
00758 
00766     bool isExporting() const;
00767 
00785     virtual bool loadChildren( KoStore* );
00786 
00792     virtual bool saveChildren( KoStore* store );
00793 
00799     virtual bool completeLoading( KoStore* store );
00800 
00811     virtual bool completeSaving( KoStore* store );
00812 
00824     virtual void insertChild( KoDocumentChild *child );
00825 
00827     virtual void setModified() { KParts::ReadWritePart::setModified(); }
00828 
00830     virtual void insertChild(QObject *o) { QObject::insertChild(o); }
00831 
00832     KoPageLayout m_pageLayout;
00833 
00839     bool saveExternalChildren(); // BCI: make this virtual
00840 
00841 private slots:
00842     void slotChildChanged( KoChild *c );
00843     void slotChildDestroyed();
00844     void slotAutoSave();
00845     void slotStarted( KIO::Job* );
00846 
00847 private:
00848     void savePreview( KoStore* store );
00849 
00850     class Private;
00851     Private *d;
00852     KService::Ptr m_nativeService;
00853     bool m_bEmpty;
00854     static QPtrList<KoDocument> *s_documentList;
00855     static const int s_defaultAutoSave;
00856 };
00857 
00858 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:47:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003