• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdegraphics
  • Sitemap
  • Contact Us
 

okular

generator.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004-5 by Enrico Ros <eros.kde@email.it>                *
00003  *   Copyright (C) 2005   by Piotr Szymanski <niedakh@gmail.com>           *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #ifndef _OKULAR_GENERATOR_H_
00012 #define _OKULAR_GENERATOR_H_
00013 
00014 #include <okular/core/okular_export.h>
00015 #include <okular/core/fontinfo.h>
00016 #include <okular/core/global.h>
00017 #include <okular/core/pagesize.h>
00018 
00019 #include <QtCore/QList>
00020 #include <QtCore/QObject>
00021 #include <QtCore/QSharedDataPointer>
00022 #include <QtCore/QString>
00023 #include <QtCore/QVariant>
00024 #include <QtCore/QVector>
00025 
00026 #include <kmimetype.h>
00027 #include <kpluginfactory.h>
00028 
00029 #define OKULAR_EXPORT_PLUGIN( classname, aboutdata ) \
00030     K_PLUGIN_FACTORY( classname ## Factory, registerPlugin< classname >(); ) \
00031     K_EXPORT_PLUGIN( classname ## Factory( aboutdata ) )
00032 
00033 class QMutex;
00034 class QPrinter;
00035 class QPrintDialog;
00036 class KIcon;
00037 
00038 namespace Okular {
00039 
00040 class Document;
00041 class DocumentFonts;
00042 class DocumentInfo;
00043 class DocumentSynopsis;
00044 class EmbeddedFile;
00045 class ExportFormatPrivate;
00046 class GeneratorPrivate;
00047 class Page;
00048 class PixmapRequest;
00049 class PixmapRequestPrivate;
00050 class TextPage;
00051 
00052 /* Note: on contents generation and asynchronous queries.
00053  * Many observers may want to request data syncronously or asynchronously.
00054  * - Sync requests. These should be done in-place.
00055  * - Async request must be done in real background. That usually means a
00056  *   thread, such as QThread derived classes.
00057  * Once contents are available, they must be immediately stored in the
00058  * Page they refer to, and a signal is emitted as soon as storing
00059  * (even for sync or async queries) has been done.
00060  */
00061 
00069 class OKULAR_EXPORT ExportFormat
00070 {
00071     public:
00072         typedef QList<ExportFormat> List;
00073 
00079         ExportFormat();
00080 
00087         ExportFormat( const QString &description, const KMimeType::Ptr &mimeType );
00088 
00096         ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType );
00097 
00101         ~ExportFormat();
00102 
00106         ExportFormat( const ExportFormat &other );
00107 
00111         ExportFormat& operator=( const ExportFormat &other );
00112 
00116         QString description() const;
00117 
00121         KMimeType::Ptr mimeType() const;
00122 
00126         KIcon icon() const;
00127 
00134         bool isNull() const;
00135 
00139         enum StandardExportFormat
00140         {
00141             PlainText,         
00142             PDF                
00143         };
00144 
00148         static ExportFormat standardFormat( StandardExportFormat type );
00149 
00150         bool operator==( const ExportFormat &other ) const;
00151 
00152         bool operator!=( const ExportFormat &other ) const;
00153 
00154     private:
00156         friend class ExportFormatPrivate;
00158         QSharedDataPointer<ExportFormatPrivate> d;
00159 };
00160 
00177 class OKULAR_EXPORT Generator : public QObject
00178 {
00180     friend class PixmapGenerationThread;
00181     friend class TextPageGenerationThread;
00183 
00184     Q_OBJECT
00185 
00186     public:
00191         enum GeneratorFeature
00192         {
00193             Threaded,
00194             TextExtraction,    
00195             ReadRawData,       
00196             FontInfo,          
00197             PageSizes,         
00198             PrintNative,       
00199             PrintPostscript,   
00200             PrintToFile        
00201         };
00202 
00206         Generator( QObject *parent, const QVariantList &args );
00207 
00211         virtual ~Generator();
00212 
00219         virtual bool loadDocument( const QString & fileName, QVector< Page * > & pagesVector ) = 0;
00220 
00229         virtual bool loadDocumentFromData( const QByteArray & fileData, QVector< Page * > & pagesVector );
00230 
00237         bool closeDocument();
00238 
00243         virtual bool canGeneratePixmap() const;
00244 
00249         virtual void generatePixmap( PixmapRequest * request );
00250 
00255         virtual bool canGenerateTextPage() const;
00256 
00267         virtual void generateTextPage( Page * page );
00268 
00273         virtual const DocumentInfo * generateDocumentInfo();
00274 
00279         virtual const DocumentSynopsis * generateDocumentSynopsis();
00280 
00288         virtual FontInfo::List fontsForPage( int page );
00289 
00294         virtual const QList<EmbeddedFile*> * embeddedFiles() const;
00295 
00299         enum PageSizeMetric
00300         {
00301           None,   
00302           Points  
00303         };
00304 
00308         virtual PageSizeMetric pagesSizeMetric() const;
00309 
00314         virtual bool isAllowed( Permission action ) const;
00315 
00319         virtual void rotationChanged( Rotation orientation, Rotation oldOrientation );
00320 
00324         virtual PageSize::List pageSizes() const;
00325 
00329         virtual void pageSizeChanged( const PageSize &pageSize, const PageSize &oldPageSize );
00330 
00334         virtual bool print( QPrinter &printer );
00335 
00340         virtual QVariant metaData( const QString &key, const QVariant &option ) const;
00341 
00345         virtual ExportFormat::List exportFormats() const;
00346 
00351         virtual bool exportTo( const QString &fileName, const ExportFormat &format );
00352 
00356         bool hasFeature( GeneratorFeature feature ) const;
00357 
00358     Q_SIGNALS:
00365         void error( const QString &message, int duration );
00366 
00373         void warning( const QString &message, int duration );
00374 
00381         void notice( const QString &message, int duration );
00382 
00383     protected:
00388         void signalPixmapRequestDone( PixmapRequest * request );
00389 
00396         virtual bool doCloseDocument() = 0;
00397 
00405         virtual QImage image( PixmapRequest *page );
00406 
00413         virtual TextPage* textPage( Page *page );
00414 
00418         const Document * document() const;
00419 
00423         void setFeature( GeneratorFeature feature, bool on = true );
00424 
00429         QVariant documentMetaData( const QString &key, const QVariant &option = QVariant() ) const;
00430 
00434         QMutex* userMutex() const;
00435 
00436     protected:
00438         Generator( GeneratorPrivate &dd, QObject *parent, const QVariantList &args );
00439         Q_DECLARE_PRIVATE( Generator )
00440         GeneratorPrivate *d_ptr;
00441 
00442         friend class Document;
00444 
00445     private:
00446         Q_DISABLE_COPY( Generator )
00447 
00448         Q_PRIVATE_SLOT( d_func(), void pixmapGenerationFinished() )
00449         Q_PRIVATE_SLOT( d_func(), void textpageGenerationFinished() )
00450 };
00451 
00455 class OKULAR_EXPORT PixmapRequest
00456 {
00457     friend class Document;
00458     friend class DocumentPrivate;
00459 
00460     public:
00471         PixmapRequest( int id, int pageNumber, int width, int height, int priority, bool asynchronous );
00472 
00476         ~PixmapRequest();
00477 
00481         int id() const;
00482 
00486         int pageNumber() const;
00487 
00491         int width() const;
00492 
00496         int height() const;
00497 
00502         int priority() const;
00503 
00511         bool asynchronous() const;
00512 
00516         Page *page() const;
00517 
00518     private:
00519         Q_DISABLE_COPY( PixmapRequest )
00520 
00521         friend class PixmapRequestPrivate;
00522         PixmapRequestPrivate* const d;
00523 };
00524 
00525 }
00526 
00527 #ifndef QT_NO_DEBUG_STREAM
00528 OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::PixmapRequest &req );
00529 #endif
00530 
00531 #endif

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdegraphics

Skip menu "kdegraphics"
  • okular
Generated for kdegraphics by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal