2004-12-10 16:04:45 +00:00
|
|
|
/***************************************************************************
|
2005-11-18 20:48:01 +00:00
|
|
|
* Copyright (C) 2004-5 by Enrico Ros <eros.kde@email.it> *
|
2006-05-08 20:12:04 +00:00
|
|
|
* Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
|
2004-12-10 16:04:45 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
#ifndef _OKULAR_GENERATOR_H_
|
|
|
|
#define _OKULAR_GENERATOR_H_
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
#include <okular/core/okular_export.h>
|
2007-07-07 20:35:01 +00:00
|
|
|
#include <okular/core/fontinfo.h>
|
2007-01-03 14:30:48 +00:00
|
|
|
#include <okular/core/global.h>
|
2007-04-22 10:39:31 +00:00
|
|
|
#include <okular/core/pagesize.h>
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
#include <QtCore/QList>
|
|
|
|
#include <QtCore/QObject>
|
2007-04-12 20:43:37 +00:00
|
|
|
#include <QtCore/QSharedDataPointer>
|
2006-09-21 08:45:36 +00:00
|
|
|
#include <QtCore/QString>
|
2006-10-28 19:18:36 +00:00
|
|
|
#include <QtCore/QVariant>
|
2006-09-21 08:45:36 +00:00
|
|
|
#include <QtCore/QVector>
|
|
|
|
|
2006-07-01 22:17:53 +00:00
|
|
|
#include <kmimetype.h>
|
2007-12-02 20:57:24 +00:00
|
|
|
#include <kpluginfactory.h>
|
2006-09-21 08:45:36 +00:00
|
|
|
|
2007-12-02 20:57:24 +00:00
|
|
|
#define OKULAR_EXPORT_PLUGIN( classname, aboutdata ) \
|
|
|
|
K_PLUGIN_FACTORY( classname ## Factory, registerPlugin< classname >(); ) \
|
|
|
|
K_EXPORT_PLUGIN( classname ## Factory( aboutdata ) )
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2007-09-15 11:35:53 +00:00
|
|
|
class QMutex;
|
2007-10-15 23:01:27 +00:00
|
|
|
class QPrinter;
|
2007-11-26 21:43:54 +00:00
|
|
|
class QPrintDialog;
|
2006-10-25 15:35:53 +00:00
|
|
|
class KIcon;
|
2006-09-21 08:45:36 +00:00
|
|
|
|
|
|
|
namespace Okular {
|
|
|
|
|
2006-12-28 16:45:50 +00:00
|
|
|
class Document;
|
|
|
|
class DocumentFonts;
|
|
|
|
class DocumentInfo;
|
|
|
|
class DocumentSynopsis;
|
|
|
|
class EmbeddedFile;
|
2007-04-12 20:43:37 +00:00
|
|
|
class ExportFormatPrivate;
|
2007-04-20 17:17:44 +00:00
|
|
|
class GeneratorPrivate;
|
2006-09-21 08:45:36 +00:00
|
|
|
class Page;
|
|
|
|
class PixmapRequest;
|
2007-09-30 21:44:31 +00:00
|
|
|
class PixmapRequestPrivate;
|
2006-10-23 23:03:02 +00:00
|
|
|
class TextPage;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2007-01-04 15:22:28 +00:00
|
|
|
/* Note: on contents generation and asynchronous queries.
|
|
|
|
* Many observers may want to request data syncronously or asynchronously.
|
2005-01-18 16:43:36 +00:00
|
|
|
* - Sync requests. These should be done in-place.
|
2004-12-21 12:38:52 +00:00
|
|
|
* - Async request must be done in real background. That usually means a
|
|
|
|
* thread, such as QThread derived classes.
|
|
|
|
* Once contents are available, they must be immediately stored in the
|
2006-09-21 08:45:36 +00:00
|
|
|
* Page they refer to, and a signal is emitted as soon as storing
|
2004-12-21 12:38:52 +00:00
|
|
|
* (even for sync or async queries) has been done.
|
|
|
|
*/
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
/**
|
|
|
|
* @short Defines an entry for the export menu
|
|
|
|
*
|
|
|
|
* This class encapsulates information about an export format.
|
2007-01-02 19:05:49 +00:00
|
|
|
* Every Generator can support 0 or more export formats which can be
|
2007-01-13 22:55:00 +00:00
|
|
|
* queried with @ref Generator::exportFormats().
|
2006-10-25 15:35:53 +00:00
|
|
|
*/
|
|
|
|
class OKULAR_EXPORT ExportFormat
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
public:
|
|
|
|
typedef QList<ExportFormat> List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an empty export format.
|
2007-03-10 20:51:50 +00:00
|
|
|
*
|
|
|
|
* @see isNull()
|
2006-10-25 17:43:15 +00:00
|
|
|
*/
|
|
|
|
ExportFormat();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new export format.
|
|
|
|
*
|
|
|
|
* @param description The i18n'ed description of the format.
|
|
|
|
* @param mimeType The supported mime type of the format.
|
|
|
|
*/
|
|
|
|
ExportFormat( const QString &description, const KMimeType::Ptr &mimeType );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new export format.
|
|
|
|
*
|
|
|
|
* @param icon The icon used in the GUI for this format.
|
|
|
|
* @param description The i18n'ed description of the format.
|
|
|
|
* @param mimeType The supported mime type of the format.
|
|
|
|
*/
|
|
|
|
ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the export format.
|
|
|
|
*/
|
|
|
|
~ExportFormat();
|
|
|
|
|
2007-01-02 19:05:49 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2006-10-25 17:43:15 +00:00
|
|
|
ExportFormat( const ExportFormat &other );
|
2007-01-02 19:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2006-10-25 17:43:15 +00:00
|
|
|
ExportFormat& operator=( const ExportFormat &other );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the description of the format.
|
|
|
|
*/
|
|
|
|
QString description() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the mime type of the format.
|
|
|
|
*/
|
|
|
|
KMimeType::Ptr mimeType() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the icon for GUI representations of the format.
|
|
|
|
*/
|
|
|
|
KIcon icon() const;
|
|
|
|
|
2007-03-10 20:51:50 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the export format is null/valid.
|
|
|
|
*
|
|
|
|
* An ExportFormat is null if the mimetype is not valid or the
|
|
|
|
* description is empty, or both.
|
|
|
|
*/
|
|
|
|
bool isNull() const;
|
|
|
|
|
2007-03-10 21:32:09 +00:00
|
|
|
/**
|
2007-04-21 11:09:41 +00:00
|
|
|
* Type of standard export format.
|
2007-03-10 21:32:09 +00:00
|
|
|
*/
|
2007-04-21 11:09:41 +00:00
|
|
|
enum StandardExportFormat
|
|
|
|
{
|
|
|
|
PlainText, ///< Plain text
|
|
|
|
PDF ///< PDF, aka Portable Document Format
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a standard format for the specified @p type .
|
|
|
|
*/
|
|
|
|
static ExportFormat standardFormat( StandardExportFormat type );
|
2007-03-10 21:32:09 +00:00
|
|
|
|
2007-04-12 20:43:37 +00:00
|
|
|
bool operator==( const ExportFormat &other ) const;
|
|
|
|
|
|
|
|
bool operator!=( const ExportFormat &other ) const;
|
|
|
|
|
2006-10-25 17:43:15 +00:00
|
|
|
private:
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @cond PRIVATE
|
2007-04-12 20:43:37 +00:00
|
|
|
friend class ExportFormatPrivate;
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @endcond
|
2007-04-12 20:43:37 +00:00
|
|
|
QSharedDataPointer<ExportFormatPrivate> d;
|
2006-10-25 15:35:53 +00:00
|
|
|
};
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
/**
|
|
|
|
* @short [Abstract Class] The information generator.
|
|
|
|
*
|
2007-01-20 14:51:43 +00:00
|
|
|
* Most of class members are virtuals and some of them pure virtual. The pure
|
|
|
|
* virtuals provide the minimal functionalities for a Generator, that is being
|
|
|
|
* able to generate QPixmap for the Page 's of the Document.
|
2004-12-10 16:04:45 +00:00
|
|
|
*
|
2007-01-20 14:51:43 +00:00
|
|
|
* Implementing the other functions will make the Generator able to provide
|
|
|
|
* more contents and/or functionalities (like text extraction).
|
|
|
|
*
|
|
|
|
* Generation/query is requested by the Document class only, and that
|
|
|
|
* class stores the resulting data into Page s. The data will then be
|
|
|
|
* displayed by the GUI components (PageView, ThumbnailList, etc..).
|
|
|
|
*
|
|
|
|
* @see PrintInterface, ConfigInterface, GuiInterface
|
2004-12-10 16:04:45 +00:00
|
|
|
*/
|
2006-05-08 20:12:04 +00:00
|
|
|
class OKULAR_EXPORT Generator : public QObject
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @cond PRIVATE
|
2007-01-31 18:31:19 +00:00
|
|
|
friend class PixmapGenerationThread;
|
|
|
|
friend class TextPageGenerationThread;
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @endcond
|
2007-01-31 18:31:19 +00:00
|
|
|
|
2006-06-10 12:59:09 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
public:
|
2007-01-20 14:51:43 +00:00
|
|
|
/**
|
|
|
|
* Describe the possible optional features that a Generator can
|
|
|
|
* provide.
|
|
|
|
*/
|
2007-01-12 22:49:14 +00:00
|
|
|
enum GeneratorFeature
|
|
|
|
{
|
2007-01-31 18:31:19 +00:00
|
|
|
Threaded,
|
2007-01-17 11:58:20 +00:00
|
|
|
TextExtraction, ///< Whether the Generator can extract text from the document in the form of TextPage's
|
2007-01-17 18:02:53 +00:00
|
|
|
ReadRawData, ///< Whether the Generator can read a document directly from its raw data.
|
2007-07-07 20:35:01 +00:00
|
|
|
FontInfo, ///< Whether the Generator can provide information about the fonts used in the document
|
2007-11-26 21:43:54 +00:00
|
|
|
PageSizes, ///< Whether the Generator can change the size of the document pages.
|
|
|
|
PrintNative, ///< Whether the Generator supports native cross-platform printing (QPainter-based).
|
|
|
|
PrintPostscript, ///< Whether the Generator supports postscript-based file printing.
|
|
|
|
PrintToFile ///< Whether the Generator supports export to PDF & PS through the Print Dialog
|
2007-01-12 22:49:14 +00:00
|
|
|
};
|
|
|
|
|
2006-10-20 16:51:46 +00:00
|
|
|
/**
|
2006-10-22 11:25:08 +00:00
|
|
|
* Creates a new generator.
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2007-12-02 20:57:24 +00:00
|
|
|
Generator( QObject *parent, const QVariantList &args );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the generator.
|
|
|
|
*/
|
|
|
|
virtual ~Generator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads the document with the given @p fileName and fills the
|
|
|
|
* @p pagesVector with the parsed pages.
|
|
|
|
*
|
|
|
|
* @returns true on success, false otherwise.
|
|
|
|
*/
|
2006-09-21 08:45:36 +00:00
|
|
|
virtual bool loadDocument( const QString & fileName, QVector< Page * > & pagesVector ) = 0;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2007-01-12 22:49:14 +00:00
|
|
|
/**
|
|
|
|
* Loads the document from the raw data @p fileData and fills the
|
|
|
|
* @p pagesVector with the parsed pages.
|
|
|
|
*
|
|
|
|
* @note the Generator has to have the feature @ref ReadRawData enabled
|
|
|
|
*
|
|
|
|
* @returns true on success, false otherwise.
|
|
|
|
*/
|
|
|
|
virtual bool loadDocumentFromData( const QByteArray & fileData, QVector< Page * > & pagesVector );
|
|
|
|
|
2006-10-20 16:51:46 +00:00
|
|
|
/**
|
|
|
|
* This method is called when the document is closed and not used
|
|
|
|
* any longer.
|
|
|
|
*
|
|
|
|
* @returns true on success, false otherwise.
|
|
|
|
*/
|
2007-10-08 16:46:51 +00:00
|
|
|
bool closeDocument();
|
2005-11-04 11:59:51 +00:00
|
|
|
|
2006-10-20 16:51:46 +00:00
|
|
|
/**
|
2007-01-24 15:06:45 +00:00
|
|
|
* This method returns whether the generator is ready to
|
|
|
|
* handle a new pixmap request.
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2007-01-31 18:31:19 +00:00
|
|
|
virtual bool canGeneratePixmap() const;
|
2005-11-04 11:59:51 +00:00
|
|
|
|
2006-10-20 16:51:46 +00:00
|
|
|
/**
|
2007-01-24 15:06:45 +00:00
|
|
|
* This method can be called to trigger the generation of
|
|
|
|
* a new pixmap as described by @p request.
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2007-01-31 18:31:19 +00:00
|
|
|
virtual void generatePixmap( PixmapRequest * request );
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2007-01-24 18:27:54 +00:00
|
|
|
/**
|
|
|
|
* This method returns whether the generator is ready to
|
|
|
|
* handle a new text page request.
|
|
|
|
*/
|
2007-01-31 18:31:19 +00:00
|
|
|
virtual bool canGenerateTextPage() const;
|
2007-01-24 18:27:54 +00:00
|
|
|
|
2006-10-20 16:51:46 +00:00
|
|
|
/**
|
2007-01-24 15:06:45 +00:00
|
|
|
* This method can be called to trigger the generation of
|
|
|
|
* a text page for the given @p page.
|
2007-01-31 21:10:00 +00:00
|
|
|
*
|
|
|
|
* The generation is done synchronous or asynchronous, depending
|
|
|
|
* on the @p type parameter and the capabilities of the
|
|
|
|
* generator (e.g. multithreading).
|
|
|
|
*
|
2007-01-24 15:06:45 +00:00
|
|
|
* @see TextPage
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2007-08-13 22:25:27 +00:00
|
|
|
virtual void generateTextPage( Page * page );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the general information object of the document or 0 if
|
|
|
|
* no information are available.
|
|
|
|
*/
|
|
|
|
virtual const DocumentInfo * generateDocumentInfo();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the 'table of content' object of the document or 0 if
|
|
|
|
* no table of content is available.
|
|
|
|
*/
|
|
|
|
virtual const DocumentSynopsis * generateDocumentSynopsis();
|
|
|
|
|
|
|
|
/**
|
2007-07-07 20:35:01 +00:00
|
|
|
* Returns the 'list of embedded fonts' object of the specified \page
|
|
|
|
* of the document.
|
|
|
|
*
|
|
|
|
* \param page a page of the document, starting from 1 - 0 indicates all
|
|
|
|
* the other fonts
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2007-07-07 20:35:01 +00:00
|
|
|
virtual FontInfo::List fontsForPage( int page );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the 'list of embedded files' object of the document or 0 if
|
|
|
|
* no list of embedded files is available.
|
|
|
|
*/
|
|
|
|
virtual const QList<EmbeddedFile*> * embeddedFiles() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This enum identifies the metric of the page size.
|
|
|
|
*/
|
|
|
|
enum PageSizeMetric
|
|
|
|
{
|
2007-01-02 17:45:32 +00:00
|
|
|
None, ///< The page size is not defined in a physical metric.
|
|
|
|
Points ///< The page size is given in 1/72 inches.
|
2006-10-20 16:51:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2007-01-13 22:55:00 +00:00
|
|
|
* This method returns the metric of the page size. Default is @ref None.
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
|
|
|
virtual PageSizeMetric pagesSizeMetric() const;
|
|
|
|
|
|
|
|
/**
|
2007-03-10 23:59:11 +00:00
|
|
|
* This method returns whether given @p action (@ref Permission) is
|
2006-10-20 16:51:46 +00:00
|
|
|
* allowed in this document.
|
|
|
|
*/
|
2007-03-10 23:59:11 +00:00
|
|
|
virtual bool isAllowed( Permission action ) const;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2006-10-20 16:51:46 +00:00
|
|
|
/**
|
|
|
|
* This method is called when the orientation has been changed by the user.
|
|
|
|
*/
|
2007-01-05 17:09:47 +00:00
|
|
|
virtual void rotationChanged( Rotation orientation, Rotation oldOrientation );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
2007-01-05 23:12:06 +00:00
|
|
|
* Returns the list of supported page sizes.
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2007-01-05 23:12:06 +00:00
|
|
|
virtual PageSize::List pageSizes() const;
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
2007-01-05 23:12:06 +00:00
|
|
|
* This method is called when the page size has been changed by the user.
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2007-01-05 23:12:06 +00:00
|
|
|
virtual void pageSizeChanged( const PageSize &pageSize, const PageSize &oldPageSize );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called to print the document to the given @p printer.
|
|
|
|
*/
|
2007-10-15 23:01:27 +00:00
|
|
|
virtual bool print( QPrinter &printer );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method returns the meta data of the given @p key with the given @p option
|
|
|
|
* of the document.
|
|
|
|
*/
|
2006-10-28 19:18:36 +00:00
|
|
|
virtual QVariant metaData( const QString &key, const QVariant &option ) const;
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of additional supported export formats.
|
|
|
|
*/
|
2006-10-25 15:35:53 +00:00
|
|
|
virtual ExportFormat::List exportFormats() const;
|
2006-10-20 16:51:46 +00:00
|
|
|
|
|
|
|
/**
|
2006-10-25 15:35:53 +00:00
|
|
|
* This method is called to export the document in the given @p format and save it
|
|
|
|
* under the given @p fileName. The format must be one of the supported export formats.
|
2006-10-20 16:51:46 +00:00
|
|
|
*/
|
2006-10-25 15:35:53 +00:00
|
|
|
virtual bool exportTo( const QString &fileName, const ExportFormat &format );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
2007-01-12 22:49:14 +00:00
|
|
|
/**
|
|
|
|
* Query for the specified @p feature.
|
|
|
|
*/
|
2007-01-26 16:35:30 +00:00
|
|
|
bool hasFeature( GeneratorFeature feature ) const;
|
2007-01-12 22:49:14 +00:00
|
|
|
|
2006-10-20 16:51:46 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
2006-12-28 16:58:56 +00:00
|
|
|
* This signal should be emitted whenever an error occurred in the generator.
|
2006-10-20 16:51:46 +00:00
|
|
|
*
|
|
|
|
* @param message The message which should be shown to the user.
|
|
|
|
* @param duration The time that the message should be shown to the user.
|
|
|
|
*/
|
|
|
|
void error( const QString &message, int duration );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This signal should be emitted whenever the user should be warned.
|
|
|
|
*
|
|
|
|
* @param message The message which should be shown to the user.
|
|
|
|
* @param duration The time that the message should be shown to the user.
|
|
|
|
*/
|
|
|
|
void warning( const QString &message, int duration );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This signal should be emitted whenever the user should be noticed.
|
|
|
|
*
|
|
|
|
* @param message The message which should be shown to the user.
|
|
|
|
* @param duration The time that the message should be shown to the user.
|
|
|
|
*/
|
|
|
|
void notice( const QString &message, int duration );
|
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
|
|
|
|
2005-11-04 11:59:51 +00:00
|
|
|
protected:
|
2006-10-20 16:51:46 +00:00
|
|
|
/**
|
2007-01-13 22:55:00 +00:00
|
|
|
* This method must be called when the pixmap request triggered by generatePixmap()
|
2006-10-20 16:51:46 +00:00
|
|
|
* has been finished.
|
|
|
|
*/
|
2007-01-29 08:17:45 +00:00
|
|
|
void signalPixmapRequestDone( PixmapRequest * request );
|
2006-10-20 16:51:46 +00:00
|
|
|
|
2007-10-08 16:46:51 +00:00
|
|
|
/**
|
|
|
|
* This method is called when the document is closed and not used
|
|
|
|
* any longer.
|
|
|
|
*
|
|
|
|
* @returns true on success, false otherwise.
|
|
|
|
*/
|
|
|
|
virtual bool doCloseDocument() = 0;
|
|
|
|
|
2007-01-24 15:06:45 +00:00
|
|
|
/**
|
2007-01-31 18:31:19 +00:00
|
|
|
* Returns the image of the page as specified in
|
|
|
|
* the passed pixmap @p request.
|
|
|
|
*
|
|
|
|
* @warning this method may be executed in its own separated thread if the
|
|
|
|
* @ref Threaded is enabled!
|
2007-01-24 18:27:54 +00:00
|
|
|
*/
|
2007-01-31 18:31:19 +00:00
|
|
|
virtual QImage image( PixmapRequest *page );
|
2007-01-24 18:27:54 +00:00
|
|
|
|
2007-01-24 15:06:45 +00:00
|
|
|
/**
|
2007-01-31 18:31:19 +00:00
|
|
|
* Returns the text page for the given @p page.
|
2007-01-24 15:06:45 +00:00
|
|
|
*
|
2007-01-31 18:31:19 +00:00
|
|
|
* @warning this method may be executed in its own separated thread if the
|
|
|
|
* @ref Threaded is enabled!
|
2007-01-24 15:06:45 +00:00
|
|
|
*/
|
2007-01-31 18:31:19 +00:00
|
|
|
virtual TextPage* textPage( Page *page );
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2006-10-22 11:25:08 +00:00
|
|
|
/**
|
|
|
|
* Returns a pointer to the document.
|
|
|
|
*/
|
2007-03-17 12:11:41 +00:00
|
|
|
const Document * document() const;
|
2006-10-22 11:25:08 +00:00
|
|
|
|
2007-01-26 16:35:30 +00:00
|
|
|
/**
|
|
|
|
* Toggle the @p feature .
|
|
|
|
*/
|
|
|
|
void setFeature( GeneratorFeature feature, bool on = true );
|
|
|
|
|
2007-09-14 22:16:00 +00:00
|
|
|
/**
|
|
|
|
* Request a meta data of the Document, if available, like an internal
|
|
|
|
* setting.
|
|
|
|
*/
|
|
|
|
QVariant documentMetaData( const QString &key, const QVariant &option = QVariant() ) const;
|
|
|
|
|
2007-09-15 11:35:53 +00:00
|
|
|
/**
|
|
|
|
* Return the pointer to a mutex the generator can use freely.
|
|
|
|
*/
|
|
|
|
QMutex* userMutex() const;
|
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
protected:
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @cond PRIVATE
|
2007-12-02 20:57:24 +00:00
|
|
|
Generator( GeneratorPrivate &dd, QObject *parent, const QVariantList &args );
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_DECLARE_PRIVATE( Generator )
|
|
|
|
GeneratorPrivate *d_ptr;
|
2007-01-31 18:31:19 +00:00
|
|
|
|
2007-04-20 17:26:04 +00:00
|
|
|
friend class Document;
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @endcond PRIVATE
|
2007-04-20 17:26:04 +00:00
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY( Generator )
|
|
|
|
|
|
|
|
Q_PRIVATE_SLOT( d_func(), void pixmapGenerationFinished() )
|
|
|
|
Q_PRIVATE_SLOT( d_func(), void textpageGenerationFinished() )
|
2004-12-22 18:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Describes a pixmap type request.
|
|
|
|
*/
|
2006-10-25 15:35:53 +00:00
|
|
|
class OKULAR_EXPORT PixmapRequest
|
2006-07-01 22:17:53 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
friend class Document;
|
2007-09-30 21:44:31 +00:00
|
|
|
friend class DocumentPrivate;
|
2006-10-25 17:43:15 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a new pixmap request.
|
|
|
|
*
|
|
|
|
* @param id The observer id.
|
|
|
|
* @param pageNumber The page number.
|
|
|
|
* @param width The width of the page.
|
|
|
|
* @param height The height of the page.
|
|
|
|
* @param priority The priority of the request.
|
|
|
|
* @param asynchronous The mode of generation.
|
|
|
|
*/
|
|
|
|
PixmapRequest( int id, int pageNumber, int width, int height, int priority, bool asynchronous );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the pixmap request.
|
|
|
|
*/
|
|
|
|
~PixmapRequest();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the observer id of the request.
|
|
|
|
*/
|
|
|
|
int id() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the page number of the request.
|
|
|
|
*/
|
|
|
|
int pageNumber() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the page width of the requested pixmap.
|
|
|
|
*/
|
|
|
|
int width() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the page height of the requested pixmap.
|
|
|
|
*/
|
|
|
|
int height() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the priority (less it better, 0 is maximum) of the
|
|
|
|
* request.
|
|
|
|
*/
|
|
|
|
int priority() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the generation should be done synchronous or
|
|
|
|
* asynchronous.
|
|
|
|
*
|
|
|
|
* If asynchronous, the pixmap is created in a thread and the observer
|
|
|
|
* is notified when the job is done.
|
|
|
|
*/
|
|
|
|
bool asynchronous() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a pointer to the page where the pixmap shall be generated for.
|
|
|
|
*/
|
|
|
|
Page *page() const;
|
|
|
|
|
2007-09-15 13:16:30 +00:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY( PixmapRequest )
|
|
|
|
|
2007-09-30 21:44:31 +00:00
|
|
|
friend class PixmapRequestPrivate;
|
|
|
|
PixmapRequestPrivate* const d;
|
2006-07-01 22:17:53 +00:00
|
|
|
};
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
}
|
|
|
|
|
2007-07-30 23:58:04 +00:00
|
|
|
#ifndef QT_NO_DEBUG_STREAM
|
2007-11-04 23:31:36 +00:00
|
|
|
OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::PixmapRequest &req );
|
2007-07-30 23:58:04 +00:00
|
|
|
#endif
|
2006-10-22 13:34:47 +00:00
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
#endif
|