mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-12 20:51:17 +00:00
Merge the new functions of ThreadedGenerator into the base Generator: this means that there's again only a single base Generator that can provide the multithreading for the generation of contents, just pixmaps for now.
svn path=/trunk/playground/graphics/okular/; revision=628853
This commit is contained in:
parent
763bb521b7
commit
6068c76df6
|
@ -627,7 +627,7 @@ void Document::Private::sendGeneratorRequest()
|
||||||
cleanupPixmapMemory( pixmapBytes );
|
cleanupPixmapMemory( pixmapBytes );
|
||||||
|
|
||||||
// submit the request to the generator
|
// submit the request to the generator
|
||||||
if ( m_generator->canRequestPixmap() )
|
if ( m_generator->canGeneratePixmap() )
|
||||||
{
|
{
|
||||||
kWarning() << "sending request id=" << request->id() << " " <<request->width() << "x" << request->height() << "@" << request->pageNumber() << " async == " << request->asynchronous() << endl;
|
kWarning() << "sending request id=" << request->id() << " " <<request->width() << "x" << request->height() << "@" << request->pageNumber() << " async == " << request->asynchronous() << endl;
|
||||||
m_pixmapRequestsStack.removeAll ( request );
|
m_pixmapRequestsStack.removeAll ( request );
|
||||||
|
@ -635,7 +635,7 @@ void Document::Private::sendGeneratorRequest()
|
||||||
if ( (int)m_rotation % 2 )
|
if ( (int)m_rotation % 2 )
|
||||||
request->swap();
|
request->swap();
|
||||||
|
|
||||||
m_generator->requestPixmap( request );
|
m_generator->generatePixmap( request );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// pino (7/4/2006): set the polling interval from 10 to 30
|
// pino (7/4/2006): set the polling interval from 10 to 30
|
||||||
|
@ -1328,7 +1328,7 @@ void Document::requestTextPage( uint page )
|
||||||
|
|
||||||
// Memory management for TextPages
|
// Memory management for TextPages
|
||||||
|
|
||||||
d->m_generator->requestTextPage( kp );
|
d->m_generator->generateTextPage( kp );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::addPageAnnotation( int page, Annotation * annotation )
|
void Document::addPageAnnotation( int page, Annotation * annotation )
|
||||||
|
@ -2148,7 +2148,7 @@ QStringList Document::supportedMimeTypes() const
|
||||||
void Document::requestDone( PixmapRequest * req )
|
void Document::requestDone( PixmapRequest * req )
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if ( !d->m_generator->canRequestPixmap() )
|
if ( !d->m_generator->canGeneratePixmap() )
|
||||||
kDebug() << "requestDone with generator not in READY state." << endl;
|
kDebug() << "requestDone with generator not in READY state." << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,23 +14,82 @@
|
||||||
|
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
#include "generator.h"
|
#include "generator.h"
|
||||||
|
#include "page.h"
|
||||||
|
#include "threadedgenerator_p.h"
|
||||||
|
|
||||||
using namespace Okular;
|
using namespace Okular;
|
||||||
|
|
||||||
class Generator::Private
|
class Generator::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private()
|
Private( Generator *parent )
|
||||||
: m_document( 0 )
|
: m_document( 0 ),
|
||||||
|
m_generator( parent ),
|
||||||
|
mPixmapReady( true ),
|
||||||
|
mTextPageReady( true )
|
||||||
{
|
{
|
||||||
|
mPixmapGenerationThread = new PixmapGenerationThread( m_generator );
|
||||||
|
QObject::connect( mPixmapGenerationThread, SIGNAL( finished() ),
|
||||||
|
m_generator, SLOT( pixmapGenerationFinished() ),
|
||||||
|
Qt::QueuedConnection );
|
||||||
|
|
||||||
|
mTextPageGenerationThread = new TextPageGenerationThread( m_generator );
|
||||||
|
QObject::connect( mTextPageGenerationThread, SIGNAL( finished() ),
|
||||||
|
m_generator, SLOT( textpageGenerationFinished() ),
|
||||||
|
Qt::QueuedConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Private()
|
||||||
|
{
|
||||||
|
if ( mPixmapGenerationThread )
|
||||||
|
mPixmapGenerationThread->wait();
|
||||||
|
|
||||||
|
delete mPixmapGenerationThread;
|
||||||
|
|
||||||
|
if ( mTextPageGenerationThread )
|
||||||
|
mTextPageGenerationThread->wait();
|
||||||
|
|
||||||
|
delete mTextPageGenerationThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pixmapGenerationFinished();
|
||||||
|
void textpageGenerationFinished();
|
||||||
|
|
||||||
Document * m_document;
|
Document * m_document;
|
||||||
QSet< GeneratorFeature > m_features;
|
QSet< GeneratorFeature > m_features;
|
||||||
|
Generator *m_generator;
|
||||||
|
PixmapGenerationThread *mPixmapGenerationThread;
|
||||||
|
TextPageGenerationThread *mTextPageGenerationThread;
|
||||||
|
bool mPixmapReady;
|
||||||
|
bool mTextPageReady;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void Generator::Private::pixmapGenerationFinished()
|
||||||
|
{
|
||||||
|
PixmapRequest *request = mPixmapGenerationThread->request();
|
||||||
|
mPixmapGenerationThread->endGeneration();
|
||||||
|
|
||||||
|
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( mPixmapGenerationThread->image() ) ) );
|
||||||
|
|
||||||
|
mPixmapReady = true;
|
||||||
|
|
||||||
|
m_generator->signalPixmapRequestDone( request );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Generator::Private::textpageGenerationFinished()
|
||||||
|
{
|
||||||
|
Page *page = mTextPageGenerationThread->page();
|
||||||
|
mTextPageGenerationThread->endGeneration();
|
||||||
|
|
||||||
|
mTextPageReady = true;
|
||||||
|
|
||||||
|
if ( mTextPageGenerationThread->textPage() )
|
||||||
|
page->setTextPage( mTextPageGenerationThread->textPage() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Generator::Generator()
|
Generator::Generator()
|
||||||
: d( new Private )
|
: d( new Private( this ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,33 +103,56 @@ bool Generator::loadDocumentFromData( const QByteArray &, QVector< Page * > & )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Generator::canRequestPixmap() const
|
bool Generator::canGeneratePixmap() const
|
||||||
{
|
{
|
||||||
return canGeneratePixmap();
|
return d->mPixmapReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Generator::requestPixmap( PixmapRequest *request )
|
void Generator::generatePixmap( PixmapRequest *request )
|
||||||
{
|
{
|
||||||
generatePixmap( request );
|
d->mPixmapReady = false;
|
||||||
}
|
|
||||||
|
|
||||||
bool Generator::canRequestTextPage() const
|
if ( hasFeature( Threaded ) )
|
||||||
{
|
{
|
||||||
return canGenerateTextPage();
|
d->mPixmapGenerationThread->startGeneration( request );
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void Generator::requestTextPage( Page *page )
|
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( image( request ) ) ) );
|
||||||
{
|
|
||||||
generateSyncTextPage( page );
|
d->mPixmapReady = true;
|
||||||
|
|
||||||
|
d->m_generator->signalPixmapRequestDone( request );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Generator::canGenerateTextPage() const
|
bool Generator::canGenerateTextPage() const
|
||||||
{
|
{
|
||||||
return true;
|
return d->mTextPageReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Generator::generateSyncTextPage( Page* )
|
void Generator::generateTextPage( Page *page )
|
||||||
{
|
{
|
||||||
|
d->mTextPageReady = false;
|
||||||
|
|
||||||
|
if ( hasFeature( Threaded ) )
|
||||||
|
{
|
||||||
|
d->mTextPageGenerationThread->startGeneration( page );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
page->setTextPage( textPage( page ) );
|
||||||
|
|
||||||
|
d->mTextPageReady = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage Generator::image( PixmapRequest * )
|
||||||
|
{
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
TextPage* Generator::textPage( Page* )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentInfo * Generator::generateDocumentInfo()
|
const DocumentInfo * Generator::generateDocumentInfo()
|
||||||
|
|
|
@ -141,6 +141,9 @@ class OKULAR_EXPORT ExportFormat
|
||||||
*/
|
*/
|
||||||
class OKULAR_EXPORT Generator : public QObject
|
class OKULAR_EXPORT Generator : public QObject
|
||||||
{
|
{
|
||||||
|
friend class PixmapGenerationThread;
|
||||||
|
friend class TextPageGenerationThread;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -150,6 +153,7 @@ class OKULAR_EXPORT Generator : public QObject
|
||||||
*/
|
*/
|
||||||
enum GeneratorFeature
|
enum GeneratorFeature
|
||||||
{
|
{
|
||||||
|
Threaded,
|
||||||
TextExtraction, ///< Whether the Generator can extract text from the document in the form of TextPage's
|
TextExtraction, ///< Whether the Generator can extract text from the document in the form of TextPage's
|
||||||
ReadRawData, ///< Whether the Generator can read a document directly from its raw data.
|
ReadRawData, ///< Whether the Generator can read a document directly from its raw data.
|
||||||
PageSizes ///< Whether the Generator can change the size of the document pages.
|
PageSizes ///< Whether the Generator can change the size of the document pages.
|
||||||
|
@ -200,26 +204,26 @@ class OKULAR_EXPORT Generator : public QObject
|
||||||
* This method returns whether the generator is ready to
|
* This method returns whether the generator is ready to
|
||||||
* handle a new pixmap request.
|
* handle a new pixmap request.
|
||||||
*/
|
*/
|
||||||
virtual bool canRequestPixmap() const;
|
virtual bool canGeneratePixmap() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method can be called to trigger the generation of
|
* This method can be called to trigger the generation of
|
||||||
* a new pixmap as described by @p request.
|
* a new pixmap as described by @p request.
|
||||||
*/
|
*/
|
||||||
virtual void requestPixmap( PixmapRequest * request );
|
virtual void generatePixmap( PixmapRequest * request );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns whether the generator is ready to
|
* This method returns whether the generator is ready to
|
||||||
* handle a new text page request.
|
* handle a new text page request.
|
||||||
*/
|
*/
|
||||||
virtual bool canRequestTextPage() const;
|
virtual bool canGenerateTextPage() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method can be called to trigger the generation of
|
* This method can be called to trigger the generation of
|
||||||
* a text page for the given @p page.
|
* a text page for the given @p page.
|
||||||
* @see TextPage
|
* @see TextPage
|
||||||
*/
|
*/
|
||||||
virtual void requestTextPage( Page * page );
|
virtual void generateTextPage( Page * page );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the general information object of the document or 0 if
|
* Returns the general information object of the document or 0 if
|
||||||
|
@ -340,30 +344,21 @@ class OKULAR_EXPORT Generator : public QObject
|
||||||
void signalPixmapRequestDone( PixmapRequest * request );
|
void signalPixmapRequestDone( PixmapRequest * request );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called to check whether the generator is ready
|
* Returns the image of the page as specified in
|
||||||
* to handle a new request for pixmap generation.
|
* the passed pixmap @p request.
|
||||||
*/
|
|
||||||
virtual bool canGeneratePixmap() const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called to create a pixmap for a page. The page number,
|
|
||||||
* width and height is encapsulated in the page @p request.
|
|
||||||
*/
|
|
||||||
virtual void generatePixmap( PixmapRequest * request ) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called to check whether the generator is ready
|
|
||||||
* to handle a new request for text page generation.
|
|
||||||
*/
|
|
||||||
virtual bool canGenerateTextPage() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called to create a so called 'text page' for the given @p page.
|
|
||||||
*
|
*
|
||||||
* A text page is an abstract description of the readable text of the page.
|
* @warning this method may be executed in its own separated thread if the
|
||||||
* It's used for search and text extraction.
|
* @ref Threaded is enabled!
|
||||||
*/
|
*/
|
||||||
virtual void generateSyncTextPage( Page *page );
|
virtual QImage image( PixmapRequest *page );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the text page for the given @p page.
|
||||||
|
*
|
||||||
|
* @warning this method may be executed in its own separated thread if the
|
||||||
|
* @ref Threaded is enabled!
|
||||||
|
*/
|
||||||
|
virtual TextPage* textPage( Page *page );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the document.
|
* Returns a pointer to the document.
|
||||||
|
@ -378,6 +373,9 @@ class OKULAR_EXPORT Generator : public QObject
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
Private* const d;
|
Private* const d;
|
||||||
|
|
||||||
|
Q_PRIVATE_SLOT( d, void pixmapGenerationFinished() )
|
||||||
|
Q_PRIVATE_SLOT( d, void textpageGenerationFinished() )
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -317,9 +317,9 @@ void TextDocumentGenerator::generatePixmap( Okular::PixmapRequest * request )
|
||||||
signalPixmapRequestDone( request );
|
signalPixmapRequestDone( request );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextDocumentGenerator::generateSyncTextPage( Okular::Page * page )
|
Okular::TextPage* TextDocumentGenerator::textPage( Okular::Page * page )
|
||||||
{
|
{
|
||||||
page->setTextPage( d->createTextPage( page->number() ) );
|
return d->createTextPage( page->number() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextDocumentGenerator::print( KPrinter& printer )
|
bool TextDocumentGenerator::print( KPrinter& printer )
|
||||||
|
|
|
@ -117,6 +117,10 @@ class OKULAR_EXPORT TextDocumentGenerator : public Generator
|
||||||
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
||||||
bool closeDocument();
|
bool closeDocument();
|
||||||
|
|
||||||
|
// [INHERITED] perform actions on document / pages
|
||||||
|
bool canGeneratePixmap() const;
|
||||||
|
void generatePixmap( Okular::PixmapRequest * request );
|
||||||
|
|
||||||
// [INHERITED] print document using already configured kprinter
|
// [INHERITED] print document using already configured kprinter
|
||||||
bool print( KPrinter& printer );
|
bool print( KPrinter& printer );
|
||||||
|
|
||||||
|
@ -128,10 +132,7 @@ class OKULAR_EXPORT TextDocumentGenerator : public Generator
|
||||||
const Okular::DocumentSynopsis* generateDocumentSynopsis();
|
const Okular::DocumentSynopsis* generateDocumentSynopsis();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// [INHERITED] perform actions on document / pages
|
Okular::TextPage* textPage( Okular::Page *page );
|
||||||
bool canGeneratePixmap() const;
|
|
||||||
void generatePixmap( Okular::PixmapRequest * request );
|
|
||||||
void generateSyncTextPage( Okular::Page * page );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Okular {
|
||||||
class PixmapGenerationThread : public QThread
|
class PixmapGenerationThread : public QThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PixmapGenerationThread( ThreadedGenerator *generator )
|
PixmapGenerationThread( Generator *generator )
|
||||||
: mGenerator( generator ), mRequest( 0 )
|
: mGenerator( generator ), mRequest( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class PixmapGenerationThread : public QThread
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThreadedGenerator *mGenerator;
|
Generator *mGenerator;
|
||||||
PixmapRequest *mRequest;
|
PixmapRequest *mRequest;
|
||||||
QImage mImage;
|
QImage mImage;
|
||||||
};
|
};
|
||||||
|
@ -63,7 +63,7 @@ class PixmapGenerationThread : public QThread
|
||||||
class TextPageGenerationThread : public QThread
|
class TextPageGenerationThread : public QThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextPageGenerationThread( ThreadedGenerator *generator )
|
TextPageGenerationThread( Generator *generator )
|
||||||
: mGenerator( generator ), mPage( 0 )
|
: mGenerator( generator ), mPage( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class TextPageGenerationThread : public QThread
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThreadedGenerator *mGenerator;
|
Generator *mGenerator;
|
||||||
Page *mPage;
|
Page *mPage;
|
||||||
TextPage *mTextPage;
|
TextPage *mTextPage;
|
||||||
};
|
};
|
||||||
|
|
|
@ -346,7 +346,7 @@ void CHMGenerator::additionalRequestData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHMGenerator::generateSyncTextPage( Okular::Page * page )
|
Okular::TextPage* CHMGenerator::textPage( Okular::Page * page )
|
||||||
{
|
{
|
||||||
syncLock.lock();
|
syncLock.lock();
|
||||||
double zoomP=Okular::Settings::zoomFactor();
|
double zoomP=Okular::Settings::zoomFactor();
|
||||||
|
@ -355,8 +355,8 @@ void CHMGenerator::generateSyncTextPage( Okular::Page * page )
|
||||||
preparePageForSyncOperation(zoom, m_file->getUrlForPage ( page->number() + 1 ));
|
preparePageForSyncOperation(zoom, m_file->getUrlForPage ( page->number() + 1 ));
|
||||||
Okular::TextPage *tp=new Okular::TextPage();
|
Okular::TextPage *tp=new Okular::TextPage();
|
||||||
recursiveExploreNodes( m_syncGen->htmlDocument(), tp);
|
recursiveExploreNodes( m_syncGen->htmlDocument(), tp);
|
||||||
page->setTextPage(tp);
|
|
||||||
syncLock.unlock();
|
syncLock.unlock();
|
||||||
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant CHMGenerator::metaData( const QString &key, const QVariant &option ) const
|
QVariant CHMGenerator::metaData( const QString &key, const QVariant &option ) const
|
||||||
|
|
|
@ -38,15 +38,16 @@ class CHMGenerator : public Okular::Generator
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
||||||
const Okular::DocumentFonts * generateDocumentFonts();
|
const Okular::DocumentFonts * generateDocumentFonts();
|
||||||
|
|
||||||
|
bool canGeneratePixmap() const;
|
||||||
|
void generatePixmap( Okular::PixmapRequest * request );
|
||||||
|
|
||||||
QVariant metaData( const QString & key, const QVariant & option ) const;
|
QVariant metaData( const QString & key, const QVariant & option ) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotCompleted();
|
void slotCompleted();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool canGeneratePixmap() const;
|
Okular::TextPage* textPage( Okular::Page *page );
|
||||||
void generatePixmap( Okular::PixmapRequest * request );
|
|
||||||
void generateSyncTextPage( Okular::Page * page );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void additionalRequestData ();
|
void additionalRequestData ();
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
OKULAR_EXPORT_PLUGIN(ComicBookGenerator)
|
OKULAR_EXPORT_PLUGIN(ComicBookGenerator)
|
||||||
|
|
||||||
ComicBookGenerator::ComicBookGenerator()
|
ComicBookGenerator::ComicBookGenerator()
|
||||||
: ThreadedGenerator()
|
: Generator()
|
||||||
{
|
{
|
||||||
|
setFeature( Threaded );
|
||||||
}
|
}
|
||||||
|
|
||||||
ComicBookGenerator::~ComicBookGenerator()
|
ComicBookGenerator::~ComicBookGenerator()
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
#ifndef GENERATOR_COMICBOOK_H
|
#ifndef GENERATOR_COMICBOOK_H
|
||||||
#define GENERATOR_COMICBOOK_H
|
#define GENERATOR_COMICBOOK_H
|
||||||
|
|
||||||
#include <okular/core/threadedgenerator.h>
|
#include <core/generator.h>
|
||||||
|
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
|
|
||||||
class ComicBookGenerator : public Okular::ThreadedGenerator
|
class ComicBookGenerator : public Okular::Generator
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ class DjVuGenerator : public Okular::Generator
|
||||||
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
||||||
bool closeDocument();
|
bool closeDocument();
|
||||||
|
|
||||||
|
// pixmap generation
|
||||||
|
bool canGeneratePixmap() const;
|
||||||
|
void generatePixmap( Okular::PixmapRequest * request );
|
||||||
|
|
||||||
// document information
|
// document information
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
const Okular::DocumentInfo * generateDocumentInfo();
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
||||||
|
@ -40,11 +44,6 @@ class DjVuGenerator : public Okular::Generator
|
||||||
private slots:
|
private slots:
|
||||||
void djvuImageGenerated( int page, const QImage & img );
|
void djvuImageGenerated( int page, const QImage & img );
|
||||||
|
|
||||||
protected:
|
|
||||||
// pixmap generation
|
|
||||||
bool canGeneratePixmap() const;
|
|
||||||
void generatePixmap( Okular::PixmapRequest * request );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadPages( QVector<Okular::Page*> & pagesVector, int rotation );
|
void loadPages( QVector<Okular::Page*> & pagesVector, int rotation );
|
||||||
Okular::ObjectRect* convertKDjVuLink( int page, KDjVu::Link * link ) const;
|
Okular::ObjectRect* convertKDjVuLink( int page, KDjVu::Link * link ) const;
|
||||||
|
|
|
@ -239,9 +239,9 @@ void DviGenerator::generatePixmap( Okular::PixmapRequest *request )
|
||||||
signalPixmapRequestDone( request );
|
signalPixmapRequestDone( request );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DviGenerator::generateSyncTextPage( Okular::Page* page )
|
Okular::TextPage* DviGenerator::textPage( Okular::Page *page )
|
||||||
{
|
{
|
||||||
kDebug() << "DviGenerator::generateSyncTextPage( Okular::Page * page )" << endl;
|
kDebug() << "DviGenerator::textPage( Okular::Page * page )" << endl;
|
||||||
dviPageInfo *pageInfo = new dviPageInfo();
|
dviPageInfo *pageInfo = new dviPageInfo();
|
||||||
pageSize ps;
|
pageSize ps;
|
||||||
|
|
||||||
|
@ -255,14 +255,15 @@ void DviGenerator::generateSyncTextPage( Okular::Page* page )
|
||||||
pageInfo->resolution = (double)(pageInfo->width)/ps.width().getLength_in_inch();
|
pageInfo->resolution = (double)(pageInfo->width)/ps.width().getLength_in_inch();
|
||||||
|
|
||||||
// get page text from m_dviRenderer
|
// get page text from m_dviRenderer
|
||||||
|
Okular::TextPage *ktp = 0;
|
||||||
if ( m_dviRenderer )
|
if ( m_dviRenderer )
|
||||||
{
|
{
|
||||||
m_dviRenderer->getText( pageInfo );
|
m_dviRenderer->getText( pageInfo );
|
||||||
|
|
||||||
Okular::TextPage *ktp = extractTextFromPage( pageInfo, page->totalOrientation() );
|
ktp = extractTextFromPage( pageInfo, page->totalOrientation() );
|
||||||
page->setTextPage( ktp );
|
|
||||||
}
|
}
|
||||||
delete pageInfo;
|
delete pageInfo;
|
||||||
|
return ktp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Okular::TextPage *DviGenerator::extractTextFromPage( dviPageInfo *pageInfo, int orientation )
|
Okular::TextPage *DviGenerator::extractTextFromPage( dviPageInfo *pageInfo, int orientation )
|
||||||
|
|
|
@ -29,17 +29,17 @@ class DviGenerator : public Okular::Generator
|
||||||
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
||||||
bool closeDocument();
|
bool closeDocument();
|
||||||
|
|
||||||
|
bool canGeneratePixmap() const;
|
||||||
|
void generatePixmap( Okular::PixmapRequest * request );
|
||||||
|
|
||||||
// document information
|
// document information
|
||||||
const Okular::DocumentInfo *generateDocumentInfo();
|
const Okular::DocumentInfo *generateDocumentInfo();
|
||||||
|
|
||||||
// table of contents
|
// table of contents
|
||||||
const Okular::DocumentSynopsis *generateDocumentSynopsis();
|
const Okular::DocumentSynopsis *generateDocumentSynopsis();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool canGeneratePixmap() const;
|
Okular::TextPage* textPage( Okular::Page *page );
|
||||||
void generatePixmap( Okular::PixmapRequest * request );
|
|
||||||
|
|
||||||
void generateSyncTextPage( Okular::Page * page );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_resolution;
|
double m_resolution;
|
||||||
|
|
|
@ -38,6 +38,10 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface, pu
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis() { return 0L; }
|
const Okular::DocumentSynopsis * generateDocumentSynopsis() { return 0L; }
|
||||||
const Okular::DocumentFonts * generateDocumentFonts() { return 0L; }
|
const Okular::DocumentFonts * generateDocumentFonts() { return 0L; }
|
||||||
|
|
||||||
|
// page contents generation
|
||||||
|
bool canGeneratePixmap() const;
|
||||||
|
void generatePixmap( Okular::PixmapRequest * request );
|
||||||
|
|
||||||
// page size management
|
// page size management
|
||||||
Okular::PageSize::List pageSizes() const;
|
Okular::PageSize::List pageSizes() const;
|
||||||
void pageSizeChanged( const Okular::PageSize &, const Okular::PageSize & );
|
void pageSizeChanged( const Okular::PageSize &, const Okular::PageSize & );
|
||||||
|
@ -61,11 +65,6 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface, pu
|
||||||
void slotPixmapGenerated(const QImage* img);
|
void slotPixmapGenerated(const QImage* img);
|
||||||
void slotAsyncPixmapGenerated(QPixmap * img);
|
void slotAsyncPixmapGenerated(QPixmap * img);
|
||||||
|
|
||||||
protected:
|
|
||||||
// page contents generation
|
|
||||||
bool canGeneratePixmap() const;
|
|
||||||
void generatePixmap( Okular::PixmapRequest * request ) ;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// conversion handling
|
// conversion handling
|
||||||
bool m_converted;
|
bool m_converted;
|
||||||
|
|
|
@ -21,9 +21,10 @@
|
||||||
OKULAR_EXPORT_PLUGIN(KIMGIOGenerator)
|
OKULAR_EXPORT_PLUGIN(KIMGIOGenerator)
|
||||||
|
|
||||||
KIMGIOGenerator::KIMGIOGenerator()
|
KIMGIOGenerator::KIMGIOGenerator()
|
||||||
: ThreadedGenerator()
|
: Generator()
|
||||||
{
|
{
|
||||||
setFeature( ReadRawData );
|
setFeature( ReadRawData );
|
||||||
|
setFeature( Threaded );
|
||||||
}
|
}
|
||||||
|
|
||||||
KIMGIOGenerator::~KIMGIOGenerator()
|
KIMGIOGenerator::~KIMGIOGenerator()
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
#ifndef _OKULAR_GENERATOR_KIMGIO_H_
|
#ifndef _OKULAR_GENERATOR_KIMGIO_H_
|
||||||
#define _OKULAR_GENERATOR_KIMGIO_H_
|
#define _OKULAR_GENERATOR_KIMGIO_H_
|
||||||
|
|
||||||
#include <okular/core/threadedgenerator.h>
|
#include <core/generator.h>
|
||||||
|
|
||||||
#include <QtGui/QImage>
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
class KIMGIOGenerator : public Okular::ThreadedGenerator
|
class KIMGIOGenerator : public Okular::Generator
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -678,22 +678,22 @@ void PDFGenerator::generatePixmap( Okular::PixmapRequest * request )
|
||||||
signalPixmapRequestDone( request );
|
signalPixmapRequestDone( request );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFGenerator::generateSyncTextPage( Okular::Page * page )
|
Okular::TextPage* PDFGenerator::textPage( Okular::Page *page )
|
||||||
{
|
{
|
||||||
kDebug() << "calling generateSyncTextPage( Okular::Page * page )" << endl;
|
kDebug() << "calling textPage( Okular::Page * page )" << endl;
|
||||||
// build a TextList...
|
// build a TextList...
|
||||||
Poppler::Page *pp = pdfdoc->page( page->number() );
|
Poppler::Page *pp = pdfdoc->page( page->number() );
|
||||||
docLock.lock();
|
docLock.lock();
|
||||||
QList<Poppler::TextBox*> textList = pp->textList((Poppler::Page::Rotation)page->orientation());
|
QList<Poppler::TextBox*> textList = pp->textList((Poppler::Page::Rotation)page->orientation());
|
||||||
docLock.unlock();
|
docLock.unlock();
|
||||||
delete pp;
|
delete pp;
|
||||||
// ..and attach it to the page
|
|
||||||
|
|
||||||
const double pageWidth = ( page->rotation() % 2 ? page->height() : page->width() );
|
const double pageWidth = ( page->rotation() % 2 ? page->height() : page->width() );
|
||||||
const double pageHeight = ( page->rotation() % 2 ? page->width() : page->height() );
|
const double pageHeight = ( page->rotation() % 2 ? page->width() : page->height() );
|
||||||
|
|
||||||
page->setTextPage( abstractTextPage(textList, pageHeight, pageWidth, (Poppler::Page::Rotation)page->orientation()));
|
Okular::TextPage *tp = abstractTextPage(textList, pageHeight, pageWidth, (Poppler::Page::Rotation)page->orientation());
|
||||||
qDeleteAll(textList);
|
qDeleteAll(textList);
|
||||||
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PDFGenerator::print( KPrinter& printer )
|
bool PDFGenerator::print( KPrinter& printer )
|
||||||
|
|
|
@ -70,6 +70,10 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface
|
||||||
// [INHERITED] document information
|
// [INHERITED] document information
|
||||||
bool isAllowed( Okular::Permissions permissions ) const;
|
bool isAllowed( Okular::Permissions permissions ) const;
|
||||||
|
|
||||||
|
// [INHERITED] perform actions on document / pages
|
||||||
|
bool canGeneratePixmap() const;
|
||||||
|
void generatePixmap( Okular::PixmapRequest * request );
|
||||||
|
|
||||||
// [INHERITED] print page using an already configured kprinter
|
// [INHERITED] print page using an already configured kprinter
|
||||||
bool print( KPrinter& printer );
|
bool print( KPrinter& printer );
|
||||||
|
|
||||||
|
@ -84,15 +88,13 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface
|
||||||
Okular::ExportFormat::List exportFormats() const;
|
Okular::ExportFormat::List exportFormats() const;
|
||||||
bool exportTo( const QString &fileName, const Okular::ExportFormat &format );
|
bool exportTo( const QString &fileName, const Okular::ExportFormat &format );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Okular::TextPage* textPage( Okular::Page *page );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// (async related) receive data from the generator thread
|
// (async related) receive data from the generator thread
|
||||||
void threadFinished();
|
void threadFinished();
|
||||||
|
|
||||||
protected:
|
|
||||||
bool canGeneratePixmap() const;
|
|
||||||
void generatePixmap( Okular::PixmapRequest * request );
|
|
||||||
void generateSyncTextPage( Okular::Page * page );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init(QVector<Okular::Page*> & pagesVector, const QString &walletKey);
|
bool init(QVector<Okular::Page*> & pagesVector, const QString &walletKey);
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,10 @@ static QDateTime convertTIFFDateTime( const char* tiffdate )
|
||||||
OKULAR_EXPORT_PLUGIN(TIFFGenerator)
|
OKULAR_EXPORT_PLUGIN(TIFFGenerator)
|
||||||
|
|
||||||
TIFFGenerator::TIFFGenerator()
|
TIFFGenerator::TIFFGenerator()
|
||||||
: Okular::ThreadedGenerator(),
|
: Okular::Generator(),
|
||||||
d( new Private ), m_docInfo( 0 )
|
d( new Private ), m_docInfo( 0 )
|
||||||
{
|
{
|
||||||
|
setFeature( Threaded );
|
||||||
}
|
}
|
||||||
|
|
||||||
TIFFGenerator::~TIFFGenerator()
|
TIFFGenerator::~TIFFGenerator()
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
#ifndef _OKULAR_GENERATOR_TIFF_H_
|
#ifndef _OKULAR_GENERATOR_TIFF_H_
|
||||||
#define _OKULAR_GENERATOR_TIFF_H_
|
#define _OKULAR_GENERATOR_TIFF_H_
|
||||||
|
|
||||||
#include <okular/core/threadedgenerator.h>
|
#include <core/generator.h>
|
||||||
|
|
||||||
class TIFFGenerator : public Okular::ThreadedGenerator
|
class TIFFGenerator : public Okular::Generator
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -651,21 +651,13 @@ bool XpsGenerator::closeDocument()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XpsGenerator::canGeneratePixmap() const
|
QImage XpsGenerator::image( Okular::PixmapRequest * request )
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void XpsGenerator::generatePixmap( Okular::PixmapRequest * request )
|
|
||||||
{
|
{
|
||||||
QSize size( (int)request->page()->width(), (int)request->page()->height() );
|
QSize size( (int)request->page()->width(), (int)request->page()->height() );
|
||||||
QImage image( size, QImage::Format_RGB32 );
|
QImage image( size, QImage::Format_RGB32 );
|
||||||
XpsPage *pageToRender = m_xpsFile->page( request->page()->number() );
|
XpsPage *pageToRender = m_xpsFile->page( request->page()->number() );
|
||||||
pageToRender->renderToImage( &image );
|
pageToRender->renderToImage( &image );
|
||||||
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( image ) ) );
|
return image;
|
||||||
|
|
||||||
// signal that the request has been accomplished
|
|
||||||
signalPixmapRequestDone( request );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * XpsGenerator::generateDocumentInfo()
|
const Okular::DocumentInfo * XpsGenerator::generateDocumentInfo()
|
||||||
|
|
|
@ -213,8 +213,7 @@ class XpsGenerator : public Okular::Generator
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
const Okular::DocumentInfo * generateDocumentInfo();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool canGeneratePixmap() const;
|
QImage image( Okular::PixmapRequest *page );
|
||||||
void generatePixmap( Okular::PixmapRequest * request );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XpsFile *m_xpsFile;
|
XpsFile *m_xpsFile;
|
||||||
|
|
Loading…
Reference in a new issue